Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nrwl/tao

Package Overview
Dependencies
Maintainers
1
Versions
1621
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrwl/tao - npm Package Compare versions

Comparing version 8.5.0 to 8.5.1-beta.1

2

package.json
{
"name": "@nrwl/tao",
"version": "8.5.0",
"version": "8.5.1-beta.1",
"description": "CLI for generating code and running commands",

@@ -5,0 +5,0 @@ "repository": {

@@ -11,2 +11,3 @@ <p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p>

[![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join us @nrwl/community on slack](https://img.shields.io/badge/slack-%40nrwl%2Fcommunity-brightgreen)](https://join.slack.com/t/nrwlcommunity/shared_invite/enQtNzMwMTQ2MjY0MDA1LWE4ZDZiYjM5ZjE0MWVjYmVmODM1MDEyZGU5NzA2YTM2MDM2ZDY3Yzg4YWU4MDI4YTcwZTM1ZWRjNzE5M2YzY2Y)

@@ -13,0 +14,0 @@ </div>

@@ -15,2 +15,3 @@ export declare type MigrationsJson = {

ifPackageInstalled?: string;
alwaysAddToPackageJson?: boolean;
};

@@ -38,3 +39,7 @@ };

packageJson: any;
migrations: any;
migrations: {
package: string;
name: string;
version: string;
}[];
}>;

@@ -41,0 +46,0 @@ private _createMigrateJson;

@@ -35,3 +35,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const packageJson = yield this._updatePackageJson(targetPackage, targetVersion, {});
const packageJson = yield this._updatePackageJson(targetPackage, { version: targetVersion, alwaysAddToPackageJson: false }, {});
const migrations = yield this._createMigrateJson(packageJson);

@@ -45,15 +45,12 @@ return { packageJson, migrations };

const currentVersion = this.versions(c);
const targetVersion = versions[c];
if (currentVersion) {
const migrationsJson = yield this.fetch(c, targetVersion);
if (!migrationsJson.schematics)
return [];
return Object.keys(migrationsJson.schematics)
.filter(r => semver_1.gt(migrationsJson.schematics[r].version, currentVersion) &
semver_1.lte(migrationsJson.schematics[r].version, targetVersion))
.map(r => (Object.assign({}, migrationsJson.schematics[r], { package: c, name: r })));
}
else {
return Promise.resolve(null);
}
if (currentVersion === null)
return [];
const target = versions[c];
const migrationsJson = yield this.fetch(c, target.version);
if (!migrationsJson.schematics)
return [];
return Object.keys(migrationsJson.schematics)
.filter(r => semver_1.gt(migrationsJson.schematics[r].version, currentVersion) &
semver_1.lte(migrationsJson.schematics[r].version, target.version))
.map(r => (Object.assign({}, migrationsJson.schematics[r], { package: c, name: r })));
})));

@@ -63,20 +60,12 @@ return migrations.reduce((m, c) => [...m, ...c], []);

}
_updatePackageJson(targetPackage, targetVersion, versions) {
_updatePackageJson(targetPackage, target, collectedVersions) {
return __awaiter(this, void 0, void 0, function* () {
let targetVersion = target.version;
if (this.to[targetPackage]) {
targetVersion = this.to[targetPackage];
}
let currentVersion;
if (this.from[targetPackage]) {
currentVersion = this.from[targetPackage];
}
else {
currentVersion = this.versions(targetPackage);
if (!currentVersion) {
throw new Error(`Cannot find package "${targetPackage}" installed.`);
}
}
let migrationsJson;
try {
migrationsJson = yield this.fetch(targetPackage, targetVersion);
targetVersion = migrationsJson.version;
}

@@ -93,9 +82,10 @@ catch (e) {

const childCalls = yield Promise.all(Object.keys(packages)
.filter(r => !versions[r] || semver_1.gt(packages[r], versions[r]))
.map(u => this._updatePackageJson(u, packages[u], {
[targetPackage]: targetVersion
})));
.filter(r => {
return (!collectedVersions[r] ||
semver_1.gt(packages[r].version, collectedVersions[r].version));
})
.map(u => this._updatePackageJson(u, packages[u], Object.assign({}, collectedVersions, { [targetPackage]: target }))));
return childCalls.reduce((m, c) => {
Object.keys(c).forEach(r => {
if (!m[r] || semver_1.gt(c[r], m[r])) {
if (!m[r] || semver_1.gt(c[r].version, m[r].version)) {
m[r] = c[r];

@@ -105,11 +95,20 @@ }

return m;
}, { [targetPackage]: migrationsJson.version });
}, {
[targetPackage]: {
version: migrationsJson.version,
alwaysAddToPackageJson: target.alwaysAddToPackageJson || false
}
});
});
}
collapsePackages(packageName, targetVersion, m) {
// this should be used to know what version to include
// we should use from everywhere we use versions
if (!m.packageJsonUpdates)
return {};
return Object.keys(m.packageJsonUpdates)
.filter(r => semver_1.gt(m.packageJsonUpdates[r].version, this.versions(packageName)) &
semver_1.lte(m.packageJsonUpdates[r].version, targetVersion))
.filter(r => {
return (semver_1.gt(m.packageJsonUpdates[r].version, this.versions(packageName)) &&
semver_1.lte(m.packageJsonUpdates[r].version, targetVersion));
})
.map(r => m.packageJsonUpdates[r].packages)

@@ -122,3 +121,6 @@ .map(packages => {

this.versions(packages[p].ifPackageInstalled))
.reduce((m, c) => (Object.assign({}, m, { [c]: packages[c].version })), {});
.reduce((m, c) => (Object.assign({}, m, { [c]: {
version: packages[c].version,
alwaysAddToPackageJson: packages[c].alwaysAddToPackageJson
} })), {});
})

@@ -179,7 +181,7 @@ .reduce((m, c) => (Object.assign({}, m, c)), {});

return (packageName) => {
const content = fs_1.readFileSync(path.join(root, `./node_modules/${packageName}/package.json`));
if (content) {
try {
const content = fs_1.readFileSync(path.join(root, `./node_modules/${packageName}/package.json`));
return JSON.parse(stripJsonComments(content.toString()))['version'];
}
else {
catch (e) {
return null;

@@ -197,7 +199,13 @@ }

const json = JSON.parse(stripJsonComments(fs_1.readFileSync(path.join(dir, 'node_modules', packageName, 'package.json')).toString()));
const migrationsFile = json['nx-migrations'] || json['ng-update'];
let migrationsFile = json['nx-migrations'] || json['ng-update'];
// migrationsFile is an object
if (migrationsFile.migration) {
migrationsFile = migrationsFile.migration;
}
// packageVersion can be a tag, resolvedVersion works with semver
const resolvedVersion = json.version;
if (migrationsFile) {
const json = JSON.parse(stripJsonComments(fs_1.readFileSync(path.join(dir, 'node_modules', packageName, migrationsFile)).toString()));
return {
version: packageVersion,
version: resolvedVersion,
schematics: json.schematics,

@@ -208,3 +216,3 @@ packageJsonUpdates: json.packageJsonUpdates

else {
return { version: packageVersion };
return { version: resolvedVersion };
}

@@ -222,8 +230,11 @@ });

if (json.devDependencies && json.devDependencies[p]) {
json.devDependencies[p] = packageJson[p];
json.devDependencies[p] = packageJson[p].version;
}
else {
else if (json.dependencies && json.dependencies[p]) {
json.dependencies[p] = packageJson[p].version;
}
else if (packageJson[p].alwaysAddToPackageJson) {
if (!json.dependencies)
json.dependencies = {};
json.dependencies[p] = packageJson[p];
json.dependencies[p] = packageJson[p].version;
}

@@ -242,10 +253,17 @@ });

const { migrations, packageJson } = yield migrator.updatePackageJson(opts.targetPackage, opts.targetVersion);
createMigrationsFile(root, migrations);
updatePackageJson(root, packageJson);
logger.info(`The migrate command has run successfully.`);
logger.info(`- package.json has been updated`);
logger.info(`- migrations.json has been generated`);
logger.info(`Next steps:`);
logger.info(`- Make sure package.json changes make sense and then run 'npm install' or 'yarn'`);
logger.info(`- Run 'nx migrate --run-migrations=migrations.json'`);
if (migrations.length > 0) {
createMigrationsFile(root, migrations);
logger.info(`The migrate command has run successfully.`);
logger.info(`- package.json has been updated`);
logger.info(`- migrations.json has been generated`);
logger.info(`Next steps:`);
logger.info(`- Make sure package.json changes make sense and then run 'npm install' or 'yarn'`);
logger.info(`- Run 'nx migrate --run-migrations=migrations.json'`);
}
else {
logger.info(`The migrate command has run successfully.`);
logger.info(`- package.json has been updated`);
logger.info(`- there are no migrations to run, so migrations.json has not been created.`);
}
});

@@ -252,0 +270,0 @@ }

@@ -17,3 +17,5 @@ "use strict";

versions: () => null,
fetch: (p, v) => null,
fetch: (p, v) => {
throw new Error('cannot fetch');
},
from: {},

@@ -27,3 +29,3 @@ to: {}

catch (e) {
expect(e.message).toEqual(`Cannot find package "mypackage" installed.`);
expect(e.message).toEqual(`cannot fetch`);
}

@@ -41,3 +43,3 @@ }));

packageJson: {
mypackage: '2.0.0'
mypackage: { version: '2.0.0', alwaysAddToPackageJson: false }
}

@@ -57,3 +59,4 @@ });

packages: {
child: { version: '2.0.0' }
child: { version: '2.0.0' },
newChild: { version: '3.0.0', alwaysAddToPackageJson: true }
}

@@ -68,2 +71,5 @@ }

}
else if (p === 'newChild') {
return Promise.resolve({ version: '2.0.0' });
}
else {

@@ -79,4 +85,5 @@ return Promise.resolve(null);

packageJson: {
parent: '2.0.0',
child: '2.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child: { version: '2.0.0', alwaysAddToPackageJson: false },
newChild: { version: '2.0.0', alwaysAddToPackageJson: true }
}

@@ -127,4 +134,4 @@ });

packageJson: {
parent: '2.0.0',
child: '2.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child: { version: '2.0.0', alwaysAddToPackageJson: false }
}

@@ -190,6 +197,6 @@ });

packageJson: {
parent: '2.0.0',
child1: '2.0.0',
child2: '2.0.0',
grandchild: '4.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child1: { version: '2.0.0', alwaysAddToPackageJson: false },
child2: { version: '2.0.0', alwaysAddToPackageJson: false },
grandchild: { version: '4.0.0', alwaysAddToPackageJson: false }
}

@@ -240,4 +247,4 @@ });

packageJson: {
parent: '2.0.0',
child: '2.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child: { version: '2.0.0', alwaysAddToPackageJson: false }
}

@@ -284,4 +291,4 @@ });

packageJson: {
parent: '2.0.0',
child1: '2.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child1: { version: '2.0.0', alwaysAddToPackageJson: false }
}

@@ -294,3 +301,9 @@ });

const migrator = new migrate_1.Migrator({
versions: p => (p !== 'not-installed' ? '1.0.0' : null),
versions: p => {
if (p === 'parent')
return '1.0.0';
if (p === 'child')
return '1.0.0';
return null;
},
fetch: (p, v) => {

@@ -304,3 +317,6 @@ if (p === 'parent') {

packages: {
child: { version: '2.0.0' }
child: { version: '2.0.0' },
newChild: {
version: '3.0.0'
}
}

@@ -328,2 +344,13 @@ }

}
else if (p === 'newChild') {
return Promise.resolve({
version: '3.0.0',
schematics: {
version2: {
version: '2.0.0',
factory: 'new-child-factory'
}
}
});
}
else {

@@ -352,4 +379,5 @@ return Promise.resolve(null);

packageJson: {
parent: '2.0.0',
child: '2.0.0'
parent: { version: '2.0.0', alwaysAddToPackageJson: false },
child: { version: '2.0.0', alwaysAddToPackageJson: false },
newChild: { version: '3.0.0', alwaysAddToPackageJson: false }
}

@@ -356,0 +384,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc