Skip to content

Commit 72d3c2e

Browse files
jamesdanielssulco
andauthored
feat(schematics): Super charge the schematics (#2836)
Co-authored-by: Tomek Sułkowski <[email protected]>
1 parent d6cfe16 commit 72d3c2e

38 files changed

+2205
-1419
lines changed

Diff for: .github/workflows/test.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ jobs:
155155
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
156156
yarn install --frozen-lockfile --prefer-offline --ignore-engines
157157
- name: Build
158-
id: yarn-pack-dir
159158
run: yarn build
159+
# Seeing some flakes on windows, skip for now
160+
# https://github.com/angular/angularfire/runs/3593478229
161+
# not just windows
162+
# https://github.com/angular/angularfire/runs/3593535123
163+
# - name: Test
164+
# if: runner.os != 'windows'
165+
# run: yarn test
160166

161167
headless:
162168
runs-on: ubuntu-latest

Diff for: package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,25 @@
5252
"@angular/platform-browser": "^12.0.0",
5353
"@angular/platform-browser-dynamic": "^12.0.0",
5454
"@angular/router": "^12.0.0",
55+
"@schematics/angular": "^12.0.0",
5556
"firebase": "^9.0.0",
56-
"firebase-admin": "^8.10.0",
57+
"firebase-admin": "^9.11.1",
5758
"firebase-functions": "^3.6.0",
5859
"firebase-tools": "^9.0.0",
5960
"fs-extra": "^8.0.1",
6061
"fuzzy": "^0.1.3",
6162
"husky": "^4.2.5",
62-
"inquirer": "^6.2.2",
6363
"inquirer-autocomplete-prompt": "^1.0.1",
6464
"jsonc-parser": "^3.0.0",
65-
"open": "^7.0.3",
65+
"open": "^7.0.3 || ^8.0.0",
66+
"ora": "^5.3.0",
6667
"rxfire": "^6.0.0",
6768
"rxjs": "~6.6.0",
6869
"semver": "^7.1.3",
70+
"triple-beam": "^1.3.0",
6971
"tslib": "^2.1.0",
7072
"webpack": "^5.35.0",
73+
"winston": "^3.0.0",
7174
"zone.js": "~0.11.4"
7275
},
7376
"devDependencies": {
@@ -84,6 +87,8 @@
8487
"@types/node": "^12.6.2 < 12.12.42",
8588
"@types/request": "0.0.30",
8689
"@types/semver": "^7.1.0",
90+
"@types/triple-beam": "^1.3.0",
91+
"@types/winston": "^2.4.4",
8792
"codelyzer": "^6.0.0",
8893
"concurrently": "^2.2.0",
8994
"conventional-changelog-cli": "^1.2.0",

Diff for: samples/advanced/.firebaserc

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: samples/advanced/angular.json

+12-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: samples/advanced/firebase.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: samples/advanced/package.json

+1-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: samples/advanced/yarn.lock

+9-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: samples/modular/yarn.lock

+9-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/package.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@
3232
"rxjs": "~6.6.0"
3333
},
3434
"dependencies": {
35-
"tslib": "^2.0.0"
35+
"tslib": "^2.0.0",
36+
"fuzzy": "^0.1.3",
37+
"inquirer-autocomplete-prompt": "^1.0.1",
38+
"open": "^8.0.0",
39+
"jsonc-parser": "^3.0.0",
40+
"ora": "^5.3.0",
41+
"winston": "^3.0.0",
42+
"triple-beam": "^1.3.0"
3643
},
3744
"ngPackage": {
3845
"lib": {
@@ -45,7 +52,12 @@
4552
},
4653
"entryFile": "public_api.ts"
4754
},
48-
"dest": "../dist/packages-dist"
55+
"dest": "../dist/packages-dist",
56+
"allowedNonPeerDependencies": [
57+
"fuzzy", "inquirer-autocomplete-prompt",
58+
"open", "jsonc-parser", "ora", "winston",
59+
"triple-beam"
60+
]
4961
},
5062
"ng-update": {
5163
"migrations": "./schematics/migration.json"

Diff for: src/schematics/add/index.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { chain, Rule, SchematicContext, TaskId, Tree } from '@angular-devkit/schematics';
2+
import { DeployOptions } from '../interfaces';
3+
import { addDependencies } from '../common';
4+
import { peerDependencies } from '../versions.json';
5+
import { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';
6+
7+
const addFirebaseHostingDependencies = () => (tree: Tree, context: SchematicContext) => {
8+
addDependencies(
9+
tree,
10+
peerDependencies,
11+
context
12+
);
13+
return tree;
14+
};
15+
16+
let npmInstallTaskId: TaskId;
17+
18+
const npmInstall = () => (tree: Tree, context: SchematicContext) => {
19+
npmInstallTaskId = context.addTask(new NodePackageInstallTask());
20+
return tree;
21+
};
22+
23+
const runSetup = (options: DeployOptions) => (tree: Tree, context: SchematicContext) => {
24+
context.addTask(new RunSchematicTask('ng-add-setup-project', options), [npmInstallTaskId]);
25+
return tree;
26+
};
27+
28+
export const ngAdd = (options: DeployOptions): Rule => {
29+
return chain([
30+
addFirebaseHostingDependencies(),
31+
npmInstall(),
32+
runSetup(options),
33+
]);
34+
};

Diff for: src/schematics/add/schema.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "angular-fire-ng-add",
4+
"title": "AngularFire ng-add",
5+
"type": "object",
6+
"properties": {
7+
"project": {
8+
"type": "string",
9+
"description": "The name of the project.",
10+
"$default": {
11+
"$source": "projectName"
12+
}
13+
}
14+
},
15+
"required": []
16+
}

Diff for: src/schematics/collection.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"schematics": {
44
"ng-add": {
55
"description": "Add firebase deploy schematic",
6-
"factory": "./public_api#ngAdd"
6+
"factory": "./add#ngAdd",
7+
"schema": "./add/schema.json"
78
},
89
"ng-add-setup-project": {
910
"description": "Setup ng deploy",
10-
"factory": "./public_api#ngAddSetupProject"
11+
"factory": "./setup#ngAddSetupProject",
12+
"schema": "./setup/schema.json"
1113
}
1214
}
1315
}

0 commit comments

Comments
 (0)