Skip to content

Commit

Permalink
Fixed the issue where flags that require special handling were being …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
yoozo authored Dec 2, 2024
1 parent f9276d0 commit e46248a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/controller/deploy-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions packages/node-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions packages/node-core/src/configure/configure.module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ describe('Configure', () => {
const option = {headers: {'api-key': '<your-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]);
Expand Down
16 changes: 9 additions & 7 deletions packages/node-core/src/configure/configure.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record<string, string>
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) {
Expand All @@ -61,7 +63,7 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record<string, string>
}

// 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];
Expand All @@ -76,20 +78,20 @@ export function yargsToIConfig(yargs: Args, nameMapping: Record<string, string>
);
}
}
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);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e46248a

Please sign in to comment.