Create .backstage-version file

Signed-off-by: Vincenzo Scamporlino <me@vinzscam.dev>
This commit is contained in:
Vincenzo Scamporlino
2021-10-20 14:12:02 +02:00
parent 3e6762ba3f
commit 4ebc9fd277
4 changed files with 17 additions and 5 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/create-app': patch
---
Add .bsversion file
`@backstage/create-app` will create a new `.bsversion` file containing the version of `@backstage/create-app` that has been used for creating the application.
+3 -3
View File
@@ -30,7 +30,7 @@ import {
templatingTask,
} from './lib/tasks';
export default async (cmd: Command): Promise<void> => {
export default async (cmd: Command, version: string): Promise<void> => {
/* eslint-disable-next-line no-restricted-syntax */
const paths = findPaths(__dirname);
@@ -82,7 +82,7 @@ export default async (cmd: Command): Promise<void> => {
await checkPathExistsTask(appDir);
Task.section('Preparing files');
await templatingTask(templateDir, cmd.path, answers);
await templatingTask(templateDir, cmd.path, answers, version);
} else {
// Template to temporary location, and then move files
@@ -93,7 +93,7 @@ export default async (cmd: Command): Promise<void> => {
await createTemporaryAppFolderTask(tempDir);
Task.section('Preparing files');
await templatingTask(templateDir, tempDir, answers);
await templatingTask(templateDir, tempDir, answers, version);
Task.section('Moving to final location');
await moveAppTask(tempDir, appDir, answers.name);
+1 -1
View File
@@ -38,7 +38,7 @@ const main = (argv: string[]) => {
'--skip-install',
'Skip the install and builds steps after creating the app',
)
.action(createApp);
.action(cmd => createApp(cmd, version));
program.parse(argv);
};
+6 -1
View File
@@ -19,7 +19,7 @@ import fs from 'fs-extra';
import handlebars from 'handlebars';
import ora from 'ora';
import recursive from 'recursive-readdir';
import { basename, dirname, resolve as resolvePath } from 'path';
import { basename, dirname, join, resolve as resolvePath } from 'path';
import { exec as execCb } from 'child_process';
import { packageVersions } from './versions';
import { promisify } from 'util';
@@ -79,6 +79,7 @@ export async function templatingTask(
templateDir: string,
destinationDir: string,
context: any,
version: string,
) {
const files = await recursive(templateDir).catch(error => {
throw new Error(`Failed to read template directory: ${error.message}`);
@@ -125,6 +126,10 @@ export async function templatingTask(
});
}
}
const bsVersionFileName = '.bsversion';
await Task.forItem('creating', bsVersionFileName, () =>
fs.writeFile(join(destinationDir, bsVersionFileName), version),
);
}
/**