fix(js): fix typo so exports field in package.json is properly sorted (#29643)
## Current Behavior It tries to sort `exported` which is an invalid field. ## Expected Behavior It should sort `exports`. ## Related Issue(s) Fixes #
This commit is contained in:
parent
d0078d050e
commit
ed6b220214
@ -153,10 +153,32 @@ function runNgNew(projectName: string, cwd: string): void {
|
|||||||
const pmc = getPackageManagerCommand({ packageManager });
|
const pmc = getPackageManagerCommand({ packageManager });
|
||||||
|
|
||||||
const command = `${pmc.runUninstalledPackage} @angular/cli@${angularCliVersion} new ${projectName} --package-manager=${packageManager}`;
|
const command = `${pmc.runUninstalledPackage} @angular/cli@${angularCliVersion} new ${projectName} --package-manager=${packageManager}`;
|
||||||
cwd = join(tmpProjPath(), cwd);
|
const fullCwd = join(tmpProjPath(), cwd);
|
||||||
ensureDirSync(cwd);
|
ensureDirSync(fullCwd);
|
||||||
execSync(command, {
|
execSync(command, {
|
||||||
cwd,
|
cwd: fullCwd,
|
||||||
|
stdio: isVerbose() ? 'inherit' : 'pipe',
|
||||||
|
env: process.env,
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
|
||||||
|
// ensure angular packages are installed with ~ instead of ^ to prevent
|
||||||
|
// potential failures when new minor versions are released
|
||||||
|
function updateAngularDependencies(dependencies: any): void {
|
||||||
|
Object.keys(dependencies).forEach((key) => {
|
||||||
|
if (key.startsWith('@angular/') || key.startsWith('@angular-devkit/')) {
|
||||||
|
dependencies[key] = dependencies[key].replace(/^\^/, '~');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
updateJson(join(cwd, projectName, 'package.json'), (json) => {
|
||||||
|
updateAngularDependencies(json.dependencies ?? {});
|
||||||
|
updateAngularDependencies(json.devDependencies ?? {});
|
||||||
|
return json;
|
||||||
|
});
|
||||||
|
|
||||||
|
execSync(pmc.install, {
|
||||||
|
cwd: join(fullCwd, projectName),
|
||||||
stdio: isVerbose() ? 'inherit' : 'pipe',
|
stdio: isVerbose() ? 'inherit' : 'pipe',
|
||||||
env: process.env,
|
env: process.env,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
|
|||||||
@ -486,6 +486,29 @@ export function runNgNew(
|
|||||||
env: process.env,
|
env: process.env,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ensure angular packages are installed with ~ instead of ^ to prevent
|
||||||
|
// potential failures when new minor versions are released
|
||||||
|
function updateAngularDependencies(dependencies: any): void {
|
||||||
|
Object.keys(dependencies).forEach((key) => {
|
||||||
|
if (key.startsWith('@angular/') || key.startsWith('@angular-devkit/')) {
|
||||||
|
dependencies[key] = dependencies[key].replace(/^\^/, '~');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
updateJson('package.json', (json) => {
|
||||||
|
updateAngularDependencies(json.dependencies ?? {});
|
||||||
|
updateAngularDependencies(json.devDependencies ?? {});
|
||||||
|
return json;
|
||||||
|
});
|
||||||
|
|
||||||
|
execSync(pmc.install, {
|
||||||
|
cwd: join(e2eCwd, projName),
|
||||||
|
stdio: isVerbose() ? 'inherit' : 'pipe',
|
||||||
|
env: process.env,
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
|
||||||
copySync(tmpProjPath(), tmpBackupNgCliProjPath());
|
copySync(tmpProjPath(), tmpBackupNgCliProjPath());
|
||||||
|
|
||||||
if (isVerboseE2ERun()) {
|
if (isVerboseE2ERun()) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function sortPackageJsonFields(tree: Tree, projectRoot: string) {
|
|||||||
'main',
|
'main',
|
||||||
'module',
|
'module',
|
||||||
'types',
|
'types',
|
||||||
'exported',
|
'exports',
|
||||||
]);
|
]);
|
||||||
const orderedBottomFields = new Set([
|
const orderedBottomFields = new Set([
|
||||||
'dependencies',
|
'dependencies',
|
||||||
|
|||||||
@ -1027,8 +1027,8 @@ module.exports = withNx(
|
|||||||
"main",
|
"main",
|
||||||
"module",
|
"module",
|
||||||
"types",
|
"types",
|
||||||
"nx",
|
|
||||||
"exports",
|
"exports",
|
||||||
|
"nx",
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
expect(readJson(tree, 'mylib/tsconfig.json')).toMatchInlineSnapshot(`
|
expect(readJson(tree, 'mylib/tsconfig.json')).toMatchInlineSnapshot(`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user