-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix all tests + handling of dotfiles, notfound, and nojekyll for Comm…
…ander vs. Angular CLI (#180) * fix jest / ts-jest setup * Looks like the angularfire team has now changed their setup like this: https://github.com/angular/angularfire/blob/master/package.json only dependencies and devDependencies, no peerDependencies any longer. And they skipped all previous version, too. So I think I will try this out too: * fixing snapshot file * remove support for deprecated defaultProject setting * fix all unit tests * tests for Commander CLI Options * tests for Angular CLI options * remove own consoleLogger * 2.0.0-beta.2 * 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]> --------- Co-authored-by: Ferdinand Malcher <[email protected]>
- Loading branch information
1 parent
95d8603
commit cb7a1cb
Showing
15 changed files
with
132 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,44 +16,29 @@ The command `npx` is also able to install `angular-cli-ghpages` on the first usa | |
|
||
## Usage | ||
|
||
Execute `npx angular-cli-ghpages` in order to deploy the project with a build from `dist` folder. | ||
**Note: You have to create the `dist` folder first (e.g. by running `ng build --prod`).** | ||
Execute `npx angular-cli-ghpages` in order to deploy the project with a build from `dist` folder. (`dist` is the default) | ||
**Note: You have to create the `dist` folder first (e.g. by running `ng build`).** | ||
|
||
Usage: | ||
Since Angular CLI 6 the build artifacts will be put in a subfolder, e.g. `dist/PROJECTNAME`. | ||
Since Angular CLI 17 the build artifacts will be put in a subfolder, followed by the folder `browser`, e.g. `dist/PROJECTNAME/browser`. | ||
|
||
```bash | ||
ng build --prod --base-href "https://USERNAME.github.io/REPOSITORY_NAME/" | ||
npx angular-cli-ghpages [OPTIONS] | ||
``` | ||
Please take a look at the `dist` folder to see whether there is a subfolder with your project's name or not. | ||
If yes, you need to specify the deploy directory manually then when using this tool: | ||
|
||
or | ||
Usage: | ||
|
||
```bash | ||
ng build --prod --base-href "/REPOSITORY_NAME/" | ||
npx angular-cli-ghpages [OPTIONS] | ||
ng build --base-href "/REPOSITORY_NAME/" | ||
npx angular-cli-ghpages --dir=dist/[PROJECTNAME]/browser | ||
``` | ||
|
||
or (`<base href="/">` stays untouched) | ||
|
||
```bash | ||
ng build --prod | ||
npx angular-cli-ghpages [OPTIONS] | ||
ng build | ||
npx angular-cli-ghpages [OPTIONS] --dir=dist/[PROJECTNAME]/browser | ||
``` | ||
|
||
If you want to push to `gh-pages` on the same repository with your default credentials, then just enter `npx angular-cli-ghpages` without any options. | ||
|
||
### Usage with Angular CLI 6 or higher | ||
|
||
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. | ||
If yes, you need to specify the deploy directory manually then when using this tool: | ||
|
||
```bash | ||
npx angular-cli-ghpages --dir=dist/[PROJECTNAME] | ||
``` | ||
|
||
I most cases, the `[PROJECTNAME]` can be found in the `angular.json` file at `defaultProject`. | ||
|
||
### Usage with Ionic | ||
|
||
You can use the tool with Angular based Ionic projects, too. Instead of the ` dist` folder, the Ionic CLI will create a `www` folder you have to point the tool to. Just use the following commands: | ||
|
@@ -76,7 +61,7 @@ In example, the following command runs [on our Travis-CI](https://travis-ci.org/ | |
npx angular-cli-ghpages --repo=https://[email protected]/<username>/<repositoryname>.git --name="Displayed Username" [email protected] | ||
``` | ||
|
||
> You have to treat the GH_TOKEN as secure as a password! | ||
> Don't share the GH_TOKEN with anyone! It is essentially a password to your GitHub account. | ||
## Options | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
|
||
import { execSync } from 'child_process'; | ||
|
||
|
||
function runCliWithArgs(args) { | ||
|
||
const distFolder = path.resolve(__dirname, 'dist'); | ||
|
||
if (!fs.existsSync(distFolder)) { | ||
throw new Error(`Dist directory ${distFolder} not found. Can't execute test! The directory must exist from the last build.`); | ||
} | ||
const program = path.resolve(__dirname, 'dist/angular-cli-ghpages'); | ||
return execSync(`node ${program} --dry-run ${args}`).toString(); | ||
} | ||
|
||
describe('Commander CLI options', () => { | ||
|
||
test('should set dotfiles, notfound, and nojekyll to `true` by default', () => { | ||
const output = runCliWithArgs(''); | ||
expect(output).toContain(`"dotfiles": "files starting with dot ('.') will be included"`); | ||
expect(output).toContain('"notfound": "a 404.html file will be created"'); | ||
expect(output).toContain('"nojekyll": "a .nojekyll file will be created"'); | ||
}); | ||
|
||
test('should set dotfiles, notfound, and nojekyll to `false` with no- flags', () => { | ||
const output = runCliWithArgs('--no-dotfiles --no-notfound --no-nojekyll'); | ||
expect(output).toMatch(`"dotfiles": "files starting with dot ('.') will be ignored"`); | ||
expect(output).toMatch('"notfound": "a 404.html file will NOT be created"'); | ||
expect(output).toMatch('"nojekyll": "a .nojekyll file will NOT be created"'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node' | ||
}; |
Oops, something went wrong.