Skip to content

Commit 18ce3ba

Browse files
committed
json-c parser, getting ng add working
1 parent fa796a7 commit 18ce3ba

11 files changed

+46
-31
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"tslib": "^1.10.0 || ^2.0.0",
6666
"ws": "^7.2.1",
6767
"xhr2": "^0.1.4",
68-
"zone.js": "~0.11.4"
68+
"zone.js": "~0.11.4",
69+
"jsonc-parser": "^3.0.0"
6970
},
7071
"optionalDependencies": {
7172
"bufferutil": "^4.0.1",

sample/.firebaserc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"projects": {
1212
"default": "aftest-94085"
1313
}
14-
}
14+
}

sample/angular.json

+18-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,22 @@
134134
"main": "server.ts",
135135
"tsConfig": "tsconfig.server.json",
136136
"bundleDependencies": true,
137-
"externalDependencies": [ ],
137+
"externalDependencies": [
138+
"firebase",
139+
"@firebase/app",
140+
"@firebase/analytics",
141+
"@firebase/auth",
142+
"@firebase/component",
143+
"@firebase/database",
144+
"@firebase/firestore",
145+
"@firebase/functions",
146+
"@firebase/installations",
147+
"@firebase/messaging",
148+
"@firebase/storage",
149+
"@firebase/performance",
150+
"@firebase/remote-config",
151+
"@firebase/util"
152+
],
138153
"sourceMap": true,
139154
"optimization": false
140155
},
@@ -181,11 +196,7 @@
181196
"deploy": {
182197
"builder": "@angular/fire:deploy",
183198
"options": {
184-
"ssr": true,
185-
"functionsNodeVersion": 12,
186-
"functionsRuntimeOptions": {
187-
"memory": "1GB"
188-
}
199+
"ssr": true
189200
}
190201
}
191202
}
@@ -195,4 +206,4 @@
195206
"cli": {
196207
"analytics": "cf8320c3-bce0-480d-a971-68484635f481"
197208
}
198-
}
209+
}

sample/firebase.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
"value": "public,max-age=31536000,immutable"
1616
}
1717
]
18-
}, {
19-
"source": "*-sw.js",
20-
"headers": [
21-
{
22-
"key": "Cache-Control",
23-
"value": "no-cache"
24-
}
25-
]
2618
}
2719
],
2820
"rewrites": [
@@ -56,4 +48,4 @@
5648
"enabled": true
5749
}
5850
}
59-
}
51+
}

sample/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@
6262
"inquirer-autocomplete-prompt": "^1.0.1",
6363
"jasmine-core": "~3.5.0",
6464
"jasmine-spec-reporter": "~5.0.0",
65+
"jsonc-parser": "^3.0.0",
6566
"karma": "~6.3.2",
6667
"karma-chrome-launcher": "~3.1.0",
6768
"karma-coverage-istanbul-reporter": "~3.0.2",
6869
"karma-jasmine": "~4.0.0",
6970
"karma-jasmine-html-reporter": "^1.5.0",
71+
"open": "^7.0.3",
7072
"ts-node": "~9.0.0",
7173
"tslint": "~6.1.3",
7274
"typescript": "~4.2.4"
7375
}
74-
}
76+
}

sample/yarn.lock

+11-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
tslib "^2.1.0"
237237

238238
"@angular/fire@../dist/packages-dist":
239-
version "6.1.4"
239+
version "6.1.5"
240240
dependencies:
241241
tslib "^2.0.0"
242242

@@ -7127,7 +7127,7 @@ is-wsl@^1.1.0:
71277127
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
71287128
integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=
71297129

7130-
is-wsl@^2.2.0:
7130+
is-wsl@^2.1.1, is-wsl@^2.2.0:
71317131
version "2.2.0"
71327132
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
71337133
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
@@ -7430,7 +7430,7 @@ json5@^2.1.2:
74307430
dependencies:
74317431
minimist "^1.2.5"
74327432

7433-
7433+
[email protected], jsonc-parser@^3.0.0:
74347434
version "3.0.0"
74357435
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.0.0.tgz#abdd785701c7e7eaca8a9ec8cf070ca51a745a22"
74367436
integrity sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==
@@ -8855,6 +8855,14 @@ open@^6.3.0:
88558855
dependencies:
88568856
is-wsl "^1.1.0"
88578857

8858+
open@^7.0.3:
8859+
version "7.4.2"
8860+
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
8861+
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
8862+
dependencies:
8863+
is-docker "^2.0.0"
8864+
is-wsl "^2.1.1"
8865+
88588866
openapi3-ts@^1.2.0:
88598867
version "1.4.0"
88608868
resolved "https://registry.yarnpkg.com/openapi3-ts/-/openapi3-ts-1.4.0.tgz#679d5a24be0efc36f5de4fc2c4b8513663e16f65"

src/schematics/deploy/actions.jasmine.ts

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ describe('Deploy Angular apps', () => {
130130
try {
131131
await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined, undefined, { preview: false });
132132
} catch (e) {
133-
console.log(e);
134133
expect(e.message).toMatch(/Cannot find firebase project/);
135134
}
136135
});

src/schematics/deploy/schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "FirebaseDeploySchema",
4+
// Include id field to remain compatible with older Angular
45
"id": "FirebaseDeploySchema",
56
"title": "Firebase Deploy",
67
"description": "Ng Deploy target options for Firebase.",

src/schematics/ng-add-ssr.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function generateFirebaseJson(
9999
export const addFirebaseFunctionsDependencies = (tree: Tree, context: SchematicContext) => {
100100
addDependencies(
101101
tree,
102-
{...defaultDependencies, ...firebaseFunctionsDependencies},
102+
firebaseFunctionsDependencies,
103103
context
104104
);
105105
};

src/schematics/ng-add.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';
22
import { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';
3-
import { JsonParseMode, parseJson } from '@angular-devkit/core';
43
import { listProjects, projectPrompt, projectTypePrompt } from './utils';
54
import { Workspace } from './interfaces';
65
import { DeployOptions, NgAddNormalizedOptions } from './ng-add-common';
@@ -19,12 +18,13 @@ function getWorkspace(
1918
}
2019
const content = configBuffer.toString();
2120

21+
const { parse } = (require('jsonc-parser') as typeof import('jsonc-parser'));
22+
2223
let workspace: Workspace;
2324
try {
24-
workspace = (parseJson(
25+
workspace = parse(
2526
content,
26-
JsonParseMode.Loose
27-
) as {}) as Workspace;
27+
) as Workspace;
2828
} catch (e) {
2929
throw new SchematicsException(`Could not parse angular.json: ` + e.message);
3030
}
@@ -103,14 +103,14 @@ export const ngAdd = (options: DeployOptions) => (
103103
context: SchematicContext
104104
) => {
105105

106+
addFirebaseHostingDependencies(host, context);
107+
106108
const {project} = getProject(options, host);
107109

108110
return projectTypePrompt(project).then(
109111
({ universalProject }: { universalProject: boolean }) => {
110112
if (universalProject) {
111113
addFirebaseFunctionsDependencies(host, context);
112-
} else {
113-
addFirebaseHostingDependencies(host, context);
114114
}
115115
const projectOptions: DeployOptions & { isUniversalProject: boolean } = {
116116
...options,

src/schematics/versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"fuzzy": { "dev": true, "version": "0.0.0"},
77
"inquirer": { "dev": true, "version": "0.0.0"},
88
"inquirer-autocomplete-prompt": { "dev": true, "version": "0.0.0"},
9-
"open": { "dev": true, "version": "0.0.0"}
9+
"open": { "dev": true, "version": "0.0.0"},
10+
"jsonc-parser": { "dev": true, "version": "0.0.0" }
1011
},
1112
"firebaseFunctions": {
1213
"firebase-admin": { "dev": true, "version": "0.0.0" },

0 commit comments

Comments
 (0)