Skip to content

Commit

Permalink
refactor(cli): better gitignore management to make it easier when r…
Browse files Browse the repository at this point in the history
…unning the CLI on upstream backstage environments. (#2325)

refactor(cli): better gitignore management...

... to make it easier when running the CLI on upstream backstage environments.

Signed-off-by: David Festal <dfestal@redhat.com>
  • Loading branch information
davidfestal authored and schultzp2020 committed Oct 15, 2024
1 parent ba3380f commit 91ba24d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ export async function backend(opts: OptionValues): Promise<string> {
path.join(target, '.gitignore'),
`
*
${
opts.trackDynamicManifestAndLockFile
? `
!package.json
!yarn.lock
`,
`
: ''
}`,
);

const embeddedPeerDependencies: {
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/commands/export-dynamic-plugin/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ export async function applyDevOptions(
path.dirname(destFolderPath),
)}`,
);

if (!fs.existsSync(dynamicPluginsRootPath)) {
await fs.mkdirs(dynamicPluginsRootPath);
await fs.writeFile(
path.resolve(dynamicPluginsRootPath, '.gitignore'),
'*',
);
}
fs.rmSync(destFolderPath, { force: true, recursive: true });
fs.cpSync(target, destFolderPath, { recursive: true });
}
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export function registerScriptCommand(program: Command) {
'--scalprum-config <file>',
'Allows retrieving scalprum configuration from an external JSON file, instead of using a `scalprum` field of the `package.json`. Frontend plugins only.',
)
.option(
'--track-dynamic-manifest-and-lock-file',
'Adds the `package.json` and `yarn.lock` files, generated in the `dist-dynamic` folder of backend plugins, to source control. By default the whole `dist-dynamic` folder id git-ignored.',
false,
)
.action(lazy(() => import('./export-dynamic-plugin').then(m => m.command)));

command
Expand Down

0 comments on commit 91ba24d

Please sign in to comment.