Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the issue where flags that require special handling were being overwritten. #2613

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a sufficient test. The issue was the snake case being overwritten not support for snakeCase

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields we get from yargs will include both snake_case and camelCase.

'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
Loading