Skip to content

Commit 52ef555

Browse files
refactor: update getOssFiles function to clarify parameter naming and logic
1 parent 85b8255 commit 52ef555

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

scripts/release/build-mpk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function createNativeMobileResourcesModule(): Promise<ArtifactResult> {
106106
log("Creating the Native Mobile Resource module...");
107107
const moduleFolder = join(repoRootPath, "packages/jsActions", inputs.module);
108108
log(`Module folder: ${moduleFolder}`);
109-
const ossFiles = await getOssFiles(moduleFolder, true);
109+
const ossFiles = await getOssFiles(moduleFolder, false);
110110
log(`OSS files to include: ${ossFiles.length}`);
111111
const tmpFolder = join(repoRootPath, "tmp", inputs.module);
112112
log(`Temp folder: ${tmpFolder}`);
@@ -141,7 +141,7 @@ async function createNanoflowCommonsModule(): Promise<ArtifactResult> {
141141
log("Creating the Nanoflow Commons module...");
142142
const moduleFolder = join(repoRootPath, "packages/jsActions", inputs.module);
143143
log(`Module folder: ${moduleFolder}`);
144-
const ossFiles = await getOssFiles(moduleFolder, true);
144+
const ossFiles = await getOssFiles(moduleFolder, false);
145145
log(`OSS files to include: ${ossFiles.length}`);
146146
const tmpFolder = join(repoRootPath, "tmp", inputs.module);
147147
log(`Temp folder: ${tmpFolder}`);

scripts/release/module-automation/commons.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ export function copyFilesToMpk(
2525
moduleNameInModeler: string
2626
): Promise<void>;
2727

28-
export function getOssFiles(folderPath: string, skipOssReadme: boolean): Promise<Array<{ src: string; dest: string }>>;
28+
export function getOssFiles(
29+
folderPath: string,
30+
isOssReadmeRequired: boolean
31+
): Promise<Array<{ src: string; dest: string }>>;

scripts/release/module-automation/commons.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function unzip(src, dest) {
261261
return execShellCommand(`unzip "${src}" -d "${dest}"`);
262262
}
263263

264-
async function getOssFiles(folderPath, skipOssReadme) {
264+
async function getOssFiles(folderPath, isOssReadmeRequired) {
265265
if (!folderPath || typeof folderPath !== "string") {
266266
throw new TypeError(`Invalid folderPath: ${folderPath}`);
267267
}
@@ -273,17 +273,17 @@ async function getOssFiles(folderPath, skipOssReadme) {
273273
throw new Error(`License file not found at expected location: ${licenseFile}`);
274274
}
275275

276-
if (skipOssReadme) {
277-
return [{ src: licenseFile, dest: basename(licenseFile) }];
278-
}
279-
280276
const readmeossPattern = "*__*__READMEOSS_*.html";
281277
const readmeossFiles = globSync(readmeossPattern, { cwd: folderPath, absolute: true, ignore: "**/.*/**" });
282278

283-
if (readmeossFiles.length === 0) {
279+
if (isOssReadmeRequired && readmeossFiles.length === 0) {
284280
throw new Error(`No OSS README file found in ${folderPath} matching ${readmeossPattern}`);
285281
}
286282

283+
if (readmeossFiles.length === 0) {
284+
return [{ src: licenseFile, dest: basename(licenseFile) }];
285+
}
286+
287287
const ossReadmeFile = readmeossFiles[0];
288288

289289
return [
@@ -292,13 +292,13 @@ async function getOssFiles(folderPath, skipOssReadme) {
292292
];
293293
}
294294

295-
async function copyFilesToMpk(filesToAdd, mpkOutput, moduleName) {
295+
async function copyFilesToMpk(files, mpkOutput, moduleName) {
296296
const projectPath = mpkOutput.replace(".mpk", "");
297297
// Unzip the mpk
298298
await unzip(mpkOutput, projectPath);
299299
await rm(mpkOutput, { recursive: true, force: true });
300300
// Add additional files to the MPK
301-
for await (const file of filesToAdd) {
301+
for await (const file of files) {
302302
await copyFile(file.src, join(projectPath, file.dest));
303303
}
304304
// Re-zip and rename
@@ -307,7 +307,7 @@ async function copyFilesToMpk(filesToAdd, mpkOutput, moduleName) {
307307
}
308308

309309
// Unzip the module, copy the widget and update package.xml
310-
async function exportModuleWithWidgets(moduleName, mpkOutput, widgetsFolders, filesToAdd) {
310+
async function exportModuleWithWidgets(moduleName, mpkOutput, widgetsFolders, additionalFiles) {
311311
console.log(`Adding ${widgetsFolders.length} widgets to module ${moduleName}`);
312312
const projectPath = mpkOutput.replace(".mpk", "");
313313
const packageXmlFile = join(projectPath, "package.xml");
@@ -345,7 +345,7 @@ async function exportModuleWithWidgets(moduleName, mpkOutput, widgetsFolders, fi
345345
throw new Error(`Including widgets in module failed. package.xml of widget/module ${moduleName} not found`);
346346
}
347347
// Add additional files to the MPK
348-
for await (const file of filesToAdd) {
348+
for await (const file of additionalFiles) {
349349
await copyFile(file.src, join(projectPath, file.dest));
350350
}
351351
// Re-zip and rename

0 commit comments

Comments
 (0)