fix(docs-infra): use clean package.json template when generating zips (#24691)
Closes #24689 PR Close #24691
This commit is contained in:
parent
66e50f28d2
commit
3db9d57de3
|
@ -9,8 +9,8 @@
|
|||
],
|
||||
"dependencies": [],
|
||||
"devDependencies": [
|
||||
"@angular/cli",
|
||||
"@angular-devkit/build-angular",
|
||||
"@angular/cli",
|
||||
"@types/jasminewd2",
|
||||
"jasmine-spec-reporter",
|
||||
"karma-coverage-istanbul-reporter",
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
],
|
||||
"dependencies": [],
|
||||
"devDependencies": [
|
||||
"@angular/cli",
|
||||
"@angular-devkit/build-angular",
|
||||
"@angular/cli",
|
||||
"@types/jasminewd2",
|
||||
"jasmine-spec-reporter",
|
||||
"karma-coverage-istanbul-reporter",
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('canonical-path');
|
||||
const fs = require('fs');
|
||||
|
||||
const examplesPath = path.resolve(__dirname, '../../../examples');
|
||||
const packageFolder = path.resolve(__dirname);
|
||||
|
||||
class PackageJsonCustomizer {
|
||||
constructor() {
|
||||
this.dependenciesPackageJson = require(path.join(examplesPath, '/shared/package.json'));
|
||||
this.scriptsPackageJson = require(path.join(examplesPath, '/shared/boilerplate/systemjs/package.json'));
|
||||
this.basePackageJson = require(`${packageFolder}/base.json`);
|
||||
this.dependenciesPackageJson = this.readJson(path.join(examplesPath, '/shared/package.json'));
|
||||
this.scriptsPackageJson = this.readJson(path.join(examplesPath, '/shared/boilerplate/systemjs/package.json'));
|
||||
this.basePackageJson = this.readJson(`${packageFolder}/base.json`);
|
||||
this.templatePackageJson = this.readJson(`${packageFolder}/package.json`, false);
|
||||
}
|
||||
|
||||
generate(type = 'systemjs') {
|
||||
let packageJson = require(`${packageFolder}/package.json`);
|
||||
let packageJson = JSON.parse(this.templatePackageJson);
|
||||
let rules = require(`${packageFolder}/${type}.json`);
|
||||
|
||||
this._mergeJSON(rules, this.basePackageJson);
|
||||
|
@ -39,8 +41,8 @@ class PackageJsonCustomizer {
|
|||
return JSON.stringify(packageJson, null, 2);
|
||||
}
|
||||
|
||||
_mergeJSON(json1,json2) {
|
||||
var result = json1 ;
|
||||
_mergeJSON(json1, json2) {
|
||||
var result = json1;
|
||||
for (var prop in json2)
|
||||
{
|
||||
if (json2.hasOwnProperty(prop))
|
||||
|
@ -50,6 +52,12 @@ class PackageJsonCustomizer {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
readJson(jsonFile, parse = true) {
|
||||
const contents = fs.readFileSync(jsonFile, 'utf8');
|
||||
|
||||
return parse ? JSON.parse(contents) : contents;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PackageJsonCustomizer;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
],
|
||||
"dependencies": [],
|
||||
"devDependencies": [
|
||||
"@angular-devkit/build-angular",
|
||||
"@angular/cli",
|
||||
"@types/jasminewd2",
|
||||
"jasmine-marbles",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"@nguniversal/module-map-ngfactory-loader"
|
||||
],
|
||||
"devDependencies": [
|
||||
"@angular-devkit/build-angular",
|
||||
"@angular/cli",
|
||||
"@types/jasminewd2",
|
||||
"jasmine-spec-reporter",
|
||||
|
|
Loading…
Reference in New Issue