Merge pull request #310 from spotify/rugvip/merge

cli: unify test and lint commands
This commit is contained in:
Patrik Oldsberg
2020-03-18 21:13:57 +01:00
committed by GitHub
14 changed files with 22 additions and 124 deletions
+2 -2
View File
@@ -27,8 +27,8 @@
"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",
"test": "backstage-cli app:test",
"lint": "backstage-cli app:lint"
"test": "backstage-cli test",
"lint": "backstage-cli lint"
},
"browserslist": {
"production": [
@@ -15,7 +15,7 @@
*/
import { Command } from 'commander';
import { run } from '../../helpers/run';
import { run } from '../helpers/run';
export default async (cmd: Command) => {
const args = ['lint', '--max-warnings=0', '--format=codeframe'];
-27
View File
@@ -1,27 +0,0 @@
/*
* 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 { Command } from 'commander';
import { run } from '../../helpers/run';
export default async (cmd: Command) => {
const args = ['lint', '--max-warnings=0', '--format=codeframe'];
if (cmd.fix) {
args.push('--fix');
}
await run('web-scripts', args);
};
@@ -16,13 +16,13 @@
import { Command } from 'commander';
import { resolve as resolvePath } from 'path';
import { run } from '../../helpers/run';
import { run } from '../helpers/run';
export default async (cmd: Command) => {
const args = [
'test',
'--config',
resolvePath(__dirname, '../../../config/jest.js'),
resolvePath(__dirname, '../../config/jest.js'),
];
if (cmd.watch) {
+11 -26
View File
@@ -19,12 +19,10 @@ import chalk from 'chalk';
import fs from 'fs';
import createPluginCommand from './commands/createPlugin';
import watch from './commands/watch-deps';
import appLint from './commands/app/lint';
import appTest from './commands/app/testCommand';
import lintCommand from './commands/lint';
import testCommand from './commands/testCommand';
import pluginBuild from './commands/plugin/build';
import pluginLint from './commands/plugin/lint';
import pluginServe from './commands/plugin/serve';
import pluginTest from './commands/plugin/testCommand';
import { exitWithError } from './helpers/errors';
const main = (argv: string[]) => {
@@ -32,19 +30,6 @@ const main = (argv: string[]) => {
program.name('backstage-cli').version(packageJson.version ?? '0.0.0');
program
.command('app:lint')
.option('--fix', 'Attempt to automatically fix violations')
.description('Lint an app')
.action(actionHandler(appLint));
program
.command('app:test')
.option('--watch', 'Enable watch mode')
.option('--coverage', 'Report test coverage')
.description('Run all tests for an app')
.action(actionHandler(appTest));
program
.command('create-plugin')
.description('Creates a new plugin in the current repository')
@@ -56,23 +41,23 @@ const main = (argv: string[]) => {
.description('Build a plugin')
.action(actionHandler(pluginBuild));
program
.command('plugin:lint')
.option('--fix', 'Attempt to automatically fix violations')
.description('Lint a plugin')
.action(actionHandler(pluginLint));
program
.command('plugin:serve')
.description('Serves the dev/ folder of a plugin')
.action(actionHandler(pluginServe));
program
.command('plugin:test')
.command('lint')
.option('--fix', 'Attempt to automatically fix violations')
.description('Lint a package')
.action(actionHandler(lintCommand));
program
.command('test')
.option('--watch', 'Enable watch mode')
.option('--coverage', 'Report test coverage')
.description('Run all tests for a plugin')
.action(actionHandler(pluginTest));
.description('Run all tests for package')
.action(actionHandler(testCommand));
program
.command('watch-deps')
@@ -1,20 +0,0 @@
/*
* 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.
*/
module.exports = {
...require('@spotify/web-scripts/config/jest.config.js'),
setupFilesAfterEnv: ['../jest.setup.ts'],
};
@@ -7,8 +7,8 @@
"private": false,
"scripts": {
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
"lint": "backstage-cli lint",
"test": "backstage-cli test"
},
"devDependencies": {
"@spotify-backstage/cli": "^{{version}}"
-20
View File
@@ -1,20 +0,0 @@
/*
* 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.
*/
module.exports = {
...require('@spotify/web-scripts/config/jest.config.js'),
setupFilesAfterEnv: ['../jest.setup.ts'],
};
+2 -2
View File
@@ -18,8 +18,8 @@
},
"scripts": {
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
"lint": "backstage-cli lint",
"test": "backstage-cli test"
},
"license": "Apache-2.0"
}
-20
View File
@@ -1,20 +0,0 @@
/*
* 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.
*/
module.exports = {
...require('@spotify/web-scripts/config/jest.config.js'),
setupFilesAfterEnv: ['../jest.setup.ts'],
};
+2 -2
View File
@@ -7,8 +7,8 @@
"private": false,
"scripts": {
"build": "backstage-cli plugin:build",
"lint": "backstage-cli plugin:lint",
"test": "backstage-cli plugin:test"
"lint": "backstage-cli lint",
"test": "backstage-cli test"
},
"devDependencies": {
"@spotify-backstage/core": "^0.1.0",