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

Format Renovate config #111

Merged
merged 2 commits into from
Jun 24, 2020
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
5 changes: 5 additions & 0 deletions .changeset/light-tomatoes-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'skuba': patch
---

**configure:** Format Renovate config
16 changes: 10 additions & 6 deletions src/cli/configure/modules/renovate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ describe('renovateModule', () => {

it('preserves extended config', async () => {
const inputFiles = {
'.github/renovate.json5':
'{"extends": ["github>seek-oss/rynovate:non-critical"], "ignorePaths": []}',
'.github/renovate.json5': `{
"extends": ["github>seek-oss/rynovate:non-critical"],
"ignorePaths": []
}`,
};

const outputFiles = await executeModule(
Expand All @@ -98,9 +100,11 @@ describe('renovateModule', () => {
defaultOpts,
);

expect(outputFiles['.github/renovate.json5']).toBe(
inputFiles['.github/renovate.json5'],
);
expect(outputFiles['.github/renovate.json5']).toBe(`{
extends: ['github>seek-oss/rynovate:non-critical'],
ignorePaths: [],
}
`);
});

it('migrates extended config', async () => {
Expand All @@ -115,7 +119,7 @@ describe('renovateModule', () => {
);

expect(outputFiles['.github/renovate.json5']).toBe(
inputFiles['renovate.json'],
"{ extends: ['seek'] }\n",
);

expect(outputFiles['renovate.json']).toBeUndefined();
Expand Down
11 changes: 10 additions & 1 deletion src/cli/configure/modules/renovate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import prettier from 'prettier';

import { readBaseTemplateFile } from '../../../utils/template';
import { deleteFiles } from '../processing/deleteFiles';
import { withPackage } from '../processing/package';
Expand Down Expand Up @@ -26,7 +28,14 @@ export const renovateModule = async ({ type }: Options): Promise<Module> => {
]);

// allow customised Renovate configs that extend a SEEK configuration
return inputFile?.includes('seek') ? inputFile : configFile;
return inputFile?.includes('seek')
? prettier.format(inputFile, {
parser: 'json5',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
})
: configFile;
},

/**
Expand Down