Skip to content

Commit

Permalink
Update function updateNameInPackageJson for angular 17 (SAP#18350)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpawelczak authored Jan 10, 2024
1 parent e0226fe commit 37b6a5f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/breaking-changes/extract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <spartacus-team@sap.com>
* SPDX-FileCopyrightText: 2024 SAP Spartacus team <spartacus-team@sap.com>
*
* SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -56,19 +55,21 @@ function runExtractor(libPath: string) {
} else {
console.error(
`API Extractor completed with ${extractorResult.errorCount} errors` +
` and ${extractorResult.warningCount} warnings`
` and ${extractorResult.warningCount} warnings`
);
process.exitCode = 1;
}
}

export function updateNameInPackageJson(filePath: string): {
export function updateNameInPackageJson(libPath: string): {
name: string;
newName: string;
} {
const filePath = `${libPath}/package.json`;
const packageContent = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
const name: string = packageContent.name;
const name: string = packageContent.name ?? getEntryPointName(libPath);
const newName = escapePackageName(name);

fs.writeFileSync(
filePath,
JSON.stringify({ ...packageContent, name: newName }, undefined, 2)
Expand All @@ -87,13 +88,14 @@ function preparePackageJson(libPath: string): void {

// Update the package.json file
console.log(`update package name in file ${libPath}/package.json`);
updateNameInPackageJson(`${libPath}/package.json`);
updateNameInPackageJson(libPath);
}

function createPackageJsonFile(libPath: string) {
const beginIdx = libPath.indexOf(distFolderPath) + distFolderPath.length + 1;
const entryPointNameFromPath = `@spartacus/${libPath.substring(beginIdx)}`;
const entryPointNameGenerated = getEntryPointName(libPath);

if (entryPointNameFromPath !== entryPointNameGenerated) {
console.log(
`INFO: Module name ${entryPointNameGenerated} differs from path name ${libPath}`
Expand Down

0 comments on commit 37b6a5f

Please sign in to comment.