diff --git a/packages/cli/bin/backstage-cli b/packages/cli/bin/backstage-cli index 23111f3061..b7317db25b 100755 --- a/packages/cli/bin/backstage-cli +++ b/packages/cli/bin/backstage-cli @@ -5,7 +5,7 @@ const path = require('path'); // Figure out whether we're running inside the backstage repo or as an installed dependency const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src')); if (!isLocal) { - require('../cjs'); + require('../dist'); } else { require('ts-node').register({ project: path.resolve(__dirname, '../tsconfig.json'), diff --git a/packages/cli/package.json b/packages/cli/package.json index eb7652be7a..da9aac46b8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,19 +1,17 @@ { "name": "@spotify-backstage/cli", - "version": "1.3.0", - "main": "src/index.ts", - "main:src": "src/index.ts", + "version": "1.4.0", + "main": "dist", "license": "Apache-2.0", "private": false, "scripts": { "exec": "npx ts-node ./src", - "build": "web-scripts build", + "build": "tsc --outDir dist --noEmit false --module CommonJS", "lint": "web-scripts lint", "test": "web-scripts test", "start": "nodemon ." }, "devDependencies": { - "@spotify/web-scripts": "^6.0.0", "@types/fs-extra": "^8.1.0", "@types/html-webpack-plugin": "^3.2.2", "@types/inquirer": "^6.5.0", @@ -33,6 +31,7 @@ "dependencies": { "@lerna/package-graph": "^3.18.5", "@lerna/project": "^3.18.0", + "@spotify/web-scripts": "^6.0.0", "chokidar": "^3.3.1", "commander": "^4.1.1", "dashify": "^2.0.0", @@ -52,7 +51,7 @@ "files": [ "templates", "bin", - "cjs" + "dist" ], "nodemonConfig": { "watch": "./src", diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 31c542ff27..d0bc932a32 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -17,7 +17,11 @@ export default async (cmd: Command) => { } try { - spawnSync('tsc', args, { stdio: 'inherit' }); + const result = spawnSync('tsc', args, { stdio: 'inherit' }); + if (result.error) { + throw result.error; + } + process.exit(result.status ?? 0); } catch (error) { process.stderr.write(`${chalk.red(error.message)}\n`); process.exit(1); diff --git a/packages/cli/src/commands/plugin/lint.ts b/packages/cli/src/commands/plugin/lint.ts index 133f449313..2f446b0f32 100644 --- a/packages/cli/src/commands/plugin/lint.ts +++ b/packages/cli/src/commands/plugin/lint.ts @@ -5,7 +5,11 @@ export default async () => { const args = ['lint']; try { - spawnSync('web-scripts', args, { stdio: 'inherit' }); + const result = spawnSync('web-scripts', args, { stdio: 'inherit' }); + if (result.error) { + throw result.error; + } + process.exit(result.status ?? 0); } catch (error) { process.stderr.write(`${chalk.red(error.message)}\n`); process.exit(1); diff --git a/packages/cli/src/commands/plugin/test.ts b/packages/cli/src/commands/plugin/test.ts index c881bbdfcb..e0433abb24 100644 --- a/packages/cli/src/commands/plugin/test.ts +++ b/packages/cli/src/commands/plugin/test.ts @@ -10,7 +10,11 @@ export default async (cmd: Command) => { } try { - spawnSync('web-scripts', args, { stdio: 'inherit' }); + const result = spawnSync('web-scripts', args, { stdio: 'inherit' }); + if (result.error) { + throw result.error; + } + process.exit(result.status ?? 0); } catch (error) { process.stderr.write(`${chalk.red(error.message)}\n`); process.exit(1);