@bemedev/codebase 1.5.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 +7 -1
- package/lib/functions/add.cjs +2 -2
- package/lib/functions/add.cjs.map +1 -1
- package/lib/functions/add.d.ts.map +1 -1
- package/lib/functions/add.js +2 -2
- package/lib/functions/add.js.map +1 -1
- package/lib/functions/index.cjs +2 -0
- package/lib/functions/index.d.ts +1 -0
- package/lib/functions/index.d.ts.map +1 -1
- package/lib/functions/index.js +2 -1
- package/lib/functions/remove.cjs +1 -1
- package/lib/functions/remove.cjs.map +1 -1
- package/lib/functions/remove.js +1 -1
- package/lib/functions/remove.js.map +1 -1
- package/lib/functions/softInit.cjs.map +1 -1
- package/lib/functions/softInit.d.ts +1 -10
- package/lib/functions/softInit.d.ts.map +1 -1
- package/lib/functions/softInit.js.map +1 -1
- package/lib/index.cjs +2 -0
- package/lib/index.js +2 -1
- package/package.json +1 -1
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,
|
package/lib/functions/add.cjs
CHANGED
|
@@ -13,7 +13,7 @@ const processFileAnalysis = (analysis, cwd, additionals, pathsEntries, files, CO
|
|
|
13
13
|
const _path = (0, path.relative)(cwd, (0, path.resolve)((0, path.dirname)(relativePath), moduleSpecifier));
|
|
14
14
|
const all = additionals.concat(pathsEntries).map(([key]) => key).concat(files);
|
|
15
15
|
if (!all.every((p) => p !== _path)) return;
|
|
16
|
-
const toAdd = CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}
|
|
16
|
+
const toAdd = CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}/index`];
|
|
17
17
|
if (!toAdd) return;
|
|
18
18
|
additionals.push([_path, toAdd]);
|
|
19
19
|
all.push(_path);
|
|
@@ -23,7 +23,7 @@ const processFileAnalysis = (analysis, cwd, additionals, pathsEntries, files, CO
|
|
|
23
23
|
relativePath: toAdd.relativePath,
|
|
24
24
|
moduleSpecifier
|
|
25
25
|
});
|
|
26
|
-
const array = [_path, `${_path}
|
|
26
|
+
const array = [_path, `${_path}/index`].filter((p) => keys.includes(p));
|
|
27
27
|
if (array.length < 1) return false;
|
|
28
28
|
return array.every((p) => !all.includes(p));
|
|
29
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.cjs","names":["transformModule","FILES_PROPERTY","getFolderPath","PATH_PROPERTY","writeFileAnalysis"],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { type JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n writeFileAnalysis,\n} from '../helpers';\nimport { CodebaseAnalysis, type FileAnalysis } from '../schemas';\nimport type { NOmit } from '../types';\n\nconst processFileAnalysis = (\n analysis: NOmit<FileAnalysis, 'exports'>,\n cwd: string,\n additionals: [string, NOmit<FileAnalysis, 'exports'>][],\n pathsEntries: [string, NOmit<FileAnalysis, 'exports'>][],\n files: string[],\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const relativePath = analysis.relativePath;\n\n const keys = Object.keys(CODEBASE_ANALYSIS);\n analysis.imports.forEach(({ moduleSpecifier }) => {\n const _path = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n );\n\n const all = additionals\n .concat(pathsEntries)\n .map(([key]) => key)\n .concat(files);\n\n const canAdd = all.every(p => p !== _path);\n if (!canAdd) return;\n\n const toAdd =\n CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}
|
|
1
|
+
{"version":3,"file":"add.cjs","names":["transformModule","FILES_PROPERTY","getFolderPath","PATH_PROPERTY","writeFileAnalysis"],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { type JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n writeFileAnalysis,\n} from '../helpers';\nimport { CodebaseAnalysis, type FileAnalysis } from '../schemas';\nimport type { NOmit } from '../types';\n\nconst processFileAnalysis = (\n analysis: NOmit<FileAnalysis, 'exports'>,\n cwd: string,\n additionals: [string, NOmit<FileAnalysis, 'exports'>][],\n pathsEntries: [string, NOmit<FileAnalysis, 'exports'>][],\n files: string[],\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const relativePath = analysis.relativePath;\n\n const keys = Object.keys(CODEBASE_ANALYSIS);\n analysis.imports.forEach(({ moduleSpecifier }) => {\n const _path = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n );\n\n const all = additionals\n .concat(pathsEntries)\n .map(([key]) => key)\n .concat(files);\n\n const canAdd = all.every(p => p !== _path);\n if (!canAdd) return;\n\n const toAdd =\n CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}/index`];\n if (!toAdd) return;\n\n additionals.push([_path, toAdd]);\n all.push(_path);\n\n const imports = toAdd.imports.filter(({ moduleSpecifier }) => {\n const _path = transformModule({\n cwd,\n relativePath: toAdd.relativePath,\n moduleSpecifier,\n });\n\n const array = [_path, `${_path}/index`].filter(p =>\n keys.includes(p),\n );\n\n if (array.length < 1) return false;\n return array.every(p => !all.includes(p));\n });\n\n const toAdd2 = { ...toAdd, imports };\n const canRecurse = toAdd2.imports.length > 0;\n\n if (canRecurse) {\n processFileAnalysis(\n toAdd2,\n cwd,\n additionals,\n pathsEntries,\n files,\n CODEBASE_ANALYSIS,\n );\n }\n });\n};\n\nexport const add = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n jsonConfigPath: string,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for addition.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, jsonConfigPath);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const files = file.get(FILES_PROPERTY) as string[];\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n\n // Release resources\n\n const additionals: [string, NOmit<FileAnalysis, 'exports'>][] = [];\n\n const pathsEntries = Object.entries(CODEBASE_ANALYSIS)\n .filter(([key]) => paths.some(p => key.startsWith(p)))\n .filter(([key]) => !files.includes(key));\n\n pathsEntries.forEach(([, analysis]) => {\n processFileAnalysis(\n analysis,\n cwd,\n additionals,\n pathsEntries,\n files,\n CODEBASE_ANALYSIS,\n );\n });\n\n const entries = new Set(\n pathsEntries.concat(additionals).filter(([, val]) => !!val),\n );\n\n consoleStars();\n console.log(`🔧 Creation of files (${entries.size} files)...`);\n\n let success = 0;\n const length = entries.size;\n\n entries.forEach(([, fileAnalysis]) => {\n const _path = writeFileAnalysis(fileAnalysis, root);\n if (_path) {\n files.push(_path);\n success++;\n }\n });\n\n file.set(FILES_PROPERTY, files);\n file.save();\n console.log(`✅ Files created! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error during file creation`);\n return false;\n }\n\n conso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
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/functions/add.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,YAAY,CAAC;AAkEjE,eAAO,MAAM,GAAG,GACd,mBAAmB,gBAAgB,EACnC,gBAAgB,MAAM,EACtB,GAAG,OAAO,MAAM,EAAE,mBA8DnB,CAAC"}
|
package/lib/functions/add.js
CHANGED
|
@@ -10,7 +10,7 @@ const processFileAnalysis = (analysis, cwd, additionals, pathsEntries, files, CO
|
|
|
10
10
|
const _path = relative(cwd, resolve(dirname(relativePath), moduleSpecifier));
|
|
11
11
|
const all = additionals.concat(pathsEntries).map(([key]) => key).concat(files);
|
|
12
12
|
if (!all.every((p) => p !== _path)) return;
|
|
13
|
-
const toAdd = CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}
|
|
13
|
+
const toAdd = CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}/index`];
|
|
14
14
|
if (!toAdd) return;
|
|
15
15
|
additionals.push([_path, toAdd]);
|
|
16
16
|
all.push(_path);
|
|
@@ -20,7 +20,7 @@ const processFileAnalysis = (analysis, cwd, additionals, pathsEntries, files, CO
|
|
|
20
20
|
relativePath: toAdd.relativePath,
|
|
21
21
|
moduleSpecifier
|
|
22
22
|
});
|
|
23
|
-
const array = [_path, `${_path}
|
|
23
|
+
const array = [_path, `${_path}/index`].filter((p) => keys.includes(p));
|
|
24
24
|
if (array.length < 1) return false;
|
|
25
25
|
return array.every((p) => !all.includes(p));
|
|
26
26
|
});
|
package/lib/functions/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","names":[],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { type JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n writeFileAnalysis,\n} from '../helpers';\nimport { CodebaseAnalysis, type FileAnalysis } from '../schemas';\nimport type { NOmit } from '../types';\n\nconst processFileAnalysis = (\n analysis: NOmit<FileAnalysis, 'exports'>,\n cwd: string,\n additionals: [string, NOmit<FileAnalysis, 'exports'>][],\n pathsEntries: [string, NOmit<FileAnalysis, 'exports'>][],\n files: string[],\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const relativePath = analysis.relativePath;\n\n const keys = Object.keys(CODEBASE_ANALYSIS);\n analysis.imports.forEach(({ moduleSpecifier }) => {\n const _path = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n );\n\n const all = additionals\n .concat(pathsEntries)\n .map(([key]) => key)\n .concat(files);\n\n const canAdd = all.every(p => p !== _path);\n if (!canAdd) return;\n\n const toAdd =\n CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}
|
|
1
|
+
{"version":3,"file":"add.js","names":[],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { type JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n writeFileAnalysis,\n} from '../helpers';\nimport { CodebaseAnalysis, type FileAnalysis } from '../schemas';\nimport type { NOmit } from '../types';\n\nconst processFileAnalysis = (\n analysis: NOmit<FileAnalysis, 'exports'>,\n cwd: string,\n additionals: [string, NOmit<FileAnalysis, 'exports'>][],\n pathsEntries: [string, NOmit<FileAnalysis, 'exports'>][],\n files: string[],\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n) => {\n const relativePath = analysis.relativePath;\n\n const keys = Object.keys(CODEBASE_ANALYSIS);\n analysis.imports.forEach(({ moduleSpecifier }) => {\n const _path = relative(\n cwd,\n resolve(dirname(relativePath), moduleSpecifier),\n );\n\n const all = additionals\n .concat(pathsEntries)\n .map(([key]) => key)\n .concat(files);\n\n const canAdd = all.every(p => p !== _path);\n if (!canAdd) return;\n\n const toAdd =\n CODEBASE_ANALYSIS[_path] ?? CODEBASE_ANALYSIS[`${_path}/index`];\n if (!toAdd) return;\n\n additionals.push([_path, toAdd]);\n all.push(_path);\n\n const imports = toAdd.imports.filter(({ moduleSpecifier }) => {\n const _path = transformModule({\n cwd,\n relativePath: toAdd.relativePath,\n moduleSpecifier,\n });\n\n const array = [_path, `${_path}/index`].filter(p =>\n keys.includes(p),\n );\n\n if (array.length < 1) return false;\n return array.every(p => !all.includes(p));\n });\n\n const toAdd2 = { ...toAdd, imports };\n const canRecurse = toAdd2.imports.length > 0;\n\n if (canRecurse) {\n processFileAnalysis(\n toAdd2,\n cwd,\n additionals,\n pathsEntries,\n files,\n CODEBASE_ANALYSIS,\n );\n }\n });\n};\n\nexport const add = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n jsonConfigPath: string,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for addition.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, jsonConfigPath);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const files = file.get(FILES_PROPERTY) as string[];\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n\n // Release resources\n\n const additionals: [string, NOmit<FileAnalysis, 'exports'>][] = [];\n\n const pathsEntries = Object.entries(CODEBASE_ANALYSIS)\n .filter(([key]) => paths.some(p => key.startsWith(p)))\n .filter(([key]) => !files.includes(key));\n\n pathsEntries.forEach(([, analysis]) => {\n processFileAnalysis(\n analysis,\n cwd,\n additionals,\n pathsEntries,\n files,\n CODEBASE_ANALYSIS,\n );\n });\n\n const entries = new Set(\n pathsEntries.concat(additionals).filter(([, val]) => !!val),\n );\n\n consoleStars();\n console.log(`🔧 Creation of files (${entries.size} files)...`);\n\n let success = 0;\n const length = entries.size;\n\n entries.forEach(([, fileAnalysis]) => {\n const _path = writeFileAnalysis(fileAnalysis, root);\n if (_path) {\n files.push(_path);\n success++;\n }\n });\n\n file.set(FILES_PROPERTY, files);\n file.save();\n console.log(`✅ Files created! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error during file creation`);\n return false;\n }\n\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;AAYA,MAAM,uBACJ,UACA,KACA,aACA,cACA,OACA,sBACG;CACH,MAAM,eAAe,SAAS;CAE9B,MAAM,OAAO,OAAO,KAAK,iBAAiB;CAC1C,SAAS,QAAQ,SAAS,EAAE,sBAAsB;EAChD,MAAM,QAAQ,SACZ,KACA,QAAQ,QAAQ,YAAY,GAAG,eAAe,CAChD;EAEA,MAAM,MAAM,YACT,OAAO,YAAY,CAAC,CACpB,KAAK,CAAC,SAAS,GAAG,CAAC,CACnB,OAAO,KAAK;EAGf,IAAI,CADW,IAAI,OAAM,MAAK,MAAM,KAC1B,GAAG;EAEb,MAAM,QACJ,kBAAkB,UAAU,kBAAkB,GAAG,MAAM;EACzD,IAAI,CAAC,OAAO;EAEZ,YAAY,KAAK,CAAC,OAAO,KAAK,CAAC;EAC/B,IAAI,KAAK,KAAK;EAEd,MAAM,UAAU,MAAM,QAAQ,QAAQ,EAAE,sBAAsB;GAC5D,MAAM,QAAQ,gBAAgB;IAC5B;IACA,cAAc,MAAM;IACpB;GACF,CAAC;GAED,MAAM,QAAQ,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,QAAO,MAC7C,KAAK,SAAS,CAAC,CACjB;GAEA,IAAI,MAAM,SAAS,GAAG,OAAO;GAC7B,OAAO,MAAM,OAAM,MAAK,CAAC,IAAI,SAAS,CAAC,CAAC;EAC1C,CAAC;EAED,MAAM,SAAS;GAAE,GAAG;GAAO;EAAQ;EAGnC,IAFmB,OAAO,QAAQ,SAAS,GAGzC,oBACE,QACA,KACA,aACA,cACA,OACA,iBACF;CAEJ,CAAC;AACH;AAEA,MAAa,OACX,mBACA,gBACA,GAAG,UACA;CAEH,IADgB,MAAM,WAAW,GACpB,OAAO,QAAQ,KAAK,kCAAkC;CACnE,IAAI;EACF,MAAM,MAAM,QAAQ,IAAI;EAExB,IAAI,OAA+B,KADtB,KAAK,KAAK,cACoB,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,QAAQ,KAAK,IAAI,cAAc;EACrC,MAAM,OAAO,cAAc,KAAK,IAAI,aAAa,CAAW;EAI5D,MAAM,cAA0D,CAAC;EAEjE,MAAM,eAAe,OAAO,QAAQ,iBAAiB,CAAC,CACnD,QAAQ,CAAC,SAAS,MAAM,MAAK,MAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CACrD,QAAQ,CAAC,SAAS,CAAC,MAAM,SAAS,GAAG,CAAC;EAEzC,aAAa,SAAS,GAAG,cAAc;GACrC,oBACE,UACA,KACA,aACA,cACA,OACA,iBACF;EACF,CAAC;EAED,MAAM,UAAU,IAAI,IAClB,aAAa,OAAO,WAAW,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,GAAG,CAC5D;EAEA,aAAa;EACb,QAAQ,IAAI,yBAAyB,QAAQ,KAAK,WAAW;EAE7D,IAAI,UAAU;EACd,MAAM,SAAS,QAAQ;EAEvB,QAAQ,SAAS,GAAG,kBAAkB;GACpC,MAAM,QAAQ,kBAAkB,cAAc,IAAI;GAClD,IAAI,OAAO;IACT,MAAM,KAAK,KAAK;IAChB;GACF;EACF,CAAC;EAED,KAAK,IAAI,gBAAgB,KAAK;EAC9B,KAAK,KAAK;EACV,QAAQ,IAAI,qBAAqB,QAAQ,GAAG,OAAO,EAAE;EACrD,OAAO,KAAA;CACT,QAAQ;EACN,QAAQ,MAAM,8BAA8B;EAC5C,OAAO;CACT;CAEA,aAAa;CACb,OAAO;AACT"}
|
package/lib/functions/index.cjs
CHANGED
|
@@ -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;
|
package/lib/functions/index.d.ts
CHANGED
|
@@ -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"}
|
package/lib/functions/index.js
CHANGED
|
@@ -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 };
|
package/lib/functions/remove.cjs
CHANGED
|
@@ -20,7 +20,7 @@ const transformModules = (entries, ...files) => {
|
|
|
20
20
|
relativePath,
|
|
21
21
|
moduleSpecifier
|
|
22
22
|
});
|
|
23
|
-
}).map((_path) => [_path, `${_path}
|
|
23
|
+
}).map((_path) => [_path, `${_path}/index`]).flat().filter((s) => files.includes(s));
|
|
24
24
|
return [key, Array.from(new Set(specifiers))];
|
|
25
25
|
});
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.cjs","names":["transformModule","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport { consoleStars, getFolderPath, transformModule } from '#helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}
|
|
1
|
+
{"version":3,"file":"remove.cjs","names":["transformModule","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport { consoleStars, getFolderPath, transformModule } from '#helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}/index`]) // Add */index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n jsonConfigPath: string,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, jsonConfigPath);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Deletion of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} imported by:`);\n modules.forEach(m => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('❌ No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path = CODEBASE_ANALYSIS[key].relativePath;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter(key1 => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Error, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Files deleted! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error while deleting files`);\n consoleStars();\n return false;\n }\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;GAC5B,OAAOA,gBAAAA,gBAAgB;IACrB;IACA;IACA;GACF,CAAC;EACH,CAAC,CAAC,CACD,KAAI,UAAS,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,CACvC,KAAK,CAAC,CACN,QAAO,MAAK,MAAM,SAAS,CAAC,CAAC;EAEhC,OAAO,CAAC,KAAK,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC,CAAC;CAC9C,CAEO;AACX;AAEA,MAAa,UACX,mBACA,gBACA,GAAG,UACA;CAEH,IADgB,MAAM,WAAW,GACpB,OAAO,QAAQ,KAAK,iCAAiC;CAClE,IAAI;EAGF,IAAI,QAAA,GAAA,eAAA,QAAA,EAAA,GAAA,KAAA,KAAA,CAFQ,QAAQ,IACA,GAAG,cACoB,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,OAAOC,gBAAAA,cAAc,KAAK,IAAIC,kBAAAA,aAAa,CAAW;EAC5D,MAAM,QAAQ,K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B,CAAC;EAED,QAAQ,IAAI,uBAAuB,cAAc,OAAO,WAAW;EAEnE,IAAI,UAAU;EACd,MAAM,SAAS,WAAW;EAE1B,WAAW,SAAS,CAAC,KAAKC,YAAU;GAClC,IAAI;IACF,CAAA,GAAA,GAAA,WAAA,CAAWA,MAAI;IACf,QAAQ,IAAI,WAAW,KAAK;IAC5B,MAAM,IACJF,kBAAAA,gBACA,MAAM,QAAO,SAAQ,SAAS,GAAG,CACnC;IACA;GACF,QAAQ;IACN,QAAQ,MAAM,gBAAgB,IAAI,GAAG;GACvC;EACF,CAAC;EAED,KAAK,KAAK;EACV,QAAQ,IAAI,uBAAuB,QAAQ,GAAG,OAAO,EAAE;EACvD,OAAO,KAAA;CACT,QAAQ;EACN,QAAQ,MAAM,8BAA8B;EAC5C,gBAAA,aAAa;EACb,OAAO;CACT;CACA,gBAAA,aAAa;CACb,OAAO;AACT"}
|
package/lib/functions/remove.js
CHANGED
|
@@ -17,7 +17,7 @@ const transformModules = (entries, ...files) => {
|
|
|
17
17
|
relativePath,
|
|
18
18
|
moduleSpecifier
|
|
19
19
|
});
|
|
20
|
-
}).map((_path) => [_path, `${_path}
|
|
20
|
+
}).map((_path) => [_path, `${_path}/index`]).flat().filter((s) => files.includes(s));
|
|
21
21
|
return [key, Array.from(new Set(specifiers))];
|
|
22
22
|
});
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","names":[],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport { consoleStars, getFolderPath, transformModule } from '#helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}
|
|
1
|
+
{"version":3,"file":"remove.js","names":[],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport { consoleStars, getFolderPath, transformModule } from '#helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}/index`]) // Add */index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n jsonConfigPath: string,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, jsonConfigPath);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`🔧 Deletion of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`⚠️ ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ⚠️ ${key} imported by:`);\n modules.forEach(m => console.warn(` -> 📌 ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('❌ No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path = CODEBASE_ANALYSIS[key].relativePath;\n const absolute = join(root, _path);\n return [key, absolute] as const;\n });\n\n console.log(`🗑️ Deleting files (${safesToRemove.length} files)...`);\n\n let success = 0;\n const length = formatteds.length;\n\n formatteds.forEach(([key, path]) => {\n try {\n unlinkSync(path);\n console.log(` - 🗑️ ${key}`);\n file?.set(\n FILES_PROPERTY,\n files.filter(key1 => key1 !== key),\n );\n success++;\n } catch {\n console.error(` - ❌ Error, ${key} :`);\n }\n });\n\n file.save();\n console.log(`🗑️ Files deleted! (${success}/${length})`);\n file = undefined;\n } catch {\n console.error(`❌ Error while deleting files`);\n consoleStars();\n return false;\n }\n consoleStars();\n return true;\n};\n"],"mappings":";;;;;;AAOA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;GAC5B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D,IAAI,cAAc,SAAS,GAAG;GAC5B,MAAM,MAAM,cAAc;GAI1B,QAAQ,KAAK,OAAO,IAAI,GAAG,QAAQ,IAAI,qDAAM,oDAAK,GAAG;GACrD,cAAc,SAAS,CAAC,KAAK,aAAa;IACxC,QAAQ,KAAK,WAAW,IAAI,cAAc;IAC1C,QAAQ,SAAQ,MAAK,QAAQ,KAAK,aAAa,GAAG,CAAC;GACrD,CAAC;EACH;EAEA,IAAI,cAAc,WAAW,GAAG;GAC9B,QAAQ,KAAK,4BAA4B;GACzC,OAAO,aAAa;EACtB;EAEA,MAAM,aAAa,cAAc,KAAI,QAAO;GAC1C,MAAM,QAAQ,kBAAkB,IAAI,CAAC;GAErC,OAAO,CAAC,KADS,KAAK,MAAM,KACR,CAAC;EACvB,CAAC;EAED,QAAQ,IAAI,uBAAuB,cAAc,OAAO,WAAW;EAEnE,IAAI,UAAU;EACd,MAAM,SAAS,WAAW;EAE1B,WAAW,SAAS,CAAC,KAAK,UAAU;GAClC,IAAI;IACF,WAAW,IAAI;IACf,QAAQ,IAAI,WAAW,KAAK;IAC5B,MAAM,IACJ,gBACA,MAAM,QAAO,SAAQ,SAAS,GAAG,CACnC;IACA;GACF,QAAQ;IACN,QAAQ,MAAM,gBAAgB,IAAI,GAAG;GACvC;EACF,CAAC;EAED,KAAK,KAAK;EACV,QAAQ,IAAI,uBAAuB,QAAQ,GAAG,OAAO,EAAE;EACvD,OAAO,KAAA;CACT,QAAQ;EACN,QAAQ,MAAM,8BAA8B;EAC5C,aAAa;EACb,OAAO;CACT;CACA,aAAa;CACb,OAAO;AACT"}
|
|
@@ -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';\
|
|
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
|
-
|
|
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;
|
|
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';\
|
|
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 };
|