From ea8fa504dfabe9dba1b2108c33e614d52448f6c0 Mon Sep 17 00:00:00 2001 From: Tate Date: Fri, 29 Nov 2024 09:55:32 +0000 Subject: [PATCH 1/5] When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. --- packages/node-core/CHANGELOG.md | 3 +++ .../src/configure/configure.module.spec.ts | 2 ++ .../node-core/src/configure/configure.module.ts | 16 ++++++++++------ packages/node/CHANGELOG.md | 3 +++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index 6a4dd0af24..250747cb79 100644 --- a/packages/node-core/CHANGELOG.md +++ b/packages/node-core/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. + ## [15.0.3] - 2024-11-26 ### Fixed - Workers crashing because of lazy monitor write (#2607) diff --git a/packages/node-core/src/configure/configure.module.spec.ts b/packages/node-core/src/configure/configure.module.spec.ts index 0ec9c66c88..e54c8e9f54 100644 --- a/packages/node-core/src/configure/configure.module.spec.ts +++ b/packages/node-core/src/configure/configure.module.spec.ts @@ -93,7 +93,9 @@ describe('Configure', () => { const option = {headers: {'api-key': ''}}; const {primaryNetworkEndpoint} = yargsToIConfig({ 'primary-network-endpoint': 'https://example.com', + primaryNetworkEndpoint: 'https://example.com', 'primary-network-endpoint-config': JSON.stringify(option), + primaryNetworkEndpointConfig: JSON.stringify(option), }); expect(primaryNetworkEndpoint).toEqual(['https://example.com', option]); diff --git a/packages/node-core/src/configure/configure.module.ts b/packages/node-core/src/configure/configure.module.ts index 74d3c2c400..1f10973fb6 100644 --- a/packages/node-core/src/configure/configure.module.ts +++ b/packages/node-core/src/configure/configure.module.ts @@ -52,7 +52,7 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record return Object.entries(yargs).reduce((acc, [key, value]) => { if (['_', '$0'].includes(key)) return acc; - if (key === 'network-registry') { + if (isMatchFlag(key, ['network-registry'])) { try { value = JSON.parse(value as string); } catch (e) { @@ -61,7 +61,7 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record } // Merge network endpoints and possible endpoint configs - if (key === 'network-endpoint') { + if (isMatchFlag(key, ['network-endpoint'])) { const endpointConfig = processEndpointConfig(yargs['network-endpoint-config']); if (typeof value === 'string') { value = [value]; @@ -76,16 +76,16 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record ); } } - if (key === 'primary-network-endpoint') { + if (isMatchFlag(key, ['primary-network-endpoint'])) { const endpointConfig = processEndpointConfig(yargs['primary-network-endpoint-config']); value = [value, endpointConfig[0] ?? {}]; } - if (['network-endpoint-config', 'primary-network-endpoint-config'].includes(key)) return acc; + if (isMatchFlag(key, ['network-endpoint-config', 'primary-network-endpoint-config'])) return acc; - if (key === 'disable-historical' && value) { + if (isMatchFlag(key, ['disable-historical']) && value) { acc.historical = false; } - if (key === 'historical' && value === 'false') { + if (isMatchFlag(key, ['historical']) && value === 'false') { value = false; } @@ -94,6 +94,10 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record }, {} as any); } +function isMatchFlag(key: string, targets: string[]): boolean { + return targets.some((target) => key === target || key === camelCase(target)); +} + function warnDeprecations(argv: Args) { if (argv['subquery-name']) { logger.warn('Note that argument --subquery-name has been deprecated in favour of --db-schema'); diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index f6dc390e5b..666b9d7e95 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. + ## [5.4.2] - 2024-11-26 ### Fixed - Not using grouped events (#2607) From 63c52fc71cec0aa1164eff44a6eee06c1c3b4433 Mon Sep 17 00:00:00 2001 From: Tate Date: Fri, 29 Nov 2024 09:57:38 +0000 Subject: [PATCH 2/5] changlog --- packages/node-core/CHANGELOG.md | 2 +- packages/node/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index 250747cb79..80406734d9 100644 --- a/packages/node-core/CHANGELOG.md +++ b/packages/node-core/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. +- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error.(#2612) ## [15.0.3] - 2024-11-26 ### Fixed diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 666b9d7e95..767ccb7cd4 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. +- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error.(#2612) ## [5.4.2] - 2024-11-26 ### Fixed From d59293f049d9e6f009c9eaca44b1da0259c60475 Mon Sep 17 00:00:00 2001 From: Tate Date: Mon, 2 Dec 2024 03:50:21 +0000 Subject: [PATCH 3/5] some Improve --- .../src/configure/configure.module.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/node-core/src/configure/configure.module.ts b/packages/node-core/src/configure/configure.module.ts index 1f10973fb6..af4f1e1ef9 100644 --- a/packages/node-core/src/configure/configure.module.ts +++ b/packages/node-core/src/configure/configure.module.ts @@ -52,7 +52,9 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record return Object.entries(yargs).reduce((acc, [key, value]) => { if (['_', '$0'].includes(key)) return acc; - if (isMatchFlag(key, ['network-registry'])) { + const outputKey = nameMapping[key] ?? camelCase(key); + + if (outputKey === 'networkRegistry') { try { value = JSON.parse(value as string); } catch (e) { @@ -61,7 +63,7 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record } // Merge network endpoints and possible endpoint configs - if (isMatchFlag(key, ['network-endpoint'])) { + if (outputKey === 'networkEndpoint') { const endpointConfig = processEndpointConfig(yargs['network-endpoint-config']); if (typeof value === 'string') { value = [value]; @@ -76,28 +78,24 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record ); } } - if (isMatchFlag(key, ['primary-network-endpoint'])) { + if (outputKey === 'primaryNetworkEndpoint') { const endpointConfig = processEndpointConfig(yargs['primary-network-endpoint-config']); value = [value, endpointConfig[0] ?? {}]; } - if (isMatchFlag(key, ['network-endpoint-config', 'primary-network-endpoint-config'])) return acc; + if (['networkEndpointConfig', 'primaryNetworkEndpointConfig'].includes(outputKey)) return acc; - if (isMatchFlag(key, ['disable-historical']) && value) { + if (outputKey === 'disableHistorical' && value) { acc.historical = false; } - if (isMatchFlag(key, ['historical']) && value === 'false') { + if (outputKey === 'historical' && value === 'false') { value = false; } - acc[nameMapping[key] ?? camelCase(key)] = value; + acc[outputKey] = value; return acc; }, {} as any); } -function isMatchFlag(key: string, targets: string[]): boolean { - return targets.some((target) => key === target || key === camelCase(target)); -} - function warnDeprecations(argv: Args) { if (argv['subquery-name']) { logger.warn('Note that argument --subquery-name has been deprecated in favour of --db-schema'); From 651cc70930d07b8f1ec6aeb5dc24e272f0606b75 Mon Sep 17 00:00:00 2001 From: Tate Date: Mon, 2 Dec 2024 04:01:25 +0000 Subject: [PATCH 4/5] change log --- packages/node-core/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index 80406734d9..8f8b5ce40f 100644 --- a/packages/node-core/CHANGELOG.md +++ b/packages/node-core/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error.(#2612) +- Fixed the issue where flags that require special handling were being overwritten.(#2612) ## [15.0.3] - 2024-11-26 ### Fixed From c87544a775b7c837597131fb0878eb102d1bc152 Mon Sep 17 00:00:00 2001 From: Tate Date: Mon, 2 Dec 2024 07:42:23 +0000 Subject: [PATCH 5/5] Fix the use of an invalid CID in unit test --- packages/cli/src/controller/deploy-controller.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/controller/deploy-controller.test.ts b/packages/cli/src/controller/deploy-controller.test.ts index 32a7d4bb2c..f979e29a85 100644 --- a/packages/cli/src/controller/deploy-controller.test.ts +++ b/packages/cli/src/controller/deploy-controller.test.ts @@ -153,7 +153,7 @@ describe('CLI deploy, delete, promote', () => { it('reDeploy to Hosted Service', async () => { const {ipfs, org, projectName, type} = projectSpec; - const newIPFS = 'QmbKvrzwSmzTZi5jrhEpa6yDDHQXRURi5S4ztLgJLpBxAi'; + const newIPFS = 'Qmdr4yg98Fv8Yif3anjKVHhjuAKR665j6ekhWsfYUdkaCu'; const validator = await ipfsCID_validate(projectSpec.ipfs, testAuth, ROOT_API_URL_PROD); const deployOutput = await deployTestProject(validator, ipfs, org, projectName, testAuth, ROOT_API_URL_PROD);