Skip to content

fix(@angular/cli): add packageGroup for @angular/cli #13942

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

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 14 additions & 1 deletion packages/angular/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
"symbol-observable": "1.2.0"
},
"ng-update": {
"migrations": "@schematics/angular/migrations/migration-collection.json"
"migrations": "@schematics/angular/migrations/migration-collection.json",
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
17 changes: 16 additions & 1 deletion packages/angular_devkit/architect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,20 @@
"@angular-devkit/core": "0.0.0",
"rxjs": "6.4.0"
},
"builders": "./builders/builders.json"
"builders": "./builders/builders.json",
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,20 @@
"popper.js": "^1.14.1",
"protractor": "~5.4.0",
"zone.js": "^0.8.19"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/build_ng_packagr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,20 @@
"ng-packagr": "^4.2.0",
"tsickle": ">=0.34.0",
"tslib": "^1.9.0"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/build_optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,20 @@
"source-map": "0.5.6",
"typescript": "3.2.4",
"webpack-sources": "1.3.0"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/build_webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,20 @@
"devDependencies": {
"webpack": "4.29.6",
"webpack-dev-server": "^3.1.4"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@
},
"devDependencies": {
"seedrandom": "^2.4.4"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/angular_devkit/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@
"dependencies": {
"@angular-devkit/core": "0.0.0",
"rxjs": "6.4.0"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,20 @@
"@angular/compiler-cli": "^7.2.0-rc.0",
"typescript": "3.2.4",
"webpack": "4.29.6"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/schematics/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,20 @@
"dependencies": {
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
15 changes: 15 additions & 0 deletions packages/schematics/update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,20 @@
"semver": "5.6.0",
"semver-intersect": "1.4.0",
"rxjs": "6.4.0"
},
"ng-update": {
"packageGroupName": "@angular/cli",
"packageGroup": {
"@angular-devkit/architect": "0.0.0",
"@angular-devkit/build-angular": "0.0.0",
"@angular-devkit/build-ng-packagr": "0.0.0",
"@angular-devkit/build-optimizer": "0.0.0",
"@angular-devkit/build-webpack": "0.0.0",
"@angular-devkit/core": "0.0.0",
"@angular-devkit/schematics": "0.0.0",
"@ngtools/webpack": "0.0.0",
"@schematics/angular": "0.0.0",
"@schematics/update": "0.0.0"
}
}
}
117 changes: 76 additions & 41 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,79 @@ async function _bazel(logger: logging.Logger) {
// _exec('bazel', ['build', '//packages/...'], {}, logger);
}

async function _setVersions(
sortedPackages: string[],
argv: { local?: boolean, snapshot?: boolean },
logger: logging.Logger,
) {
for (const packageName of sortedPackages) {
logger.info(packageName);
const pkg = packages[packageName];
const packageJsonPath = path.join(pkg.dist, 'package.json');
const packageJson = pkg.packageJson;
const version = pkg.version;

if (version) {
packageJson['version'] = version;
} else {
logger.error('No version found... Only updating dependencies.');
}

for (const depName of Object.keys(packages)) {
const v = packages[depName].version;
for (const depKey of ['dependencies', 'peerDependencies', 'devDependencies']) {
const obj = packageJson[depKey] as JsonObject | null;
if (obj && obj[depName]) {
if (argv.local) {
obj[depName] = packages[depName].tar;
} else if (argv.snapshot) {
const pkg = packages[depName];
if (!pkg.snapshotRepo) {
logger.error(
`Package ${JSON.stringify(depName)} is not published as a snapshot. `
+ `Fixing to current version ${v}.`,
);
obj[depName] = v;
} else {
obj[depName] = `github:${pkg.snapshotRepo}#${pkg.snapshotHash}`;
}
} else if ((obj[depName] as string).match(/\b0\.0\.0\b/)) {
obj[depName] = (obj[depName] as string).replace(/\b0\.0\.0\b/, v);
}
}
}
}

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
}
}

async function _setPackageGroups(sortedPackages: string[], logger: logging.Logger) {
for (const packageName of sortedPackages) {
logger.info(packageName);
const pkg = packages[packageName];

const packageJsonPath = path.join(pkg.dist, 'package.json');
const packageJson = pkg.packageJson;
// tslint:disable-next-line:no-any
const ngUpdateJson: any = packageJson['ng-update'] || (packageJson['ng-update'] = {});
const packageGroup = ngUpdateJson['packageGroup'] || (ngUpdateJson['packageGroup'] = {});

let changed = false;
for (const subPackageName of sortedPackages) {
const subpkg = packages[subPackageName];
if (packageGroup[subPackageName] === '0.0.0') {
packageGroup[subPackageName] = subpkg.version;
changed = true;
}
}

if (changed) {
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
}
}
}

export default async function(
argv: { local?: boolean, snapshot?: boolean },
logger: logging.Logger,
Expand Down Expand Up @@ -350,48 +423,10 @@ export default async function(
}

logger.info('Setting versions...');
await _setVersions(sortedPackages, argv, logger.createChild('versions'));

const versionLogger = logger.createChild('versions');
for (const packageName of sortedPackages) {
versionLogger.info(packageName);
const pkg = packages[packageName];
const packageJsonPath = path.join(pkg.dist, 'package.json');
const packageJson = pkg.packageJson;
const version = pkg.version;

if (version) {
packageJson['version'] = version;
} else {
versionLogger.error('No version found... Only updating dependencies.');
}

for (const depName of Object.keys(packages)) {
const v = packages[depName].version;
for (const depKey of ['dependencies', 'peerDependencies', 'devDependencies']) {
const obj = packageJson[depKey] as JsonObject | null;
if (obj && obj[depName]) {
if (argv.local) {
obj[depName] = packages[depName].tar;
} else if (argv.snapshot) {
const pkg = packages[depName];
if (!pkg.snapshotRepo) {
versionLogger.error(
`Package ${JSON.stringify(depName)} is not published as a snapshot. `
+ `Fixing to current version ${v}.`,
);
obj[depName] = v;
} else {
obj[depName] = `github:${pkg.snapshotRepo}#${pkg.snapshotHash}`;
}
} else if ((obj[depName] as string).match(/\b0\.0\.0\b/)) {
obj[depName] = (obj[depName] as string).replace(/\b0\.0\.0\b/, v);
}
}
}
}

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
}
logger.info('Setting packageGroups...');
await _setPackageGroups(sortedPackages, logger.createChild('packageGroups'));
Copy link
Member

@clydin clydin Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this add package groups to all the dev kit packages each with all the other dev kit packages included?

Do we want that? Updating the schematics CLI for instance should probably not update the CLI proper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I added a check instead that build will add package group packages if they're in the package.json already, and added all packages that I thought were okay.


logger.info('Tarring all packages...');
const tarLogger = logger.createChild('license');
Expand Down