@nrwl/tao
Advanced tools
Comparing version 8.11.1 to 8.11.2-beta.1
{ | ||
"name": "@nrwl/tao", | ||
"version": "8.11.1", | ||
"version": "8.11.2-beta.1", | ||
"description": "CLI for generating code and running commands", | ||
@@ -32,5 +32,5 @@ "repository": { | ||
"dependencies": { | ||
"@angular-devkit/schematics": "8.3.14", | ||
"@angular-devkit/core": "8.3.14", | ||
"@angular-devkit/architect": "0.803.14", | ||
"@angular-devkit/schematics": "8.3.22", | ||
"@angular-devkit/core": "8.3.22", | ||
"@angular-devkit/architect": "0.803.22", | ||
"inquirer": "^6.3.1", | ||
@@ -37,0 +37,0 @@ "minimist": "^1.2.0", |
@@ -49,4 +49,22 @@ export declare type MigrationsJson = { | ||
private lte; | ||
private normalizeVersion; | ||
} | ||
export declare function normalizeVersionWithTagCheck(version: string): string; | ||
export declare function normalizeVersion(version: string): string; | ||
declare type GenerateMigrations = { | ||
type: 'generateMigrations'; | ||
targetPackage: string; | ||
targetVersion: string; | ||
from: { | ||
[k: string]: string; | ||
}; | ||
to: { | ||
[k: string]: string; | ||
}; | ||
}; | ||
declare type RunMigrations = { | ||
type: 'runMigrations'; | ||
runMigrations: string; | ||
}; | ||
export declare function parseMigrationsOptions(args: string[]): GenerateMigrations | RunMigrations; | ||
export declare function migrate(root: string, args: string[], isVerbose?: boolean): Promise<any>; | ||
export {}; |
@@ -152,20 +152,54 @@ "use strict"; | ||
gt(v1, v2) { | ||
return semver_1.gt(this.normalizeVersion(v1), this.normalizeVersion(v2)); | ||
return semver_1.gt(normalizeVersion(v1), normalizeVersion(v2)); | ||
} | ||
lte(v1, v2) { | ||
return semver_1.lte(this.normalizeVersion(v1), this.normalizeVersion(v2)); | ||
return semver_1.lte(normalizeVersion(v1), normalizeVersion(v2)); | ||
} | ||
normalizeVersion(v) { | ||
if (v.startsWith('8-')) | ||
return '8.0.0-beta.1'; | ||
if (v.startsWith('9-')) | ||
return '9.0.0-beta.1'; | ||
if (v.startsWith('10-')) | ||
return '9.0.0-beta.1'; | ||
if (v.startsWith('11-')) | ||
return '9.0.0-beta.1'; | ||
return v; | ||
} | ||
exports.Migrator = Migrator; | ||
function normalizeVersionWithTagCheck(version) { | ||
if (version[0].match(/[0-9]/)) { | ||
return normalizeVersion(version); | ||
} | ||
else { | ||
throw new Error(`Incorrect version "${version}". You must use a semver version (cannot use "latest" or "next").`); | ||
} | ||
} | ||
exports.Migrator = Migrator; | ||
exports.normalizeVersionWithTagCheck = normalizeVersionWithTagCheck; | ||
function normalizeVersion(version) { | ||
const [v, t] = version.split('-'); | ||
const [major, minor, patch] = v.split('.'); | ||
const newV = `${major || 0}.${minor || 0}.${patch || 0}`; | ||
const newVersion = t ? `${newV}-${t}` : newV; | ||
try { | ||
semver_1.gt(newVersion, '0.0.0'); | ||
return newVersion; | ||
} | ||
catch (e) { | ||
try { | ||
semver_1.gt(newV, '0.0.0'); | ||
return newV; | ||
} | ||
catch (e) { | ||
const withoutPatch = `${major || 0}.${minor || 0}.0`; | ||
try { | ||
if (semver_1.gt(withoutPatch, '0.0.0')) { | ||
return withoutPatch; | ||
} | ||
} | ||
catch (e) { | ||
const withoutPatchAndMinor = `${major || 0}.0.0`; | ||
try { | ||
if (semver_1.gt(withoutPatchAndMinor, '0.0.0')) { | ||
return withoutPatchAndMinor; | ||
} | ||
} | ||
catch (e) { | ||
return '0.0.0'; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
exports.normalizeVersion = normalizeVersion; | ||
function parseMigrationsOptions(args) { | ||
@@ -179,31 +213,5 @@ const options = params_1.convertToCamelCase(minimist(args, { | ||
if (!options.runMigrations) { | ||
let from = {}; | ||
if (options.from) { | ||
options.from.split(',').forEach(p => { | ||
const split = p.lastIndexOf('@'); | ||
from[p.substring(0, split)] = p.substring(split + 1); | ||
}); | ||
} | ||
let to = {}; | ||
if (options.to) { | ||
options.to.split(',').forEach(p => { | ||
const split = p.lastIndexOf('@'); | ||
to[p.substring(0, split)] = p.substring(split + 1); | ||
}); | ||
} | ||
let targetPackage; | ||
let targetVersion; | ||
if (args[0] && args[0].indexOf('@') > 1) { | ||
const i = args[0].lastIndexOf('@'); | ||
targetPackage = args[0].substring(0, i); | ||
targetVersion = args[0].substring(i + 1); | ||
} | ||
else if (args[0]) { | ||
targetPackage = '@nrwl/workspace'; | ||
targetVersion = args[0]; | ||
} | ||
else { | ||
targetPackage = '@nrwl/workspace'; | ||
targetVersion = 'latest'; | ||
} | ||
const from = options.from ? versionOverrides(options.from, 'from') : {}; | ||
const to = options.to ? versionOverrides(options.to, 'to') : {}; | ||
const { targetPackage, targetVersion } = parseTargetPackageAndVersion(args[0]); | ||
return { | ||
@@ -221,2 +229,40 @@ type: 'generateMigrations', | ||
} | ||
exports.parseMigrationsOptions = parseMigrationsOptions; | ||
function parseTargetPackageAndVersion(args) { | ||
if (!args) { | ||
throw new Error(`Provide the correct package name and version. E.g., @nrwl/workspace@9.0.0.`); | ||
} | ||
if (args.indexOf('@') > -1) { | ||
const i = args.lastIndexOf('@'); | ||
const targetPackage = args.substring(0, i); | ||
const maybeVersion = args.substring(i + 1); | ||
if (!targetPackage || !maybeVersion) { | ||
throw new Error(`Provide the correct package name and version. E.g., @nrwl/workspace@9.0.0.`); | ||
} | ||
const targetVersion = normalizeVersionWithTagCheck(maybeVersion); | ||
return { targetPackage, targetVersion }; | ||
} | ||
else { | ||
return { | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: normalizeVersionWithTagCheck(args) | ||
}; | ||
} | ||
} | ||
function versionOverrides(overrides, param) { | ||
const res = {}; | ||
overrides.split(',').forEach(p => { | ||
const split = p.lastIndexOf('@'); | ||
if (split === -1 || split === 0) { | ||
throw new Error(`Incorrect '${param}' section. Use --${param}="package@version"`); | ||
} | ||
const selectedPackage = p.substring(0, split).trim(); | ||
const selectedVersion = p.substring(split + 1).trim(); | ||
if (!selectedPackage || !selectedVersion) { | ||
throw new Error(`Incorrect '${param}' section. Use --${param}="package@version"`); | ||
} | ||
res[selectedPackage] = normalizeVersionWithTagCheck(selectedVersion); | ||
}); | ||
return res; | ||
} | ||
function versions(root, from) { | ||
@@ -223,0 +269,0 @@ return (packageName) => { |
@@ -440,2 +440,71 @@ "use strict"; | ||
}); | ||
describe('normalizeVersions', () => { | ||
it('should return version when it meets semver requirements', () => { | ||
expect(migrate_1.normalizeVersion('1.2.3')).toEqual('1.2.3'); | ||
expect(migrate_1.normalizeVersion('1.2.3-beta.1')).toEqual('1.2.3-beta.1'); | ||
}); | ||
it('should handle versions missing a patch or a minor', () => { | ||
expect(migrate_1.normalizeVersion('1.2')).toEqual('1.2.0'); | ||
expect(migrate_1.normalizeVersion('1')).toEqual('1.0.0'); | ||
expect(migrate_1.normalizeVersion('1-beta.1')).toEqual('1.0.0-beta.1'); | ||
}); | ||
it('should handle incorrect versions', () => { | ||
expect(migrate_1.normalizeVersion('1-invalid-version')).toEqual('1.0.0-invalid'); | ||
expect(migrate_1.normalizeVersion('1.invalid-version')).toEqual('1.0.0'); | ||
expect(migrate_1.normalizeVersion('invalid-version')).toEqual('0.0.0'); | ||
}); | ||
}); | ||
describe('parseMigrationsOptions', () => { | ||
it('should work', () => { | ||
const r = migrate_1.parseMigrationsOptions([ | ||
'8.12.0', | ||
'--from', | ||
'@myscope/a@12.3,@myscope/b@1.1.1', | ||
'--to', | ||
'@myscope/c@12.3.1' | ||
]); | ||
expect(r).toEqual({ | ||
type: 'generateMigrations', | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.12.0', | ||
from: { | ||
'@myscope/a': '12.3.0', | ||
'@myscope/b': '1.1.1' | ||
}, | ||
to: { | ||
'@myscope/c': '12.3.1' | ||
} | ||
}); | ||
}); | ||
it('should handle different variations of the target package', () => { | ||
expect(migrate_1.parseMigrationsOptions(['8.12'])).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.12.0' | ||
}); | ||
expect(migrate_1.parseMigrationsOptions(['8'])).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.0.0' | ||
}); | ||
expect(migrate_1.parseMigrationsOptions(['@nrwl/workspace@8.12'])).toMatchObject({ | ||
targetPackage: '@nrwl/workspace', | ||
targetVersion: '8.12.0' | ||
}); | ||
expect(migrate_1.parseMigrationsOptions(['mypackage@8.12'])).toMatchObject({ | ||
targetPackage: 'mypackage', | ||
targetVersion: '8.12.0' | ||
}); | ||
expect(() => migrate_1.parseMigrationsOptions(['mypackage@latest'])).toThrowError(`Incorrect version "latest". You must use a semver version (cannot use "latest" or "next").`); | ||
expect(() => migrate_1.parseMigrationsOptions(['@nrwl/workspace'])).toThrowError(`Provide the correct package name and version. E.g., @nrwl/workspace@9.0.0.`); | ||
}); | ||
it('should handle incorrect from', () => { | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--from', '@myscope/a@'])).toThrowError(`Incorrect 'from' section. Use --from="package@version"`); | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--from', '@myscope/a'])).toThrowError(`Incorrect 'from' section. Use --from="package@version"`); | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--from', 'myscope'])).toThrowError(`Incorrect 'from' section. Use --from="package@version"`); | ||
}); | ||
it('should handle incorrect from', () => { | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--to', '@myscope/a@'])).toThrowError(`Incorrect 'to' section. Use --to="package@version"`); | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--to', '@myscope/a'])).toThrowError(`Incorrect 'to' section. Use --to="package@version"`); | ||
expect(() => migrate_1.parseMigrationsOptions(['8.12.0', '--to', 'myscope'])).toThrowError(`Incorrect 'to' section. Use --to="package@version"`); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96108
1983
1
+ Added@angular-devkit/architect@0.803.22(transitive)
+ Added@angular-devkit/core@8.3.22(transitive)
+ Added@angular-devkit/schematics@8.3.22(transitive)
- Removed@angular-devkit/architect@0.803.14(transitive)
- Removed@angular-devkit/core@8.3.14(transitive)
- Removed@angular-devkit/schematics@8.3.14(transitive)
Updated@angular-devkit/core@8.3.22