@bemedev/codebase 1.3.0 โ†’ 1.4.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
@@ -1,7 +1,7 @@
1
1
  # @bemedev/codebase
2
2
 
3
3
  ![License](https://img.shields.io/badge/license-MIT-blue.svg)
4
- ![Node.js](https://img.shields.io/badge/node-%3E%3D22-green.svg)
4
+ ![Node.js](https://img.shields.io/badge/node-%3E%3D24-green.svg)
5
5
  ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)
6
6
 
7
7
  A powerful CLI to generate and analyze your TypeScript/JavaScript
@@ -17,6 +17,8 @@ comprehensive analyses of your source code.
17
17
  - **๐Ÿ“ฆ Partial import**: Selective import of library parts
18
18
  - **๐ŸŽฏ Flexible exclusion**: Ability to exclude specific files
19
19
  - **๐Ÿ“ˆ Statistics**: Detailed reports about your codebase
20
+ - **๐Ÿงน Code pruning**: Automatic removal of unused declarations, empty
21
+ files, and empty folders in target directories
20
22
 
21
23
  ## ๐Ÿ“‹ Prerequisites
22
24
 
@@ -116,6 +118,20 @@ remove(
116
118
  );
117
119
  ```
118
120
 
121
+ #### Pruning unused code programmatically
122
+
123
+ You can use the `lift` function to prune unused declarations
124
+ (references, types, variables, classes, functions, or enums) and clean
125
+ up imports within a target folder, automatically deleting files and
126
+ folders that become empty.
127
+
128
+ ```typescript
129
+ import { lift } from '@bemedev/codebase';
130
+
131
+ // Prune unused code and perform tree shaking in the specified folder
132
+ lift('my-project-src');
133
+ ```
134
+
119
135
  ## ๐Ÿ“Š Output format
120
136
 
121
137
  The generated JSON file contains:
@@ -146,7 +162,9 @@ src/
146
162
  โ”‚ โ”œโ”€โ”€ add.ts # Add dependencies
147
163
  โ”‚ โ”œโ”€โ”€ generate.ts # Generate analysis
148
164
  โ”‚ โ”œโ”€โ”€ init.ts # Initialization
149
- โ”‚ โ””โ”€โ”€ remove.ts # Removal
165
+ โ”‚ โ”œโ”€โ”€ lift.ts # Code pruning/tree shaking
166
+ โ”‚ โ”œโ”€โ”€ remove.ts # Removal
167
+ โ”‚ โ””โ”€โ”€ softInit.ts # Soft initialization helper
150
168
  โ”œโ”€โ”€ analyse.ts # Analysis engine
151
169
  โ”œโ”€โ”€ types.ts # TypeScript definitions
152
170
  โ””โ”€โ”€ constants.ts # Global constants
@@ -2,10 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_functions_add = require("./add.cjs");
3
3
  const require_functions_generate = require("./generate.cjs");
4
4
  const require_functions_init = require("./init.cjs");
5
+ const require_functions_lift = require("./lift.cjs");
5
6
  const require_functions_remove = require("./remove.cjs");
6
7
  exports.add = require_functions_add.add;
7
- exports.createTypesStructure = require_functions_init.createTypesStructure;
8
8
  exports.generate = require_functions_generate.generate;
9
9
  exports.init = require_functions_init.init;
10
+ exports.lift = require_functions_lift.lift;
10
11
  exports.remove = require_functions_remove.remove;
11
12
  exports.transformJSON = require_functions_generate.transformJSON;
@@ -1,5 +1,6 @@
1
1
  export * from './add';
2
2
  export * from './generate';
3
3
  export * from './init';
4
+ export * from './lift';
4
5
  export * from './remove';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { add } from "./add.js";
2
2
  import { generate, transformJSON } from "./generate.js";
3
- import { createTypesStructure, init } from "./init.js";
3
+ import { init } from "./init.js";
4
+ import { lift } from "./lift.js";
4
5
  import { remove } from "./remove.js";
5
- export { add, createTypesStructure, generate, init, remove, transformJSON };
6
+ export { add, generate, init, lift, remove, transformJSON };
@@ -4,19 +4,6 @@ const require_helpers = require("../helpers.cjs");
4
4
  let path = require("path");
5
5
  let fs = require("fs");
6
6
  //#region src/functions/init.ts
7
- const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
8
- const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {
9
- return key.endsWith("types") || key.endsWith("constants");
10
- });
11
- const PATHS = [];
12
- console.log(`๐Ÿ”ง Creating types structure (${entries.length} files)...`);
13
- for (const [, fileAnalysis] of entries) {
14
- const file = require_helpers.writeFileAnalysis(fileAnalysis, folderPath);
15
- if (file) PATHS.push(file);
16
- }
17
- console.log(`โœ… Types structure successfully created!`);
18
- return PATHS;
19
- };
20
7
  const init = (CODEBASE_ANALYSIS, { root, json, path: path$1 = require_constants.DEFAULT_PATH_KEY, bin = require_constants.DEFAULT_CLI_NAME }) => {
21
8
  const cwd = process.cwd();
22
9
  const configFile = (0, path.join)(cwd, json);
@@ -31,7 +18,7 @@ const init = (CODEBASE_ANALYSIS, { root, json, path: path$1 = require_constants.
31
18
  }
32
19
  let files = [];
33
20
  try {
34
- files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);
21
+ files = require_helpers.createTypesStructure(folderPath, CODEBASE_ANALYSIS);
35
22
  } catch {
36
23
  console.error(`โŒ Error creating the types structure:`);
37
24
  return false;
@@ -63,11 +50,10 @@ const init = (CODEBASE_ANALYSIS, { root, json, path: path$1 = require_constants.
63
50
  console.error(`โŒ Error creating the file ${json}:`, error);
64
51
  return false;
65
52
  }
66
- console.log(`๐ŸŽ‰ Bemedev initialization completed successfully!`);
53
+ console.log(`๐ŸŽ‰ ${bin} initialization completed successfully!`);
67
54
  return true;
68
55
  };
69
56
  //#endregion
70
- exports.createTypesStructure = createTypesStructure;
71
57
  exports.init = init;
72
58
 
73
59
  //# sourceMappingURL=init.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.cjs","names":["writeFileAnalysis","DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","getFolderPath","path","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\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 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":";;;;;;AAqBA,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,CAAC;CAEzB,QAAQ,IACN,gCAAgC,QAAQ,OAAO,WACjD;CAEA,KAAK,MA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AAA,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;GACRC,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
+ {"version":3,"file":"init.cjs","names":["DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","getFolderPath","createTypesStructure","path","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { createTypesStructure, getFolderPath } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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 init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\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 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(`๐ŸŽ‰ ${bin} initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;AAqBA,MAAa,QACX,mBACA,EACE,MACA,MACA,MAAA,SAAOA,kBAAAA,kBACP,MAAMC,kBAAAA,uBAEL;CACH,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AA,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,MAAM,IAAI,wCAAwC;CAC9D,OAAO;AACT"}
@@ -9,6 +9,5 @@ export interface InitOptions {
9
9
  path?: string;
10
10
  bin?: string;
11
11
  }
12
- export declare const createTypesStructure: (folderPath: string, CODEBASE_ANALYSIS: CodebaseAnalysis) => string[];
13
12
  export declare const init: (CODEBASE_ANALYSIS: CodebaseAnalysis, { root, json, path, bin, }: InitOptions) => boolean;
14
13
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/functions/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,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,4BAKG,WAAW,YAqFf,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/functions/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,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,IAAI,GACf,mBAAmB,gBAAgB,EACnC,4BAKG,WAAW,YAqFf,CAAC"}
@@ -1,21 +1,8 @@
1
1
  import { DEFAULT_CLI_NAME, DEFAULT_PATH_KEY, PROPERTIES } from "../constants.js";
2
- import { getFolderPath, writeFileAnalysis } from "../helpers.js";
2
+ import { createTypesStructure, getFolderPath } from "../helpers.js";
3
3
  import { join, relative } from "path";
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
5
5
  //#region src/functions/init.ts
6
- const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
7
- const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {
8
- return key.endsWith("types") || key.endsWith("constants");
9
- });
10
- const PATHS = [];
11
- console.log(`๐Ÿ”ง Creating types structure (${entries.length} files)...`);
12
- for (const [, fileAnalysis] of entries) {
13
- const file = writeFileAnalysis(fileAnalysis, folderPath);
14
- if (file) PATHS.push(file);
15
- }
16
- console.log(`โœ… Types structure successfully created!`);
17
- return PATHS;
18
- };
19
6
  const init = (CODEBASE_ANALYSIS, { root, json, path = DEFAULT_PATH_KEY, bin = DEFAULT_CLI_NAME }) => {
20
7
  const cwd = process.cwd();
21
8
  const configFile = join(cwd, json);
@@ -62,10 +49,10 @@ const init = (CODEBASE_ANALYSIS, { root, json, path = DEFAULT_PATH_KEY, bin = DE
62
49
  console.error(`โŒ Error creating the file ${json}:`, error);
63
50
  return false;
64
51
  }
65
- console.log(`๐ŸŽ‰ Bemedev initialization completed successfully!`);
52
+ console.log(`๐ŸŽ‰ ${bin} initialization completed successfully!`);
66
53
  return true;
67
54
  };
68
55
  //#endregion
69
- export { createTypesStructure, init };
56
+ export { init };
70
57
 
71
58
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { getFolderPath, writeFileAnalysis } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\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 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":";;;;;AAqBA,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,CAAC;CAEzB,QAAQ,IACN,gCAAgC,QAAQ,OAAO,WACjD;CAEA,KAAK,MAAM,GAAG,iBAAiB,SAAS;EACtC,MAAM,OAAO,kBAAkB,cAAc,UAAU;EACvD,IAAI,MAAM,MAAM,KAAK,IAAI;CAC3B;CAEA,QAAQ,IAAI,yCAAyC;CACrD,OAAO;AACT;AAEA,MAAa,QACX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AAoC;CACjE,SAAS,OAAO;EACd,QAAQ,MAAM,6BAA6B,KAAK,IAAI,KAAK;EACzD,OAAO;CACT;CAEA,QAAQ,IAAI,mDAAmD;CAC/D,OAAO;AACT"}
1
+ {"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport {\n DEFAULT_CLI_NAME,\n DEFAULT_PATH_KEY,\n PROPERTIES,\n} from '../constants';\nimport { createTypesStructure, getFolderPath } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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 init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\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 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(`๐ŸŽ‰ ${bin} initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;AAqBA,MAAa,QACX,mBACA,EACE,MACA,MACA,OAAO,kBACP,MAAM,uBAEL;CACH,MAAM,MAAM,QAAQ,IAAI;CACxB,MAAM,aAAa,KAAK,KAAK,IAAI;CAEjC,IADqB,WAAW,UACjB,GAAG,OAAO;CACzB,MAAM,aAAa,cAAc,IAAI;CAGrC,IAAI;EACF,UAAU,YAAY,EAAE,WAAW,KAAK,CAAC;EACzC,QAAQ,IAAI,YAAY,IAAI,eAAe,MAAM;CACnD,SAAS,OAAO;EACd,QAAQ,MAAM,+BAA+B,IAAI,IAAI,KAAK;EAC1D,OAAO;CACT;CAGA,IAAI,QAAkB,CAAC;CAEvB,IAAI;EACF,QAAQ,qBAAqB,YAAY,iBAAiB;CAC5D,QAAQ;EACN,QAAQ,MAAM,uCAAuC;EACrD,OAAO;CACT;CAGA,MAAM,eAAe,KAAK,KAAK,eAAe;CAE9C,IAAI,WAAW,YAAY,GACzB,IAAI;EACF,MAAM,kBAAkB,aAAa,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,eAAe,SAAS,QAAQ,IAAI,GAAG,UAAU;EAEvD,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,MAAM,IAAI,wCAAwC;CAC9D,OAAO;AACT"}
@@ -0,0 +1,125 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_helpers = require("../helpers.cjs");
3
+ let path = require("path");
4
+ let ts_morph = require("ts-morph");
5
+ let fs = require("fs");
6
+ //#region src/functions/lift.ts
7
+ const lift = (root) => {
8
+ const folderPath = require_helpers.getFolderPath(root);
9
+ if (!(0, fs.existsSync)(folderPath)) {
10
+ console.warn(`Folder not found: ${folderPath}`);
11
+ return false;
12
+ }
13
+ const tsconfigPath = (0, path.join)(process.cwd(), "tsconfig.json");
14
+ const project = (0, fs.existsSync)(tsconfigPath) ? new ts_morph.Project({ tsConfigFilePath: tsconfigPath }) : new ts_morph.Project();
15
+ project.addSourceFilesAtPaths((0, path.join)(folderPath, "**/*.ts"));
16
+ project.addSourceFilesAtPaths((0, path.join)(folderPath, "**/*.tsx"));
17
+ const isInsideFolder = (filePath) => {
18
+ return filePath.startsWith(folderPath);
19
+ };
20
+ let changed = true;
21
+ while (changed) {
22
+ changed = false;
23
+ const declarations = project.getSourceFiles().filter((sf) => isInsideFolder(sf.getFilePath())).flatMap((sf) => [
24
+ ...sf.getTypeAliases(),
25
+ ...sf.getInterfaces(),
26
+ ...sf.getVariableDeclarations(),
27
+ ...sf.getFunctions(),
28
+ ...sf.getClasses(),
29
+ ...sf.getEnums()
30
+ ]);
31
+ for (const decl of declarations) {
32
+ if (decl.wasForgotten()) continue;
33
+ const nameNode = decl.getNameNode();
34
+ if (!nameNode || !ts_morph.Node.isIdentifier(nameNode)) continue;
35
+ const referencedSymbols = nameNode.findReferences();
36
+ let refCount = 0;
37
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getNode() !== nameNode) refCount++;
38
+ if (refCount === 0) {
39
+ decl.remove();
40
+ changed = true;
41
+ break;
42
+ }
43
+ }
44
+ if (changed) continue;
45
+ const importDeclarations = project.getSourceFiles().filter((sf) => isInsideFolder(sf.getFilePath())).flatMap((sf) => sf.getImportDeclarations());
46
+ for (const imp of importDeclarations) {
47
+ if (imp.wasForgotten()) continue;
48
+ const sf = imp.getSourceFile();
49
+ const namedImports = imp.getNamedImports();
50
+ for (const spec of namedImports) {
51
+ if (spec.wasForgotten()) continue;
52
+ const nameNode = spec.getNameNode();
53
+ if (!ts_morph.Node.isIdentifier(nameNode)) continue;
54
+ const referencedSymbols = nameNode.findReferences();
55
+ let refCount = 0;
56
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== nameNode) refCount++;
57
+ if (refCount === 0) {
58
+ spec.remove();
59
+ changed = true;
60
+ break;
61
+ }
62
+ }
63
+ if (changed) break;
64
+ const defaultImport = imp.getDefaultImport();
65
+ if (defaultImport && !defaultImport.wasForgotten() && ts_morph.Node.isIdentifier(defaultImport)) {
66
+ const referencedSymbols = defaultImport.findReferences();
67
+ let refCount = 0;
68
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== defaultImport) refCount++;
69
+ if (refCount === 0) {
70
+ const hasNamed = imp.getNamedImports().length > 0;
71
+ const hasNamespace = !!imp.getNamespaceImport();
72
+ if (!hasNamed && !hasNamespace) imp.remove();
73
+ else imp.removeDefaultImport();
74
+ changed = true;
75
+ break;
76
+ }
77
+ }
78
+ if (changed) break;
79
+ const namespaceImport = imp.getNamespaceImport();
80
+ if (namespaceImport && !namespaceImport.wasForgotten() && ts_morph.Node.isIdentifier(namespaceImport)) {
81
+ const referencedSymbols = namespaceImport.findReferences();
82
+ let refCount = 0;
83
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== namespaceImport) refCount++;
84
+ if (refCount === 0) {
85
+ imp.remove();
86
+ changed = true;
87
+ break;
88
+ }
89
+ }
90
+ if (changed) break;
91
+ const hasNamed = imp.getNamedImports().length > 0;
92
+ const hasDefault = !!imp.getDefaultImport();
93
+ const hasNamespace = !!imp.getNamespaceImport();
94
+ if (!hasNamed && !hasDefault && !hasNamespace) {
95
+ imp.remove();
96
+ changed = true;
97
+ break;
98
+ }
99
+ }
100
+ }
101
+ project.saveSync();
102
+ const sourceFiles = project.getSourceFiles();
103
+ for (const sf of sourceFiles) {
104
+ const filePath = sf.getFilePath();
105
+ if (isInsideFolder(filePath) && sf.getFullText().trim() === "") {
106
+ project.removeSourceFile(sf);
107
+ if ((0, fs.existsSync)(filePath)) (0, fs.unlinkSync)(filePath);
108
+ }
109
+ }
110
+ const cleanEmptyDirs = (dir) => {
111
+ if (!(0, fs.existsSync)(dir) || !(0, fs.statSync)(dir).isDirectory()) return;
112
+ const files = (0, fs.readdirSync)(dir);
113
+ for (const file of files) {
114
+ const fullPath = (0, path.join)(dir, file);
115
+ if ((0, fs.statSync)(fullPath).isDirectory()) cleanEmptyDirs(fullPath);
116
+ }
117
+ if ((0, fs.readdirSync)(dir).length === 0) (0, fs.rmdirSync)(dir);
118
+ };
119
+ cleanEmptyDirs(folderPath);
120
+ return true;
121
+ };
122
+ //#endregion
123
+ exports.lift = lift;
124
+
125
+ //# sourceMappingURL=lift.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift.cjs","names":["getFolderPath","Project","Node"],"sources":["../../src/functions/lift.ts"],"sourcesContent":["import {\n existsSync,\n readdirSync,\n rmdirSync,\n statSync,\n unlinkSync,\n} from 'fs';\nimport { join } from 'path';\nimport { Project, Node } from 'ts-morph';\nimport { getFolderPath } from '../helpers';\n\nexport const lift = (root: string) => {\n const folderPath = getFolderPath(root);\n if (!existsSync(folderPath)) {\n console.warn(`Folder not found: ${folderPath}`);\n return false;\n }\n\n const tsconfigPath = join(process.cwd(), 'tsconfig.json');\n const project = existsSync(tsconfigPath)\n ? new Project({ tsConfigFilePath: tsconfigPath })\n : new Project();\n\n // Add all source files recursively\n project.addSourceFilesAtPaths(join(folderPath, '**/*.ts'));\n project.addSourceFilesAtPaths(join(folderPath, '**/*.tsx'));\n\n const isInsideFolder = (filePath: string) => {\n return filePath.startsWith(folderPath);\n };\n\n let changed = true;\n while (changed) {\n changed = false;\n\n // A: Declarations inside the target folder\n const declarations = project\n .getSourceFiles()\n .filter(sf => isInsideFolder(sf.getFilePath()))\n .flatMap(sf => [\n ...sf.getTypeAliases(),\n ...sf.getInterfaces(),\n ...sf.getVariableDeclarations(),\n ...sf.getFunctions(),\n ...sf.getClasses(),\n ...sf.getEnums(),\n ]);\n\n for (const decl of declarations) {\n if (decl.wasForgotten()) continue;\n\n const nameNode = decl.getNameNode();\n if (!nameNode || !Node.isIdentifier(nameNode)) continue;\n\n const referencedSymbols = nameNode.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (ref.getNode() !== nameNode) {\n refCount++;\n }\n }\n }\n\n if (refCount === 0) {\n decl.remove();\n changed = true;\n break;\n }\n }\n\n if (changed) continue;\n\n // B: Imports inside the target folder\n const importDeclarations = project\n .getSourceFiles()\n .filter(sf => isInsideFolder(sf.getFilePath()))\n .flatMap(sf => sf.getImportDeclarations());\n\n for (const imp of importDeclarations) {\n if (imp.wasForgotten()) continue;\n const sf = imp.getSourceFile();\n\n // 1. Named imports\n const namedImports = imp.getNamedImports();\n for (const spec of namedImports) {\n if (spec.wasForgotten()) continue;\n const nameNode = spec.getNameNode();\n if (!Node.isIdentifier(nameNode)) continue;\n\n const referencedSymbols = nameNode.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== nameNode\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n spec.remove();\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 2. Default import\n const defaultImport = imp.getDefaultImport();\n if (\n defaultImport &&\n !defaultImport.wasForgotten() &&\n Node.isIdentifier(defaultImport)\n ) {\n const referencedSymbols = defaultImport.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== defaultImport\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n const hasNamed = imp.getNamedImports().length > 0;\n const hasNamespace = !!imp.getNamespaceImport();\n if (!hasNamed && !hasNamespace) {\n imp.remove();\n } else {\n imp.removeDefaultImport();\n }\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 3. Namespace import\n const namespaceImport = imp.getNamespaceImport();\n if (\n namespaceImport &&\n !namespaceImport.wasForgotten() &&\n Node.isIdentifier(namespaceImport)\n ) {\n const referencedSymbols = namespaceImport.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== namespaceImport\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n imp.remove();\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 4. Empty import declarations\n const hasNamed = imp.getNamedImports().length > 0;\n const hasDefault = !!imp.getDefaultImport();\n const hasNamespace = !!imp.getNamespaceImport();\n if (!hasNamed && !hasDefault && !hasNamespace) {\n imp.remove();\n changed = true;\n break;\n }\n }\n }\n\n // Save changes\n project.saveSync();\n\n // Delete files that are empty (after trimming whitespace) and inside the target folder\n const sourceFiles = project.getSourceFiles();\n for (const sf of sourceFiles) {\n const filePath = sf.getFilePath();\n if (isInsideFolder(filePath) && sf.getFullText().trim() === '') {\n project.removeSourceFile(sf);\n if (existsSync(filePath)) {\n unlinkSync(filePath);\n }\n }\n }\n\n // Helper to recursively clean empty directories\n const cleanEmptyDirs = (dir: string) => {\n if (!existsSync(dir) || !statSync(dir).isDirectory()) return;\n\n const files = readdirSync(dir);\n for (const file of files) {\n const fullPath = join(dir, file);\n if (statSync(fullPath).isDirectory()) {\n cleanEmptyDirs(fullPath);\n }\n }\n\n const remaining = readdirSync(dir);\n if (remaining.length === 0) {\n rmdirSync(dir);\n }\n };\n\n cleanEmptyDirs(folderPath);\n\n return true;\n};\n"],"mappings":";;;;;;AAWA,MAAa,QAAQ,SAAiB;CACpC,MAAM,aAAaA,gBAAAA,cAAc,IAAI;CACrC,IAAI,EAAA,GAAA,GAAA,WAAA,CAAY,UAAU,GAAG;EAC3B,QAAQ,KAAK,qBAAqB,YAAY;EAC9C,OAAO;CACT;CAEA,MAAM,gBAAA,GAAA,KAAA,KAAA,CAAoB,QAAQ,IAAI,GAAG,eAAe;CACxD,MAAM,WAAA,GAAA,GAAA,WAAA,CAAqB,YAAY,IACnC,IAAIC,SAAAA,QAAQ,EAAE,kBAAkB,aAAa,CAAC,IAC9C,IAAIA,SAAAA,QAAQ;C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,IAAI,gBAAgB,CAAC,CAAC,SAAS;GAChD,MAAM,aAAa,CAAC,CAAC,IAAI,iBAAiB;GAC1C,MAAM,eAAe,CAAC,CAAC,IAAI,mBAAmB;GAC9C,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,cAAc;IAC7C,IAAI,OAAO;IACX,UAAU;IACV;GACF;EACF;CACF;CAGA,QAAQ,SAAS;CAGjB,MAAM,cAAc,QAAQ,eAAe;CAC3C,KAAK,MAAM,MAAM,aAAa;EAC5B,MAAM,WAAW,GAAG,YAAY;EAChC,IAAI,eAAe,QAAQ,KAAK,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM,IAAI;GAC9D,QAAQ,iBAAiB,EAAE;GAC3B,KAAA,GAAA,GAAA,WAAA,CAAe,QAAQ,GACrB,CAAA,GAAA,GAAA,WAAA,CAAW,QAAQ;EAEvB;CACF;CAGA,MAAM,kBAAkB,QAAgB;EACtC,IAAI,EAAA,GAAA,GAAA,WAAA,CAAY,GAAG,KAAK,EAAA,GAAA,GAAA,SAAA,CAAU,GAAG,CAAC,CAAC,YAAY,GAAG;EAEtD,MAAM,SAAA,GAAA,GAAA,YAAA,CAAoB,GAAG;EAC7B,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,YAAA,GAAA,KAAA,KAAA,CAAgB,KAAK,IAAI;GAC/B,KAAA,GAAA,GAAA,SAAA,CAAa,QAAQ,CAAC,CAAC,YAAY,GACjC,eAAe,QAAQ;EAE3B;EAGA,KAAA,GAAA,GAAA,YAAA,CAD8B,GAClB,CAAC,CAAC,WAAW,GACvB,CAAA,GAAA,GAAA,UAAA,CAAU,GAAG;CAEjB;CAEA,eAAe,UAAU;CAEzB,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ export declare const lift: (root: string) => boolean;
2
+ //# sourceMappingURL=lift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift.d.ts","sourceRoot":"","sources":["../../src/functions/lift.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,YA+MhC,CAAC"}
@@ -0,0 +1,124 @@
1
+ import { getFolderPath } from "../helpers.js";
2
+ import { join } from "path";
3
+ import { Node, Project } from "ts-morph";
4
+ import { existsSync, readdirSync, rmdirSync, statSync, unlinkSync } from "fs";
5
+ //#region src/functions/lift.ts
6
+ const lift = (root) => {
7
+ const folderPath = getFolderPath(root);
8
+ if (!existsSync(folderPath)) {
9
+ console.warn(`Folder not found: ${folderPath}`);
10
+ return false;
11
+ }
12
+ const tsconfigPath = join(process.cwd(), "tsconfig.json");
13
+ const project = existsSync(tsconfigPath) ? new Project({ tsConfigFilePath: tsconfigPath }) : new Project();
14
+ project.addSourceFilesAtPaths(join(folderPath, "**/*.ts"));
15
+ project.addSourceFilesAtPaths(join(folderPath, "**/*.tsx"));
16
+ const isInsideFolder = (filePath) => {
17
+ return filePath.startsWith(folderPath);
18
+ };
19
+ let changed = true;
20
+ while (changed) {
21
+ changed = false;
22
+ const declarations = project.getSourceFiles().filter((sf) => isInsideFolder(sf.getFilePath())).flatMap((sf) => [
23
+ ...sf.getTypeAliases(),
24
+ ...sf.getInterfaces(),
25
+ ...sf.getVariableDeclarations(),
26
+ ...sf.getFunctions(),
27
+ ...sf.getClasses(),
28
+ ...sf.getEnums()
29
+ ]);
30
+ for (const decl of declarations) {
31
+ if (decl.wasForgotten()) continue;
32
+ const nameNode = decl.getNameNode();
33
+ if (!nameNode || !Node.isIdentifier(nameNode)) continue;
34
+ const referencedSymbols = nameNode.findReferences();
35
+ let refCount = 0;
36
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getNode() !== nameNode) refCount++;
37
+ if (refCount === 0) {
38
+ decl.remove();
39
+ changed = true;
40
+ break;
41
+ }
42
+ }
43
+ if (changed) continue;
44
+ const importDeclarations = project.getSourceFiles().filter((sf) => isInsideFolder(sf.getFilePath())).flatMap((sf) => sf.getImportDeclarations());
45
+ for (const imp of importDeclarations) {
46
+ if (imp.wasForgotten()) continue;
47
+ const sf = imp.getSourceFile();
48
+ const namedImports = imp.getNamedImports();
49
+ for (const spec of namedImports) {
50
+ if (spec.wasForgotten()) continue;
51
+ const nameNode = spec.getNameNode();
52
+ if (!Node.isIdentifier(nameNode)) continue;
53
+ const referencedSymbols = nameNode.findReferences();
54
+ let refCount = 0;
55
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== nameNode) refCount++;
56
+ if (refCount === 0) {
57
+ spec.remove();
58
+ changed = true;
59
+ break;
60
+ }
61
+ }
62
+ if (changed) break;
63
+ const defaultImport = imp.getDefaultImport();
64
+ if (defaultImport && !defaultImport.wasForgotten() && Node.isIdentifier(defaultImport)) {
65
+ const referencedSymbols = defaultImport.findReferences();
66
+ let refCount = 0;
67
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== defaultImport) refCount++;
68
+ if (refCount === 0) {
69
+ const hasNamed = imp.getNamedImports().length > 0;
70
+ const hasNamespace = !!imp.getNamespaceImport();
71
+ if (!hasNamed && !hasNamespace) imp.remove();
72
+ else imp.removeDefaultImport();
73
+ changed = true;
74
+ break;
75
+ }
76
+ }
77
+ if (changed) break;
78
+ const namespaceImport = imp.getNamespaceImport();
79
+ if (namespaceImport && !namespaceImport.wasForgotten() && Node.isIdentifier(namespaceImport)) {
80
+ const referencedSymbols = namespaceImport.findReferences();
81
+ let refCount = 0;
82
+ for (const refSymbol of referencedSymbols) for (const ref of refSymbol.getReferences()) if (ref.getSourceFile() === sf && ref.getNode() !== namespaceImport) refCount++;
83
+ if (refCount === 0) {
84
+ imp.remove();
85
+ changed = true;
86
+ break;
87
+ }
88
+ }
89
+ if (changed) break;
90
+ const hasNamed = imp.getNamedImports().length > 0;
91
+ const hasDefault = !!imp.getDefaultImport();
92
+ const hasNamespace = !!imp.getNamespaceImport();
93
+ if (!hasNamed && !hasDefault && !hasNamespace) {
94
+ imp.remove();
95
+ changed = true;
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ project.saveSync();
101
+ const sourceFiles = project.getSourceFiles();
102
+ for (const sf of sourceFiles) {
103
+ const filePath = sf.getFilePath();
104
+ if (isInsideFolder(filePath) && sf.getFullText().trim() === "") {
105
+ project.removeSourceFile(sf);
106
+ if (existsSync(filePath)) unlinkSync(filePath);
107
+ }
108
+ }
109
+ const cleanEmptyDirs = (dir) => {
110
+ if (!existsSync(dir) || !statSync(dir).isDirectory()) return;
111
+ const files = readdirSync(dir);
112
+ for (const file of files) {
113
+ const fullPath = join(dir, file);
114
+ if (statSync(fullPath).isDirectory()) cleanEmptyDirs(fullPath);
115
+ }
116
+ if (readdirSync(dir).length === 0) rmdirSync(dir);
117
+ };
118
+ cleanEmptyDirs(folderPath);
119
+ return true;
120
+ };
121
+ //#endregion
122
+ export { lift };
123
+
124
+ //# sourceMappingURL=lift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lift.js","names":[],"sources":["../../src/functions/lift.ts"],"sourcesContent":["import {\n existsSync,\n readdirSync,\n rmdirSync,\n statSync,\n unlinkSync,\n} from 'fs';\nimport { join } from 'path';\nimport { Project, Node } from 'ts-morph';\nimport { getFolderPath } from '../helpers';\n\nexport const lift = (root: string) => {\n const folderPath = getFolderPath(root);\n if (!existsSync(folderPath)) {\n console.warn(`Folder not found: ${folderPath}`);\n return false;\n }\n\n const tsconfigPath = join(process.cwd(), 'tsconfig.json');\n const project = existsSync(tsconfigPath)\n ? new Project({ tsConfigFilePath: tsconfigPath })\n : new Project();\n\n // Add all source files recursively\n project.addSourceFilesAtPaths(join(folderPath, '**/*.ts'));\n project.addSourceFilesAtPaths(join(folderPath, '**/*.tsx'));\n\n const isInsideFolder = (filePath: string) => {\n return filePath.startsWith(folderPath);\n };\n\n let changed = true;\n while (changed) {\n changed = false;\n\n // A: Declarations inside the target folder\n const declarations = project\n .getSourceFiles()\n .filter(sf => isInsideFolder(sf.getFilePath()))\n .flatMap(sf => [\n ...sf.getTypeAliases(),\n ...sf.getInterfaces(),\n ...sf.getVariableDeclarations(),\n ...sf.getFunctions(),\n ...sf.getClasses(),\n ...sf.getEnums(),\n ]);\n\n for (const decl of declarations) {\n if (decl.wasForgotten()) continue;\n\n const nameNode = decl.getNameNode();\n if (!nameNode || !Node.isIdentifier(nameNode)) continue;\n\n const referencedSymbols = nameNode.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (ref.getNode() !== nameNode) {\n refCount++;\n }\n }\n }\n\n if (refCount === 0) {\n decl.remove();\n changed = true;\n break;\n }\n }\n\n if (changed) continue;\n\n // B: Imports inside the target folder\n const importDeclarations = project\n .getSourceFiles()\n .filter(sf => isInsideFolder(sf.getFilePath()))\n .flatMap(sf => sf.getImportDeclarations());\n\n for (const imp of importDeclarations) {\n if (imp.wasForgotten()) continue;\n const sf = imp.getSourceFile();\n\n // 1. Named imports\n const namedImports = imp.getNamedImports();\n for (const spec of namedImports) {\n if (spec.wasForgotten()) continue;\n const nameNode = spec.getNameNode();\n if (!Node.isIdentifier(nameNode)) continue;\n\n const referencedSymbols = nameNode.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== nameNode\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n spec.remove();\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 2. Default import\n const defaultImport = imp.getDefaultImport();\n if (\n defaultImport &&\n !defaultImport.wasForgotten() &&\n Node.isIdentifier(defaultImport)\n ) {\n const referencedSymbols = defaultImport.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== defaultImport\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n const hasNamed = imp.getNamedImports().length > 0;\n const hasNamespace = !!imp.getNamespaceImport();\n if (!hasNamed && !hasNamespace) {\n imp.remove();\n } else {\n imp.removeDefaultImport();\n }\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 3. Namespace import\n const namespaceImport = imp.getNamespaceImport();\n if (\n namespaceImport &&\n !namespaceImport.wasForgotten() &&\n Node.isIdentifier(namespaceImport)\n ) {\n const referencedSymbols = namespaceImport.findReferences();\n let refCount = 0;\n for (const refSymbol of referencedSymbols) {\n for (const ref of refSymbol.getReferences()) {\n if (\n ref.getSourceFile() === sf &&\n ref.getNode() !== namespaceImport\n ) {\n refCount++;\n }\n }\n }\n if (refCount === 0) {\n imp.remove();\n changed = true;\n break;\n }\n }\n if (changed) break;\n\n // 4. Empty import declarations\n const hasNamed = imp.getNamedImports().length > 0;\n const hasDefault = !!imp.getDefaultImport();\n const hasNamespace = !!imp.getNamespaceImport();\n if (!hasNamed && !hasDefault && !hasNamespace) {\n imp.remove();\n changed = true;\n break;\n }\n }\n }\n\n // Save changes\n project.saveSync();\n\n // Delete files that are empty (after trimming whitespace) and inside the target folder\n const sourceFiles = project.getSourceFiles();\n for (const sf of sourceFiles) {\n const filePath = sf.getFilePath();\n if (isInsideFolder(filePath) && sf.getFullText().trim() === '') {\n project.removeSourceFile(sf);\n if (existsSync(filePath)) {\n unlinkSync(filePath);\n }\n }\n }\n\n // Helper to recursively clean empty directories\n const cleanEmptyDirs = (dir: string) => {\n if (!existsSync(dir) || !statSync(dir).isDirectory()) return;\n\n const files = readdirSync(dir);\n for (const file of files) {\n const fullPath = join(dir, file);\n if (statSync(fullPath).isDirectory()) {\n cleanEmptyDirs(fullPath);\n }\n }\n\n const remaining = readdirSync(dir);\n if (remaining.length === 0) {\n rmdirSync(dir);\n }\n };\n\n cleanEmptyDirs(folderPath);\n\n return true;\n};\n"],"mappings":";;;;;AAWA,MAAa,QAAQ,SAAiB;CACpC,MAAM,aAAa,cAAc,IAAI;CACrC,IAAI,CAAC,WAAW,UAAU,GAAG;EAC3B,QAA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QAAQ,MAAM,iBAElB;IAIN,IAAI,aAAa,GAAG;KAClB,IAAI,OAAO;KACX,UAAU;KACV;IACF;GACF;GACA,IAAI,SAAS;GAGb,MAAM,WAAW,IAAI,gBAAgB,CAAC,CAAC,SAAS;GAChD,MAAM,aAAa,CAAC,CAAC,IAAI,iBAAiB;GAC1C,MAAM,eAAe,CAAC,CAAC,IAAI,mBAAmB;GAC9C,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,cAAc;IAC7C,IAAI,OAAO;IACX,UAAU;IACV;GACF;EACF;CACF;CAGA,QAAQ,SAAS;CAGjB,MAAM,cAAc,QAAQ,eAAe;CAC3C,KAAK,MAAM,MAAM,aAAa;EAC5B,MAAM,WAAW,GAAG,YAAY;EAChC,IAAI,eAAe,QAAQ,KAAK,GAAG,YAAY,CAAC,CAAC,KAAK,MAAM,IAAI;GAC9D,QAAQ,iBAAiB,EAAE;GAC3B,IAAI,WAAW,QAAQ,GACrB,WAAW,QAAQ;EAEvB;CACF;CAGA,MAAM,kBAAkB,QAAgB;EACtC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,YAAY,GAAG;EAEtD,MAAM,QAAQ,YAAY,GAAG;EAC7B,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,WAAW,KAAK,KAAK,IAAI;GAC/B,IAAI,SAAS,QAAQ,CAAC,CAAC,YAAY,GACjC,eAAe,QAAQ;EAE3B;EAGA,IADkB,YAAY,GAClB,CAAC,CAAC,WAAW,GACvB,UAAU,GAAG;CAEjB;CAEA,eAAe,UAAU;CAEzB,OAAO;AACT"}
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_constants = require("../constants.cjs");
3
+ const require_helpers = require("../helpers.cjs");
4
+ let path = require("path");
5
+ let fs = require("fs");
6
+ //#region src/functions/softInit.ts
7
+ const softInit = (CODEBASE_ANALYSIS, { root, json, path: path$1 = require_constants.DEFAULT_PATH_KEY, bin = require_constants.DEFAULT_CLI_NAME }) => {
8
+ const cwd = process.cwd();
9
+ if (!(0, fs.existsSync)((0, path.join)(cwd, json))) return false;
10
+ const folderPath = require_helpers.getFolderPath(root);
11
+ if (!(0, fs.existsSync)(folderPath)) return false;
12
+ const tsconfigPath = (0, path.join)(cwd, "tsconfig.json");
13
+ if (!(0, fs.existsSync)(tsconfigPath)) return false;
14
+ const tsconfigContent = (0, fs.readFileSync)(tsconfigPath, "utf8");
15
+ const tsconfig = JSON.parse(tsconfigContent);
16
+ const relativePath = (0, path.relative)(process.cwd(), folderPath);
17
+ if (!(tsconfig?.compilerOptions?.paths?.[path$1]?.[0] === `./${relativePath}/*`)) return false;
18
+ try {
19
+ require_helpers.createTypesStructure(folderPath, CODEBASE_ANALYSIS);
20
+ } catch {
21
+ console.error(`โŒ Error creating the types structure:`);
22
+ return false;
23
+ }
24
+ console.log(`๐ŸŽ‰ ${bin} soft initialization completed successfully!`);
25
+ return true;
26
+ };
27
+ //#endregion
28
+ exports.softInit = softInit;
29
+
30
+ //# sourceMappingURL=softInit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softInit.cjs","names":["DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","getFolderPath","path"],"sources":["../../src/functions/softInit.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { DEFAULT_CLI_NAME, DEFAULT_PATH_KEY } from '../constants';\nimport { createTypesStructure, getFolderPath } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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 softInit = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (!configExists) return false;\n\n const folderPath = getFolderPath(root);\n if (!existsSync(folderPath)) return false;\n\n const tsconfigPath = join(cwd, 'tsconfig.json');\n const tsConfigExists = existsSync(tsconfigPath);\n if (!tsConfigExists) return false;\n\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n const relativePath = relative(process.cwd(), folderPath);\n\n const checkPaths =\n tsconfig?.compilerOptions?.paths?.[path]?.[0] ===\n `./${relativePath}/*`;\n\n if (!checkPaths) return false;\n\n try {\n createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`โŒ Error creating the types structure:`);\n return false;\n }\n\n // 3. Create the .bemedev.json file at the root\n\n console.log(`๐ŸŽ‰ ${bin} soft initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;AAiBA,MAAa,YACX,mBACA,EACE,MACA,MACA,MAAA,SAAOA,kBAAAA,kBACP,MAAMC,kBAAAA,uBAEL;CACH,MAAM,MAAM,QAAQ,IAAI;CAGxB,IAAI,EAAA,GAAA,GAAA,WAAA,EAAA,GAAA,KAAA,KAAA,CAFoB,KAAK,IACY,CACzB,GAAG,OAAO;CAE1B,MAAM,aAAaC,gBAAAA,cAAc,IAAI;CACrC,IAAI,EAAA,GAAA,GAAA,WAAA,CAAY,UAAU,GAAG,OAAO;CAEpC,MAAM,gBAAA,GAAA,KAAA,KAAA,CAAoB,KAAK,eAAe;CAE9C,IAAI,EAAA,GAAA,GAAA,WAAA,CAD8B,YAChB,GAAG,OAAO;CAE5B,MAAM,mBAAA,GAAA,GAAA,aAAA,CAA+B,cAAc,MAAM;CACzD,MAAM,WAAW,KAAK,MAAM,eAAe;CAC3C,MAAM,gBAAA,GAAA,KAAA,SAAA,CAAwB,QAAQ,IAAI,GAAG,UAAU;CAMvD,IAAI,EAHF,UAAU,iBAAiB,QAAQC,OAAK,GAAG,OAC3C,KAAK,aAAa,MAEH,OAAO;CAExB,IAAI;EACF,gBAAA,qBAAqB,YAAY,iBAAiB;CACpD,QAAQ;EACN,QAAQ,MAAM,uCAAuC;EACrD,OAAO;CACT;CAIA,QAAQ,IAAI,MAAM,IAAI,6CAA6C;CACnE,OAAO;AACT"}
@@ -0,0 +1,13 @@
1
+ import { CodebaseAnalysis } from '../schemas';
2
+ export interface InitOptions {
3
+ /**
4
+ * Custom location for the .bemedev folder
5
+ * Default: 'src/.bemedev' if src exists, otherwise '.bemedev' at the root
6
+ */
7
+ root: string;
8
+ json: string;
9
+ path?: string;
10
+ bin?: string;
11
+ }
12
+ export declare const softInit: (CODEBASE_ANALYSIS: CodebaseAnalysis, { root, json, path, bin, }: InitOptions) => boolean;
13
+ //# sourceMappingURL=softInit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softInit.d.ts","sourceRoot":"","sources":["../../src/functions/softInit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,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,QAAQ,GACnB,mBAAmB,gBAAgB,EACnC,4BAKG,WAAW,YAmCf,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { DEFAULT_CLI_NAME, DEFAULT_PATH_KEY } from "../constants.js";
2
+ import { createTypesStructure, getFolderPath } from "../helpers.js";
3
+ import { join, relative } from "path";
4
+ import { existsSync, readFileSync } from "fs";
5
+ //#region src/functions/softInit.ts
6
+ const softInit = (CODEBASE_ANALYSIS, { root, json, path = DEFAULT_PATH_KEY, bin = DEFAULT_CLI_NAME }) => {
7
+ const cwd = process.cwd();
8
+ if (!existsSync(join(cwd, json))) return false;
9
+ const folderPath = getFolderPath(root);
10
+ if (!existsSync(folderPath)) return false;
11
+ const tsconfigPath = join(cwd, "tsconfig.json");
12
+ if (!existsSync(tsconfigPath)) return false;
13
+ const tsconfigContent = readFileSync(tsconfigPath, "utf8");
14
+ const tsconfig = JSON.parse(tsconfigContent);
15
+ const relativePath = relative(process.cwd(), folderPath);
16
+ if (!(tsconfig?.compilerOptions?.paths?.[path]?.[0] === `./${relativePath}/*`)) return false;
17
+ try {
18
+ createTypesStructure(folderPath, CODEBASE_ANALYSIS);
19
+ } catch {
20
+ console.error(`โŒ Error creating the types structure:`);
21
+ return false;
22
+ }
23
+ console.log(`๐ŸŽ‰ ${bin} soft initialization completed successfully!`);
24
+ return true;
25
+ };
26
+ //#endregion
27
+ export { softInit };
28
+
29
+ //# sourceMappingURL=softInit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softInit.js","names":[],"sources":["../../src/functions/softInit.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { DEFAULT_CLI_NAME, DEFAULT_PATH_KEY } from '../constants';\nimport { createTypesStructure, getFolderPath } from '../helpers';\nimport { CodebaseAnalysis } from '../schemas';\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 softInit = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n {\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n }: InitOptions,\n) => {\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (!configExists) return false;\n\n const folderPath = getFolderPath(root);\n if (!existsSync(folderPath)) return false;\n\n const tsconfigPath = join(cwd, 'tsconfig.json');\n const tsConfigExists = existsSync(tsconfigPath);\n if (!tsConfigExists) return false;\n\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n const relativePath = relative(process.cwd(), folderPath);\n\n const checkPaths =\n tsconfig?.compilerOptions?.paths?.[path]?.[0] ===\n `./${relativePath}/*`;\n\n if (!checkPaths) return false;\n\n try {\n createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`โŒ Error creating the types structure:`);\n return false;\n }\n\n // 3. Create the .bemedev.json file at the root\n\n console.log(`๐ŸŽ‰ ${bin} soft initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;AAiBA,MAAa,YACX,mBACA,EACE,MACA,MACA,OAAO,kBACP,MAAM,uBAEL;CACH,MAAM,MAAM,QAAQ,IAAI;CAGxB,IAAI,CADiB,WADF,KAAK,KAAK,IACY,CACzB,GAAG,OAAO;CAE1B,MAAM,aAAa,cAAc,IAAI;CACrC,IAAI,CAAC,WAAW,UAAU,GAAG,OAAO;CAEpC,MAAM,eAAe,KAAK,KAAK,eAAe;CAE9C,IAAI,CADmB,WAAW,YAChB,GAAG,OAAO;CAE5B,MAAM,kBAAkB,aAAa,cAAc,MAAM;CACzD,MAAM,WAAW,KAAK,MAAM,eAAe;CAC3C,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,UAAU;CAMvD,IAAI,EAHF,UAAU,iBAAiB,QAAQ,KAAK,GAAG,OAC3C,KAAK,aAAa,MAEH,OAAO;CAExB,IAAI;EACF,qBAAqB,YAAY,iBAAiB;CACpD,QAAQ;EACN,QAAQ,MAAM,uCAAuC;EACrD,OAAO;CACT;CAIA,QAAQ,IAAI,MAAM,IAAI,6CAA6C;CACnE,OAAO;AACT"}
package/lib/helpers.cjs CHANGED
@@ -41,8 +41,24 @@ const getFolderPath = (root) => {
41
41
  const cwd = process.cwd();
42
42
  return (0, fs.existsSync)((0, path.join)(cwd, "src")) ? (0, path.join)(cwd, "src", root) : (0, path.join)(cwd, root);
43
43
  };
44
+ const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
45
+ const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {
46
+ return key.endsWith("types") || key.endsWith("constants");
47
+ });
48
+ const PATHS = [];
49
+ console.log(`๐Ÿ”ง Creating types structure (${entries.length} files)...`);
50
+ for (const [, fileAnalysis] of entries) try {
51
+ const file = writeFileAnalysis(fileAnalysis, folderPath);
52
+ if (file) PATHS.push(file);
53
+ } catch {
54
+ console.error(`โŒ Error creating the file ${fileAnalysis.relativePath}:`);
55
+ }
56
+ console.log(`โœ… Types structure successfully created!`);
57
+ return PATHS;
58
+ };
44
59
  //#endregion
45
60
  exports.consoleStars = consoleStars;
61
+ exports.createTypesStructure = createTypesStructure;
46
62
  exports.getFolderPath = getFolderPath;
47
63
  exports.pathToJsonKey = pathToJsonKey;
48
64
  exports.toArray = toArray;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { dirname, join, relative, resolve, parse } from '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 );\n\n return out;\n};\n\nexport const pathToJsonKey = (relativePath: string, name: string) => {\n const parts = relativePath.split('/');\n parts.pop();\n parts.push(name);\n return parts.join('/');\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in root maintaining the structure\n const destPath = join(folderPath, relativePath);\n const parsed = parse(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(parsed.dir, { recursive: true });\n let fileContent = fileAnalysis.text;\n\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 console.log(` โœ… ${relativePath}`);\n return pathToJsonKey(relativePath, parsed.name);\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,CAGvC;AACX;AAEA,MAAa,iBAAiB,cAAsB,SAAiB;CACnE,MAAM,QAAQ,aAAa,MAAM,GAAG;CACpC,MAAM,IAAI;CACV,MAAM,KAAK,IAAI;CACf,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAElC,MAAM,YAAA,GAAA,KAAA,KAAA,CAAgB,YAAY,YAAY;CAC9C,MAAM,UAAA,GAAA,KAAA,MAAA,CAAe,QAAQ;CAE7B,IAAI;EAEF,CAAA,GAAA,GAAA,UAAA,CAAU,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;EACzC,IAAI,cAAc,aAAa;EAE/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;EAC3C,QAAQ,IAAI,OAAO,cAAc;EACjC,OAAO,cAAc,cAAc,OAAO,IAAI;CAChD,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"}
1
+ {"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { dirname, join, relative, resolve, parse } from 'path';\nimport { REPLACERS } from './constants';\nimport { FileAnalysis, type CodebaseAnalysis } 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 );\n\n return out;\n};\n\nexport const pathToJsonKey = (relativePath: string, name: string) => {\n const parts = relativePath.split('/');\n parts.pop();\n parts.push(name);\n return parts.join('/');\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in root maintaining the structure\n const destPath = join(folderPath, relativePath);\n const parsed = parse(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(parsed.dir, { recursive: true });\n let fileContent = fileAnalysis.text;\n\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 console.log(` โœ… ${relativePath}`);\n return pathToJsonKey(relativePath, parsed.name);\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\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 try {\n const file = writeFileAnalysis(fileAnalysis, folderPath);\n if (file) PATHS.push(file);\n } catch {\n console.error(\n `โŒ Error creating the file ${fileAnalysis.relativePath}:`,\n );\n }\n }\n\n console.log(`โœ… Types structure successfully created!`);\n return PATHS;\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,CAGvC;AACX;AAEA,MAAa,iBAAiB,cAAsB,SAAiB;CACnE,MAAM,QAAQ,aAAa,MAAM,GAAG;CACpC,MAAM,IAAI;CACV,MAAM,KAAK,IAAI;CACf,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAElC,MA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,iBAAiB,SAC7B,IAAI;EACF,MAAM,OAAO,kBAAkB,cAAc,UAAU;EACvD,IAAI,MAAM,MAAM,KAAK,IAAI;CAC3B,QAAQ;EACN,QAAQ,MACN,6BAA6B,aAAa,aAAa,EACzD;CACF;CAGF,QAAQ,IAAI,yCAAyC;CACrD,OAAO;AACT"}
package/lib/helpers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FileAnalysis } from './schemas';
1
+ import { FileAnalysis, type CodebaseAnalysis } from './schemas';
2
2
  export type TransformModuleArgs = {
3
3
  cwd?: string;
4
4
  relativePath: string;
@@ -10,4 +10,5 @@ export declare const writeFileAnalysis: (fileAnalysis: FileAnalysis, folderPath:
10
10
  export declare const consoleStars: () => void;
11
11
  export declare const toArray: <T>(value?: T | T[]) => T[];
12
12
  export declare const getFolderPath: (root: string) => string;
13
+ export declare const createTypesStructure: (folderPath: string, CODEBASE_ANALYSIS: CodebaseAnalysis) => string[];
13
14
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +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,aAAa,GAAI,cAAc,MAAM,EAAE,MAAM,MAAM,WAK/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,YAAY,MAAM,kBAuBnB,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"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEhE,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,aAAa,GAAI,cAAc,MAAM,EAAE,MAAM,MAAM,WAK/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,YAAY,MAAM,kBAuBnB,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;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,MAAM,EAClB,mBAAmB,gBAAgB,aAyBpC,CAAC"}
package/lib/helpers.js CHANGED
@@ -40,7 +40,22 @@ const getFolderPath = (root) => {
40
40
  const cwd = process.cwd();
41
41
  return existsSync(join(cwd, "src")) ? join(cwd, "src", root) : join(cwd, root);
42
42
  };
43
+ const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
44
+ const entries = Object.entries(CODEBASE_ANALYSIS).filter(([key]) => {
45
+ return key.endsWith("types") || key.endsWith("constants");
46
+ });
47
+ const PATHS = [];
48
+ console.log(`๐Ÿ”ง Creating types structure (${entries.length} files)...`);
49
+ for (const [, fileAnalysis] of entries) try {
50
+ const file = writeFileAnalysis(fileAnalysis, folderPath);
51
+ if (file) PATHS.push(file);
52
+ } catch {
53
+ console.error(`โŒ Error creating the file ${fileAnalysis.relativePath}:`);
54
+ }
55
+ console.log(`โœ… Types structure successfully created!`);
56
+ return PATHS;
57
+ };
43
58
  //#endregion
44
- export { consoleStars, getFolderPath, pathToJsonKey, toArray, transformModule, writeFileAnalysis };
59
+ export { consoleStars, createTypesStructure, getFolderPath, pathToJsonKey, toArray, transformModule, writeFileAnalysis };
45
60
 
46
61
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { dirname, join, relative, resolve, parse } from '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 );\n\n return out;\n};\n\nexport const pathToJsonKey = (relativePath: string, name: string) => {\n const parts = relativePath.split('/');\n parts.pop();\n parts.push(name);\n return parts.join('/');\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in root maintaining the structure\n const destPath = join(folderPath, relativePath);\n const parsed = parse(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(parsed.dir, { recursive: true });\n let fileContent = fileAnalysis.text;\n\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 console.log(` โœ… ${relativePath}`);\n return pathToJsonKey(relativePath, parsed.name);\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,OALY,SACV,KACA,QAAQ,QAAQ,YAAY,GAAG,eAAe,CAGvC;AACX;AAEA,MAAa,iBAAiB,cAAsB,SAAiB;CACnE,MAAM,QAAQ,aAAa,MAAM,GAAG;CACpC,MAAM,IAAI;CACV,MAAM,KAAK,IAAI;CACf,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAElC,MAAM,WAAW,KAAK,YAAY,YAAY;CAC9C,MAAM,SAAS,MAAM,QAAQ;CAE7B,IAAI;EAEF,UAAU,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;EACzC,IAAI,cAAc,aAAa;EAE/B,UAAU,KAAK,SAAS,CAAC,QAAQ,aAAa;GAC5C,cAAc,YAAY,WAAW,QAAQ,OAAO;EACtD,CAAC;EAGD,cAAc,UAAU,aAAa,MAAM;EAC3C,QAAQ,IAAI,OAAO,cAAc;EACjC,OAAO,cAAc,cAAc,OAAO,IAAI;CAChD,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,OALkB,WAAW,KAAK,KAAK,KAAK,CACjB,IACvB,KAAK,KAAK,OAAO,IAAI,IACrB,KAAK,KAAK,IAAI;AAGpB"}
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { dirname, join, relative, resolve, parse } from 'path';\nimport { REPLACERS } from './constants';\nimport { FileAnalysis, type CodebaseAnalysis } 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 );\n\n return out;\n};\n\nexport const pathToJsonKey = (relativePath: string, name: string) => {\n const parts = relativePath.split('/');\n parts.pop();\n parts.push(name);\n return parts.join('/');\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in root maintaining the structure\n const destPath = join(folderPath, relativePath);\n const parsed = parse(destPath);\n\n try {\n // Create the destination folder if necessary\n mkdirSync(parsed.dir, { recursive: true });\n let fileContent = fileAnalysis.text;\n\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 console.log(` โœ… ${relativePath}`);\n return pathToJsonKey(relativePath, parsed.name);\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\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 try {\n const file = writeFileAnalysis(fileAnalysis, folderPath);\n if (file) PATHS.push(file);\n } catch {\n console.error(\n `โŒ Error creating the file ${fileAnalysis.relativePath}:`,\n );\n }\n }\n\n console.log(`โœ… Types structure successfully created!`);\n return PATHS;\n};\n"],"mappings":";;;;AAWA,MAAa,mBAAmB,EAC9B,MAAM,QAAQ,IAAI,GAClB,cACA,sBACyB;CAMzB,OALY,SACV,KACA,QAAQ,QAAQ,YAAY,GAAG,eAAe,CAGvC;AACX;AAEA,MAAa,iBAAiB,cAAsB,SAAiB;CACnE,MAAM,QAAQ,aAAa,MAAM,GAAG;CACpC,MAAM,IAAI;CACV,MAAM,KAAK,IAAI;CACf,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;CAElC,MAAM,WAAW,KAAK,YAAY,YAAY;CAC9C,MAAM,SAAS,MAAM,QAAQ;CAE7B,IAAI;EAEF,UAAU,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;EACzC,IAAI,cAAc,aAAa;EAE/B,UAAU,KAAK,SAAS,CAAC,QAAQ,aAAa;GAC5C,cAAc,YAAY,WAAW,QAAQ,OAAO;EACtD,CAAC;EAGD,cAAc,UAAU,aAAa,MAAM;EAC3C,QAAQ,IAAI,OAAO,cAAc;EACjC,OAAO,cAAc,cAAc,OAAO,IAAI;CAChD,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,OALkB,WAAW,KAAK,KAAK,KAAK,CACjB,IACvB,KAAK,KAAK,OAAO,IAAI,IACrB,KAAK,KAAK,IAAI;AAGpB;AAEA,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,CAAC;CAEzB,QAAQ,IACN,gCAAgC,QAAQ,OAAO,WACjD;CAEA,KAAK,MAAM,GAAG,iBAAiB,SAC7B,IAAI;EACF,MAAM,OAAO,kBAAkB,cAAc,UAAU;EACvD,IAAI,MAAM,MAAM,KAAK,IAAI;CAC3B,QAAQ;EACN,QAAQ,MACN,6BAA6B,aAAa,aAAa,EACzD;CACF;CAGF,QAAQ,IAAI,yCAAyC;CACrD,OAAO;AACT"}
package/lib/index.cjs CHANGED
@@ -5,6 +5,7 @@ const require_analyse = require("./analyse.cjs");
5
5
  const require_functions_add = require("./functions/add.cjs");
6
6
  const require_functions_generate = require("./functions/generate.cjs");
7
7
  const require_functions_init = require("./functions/init.cjs");
8
+ const require_functions_lift = require("./functions/lift.cjs");
8
9
  const require_functions_remove = require("./functions/remove.cjs");
9
10
  require("./functions/index.cjs");
10
11
  exports.AnalysisStatsSchema = require_schemas.AnalysisStatsSchema;
@@ -17,9 +18,9 @@ exports.ImportInfoSchema = require_schemas.ImportInfoSchema;
17
18
  exports.add = require_functions_add.add;
18
19
  exports.analyze = require_analyse.analyze;
19
20
  exports.consoleStars = require_helpers.consoleStars;
20
- exports.createTypesStructure = require_functions_init.createTypesStructure;
21
21
  exports.generate = require_functions_generate.generate;
22
22
  exports.getFolderPath = require_helpers.getFolderPath;
23
23
  exports.init = require_functions_init.init;
24
+ exports.lift = require_functions_lift.lift;
24
25
  exports.remove = require_functions_remove.remove;
25
26
  exports.transformJSON = require_functions_generate.transformJSON;
package/lib/index.js CHANGED
@@ -3,7 +3,8 @@ import { consoleStars, getFolderPath } from "./helpers.js";
3
3
  import { analyze } from "./analyse.js";
4
4
  import { add } from "./functions/add.js";
5
5
  import { generate, transformJSON } from "./functions/generate.js";
6
- import { createTypesStructure, init } from "./functions/init.js";
6
+ import { init } from "./functions/init.js";
7
+ import { lift } from "./functions/lift.js";
7
8
  import { remove } from "./functions/remove.js";
8
9
  import "./functions/index.js";
9
- export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, consoleStars, createTypesStructure, generate, getFolderPath, init, remove, transformJSON };
10
+ export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, consoleStars, generate, getFolderPath, init, lift, remove, transformJSON };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/codebase",
3
- "version": "1.3.0",
3
+ "version": "1.4.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",
@@ -72,7 +72,7 @@
72
72
  }
73
73
  ],
74
74
  "devDependencies": {
75
- "@bemedev/dev-utils": "^0.8.2",
75
+ "@bemedev/dev-utils": "^0.8.3",
76
76
  "@size-limit/file": "^12.1.0",
77
77
  "@types/node": "^26.0.1",
78
78
  "rolldown": "1.1.3",