Skip to content

Commit d928c1c

Browse files
committed
tool(publish): adding a new tool infrastructure with a publish tool.
1 parent c55b5dc commit d928c1c

23 files changed

+503
-283
lines changed

lib/bootstrap-local.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ts = require('typescript');
99
Error.stackTraceLimit = Infinity;
1010

1111
global.angularCliIsLocal = true;
12-
global.angularCliPackages = require('./packages');
12+
global.angularCliPackages = require('./packages').packages;
1313

1414
const compilerOptions = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json')));
1515

@@ -48,7 +48,7 @@ require.extensions['.ts'] = function (m, filename) {
4848

4949
// If we're running locally, meaning npm linked. This is basically "developer mode".
5050
if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
51-
const packages = require('./packages');
51+
const packages = require('./packages').packages;
5252

5353
// We mock the module loader so that we can fake our packages when running locally.
5454
const Module = require('module');

lib/packages.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const glob = require('glob');
55
const path = require('path');
66

77
const packageRoot = path.join(__dirname, '../packages');
8+
const toolsRoot = path.join(__dirname, '../tools');
9+
const distRoot = path.join(__dirname, '../dist');
10+
811

912
// All the supported packages. Go through the packages directory and create a map of
1013
// name => fullPath.
@@ -20,7 +23,7 @@ const packages =
2023
let name = pkgJson['name'];
2124

2225
packages[name] = {
23-
dist: path.join(__dirname, '../dist', pkg.name),
26+
dist: path.join(distRoot, pkg.name),
2427
packageJson: path.join(pkg.root, 'package.json'),
2528
root: pkg.root,
2629
relative: path.relative(path.dirname(__dirname), pkg.root),
@@ -29,12 +32,38 @@ const packages =
2932
return packages;
3033
}, {});
3134

35+
const tools = glob.sync(path.join(toolsRoot, '**/package.json'))
36+
.map(toolPath => path.relative(toolsRoot, path.dirname(toolPath)))
37+
.map(toolName => {
38+
const root = path.join(toolsRoot, toolName);
39+
const pkgJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
40+
const name = pkgJson['name'];
41+
const dist = path.join(distRoot, toolName);
42+
43+
return {
44+
name,
45+
main: path.join(dist, pkgJson['main']),
46+
mainTs: path.join(toolsRoot, toolName, pkgJson['main'].replace(/\.js$/, '.ts')),
47+
root,
48+
packageJson: path.join(toolsRoot, toolName, 'package.json'),
49+
dist
50+
};
51+
})
52+
.reduce((tools, tool) => {
53+
tools[tool.name] = tool;
54+
return tools;
55+
}, {});
56+
3257

33-
module.exports = packages;
58+
module.exports = { packages, tools };
3459

3560

3661
// If we run this from the command line, just output the list of modules neatly formatted.
3762
if (require.main === module) {
38-
// eslint-disable-next-line no-console
63+
/* eslint-disable no-console */
64+
console.log('Packages:');
3965
console.log(JSON.stringify(packages, null, 2));
66+
console.log('');
67+
console.log('Tools:');
68+
console.log(JSON.stringify(tools, null, 2));
4069
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
},
1010
"keywords": [],
1111
"scripts": {
12-
"build": "node ./scripts/publish/build.js",
13-
"build:patch": "node ./scripts/patch.js",
14-
"build:packages": "for PKG in packages/*; do echo Building $PKG...; tsc -p $PKG; done",
12+
"build": "node scripts/run-tool.js publish build",
1513
"test": "npm-run-all -c test:packages test:cli test:deps test:licenses test:messages",
1614
"e2e": "npm run test:e2e",
1715
"e2e:nightly": "node tests/run_e2e.js --nightly",
@@ -24,7 +22,8 @@
2422
"test:packages": "node scripts/run-packages-spec.js",
2523
"eslint": "eslint .",
2624
"tslint": "tslint \"**/*.ts\" -c tslint.json -e \"**/config/schema.d.ts\" -e \"**/tests/**\" -e \"**/blueprints/*/files/**/*.ts\" -e \"node_modules/**\" -e \"tmp/**\" -e \"dist/**\"",
27-
"lint": "npm-run-all -c eslint tslint"
25+
"lint": "npm-run-all -c eslint tslint",
26+
"tool": "node scripts/run-tool.js"
2827
},
2928
"repository": {
3029
"type": "git",
@@ -119,6 +118,7 @@
119118
"@types/glob": "^5.0.29",
120119
"@types/jasmine": "~2.2.0",
121120
"@types/lodash": "4.14.50",
121+
"@types/minimist": "^1.2.0",
122122
"@types/mock-fs": "^3.6.30",
123123
"@types/node": "^6.0.36",
124124
"@types/request": "0.0.39",

packages/@ngtools/json-schema/src/schema-class-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface SchemaClass<JsonType> extends Object {
7878
// Direct access to the schema.
7979
$$schema(): RootSchemaTreeNode;
8080

81-
$$serialize(mimetype?: string): string;
81+
$$serialize(mimetype?: string, ...args: any[]): string;
8282
}
8383

8484

scripts/build-schema-dts.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/publish/build.js

Lines changed: 0 additions & 194 deletions
This file was deleted.

scripts/publish/changelog.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

scripts/publish/validate_dependencies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const chalk = require('chalk');
66
const fs = require('fs');
77
const glob = require('glob');
8-
const packages = require('../../lib/packages');
8+
const packages = require('../../lib/packages').packages;
99
const path = require('path');
1010

1111

0 commit comments

Comments
 (0)