@bemedev/codebase 0.3.0 → 1.1.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.
Files changed (100) hide show
  1. package/README.md +26 -13
  2. package/lib/analyse.cjs +10 -8
  3. package/lib/analyse.cjs.map +1 -1
  4. package/lib/analyse.d.ts +4 -3
  5. package/lib/analyse.d.ts.map +1 -0
  6. package/lib/analyse.js +9 -7
  7. package/lib/analyse.js.map +1 -1
  8. package/lib/analyse.utils.cjs +6 -6
  9. package/lib/analyse.utils.cjs.map +1 -1
  10. package/lib/analyse.utils.d.ts +8 -7
  11. package/lib/analyse.utils.d.ts.map +1 -0
  12. package/lib/analyse.utils.js +6 -6
  13. package/lib/analyse.utils.js.map +1 -1
  14. package/lib/cli/cli.cjs +2 -2
  15. package/lib/cli/cli.cjs.map +1 -1
  16. package/lib/cli/cli.d.ts +1 -0
  17. package/lib/cli/cli.d.ts.map +1 -0
  18. package/lib/cli/cli.js +2 -1
  19. package/lib/cli/cli.js.map +1 -1
  20. package/lib/cli/constants.d.ts +1 -0
  21. package/lib/cli/constants.d.ts.map +1 -0
  22. package/lib/cli/index.cjs +0 -1
  23. package/lib/cli/index.cjs.map +1 -1
  24. package/lib/cli/index.d.ts +1 -0
  25. package/lib/cli/index.d.ts.map +1 -0
  26. package/lib/cli/index.js +0 -0
  27. package/lib/cli/index.js.map +1 -1
  28. package/lib/config.cjs +12 -0
  29. package/lib/config.cjs.map +1 -0
  30. package/lib/config.d.ts +7 -0
  31. package/lib/config.d.ts.map +1 -0
  32. package/lib/config.js +11 -0
  33. package/lib/config.js.map +1 -0
  34. package/lib/constants.cjs +6 -5
  35. package/lib/constants.cjs.map +1 -1
  36. package/lib/constants.d.ts +4 -2
  37. package/lib/constants.d.ts.map +1 -0
  38. package/lib/constants.js +4 -3
  39. package/lib/constants.js.map +1 -1
  40. package/lib/exports.cjs +0 -1
  41. package/lib/exports.cjs.map +1 -1
  42. package/lib/exports.d.ts +1 -0
  43. package/lib/exports.d.ts.map +1 -0
  44. package/lib/exports.js.map +1 -1
  45. package/lib/functions/add.cjs +6 -5
  46. package/lib/functions/add.cjs.map +1 -1
  47. package/lib/functions/add.d.ts +2 -1
  48. package/lib/functions/add.d.ts.map +1 -0
  49. package/lib/functions/add.js +6 -5
  50. package/lib/functions/add.js.map +1 -1
  51. package/lib/functions/generate.cjs +5 -6
  52. package/lib/functions/generate.cjs.map +1 -1
  53. package/lib/functions/generate.d.ts +3 -2
  54. package/lib/functions/generate.d.ts.map +1 -0
  55. package/lib/functions/generate.js +5 -5
  56. package/lib/functions/generate.js.map +1 -1
  57. package/lib/functions/index.d.ts +1 -0
  58. package/lib/functions/index.d.ts.map +1 -0
  59. package/lib/functions/init.cjs +29 -16
  60. package/lib/functions/init.cjs.map +1 -1
  61. package/lib/functions/init.d.ts +6 -3
  62. package/lib/functions/init.d.ts.map +1 -0
  63. package/lib/functions/init.js +30 -16
  64. package/lib/functions/init.js.map +1 -1
  65. package/lib/functions/remove.cjs +11 -10
  66. package/lib/functions/remove.cjs.map +1 -1
  67. package/lib/functions/remove.d.ts +2 -1
  68. package/lib/functions/remove.d.ts.map +1 -0
  69. package/lib/functions/remove.js +11 -10
  70. package/lib/functions/remove.js.map +1 -1
  71. package/lib/helpers.cjs +1 -2
  72. package/lib/helpers.cjs.map +1 -1
  73. package/lib/helpers.d.ts +4 -3
  74. package/lib/helpers.d.ts.map +1 -0
  75. package/lib/helpers.js +1 -1
  76. package/lib/helpers.js.map +1 -1
  77. package/lib/imports.cjs +2 -3
  78. package/lib/imports.cjs.map +1 -1
  79. package/lib/imports.d.ts +4 -3
  80. package/lib/imports.d.ts.map +1 -0
  81. package/lib/imports.js +2 -2
  82. package/lib/imports.js.map +1 -1
  83. package/lib/index.cjs +2 -0
  84. package/lib/index.d.ts +6 -4
  85. package/lib/index.d.ts.map +1 -0
  86. package/lib/index.js +2 -1
  87. package/lib/schemas.cjs +1 -1
  88. package/lib/schemas.cjs.map +1 -1
  89. package/lib/schemas.d.ts +2 -1
  90. package/lib/schemas.d.ts.map +1 -0
  91. package/lib/schemas.js.map +1 -1
  92. package/lib/types.d.ts +1 -6
  93. package/lib/types.d.ts.map +1 -0
  94. package/lib/utils.cjs +2 -2
  95. package/lib/utils.cjs.map +1 -1
  96. package/lib/utils.d.ts +2 -1
  97. package/lib/utils.d.ts.map +1 -0
  98. package/lib/utils.js +2 -2
  99. package/lib/utils.js.map +1 -1
  100. package/package.json +43 -62
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../_virtual/_rolldown/runtime.cjs");
3
2
  const require_constants = require("../constants.cjs");
4
3
  const require_helpers = require("../helpers.cjs");
4
+ const require_config = require("../config.cjs");
5
5
  let path = require("path");
6
6
  let fs = require("fs");
7
7
  //#region src/functions/init.ts
@@ -10,31 +10,44 @@ const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
10
10
  return key.endsWith("types") || key.endsWith("constants");
11
11
  });
12
12
  const PATHS = [];
13
- console.log(`🔧 Création de la structure de types (${entries.length} fichiers)...`);
13
+ console.log(`🔧 Creating types structure (${entries.length} files)...`);
14
14
  for (const [, fileAnalysis] of entries) {
15
15
  const file = require_helpers.writeFileAnalysis(fileAnalysis, folderPath);
16
16
  if (file) PATHS.push(file);
17
17
  }
18
- console.log(`✅ Structure de types créée avec succès!`);
18
+ console.log(`✅ Types structure successfully created!`);
19
19
  return PATHS;
20
20
  };
21
- const init = (CODEBASE_ANALYSIS, { root, json }) => {
21
+ const initConfig = ({ root, json, path: path$1 = require_constants.DEFAULT_PATH_KEY, bin = require_constants.DEFAULT_CLI_NAME }) => {
22
+ require_config.config.bin = bin;
23
+ require_config.config.json = json;
24
+ require_config.config.tsConfigPath = path$1;
25
+ require_config.config.root = root;
26
+ return {
27
+ root,
28
+ json,
29
+ path: path$1,
30
+ bin
31
+ };
32
+ };
33
+ const init = (CODEBASE_ANALYSIS, options) => {
34
+ const { root, json, path: path$2, bin } = initConfig(options);
22
35
  const cwd = process.cwd();
23
36
  const configFile = (0, path.join)(cwd, json);
24
37
  if ((0, fs.existsSync)(configFile)) return true;
25
38
  const folderPath = require_helpers.getFolderPath(root);
26
39
  try {
27
40
  (0, fs.mkdirSync)(folderPath, { recursive: true });
28
- console.log(`✅ Dossier .bemedev créé dans: ${root}`);
41
+ console.log(`✅ Folder ${bin} created in: ${root}`);
29
42
  } catch (error) {
30
- console.error(`❌ Erreur lors de la création du dossier .bemedev:`, error);
43
+ console.error(`❌ Error creating the folder ${bin}:`, error);
31
44
  return false;
32
45
  }
33
46
  let files = [];
34
47
  try {
35
48
  files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);
36
49
  } catch {
37
- console.error(`❌ Erreur lors de la création de la structure de types:`);
50
+ console.error(`❌ Error creating the types structure:`);
38
51
  return false;
39
52
  }
40
53
  const tsconfigPath = (0, path.join)(cwd, "tsconfig.json");
@@ -44,27 +57,27 @@ const init = (CODEBASE_ANALYSIS, { root, json }) => {
44
57
  if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};
45
58
  if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};
46
59
  const relativePath = (0, path.relative)(process.cwd(), folderPath);
47
- tsconfig.compilerOptions.paths[require_constants.PATH_KEY] = [`./${relativePath}/*`];
60
+ tsconfig.compilerOptions.paths[path$2] = [`./${relativePath}/*`];
48
61
  (0, fs.writeFileSync)(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf8");
49
- console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);
62
+ console.log(`✅ Path ${path$2} added to tsconfig.json`);
50
63
  } catch (error) {
51
- console.error(`❌ Erreur lors de la mise à jour du tsconfig.json:`, error);
64
+ console.error(`❌ Error updating tsconfig.json:`, error);
52
65
  return false;
53
66
  }
54
- else console.warn(`⚠️ Fichier tsconfig.json introuvable, path non ajouté`);
55
- const config = {
67
+ else console.warn(`⚠️ File tsconfig.json not found, path not added`);
68
+ const jsonConfig = {
56
69
  version: "1.0.0",
57
70
  [require_constants.PROPERTIES.PATH]: root,
58
71
  [require_constants.PROPERTIES.FILES]: files
59
72
  };
60
73
  try {
61
- (0, fs.writeFileSync)(configFile, JSON.stringify(config, null, 2), "utf8");
62
- console.log(`✅ Fichier .bemedev.json créé à la racine du projet`);
74
+ (0, fs.writeFileSync)(configFile, JSON.stringify(jsonConfig, null, 2), "utf8");
75
+ console.log(`✅ File ${json} created at the root of the project`);
63
76
  } catch (error) {
64
- console.error(`❌ Erreur lors de la création du fichier .bemedev.json:`, error);
77
+ console.error(`❌ Error creating the file ${json}:`, error);
65
78
  return false;
66
79
  }
67
- console.log(`🎉 Initialisation de bemedev terminée avec succès!`);
80
+ console.log(`🎉 Bemedev initialization completed successfully!`);
68
81
  return true;
69
82
  };
70
83
  //#endregion
@@ -1 +1 @@
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,MAAA,GAAA,GAAA,YAFgC,WAAW,CAEzB,QAAO;CACzB,MAAM,aAAaC,gBAAAA,cAAc,KAAK;AAGtC,KAAI;AACF,GAAA,GAAA,GAAA,WAAU,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,gBAAA,GAAA,KAAA,MAAoB,KAAK,gBAAgB;AAE/C,MAAA,GAAA,GAAA,YAAe,aAAa,CAC1B,KAAI;EACF,MAAM,mBAAA,GAAA,GAAA,cAA+B,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,gBAAA,GAAA,KAAA,UAAwB,QAAQ,KAAK,EAAE,WAAW;AAcxD,WAAS,gBAAgB,MAAMC,kBAAAA,YAAY,CACzC,KAAK,aAAa,IACnB;AAED,GAAA,GAAA,GAAA,eACE,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;GACRC,kBAAAA,WAAW,OAAO;GAClBA,kBAAAA,WAAW,QAAQ;EACrB;AAED,KAAI;AACF,GAAA,GAAA,GAAA,eAAc,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"}
1
+ {"version":3,"file":"init.cjs","names":["writeFileAnalysis","DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","path","getFolderPath","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 {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\nimport { config } from '../config';\n\nexport interface InitOptions {\n /**\n * Custom location for the .bemedev folder\n * Default: 'src/.bemedev' if src exists, otherwise '.bemedev' at the root\n */\n root: string;\n json: string;\n path?: string;\n bin?: 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 `🔧 Creating types structure (${entries.length} files)...`,\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(`✅ Types structure successfully created!`);\n return PATHS;\n};\n\nconst initConfig = ({\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n}: InitOptions) => {\n config.bin = bin;\n config.json = json;\n config.tsConfigPath = path;\n config.root = root;\n return { root, json, path, bin };\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n options: InitOptions,\n) => {\n const { root, json, path, bin } = initConfig(options);\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Create the folder\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`✅ Folder ${bin} created in: ${root}`);\n } catch (error) {\n console.error(`❌ Error creating the folder ${bin}:`, error);\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Create the types files structure\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`❌ Error creating the types structure:`);\n return false;\n }\n\n // 2. Update 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 // Initialize compilerOptions and paths if they do not exist\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Add the 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 // // If baseUrl is defined, calculate the relative path with respect to baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // If baseUrl is not defined, use the absolute path\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[path] = [`./${relativePath}/*`];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`✅ Path ${path} added to tsconfig.json`);\n } catch (error) {\n console.error(`❌ Error updating tsconfig.json:`, error);\n return false;\n }\n } else {\n console.warn(`⚠️ File tsconfig.json not found, path not added`);\n }\n\n // 3. Create the .bemedev.json file at the root\n\n const jsonConfig = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(\n configFile,\n JSON.stringify(jsonConfig, null, 2),\n 'utf8',\n );\n console.log(`✅ File ${json} created at the root of the project`);\n } catch (error) {\n console.error(`❌ Error creating the file ${json}:`, error);\n return false;\n }\n\n console.log(`🎉 Bemedev initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;;AA2BA,MAAa,wBACX,YACA,sBACG;CACH,MAAM,UAAU,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,SAAS;EAClE,OAAO,IAAI,SAAS,OAAO,KAAK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M,mBAAA,GAAA,GAAA,aAAA,CAA+B,cAAc,MAAM;EACzD,MAAM,WAAW,KAAK,MAAM,eAAe;EAG3C,IAAI,CAAC,SAAS,iBACZ,SAAS,kBAAkB,CAAC;EAG9B,IAAI,CAAC,SAAS,gBAAgB,OAC5B,SAAS,gBAAgB,QAAQ,CAAC;EAIpC,MAAM,gBAAA,GAAA,KAAA,SAAA,CAAwB,QAAQ,IAAI,GAAG,UAAU;EAcvD,SAAS,gBAAgB,MAAMD,UAAQ,CAAC,KAAK,aAAa,GAAG;EAE7D,CAAA,GAAA,GAAA,cAAA,CACE,cACA,KAAK,UAAU,UAAU,MAAM,CAAC,GAChC,MACF;EACA,QAAQ,IAAI,UAAUA,OAAK,wBAAwB;CACrD,SAAS,OAAO;EACd,QAAQ,MAAM,mCAAmC,KAAK;EACtD,OAAO;CACT;MAEA,QAAQ,KAAK,iDAAiD;CAKhE,MAAM,aAAa;EACjB,SAAS;GACRE,kBAAAA,WAAW,OAAO;GAClBA,kBAAAA,WAAW,QAAQ;CACtB;CAEA,IAAI;EACF,CAAA,GAAA,GAAA,cAAA,CACE,YACA,KAAK,UAAU,YAAY,MAAM,CAAC,GAClC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,oCAAoC;CACjE,SAAS,OAAO;EACd,QAAQ,MAAM,6BAA6B,KAAK,IAAI,KAAK;EACzD,OAAO;CACT;CAEA,QAAQ,IAAI,mDAAmD;CAC/D,OAAO;AACT"}
@@ -1,11 +1,14 @@
1
1
  import { CodebaseAnalysis } from '../schemas';
2
2
  export interface InitOptions {
3
3
  /**
4
- * Emplacement personnalisé pour le dossier .bemedev
5
- * Par défaut: 'src/.bemedev' si src existe, sinon '.bemedev' à la racine
4
+ * Custom location for the .bemedev folder
5
+ * Default: 'src/.bemedev' if src exists, otherwise '.bemedev' at the root
6
6
  */
7
7
  root: string;
8
8
  json: string;
9
+ path?: string;
10
+ bin?: string;
9
11
  }
10
12
  export declare const createTypesStructure: (folderPath: string, CODEBASE_ANALYSIS: CodebaseAnalysis) => string[];
11
- export declare const init: (CODEBASE_ANALYSIS: CodebaseAnalysis, { root, json }: InitOptions) => boolean;
13
+ export declare const init: (CODEBASE_ANALYSIS: CodebaseAnalysis, options: InitOptions) => boolean;
14
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/functions/init.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,oBAAoB,GAC/B,YAAY,MAAM,EAClB,mBAAmB,gBAAgB,aAmBpC,CAAC;AAeF,eAAO,MAAM,IAAI,GACf,mBAAmB,gBAAgB,EACnC,SAAS,WAAW,YAkGrB,CAAC"}
@@ -1,5 +1,6 @@
1
- import { PATH_KEY, PROPERTIES } from "../constants.js";
1
+ import { DEFAULT_CLI_NAME, DEFAULT_PATH_KEY, PROPERTIES } from "../constants.js";
2
2
  import { getFolderPath, writeFileAnalysis } from "../helpers.js";
3
+ import { config } from "../config.js";
3
4
  import { join, relative } from "path";
4
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
5
6
  //#region src/functions/init.ts
@@ -8,31 +9,44 @@ const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
8
9
  return key.endsWith("types") || key.endsWith("constants");
9
10
  });
10
11
  const PATHS = [];
11
- console.log(`🔧 Création de la structure de types (${entries.length} fichiers)...`);
12
+ console.log(`🔧 Creating types structure (${entries.length} files)...`);
12
13
  for (const [, fileAnalysis] of entries) {
13
14
  const file = writeFileAnalysis(fileAnalysis, folderPath);
14
15
  if (file) PATHS.push(file);
15
16
  }
16
- console.log(`✅ Structure de types créée avec succès!`);
17
+ console.log(`✅ Types structure successfully created!`);
17
18
  return PATHS;
18
19
  };
19
- const init = (CODEBASE_ANALYSIS, { root, json }) => {
20
+ const initConfig = ({ root, json, path = DEFAULT_PATH_KEY, bin = DEFAULT_CLI_NAME }) => {
21
+ config.bin = bin;
22
+ config.json = json;
23
+ config.tsConfigPath = path;
24
+ config.root = root;
25
+ return {
26
+ root,
27
+ json,
28
+ path,
29
+ bin
30
+ };
31
+ };
32
+ const init = (CODEBASE_ANALYSIS, options) => {
33
+ const { root, json, path, bin } = initConfig(options);
20
34
  const cwd = process.cwd();
21
35
  const configFile = join(cwd, json);
22
36
  if (existsSync(configFile)) return true;
23
37
  const folderPath = getFolderPath(root);
24
38
  try {
25
39
  mkdirSync(folderPath, { recursive: true });
26
- console.log(`✅ Dossier .bemedev créé dans: ${root}`);
40
+ console.log(`✅ Folder ${bin} created in: ${root}`);
27
41
  } catch (error) {
28
- console.error(`❌ Erreur lors de la création du dossier .bemedev:`, error);
42
+ console.error(`❌ Error creating the folder ${bin}:`, error);
29
43
  return false;
30
44
  }
31
45
  let files = [];
32
46
  try {
33
47
  files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);
34
48
  } catch {
35
- console.error(`❌ Erreur lors de la création de la structure de types:`);
49
+ console.error(`❌ Error creating the types structure:`);
36
50
  return false;
37
51
  }
38
52
  const tsconfigPath = join(cwd, "tsconfig.json");
@@ -42,27 +56,27 @@ const init = (CODEBASE_ANALYSIS, { root, json }) => {
42
56
  if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};
43
57
  if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};
44
58
  const relativePath = relative(process.cwd(), folderPath);
45
- tsconfig.compilerOptions.paths[PATH_KEY] = [`./${relativePath}/*`];
59
+ tsconfig.compilerOptions.paths[path] = [`./${relativePath}/*`];
46
60
  writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf8");
47
- console.log(`✅ Path #bemedev/* ajouté au tsconfig.json`);
61
+ console.log(`✅ Path ${path} added to tsconfig.json`);
48
62
  } catch (error) {
49
- console.error(`❌ Erreur lors de la mise à jour du tsconfig.json:`, error);
63
+ console.error(`❌ Error updating tsconfig.json:`, error);
50
64
  return false;
51
65
  }
52
- else console.warn(`⚠️ Fichier tsconfig.json introuvable, path non ajouté`);
53
- const config = {
66
+ else console.warn(`⚠️ File tsconfig.json not found, path not added`);
67
+ const jsonConfig = {
54
68
  version: "1.0.0",
55
69
  [PROPERTIES.PATH]: root,
56
70
  [PROPERTIES.FILES]: files
57
71
  };
58
72
  try {
59
- writeFileSync(configFile, JSON.stringify(config, null, 2), "utf8");
60
- console.log(`✅ Fichier .bemedev.json créé à la racine du projet`);
73
+ writeFileSync(configFile, JSON.stringify(jsonConfig, null, 2), "utf8");
74
+ console.log(`✅ File ${json} created at the root of the project`);
61
75
  } catch (error) {
62
- console.error(`❌ Erreur lors de la création du fichier .bemedev.json:`, error);
76
+ console.error(`❌ Error creating the file ${json}:`, error);
63
77
  return false;
64
78
  }
65
- console.log(`🎉 Initialisation de bemedev terminée avec succès!`);
79
+ console.log(`🎉 Bemedev initialization completed successfully!`);
66
80
  return true;
67
81
  };
68
82
  //#endregion
@@ -1 +1 @@
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"}
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 {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\nimport { config } from '../config';\n\nexport interface InitOptions {\n /**\n * Custom location for the .bemedev folder\n * Default: 'src/.bemedev' if src exists, otherwise '.bemedev' at the root\n */\n root: string;\n json: string;\n path?: string;\n bin?: 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 `🔧 Creating types structure (${entries.length} files)...`,\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(`✅ Types structure successfully created!`);\n return PATHS;\n};\n\nconst initConfig = ({\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n}: InitOptions) => {\n config.bin = bin;\n config.json = json;\n config.tsConfigPath = path;\n config.root = root;\n return { root, json, path, bin };\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n options: InitOptions,\n) => {\n const { root, json, path, bin } = initConfig(options);\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Create the folder\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`✅ Folder ${bin} created in: ${root}`);\n } catch (error) {\n console.error(`❌ Error creating the folder ${bin}:`, error);\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Create the types files structure\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`❌ Error creating the types structure:`);\n return false;\n }\n\n // 2. Update 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 // Initialize compilerOptions and paths if they do not exist\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Add the 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 // // If baseUrl is defined, calculate the relative path with respect to baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // If baseUrl is not defined, use the absolute path\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[path] = [`./${relativePath}/*`];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`✅ Path ${path} added to tsconfig.json`);\n } catch (error) {\n console.error(`❌ Error updating tsconfig.json:`, error);\n return false;\n }\n } else {\n console.warn(`⚠️ File tsconfig.json not found, path not added`);\n }\n\n // 3. Create the .bemedev.json file at the root\n\n const jsonConfig = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(\n configFile,\n JSON.stringify(jsonConfig, null, 2),\n 'utf8',\n );\n console.log(`✅ File ${json} created at the root of the project`);\n } catch (error) {\n console.error(`❌ Error creating the file ${json}:`, error);\n return false;\n }\n\n console.log(`🎉 Bemedev initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;AA2BA,MAAa,wBACX,YACA,sBACG;CACH,MAAM,UAAU,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,SAAS;EAClE,OAAO,IAAI,SAAS,OAAO,KAAK,IAAI,SAAS,WAAW;CAC1D,CAAC;CAED,MAAM,QAAkB,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AAU;EAcvD,SAAS,gBAAgB,MAAM,QAAQ,CAAC,KAAK,aAAa,GAAG;EAE7D,cACE,cACA,KAAK,UAAU,UAAU,MAAM,CAAC,GAChC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,wBAAwB;CACrD,SAAS,OAAO;EACd,QAAQ,MAAM,mCAAmC,KAAK;EACtD,OAAO;CACT;MAEA,QAAQ,KAAK,iDAAiD;CAKhE,MAAM,aAAa;EACjB,SAAS;GACR,WAAW,OAAO;GAClB,WAAW,QAAQ;CACtB;CAEA,IAAI;EACF,cACE,YACA,KAAK,UAAU,YAAY,MAAM,CAAC,GAClC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,oCAAoC;CACjE,SAAS,OAAO;EACd,QAAQ,MAAM,6BAA6B,KAAK,IAAI,KAAK;EACzD,OAAO;CACT;CAEA,QAAQ,IAAI,mDAAmD;CAC/D,OAAO;AACT"}
@@ -2,10 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
3
  const require_constants = require("../constants.cjs");
4
4
  const require_helpers = require("../helpers.cjs");
5
+ const require_config = require("../config.cjs");
5
6
  let path = require("path");
6
7
  let fs = require("fs");
7
8
  let edit_json_file = require("edit-json-file");
8
- edit_json_file = require_runtime.__toESM(edit_json_file);
9
+ edit_json_file = require_runtime.__toESM(edit_json_file, 1);
9
10
  //#region src/functions/remove.ts
10
11
  const transformModules = (entries, ...files) => {
11
12
  const cwd = process.cwd();
@@ -27,7 +28,7 @@ const transformModules = (entries, ...files) => {
27
28
  const remove = (CODEBASE_ANALYSIS, ...paths) => {
28
29
  if (paths.length === 0) return console.warn("No files specified for removal.");
29
30
  try {
30
- let file = (0, edit_json_file.default)((0, path.join)(process.cwd(), require_constants.JSON_FILE_NAME));
31
+ let file = (0, edit_json_file.default)((0, path.join)(process.cwd(), require_config.config.json));
31
32
  if (!file) return;
32
33
  const root = require_helpers.getFolderPath(file.get(require_constants.PATH_PROPERTY));
33
34
  const files = file.get(require_constants.FILES_PROPERTY);
@@ -44,23 +45,23 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
44
45
  return safesToRemove.push(key);
45
46
  });
46
47
  require_helpers.consoleStars();
47
- console.log(`🔧 Suppression des fichiers (${entries.length} fichiers)...`);
48
+ console.log(`🔧 Deleting of files (${entries.length} files)...`);
48
49
  if (cannotsRemove.length > 0) {
49
50
  const len = cannotsRemove.length;
50
- console.warn(`⚠️ ${len} ${len === 1 ? "fichier ne peut pas être supprimé (importé dans d'autres fichiers)" : "fichiers ne peuvent pas être supprimés (importés dans d'autres fichiers)"} :`);
51
+ console.warn(`⚠️ ${len} ${len === 1 ? "file cannot be deleted (imported in other files)" : "files cannot be deleted (imported in other files)"} :`);
51
52
  cannotsRemove.forEach(([key, modules]) => {
52
- console.warn(` - ⚠️ ${key} importé par :`);
53
+ console.warn(` - ⚠️ ${key} imported by:`);
53
54
  modules.forEach((m) => console.warn(` -> 📌 ${m}`));
54
55
  });
55
56
  }
56
57
  if (safesToRemove.length === 0) {
57
- console.warn("❌ Aucun fichier ne peut être supprimé.");
58
+ console.warn("❌ No files can be deleted.");
58
59
  return require_helpers.consoleStars();
59
60
  }
60
61
  const formatteds = safesToRemove.map((key) => {
61
62
  return [key, (0, path.join)(root, `${key.replaceAll(".", "/")}.ts`)];
62
63
  });
63
- console.log(`🗑️ Suppression des fichiers (${safesToRemove.length} fichiers)...`);
64
+ console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);
64
65
  let success = 0;
65
66
  const length = formatteds.length;
66
67
  formatteds.forEach(([key, path$1]) => {
@@ -70,14 +71,14 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
70
71
  file?.set(require_constants.FILES_PROPERTY, files.filter((key1) => key1 !== key));
71
72
  success++;
72
73
  } catch {
73
- console.error(` - ❌ Erreur, ${key} :`);
74
+ console.error(` - ❌ Error, ${key} :`);
74
75
  }
75
76
  });
76
77
  file.save();
77
- console.log(`🗑️ Fichiers supprimés! (${success}/${length})`);
78
+ console.log(`🗑️ Files deleted! (${success}/${length})`);
78
79
  file = void 0;
79
80
  } catch {
80
- console.error(`❌ Erreur lors de la création des fichiers`);
81
+ console.error(`❌ Error while deleting files`);
81
82
  require_helpers.consoleStars();
82
83
  return false;
83
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remove.cjs","names":["transformModule","JSON_FILE_NAME","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from \"edit-json-file\";\nimport { unlinkSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { FILES_PROPERTY, JSON_FILE_NAME, PATH_PROPERTY } from \"../constants\";\nimport { consoleStars, getFolderPath, transformModule } from \"../helpers\";\nimport { CodebaseAnalysis, FileAnalysis } from \"../schemas\";\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map((_path) => [_path, `${_path}.index`]) // Ajouter les variantes .index\n .flat()\n .filter((s) => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn(\"No files specified for removal.\");\n try {\n const cwd = process.cwd();\n const json = join(cwd, JSON_FILE_NAME);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some((p) => key.startsWith(p)),\n );\n\n // Vérifier les dépendances avant suppression\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log(\"modules\", \"=>\", importedFroms);\n console.log(\"key\", \"=>\", key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Suppression des fichiers (${entries.length} fichiers)...`);\n\n // Afficher les fichiers qui ne peuvent pas être supprimés\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one =\n \"fichier ne peut pas être supprimé (importé dans d'autres fichiers)\";\n const many =\n \"fichiers ne peuvent pas être supprimés (importés dans d'autres fichiers)\";\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} importé par :`);\n modules.forEach((m) => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn(\"Aucun fichier ne peut être supprimé.\");\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map((key) => {\n const _path = `${key.replaceAll(\".\", \"/\")}.ts`;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(\n `🗑️ Suppression des fichiers (${safesToRemove.length} fichiers)...`,\n );\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter((key1) => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Erreur, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Fichiers supprimés! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Erreur lors de la création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O,KAAA;SACD;AACN,UAAQ,MAAM,4CAA4C;AAC1D,kBAAA,cAAc;AACd,SAAO;;AAET,iBAAA,cAAc;AACd,QAAO"}
1
+ {"version":3,"file":"remove.cjs","names":["transformModule","config","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { config } from '../config';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n} from '../helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}.index`]) // Add .index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, config.json);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Deleting of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} imported by:`);\n modules.forEach(m => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path = `${key.replaceAll('.', '/')}.ts`;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter(key1 => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Error, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Files deleted! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error while deleting files`);\n consoleStars();\n return false;\n }\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,Q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as";
1
+ import { CodebaseAnalysis } from '../schemas';
2
2
  export declare const remove: (CODEBASE_ANALYSIS: CodebaseAnalysis, ...paths: string[]) => boolean | void;
3
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/functions/remove.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,YAAY,CAAC;AA+B5D,eAAO,MAAM,MAAM,GACjB,mBAAmB,gBAAgB,EACnC,GAAG,OAAO,MAAM,EAAE,mBAiGnB,CAAC"}
@@ -1,5 +1,6 @@
1
- import { FILES_PROPERTY, JSON_FILE_NAME, PATH_PROPERTY } from "../constants.js";
1
+ import { FILES_PROPERTY, PATH_PROPERTY } from "../constants.js";
2
2
  import { consoleStars, getFolderPath, transformModule } from "../helpers.js";
3
+ import { config } from "../config.js";
3
4
  import { join } from "path";
4
5
  import { unlinkSync } from "fs";
5
6
  import edit from "edit-json-file";
@@ -24,7 +25,7 @@ const transformModules = (entries, ...files) => {
24
25
  const remove = (CODEBASE_ANALYSIS, ...paths) => {
25
26
  if (paths.length === 0) return console.warn("No files specified for removal.");
26
27
  try {
27
- let file = edit(join(process.cwd(), JSON_FILE_NAME));
28
+ let file = edit(join(process.cwd(), config.json));
28
29
  if (!file) return;
29
30
  const root = getFolderPath(file.get(PATH_PROPERTY));
30
31
  const files = file.get(FILES_PROPERTY);
@@ -41,23 +42,23 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
41
42
  return safesToRemove.push(key);
42
43
  });
43
44
  consoleStars();
44
- console.log(`🔧 Suppression des fichiers (${entries.length} fichiers)...`);
45
+ console.log(`🔧 Deleting of files (${entries.length} files)...`);
45
46
  if (cannotsRemove.length > 0) {
46
47
  const len = cannotsRemove.length;
47
- console.warn(`⚠️ ${len} ${len === 1 ? "fichier ne peut pas être supprimé (importé dans d'autres fichiers)" : "fichiers ne peuvent pas être supprimés (importés dans d'autres fichiers)"} :`);
48
+ console.warn(`⚠️ ${len} ${len === 1 ? "file cannot be deleted (imported in other files)" : "files cannot be deleted (imported in other files)"} :`);
48
49
  cannotsRemove.forEach(([key, modules]) => {
49
- console.warn(` - ⚠️ ${key} importé par :`);
50
+ console.warn(` - ⚠️ ${key} imported by:`);
50
51
  modules.forEach((m) => console.warn(` -> 📌 ${m}`));
51
52
  });
52
53
  }
53
54
  if (safesToRemove.length === 0) {
54
- console.warn("❌ Aucun fichier ne peut être supprimé.");
55
+ console.warn("❌ No files can be deleted.");
55
56
  return consoleStars();
56
57
  }
57
58
  const formatteds = safesToRemove.map((key) => {
58
59
  return [key, join(root, `${key.replaceAll(".", "/")}.ts`)];
59
60
  });
60
- console.log(`🗑️ Suppression des fichiers (${safesToRemove.length} fichiers)...`);
61
+ console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);
61
62
  let success = 0;
62
63
  const length = formatteds.length;
63
64
  formatteds.forEach(([key, path]) => {
@@ -67,14 +68,14 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
67
68
  file?.set(FILES_PROPERTY, files.filter((key1) => key1 !== key));
68
69
  success++;
69
70
  } catch {
70
- console.error(` - ❌ Erreur, ${key} :`);
71
+ console.error(` - ❌ Error, ${key} :`);
71
72
  }
72
73
  });
73
74
  file.save();
74
- console.log(`🗑️ Fichiers supprimés! (${success}/${length})`);
75
+ console.log(`🗑️ Files deleted! (${success}/${length})`);
75
76
  file = void 0;
76
77
  } catch {
77
- console.error(`❌ Erreur lors de la création des fichiers`);
78
+ console.error(`❌ Error while deleting files`);
78
79
  consoleStars();
79
80
  return false;
80
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remove.js","names":[],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from \"edit-json-file\";\nimport { unlinkSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { FILES_PROPERTY, JSON_FILE_NAME, PATH_PROPERTY } from \"../constants\";\nimport { consoleStars, getFolderPath, transformModule } from \"../helpers\";\nimport { CodebaseAnalysis, FileAnalysis } from \"../schemas\";\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map((_path) => [_path, `${_path}.index`]) // Ajouter les variantes .index\n .flat()\n .filter((s) => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn(\"No files specified for removal.\");\n try {\n const cwd = process.cwd();\n const json = join(cwd, JSON_FILE_NAME);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some((p) => key.startsWith(p)),\n );\n\n // Vérifier les dépendances avant suppression\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log(\"modules\", \"=>\", importedFroms);\n console.log(\"key\", \"=>\", key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Suppression des fichiers (${entries.length} fichiers)...`);\n\n // Afficher les fichiers qui ne peuvent pas être supprimés\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one =\n \"fichier ne peut pas être supprimé (importé dans d'autres fichiers)\";\n const many =\n \"fichiers ne peuvent pas être supprimés (importés dans d'autres fichiers)\";\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} importé par :`);\n modules.forEach((m) => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn(\"Aucun fichier ne peut être supprimé.\");\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map((key) => {\n const _path = `${key.replaceAll(\".\", \"/\")}.ts`;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(\n `🗑️ Suppression des fichiers (${safesToRemove.length} fichiers)...`,\n );\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter((key1) => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Erreur, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Fichiers supprimés! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Erreur lors de la création des fichiers`);\n consoleStars();\n return false;\n }\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;;AAOA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,KAAK;AAsBzB,QArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;EAAQ,CAC/B,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;AAC5B,UAAO,gBAAgB;IACrB;IACA;IACA;IACD,CAAC;IACF,CACD,KAAK,UAAU,CAAC,OAAO,GAAG,MAAM,QAAQ,CAAC,CACzC,MAAM,CACN,QAAQ,MAAM,MAAM,SAAS,EAAE,CAAC;AAEnC,SAAO,CAAC,KAAK,MAAM,KAAK,IAAI,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C;KACtD;;AAGJ,MAAI,cAAc,WAAW,GAAG;AAC9B,WAAQ,KAAK,yCAAyC;AACtD,UAAO,cAAc;;EAGvB,MAAM,aAAa,cAAc,KAAK,QAAQ;AAG5C,UAAO,CAAC,KADS,KAAK,MADR,GAAG,IAAI,WAAW,KAAK,IAAI,CAAC,KACR,CACZ;IACtB;AAEF,UAAQ,IACN,iCAAiC,cAAc,OAAO,eACvD;EAED,IAAI,UAAU;EACd,MAAM,SAAS,WAAW;AAE1B,aAAW,SAAS,CAAC,KAAK,UAAU;AAClC,OAAI;AACF,eAAW,KAAK;AAChB,YAAQ,IAAI,WAAW,MAAM;AAC7B,UAAM,IACJ,gBACA,MAAM,QAAQ,SAAS,SAAS,IAAI,CACrC;AACD;WACM;AACN,YAAQ,MAAM,iBAAiB,IAAI,IAAI;;IAEzC;AAEF,OAAK,MAAM;AACX,UAAQ,IAAI,4BAA4B,QAAQ,GAAG,OAAO,GAAG;AAC7D,SAAO,KAAA;SACD;AACN,UAAQ,MAAM,4CAA4C;AAC1D,gBAAc;AACd,SAAO;;AAET,eAAc;AACd,QAAO"}
1
+ {"version":3,"file":"remove.js","names":[],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { config } from '../config';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n} from '../helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}.index`]) // Add .index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, config.json);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Deleting of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} imported by:`);\n modules.forEach(m => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path = `${key.replaceAll('.', '/')}.ts`;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter(key1 => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Error, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Files deleted! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error while deleting files`);\n consoleStars();\n return false;\n }\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;;;AAYA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;GAC5B,OAAO,gBAAgB;IACrB;IACA;IACA;GACF,CAAC;EACH,CAAC,CAAC,CACD,KAAI,UAAS,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,CACvC,KAAK,CAAC,CACN,QAAO,MAAK,MAAM,SAAS,CAAC,CAAC;EAEhC,OAAO,CAAC,KAAK,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC,CAAC;CAC9C,CAEO;AACX;AAEA,MAAa,UACX,mBACA,GAAG,UACA;CAEH,IADgB,MAAM,WAAW,GACpB,OAAO,QAAQ,KAAK,iCAAiC;CAClE,IAAI;EAGF,IAAI,OAA+B,KADtB,KADD,QAAQ,IACA,GAAG,OAAO,IACa,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,OAAO,cAAc,KAAK,IAAI,aAAa,CAAW;EAC5D,MAAM,QAAQ,KAAK,IAAI,cAAc;EAErC,MAAM,WAAW,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,SAC1D,MAAM,SAAS,GAAG,CACpB;EAEA,MAAM,UAAU,SAAS,QAAQ,CAAC,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,MAAM,IACJ,gBACA,MAAM,QAAO,SAAQ,SAAS,GAAG,CACnC;IACA;GACF,QAAQ;IACN,QAAQ,MAAM,gBAAgB,IAAI,GAAG;GACvC;EACF,CAAC;EAED,KAAK,KAAK;EACV,QAAQ,IAAI,uBAAuB,QAAQ,GAAG,OAAO,EAAE;EACvD,OAAO,KAAA;CACT,QAAQ;EACN,QAAQ,MAAM,8BAA8B;EAC5C,aAAa;EACb,OAAO;CACT;CACA,aAAa;CACb,OAAO;AACT"}
package/lib/helpers.cjs CHANGED
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./_virtual/_rolldown/runtime.cjs");
3
2
  const require_constants = require("./constants.cjs");
4
3
  let path = require("path");
5
4
  let fs = require("fs");
@@ -21,7 +20,7 @@ const writeFileAnalysis = (fileAnalysis, folderPath) => {
21
20
  console.log(` ✅ ${relativePath}`);
22
21
  return relativePath.slice(0, -3).replaceAll("/", ".");
23
22
  } catch (error) {
24
- return console.error(` ❌ Erreur pour ${relativePath}:`, error);
23
+ return console.error(` ❌ Error for ${relativePath}:`, error);
25
24
  }
26
25
  };
27
26
  const consoleStars = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport { REPLACERS } from \"./constants\";\nimport { FileAnalysis } from \"./schemas\";\n\nexport type TransformModuleArgs = {\n cwd?: string;\n relativePath: string;\n moduleSpecifier: string;\n};\n\nexport const transformModule = ({\n cwd = process.cwd(),\n relativePath,\n moduleSpecifier,\n}: TransformModuleArgs) => {\n const out = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n ).replaceAll(\"/\", \".\");\n\n return out;\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n\n // Créer le chemin de destination dans .bemedev en maintenant la structure\n const destPath = join(folderPath, relativePath);\n const destDir = dirname(destPath);\n\n try {\n // Créer le dossier de destination si nécessaire\n mkdirSync(destDir, { recursive: true });\n\n let fileContent = fileAnalysis.text;\n REPLACERS.init.forEach(([search, replace]) => {\n fileContent = fileContent.replaceAll(search, replace);\n });\n\n // Écrire le contenu du fichier types\n writeFileSync(destPath, fileContent, \"utf8\");\n\n console.log(` ✅ ${relativePath}`);\n return relativePath.slice(0, -3).replaceAll(\"/\", \".\");\n } catch (error) {\n return console.error(` ❌ Erreur pour ${relativePath}:`, error);\n }\n};\n\nexport const consoleStars = () => {\n console.log();\n console.log(\"*\".repeat(30));\n console.log();\n};\n\nexport const toArray = <T>(value?: T | T[]): T[] => {\n return Array.isArray(value) ? value : !value ? [] : [value];\n};\n\nexport const getFolderPath = (root: string) => {\n const cwd = process.cwd();\n const srcExists = existsSync(join(cwd, \"src\"));\n const folderPath = srcExists ? join(cwd, \"src\", root) : join(cwd, root);\n\n return folderPath;\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBAAmB,EAC9B,MAAM,QAAQ,KAAK,EACnB,cACA,sBACyB;AAMzB,SAAA,GAAA,KAAA,UAJE,MAAA,GAAA,KAAA,UAAA,GAAA,KAAA,SACgB,aAAa,EAAE,gBAAgB,CAChD,CAAC,WAAW,KAAK,IAAI;;AAKxB,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAGlC,MAAM,YAAA,GAAA,KAAA,MAAgB,YAAY,aAAa;CAC/C,MAAM,WAAA,GAAA,KAAA,SAAkB,SAAS;AAEjC,KAAI;AAEF,GAAA,GAAA,GAAA,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;EAEvC,IAAI,cAAc,aAAa;AAC/B,oBAAA,UAAU,KAAK,SAAS,CAAC,QAAQ,aAAa;AAC5C,iBAAc,YAAY,WAAW,QAAQ,QAAQ;IACrD;AAGF,GAAA,GAAA,GAAA,eAAc,UAAU,aAAa,OAAO;AAE5C,UAAQ,IAAI,OAAO,eAAe;AAClC,SAAO,aAAa,MAAM,GAAG,GAAG,CAAC,WAAW,KAAK,IAAI;UAC9C,OAAO;AACd,SAAO,QAAQ,MAAM,mBAAmB,aAAa,IAAI,MAAM;;;AAInE,MAAa,qBAAqB;AAChC,SAAQ,KAAK;AACb,SAAQ,IAAI,IAAI,OAAO,GAAG,CAAC;AAC3B,SAAQ,KAAK;;AAGf,MAAa,WAAc,UAAyB;AAClD,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM;;AAG7D,MAAa,iBAAiB,SAAiB;CAC7C,MAAM,MAAM,QAAQ,KAAK;AAIzB,SAAA,GAAA,GAAA,aAAA,GAAA,KAAA,MAHkC,KAAK,MAAM,CAAC,IAAA,GAAA,KAAA,MACV,KAAK,OAAO,KAAK,IAAA,GAAA,KAAA,MAAQ,KAAK,KAAK"}
1
+ {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { REPLACERS } from './constants';\nimport { FileAnalysis } from './schemas';\n\nexport type TransformModuleArgs = {\n cwd?: string;\n relativePath: string;\n moduleSpecifier: string;\n};\n\nexport const transformModule = ({\n cwd = process.cwd(),\n relativePath,\n moduleSpecifier,\n}: TransformModuleArgs) => {\n const out = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n ).replaceAll('/', '.');\n\n return out;\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n\n // Create the destination path in .bemedev maintaining the structure\n const destPath = join(folderPath, relativePath);\n const destDir = dirname(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(destDir, { recursive: true });\n\n let fileContent = fileAnalysis.text;\n REPLACERS.init.forEach(([search, replace]) => {\n fileContent = fileContent.replaceAll(search, replace);\n });\n\n // Write the types file content\n writeFileSync(destPath, fileContent, 'utf8');\n\n console.log(` ✅ ${relativePath}`);\n return relativePath.slice(0, -3).replaceAll('/', '.');\n } catch (error) {\n return console.error(` ❌ Error for ${relativePath}:`, error);\n }\n};\n\nexport const consoleStars = () => {\n console.log();\n console.log('*'.repeat(30));\n console.log();\n};\n\nexport const toArray = <T>(value?: T | T[]): T[] => {\n return Array.isArray(value) ? value : !value ? [] : [value];\n};\n\nexport const getFolderPath = (root: string) => {\n const cwd = process.cwd();\n const srcExists = existsSync(join(cwd, 'src'));\n const folderPath = srcExists\n ? join(cwd, 'src', root)\n : join(cwd, root);\n\n return folderPath;\n};\n"],"mappings":";;;;;AAWA,MAAa,mBAAmB,EAC9B,MAAM,QAAQ,IAAI,GAClB,cACA,sBACyB;CAMzB,QAAA,GAAA,KAAA,SAAA,CAJE,MAAA,GAAA,KAAA,QAAA,EAAA,GAAA,KAAA,QAAA,CACgB,YAAY,GAAG,eAAe,CAChD,CAAC,CAAC,WAAW,KAAK,GAET;AACX;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAGlC,MAAM,YAAA,GAAA,KAAA,KAAA,CAAgB,YAAY,YAAY;CAC9C,MAAM,WAAA,GAAA,KAAA,QAAA,CAAkB,QAAQ;CAEhC,IAAI;EAEF,CAAA,GAAA,GAAA,UAAA,CAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAEtC,IAAI,cAAc,aAAa;EAC/B,kBAAA,UAAU,KAAK,SAAS,CAAC,QAAQ,aAAa;GAC5C,cAAc,YAAY,WAAW,QAAQ,OAAO;EACtD,CAAC;EAGD,CAAA,GAAA,GAAA,cAAA,CAAc,UAAU,aAAa,MAAM;EAE3C,QAAQ,IAAI,OAAO,cAAc;EACjC,OAAO,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,WAAW,KAAK,GAAG;CACtD,SAAS,OAAO;EACd,OAAO,QAAQ,MAAM,iBAAiB,aAAa,IAAI,KAAK;CAC9D;AACF;AAEA,MAAa,qBAAqB;CAChC,QAAQ,IAAI;CACZ,QAAQ,IAAI,IAAI,OAAO,EAAE,CAAC;CAC1B,QAAQ,IAAI;AACd;AAEA,MAAa,WAAc,UAAyB;CAClD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;AAC5D;AAEA,MAAa,iBAAiB,SAAiB;CAC7C,MAAM,MAAM,QAAQ,IAAI;CAMxB,QAAA,GAAA,GAAA,WAAA,EAAA,GAAA,KAAA,KAAA,CALkC,KAAK,KAAK,CACjB,KAAA,GAAA,KAAA,KAAA,CAClB,KAAK,OAAO,IAAI,KAAA,GAAA,KAAA,KAAA,CAChB,KAAK,IAAI;AAGpB"}
package/lib/helpers.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { FileAnalysis } from "./schemas";
1
+ import { FileAnalysis } from './schemas';
2
2
  export type TransformModuleArgs = {
3
3
  cwd?: string;
4
4
  relativePath: string;
5
5
  moduleSpecifier: string;
6
6
  };
7
- export declare const transformModule: ({ cwd, relativePath, moduleSpecifier, }: TransformModuleArgs) => any;
8
- export declare const writeFileAnalysis: (fileAnalysis: FileAnalysis, folderPath: string) => any;
7
+ export declare const transformModule: ({ cwd, relativePath, moduleSpecifier, }: TransformModuleArgs) => string;
8
+ export declare const writeFileAnalysis: (fileAnalysis: FileAnalysis, folderPath: string) => string | void;
9
9
  export declare const consoleStars: () => void;
10
10
  export declare const toArray: <T>(value?: T | T[]) => T[];
11
11
  export declare const getFolderPath: (root: string) => string;
12
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,yCAI7B,mBAAmB,WAOrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,YAAY,MAAM,kBAyBnB,CAAC;AAEF,eAAO,MAAM,YAAY,YAIxB,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAG,CAAC,EAE7C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,WAQzC,CAAC"}