chore: added deprecation warnings and removing build-image command that has been deprecated for 6 months. think it's fine to remove this now.
Co-authored-by: Johan Haals <johan.haals@gmail.com> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': minor
|
||||
---
|
||||
|
||||
Remove the `backend:build-image` command from the CLI and added more deprecation warnings to other deprecated fields like `--lax` and `remove-plugin`
|
||||
@@ -20,8 +20,17 @@ import { buildBundle } from '../../lib/bundler';
|
||||
import { parseParallel, PARALLEL_ENV_VAR } from '../../lib/parallel';
|
||||
import { loadCliConfig } from '../../lib/config';
|
||||
import { paths } from '../../lib/paths';
|
||||
import chalk from 'chalk';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
if (cmd.lax) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'[DEPRECATED] - The lax argument is deprecated and will be removed in the future.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
|
||||
await buildBundle({
|
||||
entry: 'src/index',
|
||||
|
||||
@@ -1,95 +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 { Command } from 'commander';
|
||||
import { yellow } from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
import { join as joinPath, relative as relativePath } from 'path';
|
||||
import { createDistWorkspace } from '../../lib/packager';
|
||||
import { paths } from '../../lib/paths';
|
||||
import { run } from '../../lib/run';
|
||||
import { parseParallel, PARALLEL_ENV_VAR } from '../../lib/parallel';
|
||||
|
||||
const PKG_PATH = 'package.json';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
// Skip the preparation steps if we're being asked for help
|
||||
if (cmd.args.includes('--help')) {
|
||||
await run('docker', ['image', 'build', '--help']);
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn(
|
||||
yellow(`
|
||||
The backend:build-image command is deprecated and will be removed in the future.
|
||||
Please use the backend:bundle command instead along with your own Docker setup.
|
||||
|
||||
https://backstage.io/docs/deployment/docker
|
||||
`),
|
||||
);
|
||||
|
||||
const pkgPath = paths.resolveTarget(PKG_PATH);
|
||||
const pkg = await fs.readJson(pkgPath);
|
||||
const appConfigs = await findAppConfigs();
|
||||
const npmrc = (await fs.pathExists(paths.resolveTargetRoot('.npmrc')))
|
||||
? ['.npmrc']
|
||||
: [];
|
||||
const tempDistWorkspace = await createDistWorkspace([pkg.name], {
|
||||
buildDependencies: Boolean(cmd.build),
|
||||
files: [
|
||||
'package.json',
|
||||
'yarn.lock',
|
||||
...npmrc,
|
||||
...appConfigs,
|
||||
{ src: paths.resolveTarget('Dockerfile'), dest: 'Dockerfile' },
|
||||
],
|
||||
parallel: parseParallel(process.env[PARALLEL_ENV_VAR]),
|
||||
skeleton: 'skeleton.tar',
|
||||
});
|
||||
console.log(`Dist workspace ready at ${tempDistWorkspace}`);
|
||||
|
||||
// all args are forwarded to docker build
|
||||
await run('docker', ['image', 'build', '.', ...cmd.args], {
|
||||
cwd: tempDistWorkspace,
|
||||
});
|
||||
|
||||
await fs.remove(tempDistWorkspace);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all config files to copy into the image
|
||||
*/
|
||||
async function findAppConfigs(): Promise<string[]> {
|
||||
const files = [];
|
||||
|
||||
for (const name of await fs.readdir(paths.targetRoot)) {
|
||||
if (name.startsWith('app-config.') && name.endsWith('.yaml')) {
|
||||
files.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (paths.targetRoot !== paths.targetDir) {
|
||||
const dirPath = relativePath(paths.targetRoot, paths.targetDir);
|
||||
|
||||
for (const name of await fs.readdir(paths.targetDir)) {
|
||||
if (name.startsWith('app-config.') && name.endsWith('.yaml')) {
|
||||
files.push(joinPath(dirPath, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
@@ -19,8 +19,17 @@ import { stringify as stringifyYaml } from 'yaml';
|
||||
import { AppConfig, ConfigReader } from '@backstage/config';
|
||||
import { loadCliConfig } from '../../lib/config';
|
||||
import { ConfigSchema, ConfigVisibility } from '@backstage/config-loader';
|
||||
import chalk from 'chalk';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
if (cmd.lax) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'[DEPRECATED] - The lax argument is deprecated and will be removed in the future.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const { schema, appConfigs } = await loadCliConfig({
|
||||
args: cmd.config,
|
||||
fromPackage: cmd.package,
|
||||
|
||||
@@ -14,10 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { Command } from 'commander';
|
||||
import { loadCliConfig } from '../../lib/config';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
if (cmd.lax) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'[DEPRECATED] - The lax argument is deprecated and will be removed in the future.',
|
||||
),
|
||||
);
|
||||
}
|
||||
await loadCliConfig({
|
||||
args: cmd.config,
|
||||
fromPackage: cmd.package,
|
||||
|
||||
@@ -30,7 +30,11 @@ export function registerCommands(program: CommanderStatic) {
|
||||
.command('app:build')
|
||||
.description('Build an app for a production release')
|
||||
.option('--stats', 'Write bundle stats to output directory')
|
||||
.option('--lax', 'Do not require environment variables to be set')
|
||||
// Deprecated
|
||||
.option(
|
||||
'--lax',
|
||||
'[DEPRECATED] - Do not require environment variables to be set',
|
||||
)
|
||||
.option(...configOption)
|
||||
.action(lazy(() => import('./app/build').then(m => m.default)));
|
||||
|
||||
@@ -55,16 +59,6 @@ export function registerCommands(program: CommanderStatic) {
|
||||
)
|
||||
.action(lazy(() => import('./backend/bundle').then(m => m.default)));
|
||||
|
||||
program
|
||||
.command('backend:build-image')
|
||||
.allowUnknownOption(true)
|
||||
.helpOption(', --backstage-cli-help') // Let docker handle --help
|
||||
.option('--build', 'Build packages before packing them into the image')
|
||||
.description(
|
||||
'Bundles the package into a docker image. This command is deprecated and will be removed.',
|
||||
)
|
||||
.action(lazy(() => import('./backend/buildImage').then(m => m.default)));
|
||||
|
||||
program
|
||||
.command('backend:dev')
|
||||
.description('Start local development server with HMR for the backend')
|
||||
@@ -115,7 +109,7 @@ export function registerCommands(program: CommanderStatic) {
|
||||
|
||||
program
|
||||
.command('remove-plugin')
|
||||
.description('Removes plugin in the current repository')
|
||||
.description('[DEPRECATED] - Removes plugin in the current repository')
|
||||
.action(
|
||||
lazy(() => import('./remove-plugin/removePlugin').then(m => m.default)),
|
||||
);
|
||||
@@ -178,7 +172,10 @@ export function registerCommands(program: CommanderStatic) {
|
||||
'--package <name>',
|
||||
'Only load config schema that applies to the given package',
|
||||
)
|
||||
.option('--lax', 'Do not require environment variables to be set')
|
||||
.option(
|
||||
'--lax',
|
||||
'[DEPRECATED] - Do not require environment variables to be set',
|
||||
)
|
||||
.option('--frontend', 'Print only the frontend configuration')
|
||||
.option('--with-secrets', 'Include secrets in the printed configuration')
|
||||
.option(
|
||||
@@ -195,7 +192,10 @@ export function registerCommands(program: CommanderStatic) {
|
||||
'--package <name>',
|
||||
'Only load config schema that applies to the given package',
|
||||
)
|
||||
.option('--lax', 'Do not require environment variables to be set')
|
||||
.option(
|
||||
'--lax',
|
||||
'[DEPRECATED] - Do not require environment variables to be set',
|
||||
)
|
||||
.option('--frontend', 'Only validate the frontend configuration')
|
||||
.option(...configOption)
|
||||
.description(
|
||||
|
||||
@@ -184,6 +184,12 @@ export const removeReferencesFromAppPackage = async (
|
||||
};
|
||||
|
||||
export default async () => {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
'[DEPRECATED] - The remove-plugin command is deprecated and will be removed in the future.',
|
||||
),
|
||||
);
|
||||
|
||||
const questions: Question[] = [
|
||||
{
|
||||
type: 'input',
|
||||
|
||||
Reference in New Issue
Block a user