@bemedev/codebase 1.6.0 → 1.7.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
@@ -94,7 +94,7 @@ configurations and selectively add/remove files using their regular
94
94
  slash-separated paths (instead of dot-parsed notation).
95
95
 
96
96
  ```typescript
97
- import { init, add, remove } from '@bemedev/codebase';
97
+ import { init, softInit, add, remove } from '@bemedev/codebase';
98
98
  import analysis from './codebase.json';
99
99
 
100
100
  // Initialize the project workspace
@@ -103,6 +103,12 @@ init(analysis.CODEBASE_ANALYSIS, {
103
103
  json: '.project-codebase.json',
104
104
  });
105
105
 
106
+ // Rebuild types and imports structure if configuration already exists
107
+ softInit(analysis.CODEBASE_ANALYSIS, {
108
+ root: 'my-project-src',
109
+ json: '.project-codebase.json',
110
+ });
111
+
106
112
  // Add files dynamically using regular slash-separated paths
107
113
  add(
108
114
  analysis.CODEBASE_ANALYSIS,
@@ -3,10 +3,12 @@ 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
5
  const require_functions_lift = require("./lift.cjs");
6
+ const require_functions_softInit = require("./softInit.cjs");
6
7
  const require_functions_remove = require("./remove.cjs");
7
8
  exports.add = require_functions_add.add;
8
9
  exports.generate = require_functions_generate.generate;
9
10
  exports.init = require_functions_init.init;
10
11
  exports.lift = require_functions_lift.lift;
11
12
  exports.remove = require_functions_remove.remove;
13
+ exports.softInit = require_functions_softInit.softInit;
12
14
  exports.transformJSON = require_functions_generate.transformJSON;
@@ -2,5 +2,6 @@ export * from './add';
2
2
  export * from './generate';
3
3
  export * from './init';
4
4
  export * from './lift';
5
+ export * from './softInit';
5
6
  export * from './remove';
6
7
  //# 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,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,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -2,5 +2,6 @@ import { add } from "./add.js";
2
2
  import { generate, transformJSON } from "./generate.js";
3
3
  import { init } from "./init.js";
4
4
  import { lift } from "./lift.js";
5
+ import { softInit } from "./softInit.js";
5
6
  import { remove } from "./remove.js";
6
- export { add, generate, init, lift, remove, transformJSON };
7
+ export { add, generate, init, lift, remove, softInit, transformJSON };
@@ -1 +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"}
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';\nimport type { InitOptions } from './init';\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":";;;;;;AAOA,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"}
@@ -1,13 +1,4 @@
1
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
- }
2
+ import type { InitOptions } from './init';
12
3
  export declare const softInit: (CODEBASE_ANALYSIS: CodebaseAnalysis, { root, json, path, bin, }: InitOptions) => boolean;
13
4
  //# sourceMappingURL=softInit.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"softInit.d.ts","sourceRoot":"","sources":["../../src/functions/softInit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,eAAO,MAAM,QAAQ,GACnB,mBAAmB,gBAAgB,EACnC,4BAKG,WAAW,YAmCf,CAAC"}
@@ -1 +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"}
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';\nimport type { InitOptions } from './init';\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":";;;;;AAOA,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/index.cjs CHANGED
@@ -6,6 +6,7 @@ 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
8
  const require_functions_lift = require("./functions/lift.cjs");
9
+ const require_functions_softInit = require("./functions/softInit.cjs");
9
10
  const require_functions_remove = require("./functions/remove.cjs");
10
11
  require("./functions/index.cjs");
11
12
  exports.AnalysisStatsSchema = require_schemas.AnalysisStatsSchema;
@@ -23,4 +24,5 @@ exports.getFolderPath = require_helpers.getFolderPath;
23
24
  exports.init = require_functions_init.init;
24
25
  exports.lift = require_functions_lift.lift;
25
26
  exports.remove = require_functions_remove.remove;
27
+ exports.softInit = require_functions_softInit.softInit;
26
28
  exports.transformJSON = require_functions_generate.transformJSON;
package/lib/index.js CHANGED
@@ -5,6 +5,7 @@ import { add } from "./functions/add.js";
5
5
  import { generate, transformJSON } from "./functions/generate.js";
6
6
  import { init } from "./functions/init.js";
7
7
  import { lift } from "./functions/lift.js";
8
+ import { softInit } from "./functions/softInit.js";
8
9
  import { remove } from "./functions/remove.js";
9
10
  import "./functions/index.js";
10
- export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, consoleStars, generate, getFolderPath, init, lift, remove, transformJSON };
11
+ export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, consoleStars, generate, getFolderPath, init, lift, remove, softInit, transformJSON };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/codebase",
3
- "version": "1.6.0",
3
+ "version": "1.7.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",