From 25166a0cc12ca8338ed59da008390e5bca0881f6 Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sat, 12 Aug 2023 00:28:43 -0400 Subject: [PATCH 1/2] makes generic --- tools/lib.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/lib.js b/tools/lib.js index 955e169..ee25313 100644 --- a/tools/lib.js +++ b/tools/lib.js @@ -98,15 +98,17 @@ function generateDistFolder(appFolder) { } fs.mkdirSync(distPath, { recursive: true }); - const files = glob.sync(`./apps/${appFolder}/widget/**/*.{js,jsx,ts,tsx}`); - files.forEach((file) => { - const distFilePath = file - .replace(appFolder + "/widget", appFolder + "/src") - .replace("./apps", `./${distFolder}`); - if (!fs.existsSync(path.dirname(distFilePath))) { - fs.mkdirSync(path.dirname(distFilePath), { recursive: true }); - } - fs.copyFileSync(file, distFilePath); + ["widget", "thing", "type"].forEach((type) => { + const files = glob.sync(`./apps/${appFolder}/${type}/**/*.{js,jsx,ts,tsx}`); + files.forEach((file) => { + const distFilePath = file + .replace(appFolder + `/${type}`, appFolder + "/src") + .replace("./apps", `./${distFolder}`); + if (!fs.existsSync(path.dirname(distFilePath))) { + fs.mkdirSync(path.dirname(distFilePath), { recursive: true }); + } + fs.copyFileSync(file, distFilePath); + }); }); } @@ -188,19 +190,18 @@ function generateDevJson(appFolder) { if (!appConfig.appAccount) { return devJson; } - const widgetFiles = glob.sync( + + const files = glob.sync( `./${distFolder}/${appFolder}/src/**/*.{js,jsx,ts,tsx}`, ); - widgetFiles.forEach((file) => { + files.forEach((file) => { let fileContent = fs.readFileSync(file, "utf8"); - let widgetPath = file + let filePath = file .replace(`./${distFolder}/${appFolder}/src/`, "") .replace(path.extname(file), ""); - let widgetKey = `${appConfig.appAccount}/widget/${widgetPath - .split(path.sep) - .join(".")}`; - devJson.components[widgetKey] = { code: fileContent }; + let key = `${appConfig.appAccount}/$/${filePath.split(filePath.sep).join(".")}`; + devJson.components[key] = { code: fileContent }; }); return devJson; @@ -405,3 +406,4 @@ module.exports = { uploadDataCLI, uploadData, }; + From b7417a7f3ffd50aee731a1f57e5b6dda6a9b52ea Mon Sep 17 00:00:00 2001 From: Elliot Braem <16282460+elliotBraem@users.noreply.github.com> Date: Sun, 13 Aug 2023 18:20:14 -0400 Subject: [PATCH 2/2] . --- tools/lib.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/lib.js b/tools/lib.js index ee25313..abf16df 100644 --- a/tools/lib.js +++ b/tools/lib.js @@ -102,7 +102,7 @@ function generateDistFolder(appFolder) { const files = glob.sync(`./apps/${appFolder}/${type}/**/*.{js,jsx,ts,tsx}`); files.forEach((file) => { const distFilePath = file - .replace(appFolder + `/${type}`, appFolder + "/src") + .replace(appFolder + `/${type}`, appFolder + "/src" + `/${type}`) .replace("./apps", `./${distFolder}`); if (!fs.existsSync(path.dirname(distFilePath))) { fs.mkdirSync(path.dirname(distFilePath), { recursive: true }); @@ -191,17 +191,20 @@ function generateDevJson(appFolder) { return devJson; } - const files = glob.sync( - `./${distFolder}/${appFolder}/src/**/*.{js,jsx,ts,tsx}`, - ); - - files.forEach((file) => { - let fileContent = fs.readFileSync(file, "utf8"); - let filePath = file - .replace(`./${distFolder}/${appFolder}/src/`, "") - .replace(path.extname(file), ""); - let key = `${appConfig.appAccount}/$/${filePath.split(filePath.sep).join(".")}`; - devJson.components[key] = { code: fileContent }; + ["widget", "thing", "type"].forEach((it) => { + const files = glob.sync( + `./${distFolder}/${appFolder}/src/${type}/**/*.{js,jsx,ts,tsx}`, + ); + files.forEach((file) => { + let fileContent = fs.readFileSync(file, "utf8"); + let filePath = file + .replace(`./${distFolder}/${appFolder}/src/`, "") + .replace(path.extname(file), ""); + let key = `${appConfig.appAccount}/${type}/${filePath + .split(filePath.sep) + .join(".")}`; + devJson.components[key] = { code: fileContent }; + }); }); return devJson; @@ -406,4 +409,3 @@ module.exports = { uploadDataCLI, uploadData, }; -