Skip to content

Commit dfc4b18

Browse files
V2 - Support for Angular 17, new build system, new defaults (#179)
* WIP * updated most deps, remove prettier + husky * allow customization of output locations see angular/angular-cli#26675 * trigger new build * Update README.md * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update README.md Co-authored-by: Ferdinand Malcher <[email protected]> * + ng deploy --dir=dist/test/browser * typo * Update docs/README_standalone.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update docs/README_standalone.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update docs/README_standalone.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/angular-cli-ghpages Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/deploy/schema.json Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/deploy/schema.json Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/engine/engine.ts Co-authored-by: Ferdinand Malcher <[email protected]> * Update docs/README_standalone.md * Update src/engine/engine.ts Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/engine/engine.ts Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/package.json Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/package.json Co-authored-by: Ferdinand Malcher <[email protected]> * Update docs/README_standalone.md Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/deploy/schema.json Co-authored-by: Ferdinand Malcher <[email protected]> * Update src/deploy/actions.ts Co-authored-by: Ferdinand Malcher <[email protected]> --------- Co-authored-by: Ferdinand Malcher <[email protected]>
1 parent 56b2bd7 commit dfc4b18

17 files changed

+2649
-10908
lines changed

.circleci/config.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
run: |
3838
cd your-angular-project
39-
ng deploy --no-silent --name="The Buildbot" --email="[email protected]" --cname=angular-cli-ghpages.angular.schule
39+
ng deploy --name="The Buildbot" --email="[email protected]" --cname=angular-cli-ghpages.angular.schule

.vscode/launch.json

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "launch",
10-
"name": "Launch Standalone Program",
11-
"cwd": "${workspaceRoot}/src",
12-
"program": "${workspaceFolder}/src/dist/angular-cli-ghpages",
13-
"outFiles": [
14-
"${workspaceFolder}/src/dist/**/*.js"
15-
],
16-
"args": [
17-
//"--no-silent",
18-
//"--dry-run",
19-
"--dir=mini-testdrive",
20-
"--cname=angular-cli-ghpages.angular.schule"
21-
],
22-
"stopOnEntry": true,
23-
"sourceMaps": true,
24-
"preLaunchTask": "npm build",
25-
},
26-
{
27-
"name": "Debug Jest Tests",
28-
"type": "node",
29-
"request": "launch",
30-
"runtimeArgs": [
31-
"--inspect-brk",
32-
"${workspaceRoot}/src/node_modules/.bin/jest",
33-
"--runInBand"
34-
],
35-
"cwd": "${workspaceFolder}/src",
36-
"console": "integratedTerminal",
37-
"internalConsoleOptions": "neverOpen",
38-
"port": 9229
39-
}
40-
]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Standalone Program",
11+
"cwd": "${workspaceRoot}/src",
12+
"program": "${workspaceFolder}/src/dist/angular-cli-ghpages",
13+
"outFiles": ["${workspaceFolder}/src/dist/**/*.js"],
14+
"args": [
15+
//"--dry-run",
16+
"--dir=mini-testdrive",
17+
"--cname=angular-cli-ghpages.angular.schule"
18+
],
19+
"stopOnEntry": true,
20+
"sourceMaps": true,
21+
"preLaunchTask": "npm build"
22+
},
23+
{
24+
"name": "Debug Jest Tests",
25+
"type": "node",
26+
"request": "launch",
27+
"runtimeArgs": [
28+
"--inspect-brk",
29+
"${workspaceRoot}/src/node_modules/.bin/jest",
30+
"--runInBand"
31+
],
32+
"cwd": "${workspaceFolder}/src",
33+
"console": "integratedTerminal",
34+
"internalConsoleOptions": "neverOpen",
35+
"port": 9229
36+
}
37+
]
4138
}

README.md

Lines changed: 81 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# angular-cli-ghpages
22

33
[![NPM version][npm-image]][npm-url]
4-
[![CircleCI](https://circleci.com/gh/angular-schule/angular-cli-ghpages.svg?style=svg)](https://circleci.com/gh/angular-schule/angular-cli-ghpages)
54
[![GitHub Actions](https://github.com/angular-schule/angular-cli-ghpages/actions/workflows/main.yml/badge.svg)](https://github.com/angular-schule/angular-cli-ghpages/actions/workflows/main.yml)
65
[![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg?color=blue&style=flat-square)](http://opensource.org/licenses/MIT)
76

8-
**Deploy your Angular app to GitHub Pages or any other Git repo directly from the Angular CLI! 🚀**
7+
**Deploy your Angular app to GitHub Pages, Cloudflare Pages or any other Git repo directly from the Angular CLI! 🚀**
98

109
![Screenshot](docs/img/angular-cli-ghpages-deploy.gif)
1110

@@ -24,8 +23,9 @@
2423
- [--message](#message)
2524
- [--branch](#branch)
2625
- [--name & --email](#name)
27-
- [--no-silent](#no-silent)
2826
- [--no-dotfiles](#no-dotfiles)
27+
- [--no-notfound](#no-notfound)
28+
- [--no-nojekyll](#no-nojekyll)
2929
- [--cname](#cname)
3030
- [--dry-run](#dry-run)
3131
7. [📁 Configuration File](#configuration-file)
@@ -38,39 +38,64 @@
3838

3939
A detailed changelog is available in the [releases](https://github.com/angular-schule/angular-cli-ghpages/releases) section.
4040

41-
**⚠️ BREAKING CHANGE (v1)**
41+
**⚠️ BREAKING CHANGE (v2)**
4242

43-
Starting with version 1 the option `--configuration` was renamed to `--build-target`.
43+
The internal build of Angular has changed with Angular 17.
44+
Unfortunately, there are now a lot of different _build targets_ and builders.
45+
We will try to guess the correct build target, based on the usual conventions to name them.
46+
The conventions are shown below, try to specify the build target more and more explicitly until the project compiles.
4447

45-
BEFORE (_does not work_):
48+
In the following example, your app is called `test` and you want to deploy the `production` build.
4649

47-
```
48-
ng deploy --configuration=test
50+
```bash
51+
ng deploy
4952
```
5053

51-
NOW:
54+
If this doesn't work, try this:
5255

53-
```
56+
```bash
5457
ng deploy --build-target=test
5558
```
5659

57-
If you use the old syntax, you will probably receive the following error:
60+
If this doesn't work, try this:
5861

59-
> An unhandled exception occurred: Configuration 'test' is not set in the workspace.
62+
```bash
63+
ng deploy --build-target=test:build:production
64+
```
6065

61-
<br>
66+
You can also and modify your `angular.json` to archive the same:
6267

63-
**🐙 GitHub Actions** is now properly supported alongside Travis CI and CircleCi. The token `GITHUB_TOKEN` is also supported. Learn everything you need to know in the following article:
68+
```json
69+
{
70+
"deploy": {
71+
"builder": "angular-cli-ghpages:deploy",
72+
"options": {
73+
"buildTarget": "test:build:production"
74+
}
75+
}
76+
}
77+
```
78+
79+
For your convenience, you can also use `prerenderTarget` (which adds the suffix `:prerender:production`).
80+
There is no support for `universalBuildTarget` or `serverTarget` because Github Pages only supports static assets and no Server-Side Rendering!
81+
82+
We will then try to deploy the `dist/test/browser` folder to Github Pages.
83+
If this is not the folder that you want to serve, you should explicitly specify the directory with the `--dir` option:
84+
85+
```bash
86+
ng deploy --dir=dist/test/browser
87+
```
6488

65-
**[Everything GitHub: Continuous Integration, Deployment and Hosting for your Angular App](https://angular.schule/blog/2020-01-everything-github)**
89+
This new build logic is a breaking change, therefore `angular-cli-ghpages` v2 only supports Angular 17 and higher.
90+
For previous versions of Angular, use `angular-cli-ghpages` v1.x.
6691

6792
## ⚠️ Prerequisites <a name="prerequisites"></a>
6893

6994
This command has the following prerequisites:
7095

7196
- Git 1.9 or higher (execute `git --version` to check your version)
72-
- Angular project created via [Angular CLI](https://github.com/angular/angular-cli) v9.0.0 or greater
73-
- older Angular projects can still use the standalone program. See the documentation at [README_standalone](https://github.com/angular-schule/angular-cli-ghpages/blob/master/docs/README_standalone.md).
97+
- Angular project created via [Angular CLI](https://github.com/angular/angular-cli) v17 or greater
98+
- older Angular projects can still use a v1.x version or use the standalone program. See the documentation at [README_standalone](https://github.com/angular-schule/angular-cli-ghpages/blob/master/docs/README_standalone.md).
7499

75100
## 🚀 Quick Start (local development) <a name="quickstart-local"></a>
76101

@@ -165,11 +190,6 @@ ng deploy --repo=https://github.com/<username>/<repositoryname>.git --name="Your
165190

166191
(replace `<username>` and `<repositoryname>` with your username from GitHub and the name of your repository)
167192

168-
> **⚠️Important**
169-
>
170-
> Please **do not disable the silent mode** if you use tokens, otherwise people could read them in the output logs.
171-
> If you are sure that your CI/CD provider does not display secrets on the console (this applies to CircleCI / Travis CI and Github Actions), you are welcome to disable silent mode.
172-
173193
> **ℹ️ Note for GitHub Actions**
174194
>
175195
> The `GITHUB_TOKEN` (installation access token) will only trigger a release of a new website if the action runs in a private repository. In a public repo, a commit is generated, but the site does not change. See this [GitHub Community post](https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/26869) for more info. If your repo is public, you must still use the `GH_TOKEN` (personal access token).
@@ -304,43 +324,44 @@ If you run the command in a repository without `user.name` or `user.email` Git c
304324
you must provide user info before Git allows you to commit.
305325
In this case, provide **both** `name` and `email` string values to identify the committer.
306326

307-
#### --no-silent <a name="no-silent"></a>
327+
#### --no-dotfiles <a name="no-dotfiles"></a>
308328

309329
- **optional**
310-
- Default: silent `true` (boolean)
330+
- Default: Dotfiles are created (boolean `true`)
311331
- Example:
312-
- `ng deploy`Logging is in silent mode by default.
313-
- `ng deploy --no-silent`Logging shows extended information.
332+
- `ng deploy`Dotfiles are included by default.
333+
- `ng deploy --no-dotfiles`Dotfiles are ignored.
314334

315-
Logging is in silent mode by default.
316-
In silent mode, the error messages for git operations are always sanitized.
317-
(The message is always: `'Unspecified error (run without silent option for detail)'`)
335+
The command includes dotfiles by default (e.g. `.htaccess` will be committed).
336+
With `--no-dotfiles` files starting with `.` are ignored.
318337

319-
The `--no-silent` option enables detailed error messages and extended console logging.
320-
Keep this untouched if the repository URL or other information passed to git commands is sensitive!
338+
#### --no-notfound <a name="no-notfound"></a>
321339

322-
> **⚠️ WARNING**
323-
>
324-
> This option should be kept as it is if the repository URL or other information passed to Git commands is sensitive and should not be logged (== you have a public build server and you are using the token feature).
325-
> By default the silent mode is enabled to avoid sensitive data exposure.
340+
- **optional**
341+
- Default: `404.html` file is created (boolean `true`)
342+
- Example:
343+
- `ng deploy` – A `404.html` file is created by default.
344+
- `ng deploy --no-notfound` – No `404.html` file is created.
326345

327-
#### --no-dotfiles <a name="no-dotfiles"></a>
346+
By default a `404.html` file is created, because this is the only known workaround to avoid 404 error messages on GitHub Pages.
347+
For Cloudflare Pages we highly recommend to disable the `404.html` file by setting this switch to true! see [#178](https://github.com/angular-schule/angular-cli-ghpages/issues/178)
348+
349+
#### --no-nojekyll <a name="no-nojekyll"></a>
328350

329351
- **optional**
330-
- Default: dotfiles `true` (boolean)
352+
- Default: `.nojekyll` file is created (boolean `true`)
331353
- Example:
332-
- `ng deploy`Dotfiles are included by default.
333-
- `ng deploy --no-dotfiles`Dotfiles are ignored.
354+
- `ng deploy`A `.nojekyll` file is created by default.
355+
- `ng deploy --no-nojekyll`No `.nojekyll` file is created.
334356

335-
The command includes dotfiles by default (e.g. `.htaccess` will be committed).
336-
With `--no-dotfiles` files starting with `.` are ignored.
357+
By default a `.nojekyll` file is created, because we assume you don't want to compile the build again with Jekyll.
337358

338-
**Hint:**
339-
This is super useful if you want to publish a `.nojekyll` file.
340-
Create such a file in the root of your pages repo to bypass the Jekyll static site generator on GitHub Pages.
359+
**Explanation:**
360+
By creating such a file in the root of your pages repo, you will bypass the Jekyll static site generator on GitHub Pages.
341361
Static content is still delivered – even without Jekyll.
342-
This should only be necessary if your site uses files or directories that start with **\_underscores** since Jekyll considers these to be special resources and does not copy them to the final site.
343-
→ Or just don't use underscores!
362+
But now the deployment will be a bit faster.
363+
This is also necessary if your site uses files or directories that start with **\_underscores** since Jekyll considers these to be special resources and does not copy them to the final site.
364+
The same applies to `.txt` files in your assets folder: They will just disappear if Jekyll processes the build. see [#160](https://github.com/angular-schule/angular-cli-ghpages/issues/160)
344365

345366
#### --cname <a name="cname"></a>
346367

@@ -352,6 +373,15 @@ This should only be necessary if your site uses files or directories that start
352373
A CNAME file will be created enabling you to use a custom domain.
353374
[More information on GitHub Pages using a custom domain](https://help.github.com/articles/using-a-custom-domain-with-github-pages/).
354375

376+
#### --dir <a name="dir"></a>
377+
378+
- **optional**
379+
- Default: `undefined` (string) – Conventions will be used to guess the correct directory in your `dist` folder.
380+
- Example:
381+
- `ng deploy --dir=dist/completely-different-folder/en`
382+
383+
Overrides the directory for all published sources, relative to the current working directory.
384+
355385
#### --dry-run <a name="dry-run"></a>
356386

357387
- **optional**
@@ -375,9 +405,11 @@ To avoid all these command-line cmd options, you can write down your configurati
375405
- branch
376406
- name
377407
- email
378-
- noSilent
379408
- noDotfiles
409+
- noNotfound
410+
- noNojekyll
380411
- cname
412+
- dir
381413
- dryRun
382414

383415
A list of all available options is also available [here](https://github.com/angular-schule/angular-cli-ghpages/blob/master/src/deploy/schema.json).
@@ -413,7 +445,7 @@ Now you can just run `ng deploy` without all the options in the command line!
413445
We have seen `angular-cli-ghpages` running on various environments, like Travis CI, CircleCi or Github Actions.
414446
Please share your knowledge by writing an article about how to set up the deployment.
415447

416-
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)
448+
1. [GitHub Actions](https://angular.schule/blog/2020-01-everything-github)
417449
2. Travis CI
418450
3. CircleCI
419451

@@ -428,11 +460,9 @@ Code released under the [MIT license](LICENSE).
428460

429461
<hr>
430462

431-
## 🚀 Powered by [ngx-deploy-starter](https://github.com/angular-schule/ngx-deploy-starter)
432-
433463
<img src="https://assets.angular.schule/logo-angular-schule.png" height="60">
434464

435-
### &copy; 2017-2022 https://angular.schule
465+
### &copy; 2017-2024 https://angular.schule
436466

437467
This project is made on top of [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
438468
Thank you very much for this great foundation!

docs/README_contributors.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Execute the next three steps, if your test project is still older.
4040
npm install -g @angular/cli
4141
```
4242

43-
2. Run `ng version`, to make sure you have installed Angular v9.0.0 or greater.
43+
2. Run `ng version`, to make sure you have installed Angular v17 or greater.
4444

4545
3. Update your existing project using the command:
4646

@@ -179,7 +179,6 @@ Use VSCode and debug the task `Launch Standalone Program`.
179179

180180
```
181181
cd angular-cli-ghpages/src
182-
npm run prettier
183182
npm run build
184183
npm run test
185184
npm run publish-to-npm

0 commit comments

Comments
 (0)