From 427ad9c2427b52eca44fe3ad411fac948770f49f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 6 Mar 2020 15:59:26 +0100 Subject: [PATCH 1/5] cli: only build cjs to dist folder and set it as entrypoint --- packages/cli/bin/backstage-cli | 2 +- packages/cli/package.json | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) 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..011f9b506f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,13 +1,12 @@ { "name": "@spotify-backstage/cli", "version": "1.3.0", - "main": "src/index.ts", - "main:src": "src/index.ts", + "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 ." @@ -52,7 +51,7 @@ "files": [ "templates", "bin", - "cjs" + "dist" ], "nodemonConfig": { "watch": "./src", From 1b7d0a4e4bbbc287f648dc00eb67549dbf2811b0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 6 Mar 2020 16:23:54 +0100 Subject: [PATCH 2/5] cli: fix for error output being ignored --- packages/cli/src/commands/plugin/build.ts | 5 ++++- packages/cli/src/commands/plugin/lint.ts | 5 ++++- packages/cli/src/commands/plugin/test.ts | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index 31c542ff27..fac78b650a 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -17,7 +17,10 @@ export default async (cmd: Command) => { } try { - spawnSync('tsc', args, { stdio: 'inherit' }); + const result = spawnSync('tsc', args, { stdio: 'inherit' }); + if (result.error) { + throw result.error; + } } 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..7c5be33147 100644 --- a/packages/cli/src/commands/plugin/lint.ts +++ b/packages/cli/src/commands/plugin/lint.ts @@ -5,7 +5,10 @@ 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; + } } 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..6667f97055 100644 --- a/packages/cli/src/commands/plugin/test.ts +++ b/packages/cli/src/commands/plugin/test.ts @@ -10,7 +10,10 @@ 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; + } } catch (error) { process.stderr.write(`${chalk.red(error.message)}\n`); process.exit(1); From c3febb492f5c83446d27cdee1a64ac6284cdac99 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 6 Mar 2020 16:30:37 +0100 Subject: [PATCH 3/5] cli: properly forward status code in plugin commands --- packages/cli/src/commands/plugin/build.ts | 1 + packages/cli/src/commands/plugin/lint.ts | 1 + packages/cli/src/commands/plugin/test.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/cli/src/commands/plugin/build.ts b/packages/cli/src/commands/plugin/build.ts index fac78b650a..d0bc932a32 100644 --- a/packages/cli/src/commands/plugin/build.ts +++ b/packages/cli/src/commands/plugin/build.ts @@ -21,6 +21,7 @@ export default async (cmd: Command) => { 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 7c5be33147..2f446b0f32 100644 --- a/packages/cli/src/commands/plugin/lint.ts +++ b/packages/cli/src/commands/plugin/lint.ts @@ -9,6 +9,7 @@ export default async () => { 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 6667f97055..e0433abb24 100644 --- a/packages/cli/src/commands/plugin/test.ts +++ b/packages/cli/src/commands/plugin/test.ts @@ -14,6 +14,7 @@ export default async (cmd: Command) => { if (result.error) { throw result.error; } + process.exit(result.status ?? 0); } catch (error) { process.stderr.write(`${chalk.red(error.message)}\n`); process.exit(1); From 2d6ee263f40d24a755d8599bf26771cab2d7d90a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 6 Mar 2020 16:40:13 +0100 Subject: [PATCH 4/5] cli: move spotify web-scripts to deps --- packages/cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 011f9b506f..b30a9f2a8a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -12,7 +12,6 @@ "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", @@ -32,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", From 5e5295622074e094b2620203ef856d2004b24650 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 6 Mar 2020 15:50:16 +0100 Subject: [PATCH 5/5] cli: bump to 1.4.0 --- packages/cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index b30a9f2a8a..da9aac46b8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@spotify-backstage/cli", - "version": "1.3.0", + "version": "1.4.0", "main": "dist", "license": "Apache-2.0", "private": false,