Skip to content

Commit 6068248

Browse files
committed
chore(packages): move packages into their own scope.
This will facilitate management of packages internally.
1 parent 9687081 commit 6068248

35 files changed

+41
-211
lines changed

lib/packages.js

+33-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
'use strict';
22

33
const fs = require('fs');
4+
const glob = require('glob');
45
const path = require('path');
56

67
const packageRoot = path.join(__dirname, '../packages');
78

89
// All the supported packages. Go through the packages directory and create a map of
910
// name => fullPath.
10-
const packages = fs.readdirSync(packageRoot)
11-
.map(pkgName => ({ name: pkgName, root: path.join(packageRoot, pkgName) }))
12-
.filter(pkg => fs.statSync(pkg.root).isDirectory())
13-
.reduce((packages, pkg) => {
14-
let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8'));
15-
let name = pkgJson['name'];
16-
packages[name] = {
17-
dist: path.join(__dirname, '../dist', pkg.name),
18-
packageJson: path.join(pkg.root, 'package.json'),
19-
root: pkg.root,
20-
relative: path.relative(path.dirname(__dirname), pkg.root),
21-
main: path.resolve(pkg.root, 'src/index.ts')
22-
};
23-
return packages;
24-
}, {});
11+
let packages = null;
12+
13+
function getPackages() {
14+
return glob.sync(path.join(packageRoot, '**/package.json'))
15+
.filter(p => !p.match(/blueprints/))
16+
.map(pkgPath => path.relative(packageRoot, path.dirname(pkgPath)))
17+
.map(pkgName => {
18+
return { name: pkgName, root: path.join(packageRoot, pkgName) };
19+
})
20+
.reduce((packages, pkg) => {
21+
let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8'));
22+
let name = pkgJson['name'];
23+
24+
packages[name] = {
25+
dist: path.join(__dirname, '../dist', pkg.name),
26+
packageJson: path.join(pkg.root, 'package.json'),
27+
root: pkg.root,
28+
relative: path.relative(path.dirname(__dirname), pkg.root),
29+
main: path.resolve(pkg.root, 'src/index.ts')
30+
};
31+
return packages;
32+
}, {});
33+
}
2534

26-
module.exports = packages;
35+
36+
Object.defineProperty(module, 'exports', {
37+
get: function() {
38+
if (!packages) {
39+
packages = getPackages();
40+
}
41+
return packages;
42+
}
43+
});

packages/ast-tools/tsconfig.json renamed to packages/@angular-cli/ast-tools/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"moduleResolution": "node",
88
"noEmitOnError": true,
99
"noImplicitAny": true,
10-
"outDir": "../../dist/ast-tools",
10+
"outDir": "../../../dist/@angular-cli/ast-tools",
1111
"rootDir": ".",
1212
"sourceMap": true,
1313
"sourceRoot": "/",

packages/base-href-webpack/tsconfig.json renamed to packages/@angular-cli/base-href-webpack/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"moduleResolution": "node",
88
"noEmitOnError": true,
99
"noImplicitAny": true,
10-
"outDir": "../../dist/base-href-webpack",
10+
"outDir": "../../../dist/@angular-cli/base-href-webpack",
1111
"rootDir": ".",
1212
"sourceMap": true,
1313
"sourceRoot": "/",
File renamed without changes.

packages/webpack/tsconfig.json renamed to packages/@ngtools/webpack/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"moduleResolution": "node",
88
"noEmitOnError": true,
99
"noImplicitAny": true,
10-
"outDir": "../../dist/webpack",
10+
"outDir": "../../../dist/@ngtools/webpack",
1111
"rootDir": ".",
1212
"lib": ["es2015", "es6", "dom"],
1313
"target": "es5",
1414
"sourceMap": true,
1515
"sourceRoot": "/",
16-
"baseUrl": ".",
16+
"baseUrl": "./",
1717
"paths": {
18-
"@angular-cli/ast-tools": [ "../../dist/ast-tools/src" ]
18+
"@angular-cli/ast-tools": [ "../../../dist/ast-tools/src" ]
1919
},
2020
"typeRoots": [
2121
"../../node_modules/@types"

packages/angular-cli/models/find-lazy-modules.ts

-77
This file was deleted.

packages/angular-cli/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
],
2121
"baseUrl": "",
2222
"paths": {
23-
"@angular-cli/ast-tools": [ "../../dist/ast-tools/src" ],
24-
"@angular-cli/base-href-webpack": [ "../../dist/base-href-webpack/src" ],
25-
"@ngtools/webpack": [ "../../dist/webpack/src" ]
23+
"@angular-cli/ast-tools": [ "../../dist/@angular-cli/ast-tools/src" ],
24+
"@angular-cli/base-href-webpack": [ "../../dist/@angular-cli/base-href-webpack/src" ],
25+
"@ngtools/webpack": [ "../../dist/@ngtools/webpack/src" ]
2626
}
2727
},
2828
"include": [

tests/acceptance/find-lazy-module.spec.ts

-50
This file was deleted.

tests/models/find-lazy-modules.spec.ts

-60
This file was deleted.

0 commit comments

Comments
 (0)