From a70b477bdc4ed2de797fa6382ac353a944f38e4c Mon Sep 17 00:00:00 2001 From: Kiryl Bahdanau Date: Fri, 3 May 2024 15:17:33 +0200 Subject: [PATCH 1/9] docs: update example to recent version of actions and Node.js v20 (#183) Node 16 is almost deprecated and cause warnings --- docs/README_environment_github_actions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README_environment_github_actions.md b/docs/README_environment_github_actions.md index 734a930..2de0bfe 100644 --- a/docs/README_environment_github_actions.md +++ b/docs/README_environment_github_actions.md @@ -50,12 +50,12 @@ More info can be found here: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Use Node.js 16.x - uses: actions/setup-node@v3 + - name: Use Node.js 20.x + uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 20.x cache: "npm" - name: Prepare and deploy From 97271a9f9a5b76dedf48160b6b133279eaa98bc4 Mon Sep 17 00:00:00 2001 From: Kiryl Bahdanau Date: Wed, 8 May 2024 11:15:14 +0200 Subject: [PATCH 2/9] Add one more step to run tests and deploy only if tests are passing (#184) * Add one more step to run tests and deploy only if tests are passing * Update docs/README_environment_github_actions.md Co-authored-by: Ferdinand Malcher --------- Co-authored-by: Ferdinand Malcher --- docs/README_environment_github_actions.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/README_environment_github_actions.md b/docs/README_environment_github_actions.md index 2de0bfe..61fa9e7 100644 --- a/docs/README_environment_github_actions.md +++ b/docs/README_environment_github_actions.md @@ -58,16 +58,21 @@ More info can be found here: node-version: 20.x cache: "npm" + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm run ng -- test --no-watch --no-progress --browsers=ChromeHeadless + - name: Prepare and deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - npm install - npm run ng -- deploy --base-href=/the-repository-name/ --name="Displayed Username" --email="mail@example.org" + run: npm run ng -- deploy --base-href=/the-repository-name/ --name="Displayed Username" --email="mail@example.org" ``` 6. Make sure to replace **`/the-repository-name/`**, **`Displayed Username`** and **`mail@example.org`** with correct values in above snippet. -7. You can also control when your workflows are triggered: +7. If you do not have tests you may remove the step "Run tests" from the example. +8. You can also control when your workflows are triggered: - It can be helpful to not have your workflows run on every push to every branch in the repo. @@ -100,8 +105,8 @@ More info can be found here: - For more information see [Events that trigger workflows](https://help.github.com/articles/events-that-trigger-workflows) and [Workflow syntax for GitHub Actions](https://help.github.com/articles/workflow-syntax-for-github-actions#on). -8. Commit and Push to add the workflow file. -9. Done. +9. Commit and Push to add the workflow file. +10. Done. --- From accfd971ba9da543f5c116232974ce1a0ca6cedb Mon Sep 17 00:00:00 2001 From: Ignacio Salcedo Date: Sun, 26 May 2024 23:24:50 -0500 Subject: [PATCH 3/9] "feat: add support for "add" parameter in angular-cli-ghpages" (#188) --- .gitignore | 1 + README.md | 37 +++++++++++++++++++++++------------ docs/README_standalone.md | 19 ++++++++++++++---- src/angular-cli-ghpages | 5 +++++ src/deploy/schema.json | 5 +++++ src/engine/defaults.ts | 1 + src/engine/engine.ts | 41 ++++++++++++++++++++------------------- src/package-lock.json | 4 ++-- 8 files changed, 75 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index a4d70b0..8bfdd75 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules *.swp *.swo *.d.ts +.idea *.classpath *.project diff --git a/README.md b/README.md index d536e0c..a98a1a2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ - [--no-notfound](#no-notfound) - [--no-nojekyll](#no-nojekyll) - [--cname](#cname) + - [--add](#add) - [--dry-run](#dry-run) 7. [📁 Configuration File](#configuration-file) 8. [🌍 Environments](#environments) @@ -77,9 +78,9 @@ You can also and modify your `angular.json` to archive the same: ``` For your convenience, you can also use `prerenderTarget` (which adds the suffix `:prerender:production`). -There is no support for `universalBuildTarget` or `serverTarget` because Github Pages only supports static assets and no Server-Side Rendering! +There is no support for `universalBuildTarget` or `serverTarget` because GitHub Pages only supports static assets and no Server-Side Rendering! -We will then try to deploy the `dist/test/browser` folder to Github Pages. +We will then try to deploy the `dist/test/browser` folder to GitHub Pages. If this is not the folder that you want to serve, you should explicitly specify the directory with the `--dir` option: ```bash @@ -111,7 +112,7 @@ If you already have an existing Angular project on GitHub, skip step 1 and 2. cd your-angular-project ``` -2. By default the Angular CLI initializes a Git repository for you. +2. By default, the Angular CLI initializes a Git repository for you. To add a new remote for GitHub, use the `git remote add` command: ```sh @@ -167,8 +168,8 @@ ng add angular-cli-ghpages --project MYPROJECTNAME ## 🚀 Continuous Delivery If you run this command from a CI/CD environment, the deployment will most likely not work out of the box. -For security reasons, those environments usually have read-only privileges or you haven't set up Git correctly. -Therefore you should take a look at ["personal access tokens" `GH_TOKEN`](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) (which works everywhere) and the ["installation access token" `GITHUB_TOKEN`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token) (which is exclusively provided by GitHub actions). +For security reasons, those environments usually have read-only privileges, or you haven't set up Git correctly. +Therefore, you should take a look at ["personal access tokens" `GH_TOKEN`](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) (which works everywhere) and the ["installation access token" `GITHUB_TOKEN`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token) (which is exclusively provided by GitHub actions). In short: a token replaces username and password and is a safer choice because a token can be revoked at any time. All you need to do is to set an environment variable called `GH_TOKEN` (or `PERSONAL_TOKEN`) in your CI/CD environment. @@ -201,7 +202,7 @@ ng deploy --repo=https://github.com//.git --name="Your - `ng deploy` – The tag `` remains unchanged in your `index.html` - `ng deploy --base-href=/the-repositoryname/` – The tag `` is added to your `index.html` -Specifies the base URL for the application being built. +Specify the base URL for the application being built. Same as `ng build --base-href=/XXX/` **â„šī¸ Please read the next lines carefully, or you will get 404 errors in case of a wrong configuration!** @@ -266,7 +267,7 @@ ng deploy --build-target=test - `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. +Skip the 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 `--build-target` setting to have no effect. @@ -280,7 +281,7 @@ This specifies the target repository. If none is given as an option, the reposit By default, this command assumes that the current working directory is a Git repository, and that you want to push changes to the `origin` remote. -If instead your files are not in a git repository, or if you want to push to another repository, +If instead, your files are not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option. > **â„šī¸ Hint** @@ -340,8 +341,9 @@ With `--no-dotfiles` files starting with `.` are ignored. - `ng deploy` – A `404.html` file is created by default. - `ng deploy --no-notfound` – No `404.html` file is created. -By default a `404.html` file is created, because this is the only known workaround to avoid 404 error messages on GitHub Pages. -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) +By default, a `404.html` file is created, because this is the only known workaround to avoid 404 error messages on GitHub Pages. +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) #### --no-nojekyll @@ -351,7 +353,7 @@ For Cloudflare Pages we highly recommend to disable the `404.html` file by setti - `ng deploy` – A `.nojekyll` file is created by default. - `ng deploy --no-nojekyll` – No `.nojekyll` file is created. -By default a `.nojekyll` file is created, because we assume you don't want to compile the build again with Jekyll. +By default, a `.nojekyll` file is created, because we assume you don't want to compile the build again with Jekyll. **Explanation:** By creating such a file in the root of your pages repo, you will bypass the Jekyll static site generator on GitHub Pages. @@ -370,6 +372,17 @@ The same applies to `.txt` files in your assets folder: They will just disappear A CNAME file will be created enabling you to use a custom domain. [More information on GitHub Pages using a custom domain](https://help.github.com/articles/using-a-custom-domain-with-github-pages/). +#### --add + +- **optional** +- Default: `false` (boolean) – The existing files will be removed from the branch you'll be pushing to as expected. +- Example: + - `ng deploy --add=true` + +If is set to `true`, it will only add, and never remove existing files. +By default, existing files in the target branch are removed before adding the ones. +[More information](https://www.npmjs.com/package/gh-pages#optionsadd). + #### --dir - **optional** @@ -439,7 +452,7 @@ Now you can just run `ng deploy` without all the options in the command line! ## 🌍 Environments -We have seen `angular-cli-ghpages` running on various environments, like Travis CI, CircleCi or Github Actions. +We have seen `angular-cli-ghpages` running on various environments, like Travis CI, CircleCi or GitHub Actions. Please share your knowledge by writing an article about how to set up the deployment. 1. [GitHub Actions](https://angular.schule/blog/2020-01-everything-github) diff --git a/docs/README_standalone.md b/docs/README_standalone.md index de9738b..f974948 100644 --- a/docs/README_standalone.md +++ b/docs/README_standalone.md @@ -1,6 +1,6 @@ # angular-cli-ghpages: README for the standalone program -In the past this project was a standalone program. +In the past, this project was a standalone program. This is still possible. ## Installation & Setup @@ -85,7 +85,7 @@ Output the version number. Please provide the version number on any bug report! By default, **gh-pages** assumes that the current working directory is a git repository, and that you want to push changes to the `origin` remote. -If instead your files are not in a git repository, or if you want to push to another repository, +If instead, your files are not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option. #### --message @@ -125,7 +125,7 @@ In this case provide both `name` and `email` string values to identify the commi - Default: `dist` Directory for all published sources, relative to the current working directory. -**Starting with Angular CLI 6 the build artifacts will be put in a subfolder under `dist`. +**Starting with Angular CLI 6, the build artifacts will be put in a subfolder under `dist`. Please take a look at the `dist` folder to see whether there is a subfolder with your project's name or not.** This option can be used to deploy completely different folders, @@ -139,7 +139,7 @@ which are not related at all to angular. - `npx angular-cli-ghpages` -- Dotfiles are included by default. - `npx angular-cli-ghpages --no-dotfiles` -- Dotfiles are ignored. -The command includes dotfiles by default (e.g `.htaccess` will be committed) +The command includes dotfiles by default (e.g. `.htaccess` will be committed) With `--no-dotfiles` files starting with `.` are ignored. #### --dry-run @@ -161,6 +161,17 @@ Run through without making any changes. This can be very usefull, because it out A CNAME file will be created enabling you to use a custom domain. [More information on Github Pages using a custom domain](https://help.github.com/articles/using-a-custom-domain-with-github-pages/). +#### --add + +- **optional** +- Default: `false` (boolean) – The existing files will be removed from the branch you'll be pushing to as expected. +- Example: + - `npx angular-cli-ghpages --add=true` + +If is set to `true`, it will only add, and never remove existing files. +By default, existing files in the target branch are removed before adding the ones. +[More information](https://www.npmjs.com/package/gh-pages#optionsadd). + ## FAQ Before posting any issue, [please read the FAQ first](https://github.com/angular-schule/angular-cli-ghpages/wiki/FAQ). diff --git a/src/angular-cli-ghpages b/src/angular-cli-ghpages index 6835134..3e7f19e 100755 --- a/src/angular-cli-ghpages +++ b/src/angular-cli-ghpages @@ -65,6 +65,11 @@ commander 'Generate a CNAME file for the specified domain.', defaults.cname ) + .option( + '-a, --add', + 'Only add, and never remove existing files from the GitHub pages branch.', + defaults.add + ) .option( '--dry-run', 'For testing: Run through without making any changes.', diff --git a/src/deploy/schema.json b/src/deploy/schema.json index b4735fa..3729fd7 100644 --- a/src/deploy/schema.json +++ b/src/deploy/schema.json @@ -71,6 +71,11 @@ "description": "Generate a CNAME file for the specified domain.", "default": "" }, + "add": { + "type": "boolean", + "description": "Only add, and never remove existing files from the GitHub pages branch.", + "default": false + }, "dir": { "type": "string", "description": "Overrides the directory for all published sources, relative to the current working directory.", diff --git a/src/engine/defaults.ts b/src/engine/defaults.ts index 65d4cc9..6075781 100644 --- a/src/engine/defaults.ts +++ b/src/engine/defaults.ts @@ -9,6 +9,7 @@ export const defaults = { notfound: true, nojekyll: true, cname: undefined, + add: false, dryRun: false, remote: 'origin', git: 'git' diff --git a/src/engine/engine.ts b/src/engine/engine.ts index 90af3d5..5f47e19 100644 --- a/src/engine/engine.ts +++ b/src/engine/engine.ts @@ -1,10 +1,10 @@ -import { logging } from '@angular-devkit/core'; +import {logging} from '@angular-devkit/core'; import * as fse from 'fs-extra'; import * as path from 'path'; -import { Schema } from '../deploy/schema'; -import { GHPages } from '../interfaces'; -import { defaults } from './defaults'; +import {Schema} from '../deploy/schema'; +import {GHPages} from '../interfaces'; +import {defaults} from './defaults'; import Git from 'gh-pages/lib/git'; @@ -293,22 +293,23 @@ async function publishViaGhPages( if (options.dryRun) { logger.info( `Dry-run / SKIPPED: publishing folder '${dir}' with the following options: ` + - JSON.stringify( - { - dir, - repo: options.repo || 'current working directory (which must be a git repo in this case) will be used to commit & push', - message: options.message, - branch: options.branch, - name: options.name ? `the name '${options.username} will be used for the commit` : 'local or global git user name will be used for the commit', - email: options.email ? `the email '${options.cname} will be used for the commit` : 'local or global git user email will be used for the commit', - dotfiles: options.dotfiles ? `files starting with dot ('.') will be included` : `files starting with dot ('.') will be ignored`, - notfound: options.notfound ? 'a 404.html file will be created' : 'a 404.html file will NOT be created', - nojekyll: options.nojekyll ? 'a .nojekyll file will be created' : 'a .nojekyll file will NOT be created', - cname: options.cname ? `a CNAME file with the content '${options.cname}' will be created` : 'a CNAME file will NOT be created' - }, - null, - ' ' - ) + JSON.stringify( + { + dir, + repo: options.repo || 'current working directory (which must be a git repo in this case) will be used to commit & push', + message: options.message, + branch: options.branch, + name: options.name ? `the name '${options.username} will be used for the commit` : 'local or global git user name will be used for the commit', + email: options.email ? `the email '${options.cname} will be used for the commit` : 'local or global git user email will be used for the commit', + dotfiles: options.dotfiles ? `files starting with dot ('.') will be included` : `files starting with dot ('.') will be ignored`, + notfound: options.notfound ? 'a 404.html file will be created' : 'a 404.html file will NOT be created', + nojekyll: options.nojekyll ? 'a .nojekyll file will be created' : 'a .nojekyll file will NOT be created', + cname: options.cname ? `a CNAME file with the content '${options.cname}' will be created` : 'a CNAME file will NOT be created', + add: options.add ? 'all files will be added to the branch. Existing files will not be removed' : 'existing files will be removed from the branch before adding the new ones', + }, + null, + ' ' + ) ); return; } diff --git a/src/package-lock.json b/src/package-lock.json index 6b9762e..4983a65 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "angular-cli-ghpages", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "angular-cli-ghpages", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.2", "license": "MIT", "dependencies": { "@angular-devkit/architect": "~0.1700.0", From 1fbbb591c6d11797c9bfac9a4a1a51b18ed38b95 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Mon, 27 May 2024 07:38:37 +0200 Subject: [PATCH 4/9] v2.0.0 - with support for Angular 18 --- package-lock.json | 6 ++ src/jest.config.js | 3 +- src/package-lock.json | 140 +++++++++++++++--------------------------- src/package.json | 14 ++--- 4 files changed, 64 insertions(+), 99 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..baa479c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "angular-cli-ghpages", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/src/jest.config.js b/src/jest.config.js index a58c252..97d9d7f 100644 --- a/src/jest.config.js +++ b/src/jest.config.js @@ -1,5 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', - testEnvironment: 'node' + testEnvironment: 'node', + modulePathIgnorePatterns: ['/dist/package.json'] }; diff --git a/src/package-lock.json b/src/package-lock.json index 4983a65..231237f 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,17 +1,17 @@ { "name": "angular-cli-ghpages", - "version": "2.0.0-beta.2", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "angular-cli-ghpages", - "version": "2.0.0-beta.2", + "version": "2.0.0", "license": "MIT", "dependencies": { - "@angular-devkit/architect": "~0.1700.0", - "@angular-devkit/core": "^17.0.0", - "@angular-devkit/schematics": "^17.0.0", + "@angular-devkit/architect": "~0.1800.0", + "@angular-devkit/core": "^18.0.0", + "@angular-devkit/schematics": "^18.0.0", "commander": "^3.0.0-0", "fs-extra": "^11.2.0", "gh-pages": "^3.1.0" @@ -21,9 +21,9 @@ "ngh": "angular-cli-ghpages" }, "devDependencies": { - "@angular-devkit/architect": "~0.1700.0", - "@angular-devkit/core": "^17.0.0", - "@angular-devkit/schematics": "^17.0.0", + "@angular-devkit/architect": "~0.1800.0", + "@angular-devkit/core": "^18.0.0", + "@angular-devkit/schematics": "^18.0.0", "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.11", "@types/node": "^20.11.7", @@ -49,74 +49,35 @@ } }, "node_modules/@angular-devkit/architect": { - "version": "0.1700.10", - "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.1700.10.tgz", - "integrity": "sha512-JD/3jkdN1jrFMIDEk9grKdbjutIoxUDMRazq1LZooWjTkzlYk09i/s6HwvIPao7zvxJfelD6asTPspgkjOMP5A==", + "version": "0.1800.1", + "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.1800.1.tgz", + "integrity": "sha512-L3n1Rh0NUNTlQZBBuPY8VFc5Skr6Oa6xT821k+XLLZTbz1ci2e3ltINyUhqISeksa3AyyL8e4JR2kCbDli9uJA==", "dev": true, "dependencies": { - "@angular-devkit/core": "17.0.10", + "@angular-devkit/core": "18.0.1", "rxjs": "7.8.1" }, "engines": { - "node": "^18.13.0 || >=20.9.0", - "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", - "yarn": ">= 1.13.0" - } - }, - "node_modules/@angular-devkit/architect/node_modules/@angular-devkit/core": { - "version": "17.0.10", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-17.0.10.tgz", - "integrity": "sha512-93N6oHnmtRt0hL3AXxvnk47sN1rHndfj+pqI5haEY41AGWzIWv9cSBsqlM0PWltNpo6VivcExZESvbLJ71wqbQ==", - "dev": true, - "dependencies": { - "ajv": "8.12.0", - "ajv-formats": "2.1.1", - "jsonc-parser": "3.2.0", - "picomatch": "3.0.1", - "rxjs": "7.8.1", - "source-map": "0.7.4" - }, - "engines": { - "node": "^18.13.0 || >=20.9.0", + "node": "^18.19.1 || ^20.11.1 || >=22.0.0", "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", "yarn": ">= 1.13.0" - }, - "peerDependencies": { - "chokidar": "^3.5.2" - }, - "peerDependenciesMeta": { - "chokidar": { - "optional": true - } - } - }, - "node_modules/@angular-devkit/architect/node_modules/picomatch": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", - "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/@angular-devkit/core": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-17.1.1.tgz", - "integrity": "sha512-b1wd1caegc1p18nTrfPhfHQAZW1GnWWKGldq5MZ8C/nkgJbjjN8SKb1Vw7GONkOnH6KxWDAXS4i93/wdQcz4Bg==", + "version": "18.0.1", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-18.0.1.tgz", + "integrity": "sha512-91eKZoObs+wRgwssw81Y/94Nvixj0WqJkNusBAg+gAfZTCEeJoGGZJkRK8wrONbM79C3Bx8lN/TfSIPRbjnfOQ==", "dev": true, "dependencies": { - "ajv": "8.12.0", - "ajv-formats": "2.1.1", - "jsonc-parser": "3.2.0", - "picomatch": "3.0.1", + "ajv": "8.13.0", + "ajv-formats": "3.0.1", + "jsonc-parser": "3.2.1", + "picomatch": "4.0.2", "rxjs": "7.8.1", "source-map": "0.7.4" }, "engines": { - "node": "^18.13.0 || >=20.9.0", + "node": "^18.19.1 || ^20.11.1 || >=22.0.0", "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", "yarn": ">= 1.13.0" }, @@ -130,31 +91,31 @@ } }, "node_modules/@angular-devkit/core/node_modules/picomatch": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-3.0.1.tgz", - "integrity": "sha512-I3EurrIQMlRc9IaAZnqRR044Phh2DXY+55o7uJ0V+hYZAcQYSuFWsc9q5PvyDHUSCe1Qxn/iBz+78s86zWnGag==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/@angular-devkit/schematics": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-17.1.1.tgz", - "integrity": "sha512-3AtEO7k0Znzg11o51ZqebkW8063QkZ7Y7BC96Oye+wSdpT3ow57P0w0UtOpUNesNKzj1iMuPWqqm4i+YqitjCw==", + "version": "18.0.1", + "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-18.0.1.tgz", + "integrity": "sha512-AKcEGa3fIgyXT6XTQZWEJZzgmcqlB89fcF7JFOuz4rgQfRmnE2xFw37lKE6ZclCOSiEoffAvgrL8acjdPI1ouw==", "dev": true, "dependencies": { - "@angular-devkit/core": "17.1.1", - "jsonc-parser": "3.2.0", - "magic-string": "0.30.5", + "@angular-devkit/core": "18.0.1", + "jsonc-parser": "3.2.1", + "magic-string": "0.30.10", "ora": "5.4.1", "rxjs": "7.8.1" }, "engines": { - "node": "^18.13.0 || >=20.9.0", + "node": "^18.19.1 || ^20.11.1 || >=22.0.0", "npm": "^6.11.0 || ^7.5.6 || >=8.0.0", "yarn": ">= 1.13.0" } @@ -1472,15 +1433,15 @@ "dev": true }, "node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz", + "integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==", "dev": true, "dependencies": { - "fast-deep-equal": "^3.1.1", + "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" + "uri-js": "^4.4.1" }, "funding": { "type": "github", @@ -1488,9 +1449,9 @@ } }, "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", "dev": true, "dependencies": { "ajv": "^8.0.0" @@ -3915,9 +3876,9 @@ } }, "node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", + "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", "dev": true }, "node_modules/jsonfile": { @@ -4012,15 +3973,12 @@ } }, "node_modules/magic-string": { - "version": "0.30.5", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", - "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", + "version": "0.30.10", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz", + "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "engines": { - "node": ">=12" } }, "node_modules/make-dir": { @@ -4478,9 +4436,9 @@ } }, "node_modules/punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" diff --git a/src/package.json b/src/package.json index 8b8c785..6554adb 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "angular-cli-ghpages", - "version": "2.0.0-beta.2", + "version": "2.0.0", "description": "Deploy your Angular app to GitHub Pages or Cloudflare Pages directly from the Angular CLI (ng deploy)", "main": "index.js", "bin": { @@ -55,9 +55,9 @@ }, "homepage": "https://github.com/angular-schule/angular-cli-ghpages/#readme", "devDependencies": { - "@angular-devkit/architect": "~0.1700.0", - "@angular-devkit/core": "^17.0.0", - "@angular-devkit/schematics": "^17.0.0", + "@angular-devkit/architect": "~0.1800.0", + "@angular-devkit/core": "^18.0.0", + "@angular-devkit/schematics": "^18.0.0", "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.11", "@types/node": "^20.11.7", @@ -69,9 +69,9 @@ "typescript": "~5.2.2" }, "dependencies": { - "@angular-devkit/architect": "~0.1700.0", - "@angular-devkit/core": "^17.0.0", - "@angular-devkit/schematics": "^17.0.0", + "@angular-devkit/architect": "~0.1800.0", + "@angular-devkit/core": "^18.0.0", + "@angular-devkit/schematics": "^18.0.0", "commander": "^3.0.0-0", "fs-extra": "^11.2.0", "gh-pages": "^3.1.0" From 30c6b0ad26e49267397edd19ae27b3e1f724fe3a Mon Sep 17 00:00:00 2001 From: colinvh0 Date: Mon, 10 Jun 2024 13:42:28 -0700 Subject: [PATCH 5/9] Added --remote option (#191) * Added --remote option * Explicated new feature behavior in --help --- docs/README_standalone.md | 10 ++++++++++ src/angular-cli-ghpages | 7 ++++++- src/deploy/schema.json | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/README_standalone.md b/docs/README_standalone.md index f974948..1bb452d 100644 --- a/docs/README_standalone.md +++ b/docs/README_standalone.md @@ -88,6 +88,16 @@ and that you want to push changes to the `origin` remote. If instead, your files are not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option. +#### --remote + +- **optional** +- Default: `origin` +- Example: `npx angular-cli-ghpages --remote=github` + +By default, **gh-pages** assumes that the current working directory is a git repository, +and that you want to push changes to the `origin` remote. +If you want to push to another remote, you can provide the remote name in the `remote` option. + #### --message - **optional** diff --git a/src/angular-cli-ghpages b/src/angular-cli-ghpages index 3e7f19e..76de2b7 100755 --- a/src/angular-cli-ghpages +++ b/src/angular-cli-ghpages @@ -21,9 +21,14 @@ commander ) .option( '-r, --repo ', - 'Provide the repository URL. If no value is provided, the `origin` remote of the current working directory is used.', + 'Provide the repository URL. If no value is provided, a remote of the current working directory is used (defaults to `origin`; see --remote for details).', defaults.repo ) + .option( + '-R, --remote ', + 'Provide the remote name. If no value is provided, `origin` is used. Has no function if --repo is set.', + defaults.remote + ) .option( '-m, --message ', 'The commit message, must be wrapped in quotes.', diff --git a/src/deploy/schema.json b/src/deploy/schema.json index 3729fd7..f7b5595 100644 --- a/src/deploy/schema.json +++ b/src/deploy/schema.json @@ -24,9 +24,13 @@ "default": false, "description": "Skip build process during deployment." }, + "remote": { + "type": "string", + "description": "Provide the remote name. If no value is provided, `origin` is used. Has no function if --repo is set." + }, "repo": { "type": "string", - "description": "Provide the repository URL. If no value is provided, the `origin` remote of the current working directory is used." + "description": "Provide the repository URL. If no value is provided, a remote of the current working directory is used (defaults to `origin`; see --remote for details)." }, "message": { "type": "string", From 5433e40fe788bac51decdcb54adc5243eab336d8 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Mon, 10 Jun 2024 23:06:51 +0200 Subject: [PATCH 6/9] v2.0.1 with --remote option --- package-lock.json | 6 ------ src/package-lock.json | 4 ++-- src/package.json | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index baa479c..0000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "angular-cli-ghpages", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} diff --git a/src/package-lock.json b/src/package-lock.json index 231237f..09c997a 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "angular-cli-ghpages", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "angular-cli-ghpages", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT", "dependencies": { "@angular-devkit/architect": "~0.1800.0", diff --git a/src/package.json b/src/package.json index 6554adb..6ccae78 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "angular-cli-ghpages", - "version": "2.0.0", + "version": "2.0.1", "description": "Deploy your Angular app to GitHub Pages or Cloudflare Pages directly from the Angular CLI (ng deploy)", "main": "index.js", "bin": { From 0671722ad74cc86a257f94e8593ad7cbc4f1237c Mon Sep 17 00:00:00 2001 From: Ferdinand Malcher Date: Tue, 22 Oct 2024 16:57:20 +0200 Subject: [PATCH 7/9] fix: provide default value for remote option (#194) --- src/deploy/schema.json | 3 ++- src/engine/engine.spec.ts | 16 ++++++++++++++++ src/engine/engine.ts | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/deploy/schema.json b/src/deploy/schema.json index f7b5595..2274f23 100644 --- a/src/deploy/schema.json +++ b/src/deploy/schema.json @@ -26,7 +26,8 @@ }, "remote": { "type": "string", - "description": "Provide the remote name. If no value is provided, `origin` is used. Has no function if --repo is set." + "description": "Provide the remote name. If no value is provided, `origin` is used. Has no function if --repo is set.", + "default": "origin" }, "repo": { "type": "string", diff --git a/src/engine/engine.spec.ts b/src/engine/engine.spec.ts index 1833539..85c12c9 100644 --- a/src/engine/engine.spec.ts +++ b/src/engine/engine.spec.ts @@ -83,6 +83,22 @@ describe('engine', () => { expect(finalOptions.repo).toMatch(/angular-schule\/angular-cli-ghpages/); }); + + describe('remote', () => { + it('should use the provided remote if --remote is set', async () => { + const options = { remote: 'foobar', repo: 'xxx' }; + const finalOptions = await engine.prepareOptions(options, logger); + + expect(finalOptions.remote).toBe('foobar'); + }); + + it('should use the origin remote if --remote is not set', async () => { + const options = { repo: 'xxx' }; + const finalOptions = await engine.prepareOptions(options, logger); + + expect(finalOptions.remote).toBe('origin'); + }); + }); }); describe('prepareOptions - handling dotfiles, notfound, and nojekyll', () => { diff --git a/src/engine/engine.ts b/src/engine/engine.ts index 5f47e19..57ada08 100644 --- a/src/engine/engine.ts +++ b/src/engine/engine.ts @@ -297,6 +297,7 @@ async function publishViaGhPages( { dir, repo: options.repo || 'current working directory (which must be a git repo in this case) will be used to commit & push', + remote: options.remote, message: options.message, branch: options.branch, name: options.name ? `the name '${options.username} will be used for the commit` : 'local or global git user name will be used for the commit', From 8bfa8b03f1a181c0ee6e9753628bc1c560f0bcdc Mon Sep 17 00:00:00 2001 From: Ferdinand Malcher Date: Wed, 23 Oct 2024 06:57:20 +0200 Subject: [PATCH 8/9] build: reactivate CI test deployment (#195) --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99376ec..ab0e23a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 - name: Prepare run: | @@ -31,7 +31,7 @@ jobs: ng add angular-cli-ghpages - name: Deploy - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From 27c3050594749b4f1c6f0bc8b0de60a373c61466 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Wed, 23 Oct 2024 08:42:07 +0200 Subject: [PATCH 9/9] v2.0.3 (wrong deployment) --- src/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package.json b/src/package.json index 6ccae78..cf04f26 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "angular-cli-ghpages", - "version": "2.0.1", + "version": "2.0.3", "description": "Deploy your Angular app to GitHub Pages or Cloudflare Pages directly from the Angular CLI (ng deploy)", "main": "index.js", "bin": {