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

fix(core): fix configuration extends overrides order #2387

Merged
merged 1 commit into from
Sep 6, 2023
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
10 changes: 6 additions & 4 deletions packages/core/src/__tests__/__snapshots__/auto.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ exports[`Auto createLabels should create the labels 1`] = `
}
`;

exports[`Auto should extend config 1`] = `
exports[`Auto should extend config and keep overrides 1`] = `
Object {
"baseBranch": "main",
"extends": "@artsy/auto-config/package.json",
"extends": "@artsy",
"labels": Array [
Object {
"changelogTitle": "💥 Breaking Change",
Expand Down Expand Up @@ -156,6 +156,7 @@ Object {
"releaseType": "patch",
},
],
"name": "extended",
"onlyPublishWithReleaseLabel": true,
"owner": "foo",
"plugins": Array [
Expand All @@ -169,10 +170,10 @@ Object {
}
`;

exports[`Auto should extend local config 1`] = `
exports[`Auto should extend local config and keep overrides 1`] = `
Object {
"baseBranch": "main",
"extends": "<PROJECT_ROOT>fake.json",
"extends": "./fake.json",
"labels": Array [
Object {
"changelogTitle": "💥 Breaking Change",
Expand Down Expand Up @@ -243,6 +244,7 @@ Object {
"releaseType": "patch",
},
],
"name": "extended",
"noVersionPrefix": true,
"owner": "foo",
"plugins": Array [
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/__tests__/auto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ describe("Auto", () => {
process.env.GH_TOKEN = "XXXX";
});

test("should extend config", async () => {
search.mockReturnValueOnce({ config: { ...defaults, extends: "@artsy" } });
test("should extend config and keep overrides", async () => {
search.mockReturnValueOnce({ config: { ...defaults, extends: "@artsy", name: 'extended' } });
importMock.mockImplementation((path) =>
path === "@artsy/auto-config/package.json"
? { auto: { onlyPublishWithReleaseLabel: true } }
? { auto: { onlyPublishWithReleaseLabel: true }, name: '@artsy' }
: undefined
);

Expand All @@ -204,14 +204,14 @@ describe("Auto", () => {
expect(process.exit).toHaveBeenCalled();
});

test("should extend local config", async () => {
test("should extend local config and keep overrides", async () => {
const orig = process.cwd;
process.cwd = () => "/foo/";
search.mockReturnValueOnce({
config: { ...defaults, extends: "./fake.json" },
config: { ...defaults, extends: "./fake.json", name: 'extended' },
});
importMock.mockImplementation((path) =>
path === "/foo/fake.json" ? { noVersionPrefix: true } : undefined
path === "/foo/fake.json" ? { noVersionPrefix: true, name: 'fake' } : undefined
);

const auto = new Auto();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export default class Config {

if (rawConfig.extends) {
rawConfig = merge(
rawConfig,
await this.loadExtendConfig(rawConfig.extends)
await this.loadExtendConfig(rawConfig.extends),
rawConfig
);
}

Expand Down