Skip to content

Commit

Permalink
fix: config
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Feb 16, 2024
1 parent f904557 commit b7349b6
Show file tree
Hide file tree
Showing 5 changed files with 18,425 additions and 174 deletions.
60 changes: 30 additions & 30 deletions __application/scripts/buildPrepare.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');
const { mkdirp } = require('mkdirp');
const fs = require("fs")
const path = require("path")
const { mkdirp } = require("mkdirp")

const ignoreFiles = [
'.DS_Store',
'scripts',
'utils',
'WIP-',
];
".DS_Store",
"scripts",
"utils",
"WIP-"
]

function getRandomInt(max) {
return Math.floor(Math.random() * max);
return Math.floor(Math.random() * max)
}

const color = [
{ name: 'FgRed', value: '\x1b[31m%s\x1b[0m' },
{ name: 'FgGreen', value: '\x1b[32m%s\x1b[0m' },
{ name: 'FgYellow', value: '\x1b[33m%s\x1b[0m' },
{ name: 'FgMagenta', value: '\x1b[35m%s\x1b[0m' },
{ name: 'FgCyan', value: '\x1b[36m%s\x1b[0m' },
];
{ "name": "FgRed", "value": "\x1b[31m%s\x1b[0m" },
{ "name": "FgGreen", "value": "\x1b[32m%s\x1b[0m" },
{ "name": "FgYellow", "value": "\x1b[33m%s\x1b[0m" },
{ "name": "FgMagenta", "value": "\x1b[35m%s\x1b[0m" },
{ "name": "FgCyan", "value": "\x1b[36m%s\x1b[0m" }
]

// generate exports for all platforms
const srcPath = path.resolve(__dirname, '../component');
const components = fs.readdirSync(srcPath).filter((files) => !ignoreFiles.includes(files) && !files.includes('WIP-'));
let count = 0;
const srcPath = path.resolve(__dirname, "../component")
const components = fs.readdirSync(srcPath).filter((files) => !ignoreFiles.includes(files) && !files.includes("WIP-"))
let count = 0

components.forEach((component) => {
const componentDir = path.resolve(`${__dirname}`, `../../${component}`);
const componentDir = path.resolve(`${__dirname}`, `../../${component}`)
mkdirp(componentDir).then(() => {
const componentFile = path.resolve(componentDir, 'index.js');
const componentContent = `export { default } from '../__build-es/${component}';\nexport * from '../__build-es/${component}';\n`;
const componentFile = path.resolve(componentDir, "index.js")
const componentContent = `export { default } from '../__build-es/${component}';\nexport * from '../__build-es/${component}';\n`
fs.writeFile(componentFile, componentContent, (writeFileErr) => {
if (writeFileErr) throw writeFileErr;
console.log(color[getRandomInt(color.length)].value, ` ${count + 3}. generated: ${componentFile} \n`);
count += 1;
if (writeFileErr) throw writeFileErr
console.log(color[getRandomInt(color.length)].value, ` ${count + 3}. generated: ${componentFile} \n`)
count += 1
if (count === components.length) {
console.log(color[0].value, ` ${count + 3}. Generated: Package index files for package for direct import \n`);
console.log('\x1b[44m%s\x1b[0m', ` ${count + 4}. Final: Setup Completed Successfully`);
console.log('');
console.log(color[0].value, ` ${count + 3}. Generated: Package index files for package for direct import \n`)
console.log("\x1b[44m%s\x1b[0m", ` ${count + 4}. Final: Setup Completed Successfully`)
console.log("")
}
});
});
});
})
})
})
47 changes: 14 additions & 33 deletions __application/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
export const MONTHS_NAME = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"
export const color = [
{ "name": "FgRed", "value": "\x1b[31m%s\x1b[0m" },
{ "name": "FgGreen", "value": "\x1b[32m%s\x1b[0m" },
{ "name": "FgYellow", "value": "\x1b[33m%s\x1b[0m" },
{ "name": "FgMagenta", "value": "\x1b[35m%s\x1b[0m" },
{ "name": "FgCyan", "value": "\x1b[36m%s\x1b[0m" }
]

export const timeMap = {
"1": "13",
"2": "14",
"3": "15",
"4": "16",
"5": "17",
"6": "18",
"7": "19",
"8": "20",
"9": "21",
"10": "22",
"11": "23",
"12": "24"
}

// YEAR MAPPING

export const yearMapping = {
"1": "Jan",
"2": "Feb",
"3": "Mar",
"4": "Apr",
"5": "May",
"6": "Jun",
"7": "Jul",
"8": "Aug",
"9": "Sept",
"10": "Oct",
"11": "Nov",
"12": "Dec"
}
export const ignoreFiles = [
".DS_Store",
"scripts",
"utils",
"themePrepare.js",
"universal",
"WIP-"
]
29 changes: 29 additions & 0 deletions __application/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable import/extensions */
/* eslint-disable no-underscore-dangle */
import fs from "fs"
import path from "path"
import { ignoreFiles } from "./constants.js"

export const capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1)

export const getRandomInt = (max) => Math.floor(Math.random() * max)

export const getDirPath = (env, CURRENT_APP_DIR, COMPONENT_CONFIG_PATH) => {
let createDir

if (env === "local") {
createDir = `${CURRENT_APP_DIR}/${COMPONENT_CONFIG_PATH}/fe-theme`
} else {
createDir = path.resolve(`${__dirname}`, `../../../${process.env.COMPONENT_CONFIG_PATH}/fe-theme`)
}

return createDir
}

export const getComponents = (COMPONENT_NAME) => {
const srcPath = path.resolve("__appset")

return COMPONENT_NAME ?
COMPONENT_NAME.split(",").map((v) => `config${capitalizeFirstLetter(v)}.js`).concat(["theme.js"]) :
fs.readdirSync(srcPath).filter((files) => !ignoreFiles.includes(files))
}
Loading

0 comments on commit b7349b6

Please sign in to comment.