From 743e4d4492fc3d698e099e7730e539e5c10b2bf8 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Tue, 27 Aug 2019 11:19:35 +0200 Subject: [PATCH] feat: adds --no-build option to skip build This implements the convention from angular-schule/ngx-deploy-starter#1 docs: README for --no-build chore: uses 8.3 version build: improve build commands docs: add link to new command --no-build --- README.md | 15 ++++ docs/README_contributors.md | 11 +-- src/deploy/actions.ts | 50 ++++++------ src/deploy/schema.json | 14 +++- src/package-lock.json | 150 +++++++++++++++++++++++++++++++++--- src/package.json | 10 +-- 6 files changed, 204 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index d708599f..cc11d8b5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ - [CircleCI](#circleci) - [📦 Options](#options) - [--configuration](#--configuration) + - [--no-build](#--no-build) - [--package-version](#--package-version) - [--tag](#--tag) - [--access](#--access) @@ -115,6 +116,20 @@ jobs: A named build target, as specified in the `configurations` section of `angular.json`. Each named target is accompanied by a configuration of option defaults for that target. Same as `ng build --configuration=XXX`. +This command has no effect if the option `--no-build` option is active. + +#### --no-build +- **optional** +- Default: `false` (string) +- Example: + - `ng deploy` – Angular project is build in production mode before the deployment + - `ng deploy --no-build` – Angular project is NOT build + +Skip build process during deployment. +This can be used when you are sure that you haven't changed anything and want to deploy with the latest artifact. +This command causes the `--configuration` setting to have no effect. + +> **This is a proposal from [RFC #1](https://github.com/angular-schule/ngx-deploy-starter/issues/1).** #### --package-version diff --git a/docs/README_contributors.md b/docs/README_contributors.md index cc6b8316..5d76ebd5 100644 --- a/docs/README_contributors.md +++ b/docs/README_contributors.md @@ -25,15 +25,15 @@ Follow the instructions for [checking and updating the Angular CLI version](#ang 1. Install the next version of the Angular CLI. ```sh - npm install -g @angular/cli@next + npm install -g @angular/cli ``` -2. Run `ng version`, make sure you have installed Angular CLI v8.3.0-next.0 or greater. +2. Run `ng version`, make sure you have installed Angular CLI v8.3.0 or greater. 3. Update your existing project using the command: ```sh - ng update @angular/cli @angular/core --next=true + ng update @angular/cli @angular/core ``` @@ -99,8 +99,9 @@ Once you have completed the previous steps to `npm link` the local copy of `@ang ng deploy ``` - Which is the same as: - ``` + Or with the old builder syntax: + + ```sh ng run your-angular-project:deploy ``` diff --git a/src/deploy/actions.ts b/src/deploy/actions.ts index d7580333..0fa46f09 100644 --- a/src/deploy/actions.ts +++ b/src/deploy/actions.ts @@ -15,31 +15,35 @@ export default async function deploy( projectRoot: string, options: Schema ) { - if (!context.target) { - throw new Error('Cannot execute the build target'); + if (options.noBuild) { + context.logger.info(`📦 Skipping build`); + } else { + if (!context.target) { + throw new Error('Cannot execute the build target'); + } + + const configuration = options.configuration; + + context.logger.info( + `📦 Building "${context.target.project}". ${ + configuration ? `Configuration "${configuration}"` : '' + }` + ); + + const target = { + target: 'build', + project: context.target.project + } as Target; + + // Set the configuration if set on the options + if (configuration) { + target.configuration = configuration; + } + + const build = await context.scheduleTarget(target); + await build.result; } - const configuration = options.configuration; - - context.logger.info( - `📦 Building "${context.target.project}". ${ - configuration ? `Configuration "${configuration}"` : '' - }` - ); - - const target = { - target: 'build', - project: context.target.project - } as Target; - - // Set the configuration if set on the options - if (configuration) { - target.configuration = configuration; - } - - const build = await context.scheduleTarget(target); - await build.result; - await engine.run( projectRoot, options, diff --git a/src/deploy/schema.json b/src/deploy/schema.json index 1ec9d2db..7ca6d512 100644 --- a/src/deploy/schema.json +++ b/src/deploy/schema.json @@ -3,6 +3,16 @@ "title": "schema", "description": "Publish your angular packages to npm by just run `npm deploy your-packages`", "properties": { + "configuration": { + "type": "string", + "description": "This is a proposal from RFC #1. --- A named build target, as specified in the `configurations` section of angular.json. Each named target is accompanied by a configuration of option defaults for that target. Same as `ng build --configuration=XXX`.", + "alias": "c" + }, + "noBuild": { + "type": "boolean", + "default": false, + "description": "This is a proposal from RFC #1. --- Skip build process during deployment." + }, "packageVersion": { "type": "string", "description": "The version that your package is going to be published. Ex: '1.3.5' '2.0.0-next.0'" @@ -24,10 +34,6 @@ "type": "boolean", "description": "For testing: Run through without making any changes. Execute with --dry-run and nothing will happen.", "default": false - }, - "configuration": { - "type": "string", - "description": "This is a proposal from RFC #1. --- A named build target, as specified in the `configurations` section of angular.json. Each named target is accompanied by a configuration of option defaults for that target. Same as `ng build --configuration=XXX`." } } } diff --git a/src/package-lock.json b/src/package-lock.json index 5bd6af02..93b2aa20 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1629,17 +1629,137 @@ "dev": true }, "copyfiles": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.1.1.tgz", - "integrity": "sha512-y6DZHve80whydXzBal7r70TBgKMPKesVRR1Sn/raUu7Jh/i7iSLSyGvYaq0eMJ/3Y/CKghwzjY32q1WzEnpp3Q==", + "version": "2.4.1", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/copyfiles/-/copyfiles-2.4.1.tgz", + "integrity": "sha1-0tz/YKqtEBXwnQtm5/Dxxc08XaU=", "dev": true, "requires": { "glob": "^7.0.5", "minimatch": "^3.0.3", - "mkdirp": "^0.5.1", + "mkdirp": "^1.0.4", "noms": "0.0.0", "through2": "^2.0.1", - "yargs": "^13.2.4" + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U=", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha1-oCZe5lVHb8gHrqnfPfjfd4OAi08=", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=", + "dev": true + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha1-PrXtYmInVteaXw4qIh3+utdcL34=", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha1-lSGCxGzHssMT0VluYjmSvRY7crU=", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha1-Z+FFz/UQpqaYS98RUpEdadLrnkM=", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.5", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/y18n/-/y18n-5.0.5.tgz", + "integrity": "sha1-h2nsCNA7HqLfJQCs71YXQ7u5qxg=", + "dev": true + }, + "yargs": { + "version": "16.1.1", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/yargs/-/yargs-16.1.1.tgz", + "integrity": "sha1-WkoJW9HKgGsKUNDANhHTgDTSGaE=", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha1-tCiQ8UVmeW+Fro46JSkNIF8VSlQ=", + "dev": true + } } }, "core-util-is": { @@ -1993,6 +2113,12 @@ "es6-symbol": "^3.1.1" } }, + "escalade": { + "version": "3.1.1", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha1-2M/ccACWXFoBdLSoLqpcBVJ0LkA=", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -3603,7 +3729,7 @@ }, "isarray": { "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, @@ -4803,7 +4929,7 @@ }, "noms": { "version": "0.0.0", - "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/noms/-/noms-0.0.0.tgz", "integrity": "sha1-2o69nzr51nYJGbJ9nNyAkqczKFk=", "dev": true, "requires": { @@ -5255,7 +5381,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -5978,7 +6104,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, @@ -6381,6 +6507,12 @@ } } }, + "untildify": { + "version": "4.0.0", + "resolved": "https://indigoag.jfrog.io/indigoag/api/npm/npm/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha1-K8lHuVNlJIfkYAlJ+wkeOujNkZs=", + "dev": true + }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", diff --git a/src/package.json b/src/package.json index ea76c3d2..a2f27ded 100644 --- a/src/package.json +++ b/src/package.json @@ -4,7 +4,7 @@ "description": "Publish your angular packages to npm by just run `npm deploy your-packages`", "main": "index.js", "scripts": { - "build": "rimraf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && copyfiles README.md builders.json collection.json package.json ngx-deploy-npm deploy/schema.json dist && cp ./LICENSE ./dist/LICENSE", + "build": "rimraf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && copyfiles README.md LICENSE builders.json collection.json package.json ngx-deploy-npm deploy/schema.json dist", "predeploy": "npm run build", "deploy": "cd dist && npm publish --access public && cd ..", "link": "npm run build && cd dist && npm link && cd ..", @@ -44,12 +44,12 @@ }, "homepage": "https://github.com/bikecoders/ngx-deploy-npm/#readme", "devDependencies": { - "@angular-devkit/architect": "^0.803.0-next.0", - "@angular-devkit/core": "^8.3.0-next.0", - "@angular-devkit/schematics": "^8.3.0-next.0", + "@angular-devkit/architect": "^0.803.0", + "@angular-devkit/core": "^8.3.0", + "@angular-devkit/schematics": "^8.3.0", "@types/jest": "^24.0.18", "@types/node": "^12.6.9", - "copyfiles": "^2.1.1", + "copyfiles": "^2.4.1", "jest": "^24.8.0", "json-schema-to-typescript": "^7.0.0", "rimraf": "^2.6.3",