@bemedev/codebase 0.2.0 → 0.3.0
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/README.md
CHANGED
package/lib/functions/init.cjs
CHANGED
|
@@ -44,7 +44,7 @@ const init = (CODEBASE_ANALYSIS, { root, json }) => {
|
|
|
44
44
|
if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};
|
|
45
45
|
if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};
|
|
46
46
|
const relativePath = (0, path.relative)(process.cwd(), folderPath);
|
|
47
|
-
tsconfig.compilerOptions.paths[require_constants.PATH_KEY] = [
|
|
47
|
+
tsconfig.compilerOptions.paths[require_constants.PATH_KEY] = [`./${relativePath}/*`];
|
|
48
48
|
(0, fs.writeFileSync)(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf8");
|
|
49
49
|
console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);
|
|
50
50
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.cjs","names":["writeFileAnalysis","getFolderPath","PATH_KEY","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"init.cjs","names":["writeFileAnalysis","getFolderPath","PATH_KEY","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { PATH_KEY, PROPERTIES } from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\n\nexport interface InitOptions {\n /**\n * Emplacement personnalisé pour le dossier .bemedev\n * Par défaut: 'src/.bemedev' si src existe, sinon '.bemedev' à la racine\n */\n root: string;\n json: string;\n}\n\nexport const createTypesStructure = (\n folderPath: string,\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {\n return key.endsWith('types') || key.endsWith('constants');\n });\n\n const PATHS: string[] = [];\n\n console.log(\n `🔧 Création de la structure de types (${entries.length} fichiers)...`,\n );\n\n for (const [, fileAnalysis] of entries) {\n const file = writeFileAnalysis(fileAnalysis, folderPath);\n if (file) PATHS.push(file);\n }\n\n console.log(`✅ Structure de types créée avec succès!`);\n return PATHS;\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n { root, json }: InitOptions,\n) => {\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Créer le dossier\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`✅ Dossier .bemedev créé dans: ${root}`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la création du dossier .bemedev:`,\n error,\n );\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Créer la structure des fichiers types\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(\n `❌ Erreur lors de la création de la structure de types:`,\n );\n return false;\n }\n\n // 2. Mettre à jour le tsconfig.json\n const tsconfigPath = join(cwd, 'tsconfig.json');\n\n if (existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n // Initialiser compilerOptions et paths si ils n'existent pas\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Ajouter le path #bemedev/*\n const relativePath = relative(process.cwd(), folderPath);\n\n {\n // Remove baseUrl since typescript 6.0 will no longer use it\n // const baseUrl = tsconfig.compilerOptions.baseUrl;\n // if (typeof baseUrl === 'string') {\n // // Si baseUrl est défini, calculer le chemin relatif par rapport à baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // Si baseUrl n'est pas défini, utiliser le chemin absolu\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[PATH_KEY] = [\n `./${relativePath}/*`,\n ];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la mise à jour du tsconfig.json:`,\n error,\n );\n return false;\n }\n } else {\n console.warn(\n `⚠️ Fichier tsconfig.json introuvable, path non ajouté`,\n );\n }\n\n // 3. Créer le fichier .bemedev.json à la racine\n\n const config = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(configFile, JSON.stringify(config, null, 2), 'utf8');\n console.log(`✅ Fichier .bemedev.json créé à la racine du projet`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la création du fichier .bemedev.json:`,\n error,\n );\n return false;\n }\n\n console.log(`🎉 Initialisation de bemedev terminée avec succès!`);\n return true;\n};\n"],"mappings":";;;;;;;AAoBA,MAAa,wBACX,YACA,sBACG;CACH,MAAM,UAAU,OAAO,QAAQ,kBAAkB,CAAC,QAAQ,CAAC,SAAS;AAClE,SAAO,IAAI,SAAS,QAAQ,IAAI,IAAI,SAAS,YAAY;GACzD;CAEF,MAAM,QAAkB,EAAE;AAE1B,SAAQ,IACN,yCAAyC,QAAQ,OAAO,eACzD;AAED,MAAK,MAAM,GAAG,iBAAiB,SAAS;EACtC,MAAM,OAAOA,gBAAAA,kBAAkB,cAAc,WAAW;AACxD,MAAI,KAAM,OAAM,KAAK,KAAK;;AAG5B,SAAQ,IAAI,0CAA0C;AACtD,QAAO;;AAGT,MAAa,QACX,mBACA,EAAE,MAAM,WACL;CACH,MAAM,MAAM,QAAQ,KAAK;CACzB,MAAM,cAAA,GAAA,KAAA,MAAkB,KAAK,KAAK;AAGlC,MAA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O;;AAGT,SAAQ,IAAI,qDAAqD;AACjE,QAAO"}
|
package/lib/functions/init.d.ts
CHANGED
package/lib/functions/init.js
CHANGED
|
@@ -42,7 +42,7 @@ const init = (CODEBASE_ANALYSIS, { root, json }) => {
|
|
|
42
42
|
if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};
|
|
43
43
|
if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};
|
|
44
44
|
const relativePath = relative(process.cwd(), folderPath);
|
|
45
|
-
tsconfig.compilerOptions.paths[PATH_KEY] = [
|
|
45
|
+
tsconfig.compilerOptions.paths[PATH_KEY] = [`./${relativePath}/*`];
|
|
46
46
|
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf8");
|
|
47
47
|
console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);
|
|
48
48
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { PATH_KEY, PROPERTIES } from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\n\nexport interface InitOptions {\n /**\n * Emplacement personnalisé pour le dossier .bemedev\n * Par défaut: 'src/.bemedev' si src existe, sinon '.bemedev' à la racine\n */\n root: string;\n json: string;\n}\n\nexport const createTypesStructure = (\n folderPath: string,\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {\n return key.endsWith('types') || key.endsWith('constants');\n });\n\n const PATHS: string[] = [];\n\n console.log(\n `🔧 Création de la structure de types (${entries.length} fichiers)...`,\n );\n\n for (const [, fileAnalysis] of entries) {\n const file = writeFileAnalysis(fileAnalysis, folderPath);\n if (file) PATHS.push(file);\n }\n\n console.log(`✅ Structure de types créée avec succès!`);\n return PATHS;\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n { root, json }: InitOptions,\n) => {\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Créer le dossier\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`✅ Dossier .bemedev créé dans: ${root}`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la création du dossier .bemedev:`,\n error,\n );\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Créer la structure des fichiers types\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(\n `❌ Erreur lors de la création de la structure de types:`,\n );\n return false;\n }\n\n // 2. Mettre à jour le tsconfig.json\n const tsconfigPath = join(cwd, 'tsconfig.json');\n\n if (existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n // Initialiser compilerOptions et paths si ils n'existent pas\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Ajouter le path #bemedev/*\n const relativePath = relative(process.cwd(), folderPath);\n\n {\n // Remove baseUrl since typescript 6.0 will no longer use it\n // const baseUrl = tsconfig.compilerOptions.baseUrl;\n // if (typeof baseUrl === 'string') {\n // // Si baseUrl est défini, calculer le chemin relatif par rapport à baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // Si baseUrl n'est pas défini, utiliser le chemin absolu\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[PATH_KEY] = [\n `./${relativePath}/*`,\n ];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la mise à jour du tsconfig.json:`,\n error,\n );\n return false;\n }\n } else {\n console.warn(\n `⚠️ Fichier tsconfig.json introuvable, path non ajouté`,\n );\n }\n\n // 3. Créer le fichier .bemedev.json à la racine\n\n const config = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(configFile, JSON.stringify(config, null, 2), 'utf8');\n console.log(`✅ Fichier .bemedev.json créé à la racine du projet`);\n } catch (error) {\n console.error(\n `❌ Erreur lors de la création du fichier .bemedev.json:`,\n error,\n );\n return false;\n }\n\n console.log(`🎉 Initialisation de bemedev terminée avec succès!`);\n return true;\n};\n"],"mappings":";;;;;AAoBA,MAAa,wBACX,YACA,sBACG;CACH,MAAM,UAAU,OAAO,QAAQ,kBAAkB,CAAC,QAAQ,CAAC,SAAS;AAClE,SAAO,IAAI,SAAS,QAAQ,IAAI,IAAI,SAAS,YAAY;GACzD;CAEF,MAAM,QAAkB,EAAE;AAE1B,SAAQ,IACN,yCAAyC,QAAQ,OAAO,eACzD;AAED,MAAK,MAAM,GAAG,iBAAiB,SAAS;EACtC,MAAM,OAAO,kBAAkB,cAAc,WAAW;AACxD,MAAI,KAAM,OAAM,KAAK,KAAK;;AAG5B,SAAQ,IAAI,0CAA0C;AACtD,QAAO;;AAGT,MAAa,QACX,mBACA,EAAE,MAAM,WACL;CACH,MAAM,MAAM,QAAQ,KAAK;CACzB,MAAM,aAAa,KAAK,KAAK,KAAK;AAGlC,KAFqB,WAAW,WAAW,CAEzB,QAAO;CACzB,MAAM,aAAa,cAAc,KAAK;AAGtC,KAAI;AACF,YAAU,YAAY,EAAE,WAAW,MAAM,CAAC;AAC1C,UAAQ,IAAI,iCAAiC,OAAO;UAC7C,OAAO;AACd,UAAQ,MACN,qDACA,MACD;AACD,SAAO;;CAIT,IAAI,QAAkB,EAAE;AAExB,KAAI;AACF,UAAQ,qBAAqB,YAAY,kBAAkB;SACrD;AACN,UAAQ,MACN,yDACD;AACD,SAAO;;CAIT,MAAM,eAAe,KAAK,KAAK,gBAAgB;AAE/C,KAAI,WAAW,aAAa,CAC1B,KAAI;EACF,MAAM,kBAAkB,aAAa,cAAc,OAAO;EAC1D,MAAM,WAAW,KAAK,MAAM,gBAAgB;AAG5C,MAAI,CAAC,SAAS,gBACZ,UAAS,kBAAkB,EAAE;AAG/B,MAAI,CAAC,SAAS,gBAAgB,MAC5B,UAAS,gBAAgB,QAAQ,EAAE;EAIrC,MAAM,eAAe,SAAS,QAAQ,KAAK,EAAE,WAAW;AAcxD,WAAS,gBAAgB,MAAM,YAAY,CACzC,KAAK,aAAa,IACnB;AAED,gBACE,cACA,KAAK,UAAU,UAAU,MAAM,EAAE,EACjC,OACD;AACD,UAAQ,IAAI,4CAA4C;UACjD,OAAO;AACd,UAAQ,MACN,qDACA,MACD;AACD,SAAO;;KAGT,SAAQ,KACN,wDACD;CAKH,MAAM,SAAS;EACb,SAAS;GACR,WAAW,OAAO;GAClB,WAAW,QAAQ;EACrB;AAED,KAAI;AACF,gBAAc,YAAY,KAAK,UAAU,QAAQ,MAAM,EAAE,EAAE,OAAO;AAClE,UAAQ,IAAI,qDAAqD;UAC1D,OAAO;AACd,UAAQ,MACN,0DACA,MACD;AACD,SAAO;;AAGT,SAAQ,IAAI,qDAAqD;AACjE,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/codebase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The CLI for to generate codebase, and import partially a library. From @bemedev.",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "bri_lvi@icloud.com",
|
|
@@ -105,11 +105,11 @@
|
|
|
105
105
|
],
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@bemedev/decompose": "^2.2.0",
|
|
108
|
-
"@bemedev/dev-utils": "^0.
|
|
108
|
+
"@bemedev/dev-utils": "^0.5.2",
|
|
109
109
|
"@bemedev/fsf": "^1.0.1",
|
|
110
110
|
"@size-limit/file": "^12.0.1",
|
|
111
111
|
"@types/edit-json-file": "^1.7.4",
|
|
112
|
-
"@types/node": "^25.5.
|
|
112
|
+
"@types/node": "^25.5.2",
|
|
113
113
|
"@vitest/coverage-v8": "3.2.4",
|
|
114
114
|
"@vitest/ui": "3.2.4",
|
|
115
115
|
"glob": "^13.0.6",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"oxlint": "^1.58.0",
|
|
121
121
|
"prettier": "^3.8.1",
|
|
122
122
|
"pretty-quick": "^4.2.2",
|
|
123
|
-
"rolldown": "1.0.0-rc.
|
|
123
|
+
"rolldown": "1.0.0-rc.13",
|
|
124
124
|
"size-limit": "^12.0.1",
|
|
125
125
|
"this": "file:",
|
|
126
126
|
"tslib": "^2.8.1",
|