cli: remove deprecated commands

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-06-23 11:24:13 +02:00
parent 67fe99a656
commit 96a82d9791
10 changed files with 19 additions and 464 deletions
+19
View File
@@ -0,0 +1,19 @@
---
'@backstage/cli': minor
---
**BREAKING**: Removed the following deprecated package commands:
- `app:build` - Use `package build` instead
- `app:serve` - Use `package start` instead
- `backend:build` - Use `package build` instead
- `backend:bundle` - Use `package build` instead
- `backend:dev` - Use `package start` instead
- `plugin:build` - Use `package build` instead
- `plugin:serve` - Use `package start` instead
- `build` - Use `package build` instead
- `lint` - Use `package lint` instead
- `prepack` - Use `package prepack` instead
- `postpack` - Use `package postpack` instead
In order to replace these you need to have [migrated to using package roles](https://backstage.io/docs/tutorials/package-role-migration).
-35
View File
@@ -1,35 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import { OptionValues } from 'commander';
import { buildBundle } from '../../lib/bundler';
import { getEnvironmentParallelism } from '../../lib/parallel';
import { loadCliConfig } from '../../lib/config';
import { paths } from '../../lib/paths';
export default async (opts: OptionValues) => {
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
await buildBundle({
entry: 'src/index',
parallelism: getEnvironmentParallelism(),
statsJsonEnabled: opts.stats,
...(await loadCliConfig({
args: opts.config,
fromPackage: name,
})),
});
};
-92
View File
@@ -1,92 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import chalk from 'chalk';
import uniq from 'lodash/uniq';
import { OptionValues } from 'commander';
import { serveBundle } from '../../lib/bundler';
import { loadCliConfig } from '../../lib/config';
import { paths } from '../../lib/paths';
import { Lockfile } from '../../lib/versioning';
import { forbiddenDuplicatesFilter, includedFilter } from '../versions/lint';
export default async (opts: OptionValues) => {
const lockFilePath = paths.resolveTargetRoot('yarn.lock');
if (fs.existsSync(lockFilePath)) {
try {
const lockfile = await Lockfile.load(lockFilePath);
const result = lockfile.analyze({
filter: includedFilter,
});
const problemPackages = [...result.newVersions, ...result.newRanges]
.map(({ name }) => name)
.filter(name => forbiddenDuplicatesFilter(name));
if (problemPackages.length > 0) {
console.log(
chalk.yellow(
`⚠️ Some of the following packages may be outdated or have duplicate installations:
${uniq(problemPackages).join(', ')}
`,
),
);
console.log(
chalk.yellow(
`⚠️ The following command may fix the issue, but it could also be an issue within one of your dependencies:
yarn backstage-cli versions:check --fix
`,
),
);
}
} catch (error) {
console.log(
chalk.yellow(
`⚠️ Unable to parse yarn.lock file properly:
${error}
skipping analyzer for outdated or duplicate installations
`,
),
);
}
} else {
console.log(
chalk.yellow(
`⚠️ Unable to find yarn.lock file:
skipping analyzer for outdated or duplicate installations
`,
),
);
}
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
const waitForExit = await serveBundle({
entry: 'src/index',
checksEnabled: opts.check,
...(await loadCliConfig({
args: opts.config,
fromPackage: name,
withFilteredKeys: true,
})),
});
await waitForExit();
};
@@ -1,26 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { OptionValues } from 'commander';
import { buildPackage, Output } from '../../lib/builder';
export default async (opts: OptionValues) => {
await buildPackage({
outputs: new Set([Output.cjs, Output.types]),
minify: opts.minify,
useApiExtractor: opts.experimentalTypeBuild,
});
};
@@ -1,72 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import os from 'os';
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import tar, { CreateOptions } from 'tar';
import { OptionValues } from 'commander';
import { createDistWorkspace } from '../../lib/packager';
import { paths } from '../../lib/paths';
import { getEnvironmentParallelism } from '../../lib/parallel';
import { buildPackage, Output } from '../../lib/builder';
const BUNDLE_FILE = 'bundle.tar.gz';
const SKELETON_FILE = 'skeleton.tar.gz';
export default async (opts: OptionValues) => {
const targetDir = paths.resolveTarget('dist');
const pkg = await fs.readJson(paths.resolveTarget('package.json'));
// We build the target package without generating type declarations.
await buildPackage({ outputs: new Set([Output.cjs]) });
const tmpDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'backstage-bundle'));
try {
await createDistWorkspace([pkg.name], {
targetDir: tmpDir,
buildDependencies: Boolean(opts.buildDependencies),
buildExcludes: [pkg.name],
parallelism: getEnvironmentParallelism(),
skeleton: SKELETON_FILE,
});
// We built the target backend package using the regular build process, but the result of
// that has now been packed into the dist workspace, so clean up the dist dir.
await fs.remove(targetDir);
await fs.mkdir(targetDir);
// Move out skeleton.tar.gz before we create the main bundle, no point having that included up twice.
await fs.move(
resolvePath(tmpDir, SKELETON_FILE),
resolvePath(targetDir, SKELETON_FILE),
);
// Create main bundle.tar.gz, with some tweaks to make it more likely hit Docker build cache.
await tar.create(
{
file: resolvePath(targetDir, BUNDLE_FILE),
cwd: tmpDir,
portable: true,
noMtime: true,
gzip: true,
} as CreateOptions & { noMtime: boolean },
[''],
);
} finally {
await fs.remove(tmpDir);
}
};
-36
View File
@@ -1,36 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import { OptionValues } from 'commander';
import { paths } from '../../lib/paths';
import { serveBackend } from '../../lib/bundler/backend';
export default async (opts: OptionValues) => {
// Cleaning dist/ before we start the dev process helps work around an issue
// where we end up with the entrypoint executing multiple times, causing
// a port bind conflict among other things.
await fs.remove(paths.resolveTarget('dist'));
const waitForExit = await serveBackend({
entry: 'src/index',
checksEnabled: opts.check,
inspectEnabled: opts.inspect,
inspectBrkEnabled: opts.inspectBrk,
});
await waitForExit();
};
-100
View File
@@ -183,53 +183,6 @@ export function registerMigrateCommand(program: Command) {
}
export function registerCommands(program: Command) {
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('app:build')
.description('Build an app for a production release [DEPRECATED]')
.option('--stats', 'Write bundle stats to output directory')
.option(...configOption)
.action(lazy(() => import('./app/build').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('app:serve')
.description('Serve an app for local development [DEPRECATED]')
.option('--check', 'Enable type checking and linting')
.option(...configOption)
.action(lazy(() => import('./app/serve').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('backend:build')
.description('Build a backend plugin [DEPRECATED]')
.option('--minify', 'Minify the generated code')
.option('--experimental-type-build', 'Enable experimental type build')
.action(lazy(() => import('./backend/build').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('backend:bundle')
.description('Bundle the backend into a deployment archive [DEPRECATED]')
.option(
'--build-dependencies',
'Build all local package dependencies before bundling the backend',
)
.action(lazy(() => import('./backend/bundle').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('backend:dev')
.description(
'Start local development server with HMR for the backend [DEPRECATED]',
)
.option('--check', 'Enable type checking and linting')
.option('--inspect', 'Enable debugger')
.option('--inspect-brk', 'Enable debugger with await to attach debugger')
// We don't actually use the config in the CLI, just pass them on to the NodeJS process
.option(...configOption)
.action(lazy(() => import('./backend/dev').then(m => m.default)));
program
.command('create')
.storeOptionsAsProperties(false)
@@ -268,22 +221,6 @@ export function registerCommands(program: Command) {
lazy(() => import('./create-plugin/createPlugin').then(m => m.default)),
);
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('plugin:build')
.description('Build a plugin [DEPRECATED]')
.option('--minify', 'Minify the generated code')
.option('--experimental-type-build', 'Enable experimental type build')
.action(lazy(() => import('./plugin/build').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('plugin:serve')
.description('Serves the dev/ folder of a plugin [DEPRECATED]')
.option('--check', 'Enable type checking and linting')
.option(...configOption)
.action(lazy(() => import('./plugin/serve').then(m => m.default)));
program
.command('plugin:diff')
.option('--check', 'Fail if changes are required')
@@ -291,27 +228,6 @@ export function registerCommands(program: Command) {
.description('Diff an existing plugin with the creation template')
.action(lazy(() => import('./plugin/diff').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('build')
.description('Build a package for publishing [DEPRECATED]')
.option('--outputs <formats>', 'List of formats to output [types,cjs,esm]')
.option('--minify', 'Minify the generated code')
.option('--experimental-type-build', 'Enable experimental type build')
.action(lazy(() => import('./oldBuild').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('lint [directories...]')
.option(
'--format <format>',
'Lint report output format',
'eslint-formatter-friendly',
)
.option('--fix', 'Attempt to automatically fix violations')
.description('Lint a package [DEPRECATED]')
.action(lazy(() => import('./lint').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('test')
@@ -400,22 +316,6 @@ export function registerCommands(program: Command) {
.description('Check Backstage package versioning')
.action(lazy(() => import('./versions/lint').then(m => m.default)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('prepack')
.description(
'Prepares a package for packaging before publishing [DEPRECATED]',
)
.action(lazy(() => import('./pack').then(m => m.pre)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('postpack')
.description(
'Restores the changes made by the prepack command [DEPRECATED]',
)
.action(lazy(() => import('./pack').then(m => m.post)));
// TODO(Rugvip): Deprecate in favor of package variant
program
.command('clean')
-41
View File
@@ -1,41 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { buildPackage, Output } from '../lib/builder';
import { OptionValues } from 'commander';
export default async (opts: OptionValues) => {
let outputs = new Set<Output>();
const { outputs: outputsStr } = opts as { outputs?: string };
if (outputsStr) {
for (const output of outputsStr.split(',') as (keyof typeof Output)[]) {
if (output in Output) {
outputs.add(Output[output]);
} else {
throw new Error(`Unknown output format: ${output}`);
}
}
} else {
outputs = new Set([Output.types, Output.esm, Output.cjs]);
}
await buildPackage({
outputs,
minify: opts.minify,
useApiExtractor: opts.experimentalTypeBuild,
});
};
-26
View File
@@ -1,26 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { OptionValues } from 'commander';
import { buildPackage, Output } from '../../lib/builder';
export default async (opts: OptionValues) => {
await buildPackage({
outputs: new Set([Output.esm, Output.types]),
minify: opts.minify,
useApiExtractor: opts.experimentalTypeBuild,
});
};
-36
View File
@@ -1,36 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fs from 'fs-extra';
import { OptionValues } from 'commander';
import { serveBundle } from '../../lib/bundler';
import { loadCliConfig } from '../../lib/config';
import { paths } from '../../lib/paths';
export default async (opts: OptionValues) => {
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
const waitForExit = await serveBundle({
entry: 'dev/index',
checksEnabled: opts.check,
...(await loadCliConfig({
args: opts.config,
fromPackage: name,
withFilteredKeys: true,
})),
});
await waitForExit();
};