-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d519571
commit 9eafbfd
Showing
2 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
# compiled output | ||
*.js | ||
!update-schemas.js | ||
*.d.ts | ||
/dist | ||
/tmp | ||
|
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,40 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const BASE_URL = | ||
"https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/build_angular/src/builders/"; | ||
|
||
(async () => { | ||
await updateSchema("browser", "src/browser"); | ||
await updateSchema("extract-i18n", "src/extract-i18n"); | ||
await updateSchema("karma", "src/karma"); | ||
await updateSchema("dev-server", "src/plus-dev-server"); | ||
await updateSchema("server", "src/server"); | ||
})(); | ||
|
||
async function updateSchema(builder, targetUrl) { | ||
console.log("- Updating schema for", builder, "in", targetUrl); | ||
|
||
const url = path.join(BASE_URL, builder, "schema.json"); | ||
const schema = await loadRemoteJson(url); | ||
|
||
const extSchemaUrl = `${targetUrl}/schema.ext.json`; | ||
const extSchema = loadLocalJson(extSchemaUrl); | ||
|
||
for (const prop in extSchema) { | ||
schema.properties[prop] = extSchema[prop]; | ||
} | ||
|
||
const fullSchemaText = JSON.stringify(schema, null, 2); | ||
const fullSchemaUrl = `${targetUrl}/schema.json`; | ||
|
||
fs.writeFileSync(fullSchemaUrl, fullSchemaText, "utf8"); | ||
} | ||
|
||
async function loadRemoteJson(url) { | ||
return await fetch(url).then((resp) => resp.json()); | ||
} | ||
|
||
function loadLocalJson(extSchemaUrl) { | ||
return JSON.parse(fs.readFileSync(extSchemaUrl, { encoding: "utf8" })); | ||
} |