Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,15 @@ jobs:
npx ng deploy
cd /tmp/remote-21.git && git branch | grep gh-pages
echo "Angular 21: build + deploy successful"
- name: Test Angular 22
run: |
cd /tmp
git init --bare remote-22.git
npx @angular/cli@22 new test-app-22 --defaults
cd test-app-22
git remote add origin /tmp/remote-22.git
npm link angular-cli-ghpages
npx ng add angular-cli-ghpages
npx ng deploy
cd /tmp/remote-22.git && git branch | grep gh-pages
echo "Angular 22: build + deploy successful"
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"preLaunchTask": "npm build"
},
{
"name": "Debug Jest Tests",
"name": "Debug Vitest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/src/node_modules/.bin/jest",
"--runInBand"
"${workspaceRoot}/src/node_modules/.bin/vitest",
"--run",
"--no-file-parallelism"
],
"cwd": "${workspaceFolder}/src",
"console": "integratedTerminal",
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ The engine appends CI metadata to commit messages when running on:

## Testing

- Uses Jest (`npm test`), tests in `*.spec.ts` files
- Uses Vitest (`npm test`), tests in `*.spec.ts` files
- Requires git clone with `origin` remote (see `test-prerequisites.spec.ts`)
- All tests preserve/restore `process.env` using `originalEnv` pattern
- **No test counts in documentation** - they become stale quickly and are bragging
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

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

`angular-cli-ghpages` v3 supports Angular 18 to 21.
`angular-cli-ghpages` v3 supports Angular 18 to 22.
For previous versions of Angular, use v1 or v2.

## ⚠️ Prerequisites <a name="prerequisites"></a>
Expand All @@ -67,7 +67,7 @@ If you already have an existing Angular project on GitHub, skip steps 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
Expand Down Expand Up @@ -108,7 +108,7 @@ If you already have an existing Angular project on GitHub, skip steps 1 and 2.

Please be aware of the `--base-href` option. It is necessary when your project will be deployed to a non-root folder. See more details below.

5. Your project should be available at `https://<username>.github.io/<repositoryname>`.
5. Your project should be available at `https://<username>.github.io/<repositoryname>`.
Learn more about GitHub pages on the [official website](https://pages.github.com/).

## ⚙️ Installation <a name="installation"></a>
Expand Down Expand Up @@ -267,7 +267,7 @@ Learn more about ["personal access tokens" here](https://help.github.com/article
- Default: `Auto-generated commit` (string)
- Example: `ng deploy --message="What could possibly go wrong?"`

The commit message **must be wrapped in quotes** if there are any spaces in the text.
The commit message **must be wrapped in quotes** if there are any spaces in the text.
Some additional text is always added to the message, if the command runs on Travis CI, CircleCI or GitHub Actions.

#### --branch <a name="branch"></a>
Expand Down
27 changes: 17 additions & 10 deletions docs/README_contributors.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# angular-cli-ghpages: README for contributors

- [How to start](#how-to-start)
- [Local development](#local-development)
- [1. Angular CLI](#1-angular-cli)
- [2. npm link](#2-npm-link)
- [3. Adding to an Angular project -- ng add](#3-adding-to-an-angular-project----ng-add)
- [4. Testing](#4-testing)
- [5. Debugging](#5-debugging)
- [Testing the standalone CLI](#testing-the-standalone-cli)
- [Publish to NPM](#publish-to-npm)
- [angular-cli-ghpages: README for contributors](#angular-cli-ghpages-readme-for-contributors)
- [How to start](#how-to-start)
- [Local development](#local-development)
- [1. Optional: Latest Angular version](#1-optional-latest-angular-version)
- [2. npm link](#2-npm-link)
- [3. Adding to an Angular project -- ng add](#3-adding-to-an-angular-project----ng-add)
- [4. Testing](#4-testing)
- [5. Debugging](#5-debugging)
- [Testing the standalone CLI](#testing-the-standalone-cli)
- [Publish to NPM](#publish-to-npm)
- [Programmatic Usage](#programmatic-usage)
- [Available Types](#available-types)
- [Advanced: Angular Builder Integration](#advanced-angular-builder-integration)
- [Dependency on gh-pages Internal API](#dependency-on-gh-pages-internal-api)
- [Remote URL Discovery](#remote-url-discovery)
- [Keeping track of all the forks](#keeping-track-of-all-the-forks)

## How to start

Expand Down Expand Up @@ -150,7 +157,7 @@ Once you have completed the previous steps to `npm link` the local copy of `angu

### 4. Testing

Testing is done with [Jest](https://jestjs.io/).
Testing is done with [Vitest](https://vitest.dev/).
To run the tests:

```sh
Expand Down
71 changes: 70 additions & 1 deletion src/__snapshots__/ng-add.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ng-add > generating files > generates new files if starting from scratch 1`] = `
"{
"version": 1,
"projects": {
"THEPROJECT": {
"projectType": "application",
"root": "PROJECTROOT",
"architect": {
"build": {
"options": {
"outputPath": "dist/THEPROJECT"
}
},
"deploy": {
"builder": "angular-cli-ghpages:deploy"
}
}
},
"OTHERPROJECT": {
"projectType": "application",
"root": "PROJECTROOT",
"architect": {
"build": {
"options": {
"outputPath": "dist/OTHERPROJECT"
}
}
}
}
}
}"
`;

exports[`ng-add > generating files > overrides existing files 1`] = `
"{
"version": 1,
"projects": {
"THEPROJECT": {
"projectType": "application",
"root": "PROJECTROOT",
"architect": {
"build": {
"options": {
"outputPath": "dist/THEPROJECT"
}
},
"deploy": {
"builder": "angular-cli-ghpages:deploy"
}
}
},
"OTHERPROJECT": {
"projectType": "application",
"root": "PROJECTROOT",
"architect": {
"build": {
"options": {
"outputPath": "dist/OTHERPROJECT"
}
},
"deploy": {
"builder": "angular-cli-ghpages:deploy"
}
}
}
}
}"
`;

exports[`ng-add generating files generates new files if starting from scratch 1`] = `
"{
Expand Down
10 changes: 6 additions & 4 deletions src/commander-fork/test/test.command.allowUnknownOption.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MockInstance } from "vitest";

/**
* Module dependencies.
*/
Expand All @@ -7,17 +9,17 @@ const commander = require('../');
// , should = require('should');

describe('command.allowUnknownOption', () => {
let stubError: jest.SpyInstance;
let stubExit: jest.SpyInstance;
let stubError: MockInstance;
let stubExit: MockInstance;

function resetStubStatus() {
stubError.mockClear();
stubExit.mockClear();
}

beforeEach(() => {
stubError = jest.spyOn(console, 'error').mockImplementation(() => {});
stubExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
stubError = vi.spyOn(console, 'error').mockImplementation(() => {});
stubExit = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
return undefined as never;
});
});
Expand Down
48 changes: 23 additions & 25 deletions src/commander-fork/test/test.fork-fixes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
/**
* Tests for angular-cli-ghpages fork-specific fixes and features
*
*
* This file contains tests for the 2 intentional improvements we made
* to commander v3.0.2 for angular-cli-ghpages:
*
*
* FIX 1/2: Tightened negate detection regex
* FIX 2/2: Support for short-only and custom version flags
*
*
* These tests do NOT exist in the original commander v3.0.2.
*/

import { MockInstance } from "vitest";

const commander = require('../');

describe('Fork Fix 1: Negate detection with tightened regex', () => {
// This is implicitly tested by test.options.bool.no.spec.ts
// No additional tests needed here
});

describe('Fork Fix 2: Version short-only and custom flags', () => {
describe('version() with short-only flag', () => {
let exitSpy: jest.SpyInstance;
let writeSpy: jest.SpyInstance;
let exitSpy: MockInstance;
let writeSpy: MockInstance;
let captured: {out: string, code: null | number};

beforeEach(() => {
captured = {out: '', code: null};
exitSpy = jest.spyOn(process, 'exit').mockImplementation((c?: number) => {
exitSpy = vi.spyOn(process, 'exit').mockImplementation((c?: number) => {
captured.code = c ?? 0;
return undefined as never;
});
writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation((s: string | Uint8Array) => {
writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation((s: string | Uint8Array) => {
captured.out += s;
return true;
});
Expand Down Expand Up @@ -68,17 +66,17 @@ describe('Fork Fix 2: Version short-only and custom flags', () => {
});

describe('helpOption() with custom flags', () => {
let exitSpy: jest.SpyInstance;
let writeSpy: jest.SpyInstance;
let exitSpy: MockInstance;
let writeSpy: MockInstance;
let exitCode: null | number;

beforeEach(() => {
exitCode = null;
exitSpy = jest.spyOn(process, 'exit').mockImplementation((c?: number) => {
exitSpy = vi.spyOn(process, 'exit').mockImplementation((c?: number) => {
exitCode = c ?? 0;
throw new Error(`exit(${c})`);
});
writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
});

afterEach(() => {
Expand All @@ -88,7 +86,7 @@ describe('Fork Fix 2: Version short-only and custom flags', () => {

it('fires help listener with default flags', () => {
const program = new commander.Command();
const spy = jest.fn();
const spy = vi.fn();
program.on('--help', spy);
expect(() => program.parse(['node', 'x', '--help'])).toThrow('exit(0)');
expect(spy).toHaveBeenCalled();
Expand All @@ -97,7 +95,7 @@ describe('Fork Fix 2: Version short-only and custom flags', () => {

it('fires help listener after helpOption override', () => {
const program = new commander.Command().helpOption('-?, --helpme');
const spy = jest.fn();
const spy = vi.fn();
program.on('--helpme', spy);
expect(() => program.parse(['node', 'x', '--helpme'])).toThrow('exit(0)');
expect(spy).toHaveBeenCalled();
Expand All @@ -106,14 +104,14 @@ describe('Fork Fix 2: Version short-only and custom flags', () => {
});

describe('opts() includes version with custom flags', () => {
let exitSpy: jest.SpyInstance;
let writeSpy: jest.SpyInstance;
let exitSpy: MockInstance;
let writeSpy: MockInstance;

beforeEach(() => {
exitSpy = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
return undefined as never;
});
writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => true);
writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
});

afterEach(() => {
Expand Down Expand Up @@ -174,12 +172,12 @@ describe('Fork Fix 2: Version short-only and custom flags', () => {
});

describe('unknown options with attached values', () => {
let errSpy: jest.SpyInstance;
let exitSpy: jest.SpyInstance;
let errSpy: MockInstance;
let exitSpy: MockInstance;

beforeEach(() => {
errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
exitSpy = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
return undefined as never;
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/commander-fork/test/test.options.version.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { MockInstance } from "vitest";

const commander = require('../');
// var program = require('../')
// , should = require('should');

describe('options.version', () => {
let capturedExitCode: number;
let capturedOutput: string;
let exitSpy: jest.SpyInstance;
let writeSpy: jest.SpyInstance;
let exitSpy: MockInstance;
let writeSpy: MockInstance;

// program.version('0.0.1');

Expand All @@ -17,11 +19,11 @@ let writeSpy: jest.SpyInstance;
capturedExitCode = -1;
capturedOutput = '';

exitSpy = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
exitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
capturedExitCode = code ?? 0;
return undefined as never;
});
writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation((output: string | Uint8Array) => {
writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation((output: string | Uint8Array) => {
capturedOutput += output;
return true;
});
Expand Down
Loading