fix(docs-infra): use clean package.json template when generating zips (#24691)

Closes #24689

PR Close #24691
This commit is contained in:
Brandon Roberts 2018-06-27 10:20:09 -05:00 committed by Miško Hevery
parent 66e50f28d2
commit 3db9d57de3
5 changed files with 18 additions and 8 deletions

View File

@ -9,8 +9,8 @@
],
"dependencies": [],
"devDependencies": [
"@angular/cli",
"@angular-devkit/build-angular",
"@angular/cli",
"@types/jasminewd2",
"jasmine-spec-reporter",
"karma-coverage-istanbul-reporter",

View File

@ -11,8 +11,8 @@
],
"dependencies": [],
"devDependencies": [
"@angular/cli",
"@angular-devkit/build-angular",
"@angular/cli",
"@types/jasminewd2",
"jasmine-spec-reporter",
"karma-coverage-istanbul-reporter",

View File

@ -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);
@ -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;

View File

@ -9,6 +9,7 @@
],
"dependencies": [],
"devDependencies": [
"@angular-devkit/build-angular",
"@angular/cli",
"@types/jasminewd2",
"jasmine-marbles",

View File

@ -15,6 +15,7 @@
"@nguniversal/module-map-ngfactory-loader"
],
"devDependencies": [
"@angular-devkit/build-angular",
"@angular/cli",
"@types/jasminewd2",
"jasmine-spec-reporter",