From 677bfc2dd00ef382abb8025d3e3632aaa08615f8 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 15 Nov 2021 16:32:46 +0100 Subject: [PATCH] fix comments Signed-off-by: Vincenzo Scamporlino --- .changeset/cyan-bottles-hug.md | 8 ++++++++ .changeset/healthy-kids-mate.md | 10 ++++++---- packages/cli-common/api-report.md | 4 +--- packages/cli-common/src/paths.ts | 4 +++- packages/cli/src/commands/versions/bump.test.ts | 10 +++++----- packages/cli/src/commands/versions/bump.ts | 4 ++-- packages/create-app/src/createApp.test.ts | 6 +++--- packages/create-app/src/lib/tasks.test.ts | 5 ++++- 8 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 .changeset/cyan-bottles-hug.md diff --git a/.changeset/cyan-bottles-hug.md b/.changeset/cyan-bottles-hug.md new file mode 100644 index 0000000000..7c2083c4ff --- /dev/null +++ b/.changeset/cyan-bottles-hug.md @@ -0,0 +1,8 @@ +--- +'@backstage/cli': patch +'@backstage/cli-common': patch +--- + +Keep backstage.json in sync + +The `versions:bump` script now takes care about updating the `version` property inside `backstage.json` file. The file is created if is not present. diff --git a/.changeset/healthy-kids-mate.md b/.changeset/healthy-kids-mate.md index 3ed8172199..10e8222a15 100644 --- a/.changeset/healthy-kids-mate.md +++ b/.changeset/healthy-kids-mate.md @@ -1,9 +1,11 @@ --- -'@backstage/cli': patch -'@backstage/cli-common': patch '@backstage/create-app': patch --- -Add .backstage-version file +Create backstage.json file -`@backstage/create-app` will create a new `.backstage.json` file containing the version of `@backstage/create-app` used for creating the application. +`@backstage/create-app` will create a new `backstage.json` file. At this point, the file will contain a `version` property, representing the version of `@backstage/create-app` used for creating the application. If the backstage's application has been bootstrapped using an older version of `@backstage/create-app`, the `backstage.json` file can be created and kept in sync, together with all the changes of the latest version of backstage, by running the following script: + +```bash +yarn backstage-cli versions:bump +``` diff --git a/packages/cli-common/api-report.md b/packages/cli-common/api-report.md index e100b40cc2..34f56c3f19 100644 --- a/packages/cli-common/api-report.md +++ b/packages/cli-common/api-report.md @@ -3,10 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -// Warning: (ae-missing-release-tag) "BACKSTAGE_JSON" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public -export const BACKSTAGE_JSON = '.backstage.json'; +export const BACKSTAGE_JSON = 'backstage.json'; // @public export function findPaths(searchDir: string): Paths; diff --git a/packages/cli-common/src/paths.ts b/packages/cli-common/src/paths.ts index 2f46fee27a..2b1ca34ca5 100644 --- a/packages/cli-common/src/paths.ts +++ b/packages/cli-common/src/paths.ts @@ -170,5 +170,7 @@ export function findPaths(searchDir: string): Paths { /** * The name of the backstage's config file + * + * @public */ -export const BACKSTAGE_JSON = '.backstage.json'; +export const BACKSTAGE_JSON = 'backstage.json'; diff --git a/packages/cli/src/commands/versions/bump.test.ts b/packages/cli/src/commands/versions/bump.test.ts index 6759928458..bc4049f1f4 100644 --- a/packages/cli/src/commands/versions/bump.test.ts +++ b/packages/cli/src/commands/versions/bump.test.ts @@ -252,9 +252,9 @@ describe('bumpBackstageJsonVersion', () => { jest.resetAllMocks(); }); - it('should bump version in .backstage.json', async () => { + it('should bump version in backstage.json', async () => { mockFs({ - '/.backstage.json': JSON.stringify({ version: '0.0.1' }), + '/backstage.json': JSON.stringify({ version: '0.0.1' }), }); paths.targetDir = '/'; const latest = '1.4.1'; @@ -276,11 +276,11 @@ describe('bumpBackstageJsonVersion', () => { await bumpBackstageJsonVersion(); - const json = await fs.readJson('/.backstage.json'); + const json = await fs.readJson('/backstage.json'); expect(json).toEqual({ version: '1.4.1' }); }); - it("should create .backstage.json if doesn't exist", async () => { + it("should create backstage.json if doesn't exist", async () => { mockFs({}); paths.targetDir = '/'; const latest = '1.4.1'; @@ -302,7 +302,7 @@ describe('bumpBackstageJsonVersion', () => { await bumpBackstageJsonVersion(); - const json = await fs.readJson('/.backstage.json'); + const json = await fs.readJson('/backstage.json'); expect(json).toEqual({ version: '1.4.1' }); }); }); diff --git a/packages/cli/src/commands/versions/bump.ts b/packages/cli/src/commands/versions/bump.ts index 0e37895cad..3898c1654a 100644 --- a/packages/cli/src/commands/versions/bump.ts +++ b/packages/cli/src/commands/versions/bump.ts @@ -296,8 +296,8 @@ export async function bumpBackstageJsonVersion() { console.log( chalk.yellow( typeof backstageJson === 'undefined' - ? 'Creating .backstage.json' - : 'Bumping version in .backstage.json', + ? `Creating ${BACKSTAGE_JSON}` + : `Bumping version in ${BACKSTAGE_JSON}`, ), ); diff --git a/packages/create-app/src/createApp.test.ts b/packages/create-app/src/createApp.test.ts index 7b3b8f124c..5e54fac31e 100644 --- a/packages/create-app/src/createApp.test.ts +++ b/packages/create-app/src/createApp.test.ts @@ -59,7 +59,7 @@ describe('command entrypoint', () => { test('should call expected tasks with no path option', async () => { const cmd = {} as unknown as Command; - await createApp(cmd); + await createApp(cmd, '1.0.0'); expect(checkAppExistsMock).toHaveBeenCalled(); expect(createTemporaryAppFolderMock).toHaveBeenCalled(); expect(templatingMock).toHaveBeenCalled(); @@ -69,7 +69,7 @@ describe('command entrypoint', () => { it('should call expected tasks with path option', async () => { const cmd = { path: 'myDirectory' } as unknown as Command; - await createApp(cmd); + await createApp(cmd, '1.0.0'); expect(checkPathExistsMock).toHaveBeenCalled(); expect(templatingMock).toHaveBeenCalled(); expect(buildAppMock).toHaveBeenCalled(); @@ -77,7 +77,7 @@ describe('command entrypoint', () => { it('should not call `buildAppTask` when `skipInstall` is supplied', async () => { const cmd = { skipInstall: true } as unknown as Command; - await createApp(cmd); + await createApp(cmd, '1.0.0'); expect(buildAppMock).not.toHaveBeenCalled(); }); }); diff --git a/packages/create-app/src/lib/tasks.test.ts b/packages/create-app/src/lib/tasks.test.ts index d69526cb49..24df97c694 100644 --- a/packages/create-app/src/lib/tasks.test.ts +++ b/packages/create-app/src/lib/tasks.test.ts @@ -195,9 +195,12 @@ describe('templatingTask', () => { name: 'SuperCoolBackstageInstance', dbTypeSqlite: true, }; - await templatingTask(templateDir, destinationDir, context); + await templatingTask(templateDir, destinationDir, context, '1.0.0'); expect(fs.existsSync('templatedApp/package.json')).toBe(true); expect(fs.existsSync('templatedApp/.dockerignore')).toBe(true); + await expect(fs.readJson('templatedApp/backstage.json')).resolves.toEqual({ + version: '1.0.0', + }); // catalog was populated with `context.name` expect( fs.readFileSync('templatedApp/catalog-info.yaml', 'utf-8'),