Skip to content

Commit 891ee8c

Browse files
committed
fixing build and tests, cleanup
see angular-schule/ngx-deploy-starter#10
1 parent 5e009dc commit 891ee8c

11 files changed

+38
-38
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
4. [🚀 Continuous Delivery](#continuous-delivery)
1717
5. [📦 Options](#options)
1818
- [--base-href](#base-href)
19-
- [--configuration](#configuration)
19+
- [--build-target](#build-target)
2020
- [--no-build](#no-build)
2121
- [--repo](#repo)
2222
- [--message](#message)
@@ -172,19 +172,20 @@ ng deploy --cname=example.org
172172

173173
See the option [--cname](#cname) for more information!
174174

175-
<!-- #### --configuration <a name="configuration"></a>
175+
#### --build-target <a name="build-target"></a>
176176

177177
- **optional**
178-
- Alias: `-c`
179-
- Default: `production` (string)
178+
- Default: `undefined` (string)
180179
- Example:
181-
- `ng deploy` – Angular project is build in production mode
182-
- `ng deploy --configuration=test` – Angular project is using the configuration `test` (this configuration must exist in the `angular.json` file)
180+
- `ng deploy` – Angular project is build in `production` mode
181+
- `ng deploy --build-target=test` – Angular project is using the build configuration `test` (this configuration must exist in the `angular.json` file)
182+
183+
If no buildTarget is set, the `production` build of the default project will be chosen.
184+
The `buildTarget` simply points to an existing build configuration for your project, as specified in the `configurations` section of `angular.json`.
185+
Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed.
183186

184-
A named build target, as specified in the `configurations` section of `angular.json`.
185-
Each named target is accompanied by a configuration of option defaults for that target.
186-
Same as `ng build --configuration=XXX`.
187-
This command has no effect if the option `--no-build` option is active.
187+
This is equivalent as calling the command `ng build --configuration=XXX`."
188+
This command has no effect if the option `--no-build` is active.
188189

189190
#### --no-build <a name="no-build"></a>
190191

@@ -196,7 +197,7 @@ This command has no effect if the option `--no-build` option is active.
196197

197198
Skip build process during deployment.
198199
This can be used when you are sure that you haven't changed anything and want to deploy with the latest artifact.
199-
This command causes the `--configuration` setting to have no effect. -->
200+
This command causes the `--configuration` setting to have no effect.
200201

201202
#### --repo <a name="repo"></a>
202203

@@ -313,7 +314,7 @@ This can be very useful because it outputs what would happen without doing anyth
313314
To avoid all these command-line cmd options, you can write down your configuration in the `angular.json` file in the `options` attribute of your deploy project's architect. Just change the kebab-case to lower camel case. This is the notation of all options in lower camel case:
314315

315316
- baseHref
316-
- configuration
317+
- buildTarget
317318
- noBuild
318319
- repo
319320
- message
@@ -346,20 +347,21 @@ becomes
346347
}
347348
```
348349

349-
And just run `ng deploy` 😄.
350+
Now you can just run `ng deploy` without all the options in the command line! 😄
350351

351352
> **ℹ️ Hint**
352353
>
353354
> You can always use the [--dry-run](#dry-run) option to verify if your configuration is right.
355+
> The project will build but not deploy.
354356
355357
## 🌍 Environments <a name="environments"></a>
356358

357359
We have seen `angular-cli-ghpages` running on various environments, like Travis CI, CircleCi or Github Actions.
358360
Please share your knowledge by writing an article about how to set up the deployment.
359361

360362
1. [GitHub Actions](https://github.com/angular-schule/angular-cli-ghpages/blob/master/docs/README_environment_github_actions.md) by [Dharmen Shah](https://github.com/shhdharmen)
361-
2. TODO: Travis CI
362-
3. TODO: CircleCI
363+
2. Travis CI
364+
3. CircleCI
363365

364366
## ⁉️ FAQ <a name="faq"></a>
365367

docs/README_contributors.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- [4. Testing](#4-testing)
99
- [Testing the standalone CLI](#testing-the-standalone-cli)
1010
- [Publish to NPM](#publish-to-npm)
11-
- [Usage of Prettier Formatter](#usage-of-prettier-formatter)
1211

1312
## How to start
1413

@@ -154,20 +153,13 @@ Use VSCode and debug the task `Launch Standalone Program`.
154153

155154
```
156155
cd angular-cli-ghpages/src
157-
npx prettier --write '**/*'
156+
npm run prettier
158157
npm run build
159158
npm run test
160159
npm publish dist
161160
npm dist-tag add [email protected] next
162161
```
163162

164-
## Usage of Prettier Formatter
165-
166-
Just execute `npx prettier --write '**/*'` and the code is formated automatically.
167-
Please ignore the errors for now. ([error] No parser could be inferred for file)
168-
169-
We are still working on this, see https://github.com/angular-schule/ngx-deploy-starter/issues/10 .
170-
171163
## Keeping track of all the forks
172164

173165
[ngx-deploy-starter](https://github.com/angular-schule/ngx-deploy-starter/) and

src/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

src/.prettierrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"singleQuote": true
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"arrowParens": "avoid"
35
}

src/angular-cli-ghpages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var consoleLogger = {
7474

7575
var dir = path.join(process.cwd(), commander.dir);
7676

77-
engine.run(dir, commander, consoleLogger).catch(function(error) {
77+
engine.run(dir, commander, consoleLogger).catch(function (error) {
7878
consoleLogger.error('❌ An error occurred when trying to deploy:');
7979
consoleLogger.error(error.message);
8080
process.exit(1);

src/deploy/actions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const initMocks = () => {
119119
Promise.resolve({
120120
result: Promise.resolve(createBuilderOutputMock(true))
121121
} as BuilderRun)
122-
};
122+
} as any;
123123
};
124124

125125
const createBuilderOutputMock = (success: boolean): BuilderOutput => {

src/deploy/schema.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
"type": "string",
88
"description": "Base url for the application being built. Same as `ng build --base-href=/XXX/`."
99
},
10-
"configuration": {
10+
"buildTarget": {
1111
"type": "string",
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"
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. This is equivalent as calling the command `ng build --configuration=XXX`."
1513
},
1614
"noBuild": {
1715
"type": "boolean",

src/engine/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function prepareOptions(
5454
let debuglog = util.debuglog;
5555
util.debuglog = set => {
5656
if (set === 'gh-pages') {
57-
return function() {
57+
return function () {
5858
let message = util.format.apply(util, arguments);
5959
logger.info(message);
6060
};

src/ng-add.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('ng-add', () => {
129129

130130
function generateAngularJson() {
131131
return {
132-
defaultProject: PROJECT_NAME,
132+
defaultProject: PROJECT_NAME as string | undefined,
133133
projects: {
134134
[PROJECT_NAME]: {
135135
projectType: 'application',

src/ng-add.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { JsonParseMode, parseJson } from '@angular-devkit/core';
22
import {
33
SchematicContext,
44
SchematicsException,
5-
Tree,
5+
Tree
66
} from '@angular-devkit/schematics';
77
import { Workspace } from './interfaces';
88

99
function getWorkspace(host: Tree): { path: string; workspace: Workspace } {
1010
const possibleFiles = ['/angular.json', '/.angular.json'];
11-
const path = possibleFiles.filter((path) => host.exists(path))[0];
11+
const path = possibleFiles.filter(path => host.exists(path))[0];
1212

1313
const configBuffer = host.read(path);
1414
if (configBuffer === null) {
@@ -25,7 +25,7 @@ function getWorkspace(host: Tree): { path: string; workspace: Workspace } {
2525

2626
return {
2727
path,
28-
workspace,
28+
workspace
2929
};
3030
}
3131
interface NgAddOptions {
@@ -74,7 +74,7 @@ export const ngAdd = (options: NgAddOptions) => (
7474

7575
project.architect['deploy'] = {
7676
builder: 'angular-cli-ghpages:deploy',
77-
options: {},
77+
options: {}
7878
};
7979

8080
tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));

src/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"scripts": {
1111
"build": "rimraf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && copyfiles builders.json collection.json ng-add-schema.json package.json angular-cli-ghpages deploy/schema.json dist && copyfiles ../README.md dist/README.md",
12-
"test": "jest"
12+
"test": "jest",
13+
"prettier": "prettier --write ."
1314
},
1415
"schematics": "./collection.json",
1516
"builders": "./builders.json",
@@ -92,6 +93,10 @@
9293
"jsx",
9394
"json",
9495
"node"
96+
],
97+
"testPathIgnorePatterns": [
98+
"/node_modules/",
99+
"/dist/"
95100
]
96101
}
97102
}

0 commit comments

Comments
 (0)