From 8bb78ffeba7f38ae4906e048f019b7280e572db3 Mon Sep 17 00:00:00 2001 From: bz888 Date: Thu, 12 Oct 2023 16:16:25 +1300 Subject: [PATCH 1/5] error handle on generate command --- packages/cli/src/commands/codegen/generate.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/codegen/generate.ts b/packages/cli/src/commands/codegen/generate.ts index 281c787897..186800f6c7 100644 --- a/packages/cli/src/commands/codegen/generate.ts +++ b/packages/cli/src/commands/codegen/generate.ts @@ -5,7 +5,7 @@ import fs from 'fs'; import path from 'path'; import {EventFragment, FunctionFragment} from '@ethersproject/abi/src.ts/fragments'; import {Command, Flags} from '@oclif/core'; -import {getProjectRootAndManifest} from '@subql/common'; +import {DEFAULT_TS_MANIFEST, getProjectRootAndManifest} from '@subql/common'; import {SubqlRuntimeDatasource as EthereumDs} from '@subql/types-ethereum'; import {parseContractPath} from 'typechain'; import { @@ -49,6 +49,9 @@ export default class Generate extends Command { const {abiPath, address, events, file, functions, startBlock} = flags; const projectPath = path.resolve(file ?? process.cwd()); + if (fs.existsSync(path.join(projectPath, DEFAULT_TS_MANIFEST))) { + throw new Error('generate does not yet support ts manifest'); + } const {manifests, root} = getProjectRootAndManifest(projectPath); const abiName = parseContractPath(abiPath).name; From d12ac1b11611a15b3cd7f4f608155e9f3b4a9df5 Mon Sep 17 00:00:00 2001 From: bz888 Date: Wed, 18 Oct 2023 12:54:28 +1300 Subject: [PATCH 2/5] update error handle on cli deployment commands --- packages/cli/src/commands/deployment/delete.ts | 4 +--- packages/cli/src/commands/deployment/deploy.ts | 2 +- packages/cli/src/commands/deployment/promote.ts | 8 +------- packages/cli/src/controller/publish-controller.ts | 10 ++++++++-- packages/cli/src/utils/utils.ts | 6 +++--- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/cli/src/commands/deployment/delete.ts b/packages/cli/src/commands/deployment/delete.ts index 03dba62b6e..2f26fb127d 100644 --- a/packages/cli/src/commands/deployment/delete.ts +++ b/packages/cli/src/commands/deployment/delete.ts @@ -30,9 +30,7 @@ export default class Delete extends Command { deploymentID = await valueOrPrompt(deploymentID, 'Enter deployment ID', 'Deployment ID is required'); this.log(`Removing deployment: ${deploymentID}`); - const delete_output = await deleteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD).catch( - (e) => this.error(e) - ); + const delete_output = await deleteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD); this.log(`Removed deployment: ${delete_output}`); } } diff --git a/packages/cli/src/commands/deployment/deploy.ts b/packages/cli/src/commands/deployment/deploy.ts index 2afe5ed0b1..cfcdba437f 100644 --- a/packages/cli/src/commands/deployment/deploy.ts +++ b/packages/cli/src/commands/deployment/deploy.ts @@ -181,7 +181,7 @@ export default class Deploy extends Command { queryAD, indexerAD, ROOT_API_URL_PROD - ).catch((e) => this.error(e)); + ); this.log(`Project: ${deploymentOutput.projectKey} \nStatus: ${chalk.blue(deploymentOutput.status)} \nDeploymentID: ${deploymentOutput.id} diff --git a/packages/cli/src/commands/deployment/promote.ts b/packages/cli/src/commands/deployment/promote.ts index 629b9b2b88..561a0c5f6e 100644 --- a/packages/cli/src/commands/deployment/promote.ts +++ b/packages/cli/src/commands/deployment/promote.ts @@ -30,13 +30,7 @@ export default class Promote extends Command { project_name = await valueOrPrompt(project_name, 'Enter project name', 'Project name is required'); deploymentID = await valueOrPrompt(deploymentID, 'Enter deployment ID', 'Deployment ID is required'); - const promote_output = await promoteDeployment( - org, - project_name, - authToken, - +deploymentID, - ROOT_API_URL_PROD - ).catch((e) => this.error(e)); + const promote_output = await promoteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD); this.log(`Promote deployment: ${promote_output} from Stage to Production`); } } diff --git a/packages/cli/src/controller/publish-controller.ts b/packages/cli/src/controller/publish-controller.ts index dd8c95efc0..bc9724117f 100644 --- a/packages/cli/src/controller/publish-controller.ts +++ b/packages/cli/src/controller/publish-controller.ts @@ -3,7 +3,13 @@ import fs from 'fs'; import path from 'path'; -import {ReaderFactory, IPFS_WRITE_ENDPOINT, isFileReference, validateCommonProjectManifest, mapToObject} from '@subql/common'; +import { + ReaderFactory, + IPFS_WRITE_ENDPOINT, + isFileReference, + validateCommonProjectManifest, + mapToObject, +} from '@subql/common'; import {parseAlgorandProjectManifest} from '@subql/common-algorand'; import {parseCosmosProjectManifest} from '@subql/common-cosmos'; import {parseEthereumProjectManifest} from '@subql/common-ethereum'; @@ -219,7 +225,7 @@ export async function uploadFile( } }) .catch((e) => { - throw new Error(`Publish project to default failed, ${e}`); + throw new Error(`ipfs write Publish project to default failed, ${e}`); }); fileMap.set(contents.path, pendingCid); diff --git a/packages/cli/src/utils/utils.ts b/packages/cli/src/utils/utils.ts index b5c8b734eb..d9bc5072d5 100644 --- a/packages/cli/src/utils/utils.ts +++ b/packages/cli/src/utils/utils.ts @@ -71,11 +71,11 @@ export async function checkToken(authToken_ENV: string, token_path: string): Pro } export function errorHandle(e: any, msg: string): Error { - if (axios.isAxiosError(e) as any) { + if ((axios.isAxiosError(e) as any) && e?.response?.data) { throw new Error(`${msg} ${e.response.data.message}`); - } else { - throw new Error(`${msg} ${e.message}`); } + + throw new Error(`${msg} ${e.message}`); } export function buildProjectKey(org: string, projectName: string): string { From bda4e8fc95acce9470b6682018dd3c2cc0204be4 Mon Sep 17 00:00:00 2001 From: bz888 Date: Wed, 18 Oct 2023 12:56:59 +1300 Subject: [PATCH 3/5] update changelog --- packages/cli/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index c557a2811f..fd5e036b44 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Update error handling on deployment commands (#2108) ## [4.0.4] - 2023-10-17 ### Fixed From 9527d126a763fe73fa3da0f0161ac9225187e082 Mon Sep 17 00:00:00 2001 From: bz888 Date: Wed, 18 Oct 2023 13:51:31 +1300 Subject: [PATCH 4/5] add catches --- packages/cli/src/commands/deployment/delete.ts | 4 +++- packages/cli/src/commands/deployment/deploy.ts | 2 +- packages/cli/src/commands/deployment/promote.ts | 8 +++++++- packages/cli/src/controller/publish-controller.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/deployment/delete.ts b/packages/cli/src/commands/deployment/delete.ts index 2f26fb127d..03dba62b6e 100644 --- a/packages/cli/src/commands/deployment/delete.ts +++ b/packages/cli/src/commands/deployment/delete.ts @@ -30,7 +30,9 @@ export default class Delete extends Command { deploymentID = await valueOrPrompt(deploymentID, 'Enter deployment ID', 'Deployment ID is required'); this.log(`Removing deployment: ${deploymentID}`); - const delete_output = await deleteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD); + const delete_output = await deleteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD).catch( + (e) => this.error(e) + ); this.log(`Removed deployment: ${delete_output}`); } } diff --git a/packages/cli/src/commands/deployment/deploy.ts b/packages/cli/src/commands/deployment/deploy.ts index cfcdba437f..2afe5ed0b1 100644 --- a/packages/cli/src/commands/deployment/deploy.ts +++ b/packages/cli/src/commands/deployment/deploy.ts @@ -181,7 +181,7 @@ export default class Deploy extends Command { queryAD, indexerAD, ROOT_API_URL_PROD - ); + ).catch((e) => this.error(e)); this.log(`Project: ${deploymentOutput.projectKey} \nStatus: ${chalk.blue(deploymentOutput.status)} \nDeploymentID: ${deploymentOutput.id} diff --git a/packages/cli/src/commands/deployment/promote.ts b/packages/cli/src/commands/deployment/promote.ts index 561a0c5f6e..629b9b2b88 100644 --- a/packages/cli/src/commands/deployment/promote.ts +++ b/packages/cli/src/commands/deployment/promote.ts @@ -30,7 +30,13 @@ export default class Promote extends Command { project_name = await valueOrPrompt(project_name, 'Enter project name', 'Project name is required'); deploymentID = await valueOrPrompt(deploymentID, 'Enter deployment ID', 'Deployment ID is required'); - const promote_output = await promoteDeployment(org, project_name, authToken, +deploymentID, ROOT_API_URL_PROD); + const promote_output = await promoteDeployment( + org, + project_name, + authToken, + +deploymentID, + ROOT_API_URL_PROD + ).catch((e) => this.error(e)); this.log(`Promote deployment: ${promote_output} from Stage to Production`); } } diff --git a/packages/cli/src/controller/publish-controller.ts b/packages/cli/src/controller/publish-controller.ts index bc9724117f..cbc5819b9f 100644 --- a/packages/cli/src/controller/publish-controller.ts +++ b/packages/cli/src/controller/publish-controller.ts @@ -225,7 +225,7 @@ export async function uploadFile( } }) .catch((e) => { - throw new Error(`ipfs write Publish project to default failed, ${e}`); + throw new Error(`Publish project to default failed, ${e}`); }); fileMap.set(contents.path, pendingCid); From 62eb9953543c4df0261813c8e5bcf9f5b12158c9 Mon Sep 17 00:00:00 2001 From: bz888 Date: Wed, 18 Oct 2023 14:02:50 +1300 Subject: [PATCH 5/5] trigger node --- packages/node/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index be750250f8..9afbb2aaa4 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -5,7 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - ## [3.0.7] - 2023-10-17 ### Changed - Update with node-core 6.0.3