Skip to content

chore(packages): move packages into their own scope. #3413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions lib/packages.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
'use strict';

const fs = require('fs');
const glob = require('glob');
const path = require('path');

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

// All the supported packages. Go through the packages directory and create a map of
// name => fullPath.
const packages = fs.readdirSync(packageRoot)
.map(pkgName => ({ name: pkgName, root: path.join(packageRoot, pkgName) }))
.filter(pkg => fs.statSync(pkg.root).isDirectory())
.reduce((packages, pkg) => {
let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8'));
let name = pkgJson['name'];
packages[name] = {
dist: path.join(__dirname, '../dist', pkg.name),
packageJson: path.join(pkg.root, 'package.json'),
root: pkg.root,
relative: path.relative(path.dirname(__dirname), pkg.root),
main: path.resolve(pkg.root, 'src/index.ts')
};
return packages;
}, {});

module.exports = packages;
const packages =
glob.sync(path.join(packageRoot, '**/package.json'))
.filter(p => !p.match(/blueprints/))
.map(pkgPath => path.relative(packageRoot, path.dirname(pkgPath)))
.map(pkgName => {
return { name: pkgName, root: path.join(packageRoot, pkgName) };
})
.reduce((packages, pkg) => {
let pkgJson = JSON.parse(fs.readFileSync(path.join(pkg.root, 'package.json'), 'utf8'));
let name = pkgJson['name'];

packages[name] = {
dist: path.join(__dirname, '../dist', pkg.name),
packageJson: path.join(pkg.root, 'package.json'),
root: pkg.root,
relative: path.relative(path.dirname(__dirname), pkg.root),
main: path.resolve(pkg.root, 'src/index.ts')
};
return packages;
}, {});


module.exports = packages;


// If we run this from the command line, just output the list of modules neatly formatted.
if (require.main === module) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(packages, null, 2));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"outDir": "../../dist/ast-tools",
"outDir": "../../../dist/@angular-cli/ast-tools",
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"outDir": "../../dist/base-href-webpack",
"outDir": "../../../dist/@angular-cli/base-href-webpack",
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "/",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"outDir": "../../dist/webpack",
"outDir": "../../../dist/@ngtools/webpack",
"rootDir": ".",
"lib": ["es2015", "es6", "dom"],
"target": "es5",
"sourceMap": true,
"sourceRoot": "/",
"baseUrl": ".",
"baseUrl": "./",
"paths": {
"@angular-cli/ast-tools": [ "../../dist/ast-tools/src" ]
"@angular-cli/ast-tools": [ "../../../dist/ast-tools/src" ]
},
"typeRoots": [
"../../node_modules/@types"
Expand Down
77 changes: 0 additions & 77 deletions packages/angular-cli/models/find-lazy-modules.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/angular-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
],
"baseUrl": "",
"paths": {
"@angular-cli/ast-tools": [ "../../dist/ast-tools/src" ],
"@angular-cli/base-href-webpack": [ "../../dist/base-href-webpack/src" ],
"@ngtools/webpack": [ "../../dist/webpack/src" ]
"@angular-cli/ast-tools": [ "../../dist/@angular-cli/ast-tools/src" ],
"@angular-cli/base-href-webpack": [ "../../dist/@angular-cli/base-href-webpack/src" ],
"@ngtools/webpack": [ "../../dist/@ngtools/webpack/src" ]
}
},
"include": [
Expand Down
50 changes: 0 additions & 50 deletions tests/acceptance/find-lazy-module.spec.ts

This file was deleted.

1 change: 1 addition & 0 deletions tests/e2e/assets/webpack/test-app-weird/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@angular/router": "3.2.1",
"@ngtools/webpack": "0.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.0.0-beta.12",
"zone.js": "^0.6.21"
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/assets/webpack/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@angular/platform-browser-dynamic": "2.2.3",
"@angular/platform-server": "2.2.3",
"@angular/router": "3.2.3",
"@ngtools/webpack": "0.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.0.0-beta.12",
"zone.js": "^0.6.21"
Expand Down
14 changes: 3 additions & 11 deletions tests/e2e/tests/packages/webpack/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {copyAssets} from '../../../utils/assets';
import {exec, silentNpm} from '../../../utils/process';
import {updateJsonFile} from '../../../utils/project';
import {join} from 'path';
import {createProjectFromAsset} from '../../../utils/assets';
import {exec} from '../../../utils/process';
import {expectFileSizeToBeUnder} from '../../../utils/fs';


Expand All @@ -12,13 +10,7 @@ export default function(skipCleaning: () => void) {
}

return Promise.resolve()
.then(() => copyAssets('webpack/test-app'))
.then(dir => process.chdir(dir))
.then(() => updateJsonFile('package.json', json => {
const dist = '../../../../../dist/';
json['dependencies']['@ngtools/webpack'] = join(__dirname, dist, 'webpack');
}))
.then(() => silentNpm('install'))
.then(() => createProjectFromAsset('webpack/test-app'))
.then(() => exec('node_modules/.bin/webpack', '-p'))
.then(() => expectFileSizeToBeUnder('dist/app.main.js', 400000))
.then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 40000))
Expand Down
13 changes: 3 additions & 10 deletions tests/e2e/tests/packages/webpack/weird.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {copyAssets} from '../../../utils/assets';
import {exec, silentNpm} from '../../../utils/process';
import {createProjectFromAsset} from '../../../utils/assets';
import {exec} from '../../../utils/process';
import {updateJsonFile} from '../../../utils/project';
import {join} from 'path';
import {expectFileSizeToBeUnder, expectFileToExist} from '../../../utils/fs';
import {expectToFail} from '../../../utils/utils';

Expand All @@ -13,13 +12,7 @@ export default function(skipCleaning: () => void) {
}

return Promise.resolve()
.then(() => copyAssets('webpack/test-app-weird'))
.then(dir => process.chdir(dir))
.then(() => updateJsonFile('package.json', json => {
const dist = '../../../../../dist/';
json['dependencies']['@ngtools/webpack'] = join(__dirname, dist, 'webpack');
}))
.then(() => silentNpm('install'))
.then(() => createProjectFromAsset('webpack/test-app-weird'))
.then(() => exec('node_modules/.bin/webpack', '-p'))
.then(() => expectFileToExist('dist/app.main.js'))
.then(() => expectFileToExist('dist/0.app.main.js'))
Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/utils/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as glob from 'glob';
import {getGlobalVariable} from './env';
import {relative} from 'path';
import {copyFile} from './fs';
import {updateJsonFile} from './project';
import {silentNpm} from './process';


export function assetDir(assetName: string) {
Expand All @@ -27,3 +29,22 @@ export function copyAssets(assetName: string) {
})
.then(() => tempRoot);
}


export function createProjectFromAsset(assetName: string) {
const packages = require('../../../lib/packages');

return Promise.resolve()
.then(() => copyAssets(assetName))
.then(dir => process.chdir(dir))
.then(() => updateJsonFile('package.json', json => {
for (const packageName of Object.keys(packages)) {
if (json['dependencies'].hasOwnProperty(packageName)) {
json['dependencies'][packageName] = packages[packageName].dist;
} else if (json['devDependencies'].hasOwnProperty(packageName)) {
json['devDependencies'][packageName] = packages[packageName].dist;
}
}
}))
.then(() => silentNpm('install'));
}
60 changes: 0 additions & 60 deletions tests/models/find-lazy-modules.spec.ts

This file was deleted.