From 36a1550e0032f8dc5195e97f01a157d7382fa9f1 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Thu, 7 Mar 2019 11:13:10 -0800 Subject: [PATCH] feat(bazel): Eject Bazel (#29167) Add command line flag to expose Bazel files on disk. `ng build --leaveBazelFilesOnDisk` PR Close #29167 --- packages/bazel/src/builders/index.ts | 6 ++- packages/bazel/src/builders/schema.d.ts | 13 ++++++ packages/bazel/src/builders/schema.json | 59 ++++++++++++++----------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/packages/bazel/src/builders/index.ts b/packages/bazel/src/builders/index.ts index 6df7a4a4ca..814dfdd3c0 100644 --- a/packages/bazel/src/builders/index.ts +++ b/packages/bazel/src/builders/index.ts @@ -20,7 +20,7 @@ class BazelBuilder implements Builder { run(config: BuilderConfiguration>): Observable { const {host, logger, workspace} = this.context; const root: Path = workspace.root; - const {bazelCommand, targetLabel, watch} = config.options as Schema; + const {bazelCommand, leaveBazelFilesOnDisk, targetLabel, watch} = config.options as Schema; const executable = watch ? 'ibazel' : 'bazel'; const binary = checkInstallation(executable, root) as Path; @@ -35,7 +35,9 @@ class BazelBuilder implements Builder { logger.error(err.message); return {success: false}; } finally { - await deleteBazelFiles(host, bazelFiles); // this will never throw + if (!leaveBazelFilesOnDisk) { + await deleteBazelFiles(host, bazelFiles); // this will never throw + } } })); } diff --git a/packages/bazel/src/builders/schema.d.ts b/packages/bazel/src/builders/schema.d.ts index 79426a2eed..dbcf8d8da9 100644 --- a/packages/bazel/src/builders/schema.d.ts +++ b/packages/bazel/src/builders/schema.d.ts @@ -9,14 +9,27 @@ * Options for Bazel Builder */ export interface Schema { + /** + * Common commands supported by Bazel. + */ bazelCommand: BazelCommand; + /** + * If true, leave Bazel files on disk after running command. + */ + leaveBazelFilesOnDisk?: boolean; /** * Target to be executed under Bazel. */ targetLabel: string; + /** + * If true, watch the filesystem using ibazel. + */ watch?: boolean; } +/** + * Common commands supported by Bazel. + */ export enum BazelCommand { Build = 'build', Run = 'run', diff --git a/packages/bazel/src/builders/schema.json b/packages/bazel/src/builders/schema.json index 22bdfa55a9..694f45617c 100644 --- a/packages/bazel/src/builders/schema.json +++ b/packages/bazel/src/builders/schema.json @@ -1,29 +1,36 @@ { - "$schema": "http://json-schema.org/schema", - "title": "Bazel builder schema", - "description": "Options for Bazel Builder", - "type": "object", - "properties": { - "targetLabel": { - "type": "string", - "description": "Target to be executed under Bazel." - }, - "bazelCommand": { - "type": "string", - "enum": [ - "run", - "build", - "test" - ] - }, - "watch": { - "type": "boolean", - "default": false - } + "$schema": "http://json-schema.org/schema", + "title": "Bazel builder schema", + "description": "Options for Bazel Builder", + "type": "object", + "properties": { + "targetLabel": { + "type": "string", + "description": "Target to be executed under Bazel." }, - "additionalProperties": false, - "required": [ - "targetLabel", - "bazelCommand" - ] + "bazelCommand": { + "type": "string", + "description": "Common commands supported by Bazel.", + "enum": [ + "run", + "build", + "test" + ] + }, + "watch": { + "type": "boolean", + "description": "If true, watch the filesystem using ibazel.", + "default": false + }, + "leaveBazelFilesOnDisk": { + "type": "boolean", + "description": "If true, leave Bazel files on disk after running command.", + "default": false + } + }, + "additionalProperties": false, + "required": [ + "targetLabel", + "bazelCommand" + ] }