@arc-js/initiator 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +21 -5
- package/index.min.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -194687,7 +194687,8 @@ class ConfigGenerator {
|
|
|
194687
194687
|
srcDir: config.srcDir || pajoExports.Pajo.join(dirname, 'src') || '',
|
|
194688
194688
|
outputFile: config.outputFile || pajoExports.Pajo.join(dirname, 'src\\auto-config.ts') || '',
|
|
194689
194689
|
modulesDir: config.modulesDir || pajoExports.Pajo.join(dirname, 'src\\modules') || '',
|
|
194690
|
-
rootConfigPath: config.rootConfigPath || pajoExports.Pajo.join(dirname, 'config.json') || ''
|
|
194690
|
+
rootConfigPath: config.rootConfigPath || pajoExports.Pajo.join(dirname, 'src\\config.json') || '',
|
|
194691
|
+
projectRoot: config.projectRoot || dirname || ''
|
|
194691
194692
|
};
|
|
194692
194693
|
console.log(`--> ConfigGenerator config:: `, this.config);
|
|
194693
194694
|
}
|
|
@@ -194733,21 +194734,36 @@ class ConfigGenerator {
|
|
|
194733
194734
|
fs.writeFileSync(this.config.outputFile, content, 'utf-8');
|
|
194734
194735
|
});
|
|
194735
194736
|
}
|
|
194737
|
+
getRelativeImportPath(targetPath) {
|
|
194738
|
+
const outputDir = path.dirname(this.config.outputFile);
|
|
194739
|
+
const relative = path.relative(outputDir, targetPath);
|
|
194740
|
+
let importPath = relative.replace(/\\/g, '/');
|
|
194741
|
+
if (!importPath.startsWith('.') && !importPath.startsWith('/')) {
|
|
194742
|
+
importPath = './' + importPath;
|
|
194743
|
+
}
|
|
194744
|
+
return importPath;
|
|
194745
|
+
}
|
|
194736
194746
|
generateFileContent() {
|
|
194737
194747
|
const { rootConfigPath, modulesDir } = this.config;
|
|
194738
194748
|
const sortedModules = Array.from(this.modules).sort();
|
|
194739
194749
|
const rootConfigExists = fs.existsSync(rootConfigPath);
|
|
194740
|
-
|
|
194741
|
-
|
|
194750
|
+
console.log(`📄 Root config exists: ${rootConfigExists} at ${rootConfigPath}`);
|
|
194751
|
+
const baseImportPath = rootConfigExists
|
|
194752
|
+
? this.getRelativeImportPath(rootConfigPath)
|
|
194753
|
+
: null;
|
|
194754
|
+
const baseConfig = rootConfigExists && baseImportPath
|
|
194755
|
+
? ` 'app': (() => import('${baseImportPath}').then(module => module.default || module))`
|
|
194742
194756
|
: ` 'app': (() => Promise.resolve({}))`;
|
|
194743
194757
|
const modulesImports = sortedModules.map(moduleName => {
|
|
194744
194758
|
const configPath = path.join(modulesDir, moduleName, 'config.json');
|
|
194745
194759
|
const configExists = fs.existsSync(configPath);
|
|
194746
194760
|
if (configExists) {
|
|
194747
|
-
const
|
|
194748
|
-
|
|
194761
|
+
const importPath = this.getRelativeImportPath(configPath);
|
|
194762
|
+
console.log(`📄 Module ${moduleName} config: ${configPath} -> ${importPath}`);
|
|
194763
|
+
return ` '${moduleName}': (() => import('${importPath}').then(module => module.default || module))`;
|
|
194749
194764
|
}
|
|
194750
194765
|
else {
|
|
194766
|
+
console.log(`⚠️ Module ${moduleName} config not found: ${configPath}`);
|
|
194751
194767
|
return ` '${moduleName}': (() => Promise.resolve({}))`;
|
|
194752
194768
|
}
|
|
194753
194769
|
}).join(',\n');
|
package/index.min.js
CHANGED
|
@@ -376,12 +376,12 @@ ${e}
|
|
|
376
376
|
}
|
|
377
377
|
};
|
|
378
378
|
|
|
379
|
-
export default translations;`}generateTypeDefinitions(){if(0===this.keys.length)return"string";let r={};return this.keys.forEach(e=>{var t=e.module||"core";r[t]||(r[t]=[]),r[t].push(e.key)}),Object.entries(r).map(([e,t])=>{t=t.filter((e,t,r)=>r.indexOf(e)===t).map(e=>`"${e}"`).join(" | ");return"core"===e?t:e+":"+t}).join(" | ")}}function TranslationInitiator(){return __awaiter(this,arguments,void 0,function*(e=__dirname$2){new TranslationGenerator({},e).generate().then(()=>{}).catch(e=>{})})}let __filename$1=url.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&"SCRIPT"===_documentCurrentScript.tagName.toUpperCase()&&_documentCurrentScript.src||new URL("index.js",document.baseURI).href),__dirname$1=path.dirname(__filename$1);class ConfigGenerator{constructor(e={},t=__dirname$1){this.modules=new Set,this.config={srcDir:e.srcDir||pajoExports.Pajo.join(t,"src")||"",outputFile:e.outputFile||pajoExports.Pajo.join(t,"src\\auto-config.ts")||"",modulesDir:e.modulesDir||pajoExports.Pajo.join(t,"src\\modules")||"",rootConfigPath:e.rootConfigPath||pajoExports.Pajo.join(t,"config.json")||""}}generate(){return __awaiter(this,void 0,void 0,function*(){yield this.discoverModules(),yield this.generateAutoConfigFile()})}discoverModules(){return __awaiter(this,void 0,void 0,function*(){try{var e;if(fs.existsSync(this.config.modulesDir))for(e of fs.readdirSync(this.config.modulesDir,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)){var t=path.join(this.config.modulesDir,e,"config.json");fs.existsSync(t)&&this.modules.add(e)}}catch(e){}})}generateAutoConfigFile(){return __awaiter(this,void 0,void 0,function*(){var e=path.dirname(this.config.outputFile),e=(fs.existsSync(e)||fs.mkdirSync(e,{recursive:!0}),this.generateFileContent());fs.writeFileSync(this.config.outputFile,e,"utf-8")})}generateFileContent(){let{rootConfigPath:e,modulesDir:r}=this.config;var t=Array.from(this.modules).sort(),n=fs.existsSync(e)?
|
|
379
|
+
export default translations;`}generateTypeDefinitions(){if(0===this.keys.length)return"string";let r={};return this.keys.forEach(e=>{var t=e.module||"core";r[t]||(r[t]=[]),r[t].push(e.key)}),Object.entries(r).map(([e,t])=>{t=t.filter((e,t,r)=>r.indexOf(e)===t).map(e=>`"${e}"`).join(" | ");return"core"===e?t:e+":"+t}).join(" | ")}}function TranslationInitiator(){return __awaiter(this,arguments,void 0,function*(e=__dirname$2){new TranslationGenerator({},e).generate().then(()=>{}).catch(e=>{})})}let __filename$1=url.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&"SCRIPT"===_documentCurrentScript.tagName.toUpperCase()&&_documentCurrentScript.src||new URL("index.js",document.baseURI).href),__dirname$1=path.dirname(__filename$1);class ConfigGenerator{constructor(e={},t=__dirname$1){this.modules=new Set,this.config={srcDir:e.srcDir||pajoExports.Pajo.join(t,"src")||"",outputFile:e.outputFile||pajoExports.Pajo.join(t,"src\\auto-config.ts")||"",modulesDir:e.modulesDir||pajoExports.Pajo.join(t,"src\\modules")||"",rootConfigPath:e.rootConfigPath||pajoExports.Pajo.join(t,"src\\config.json")||"",projectRoot:e.projectRoot||t||""}}generate(){return __awaiter(this,void 0,void 0,function*(){yield this.discoverModules(),yield this.generateAutoConfigFile()})}discoverModules(){return __awaiter(this,void 0,void 0,function*(){try{var e;if(fs.existsSync(this.config.modulesDir))for(e of fs.readdirSync(this.config.modulesDir,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)){var t=path.join(this.config.modulesDir,e,"config.json");fs.existsSync(t)&&this.modules.add(e)}}catch(e){}})}generateAutoConfigFile(){return __awaiter(this,void 0,void 0,function*(){var e=path.dirname(this.config.outputFile),e=(fs.existsSync(e)||fs.mkdirSync(e,{recursive:!0}),this.generateFileContent());fs.writeFileSync(this.config.outputFile,e,"utf-8")})}getRelativeImportPath(e){var t=path.dirname(this.config.outputFile);let r=path.relative(t,e).replace(/\\/g,"/");return r=r.startsWith(".")||r.startsWith("/")?r:"./"+r}generateFileContent(){let{rootConfigPath:e,modulesDir:r}=this.config;var t=Array.from(this.modules).sort(),n=fs.existsSync(e),i=n?this.getRelativeImportPath(e):null,n=n&&i?` 'app': (() => import('${i}').then(module => module.default || module))`:" 'app': (() => Promise.resolve({}))",i=t.map(e=>{var t=path.join(r,e,"config.json");return fs.existsSync(t)?` '${e}': (() => import('${this.getRelativeImportPath(t)}').then(module => module.default || module))`:` '${e}': (() => Promise.resolve({}))`}).join(",\n");return`export const configs = {
|
|
380
380
|
'base': {
|
|
381
381
|
${n}
|
|
382
382
|
},
|
|
383
383
|
'modules': {
|
|
384
|
-
${0<
|
|
384
|
+
${0<i.length?i:" // No modules with config.json found"}
|
|
385
385
|
}
|
|
386
386
|
};
|
|
387
387
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.6",
|
|
7
7
|
"description": "INITIATOR est un système de gestion de configuration modulaire pour les applications React avec TypeScript/JavaScript. Il fournit une gestion centralisée des configurations, un chargement dynamique des modules, et une intégration transparente avec les variables d'environnement.",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"keywords": [],
|