From e46248a2a2fe87f6e78d1f7c650ea8629c69ae94 Mon Sep 17 00:00:00 2001 From: yoozo Date: Tue, 3 Dec 2024 06:41:28 +0800 Subject: [PATCH] Fixed the issue where flags that require special handling were being overwritten. (#2613) * When the `primary-network-endpoint` flag exists, it will report an "Invalid endpoint" error. * changlog * some Improve * change log * Fix the use of an invalid CID in unit test --- .../cli/src/controller/deploy-controller.test.ts | 2 +- 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 +++ 5 files changed, 18 insertions(+), 8 deletions(-) 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); diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index 6a4dd0af24..8f8b5ce40f 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 +- Fixed the issue where flags that require special handling were being overwritten.(#2612) + ## [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..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 (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 (key === 'network-endpoint') { + if (outputKey === 'networkEndpoint') { const endpointConfig = processEndpointConfig(yargs['network-endpoint-config']); if (typeof value === 'string') { value = [value]; @@ -76,20 +78,20 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record ); } } - if (key === 'primary-network-endpoint') { + if (outputKey === 'primaryNetworkEndpoint') { 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 (['networkEndpointConfig', 'primaryNetworkEndpointConfig'].includes(outputKey)) return acc; - if (key === 'disable-historical' && value) { + if (outputKey === 'disableHistorical' && value) { acc.historical = false; } - if (key === 'historical' && value === 'false') { + if (outputKey === 'historical' && value === 'false') { value = false; } - acc[nameMapping[key] ?? camelCase(key)] = value; + acc[outputKey] = value; return acc; }, {} as any); } diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index f6dc390e5b..767ccb7cd4 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.(#2612) + ## [5.4.2] - 2024-11-26 ### Fixed - Not using grouped events (#2607)