Skip to content
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
34 changes: 34 additions & 0 deletions .yarn/versions/72503862.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/core": minor

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/cli"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function parseSingleValue(configuration: Configuration, path: string, valueBase:

switch (definition.type) {
case SettingsType.ANY:
return value;
return configUtils.getValueByTree(value);
case SettingsType.SHAPE:
return parseShape(configuration, path, valueBase, definition, folder);
case SettingsType.MAP:
Expand Down
16 changes: 16 additions & 0 deletions packages/yarnpkg-core/sources/configUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ export function getValue(value: unknown) {
return isResolvedRcFile(value) ? value[1] : value;
}

export function getValueByTree(valueBase: unknown): unknown {
const value = isResolvedRcFile(valueBase) ? valueBase[1] : valueBase;

if (Array.isArray(value))
return value.map(v => getValueByTree(v));

if (isObject(value)) {
const result: {[key: string]: unknown} = {};
for (const [propKey, propValue] of Object.entries(value))
result[propKey] = getValueByTree(propValue);
return result;
}

return value;
}

export function getSource(value: unknown) {
return isResolvedRcFile(value) ? value[0] : null;
}
61 changes: 61 additions & 0 deletions packages/yarnpkg-core/tests/Configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,26 @@ describe(`Configuration`, () => {
},
},
},
any: {
description: "",
type: "ANY",
default: "",
},
anyReset: {
description: "",
type: "ANY",
default: "",
},
anyExtend: {
description: "",
type: "ANY",
default: "",
},
anyHardReset: {
description: "",
type: "ANY",
default: "",
},
}`);

await initializeConfiguration({
Expand Down Expand Up @@ -700,6 +720,18 @@ describe(`Configuration`, () => {
mapHardReset: {
foo: {string: `foo`},
},
any: {
foo: {string: `foo`},
},
anyReset: {
foo: {string: `foo`},
},
anyExtend: {
foo: {string: `foo`},
},
anyHardReset: {
foo: {string: `foo`},
},
}, async dir => {
const workspaceDirectory = `${dir}/workspace` as PortablePath;
await xfs.mkdirPromise(workspaceDirectory);
Expand Down Expand Up @@ -772,6 +804,27 @@ describe(`Configuration`, () => {
bar: {number: 2, string: `bar`},
},
},
any: {
bar: {number: 2, string: `bar`},
},
anyReset: {
onConflict: `reset`,
value: {
bar: {number: 2, string: `bar`},
},
},
anyExtend: {
onConflict: `extend`,
value: {
bar: {number: 2, string: `bar`},
},
},
anyHardReset: {
onConflict: `hardReset`,
value: {
bar: {number: 2, string: `bar`},
},
},
}));

const workspaceDirectory2 = `${dir}/workspace/workspace` as PortablePath;
Expand All @@ -785,6 +838,9 @@ describe(`Configuration`, () => {
mapHardReset: {
baz: {string: `baz`},
},
anyHardReset: {
baz: {string: `baz`},
},
}));

const configuration = await Configuration.find(workspaceDirectory2, pluginConfiguration);
Expand Down Expand Up @@ -818,6 +874,11 @@ describe(`Configuration`, () => {
expect(configuration.get(`mapHardReset`)).toEqual(new Map([
[`baz`, new Map<string, any>([[`number`, 0], [`string`, `baz`]])],
]));

expect(configuration.get(`any`)).toEqual({bar: {number: `2`, string: `bar`}, foo: {string: `foo`}});
expect(configuration.get(`anyReset`)).toEqual({bar: {number: `2`, string: `bar`}});
expect(configuration.get(`anyExtend`)).toEqual({bar: {number: `2`, string: `bar`}, foo: {string: `foo`}});
expect(configuration.get(`anyHardReset`)).toEqual({baz: {string: `baz`}});
});
});
});
Expand Down