Skip to content

Commit cea7024

Browse files
committed
feat: adds --no-build option to skip build, adds alias -c
This implements the convention from angular-schule/ngx-deploy-starter#1
1 parent f19bf48 commit cea7024

File tree

3 files changed

+55
-27
lines changed

3 files changed

+55
-27
lines changed

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
5. [📦 Options](#options)
1717
- [--base-href](#base-href)
1818
- [--configuration](#configuration)
19+
- [--no-build](#no-build)
1920
- [--repo](#repo)
2021
- [--message](#message)
2122
- [--branch](#branch)
@@ -161,6 +162,33 @@ ng deploy --cname=example.org
161162

162163
See the option [--cname](#cname) for more information!
163164

165+
166+
#### --configuration <a name="configuration"></a>
167+
* __optional__
168+
* Alias: `-c`
169+
* Default: `production` (string)
170+
* Example:
171+
* `ng deploy` – Angular project is build in production mode
172+
* `ng deploy --configuration=test` – Angular project is using the configuration `test` (this configuration must exist in the `angular.json` file)
173+
174+
A named build target, as specified in the `configurations` section of `angular.json`.
175+
Each named target is accompanied by a configuration of option defaults for that target.
176+
Same as `ng build --configuration=XXX`.
177+
This command has no effect if the option `--no-build` option is active.
178+
179+
180+
#### --no-build <a name="no-build"></a>
181+
* __optional__
182+
* Default: `false` (string)
183+
* Example:
184+
* `ng deploy` – Angular project is build in production mode before the deployment
185+
* `ng deploy --no-build` – Angular project is NOT build
186+
187+
Skip build process during deployment.
188+
This can be used when you are sure that you haven't changed anything and want to deploy with the latest artifact.
189+
This command causes the `--configuration` setting to have no effect.
190+
191+
164192
#### --repo <a name="repo"></a>
165193
* __optional__
166194
* Default: URL of the origin remote of the current dir (assumes a Git repository)
@@ -178,18 +206,6 @@ if there is an environment variable `GH_TOKEN` with the value `XXX`.
178206
Learn more about [GitHub tokens here](https://help.github.com/articles/creating-an-access-token-for-command-line-use/).)
179207

180208

181-
#### --configuration <a name="configuration"></a>
182-
* __optional__
183-
* Default: `production` (string)
184-
* Example:
185-
* `ng deploy` – Angular project is build in production mode
186-
* `ng deploy --configuration=qs` – Angular project is using the configuration `qs` (this configuration must exist in the `angular.json` file)
187-
188-
A named build target, as specified in the `configurations` section of `angular.json`.
189-
Each named target is accompanied by a configuration of option defaults for that target.
190-
Same as `ng build --configuration=XXX`.
191-
192-
193209
#### --message <a name="message"></a>
194210
* __optional__
195211
* Default: `Auto-generated commit` (string)

src/deploy/actions.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,28 @@ export default async function deploy(
1010
options: Schema
1111
) {
1212

13-
if (!context.target) {
14-
throw new Error('Cannot execute the build target');
15-
}
13+
if (options.noBuild) {
14+
context.logger.info(`📦 Skipping build`);
15+
} else {
16+
17+
if (!context.target) {
18+
throw new Error('Cannot execute the build target');
19+
}
1620

17-
const configuration = options.configuration ? options.configuration : 'production'
18-
const overrides = {
19-
...(options.baseHref && {baseHref: options.baseHref})
20-
};
21+
const configuration = options.configuration ? options.configuration : 'production'
22+
const overrides = {
23+
...(options.baseHref && {baseHref: options.baseHref})
24+
};
2125

22-
context.logger.info(`📦 Building "${ context.target.project }". Configuration: "${ configuration }".${ options.baseHref ? ' Your base-href: "' + options.baseHref + '"' : '' }`);
26+
context.logger.info(`📦 Building "${ context.target.project }". Configuration: "${ configuration }".${ options.baseHref ? ' Your base-href: "' + options.baseHref + '"' : '' }`);
2327

24-
const build = await context.scheduleTarget({
25-
target: 'build',
26-
project: context.target.project,
27-
configuration
28-
}, overrides as json.JsonObject);
29-
await build.result;
28+
const build = await context.scheduleTarget({
29+
target: 'build',
30+
project: context.target.project,
31+
configuration
32+
}, overrides as json.JsonObject);
33+
await build.result;
34+
}
3035

3136
await engine.run(
3237
projectRoot,

src/deploy/schema.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
},
1010
"configuration": {
1111
"type": "string",
12-
"description": "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`."
12+
"default": "production",
13+
"description": "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`.",
14+
"alias": "c"
15+
},
16+
"noBuild": {
17+
"type": "boolean",
18+
"default": false,
19+
"description": "Skip build process during deployment."
1320
},
1421
"repo": {
1522
"type": "string",

0 commit comments

Comments
 (0)