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 command = `${pmc.runUninstalledPackage} @angular/cli@${angularCliVersion} new ${projectName} --package-manager=${packageManager}`;
|
||||
cwd = join(tmpProjPath(), cwd);
|
||||
ensureDirSync(cwd);
|
||||
const fullCwd = join(tmpProjPath(), cwd);
|
||||
ensureDirSync(fullCwd);
|
||||
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',
|
||||
env: process.env,
|
||||
encoding: 'utf-8',
|
||||
|
||||
@ -486,6 +486,29 @@ export function runNgNew(
|
||||
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('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());
|
||||
|
||||
if (isVerboseE2ERun()) {
|
||||
|
||||
@ -14,7 +14,7 @@ export function sortPackageJsonFields(tree: Tree, projectRoot: string) {
|
||||
'main',
|
||||
'module',
|
||||
'types',
|
||||
'exported',
|
||||
'exports',
|
||||
]);
|
||||
const orderedBottomFields = new Set([
|
||||
'dependencies',
|
||||
|
||||
@ -1027,8 +1027,8 @@ module.exports = withNx(
|
||||
"main",
|
||||
"module",
|
||||
"types",
|
||||
"nx",
|
||||
"exports",
|
||||
"nx",
|
||||
]
|
||||
`);
|
||||
expect(readJson(tree, 'mylib/tsconfig.json')).toMatchInlineSnapshot(`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user