Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Angular v11 (follow up) #120

Merged
merged 11 commits into from
Nov 25, 2020
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js 12.x
- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 10.x

- name: Prepare
run: |
Expand Down
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
4. [🚀 Continuous Delivery](#continuous-delivery)
5. [📦 Options](#options)
- [--base-href](#base-href)
- [--configuration](#configuration)
- [--build-target](#build-target)
- [--no-build](#no-build)
- [--repo](#repo)
- [--message](#message)
Expand Down Expand Up @@ -172,19 +172,20 @@ ng deploy --cname=example.org

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

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

- **optional**
- Alias: `-c`
- Default: `production` (string)
- Default: `undefined` (string)
- Example:
- `ng deploy` – Angular project is build in production mode
- `ng deploy --configuration=test` – Angular project is using the configuration `test` (this configuration must exist in the `angular.json` file)
- `ng deploy` – Angular project is build in `production` mode
JohannesHoppe marked this conversation as resolved.
Show resolved Hide resolved
- `ng deploy --build-target=test` – Angular project is using the build configuration `test` (this configuration must exist in the `angular.json` file)

If no buildTarget is set, the `production` build of the default project will be chosen.
JohannesHoppe marked this conversation as resolved.
Show resolved Hide resolved
The `buildTarget` simply points to an existing build configuration for your project, as specified in the `configurations` section of `angular.json`.
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.

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`.
This command has no effect if the option `--no-build` option is active.
This is equivalent as calling the command `ng build --configuration=XXX`."
JohannesHoppe marked this conversation as resolved.
Show resolved Hide resolved
This command has no effect if the option `--no-build` is active.

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

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

Skip 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 `--configuration` setting to have no effect. -->
This command causes the `--configuration` setting to have no effect.
JohannesHoppe marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down Expand Up @@ -313,7 +314,7 @@ This can be very useful because it outputs what would happen without doing anyth
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:

- baseHref
- configuration
- buildTarget
- noBuild
- repo
- message
Expand Down Expand Up @@ -346,20 +347,21 @@ becomes
}
```

And just run `ng deploy` 😄.
Now you can just run `ng deploy` without all the options in the command line! 😄

> **ℹ️ Hint**
>
> You can always use the [--dry-run](#dry-run) option to verify if your configuration is right.
> The project will build but not deploy.

## 🌍 Environments <a name="environments"></a>

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://github.com/angular-schule/angular-cli-ghpages/blob/master/docs/README_environment_github_actions.md) by [Dharmen Shah](https://github.com/shhdharmen)
2. TODO: Travis CI
3. TODO: CircleCI
2. Travis CI
3. CircleCI

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

Expand Down
10 changes: 1 addition & 9 deletions docs/README_contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- [4. Testing](#4-testing)
- [Testing the standalone CLI](#testing-the-standalone-cli)
- [Publish to NPM](#publish-to-npm)
- [Usage of Prettier Formatter](#usage-of-prettier-formatter)

## How to start

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

```
cd angular-cli-ghpages/src
npx prettier --write '**/*'
npm run prettier
npm run build
npm run test
npm publish dist
npm dist-tag add angular-cli-ghpages@0.6.0-rc.0 next
```

## Usage of Prettier Formatter

Just execute `npx prettier --write '**/*'` and the code is formated automatically.
Please ignore the errors for now. ([error] No parser could be inferred for file)

We are still working on this, see https://github.com/angular-schule/ngx-deploy-starter/issues/10 .

## Keeping track of all the forks

[ngx-deploy-starter](https://github.com/angular-schule/ngx-deploy-starter/) and
Expand Down
1 change: 1 addition & 0 deletions src/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
4 changes: 3 additions & 1 deletion src/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion src/angular-cli-ghpages
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var consoleLogger = {

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

engine.run(dir, commander, consoleLogger).catch(function(error) {
engine.run(dir, commander, consoleLogger).catch(function (error) {
consoleLogger.error('❌ An error occurred when trying to deploy:');
consoleLogger.error(error.message);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const initMocks = () => {
Promise.resolve({
result: Promise.resolve(createBuilderOutputMock(true))
} as BuilderRun)
};
} as any;
};

const createBuilderOutputMock = (success: boolean): BuilderOutput => {
Expand Down
6 changes: 2 additions & 4 deletions src/deploy/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"type": "string",
"description": "Base url for the application being built. Same as `ng build --base-href=/XXX/`."
},
"configuration": {
"buildTarget": {
"type": "string",
"default": "production",
"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`.",
"alias": "c"
"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`."
JohannesHoppe marked this conversation as resolved.
Show resolved Hide resolved
},
"noBuild": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion src/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function prepareOptions(
let debuglog = util.debuglog;
util.debuglog = set => {
if (set === 'gh-pages') {
return function() {
return function () {
let message = util.format.apply(util, arguments);
logger.info(message);
};
Expand Down
2 changes: 1 addition & 1 deletion src/ng-add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('ng-add', () => {

function generateAngularJson() {
return {
defaultProject: PROJECT_NAME,
defaultProject: PROJECT_NAME as string | undefined,
projects: {
[PROJECT_NAME]: {
projectType: 'application',
Expand Down
8 changes: 4 additions & 4 deletions src/ng-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { JsonParseMode, parseJson } from '@angular-devkit/core';
import {
SchematicContext,
SchematicsException,
Tree,
Tree
} from '@angular-devkit/schematics';
import { Workspace } from './interfaces';

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

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

return {
path,
workspace,
workspace
};
}
interface NgAddOptions {
Expand Down Expand Up @@ -74,7 +74,7 @@ export const ngAdd = (options: NgAddOptions) => (

project.architect['deploy'] = {
builder: 'angular-cli-ghpages:deploy',
options: {},
options: {}
};

tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
Expand Down
Loading