cli: add app:build and use in app
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true backstage-cli watch-deps -- react-scripts start",
|
||||
"build": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts build",
|
||||
"build": "backstage-cli app:build",
|
||||
"test": "backstage-cli test",
|
||||
"lint": "backstage-cli lint"
|
||||
},
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"inquirer": "^7.0.4",
|
||||
"ora": "^4.0.3",
|
||||
"react-dev-utils": "^10.2.0",
|
||||
"react-scripts": "^3.4.0",
|
||||
"recursive-readdir": "^2.2.2",
|
||||
"replace-in-file": "^5.0.2",
|
||||
"ts-loader": "^6.2.1",
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* 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 { run } from '../../helpers/run';
|
||||
|
||||
export default async () => {
|
||||
const args = ['build'];
|
||||
|
||||
await run('react-scripts', args, {
|
||||
env: {
|
||||
EXTEND_ESLINT: 'true',
|
||||
SKIP_PREFLIGHT_CHECK: 'true',
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -14,14 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SpawnSyncOptions, spawn, ChildProcess } from 'child_process';
|
||||
import { SpawnOptions, spawn, ChildProcess } from 'child_process';
|
||||
import { ExitCodeError } from './errors';
|
||||
|
||||
type SpawnOptionsPartialEnv = Omit<SpawnOptions, 'env'> & {
|
||||
env?: Partial<NodeJS.ProcessEnv>;
|
||||
};
|
||||
|
||||
// Runs a child command, returning a promise that is only resolved if the child exits with code 0.
|
||||
export async function run(
|
||||
name: string,
|
||||
args: string[] = [],
|
||||
options: SpawnSyncOptions = {},
|
||||
options: SpawnOptionsPartialEnv = {},
|
||||
) {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
|
||||
@@ -21,6 +21,7 @@ import createPluginCommand from './commands/createPlugin';
|
||||
import watch from './commands/watch-deps';
|
||||
import lintCommand from './commands/lint';
|
||||
import testCommand from './commands/testCommand';
|
||||
import appBuild from './commands/app/build';
|
||||
import pluginBuild from './commands/plugin/build';
|
||||
import pluginServe from './commands/plugin/serve';
|
||||
import { exitWithError } from './helpers/errors';
|
||||
@@ -30,6 +31,11 @@ const main = (argv: string[]) => {
|
||||
|
||||
program.name('backstage-cli').version(packageJson.version ?? '0.0.0');
|
||||
|
||||
program
|
||||
.command('app:build')
|
||||
.description('Build an app for a production release')
|
||||
.action(actionHandler(appBuild));
|
||||
|
||||
program
|
||||
.command('create-plugin')
|
||||
.description('Creates a new plugin in the current repository')
|
||||
|
||||
Reference in New Issue
Block a user