Skip to content

Commit

Permalink
chore: change _version for 1.71 apps
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo committed Jul 24, 2024
1 parent b3d3db1 commit 86b6d5c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dev/copy-example-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ function copyApps(versionPathRoot, versionPathNew, version, port, versionName) {
const path = `${versionPathNew}/webapp/manifest.json`;
const manifest = fs.readFileSync(path, "utf8");
let manifestData = JSON.parse(manifest);

// Check if the version start with 1.71 and update the _version attribute
if (version.split(".")[1] === "71" && version.split(".")[0] === "1" ){
manifestData["_version"] = "1.17.0";
}

manifestData["sap.ui5"]["dependencies"]["minUI5Version"] = version;
manifestData = JSON.stringify(manifestData, null, 2);
fs.writeFileSync(path, manifestData, "utf8");

// replace ui5 version in yaml
// Read YAML file
const yamlPath = `${versionPathNew}/ui5.yaml`;
Expand All @@ -62,43 +69,51 @@ function copyApps(versionPathRoot, versionPathNew, version, port, versionName) {
let yamlStr = yaml.dump(doc);
fs.writeFileSync(yamlPath, yamlStr, 'utf8');
}

// replace port number
const pathPackageJson = `${versionPathNew}/package.json`;
const packageJson = fs.readFileSync(pathPackageJson, "utf8");
let packageJsonData = JSON.parse(packageJson);
let startScript = packageJsonData["scripts"]["start"];
startScript = startScript.replace(/\b\d{1,4}\b/, port);
packageJsonData["scripts"]["start"] = startScript;

// replace port number in scripts
let startSilentScript = packageJsonData["scripts"]["start:silent"];
startSilentScript = startSilentScript.replace(/\b\d{1,4}\b/, port);
packageJsonData["scripts"]["start:silent"] = startSilentScript;
let startFLPScript = packageJsonData["scripts"]["start-flp"];
if (startFLPScript) {
startFLPScript = startFLPScript.replace(/\b\d{1,4}\b/, port);
packageJsonData["scripts"]["start-flp"] = startFLPScript;
packageJsonData["scripts"]["start-flp"] = startFLPScript;
}

// change package.json name
packageJsonData["name"] = versionName;
packageJsonData = JSON.stringify(packageJsonData, null, 2);
fs.writeFileSync(pathPackageJson, packageJsonData, "utf8");

// replace i18n title
replaceInFile(`${versionPathNew}/webapp/i18n/i18n.properties`, 'appTitle=', 'appTitle=Test');

// replace theme to sap_fiori_3 in 1.71 and 1.84
if(version.split(".")[1] === "71" || version.split(".")[1] === "84"){
util.searchAndReplace(`${versionPathNew}/webapp/test/flpSandbox.html`,/sap_horizon/g,"sap_fiori_3")
util.searchAndReplace(`${versionPathNew}/webapp/index.html`,/sap_horizon/g,"sap_fiori_3")
}

// special script only for 1.71
if(version.split(".")[1] === "71"){
util.searchAndReplace(`${versionPathNew}/webapp/test/flpSandbox.html`,/<!-- only for 1.71 -->/g,`<script src="changes_preview.js"></script>`)
}

if(versionName.startsWith("ordersv4") && version.split(".")[1] === "84"){
util.searchAndReplace(`${versionPathNew}/webapp/ext/ListReportExtController.js`, /this.editFlow.getView\(\)/g, `this._view`);
util.searchAndReplace(`${versionPathNew}/webapp/ext/ObjectPageExtController.js`, /this.editFlow.getView\(\)/g, `this._view`);
}
}


// Read the .gitignore file

// Replace "test1" and "test2" with the strings you want to check for
Expand Down

0 comments on commit 86b6d5c

Please sign in to comment.