Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 463290b

Browse files
committed
work in progress, initial commit with a BIG thanks to @mgechev
0 parents  commit 463290b

23 files changed

+6761
-0
lines changed

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
6+
docker:
7+
- image: circleci/node:12-browsers
8+
9+
steps:
10+
- checkout
11+
12+
- restore_cache:
13+
key: dependency-cache-{{ checksum "src/package.json" }}
14+
- run: cd src && npm i --silent
15+
- save_cache:
16+
key: dependency-cache-{{ checksum "src/package.json" }}
17+
paths:
18+
- src/node_modules
19+
- run: cd src && npm run build
20+
- run: cd src && npm run test
21+
- run: cd src/dist && sudo npm link
22+
23+
- run: sudo -E npm install -g @angular/cli@next
24+
- run: sudo -E ng new your-angular-project --defaults
25+
- run: cd your-angular-project && sudo -E npm link ngx-deploy-starter
26+
- run: cd your-angular-project && sudo -E ng add ngx-deploy-starter
27+
- run: cd your-angular-project && sudo -E ng deploy

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
node_modules
2+
.tmp
3+
.sass-cache
4+
.DS_Store
5+
.bash_history
6+
*.swp
7+
*.swo
8+
*.d.ts
9+
10+
*.classpath
11+
*.project
12+
*.settings/
13+
*.classpath
14+
*.project
15+
*.settings/
16+
17+
.vim/bundle
18+
nvim/autoload
19+
nvim/plugged
20+
nvim/doc
21+
nvim/swaps
22+
nvim/colors
23+
dist
24+
25+
/src/mini-testdrive/404.html
26+
/src/mini-testdrive/CNAME
27+
.angulardoc.json

.vscode/tasks.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "build",
9+
"path": "src/",
10+
"label": "npm build"
11+
}
12+
]
13+
}

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 John Doe
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ngx-deploy-starter
2+
3+
## About
4+
5+
This is a sample project that helps you to implement your own __deployment builder__ for the Angular CLI.
6+
The groundwork of this starter was provided by Minko Gechev's [ngx-gh project](https://github.com/mgechev/ngx-gh).
7+
8+
This project has the following purposes:
9+
10+
1. To promote the adoption of `ng deploy`.
11+
2. To clarify various questions and to standardise the experience of the various builders.
12+
13+
## Essential considerations
14+
15+
These rules are open for discussion, of course.
16+
17+
### 1. A deployment builder should always compile the project before the deployment
18+
19+
To reduce the chances to deploy corrupted assets, it's important to build the app right before deploying it. ([source](https://github.com/angular-schule/website-articles/pull/3#discussion_r315802100))
20+
21+
Currently there are existing deployment builders that only build in production mode.
22+
This might be not enough.
23+
There is also the approach not to perform the build step at all.
24+
25+
**Our suggestion:**
26+
By default, a deployment builder compiles in `production` mode, but you can configure an other coniguration using the option `--configuration`.
27+
28+
### 2. A deployment builder should have an interactive wizard after the "ng add".
29+
30+
This wizard should ask all necessary questions and should persist the answers in the `angular.json` file.
31+
This feature is not implemented yet, but we are looking forward to your feedback.
32+
33+
### 2. More to come
34+
35+
What's bothers you about this example? We appreciate your feedback!
36+
37+
38+
## How to make your own deploy builder
39+
40+
1. fork this repository
41+
2. adjust the `package.json`
42+
3. search and replace for the string `ngx-deploy-starter` and choose your own name.
43+
4. search and replace for the string `to the file system` and name your deploy target.
44+
5. add your deployment code to `src/engine/engine.ts`x
45+
46+
47+
You are free to customise this project according to your needs.
48+
Please keep the spirit of Open Source alive and use the MIT or a compatible license.
49+
50+
## License
51+
Code released under the [MIT license](LICENSE).

docs/README_contributors.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# ngx-deploy-starter: README for contributors
2+
3+
## How to start <a name="start"></a>
4+
5+
tl;dr – execute this:
6+
7+
```
8+
cd src
9+
npm i
10+
npm run build
11+
npm test
12+
```
13+
14+
15+
## Local development <a name="local-dev"></a>
16+
17+
If you want to try the latest package locally without installing it from NPM, use the following instructions.
18+
This may be useful when you want to try the latest non-published version of this library or you want to make a contribution.
19+
20+
Follow the instructions for [checking and updating the Angular CLI version](#angular-cli) and then link the package.
21+
22+
23+
### 1. Angular CLI <a name="angular-cli"></a>
24+
25+
1. Install the next version of the Angular CLI.
26+
27+
```sh
28+
npm install -g @angular/cli@next
29+
```
30+
31+
2. Run `ng version`, make sure you have installed Angular CLI v8.3.0-next.0 or greater.
32+
33+
3. Update your existing project using the command:
34+
35+
```sh
36+
ng update @angular/cli @angular/core --next=true
37+
```
38+
39+
40+
### 2. npm link
41+
42+
Use the following instructions to make `ngx-deploy-starter` available locally via `npm link`.
43+
44+
1. Clone the project
45+
46+
```sh
47+
git clone https://github.com/angular-schule/ngx-deploy-starter.git
48+
cd ngx-deploy-starter
49+
```
50+
51+
2. Install the dependencies
52+
53+
```sh
54+
cd src
55+
npm install
56+
```
57+
58+
3. Build the project:
59+
60+
```sh
61+
npm run build
62+
```
63+
64+
4. Create a local npm link:
65+
66+
```sh
67+
cd dist
68+
npm link
69+
```
70+
71+
Read more about the `link` feature in the [official NPM documentation](https://docs.npmjs.com/cli/link).
72+
73+
74+
### 3. Adding to an Angular project -- ng add <a name="local-dev-add"></a>
75+
76+
Once you have completed the previous steps to `npm link` the local copy of `ngx-deploy-starter`, follow these steps to use it in a local Angular project.
77+
78+
1. Enter the project directory
79+
80+
```sh
81+
cd your-angular-project
82+
```
83+
84+
2. Add the local version of `ngx-deploy-starter`.
85+
86+
```sh
87+
npm link ngx-deploy-starter
88+
```
89+
90+
3. Now execute the `ng-add` schematic.
91+
92+
```sh
93+
ng add ngx-deploy-starter
94+
```
95+
96+
4. You can now deploy your angular app to GitHub pages.
97+
98+
```sh
99+
ng run your-angular-project:deploy
100+
```
101+
102+
5. You can remove the link later by running `npm unlink`
103+
104+
105+
### 4. Testing <a name="testing"></a>
106+
107+
Testing is done with [Jest](https://jestjs.io/).
108+
To run the tests:
109+
110+
```sh
111+
cd ngx-deploy-starter/src
112+
npm test
113+
```
114+
115+
116+
117+
118+
119+
## Testing the standalone CLI
120+
121+
To quickly test the file `engine.ts` directly, the standalone mode is the best option.
122+
Use VSCode and debug the task `Launch Standalone Program`.
123+
124+
125+
## Publish to NPM
126+
127+
```
128+
cd ngx-deploy-starter/src
129+
npm run build
130+
npm run test
131+
npm publish dist
132+
npm dist-tag add [email protected] next
133+
```

src/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ngx-deploy-starter
2+
3+
**Deploy your Angular app to the file system directly from the Angular CLI! 🚀**
4+
5+
6+
## Usage
7+
8+
Add `ngx-deploy-starter` to your project.
9+
10+
```bash
11+
ng add ngx-deploy-starter
12+
```
13+
14+
Deploy your project to the file system.
15+
16+
```
17+
ng deploy [options]
18+
```
19+
20+
21+
## Options
22+
23+
The following options are also available.
24+
25+
#### --target-dir
26+
* __optional__
27+
* Default: `~/example-folder` (string)
28+
* Example:
29+
* `ng deploy` -- App is "deployed" to the example folder (if existing)
30+
* `ng deploy --target-/var/www/html` -- App is "deployed" to another folder
31+
32+
33+
#### --configuration
34+
* __optional__
35+
* Default: `production` (string)
36+
* Example:
37+
* `ng deploy` -- Angular project is build in production mode
38+
* `ng deploy --configuration=qs` -- Angular project is using the configuration `qs` (this configuration must exist in the `angular.json` file)
39+
40+
A named build target, as specified in the `configurations` section of `angular.json`.
41+
Each named target is accompanied by a configuration of option defaults for that target.
42+
Same as `ng build --configuration=XXX`.
43+

src/builders.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "@angular-devkit/architect/src/builders-schema.json",
3+
"builders": {
4+
"deploy": {
5+
"implementation": "./deploy/builder",
6+
"schema": "./deploy/schema.json",
7+
"description": "Deploy builder"
8+
}
9+
}
10+
}

src/collection.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "@angular-devkit/schematics/collection-schema.json",
3+
"schematics": {
4+
"ng-add": {
5+
"description": "Add ngx-deploy-starter deploy schematic",
6+
"factory": "./ng-add#ngAdd"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)