Merge pull request #176 from spotify/patriko/cli-all-the-things

cli: added plugin build,lint,test commands + use them in plugins
This commit is contained in:
Patrik Oldsberg
2020-03-06 13:47:35 +01:00
committed by GitHub
11 changed files with 90 additions and 17 deletions
+25
View File
@@ -0,0 +1,25 @@
import chalk from 'chalk';
import { Command } from 'commander';
import { spawnSync } from 'child_process';
export default async (cmd: Command) => {
const args = [
'--outDir',
'dist/cjs',
'--noEmit',
'false',
'--module',
'CommonJS',
];
if (cmd.watch) {
args.push('--watch');
}
try {
spawnSync('tsc', args, { stdio: 'inherit' });
} catch (error) {
process.stderr.write(`${chalk.red(error.message)}\n`);
process.exit(1);
}
};
+13
View File
@@ -0,0 +1,13 @@
import chalk from 'chalk';
import { spawnSync } from 'child_process';
export default async () => {
const args = ['lint'];
try {
spawnSync('web-scripts', args, { stdio: 'inherit' });
} catch (error) {
process.stderr.write(`${chalk.red(error.message)}\n`);
process.exit(1);
}
};
+18
View File
@@ -0,0 +1,18 @@
import chalk from 'chalk';
import { Command } from 'commander';
import { spawnSync } from 'child_process';
export default async (cmd: Command) => {
const args = ['test'];
if (cmd.watch) {
args.push('--watch');
}
try {
spawnSync('web-scripts', args, { stdio: 'inherit' });
} catch (error) {
process.stderr.write(`${chalk.red(error.message)}\n`);
process.exit(1);
}
};
+24 -4
View File
@@ -3,7 +3,10 @@ import chalk from 'chalk';
import fs from 'fs';
import createPluginCommand from './commands/createPlugin';
import watch from './commands/watch-deps';
import serve from './commands/serve';
import pluginBuild from './commands/plugin/build';
import pluginLint from './commands/plugin/lint';
import pluginServe from './commands/plugin/serve';
import pluginTest from './commands/plugin/test';
process.on('unhandledRejection', err => {
throw err;
@@ -20,9 +23,26 @@ const main = (argv: string[]) => {
.action(createPluginCommand);
program
.command('serve')
.description('Serves the dev/ folder of a package')
.action(serve);
.command('plugin:build')
.option('--watch', 'Enable watch mode')
.description('Build a plugin')
.action(pluginBuild);
program
.command('plugin:lint')
.description('Lint a plugin')
.action(pluginLint);
program
.command('plugin:serve')
.description('Serves the dev/ folder of a plugin')
.action(pluginServe);
program
.command('plugin:test')
.option('--watch', 'Enable watch mode')
.description('Run all tests for a plugin')
.action(pluginTest);
program
.command('watch-deps')
@@ -5,13 +5,12 @@
"license": "Apache-2.0",
"private": false,
"scripts": {
"build": "tsc --outDir dist/cjs --noEmit false --module CommonJS",
"lint": "web-scripts lint",
"test": "web-scripts test"
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
},
"devDependencies": {
"@spotify-backstage/cli": "^1.2.0",
"@spotify/web-scripts": "^6.0.0"
"@spotify-backstage/cli": "^1.2.0"
},
"dependencies": {
"@material-ui/lab": "4.0.0-alpha.45"
+3 -4
View File
@@ -7,7 +7,6 @@
"@spotify-backstage/core": "1.0.0",
"@material-ui/core": "^4.9.1",
"@material-ui/icons": "^4.9.1",
"@spotify/web-scripts": "^6.0.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
@@ -21,9 +20,9 @@
"react-dom": "^16.12.0"
},
"scripts": {
"build": "tsc --outDir dist/cjs --noEmit false --module CommonJS",
"lint": "web-scripts lint",
"test": "web-scripts test"
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
},
"license": "Apache-2.0"
}
+3 -4
View File
@@ -5,7 +5,6 @@
"devDependencies": {
"@spotify-backstage/cli": "^1.2.0",
"@spotify-backstage/core": "1.0.0",
"@spotify/web-scripts": "^6.0.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
@@ -19,9 +18,9 @@
"@material-ui/icons": "^4.9.1"
},
"scripts": {
"build": "tsc --outDir dist/cjs --noEmit false --module CommonJS",
"lint": "web-scripts lint",
"test": "web-scripts test"
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
},
"license": "Apache-2.0"
}