@bemedev/codebase 1.0.0 ā 1.2.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 +10 -9
- package/lib/analyse.cjs +5 -3
- package/lib/analyse.cjs.map +1 -1
- package/lib/analyse.d.ts +2 -2
- package/lib/analyse.d.ts.map +1 -1
- package/lib/analyse.js +5 -3
- package/lib/analyse.js.map +1 -1
- package/lib/cli/cli.cjs +3 -2
- package/lib/cli/cli.cjs.map +1 -1
- package/lib/cli/cli.d.ts.map +1 -1
- package/lib/cli/cli.js +4 -3
- package/lib/cli/cli.js.map +1 -1
- package/lib/config.cjs +2 -1
- package/lib/config.cjs.map +1 -1
- package/lib/config.d.ts +1 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -2
- package/lib/config.js.map +1 -1
- package/lib/constants.cjs +2 -2
- package/lib/constants.cjs.map +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +2 -2
- package/lib/constants.js.map +1 -1
- package/lib/functions/add.cjs +1 -1
- package/lib/functions/add.cjs.map +1 -1
- package/lib/functions/add.js +1 -1
- package/lib/functions/add.js.map +1 -1
- package/lib/functions/generate.cjs +1 -1
- package/lib/functions/generate.cjs.map +1 -1
- package/lib/functions/generate.js +2 -2
- package/lib/functions/generate.js.map +1 -1
- package/lib/functions/init.cjs.map +1 -1
- package/lib/functions/init.d.ts.map +1 -1
- package/lib/functions/init.js.map +1 -1
- package/lib/functions/remove.cjs +2 -1
- package/lib/functions/remove.cjs.map +1 -1
- package/lib/functions/remove.d.ts.map +1 -1
- package/lib/functions/remove.js +2 -1
- package/lib/functions/remove.js.map +1 -1
- package/lib/helpers.cjs +3 -3
- package/lib/helpers.cjs.map +1 -1
- package/lib/helpers.d.ts.map +1 -1
- package/lib/helpers.js +4 -4
- package/lib/helpers.js.map +1 -1
- package/lib/imports.cjs.map +1 -1
- package/lib/imports.js.map +1 -1
- package/lib/index.cjs +3 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/utils.cjs +1 -1
- package/lib/utils.cjs.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,16 +51,16 @@ pnpm add -D @bemedev/codebase
|
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
# Basic analysis - generates a codebase.json file
|
|
54
|
-
|
|
54
|
+
codebase
|
|
55
55
|
|
|
56
56
|
# Specify a custom output file
|
|
57
|
-
|
|
57
|
+
codebase --output my-analysis.json
|
|
58
58
|
|
|
59
59
|
# Exclude specific files
|
|
60
|
-
|
|
60
|
+
codebase --exclude node_modules dist lib build
|
|
61
61
|
|
|
62
62
|
# Use short options
|
|
63
|
-
|
|
63
|
+
codebase -o output.json node_modules dist
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
#### Available options
|
|
@@ -94,6 +94,7 @@ import { config } from '@bemedev/codebase';
|
|
|
94
94
|
// Customize the configuration
|
|
95
95
|
config.json = '.my-custom-config.json';
|
|
96
96
|
config.tsConfigPath = '#custom/*';
|
|
97
|
+
config.codebase = '.my-custom-codebase.json';
|
|
97
98
|
```
|
|
98
99
|
|
|
99
100
|
## š Output format
|
|
@@ -127,7 +128,7 @@ src/
|
|
|
127
128
|
ā āāā generate.ts # Generate analysis
|
|
128
129
|
ā āāā init.ts # Initialization
|
|
129
130
|
ā āāā remove.ts # Removal
|
|
130
|
-
āāā
|
|
131
|
+
āāā analyse.ts # Analysis engine
|
|
131
132
|
āāā types.ts # TypeScript definitions
|
|
132
133
|
āāā constants.ts # Global constants
|
|
133
134
|
```
|
|
@@ -153,13 +154,13 @@ pnpm dev
|
|
|
153
154
|
### Analyze a React project
|
|
154
155
|
|
|
155
156
|
```bash
|
|
156
|
-
|
|
157
|
+
codebase -o react-analysis.json node_modules public build
|
|
157
158
|
```
|
|
158
159
|
|
|
159
160
|
### Analyze a Node.js project
|
|
160
161
|
|
|
161
162
|
```bash
|
|
162
|
-
|
|
163
|
+
codebase -o backend-analysis.json node_modules dist coverage
|
|
163
164
|
```
|
|
164
165
|
|
|
165
166
|
### Integrate into an NPM script
|
|
@@ -167,8 +168,8 @@ pnpm dev
|
|
|
167
168
|
```json
|
|
168
169
|
{
|
|
169
170
|
"scripts": {
|
|
170
|
-
"analyze": "
|
|
171
|
-
"analyze:clean": "
|
|
171
|
+
"analyze": "codebase -o analysis/codebase.json",
|
|
172
|
+
"analyze:clean": "codebase -o analysis/clean.json node_modules dist lib build"
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
```
|
package/lib/analyse.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_utils = require("./utils.cjs");
|
|
4
|
-
const require_constants = require("./constants.cjs");
|
|
5
4
|
const require_schemas = require("./schemas.cjs");
|
|
6
5
|
const require_analyse_utils = require("./analyse.utils.cjs");
|
|
7
6
|
const require_exports = require("./exports.cjs");
|
|
@@ -15,13 +14,16 @@ let ts_morph = require("ts-morph");
|
|
|
15
14
|
/**
|
|
16
15
|
* Analyzes all TypeScript files in src/ (except src/scripts/)
|
|
17
16
|
*/
|
|
18
|
-
const analyze = ({ src
|
|
17
|
+
const analyze = ({ src, excludes: _excludes }) => {
|
|
19
18
|
console.log("š Codebase analysis in progress...");
|
|
20
19
|
const excludes = require_helpers.toArray(_excludes);
|
|
21
20
|
const sourceFiles = new ts_morph.Project({ tsConfigFilePath: (0, path.join)(process.cwd(), "tsconfig.json") }).addSourceFilesAtPaths([
|
|
22
21
|
`${src}/**/*.ts`,
|
|
22
|
+
`${src}/**/*.tsx`,
|
|
23
23
|
`!${src}/**/*.test.ts`,
|
|
24
|
-
`!${src}/**/*.
|
|
24
|
+
`!${src}/**/*.test.tsx`,
|
|
25
|
+
`!${src}/**/*.spec.ts`,
|
|
26
|
+
`!${src}/**/*.spec.tsx`
|
|
25
27
|
].concat(excludes.map((exclude) => `!${exclude}`)));
|
|
26
28
|
const analysis = {};
|
|
27
29
|
let processedCount = 0;
|
package/lib/analyse.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyse.cjs","names":["
|
|
1
|
+
{"version":3,"file":"analyse.cjs","names":["toArray","Project","addJSDocToSourceText","analyzeImports","analyzeExports","buildImportStrings","pathToDotNotation","v","CodebaseAnalysisSchema"],"sources":["../src/analyse.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { Project } from 'ts-morph';\nimport * as v from 'valibot';\nimport { addJSDocToSourceText } from './analyse.utils';\nimport { analyzeExports } from './exports';\nimport { toArray } from './helpers';\nimport { analyzeImports, buildImportStrings } from './imports';\nimport { CodebaseAnalysisSchema } from './schemas';\nimport { pathToDotNotation } from './utils';\n\nexport type AnalyzeOptions = {\n src: string;\n excludes?: string | string[];\n};\n\n/**\n * Analyzes all TypeScript files in src/ (except src/scripts/)\n */\nexport const analyze = ({\n src,\n excludes: _excludes,\n}: AnalyzeOptions) => {\n console.log('š Codebase analysis in progress...');\n const excludes = toArray(_excludes);\n\n // Initialize the ts-morph project\n const project = new Project({\n tsConfigFilePath: join(process.cwd(), 'tsconfig.json'),\n });\n\n // Add all TypeScript files from the src folder\n const sourceFiles = project.addSourceFilesAtPaths(\n [\n `${src}/**/*.ts`,\n `${src}/**/*.tsx`,\n\n // #region Exclude test files\n `!${src}/**/*.test.ts`,\n `!${src}/**/*.test.tsx`,\n `!${src}/**/*.spec.ts`,\n `!${src}/**/*.spec.tsx`,\n // #endregion\n ].concat(excludes.map(exclude => `!${exclude}`)),\n );\n\n const analysis: v.InferInput<typeof CodebaseAnalysisSchema> = {};\n let processedCount = 0;\n\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const relativePath = relative(src, filePath);\n\n // Generate modified text with JSDoc for exports\n\n const _text = addJSDocToSourceText(sourceFile);\n\n // #region Analyze imports and exports\n const imports = analyzeImports(sourceFile);\n const exports = analyzeExports(sourceFile);\n // #endregion\n\n // Build imports from fileAnalysis.imports\n const importsStrings = buildImportStrings(imports);\n\n // Combine imports and content\n const importsSection =\n importsStrings.length > 0 ? importsStrings.join('\\n') : '';\n\n const text =\n importsSection === ''\n ? _text\n : `${importsSection}\n\n${_text}\n `;\n\n analysis[pathToDotNotation(relativePath)] = {\n relativePath,\n imports,\n exports,\n text,\n };\n\n processedCount++;\n\n // #region Display analysis progress in increments of 50\n if (processedCount % 50 === 0) {\n console.log(\n `š Analyzed ${processedCount}/${sourceFiles.length} files...`,\n );\n }\n // #endregion\n }\n\n console.log(\n `ā
Analysis completed: ${processedCount} files analyzed`,\n );\n return v.parse(CodebaseAnalysisSchema, analysis);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,WAAW,EACtB,KACA,UAAU,gBACU;CACpB,QAAQ,IAAI,qCAAqC;CACjD,MAAM,WAAWA,gBAAAA,QAAQ,SAAS;CAQlC,MAAM,cAAc,IALAC,SAAAA,QAAQ,EAC1B,mBAAA,GAAA,KAAA,KAAA,CAAuB,QAAQ,IAAI,GAAG,eAAe,EACvD,CAG0B,CAAC,CAAC,sBAC1B;EACE,GAAG,IAAI;EACP,GAAG,IAAI;EAGP,IAAI,IAAI;EACR,IAAI,IAAI;EACR,IAAI,IAAI;EACR,IAAI,IAAI;CAEV,CAAC,CAAC,OAAO,SAAS,KAAI,YAAW,IAAI,SAAS,CAAC,CACjD;CAEA,MAAM,WAAwD,CAAC;CAC/D,IAAI,iBAAiB;CAErB,KAAK,MAAM,cAAc,aAAa;EAEpC,MAAM,gBAAA,GAAA,KAAA,SAAA,CAAwB,KADb,WAAW,YACc,CAAC;EAI3C,MAAM,QAAQC,sBAAAA,qBAAqB,UAAU;EAG7C,MAAM,UAAUC,gBAAAA,eAAe,UAAU;EACzC,MAAM,UAAUC,gBAAAA,eAAe,UAAU;EAIzC,MAAM,iBAAiBC,gBAAAA,mBAAmB,OAAO;EAGjD,MAAM,iBACJ,eAAe,SAAS,IAAI,eAAe,KAAK,IAAI,IAAI;EAE1D,MAAM,OACJ,mBAAmB,KACf,QACA,GAAG,eAAe;;EAE1B,MAAM;;EAGJ,SAASC,cAAAA,kBAAkB,YAAY,KAAK;GAC1C;GACA;GACA;GACA;EACF;EAEA;EAGA,IAAI,iBAAiB,OAAO,GAC1B,QAAQ,IACN,eAAe,eAAe,GAAG,YAAY,OAAO,UACtD;CAGJ;CAEA,QAAQ,IACN,yBAAyB,eAAe,gBAC1C;CACA,OAAOC,QAAE,MAAMC,gBAAAA,wBAAwB,QAAQ;AACjD"}
|
package/lib/analyse.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type AnalyzeOptions = {
|
|
2
|
-
src
|
|
2
|
+
src: string;
|
|
3
3
|
excludes?: string | string[];
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
6
|
* Analyzes all TypeScript files in src/ (except src/scripts/)
|
|
7
7
|
*/
|
|
8
|
-
export declare const analyze: ({ src, excludes: _excludes, }
|
|
8
|
+
export declare const analyze: ({ src, excludes: _excludes, }: AnalyzeOptions) => {
|
|
9
9
|
[x: string]: {
|
|
10
10
|
relativePath: string;
|
|
11
11
|
imports: {
|
package/lib/analyse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyse.d.ts","sourceRoot":"","sources":["../src/analyse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyse.d.ts","sourceRoot":"","sources":["../src/analyse.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,+BAGrB,cAAc;;;;;;;;;;;;;;;;;;;;CA6EhB,CAAC"}
|
package/lib/analyse.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { pathToDotNotation } from "./utils.js";
|
|
2
|
-
import { SRC_DIR } from "./constants.js";
|
|
3
2
|
import { CodebaseAnalysisSchema } from "./schemas.js";
|
|
4
3
|
import { addJSDocToSourceText } from "./analyse.utils.js";
|
|
5
4
|
import { analyzeExports } from "./exports.js";
|
|
@@ -12,13 +11,16 @@ import { Project } from "ts-morph";
|
|
|
12
11
|
/**
|
|
13
12
|
* Analyzes all TypeScript files in src/ (except src/scripts/)
|
|
14
13
|
*/
|
|
15
|
-
const analyze = ({ src
|
|
14
|
+
const analyze = ({ src, excludes: _excludes }) => {
|
|
16
15
|
console.log("š Codebase analysis in progress...");
|
|
17
16
|
const excludes = toArray(_excludes);
|
|
18
17
|
const sourceFiles = new Project({ tsConfigFilePath: join(process.cwd(), "tsconfig.json") }).addSourceFilesAtPaths([
|
|
19
18
|
`${src}/**/*.ts`,
|
|
19
|
+
`${src}/**/*.tsx`,
|
|
20
20
|
`!${src}/**/*.test.ts`,
|
|
21
|
-
`!${src}/**/*.
|
|
21
|
+
`!${src}/**/*.test.tsx`,
|
|
22
|
+
`!${src}/**/*.spec.ts`,
|
|
23
|
+
`!${src}/**/*.spec.tsx`
|
|
22
24
|
].concat(excludes.map((exclude) => `!${exclude}`)));
|
|
23
25
|
const analysis = {};
|
|
24
26
|
let processedCount = 0;
|
package/lib/analyse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyse.js","names":[],"sources":["../src/analyse.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { Project } from 'ts-morph';\nimport * as v from 'valibot';\nimport { addJSDocToSourceText } from './analyse.utils';\nimport {
|
|
1
|
+
{"version":3,"file":"analyse.js","names":[],"sources":["../src/analyse.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { Project } from 'ts-morph';\nimport * as v from 'valibot';\nimport { addJSDocToSourceText } from './analyse.utils';\nimport { analyzeExports } from './exports';\nimport { toArray } from './helpers';\nimport { analyzeImports, buildImportStrings } from './imports';\nimport { CodebaseAnalysisSchema } from './schemas';\nimport { pathToDotNotation } from './utils';\n\nexport type AnalyzeOptions = {\n src: string;\n excludes?: string | string[];\n};\n\n/**\n * Analyzes all TypeScript files in src/ (except src/scripts/)\n */\nexport const analyze = ({\n src,\n excludes: _excludes,\n}: AnalyzeOptions) => {\n console.log('š Codebase analysis in progress...');\n const excludes = toArray(_excludes);\n\n // Initialize the ts-morph project\n const project = new Project({\n tsConfigFilePath: join(process.cwd(), 'tsconfig.json'),\n });\n\n // Add all TypeScript files from the src folder\n const sourceFiles = project.addSourceFilesAtPaths(\n [\n `${src}/**/*.ts`,\n `${src}/**/*.tsx`,\n\n // #region Exclude test files\n `!${src}/**/*.test.ts`,\n `!${src}/**/*.test.tsx`,\n `!${src}/**/*.spec.ts`,\n `!${src}/**/*.spec.tsx`,\n // #endregion\n ].concat(excludes.map(exclude => `!${exclude}`)),\n );\n\n const analysis: v.InferInput<typeof CodebaseAnalysisSchema> = {};\n let processedCount = 0;\n\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const relativePath = relative(src, filePath);\n\n // Generate modified text with JSDoc for exports\n\n const _text = addJSDocToSourceText(sourceFile);\n\n // #region Analyze imports and exports\n const imports = analyzeImports(sourceFile);\n const exports = analyzeExports(sourceFile);\n // #endregion\n\n // Build imports from fileAnalysis.imports\n const importsStrings = buildImportStrings(imports);\n\n // Combine imports and content\n const importsSection =\n importsStrings.length > 0 ? importsStrings.join('\\n') : '';\n\n const text =\n importsSection === ''\n ? _text\n : `${importsSection}\n\n${_text}\n `;\n\n analysis[pathToDotNotation(relativePath)] = {\n relativePath,\n imports,\n exports,\n text,\n };\n\n processedCount++;\n\n // #region Display analysis progress in increments of 50\n if (processedCount % 50 === 0) {\n console.log(\n `š Analyzed ${processedCount}/${sourceFiles.length} files...`,\n );\n }\n // #endregion\n }\n\n console.log(\n `ā
Analysis completed: ${processedCount} files analyzed`,\n );\n return v.parse(CodebaseAnalysisSchema, analysis);\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,WAAW,EACtB,KACA,UAAU,gBACU;CACpB,QAAQ,IAAI,qCAAqC;CACjD,MAAM,WAAW,QAAQ,SAAS;CAQlC,MAAM,cAAc,IALA,QAAQ,EAC1B,kBAAkB,KAAK,QAAQ,IAAI,GAAG,eAAe,EACvD,CAG0B,CAAC,CAAC,sBAC1B;EACE,GAAG,IAAI;EACP,GAAG,IAAI;EAGP,IAAI,IAAI;EACR,IAAI,IAAI;EACR,IAAI,IAAI;EACR,IAAI,IAAI;CAEV,CAAC,CAAC,OAAO,SAAS,KAAI,YAAW,IAAI,SAAS,CAAC,CACjD;CAEA,MAAM,WAAwD,CAAC;CAC/D,IAAI,iBAAiB;CAErB,KAAK,MAAM,cAAc,aAAa;EAEpC,MAAM,eAAe,SAAS,KADb,WAAW,YACc,CAAC;EAI3C,MAAM,QAAQ,qBAAqB,UAAU;EAG7C,MAAM,UAAU,eAAe,UAAU;EACzC,MAAM,UAAU,eAAe,UAAU;EAIzC,MAAM,iBAAiB,mBAAmB,OAAO;EAGjD,MAAM,iBACJ,eAAe,SAAS,IAAI,eAAe,KAAK,IAAI,IAAI;EAE1D,MAAM,OACJ,mBAAmB,KACf,QACA,GAAG,eAAe;;EAE1B,MAAM;;EAGJ,SAAS,kBAAkB,YAAY,KAAK;GAC1C;GACA;GACA;GACA;EACF;EAEA;EAGA,IAAI,iBAAiB,OAAO,GAC1B,QAAQ,IACN,eAAe,eAAe,GAAG,YAAY,OAAO,UACtD;CAGJ;CAEA,QAAQ,IACN,yBAAyB,eAAe,gBAC1C;CACA,OAAO,EAAE,MAAM,wBAAwB,QAAQ;AACjD"}
|
package/lib/cli/cli.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_constants = require("../constants.cjs");
|
|
3
3
|
const require_functions_generate = require("../functions/generate.cjs");
|
|
4
|
+
const require_cli_constants = require("./constants.cjs");
|
|
4
5
|
let cmd_ts = require("cmd-ts");
|
|
5
6
|
//#region src/cli/cli.ts
|
|
6
7
|
const cli = (0, cmd_ts.command)({
|
|
7
|
-
name: "generate",
|
|
8
8
|
args: {
|
|
9
9
|
output: (0, cmd_ts.option)({
|
|
10
10
|
long: "output",
|
|
11
11
|
short: "o",
|
|
12
12
|
type: cmd_ts.string,
|
|
13
13
|
description: "Output file path",
|
|
14
|
-
defaultValue: () => require_constants.
|
|
14
|
+
defaultValue: () => require_constants.DEFAULT_CODEBASE_FILE
|
|
15
15
|
}),
|
|
16
16
|
excludes: (0, cmd_ts.multioption)({
|
|
17
17
|
description: "The files to exclude, globs",
|
|
@@ -21,6 +21,7 @@ const cli = (0, cmd_ts.command)({
|
|
|
21
21
|
defaultValue: () => []
|
|
22
22
|
})
|
|
23
23
|
},
|
|
24
|
+
name: require_cli_constants.BIN,
|
|
24
25
|
handler: require_functions_generate.generate
|
|
25
26
|
});
|
|
26
27
|
//#endregion
|
package/lib/cli/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["string","
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["string","DEFAULT_CODEBASE_FILE","BIN"],"sources":["../../src/cli/cli.ts"],"sourcesContent":["import { array, command, multioption, option, string } from 'cmd-ts';\nimport { DEFAULT_CODEBASE_FILE } from '../constants';\nimport { generate as handler } from '../functions/generate';\nimport { BIN } from './constants';\n\nexport const cli = command({\n args: {\n output: option({\n long: 'output',\n short: 'o',\n type: string,\n description: 'Output file path',\n defaultValue: () => DEFAULT_CODEBASE_FILE,\n }),\n\n excludes: multioption({\n description: 'The files to exclude, globs',\n long: 'excludes',\n short: 'x',\n type: array(string),\n defaultValue: () => [],\n }),\n },\n\n name: BIN,\n handler,\n});\n"],"mappings":";;;;;;AAKA,MAAa,OAAA,GAAA,OAAA,QAAA,CAAc;CACzB,MAAM;EACJ,SAAA,GAAA,OAAA,OAAA,CAAe;GACb,MAAM;GACN,OAAO;GACP,MAAMA,OAAAA;GACN,aAAa;GACb,oBAAoBC,kBAAAA;EACtB,CAAC;EAED,WAAA,GAAA,OAAA,YAAA,CAAsB;GACpB,aAAa;GACb,MAAM;GACN,OAAO;GACP,OAAA,GAAA,OAAA,MAAA,CAAYD,OAAAA,MAAM;GAClB,oBAAoB,CAAC;EACvB,CAAC;CACH;CAEA,MAAME,sBAAAA;CACN,SAAA,2BAAA;AACF,CAAC"}
|
package/lib/cli/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG;;;;;;;;;;oJAqBd,CAAC"}
|
package/lib/cli/cli.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_CODEBASE_FILE } from "../constants.js";
|
|
2
2
|
import { generate } from "../functions/generate.js";
|
|
3
|
+
import { BIN } from "./constants.js";
|
|
3
4
|
import { array, command, multioption, option, string } from "cmd-ts";
|
|
4
5
|
//#region src/cli/cli.ts
|
|
5
6
|
const cli = command({
|
|
6
|
-
name: "generate",
|
|
7
7
|
args: {
|
|
8
8
|
output: option({
|
|
9
9
|
long: "output",
|
|
10
10
|
short: "o",
|
|
11
11
|
type: string,
|
|
12
12
|
description: "Output file path",
|
|
13
|
-
defaultValue: () =>
|
|
13
|
+
defaultValue: () => DEFAULT_CODEBASE_FILE
|
|
14
14
|
}),
|
|
15
15
|
excludes: multioption({
|
|
16
16
|
description: "The files to exclude, globs",
|
|
@@ -20,6 +20,7 @@ const cli = command({
|
|
|
20
20
|
defaultValue: () => []
|
|
21
21
|
})
|
|
22
22
|
},
|
|
23
|
+
name: BIN,
|
|
23
24
|
handler: generate
|
|
24
25
|
});
|
|
25
26
|
//#endregion
|
package/lib/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../../src/cli/cli.ts"],"sourcesContent":["import { array, command, multioption, option, string } from 'cmd-ts';\nimport {
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../../src/cli/cli.ts"],"sourcesContent":["import { array, command, multioption, option, string } from 'cmd-ts';\nimport { DEFAULT_CODEBASE_FILE } from '../constants';\nimport { generate as handler } from '../functions/generate';\nimport { BIN } from './constants';\n\nexport const cli = command({\n args: {\n output: option({\n long: 'output',\n short: 'o',\n type: string,\n description: 'Output file path',\n defaultValue: () => DEFAULT_CODEBASE_FILE,\n }),\n\n excludes: multioption({\n description: 'The files to exclude, globs',\n long: 'excludes',\n short: 'x',\n type: array(string),\n defaultValue: () => [],\n }),\n },\n\n name: BIN,\n handler,\n});\n"],"mappings":";;;;;AAKA,MAAa,MAAM,QAAQ;CACzB,MAAM;EACJ,QAAQ,OAAO;GACb,MAAM;GACN,OAAO;GACP,MAAM;GACN,aAAa;GACb,oBAAoB;EACtB,CAAC;EAED,UAAU,YAAY;GACpB,aAAa;GACb,MAAM;GACN,OAAO;GACP,MAAM,MAAM,MAAM;GAClB,oBAAoB,CAAC;EACvB,CAAC;CACH;CAEA,MAAM;CACN,SAAA;AACF,CAAC"}
|
package/lib/config.cjs
CHANGED
|
@@ -4,7 +4,8 @@ const require_constants = require("./constants.cjs");
|
|
|
4
4
|
const config = {
|
|
5
5
|
bin: require_constants.DEFAULT_CLI_NAME,
|
|
6
6
|
json: require_constants.DEFAULT_JSON_FILE_NAME,
|
|
7
|
-
tsConfigPath: require_constants.DEFAULT_PATH_KEY
|
|
7
|
+
tsConfigPath: require_constants.DEFAULT_PATH_KEY,
|
|
8
|
+
codebase: require_constants.DEFAULT_CODEBASE_FILE
|
|
8
9
|
};
|
|
9
10
|
//#endregion
|
|
10
11
|
exports.config = config;
|
package/lib/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["DEFAULT_CLI_NAME","DEFAULT_JSON_FILE_NAME","DEFAULT_PATH_KEY"],"sources":["../src/config.ts"],"sourcesContent":["import {\n DEFAULT_CLI_NAME,\n DEFAULT_JSON_FILE_NAME,\n DEFAULT_PATH_KEY,\n} from './constants';\n\nexport const config: {\n bin: string;\n json: string;\n tsConfigPath: string;\n root?: string;\n} = {\n bin: DEFAULT_CLI_NAME,\n json: DEFAULT_JSON_FILE_NAME,\n tsConfigPath: DEFAULT_PATH_KEY,\n};\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["DEFAULT_CLI_NAME","DEFAULT_JSON_FILE_NAME","DEFAULT_PATH_KEY","DEFAULT_CODEBASE_FILE"],"sources":["../src/config.ts"],"sourcesContent":["import {\n DEFAULT_CLI_NAME,\n DEFAULT_CODEBASE_FILE,\n DEFAULT_JSON_FILE_NAME,\n DEFAULT_PATH_KEY,\n} from './constants';\n\nexport const config: {\n bin: string;\n json: string;\n tsConfigPath: string;\n root?: string;\n codebase: string;\n} = {\n bin: DEFAULT_CLI_NAME,\n json: DEFAULT_JSON_FILE_NAME,\n tsConfigPath: DEFAULT_PATH_KEY,\n codebase: DEFAULT_CODEBASE_FILE,\n};\n"],"mappings":";;;AAOA,MAAa,SAMT;CACF,KAAKA,kBAAAA;CACL,MAAMC,kBAAAA;CACN,cAAcC,kBAAAA;CACd,UAAUC,kBAAAA;AACZ"}
|
package/lib/config.d.ts
CHANGED
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,EAAE;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAMlB,CAAC"}
|
package/lib/config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { DEFAULT_CLI_NAME, DEFAULT_JSON_FILE_NAME, DEFAULT_PATH_KEY } from "./constants.js";
|
|
1
|
+
import { DEFAULT_CLI_NAME, DEFAULT_CODEBASE_FILE, DEFAULT_JSON_FILE_NAME, DEFAULT_PATH_KEY } from "./constants.js";
|
|
2
2
|
//#region src/config.ts
|
|
3
3
|
const config = {
|
|
4
4
|
bin: DEFAULT_CLI_NAME,
|
|
5
5
|
json: DEFAULT_JSON_FILE_NAME,
|
|
6
|
-
tsConfigPath: DEFAULT_PATH_KEY
|
|
6
|
+
tsConfigPath: DEFAULT_PATH_KEY,
|
|
7
|
+
codebase: DEFAULT_CODEBASE_FILE
|
|
7
8
|
};
|
|
8
9
|
//#endregion
|
|
9
10
|
export { config };
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import {\n DEFAULT_CLI_NAME,\n DEFAULT_JSON_FILE_NAME,\n DEFAULT_PATH_KEY,\n} from './constants';\n\nexport const config: {\n bin: string;\n json: string;\n tsConfigPath: string;\n root?: string;\n} = {\n bin: DEFAULT_CLI_NAME,\n json: DEFAULT_JSON_FILE_NAME,\n tsConfigPath: DEFAULT_PATH_KEY,\n};\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import {\n DEFAULT_CLI_NAME,\n DEFAULT_CODEBASE_FILE,\n DEFAULT_JSON_FILE_NAME,\n DEFAULT_PATH_KEY,\n} from './constants';\n\nexport const config: {\n bin: string;\n json: string;\n tsConfigPath: string;\n root?: string;\n codebase: string;\n} = {\n bin: DEFAULT_CLI_NAME,\n json: DEFAULT_JSON_FILE_NAME,\n tsConfigPath: DEFAULT_PATH_KEY,\n codebase: DEFAULT_CODEBASE_FILE,\n};\n"],"mappings":";;AAOA,MAAa,SAMT;CACF,KAAK;CACL,MAAM;CACN,cAAc;CACd,UAAU;AACZ"}
|
package/lib/constants.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let path = require("path");
|
|
3
3
|
//#region src/constants.ts
|
|
4
4
|
const SRC_DIR = (0, path.join)(process.cwd(), "src");
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_CODEBASE_FILE = (0, path.join)(process.cwd(), ".codebase.json");
|
|
6
6
|
const _REPLACER = "-|||-";
|
|
7
7
|
const DEFAULT_CLI_NAME = "codebase";
|
|
8
8
|
const REPLACERS = {
|
|
@@ -26,8 +26,8 @@ const PROPERTIES = {
|
|
|
26
26
|
STATS: "STATS"
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
-
exports.CODEBASE_FILE = CODEBASE_FILE;
|
|
30
29
|
exports.DEFAULT_CLI_NAME = DEFAULT_CLI_NAME;
|
|
30
|
+
exports.DEFAULT_CODEBASE_FILE = DEFAULT_CODEBASE_FILE;
|
|
31
31
|
exports.DEFAULT_JSON_FILE_NAME = DEFAULT_JSON_FILE_NAME;
|
|
32
32
|
exports.DEFAULT_PATH_KEY = DEFAULT_PATH_KEY;
|
|
33
33
|
exports.FILES_PROPERTY = FILES_PROPERTY;
|
package/lib/constants.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from '
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from 'path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const DEFAULT_CODEBASE_FILE = join(\n process.cwd(),\n '.codebase.json',\n);\n\nconst _REPLACER = '-|||-';\n\nexport const DEFAULT_CLI_NAME = 'codebase';\n\nexport const REPLACERS = {\n code: [\n ['\\\\`', `${_REPLACER}w`],\n ['`', '\\\\`'],\n ['${', `$${_REPLACER}{`],\n ['\\\\s', `${_REPLACER}s`],\n ['\\\\w', `${_REPLACER}w`],\n ],\n init: [\n [new RegExp('\\\\`', 'g'), '`'],\n [_REPLACER, ''],\n ],\n} as const;\n\nexport const DEFAULT_PATH_KEY = '#bemedev/*';\nexport const DEFAULT_JSON_FILE_NAME = '.bemedev.json';\n\nexport const PATH_PROPERTY = 'path';\nexport const FILES_PROPERTY = 'files';\n\nexport const PROPERTIES = {\n PATH: 'path',\n FILES: 'files',\n CODEBASE_ANALYSIS: 'CODEBASE_ANALYSIS',\n STATS: 'STATS',\n} as const;\n"],"mappings":";;;AAEA,MAAa,WAAA,GAAA,KAAA,KAAA,CAAe,QAAQ,IAAI,GAAG,KAAK;AAChD,MAAa,yBAAA,GAAA,KAAA,KAAA,CACX,QAAQ,IAAI,GACZ,gBACF;AAEA,MAAM,YAAY;AAElB,MAAa,mBAAmB;AAEhC,MAAa,YAAY;CACvB,MAAM;EACJ,CAAC,OAAO,GAAG,UAAU,EAAE;EACvB,CAAC,KAAK,KAAK;EACX,CAAC,MAAM,IAAI,UAAU,EAAE;EACvB,CAAC,OAAO,GAAG,UAAU,EAAE;EACvB,CAAC,OAAO,GAAG,UAAU,EAAE;CACzB;CACA,MAAM,CACJ,iBAAC,IAAI,OAAO,OAAO,GAAG,GAAG,GAAG,GAC5B,CAAC,WAAW,EAAE,CAChB;AACF;AAEA,MAAa,mBAAmB;AAChC,MAAa,yBAAyB;AAEtC,MAAa,gBAAgB;AAC7B,MAAa,iBAAiB;AAE9B,MAAa,aAAa;CACxB,MAAM;CACN,OAAO;CACP,mBAAmB;CACnB,OAAO;AACT"}
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const SRC_DIR: string;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const DEFAULT_CODEBASE_FILE: string;
|
|
3
3
|
export declare const DEFAULT_CLI_NAME = "codebase";
|
|
4
4
|
export declare const REPLACERS: {
|
|
5
5
|
readonly code: readonly [readonly ["\\`", "-|||-w"], readonly ["`", "\\`"], readonly ["${", "$-|||-{"], readonly ["\\s", "-|||-s"], readonly ["\\w", "-|||-w"]];
|
package/lib/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAA6B,CAAC;AAClD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAA6B,CAAC;AAClD,eAAO,MAAM,qBAAqB,QAGjC,CAAC;AAIF,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,eAAO,MAAM,SAAS;;;CAYZ,CAAC;AAEX,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAEtD,eAAO,MAAM,aAAa,SAAS,CAAC;AACpC,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
package/lib/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
//#region src/constants.ts
|
|
3
3
|
const SRC_DIR = join(process.cwd(), "src");
|
|
4
|
-
const
|
|
4
|
+
const DEFAULT_CODEBASE_FILE = join(process.cwd(), ".codebase.json");
|
|
5
5
|
const _REPLACER = "-|||-";
|
|
6
6
|
const DEFAULT_CLI_NAME = "codebase";
|
|
7
7
|
const REPLACERS = {
|
|
@@ -25,6 +25,6 @@ const PROPERTIES = {
|
|
|
25
25
|
STATS: "STATS"
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
|
-
export {
|
|
28
|
+
export { DEFAULT_CLI_NAME, DEFAULT_CODEBASE_FILE, DEFAULT_JSON_FILE_NAME, DEFAULT_PATH_KEY, FILES_PROPERTY, PATH_PROPERTY, PROPERTIES, REPLACERS, SRC_DIR };
|
|
29
29
|
|
|
30
30
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from '
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from 'path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const DEFAULT_CODEBASE_FILE = join(\n process.cwd(),\n '.codebase.json',\n);\n\nconst _REPLACER = '-|||-';\n\nexport const DEFAULT_CLI_NAME = 'codebase';\n\nexport const REPLACERS = {\n code: [\n ['\\\\`', `${_REPLACER}w`],\n ['`', '\\\\`'],\n ['${', `$${_REPLACER}{`],\n ['\\\\s', `${_REPLACER}s`],\n ['\\\\w', `${_REPLACER}w`],\n ],\n init: [\n [new RegExp('\\\\`', 'g'), '`'],\n [_REPLACER, ''],\n ],\n} as const;\n\nexport const DEFAULT_PATH_KEY = '#bemedev/*';\nexport const DEFAULT_JSON_FILE_NAME = '.bemedev.json';\n\nexport const PATH_PROPERTY = 'path';\nexport const FILES_PROPERTY = 'files';\n\nexport const PROPERTIES = {\n PATH: 'path',\n FILES: 'files',\n CODEBASE_ANALYSIS: 'CODEBASE_ANALYSIS',\n STATS: 'STATS',\n} as const;\n"],"mappings":";;AAEA,MAAa,UAAU,KAAK,QAAQ,IAAI,GAAG,KAAK;AAChD,MAAa,wBAAwB,KACnC,QAAQ,IAAI,GACZ,gBACF;AAEA,MAAM,YAAY;AAElB,MAAa,mBAAmB;AAEhC,MAAa,YAAY;CACvB,MAAM;EACJ,CAAC,OAAO,GAAG,UAAU,EAAE;EACvB,CAAC,KAAK,KAAK;EACX,CAAC,MAAM,IAAI,UAAU,EAAE;EACvB,CAAC,OAAO,GAAG,UAAU,EAAE;EACvB,CAAC,OAAO,GAAG,UAAU,EAAE;CACzB;CACA,MAAM,CACJ,iBAAC,IAAI,OAAO,OAAO,GAAG,GAAG,GAAG,GAC5B,CAAC,WAAW,EAAE,CAChB;AACF;AAEA,MAAa,mBAAmB;AAChC,MAAa,yBAAyB;AAEtC,MAAa,gBAAgB;AAC7B,MAAa,iBAAiB;AAE9B,MAAa,aAAa;CACxB,MAAM;CACN,OAAO;CACP,mBAAmB;CACnB,OAAO;AACT"}
|
package/lib/functions/add.cjs
CHANGED
|
@@ -57,10 +57,10 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
57
57
|
const _path = require_helpers.writeFileAnalysis(fileAnalysis, root);
|
|
58
58
|
if (_path) {
|
|
59
59
|
files.push(_path);
|
|
60
|
-
file?.set(require_constants.FILES_PROPERTY, files);
|
|
61
60
|
success++;
|
|
62
61
|
}
|
|
63
62
|
});
|
|
63
|
+
file.set(require_constants.FILES_PROPERTY, files);
|
|
64
64
|
file.save();
|
|
65
65
|
console.log(`ā
Files created! (${success}/${length})`);
|
|
66
66
|
file = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.cjs","names":["transformModule","config","FILES_PROPERTY","getFolderPath","PATH_PROPERTY","writeFileAnalysis"],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from '
|
|
1
|
+
{"version":3,"file":"add.cjs","names":["transformModule","config","FILES_PROPERTY","getFolderPath","PATH_PROPERTY","writeFileAnalysis"],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { config } from '../config';\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 ).replaceAll('/', '.');\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\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 ...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, config.json);\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":";;;;;;;;;AAaA,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,SAAA,GAAA,KAAA,SAAA,CACJ,MAAA,GAAA,KAAA,QAAA,EAAA,GAAA,KAAA,QAAA,CACgB,YAAY,GAAG,eAAe,CAChD,CAAC,CAAC,WAAW,KAAK,GAAG;EAErB,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,kBAAk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,cACA,OACA,iBACF;EACF,CAAC;EAED,MAAM,UAAU,IAAI,IAClB,aAAa,OAAO,WAAW,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,GAAG,CAC5D;EAEA,gBAAA,aAAa;EACb,QAAQ,IAAI,yBAAyB,QAAQ,KAAK,WAAW;EAE7D,IAAI,UAAU;EACd,MAAM,SAAS,QAAQ;EAEvB,QAAQ,SAAS,GAAG,kBAAkB;GACpC,MAAM,QAAQC,gBAAAA,kBAAkB,cAAc,IAAI;GAClD,IAAI,OAAO;IACT,MAAM,KAAK,KAAK;IAChB;GACF;EACF,CAAC;EAED,KAAK,IAAIH,kBAAAA,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,gBAAA,aAAa;CACb,OAAO;AACT"}
|
package/lib/functions/add.js
CHANGED
|
@@ -54,10 +54,10 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
54
54
|
const _path = writeFileAnalysis(fileAnalysis, root);
|
|
55
55
|
if (_path) {
|
|
56
56
|
files.push(_path);
|
|
57
|
-
file?.set(FILES_PROPERTY, files);
|
|
58
57
|
success++;
|
|
59
58
|
}
|
|
60
59
|
});
|
|
60
|
+
file.set(FILES_PROPERTY, files);
|
|
61
61
|
file.save();
|
|
62
62
|
console.log(`ā
Files created! (${success}/${length})`);
|
|
63
63
|
file = void 0;
|
package/lib/functions/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","names":[],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from '
|
|
1
|
+
{"version":3,"file":"add.js","names":[],"sources":["../../src/functions/add.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { dirname, join, relative, resolve } from 'path';\nimport { config } from '../config';\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 ).replaceAll('/', '.');\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\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 ...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, config.json);\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":";;;;;;AAaA,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,CAAC,CAAC,WAAW,KAAK,GAAG;EAErB,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,C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,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"}
|
|
@@ -32,7 +32,7 @@ const transformJSON = (data) => {
|
|
|
32
32
|
/**
|
|
33
33
|
* Main execution function
|
|
34
34
|
*/
|
|
35
|
-
const generate = ({ output = require_constants.
|
|
35
|
+
const generate = ({ output = require_constants.DEFAULT_CODEBASE_FILE, excludes, src = require_constants.SRC_DIR } = {}) => {
|
|
36
36
|
const _output = output.endsWith("codebase.json") ? output : `${output}.codebase.json`;
|
|
37
37
|
try {
|
|
38
38
|
const transformed = transformJSON(require_analyse.analyze({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.cjs","names":["
|
|
1
|
+
{"version":3,"file":"generate.cjs","names":["DEFAULT_CODEBASE_FILE","SRC_DIR","analyze"],"sources":["../../src/functions/generate.ts"],"sourcesContent":["import { writeFileSync } from 'fs';\nimport { relative } from 'path';\nimport { analyze } from '../analyse';\nimport { DEFAULT_CODEBASE_FILE, SRC_DIR } from '../constants';\nimport { CodebaseAnalysis } from '../schemas';\n\nexport const transformJSON = (data: CodebaseAnalysis) => {\n let imports = 0;\n let exports = 0;\n let files = 0;\n\n const entries = Object.entries(data).map(\n ([\n key,\n { imports: _imports, relativePath, text, exports: _exports },\n ]) => {\n imports += _imports.length;\n exports += _exports?.length ?? 0;\n files++;\n\n const value: any = {\n imports: _imports,\n relativePath,\n text,\n exports: _exports?.filter(\n ({ moduleSpecifier }) => moduleSpecifier !== undefined,\n ),\n };\n\n return [key, value] as const;\n },\n );\n\n const CODEBASE_ANALYSIS = Object.fromEntries(entries);\n\n const STATS = {\n files,\n imports,\n exports,\n };\n\n return {\n STATS,\n CODEBASE_ANALYSIS,\n };\n};\n\nexport type GenerateOptions = {\n output?: string;\n excludes?: string[] | string;\n src?: string;\n};\n\n/**\n * Main execution function\n */\nexport const generate = ({\n output = DEFAULT_CODEBASE_FILE,\n excludes,\n src = SRC_DIR,\n}: GenerateOptions = {}) => {\n const _output = output.endsWith('codebase.json')\n ? output\n : `${output}.codebase.json`;\n\n try {\n const analysis = analyze({ src, excludes });\n const transformed = transformJSON(analysis);\n\n const json = JSON.stringify(transformed, null, 2);\n writeFileSync(_output, json);\n\n console.log(\n `š Analysis saved in: ${relative(process.cwd(), _output)}`,\n );\n console.log(`š Statistics:`);\n console.log(` - Files analyzed: ${transformed.STATS.files}`);\n console.log(` - Total imports: ${transformed.STATS.imports}`);\n console.log(` - Total exports: ${transformed.STATS.exports}`);\n } catch (error) {\n console.error('ā Error during codebase analysis:', error);\n process.exit(1);\n }\n\n return true;\n};\n"],"mappings":";;;;;;AAMA,MAAa,iBAAiB,SAA2B;CACvD,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,QAAQ;CAEZ,MAAM,UAAU,OAAO,QAAQ,IAAI,CAAC,CAAC,KAClC,CACC,KACA,EAAE,SAAS,UAAU,cAAc,MAAM,SAAS,gBAC9C;EACJ,WAAW,SAAS;EACpB,WAAW,UAAU,UAAU;EAC/B;EAWA,OAAO,CAAC,KAAK;GARX,SAAS;GACT;GACA;GACA,SAAS,UAAU,QAChB,EAAE,sBAAsB,oBAAoB,KAAA,CAC/C;EAGe,CAAC;CACpB,CACF;CAEA,MAAM,oBAAoB,OAAO,YAAY,OAAO;CAQpD,OAAO;EACL,OAAA;GANA;GACA;GACA;EAII;EACJ;CACF;AACF;;;;AAWA,MAAa,YAAY,EACvB,SAASA,kBAAAA,uBACT,UACA,MAAMC,kBAAAA,YACa,CAAC,MAAM;CAC1B,MAAM,UAAU,OAAO,SAAS,eAAe,IAC3C,SACA,GAAG,OAAO;CAEd,IAAI;EAEF,MAAM,cAAc,cADHC,gBAAAA,QAAQ;GAAE;GAAK;EAAS,CACA,CAAC;EAG1C,CAAA,GAAA,GAAA,cAAA,CAAc,SADD,KAAK,UAAU,aAAa,MAAM,CACrB,CAAC;EAE3B,QAAQ,IACN,0BAAA,GAAA,KAAA,SAAA,CAAkC,QAAQ,IAAI,GAAG,OAAO,GAC1D;EACA,QAAQ,IAAI,gBAAgB;EAC5B,QAAQ,IAAI,wBAAwB,YAAY,MAAM,OAAO;EAC7D,QAAQ,IAAI,uBAAuB,YAAY,MAAM,SAAS;EAC9D,QAAQ,IAAI,uBAAuB,YAAY,MAAM,SAAS;CAChE,SAAS,OAAO;EACd,QAAQ,MAAM,qCAAqC,KAAK;EACxD,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_CODEBASE_FILE, SRC_DIR } from "../constants.js";
|
|
2
2
|
import { analyze } from "../analyse.js";
|
|
3
3
|
import { relative } from "path";
|
|
4
4
|
import { writeFileSync } from "fs";
|
|
@@ -31,7 +31,7 @@ const transformJSON = (data) => {
|
|
|
31
31
|
/**
|
|
32
32
|
* Main execution function
|
|
33
33
|
*/
|
|
34
|
-
const generate = ({ output =
|
|
34
|
+
const generate = ({ output = DEFAULT_CODEBASE_FILE, excludes, src = SRC_DIR } = {}) => {
|
|
35
35
|
const _output = output.endsWith("codebase.json") ? output : `${output}.codebase.json`;
|
|
36
36
|
try {
|
|
37
37
|
const transformed = transformJSON(analyze({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","names":[],"sources":["../../src/functions/generate.ts"],"sourcesContent":["import { writeFileSync } from '
|
|
1
|
+
{"version":3,"file":"generate.js","names":[],"sources":["../../src/functions/generate.ts"],"sourcesContent":["import { writeFileSync } from 'fs';\nimport { relative } from 'path';\nimport { analyze } from '../analyse';\nimport { DEFAULT_CODEBASE_FILE, SRC_DIR } from '../constants';\nimport { CodebaseAnalysis } from '../schemas';\n\nexport const transformJSON = (data: CodebaseAnalysis) => {\n let imports = 0;\n let exports = 0;\n let files = 0;\n\n const entries = Object.entries(data).map(\n ([\n key,\n { imports: _imports, relativePath, text, exports: _exports },\n ]) => {\n imports += _imports.length;\n exports += _exports?.length ?? 0;\n files++;\n\n const value: any = {\n imports: _imports,\n relativePath,\n text,\n exports: _exports?.filter(\n ({ moduleSpecifier }) => moduleSpecifier !== undefined,\n ),\n };\n\n return [key, value] as const;\n },\n );\n\n const CODEBASE_ANALYSIS = Object.fromEntries(entries);\n\n const STATS = {\n files,\n imports,\n exports,\n };\n\n return {\n STATS,\n CODEBASE_ANALYSIS,\n };\n};\n\nexport type GenerateOptions = {\n output?: string;\n excludes?: string[] | string;\n src?: string;\n};\n\n/**\n * Main execution function\n */\nexport const generate = ({\n output = DEFAULT_CODEBASE_FILE,\n excludes,\n src = SRC_DIR,\n}: GenerateOptions = {}) => {\n const _output = output.endsWith('codebase.json')\n ? output\n : `${output}.codebase.json`;\n\n try {\n const analysis = analyze({ src, excludes });\n const transformed = transformJSON(analysis);\n\n const json = JSON.stringify(transformed, null, 2);\n writeFileSync(_output, json);\n\n console.log(\n `š Analysis saved in: ${relative(process.cwd(), _output)}`,\n );\n console.log(`š Statistics:`);\n console.log(` - Files analyzed: ${transformed.STATS.files}`);\n console.log(` - Total imports: ${transformed.STATS.imports}`);\n console.log(` - Total exports: ${transformed.STATS.exports}`);\n } catch (error) {\n console.error('ā Error during codebase analysis:', error);\n process.exit(1);\n }\n\n return true;\n};\n"],"mappings":";;;;;AAMA,MAAa,iBAAiB,SAA2B;CACvD,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,QAAQ;CAEZ,MAAM,UAAU,OAAO,QAAQ,IAAI,CAAC,CAAC,KAClC,CACC,KACA,EAAE,SAAS,UAAU,cAAc,MAAM,SAAS,gBAC9C;EACJ,WAAW,SAAS;EACpB,WAAW,UAAU,UAAU;EAC/B;EAWA,OAAO,CAAC,KAAK;GARX,SAAS;GACT;GACA;GACA,SAAS,UAAU,QAChB,EAAE,sBAAsB,oBAAoB,KAAA,CAC/C;EAGe,CAAC;CACpB,CACF;CAEA,MAAM,oBAAoB,OAAO,YAAY,OAAO;CAQpD,OAAO;EACL,OAAA;GANA;GACA;GACA;EAII;EACJ;CACF;AACF;;;;AAWA,MAAa,YAAY,EACvB,SAAS,uBACT,UACA,MAAM,YACa,CAAC,MAAM;CAC1B,MAAM,UAAU,OAAO,SAAS,eAAe,IAC3C,SACA,GAAG,OAAO;CAEd,IAAI;EAEF,MAAM,cAAc,cADH,QAAQ;GAAE;GAAK;EAAS,CACA,CAAC;EAG1C,cAAc,SADD,KAAK,UAAU,aAAa,MAAM,CACrB,CAAC;EAE3B,QAAQ,IACN,yBAAyB,SAAS,QAAQ,IAAI,GAAG,OAAO,GAC1D;EACA,QAAQ,IAAI,gBAAgB;EAC5B,QAAQ,IAAI,wBAAwB,YAAY,MAAM,OAAO;EAC7D,QAAQ,IAAI,uBAAuB,YAAY,MAAM,SAAS;EAC9D,QAAQ,IAAI,uBAAuB,YAAY,MAAM,SAAS;CAChE,SAAS,OAAO;EACd,QAAQ,MAAM,qCAAqC,KAAK;EACxD,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.cjs","names":["writeFileAnalysis","DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","path","getFolderPath","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"init.cjs","names":["writeFileAnalysis","DEFAULT_PATH_KEY","DEFAULT_CLI_NAME","path","getFolderPath","PROPERTIES"],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { config } from '../config';\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\nconst initConfig = ({\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n}: InitOptions) => {\n config.bin = bin;\n config.json = json;\n config.tsConfigPath = path;\n config.root = root;\n\n return { root, json, path, bin };\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n options: InitOptions,\n) => {\n const { root, json, path, bin } = initConfig(options);\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Create the folder\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`ā
Folder ${bin} created in: ${root}`);\n } catch (error) {\n console.error(`ā Error creating the folder ${bin}:`, error);\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Create the types files structure\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`ā Error creating the types structure:`);\n return false;\n }\n\n // 2. Update tsconfig.json\n const tsconfigPath = join(cwd, 'tsconfig.json');\n\n if (existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n // Initialize compilerOptions and paths if they do not exist\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Add the path #bemedev/*\n const relativePath = relative(process.cwd(), folderPath);\n\n {\n // Remove baseUrl since typescript 6.0 will no longer use it\n // const baseUrl = tsconfig.compilerOptions.baseUrl;\n // if (typeof baseUrl === 'string') {\n // // If baseUrl is defined, calculate the relative path with respect to baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // If baseUrl is not defined, use the absolute path\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[path] = [`./${relativePath}/*`];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`ā
Path ${path} added to tsconfig.json`);\n } catch (error) {\n console.error(`ā Error updating tsconfig.json:`, error);\n return false;\n }\n } else {\n console.warn(`ā ļø File tsconfig.json not found, path not added`);\n }\n\n // 3. Create the .bemedev.json file at the root\n\n const jsonConfig = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(\n configFile,\n JSON.stringify(jsonConfig, null, 2),\n 'utf8',\n );\n console.log(`ā
File ${json} created at the root of the project`);\n } catch (error) {\n console.error(`ā Error creating the file ${json}:`, error);\n return false;\n }\n\n console.log(`š Bemedev initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;;AAsBA,MAAa,wBACX,YACA,sBACG;CACH,MAAM,UAAU,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAA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,GAAA,GAAA,WAAA,CAAe,YAAY,GACzB,IAAI;EACF,MAAM,mBAAA,GAAA,GAAA,aAAA,CAA+B,cAAc,MAAM;EACzD,MAAM,WAAW,KAAK,MAAM,eAAe;EAG3C,IAAI,CAAC,SAAS,iBACZ,SAAS,kBAAkB,CAAC;EAG9B,IAAI,CAAC,SAAS,gBAAgB,OAC5B,SAAS,gBAAgB,QAAQ,CAAC;EAIpC,MAAM,gBAAA,GAAA,KAAA,SAAA,CAAwB,QAAQ,IAAI,GAAG,UAAU;EAcvD,SAAS,gBAAgB,MAAMD,UAAQ,CAAC,KAAK,aAAa,GAAG;EAE7D,CAAA,GAAA,GAAA,cAAA,CACE,cACA,KAAK,UAAU,UAAU,MAAM,CAAC,GAChC,MACF;EACA,QAAQ,IAAI,UAAUA,OAAK,wBAAwB;CACrD,SAAS,OAAO;EACd,QAAQ,MAAM,mCAAmC,KAAK;EACtD,OAAO;CACT;MAEA,QAAQ,KAAK,iDAAiD;CAKhE,MAAM,aAAa;EACjB,SAAS;GACRE,kBAAAA,WAAW,OAAO;GAClBA,kBAAAA,WAAW,QAAQ;CACtB;CAEA,IAAI;EACF,CAAA,GAAA,GAAA,cAAA,CACE,YACA,KAAK,UAAU,YAAY,MAAM,CAAC,GAClC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,oCAAoC;CACjE,SAAS,OAAO;EACd,QAAQ,MAAM,6BAA6B,KAAK,IAAI,KAAK;EACzD,OAAO;CACT;CAEA,QAAQ,IAAI,mDAAmD;CAC/D,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/functions/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/functions/init.ts"],"names":[],"mappings":"AASA,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;AAgBF,eAAO,MAAM,IAAI,GACf,mBAAmB,gBAAgB,EACnC,SAAS,WAAW,YAkGrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"init.js","names":[],"sources":["../../src/functions/init.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { config } from '../config';\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\nconst initConfig = ({\n root,\n json,\n path = DEFAULT_PATH_KEY,\n bin = DEFAULT_CLI_NAME,\n}: InitOptions) => {\n config.bin = bin;\n config.json = json;\n config.tsConfigPath = path;\n config.root = root;\n\n return { root, json, path, bin };\n};\n\nexport const init = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n options: InitOptions,\n) => {\n const { root, json, path, bin } = initConfig(options);\n const cwd = process.cwd();\n const configFile = join(cwd, json);\n const configExists = existsSync(configFile);\n if (configExists) return true;\n const folderPath = getFolderPath(root);\n\n // 1. Create the folder\n try {\n mkdirSync(folderPath, { recursive: true });\n console.log(`ā
Folder ${bin} created in: ${root}`);\n } catch (error) {\n console.error(`ā Error creating the folder ${bin}:`, error);\n return false;\n }\n\n // eslint-disable-next-line no-useless-assignment\n let files: string[] = [];\n // 1.5. Create the types files structure\n try {\n files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);\n } catch {\n console.error(`ā Error creating the types structure:`);\n return false;\n }\n\n // 2. Update tsconfig.json\n const tsconfigPath = join(cwd, 'tsconfig.json');\n\n if (existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n // Initialize compilerOptions and paths if they do not exist\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n // Add the path #bemedev/*\n const relativePath = relative(process.cwd(), folderPath);\n\n {\n // Remove baseUrl since typescript 6.0 will no longer use it\n // const baseUrl = tsconfig.compilerOptions.baseUrl;\n // if (typeof baseUrl === 'string') {\n // // If baseUrl is defined, calculate the relative path with respect to baseUrl\n // relativePath = relative(baseUrl, relativePath);\n // } else {\n // // If baseUrl is not defined, use the absolute path\n // tsconfig.compilerOptions.baseUrl = '.';\n // }\n }\n\n tsconfig.compilerOptions.paths[path] = [`./${relativePath}/*`];\n\n writeFileSync(\n tsconfigPath,\n JSON.stringify(tsconfig, null, 2),\n 'utf8',\n );\n console.log(`ā
Path ${path} added to tsconfig.json`);\n } catch (error) {\n console.error(`ā Error updating tsconfig.json:`, error);\n return false;\n }\n } else {\n console.warn(`ā ļø File tsconfig.json not found, path not added`);\n }\n\n // 3. Create the .bemedev.json file at the root\n\n const jsonConfig = {\n version: '1.0.0',\n [PROPERTIES.PATH]: root,\n [PROPERTIES.FILES]: files,\n };\n\n try {\n writeFileSync(\n configFile,\n JSON.stringify(jsonConfig, null, 2),\n 'utf8',\n );\n console.log(`ā
File ${json} created at the root of the project`);\n } catch (error) {\n console.error(`ā Error creating the file ${json}:`, error);\n return false;\n }\n\n console.log(`š Bemedev initialization completed successfully!`);\n return true;\n};\n"],"mappings":";;;;;;AAsBA,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,MAAM,cAAc,EAClB,MACA,MACA,OAAO,kBACP,MAAM,uBACW;CACjB,OAAO,MAAM;CACb,OAAO,OAAO;CACd,OAAO,eAAe;CACtB,OAAO,OAAO;CAEd,OAAO;EAAE;EAAM;EAAM;EAAM;CAAI;AACjC;AAEA,MAAa,QACX,mBACA,YACG;CACH,MAAM,EAAE,MAAM,MAAM,MAAM,QAAQ,WAAW,OAAO;CACpD,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;EAcvD,SAAS,gBAAgB,MAAM,QAAQ,CAAC,KAAK,aAAa,GAAG;EAE7D,cACE,cACA,KAAK,UAAU,UAAU,MAAM,CAAC,GAChC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,wBAAwB;CACrD,SAAS,OAAO;EACd,QAAQ,MAAM,mCAAmC,KAAK;EACtD,OAAO;CACT;MAEA,QAAQ,KAAK,iDAAiD;CAKhE,MAAM,aAAa;EACjB,SAAS;GACR,WAAW,OAAO;GAClB,WAAW,QAAQ;CACtB;CAEA,IAAI;EACF,cACE,YACA,KAAK,UAAU,YAAY,MAAM,CAAC,GAClC,MACF;EACA,QAAQ,IAAI,UAAU,KAAK,oCAAoC;CACjE,SAAS,OAAO;EACd,QAAQ,MAAM,6BAA6B,KAAK,IAAI,KAAK;EACzD,OAAO;CACT;CAEA,QAAQ,IAAI,mDAAmD;CAC/D,OAAO;AACT"}
|
package/lib/functions/remove.cjs
CHANGED
|
@@ -59,7 +59,8 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
59
59
|
return require_helpers.consoleStars();
|
|
60
60
|
}
|
|
61
61
|
const formatteds = safesToRemove.map((key) => {
|
|
62
|
-
|
|
62
|
+
const _path = CODEBASE_ANALYSIS[`${key.replaceAll(".", "/")}`].relativePath;
|
|
63
|
+
return [key, (0, path.join)(root, _path)];
|
|
63
64
|
});
|
|
64
65
|
console.log(`šļø Deleting files (${safesToRemove.length} files)...`);
|
|
65
66
|
let success = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.cjs","names":["transformModule","config","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from '
|
|
1
|
+
{"version":3,"file":"remove.cjs","names":["transformModule","config","getFolderPath","PATH_PROPERTY","FILES_PROPERTY","consoleStars","path"],"sources":["../../src/functions/remove.ts"],"sourcesContent":["import edit, { JsonEditor } from 'edit-json-file';\nimport { unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { config } from '../config';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n} from '../helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}.index`]) // Add .index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, config.json);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`š§ Deleting of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`ā ļø ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ā ļø ${key} imported by:`);\n modules.forEach(m => console.warn(` -> š ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('ā No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path =\n CODEBASE_ANALYSIS[`${key.replaceAll('.', '/')}`].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":";;;;;;;;;;AAYA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;GAC5B,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,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,GAAGC,eAAAA,OAAO,IACa,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,OAAOC,gBAAAA,cAAc,KAAK,IAAIC,kBAAAA,aAAa,CAAW;EAC5D,MAAM,QAAQ,KAAK,IAAIC,kBAAAA,cAAc;EAErC,MAAM,WAAW,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,SAC1D,MAAM,SAAS,GAAG,CACpB;EAEA,MAAM,UAAU,SAAS,QAAQ,CAAC,SAChC,MAAM,MAAK,MAAK,IAAI,WAAW,CAAC,CAAC,CACnC;EAGA,MAAM,gBAA0B,CAAC;EACjC,MAAM,gBAAsC,CAAC;EAE7C,QAAQ,SAAS,CAAC,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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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/functions/remove.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,YAAY,CAAC;AA+B5D,eAAO,MAAM,MAAM,GACjB,mBAAmB,gBAAgB,EACnC,GAAG,OAAO,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/functions/remove.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,YAAY,CAAC;AA+B5D,eAAO,MAAM,MAAM,GACjB,mBAAmB,gBAAgB,EACnC,GAAG,OAAO,MAAM,EAAE,mBAkGnB,CAAC"}
|
package/lib/functions/remove.js
CHANGED
|
@@ -56,7 +56,8 @@ const remove = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
56
56
|
return consoleStars();
|
|
57
57
|
}
|
|
58
58
|
const formatteds = safesToRemove.map((key) => {
|
|
59
|
-
|
|
59
|
+
const _path = CODEBASE_ANALYSIS[`${key.replaceAll(".", "/")}`].relativePath;
|
|
60
|
+
return [key, join(root, _path)];
|
|
60
61
|
});
|
|
61
62
|
console.log(`šļø Deleting files (${safesToRemove.length} files)...`);
|
|
62
63
|
let success = 0;
|
|
@@ -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 '
|
|
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 { config } from '../config';\nimport { FILES_PROPERTY, PATH_PROPERTY } from '../constants';\nimport {\n consoleStars,\n getFolderPath,\n transformModule,\n} from '../helpers';\nimport { CodebaseAnalysis, FileAnalysis } from '../schemas';\n\nconst transformModules = (\n entries: [string, FileAnalysis][],\n ...files: string[]\n) => {\n const cwd = process.cwd();\n const out = entries\n .map(\n ([key, { imports, relativePath }]) =>\n [key, relativePath, imports] as const,\n )\n .map(([key, relativePath, imports]) => {\n const specifiers = imports\n .map(({ moduleSpecifier }) => {\n return transformModule({\n cwd,\n relativePath,\n moduleSpecifier,\n });\n })\n .map(_path => [_path, `${_path}.index`]) // Add .index variants\n .flat()\n .filter(s => files.includes(s));\n\n return [key, Array.from(new Set(specifiers))] as const;\n });\n\n return out;\n};\n\nexport const remove = (\n CODEBASE_ANALYSIS: CodebaseAnalysis,\n ...paths: string[]\n) => {\n const isEmpty = paths.length === 0;\n if (isEmpty) return console.warn('No files specified for removal.');\n try {\n const cwd = process.cwd();\n const json = join(cwd, config.json);\n let file: JsonEditor | undefined = edit(json);\n\n if (!file) return;\n\n const root = getFolderPath(file.get(PATH_PROPERTY) as string);\n const files = file.get(FILES_PROPERTY) as string[];\n\n const entries2 = Object.entries(CODEBASE_ANALYSIS).filter(([key]) =>\n files.includes(key),\n );\n\n const entries = entries2.filter(([key]) =>\n paths.some(p => key.startsWith(p)),\n );\n\n // Check dependencies before deletion\n const safesToRemove: string[] = [];\n const cannotsRemove: [string, string[]][] = [];\n\n entries.forEach(([key]) => {\n const modules = transformModules(entries2, ...files);\n const importedFroms = modules\n .filter(([, specifiers]) => specifiers.includes(key))\n .map(([k]) => k);\n\n const check = importedFroms.length > 0;\n\n console.log('modules', '=>', importedFroms);\n console.log('key', '=>', key);\n\n if (check) return cannotsRemove.push([key, importedFroms]);\n return safesToRemove.push(key);\n });\n\n consoleStars();\n console.log(`š§ Deleting of files (${entries.length} files)...`);\n\n // Display files that cannot be deleted\n if (cannotsRemove.length > 0) {\n const len = cannotsRemove.length;\n const one = 'file cannot be deleted (imported in other files)';\n const many = 'files cannot be deleted (imported in other files)';\n\n console.warn(`ā ļø ${len} ${len === 1 ? one : many} :`);\n cannotsRemove.forEach(([key, modules]) => {\n console.warn(` - ā ļø ${key} imported by:`);\n modules.forEach(m => console.warn(` -> š ${m}`));\n });\n }\n\n if (safesToRemove.length === 0) {\n console.warn('ā No files can be deleted.');\n return consoleStars();\n }\n\n const formatteds = safesToRemove.map(key => {\n const _path =\n CODEBASE_ANALYSIS[`${key.replaceAll('.', '/')}`].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":";;;;;;;AAYA,MAAM,oBACJ,SACA,GAAG,UACA;CACH,MAAM,MAAM,QAAQ,IAAI;CAsBxB,OArBY,QACT,KACE,CAAC,KAAK,EAAE,SAAS,oBAChB;EAAC;EAAK;EAAc;CAAO,CAC/B,CAAC,CACA,KAAK,CAAC,KAAK,cAAc,aAAa;EACrC,MAAM,aAAa,QAChB,KAAK,EAAE,sBAAsB;GAC5B,OAAO,gBAAgB;IACrB;IACA;IACA;GACF,CAAC;EACH,CAAC,CAAC,CACD,KAAI,UAAS,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,CAC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G;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,QACJ,kBAAkB,GAAG,IAAI,WAAW,KAAK,GAAG,IAAI,CAAC;GAEnD,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"}
|
package/lib/helpers.cjs
CHANGED
|
@@ -9,16 +9,16 @@ const transformModule = ({ cwd = process.cwd(), relativePath, moduleSpecifier })
|
|
|
9
9
|
const writeFileAnalysis = (fileAnalysis, folderPath) => {
|
|
10
10
|
const relativePath = fileAnalysis.relativePath;
|
|
11
11
|
const destPath = (0, path.join)(folderPath, relativePath);
|
|
12
|
-
const
|
|
12
|
+
const parsed = (0, path.parse)(destPath);
|
|
13
13
|
try {
|
|
14
|
-
(0, fs.mkdirSync)(
|
|
14
|
+
(0, fs.mkdirSync)(parsed.dir, { recursive: true });
|
|
15
15
|
let fileContent = fileAnalysis.text;
|
|
16
16
|
require_constants.REPLACERS.init.forEach(([search, replace]) => {
|
|
17
17
|
fileContent = fileContent.replaceAll(search, replace);
|
|
18
18
|
});
|
|
19
19
|
(0, fs.writeFileSync)(destPath, fileContent, "utf8");
|
|
20
20
|
console.log(` ā
${relativePath}`);
|
|
21
|
-
return
|
|
21
|
+
return parsed.name.replaceAll("/", ".");
|
|
22
22
|
} catch (error) {
|
|
23
23
|
return console.error(` ā Error for ${relativePath}:`, error);
|
|
24
24
|
}
|
package/lib/helpers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from '
|
|
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 ).replaceAll('/', '.');\n\n return out;\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in .bemedev 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 const out = parsed.name.replaceAll('/', '.');\n return out;\n } catch (error) {\n return console.error(` ā Error for ${relativePath}:`, error);\n }\n};\n\nexport const consoleStars = () => {\n console.log();\n console.log('*'.repeat(30));\n console.log();\n};\n\nexport const toArray = <T>(value?: T | T[]): T[] => {\n return Array.isArray(value) ? value : !value ? [] : [value];\n};\n\nexport const getFolderPath = (root: string) => {\n const cwd = process.cwd();\n const srcExists = existsSync(join(cwd, 'src'));\n const folderPath = srcExists\n ? join(cwd, 'src', root)\n : join(cwd, root);\n\n return folderPath;\n};\n"],"mappings":";;;;;AAWA,MAAa,mBAAmB,EAC9B,MAAM,QAAQ,IAAI,GAClB,cACA,sBACyB;CAMzB,QAAA,GAAA,KAAA,SAAA,CAJE,MAAA,GAAA,KAAA,QAAA,EAAA,GAAA,KAAA,QAAA,CACgB,YAAY,GAAG,eAAe,CAChD,CAAC,CAAC,WAAW,KAAK,GAET;AACX;AAEA,MAAa,qBACX,cACA,eACG;CACH,MAAM,eAAe,aAAa;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;EAEjC,OADY,OAAO,KAAK,WAAW,KAAK,GAC/B;CACX,SAAS,OAAO;EACd,OAAO,QAAQ,MAAM,iBAAiB,aAAa,IAAI,KAAK;CAC9D;AACF;AAEA,MAAa,qBAAqB;CAChC,QAAQ,IAAI;CACZ,QAAQ,IAAI,IAAI,OAAO,EAAE,CAAC;CAC1B,QAAQ,IAAI;AACd;AAEA,MAAa,WAAc,UAAyB;CAClD,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;AAC5D;AAEA,MAAa,iBAAiB,SAAiB;CAC7C,MAAM,MAAM,QAAQ,IAAI;CAMxB,QAAA,GAAA,GAAA,WAAA,EAAA,GAAA,KAAA,KAAA,CALkC,KAAK,KAAK,CACjB,KAAA,GAAA,KAAA,KAAA,CAClB,KAAK,OAAO,IAAI,KAAA,GAAA,KAAA,KAAA,CAChB,KAAK,IAAI;AAGpB"}
|
package/lib/helpers.d.ts.map
CHANGED
|
@@ -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,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,yCAI7B,mBAAmB,WAOrB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,YAAY,MAAM,kBAwBnB,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"}
|
package/lib/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { REPLACERS } from "./constants.js";
|
|
2
|
-
import { dirname, join, relative, resolve } from "path";
|
|
2
|
+
import { dirname, join, parse, relative, resolve } from "path";
|
|
3
3
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
4
4
|
//#region src/helpers.ts
|
|
5
5
|
const transformModule = ({ cwd = process.cwd(), relativePath, moduleSpecifier }) => {
|
|
@@ -8,16 +8,16 @@ const transformModule = ({ cwd = process.cwd(), relativePath, moduleSpecifier })
|
|
|
8
8
|
const writeFileAnalysis = (fileAnalysis, folderPath) => {
|
|
9
9
|
const relativePath = fileAnalysis.relativePath;
|
|
10
10
|
const destPath = join(folderPath, relativePath);
|
|
11
|
-
const
|
|
11
|
+
const parsed = parse(destPath);
|
|
12
12
|
try {
|
|
13
|
-
mkdirSync(
|
|
13
|
+
mkdirSync(parsed.dir, { recursive: true });
|
|
14
14
|
let fileContent = fileAnalysis.text;
|
|
15
15
|
REPLACERS.init.forEach(([search, replace]) => {
|
|
16
16
|
fileContent = fileContent.replaceAll(search, replace);
|
|
17
17
|
});
|
|
18
18
|
writeFileSync(destPath, fileContent, "utf8");
|
|
19
19
|
console.log(` ā
${relativePath}`);
|
|
20
|
-
return
|
|
20
|
+
return parsed.name.replaceAll("/", ".");
|
|
21
21
|
} catch (error) {
|
|
22
22
|
return console.error(` ā Error for ${relativePath}:`, error);
|
|
23
23
|
}
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from '
|
|
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 ).replaceAll('/', '.');\n\n return out;\n};\n\nexport const writeFileAnalysis = (\n fileAnalysis: FileAnalysis,\n folderPath: string,\n) => {\n const relativePath = fileAnalysis.relativePath;\n // Create the destination path in .bemedev 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 const out = parsed.name.replaceAll('/', '.');\n return out;\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,CAChD,CAAC,CAAC,WAAW,KAAK,GAET;AACX;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;EAEjC,OADY,OAAO,KAAK,WAAW,KAAK,GAC/B;CACX,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"}
|
package/lib/imports.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.cjs","names":["SyntaxKind"],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from '
|
|
1
|
+
{"version":3,"file":"imports.cjs","names":["SyntaxKind"],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './schemas';\n\n/**\n * Resolves the moduleSpecifier using the tsconfig paths if it starts with \"#\"\n */\nconst resolveModuleSpecifier = (\n sourceFile: SourceFile,\n moduleSpecifier: string,\n): string => {\n const paths = sourceFile.getProject().getCompilerOptions().paths;\n\n if (!paths) return moduleSpecifier;\n\n const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;\n const paths2 = Object.entries(paths);\n\n // Find the match in paths\n for (const [pattern, mappings] of paths2) {\n // Replace * with a regex to match\n const regexPattern = pattern.replace(/\\*/g, '(.*)');\n const regex = new RegExp(`^${regexPattern}$`);\n const match = moduleSpecifier.match(regex);\n\n if (match) {\n // Take the first available mapping\n const first = mappings[0];\n\n // Resolve the absolute path\n let relativedPath = baseUrl ? join(baseUrl, first) : first;\n\n if (match[1]) {\n relativedPath = relativedPath.replace('*', match[1]);\n }\n\n // Calculate the relative path from the current source file\n const sourceFileDir = relative(\n process.cwd(),\n sourceFile.getDirectoryPath(),\n );\n const relativePath = relative(sourceFileDir, relativedPath);\n\n // Make sure the relative path starts with ./ or ../\n return relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n }\n }\n\n return moduleSpecifier;\n};\n\n/**\n * Analyzes a file's imports\n */\nexport const analyzeImports = (\n sourceFile: SourceFile,\n): ImportInfo[] => {\n const imports: ImportInfo[] = [];\n\n // Import declarations (import ... from '...')\n sourceFile.getImportDeclarations().forEach(importDecl => {\n // Determine if this is a type-only import\n const isTypeOnly = importDecl.isTypeOnly();\n\n const rawModuleSpecifier = importDecl.getModuleSpecifierValue();\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n\n // Import default\n const defaultImport = importDecl.getDefaultImport();\n if (defaultImport) {\n imports.push({\n moduleSpecifier,\n kind: 'default',\n default: defaultImport.getText(),\n isTypeOnly,\n });\n }\n\n // Import namespace (* as name)\n const namespaceImport = importDecl.getNamespaceImport();\n if (namespaceImport) {\n imports.push({\n moduleSpecifier,\n kind: 'namespace',\n default: namespaceImport.getText(),\n isTypeOnly,\n });\n }\n\n // Named imports ({ name1, name2 })\n const namedImports = importDecl.getNamedImports();\n if (namedImports.length > 0) {\n imports.push({\n moduleSpecifier,\n kind: 'named',\n namedImports: namedImports.map(ni => ni.getName()),\n isTypeOnly,\n });\n }\n\n // Side-effect import (import '...')\n if (\n !defaultImport &&\n !namespaceImport &&\n namedImports.length === 0\n ) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isTypeOnly,\n });\n }\n });\n\n // Dynamic imports (import('...'))\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .forEach(callExpr => {\n if (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"mappings":";;;;;;;AAOA,MAAM,0BACJ,YACA,oBACW;CACX,MAAM,QAAQ,WAAW,WAAW,CAAC,CAAC,mBAAmB,CAAC,CAAC;CAE3D,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,UAAU,WAAW,W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AAC,iBACD,CAAC,mBACD,aAAa,WAAW,GAExB,QAAQ,KAAK;GACX;GACA,MAAM;GACN;EACF,CAAC;CAEL,CAAC;CAGD,WACG,qBAAqBA,SAAAA,WAAW,cAAc,CAAC,CAC/C,SAAQ,aAAY;EACnB,IACE,SAAS,cAAc,CAAC,CAAC,QAAQ,MAAMA,SAAAA,WAAW,eAClD;GACA,MAAM,MAAM,SAAS,aAAa,CAAC,CAAC;GACpC,IAAI,OAAO,IAAI,QAAQ,MAAMA,SAAAA,WAAW,eAAe;IAErD,MAAM,kBAAkB,uBACtB,YAFyB,IAAI,QAAQ,CAAC,CAAC,QAAQ,SAAS,EAGvC,CACnB;IACA,QAAQ,KAAK;KACX;KACA,MAAM;KACN,WAAW;IACb,CAAC;GACH;EACF;CACF,CAAC;CAEH,OAAO;AACT;AAEA,MAAa,sBAAsB,YAA0B;CAC3D,OAAO,QAAQ,KAAI,QAAO;EACxB,QAAQ,IAAI,MAAZ;GACE,KAAK,SAAS;IACZ,MAAM,eAAe,IAAI,cAAc,KAAK,IAAI,KAAK;IACrD,OAAO,UAAU,IAAI,aAAa,UAAU,GAAG,IAAI,aAAa,WAAW,IAAI,gBAAgB;GACjG;GACA,KAAK,aACH,OAAO,UAAU,IAAI,aAAa,UAAU,GAAG,OAAO,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GACjG,KAAK;IACH,IAAI,IAAI,WACN,OAAO,8BAA8B,IAAI,gBAAgB;IAE3D,OAAO,WAAW,IAAI,gBAAgB;GAGxC,KAAK,WACH,OAAO,UAAU,IAAI,aAAa,UAAU,KAAK,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GAC5F,SACE,OAAO;EACX;CACF,CAAC;AACH"}
|
package/lib/imports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.js","names":[],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from '
|
|
1
|
+
{"version":3,"file":"imports.js","names":[],"sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './schemas';\n\n/**\n * Resolves the moduleSpecifier using the tsconfig paths if it starts with \"#\"\n */\nconst resolveModuleSpecifier = (\n sourceFile: SourceFile,\n moduleSpecifier: string,\n): string => {\n const paths = sourceFile.getProject().getCompilerOptions().paths;\n\n if (!paths) return moduleSpecifier;\n\n const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;\n const paths2 = Object.entries(paths);\n\n // Find the match in paths\n for (const [pattern, mappings] of paths2) {\n // Replace * with a regex to match\n const regexPattern = pattern.replace(/\\*/g, '(.*)');\n const regex = new RegExp(`^${regexPattern}$`);\n const match = moduleSpecifier.match(regex);\n\n if (match) {\n // Take the first available mapping\n const first = mappings[0];\n\n // Resolve the absolute path\n let relativedPath = baseUrl ? join(baseUrl, first) : first;\n\n if (match[1]) {\n relativedPath = relativedPath.replace('*', match[1]);\n }\n\n // Calculate the relative path from the current source file\n const sourceFileDir = relative(\n process.cwd(),\n sourceFile.getDirectoryPath(),\n );\n const relativePath = relative(sourceFileDir, relativedPath);\n\n // Make sure the relative path starts with ./ or ../\n return relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n }\n }\n\n return moduleSpecifier;\n};\n\n/**\n * Analyzes a file's imports\n */\nexport const analyzeImports = (\n sourceFile: SourceFile,\n): ImportInfo[] => {\n const imports: ImportInfo[] = [];\n\n // Import declarations (import ... from '...')\n sourceFile.getImportDeclarations().forEach(importDecl => {\n // Determine if this is a type-only import\n const isTypeOnly = importDecl.isTypeOnly();\n\n const rawModuleSpecifier = importDecl.getModuleSpecifierValue();\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n\n // Import default\n const defaultImport = importDecl.getDefaultImport();\n if (defaultImport) {\n imports.push({\n moduleSpecifier,\n kind: 'default',\n default: defaultImport.getText(),\n isTypeOnly,\n });\n }\n\n // Import namespace (* as name)\n const namespaceImport = importDecl.getNamespaceImport();\n if (namespaceImport) {\n imports.push({\n moduleSpecifier,\n kind: 'namespace',\n default: namespaceImport.getText(),\n isTypeOnly,\n });\n }\n\n // Named imports ({ name1, name2 })\n const namedImports = importDecl.getNamedImports();\n if (namedImports.length > 0) {\n imports.push({\n moduleSpecifier,\n kind: 'named',\n namedImports: namedImports.map(ni => ni.getName()),\n isTypeOnly,\n });\n }\n\n // Side-effect import (import '...')\n if (\n !defaultImport &&\n !namespaceImport &&\n namedImports.length === 0\n ) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isTypeOnly,\n });\n }\n });\n\n // Dynamic imports (import('...'))\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .forEach(callExpr => {\n if (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"mappings":";;;;;;AAOA,MAAM,0BACJ,YACA,o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c,aAAa,KAAI,OAAM,GAAG,QAAQ,CAAC;GACjD;EACF,CAAC;EAIH,IACE,CAAC,iBACD,CAAC,mBACD,aAAa,WAAW,GAExB,QAAQ,KAAK;GACX;GACA,MAAM;GACN;EACF,CAAC;CAEL,CAAC;CAGD,WACG,qBAAqB,WAAW,cAAc,CAAC,CAC/C,SAAQ,aAAY;EACnB,IACE,SAAS,cAAc,CAAC,CAAC,QAAQ,MAAM,WAAW,eAClD;GACA,MAAM,MAAM,SAAS,aAAa,CAAC,CAAC;GACpC,IAAI,OAAO,IAAI,QAAQ,MAAM,WAAW,eAAe;IAErD,MAAM,kBAAkB,uBACtB,YAFyB,IAAI,QAAQ,CAAC,CAAC,QAAQ,SAAS,EAGvC,CACnB;IACA,QAAQ,KAAK;KACX;KACA,MAAM;KACN,WAAW;IACb,CAAC;GACH;EACF;CACF,CAAC;CAEH,OAAO;AACT;AAEA,MAAa,sBAAsB,YAA0B;CAC3D,OAAO,QAAQ,KAAI,QAAO;EACxB,QAAQ,IAAI,MAAZ;GACE,KAAK,SAAS;IACZ,MAAM,eAAe,IAAI,cAAc,KAAK,IAAI,KAAK;IACrD,OAAO,UAAU,IAAI,aAAa,UAAU,GAAG,IAAI,aAAa,WAAW,IAAI,gBAAgB;GACjG;GACA,KAAK,aACH,OAAO,UAAU,IAAI,aAAa,UAAU,GAAG,OAAO,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GACjG,KAAK;IACH,IAAI,IAAI,WACN,OAAO,8BAA8B,IAAI,gBAAgB;IAE3D,OAAO,WAAW,IAAI,gBAAgB;GAGxC,KAAK,WACH,OAAO,UAAU,IAAI,aAAa,UAAU,KAAK,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GAC5F,SACE,OAAO;EACX;CACF,CAAC;AACH"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_schemas = require("./schemas.cjs");
|
|
3
|
+
const require_helpers = require("./helpers.cjs");
|
|
3
4
|
const require_analyse = require("./analyse.cjs");
|
|
4
5
|
const require_config = require("./config.cjs");
|
|
5
6
|
const require_functions_add = require("./functions/add.cjs");
|
|
@@ -17,8 +18,10 @@ exports.ImportInfoSchema = require_schemas.ImportInfoSchema;
|
|
|
17
18
|
exports.add = require_functions_add.add;
|
|
18
19
|
exports.analyze = require_analyse.analyze;
|
|
19
20
|
exports.config = require_config.config;
|
|
21
|
+
exports.consoleStars = require_helpers.consoleStars;
|
|
20
22
|
exports.createTypesStructure = require_functions_init.createTypesStructure;
|
|
21
23
|
exports.generate = require_functions_generate.generate;
|
|
24
|
+
exports.getFolderPath = require_helpers.getFolderPath;
|
|
22
25
|
exports.init = require_functions_init.init;
|
|
23
26
|
exports.remove = require_functions_remove.remove;
|
|
24
27
|
exports.transformJSON = require_functions_generate.transformJSON;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './analyse';
|
|
2
|
+
export * from './config';
|
|
2
3
|
export * from './functions';
|
|
4
|
+
export { consoleStars, getFolderPath } from './helpers';
|
|
3
5
|
export * from './schemas';
|
|
4
6
|
export * from './types';
|
|
5
|
-
export * from './config';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema } from "./schemas.js";
|
|
2
|
+
import { consoleStars, getFolderPath } from "./helpers.js";
|
|
2
3
|
import { analyze } from "./analyse.js";
|
|
3
4
|
import { config } from "./config.js";
|
|
4
5
|
import { add } from "./functions/add.js";
|
|
@@ -6,4 +7,4 @@ import { generate, transformJSON } from "./functions/generate.js";
|
|
|
6
7
|
import { createTypesStructure, init } from "./functions/init.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, config, createTypesStructure, generate, init, remove, transformJSON };
|
|
10
|
+
export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, config, consoleStars, createTypesStructure, generate, getFolderPath, init, remove, transformJSON };
|
package/lib/utils.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
5
5
|
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
6
6
|
*/
|
|
7
7
|
function pathToDotNotation(filePath) {
|
|
8
|
-
return filePath.replace(/\.ts$/, "").replace(/\//g, ".");
|
|
8
|
+
return filePath.replace(/\.ts$/, "").replace(/\.tsx$/, "").replace(/\//g, ".");
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
11
|
exports.pathToDotNotation = pathToDotNotation;
|
package/lib/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,OAAO,GAAG;AACvB"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\.tsx$/, '') // Remove the .tsx extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,OAAO,GAAG;AACvB"}
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1D"}
|
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
5
5
|
*/
|
|
6
6
|
function pathToDotNotation(filePath) {
|
|
7
|
-
return filePath.replace(/\.ts$/, "").replace(/\//g, ".");
|
|
7
|
+
return filePath.replace(/\.ts$/, "").replace(/\.tsx$/, "").replace(/\//g, ".");
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { pathToDotNotation };
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,OAAO,GAAG;AACvB"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/**\n * Converts a file path to a dot notation key as in .manifest.ts\n * Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'\n */\nexport function pathToDotNotation(filePath: string): string {\n return filePath\n .replace(/\\.ts$/, '') // Remove the .ts extension\n .replace(/\\.tsx$/, '') // Remove the .tsx extension\n .replace(/\\//g, '.'); // Replace / with .\n}\n"],"mappings":";;;;;AAIA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,SACJ,QAAQ,SAAS,EAAE,CAAC,CACpB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,OAAO,GAAG;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/codebase",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"valibot": "^1.4.1"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
|
-
"build": "pnpm rm:lib && pnpm run rolldown && pnpm run codegen",
|
|
90
|
+
"build": "pnpm rm:lib && pnpm run rolldown && pnpm run codegen && chmod +x lib/cli/index.js",
|
|
91
91
|
"_ci": "pnpm run config:off && pnpm run lint && pnpm run test",
|
|
92
92
|
"ci": "CI_START=$(date +%s) && pnpm run _ci && pnpm run p-q && echo \"\nā
CI takes $(($(date +%s) - CI_START))s\n\"",
|
|
93
93
|
"ci:admin": "CI_START=$(date +%s) && pnpm run rm && pnpm run upgrade && pnpm run _ci && echo \"\nā
CI_ADMIN takes $(($(date +%s) - CI_START))s\n\"",
|