@bemedev/codebase 0.2.0 → 1.0.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 +18 -5
- package/lib/analyse.cjs +5 -5
- package/lib/analyse.cjs.map +1 -1
- package/lib/analyse.d.ts +2 -1
- package/lib/analyse.d.ts.map +1 -0
- package/lib/analyse.js +4 -4
- package/lib/analyse.js.map +1 -1
- package/lib/analyse.utils.cjs +6 -6
- package/lib/analyse.utils.cjs.map +1 -1
- package/lib/analyse.utils.d.ts +8 -7
- package/lib/analyse.utils.d.ts.map +1 -0
- package/lib/analyse.utils.js +6 -6
- package/lib/analyse.utils.js.map +1 -1
- package/lib/cli/cli.cjs +0 -1
- package/lib/cli/cli.cjs.map +1 -1
- package/lib/cli/cli.d.ts +1 -0
- package/lib/cli/cli.d.ts.map +1 -0
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/constants.d.ts +1 -0
- package/lib/cli/constants.d.ts.map +1 -0
- package/lib/cli/index.cjs +0 -1
- package/lib/cli/index.cjs.map +1 -1
- package/lib/cli/index.d.ts +1 -0
- package/lib/cli/index.d.ts.map +1 -0
- package/lib/cli/index.js +0 -0
- package/lib/cli/index.js.map +1 -1
- package/lib/config.cjs +12 -0
- package/lib/config.cjs.map +1 -0
- package/lib/config.d.ts +7 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +11 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.cjs +6 -5
- package/lib/constants.cjs.map +1 -1
- package/lib/constants.d.ts +4 -2
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +4 -3
- package/lib/constants.js.map +1 -1
- package/lib/exports.cjs +0 -1
- package/lib/exports.cjs.map +1 -1
- package/lib/exports.d.ts +1 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js.map +1 -1
- package/lib/functions/add.cjs +6 -5
- package/lib/functions/add.cjs.map +1 -1
- package/lib/functions/add.d.ts +2 -1
- package/lib/functions/add.d.ts.map +1 -0
- package/lib/functions/add.js +6 -5
- package/lib/functions/add.js.map +1 -1
- package/lib/functions/generate.cjs +5 -6
- package/lib/functions/generate.cjs.map +1 -1
- package/lib/functions/generate.d.ts +3 -2
- package/lib/functions/generate.d.ts.map +1 -0
- package/lib/functions/generate.js +5 -5
- package/lib/functions/generate.js.map +1 -1
- package/lib/functions/index.d.ts +1 -0
- package/lib/functions/index.d.ts.map +1 -0
- package/lib/functions/init.cjs +29 -16
- package/lib/functions/init.cjs.map +1 -1
- package/lib/functions/init.d.ts +7 -4
- package/lib/functions/init.d.ts.map +1 -0
- package/lib/functions/init.js +30 -16
- package/lib/functions/init.js.map +1 -1
- package/lib/functions/remove.cjs +11 -10
- package/lib/functions/remove.cjs.map +1 -1
- package/lib/functions/remove.d.ts +2 -1
- package/lib/functions/remove.d.ts.map +1 -0
- package/lib/functions/remove.js +11 -10
- package/lib/functions/remove.js.map +1 -1
- package/lib/helpers.cjs +1 -2
- package/lib/helpers.cjs.map +1 -1
- package/lib/helpers.d.ts +4 -3
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/imports.cjs +2 -3
- package/lib/imports.cjs.map +1 -1
- package/lib/imports.d.ts +4 -3
- package/lib/imports.d.ts.map +1 -0
- package/lib/imports.js +2 -2
- package/lib/imports.js.map +1 -1
- package/lib/index.cjs +2 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -1
- package/lib/schemas.cjs +1 -1
- package/lib/schemas.cjs.map +1 -1
- package/lib/schemas.d.ts +2 -1
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js.map +1 -1
- package/lib/types.d.ts +1 -6
- package/lib/types.d.ts.map +1 -0
- package/lib/utils.cjs +1 -1
- package/lib/utils.cjs.map +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +42 -61
package/lib/constants.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
let path = require("path");
|
|
4
3
|
//#region src/constants.ts
|
|
5
4
|
const SRC_DIR = (0, path.join)(process.cwd(), "src");
|
|
6
5
|
const CODEBASE_FILE = (0, path.join)(process.cwd(), ".codebase.json");
|
|
7
6
|
const _REPLACER = "-|||-";
|
|
7
|
+
const DEFAULT_CLI_NAME = "codebase";
|
|
8
8
|
const REPLACERS = {
|
|
9
9
|
code: [
|
|
10
10
|
["\\`", `${_REPLACER}w`],
|
|
@@ -15,8 +15,8 @@ const REPLACERS = {
|
|
|
15
15
|
],
|
|
16
16
|
init: [[/* @__PURE__ */ new RegExp("\\`", "g"), "`"], [_REPLACER, ""]]
|
|
17
17
|
};
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const DEFAULT_PATH_KEY = "#bemedev/*";
|
|
19
|
+
const DEFAULT_JSON_FILE_NAME = ".bemedev.json";
|
|
20
20
|
const PATH_PROPERTY = "path";
|
|
21
21
|
const FILES_PROPERTY = "files";
|
|
22
22
|
const PROPERTIES = {
|
|
@@ -27,9 +27,10 @@ const PROPERTIES = {
|
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
exports.CODEBASE_FILE = CODEBASE_FILE;
|
|
30
|
+
exports.DEFAULT_CLI_NAME = DEFAULT_CLI_NAME;
|
|
31
|
+
exports.DEFAULT_JSON_FILE_NAME = DEFAULT_JSON_FILE_NAME;
|
|
32
|
+
exports.DEFAULT_PATH_KEY = DEFAULT_PATH_KEY;
|
|
30
33
|
exports.FILES_PROPERTY = FILES_PROPERTY;
|
|
31
|
-
exports.JSON_FILE_NAME = JSON_FILE_NAME;
|
|
32
|
-
exports.PATH_KEY = PATH_KEY;
|
|
33
34
|
exports.PATH_PROPERTY = PATH_PROPERTY;
|
|
34
35
|
exports.PROPERTIES = PROPERTIES;
|
|
35
36
|
exports.REPLACERS = REPLACERS;
|
package/lib/constants.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const CODEBASE_FILE = join(process.cwd(), '.codebase.json');\n\nconst _REPLACER = '-|||-';\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
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const CODEBASE_FILE = join(process.cwd(), '.codebase.json');\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,iBAAA,GAAA,KAAA,KAAA,CAAqB,QAAQ,IAAI,GAAG,gBAAgB;AAEjE,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,11 +1,12 @@
|
|
|
1
1
|
export declare const SRC_DIR: string;
|
|
2
2
|
export declare const CODEBASE_FILE: string;
|
|
3
|
+
export declare const DEFAULT_CLI_NAME = "codebase";
|
|
3
4
|
export declare const REPLACERS: {
|
|
4
5
|
readonly code: readonly [readonly ["\\`", "-|||-w"], readonly ["`", "\\`"], readonly ["${", "$-|||-{"], readonly ["\\s", "-|||-s"], readonly ["\\w", "-|||-w"]];
|
|
5
6
|
readonly init: readonly [readonly [RegExp, "`"], readonly ["-|||-", ""]];
|
|
6
7
|
};
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const DEFAULT_PATH_KEY = "#bemedev/*";
|
|
9
|
+
export declare const DEFAULT_JSON_FILE_NAME = ".bemedev.json";
|
|
9
10
|
export declare const PATH_PROPERTY = "path";
|
|
10
11
|
export declare const FILES_PROPERTY = "files";
|
|
11
12
|
export declare const PROPERTIES: {
|
|
@@ -14,3 +15,4 @@ export declare const PROPERTIES: {
|
|
|
14
15
|
readonly CODEBASE_ANALYSIS: "CODEBASE_ANALYSIS";
|
|
15
16
|
readonly STATS: "STATS";
|
|
16
17
|
};
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAA6B,CAAC;AAClD,eAAO,MAAM,aAAa,QAAwC,CAAC;AAInE,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
|
@@ -3,6 +3,7 @@ import { join } from "path";
|
|
|
3
3
|
const SRC_DIR = join(process.cwd(), "src");
|
|
4
4
|
const CODEBASE_FILE = join(process.cwd(), ".codebase.json");
|
|
5
5
|
const _REPLACER = "-|||-";
|
|
6
|
+
const DEFAULT_CLI_NAME = "codebase";
|
|
6
7
|
const REPLACERS = {
|
|
7
8
|
code: [
|
|
8
9
|
["\\`", `${_REPLACER}w`],
|
|
@@ -13,8 +14,8 @@ const REPLACERS = {
|
|
|
13
14
|
],
|
|
14
15
|
init: [[/* @__PURE__ */ new RegExp("\\`", "g"), "`"], [_REPLACER, ""]]
|
|
15
16
|
};
|
|
16
|
-
const
|
|
17
|
-
const
|
|
17
|
+
const DEFAULT_PATH_KEY = "#bemedev/*";
|
|
18
|
+
const DEFAULT_JSON_FILE_NAME = ".bemedev.json";
|
|
18
19
|
const PATH_PROPERTY = "path";
|
|
19
20
|
const FILES_PROPERTY = "files";
|
|
20
21
|
const PROPERTIES = {
|
|
@@ -24,6 +25,6 @@ const PROPERTIES = {
|
|
|
24
25
|
STATS: "STATS"
|
|
25
26
|
};
|
|
26
27
|
//#endregion
|
|
27
|
-
export { CODEBASE_FILE,
|
|
28
|
+
export { CODEBASE_FILE, DEFAULT_CLI_NAME, DEFAULT_JSON_FILE_NAME, DEFAULT_PATH_KEY, FILES_PROPERTY, PATH_PROPERTY, PROPERTIES, REPLACERS, SRC_DIR };
|
|
28
29
|
|
|
29
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 'node:path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const CODEBASE_FILE = join(process.cwd(), '.codebase.json');\n\nconst _REPLACER = '-|||-';\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
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\n\nexport const SRC_DIR = join(process.cwd(), 'src');\nexport const CODEBASE_FILE = join(process.cwd(), '.codebase.json');\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,gBAAgB,KAAK,QAAQ,IAAI,GAAG,gBAAgB;AAEjE,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/exports.cjs
CHANGED
package/lib/exports.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.cjs","names":["SyntaxKind"],"sources":["../src/exports.ts"],"sourcesContent":["import { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ExportInfo } from './schemas';\n\nexport const analyzeExports = (sourceFile: SourceFile) => {\n const exports: ExportInfo[] = [];\n\n // Export declarations (export ...)\n sourceFile.getExportDeclarations().forEach(exportDecl => {\n const moduleSpecifier = exportDecl.getModuleSpecifierValue();\n const exportText = exportDecl.getText();\n\n // Named exports\n const namedExports = exportDecl.getNamedExports();\n namedExports.forEach(namedExport => {\n exports.push({\n name: namedExport.getName(),\n kind: 'named',\n text: exportText,\n moduleSpecifier,\n });\n });\n\n // Namespace export (export * from '...')\n if (exportDecl.isNamespaceExport()) {\n exports.push({\n name: '*',\n kind: 'namespace',\n text: exportText,\n moduleSpecifier,\n });\n }\n });\n\n // Export assignments (export = ...)\n sourceFile.getExportAssignments().forEach(exportAssignment => {\n if (exportAssignment.isExportEquals()) {\n exports.push({\n name: 'default',\n kind: 'default',\n text: exportAssignment.getText(),\n });\n }\n });\n\n // Exported declarations (export function, export class, etc.)\n sourceFile.getExportedDeclarations().forEach((declarations, name) => {\n declarations.forEach(decl => {\n let declarationKind: ExportInfo['declarationKind'];\n\n if (decl.getKind() === SyntaxKind.FunctionDeclaration) {\n declarationKind = 'function';\n } else if (decl.getKind() === SyntaxKind.ClassDeclaration) {\n declarationKind = 'class';\n } else if (decl.getKind() === SyntaxKind.InterfaceDeclaration) {\n declarationKind = 'interface';\n } else if (decl.getKind() === SyntaxKind.TypeAliasDeclaration) {\n declarationKind = 'type';\n } else if (decl.getKind() === SyntaxKind.VariableDeclaration) {\n declarationKind = 'variable';\n } else if (decl.getKind() === SyntaxKind.EnumDeclaration) {\n declarationKind = 'enum';\n }\n\n exports.push({\n name,\n kind: name === 'default' ? 'default' : 'named',\n text: decl.getText(),\n declarationKind,\n });\n });\n });\n\n return exports;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exports.cjs","names":["SyntaxKind"],"sources":["../src/exports.ts"],"sourcesContent":["import { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ExportInfo } from './schemas';\n\nexport const analyzeExports = (sourceFile: SourceFile) => {\n const exports: ExportInfo[] = [];\n\n // Export declarations (export ...)\n sourceFile.getExportDeclarations().forEach(exportDecl => {\n const moduleSpecifier = exportDecl.getModuleSpecifierValue();\n const exportText = exportDecl.getText();\n\n // Named exports\n const namedExports = exportDecl.getNamedExports();\n namedExports.forEach(namedExport => {\n exports.push({\n name: namedExport.getName(),\n kind: 'named',\n text: exportText,\n moduleSpecifier,\n });\n });\n\n // Namespace export (export * from '...')\n if (exportDecl.isNamespaceExport()) {\n exports.push({\n name: '*',\n kind: 'namespace',\n text: exportText,\n moduleSpecifier,\n });\n }\n });\n\n // Export assignments (export = ...)\n sourceFile.getExportAssignments().forEach(exportAssignment => {\n if (exportAssignment.isExportEquals()) {\n exports.push({\n name: 'default',\n kind: 'default',\n text: exportAssignment.getText(),\n });\n }\n });\n\n // Exported declarations (export function, export class, etc.)\n sourceFile.getExportedDeclarations().forEach((declarations, name) => {\n declarations.forEach(decl => {\n let declarationKind: ExportInfo['declarationKind'];\n\n if (decl.getKind() === SyntaxKind.FunctionDeclaration) {\n declarationKind = 'function';\n } else if (decl.getKind() === SyntaxKind.ClassDeclaration) {\n declarationKind = 'class';\n } else if (decl.getKind() === SyntaxKind.InterfaceDeclaration) {\n declarationKind = 'interface';\n } else if (decl.getKind() === SyntaxKind.TypeAliasDeclaration) {\n declarationKind = 'type';\n } else if (decl.getKind() === SyntaxKind.VariableDeclaration) {\n declarationKind = 'variable';\n } else if (decl.getKind() === SyntaxKind.EnumDeclaration) {\n declarationKind = 'enum';\n }\n\n exports.push({\n name,\n kind: name === 'default' ? 'default' : 'named',\n text: decl.getText(),\n declarationKind,\n });\n });\n });\n\n return exports;\n};\n"],"mappings":";;;AAGA,MAAa,kBAAkB,eAA2B;CACxD,MAAM,UAAwB,CAAC;CAG/B,WAAW,sBAAsB,CAAC,CAAC,SAAQ,eAAc;EACvD,MAAM,kBAAkB,WAAW,wBAAwB;EAC3D,MAAM,aAAa,WAAW,QAAQ;EAItC,WADgC,gBACrB,CAAC,CAAC,SAAQ,gBAAe;GAClC,QAAQ,KAAK;IACX,MAAM,YAAY,QAAQ;IAC1B,MAAM;IACN,MAAM;IACN;GACF,CAAC;EACH,CAAC;EAGD,IAAI,WAAW,kBAAkB,GAC/B,QAAQ,KAAK;GACX,MAAM;GACN,MAAM;GACN,MAAM;GACN;EACF,CAAC;CAEL,CAAC;CAGD,WAAW,qBAAqB,CAAC,CAAC,SAAQ,qBAAoB;EAC5D,IAAI,iBAAiB,eAAe,GAClC,QAAQ,KAAK;GACX,MAAM;GACN,MAAM;GACN,MAAM,iBAAiB,QAAQ;EACjC,CAAC;CAEL,CAAC;CAGD,WAAW,wBAAwB,CAAC,CAAC,SAAS,cAAc,SAAS;EACnE,aAAa,SAAQ,SAAQ;GAC3B,IAAI;GAEJ,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,qBAChC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,kBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,sBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,sBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,qBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAMA,SAAAA,WAAW,iBACvC,kBAAkB;GAGpB,QAAQ,KAAK;IACX;IACA,MAAM,SAAS,YAAY,YAAY;IACvC,MAAM,KAAK,QAAQ;IACnB;GACF,CAAC;EACH,CAAC;CACH,CAAC;CAED,OAAO;AACT"}
|
package/lib/exports.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAGlD,eAAO,MAAM,cAAc,GAAI,YAAY,UAAU;;;;;;GAsEpD,CAAC"}
|
package/lib/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","names":[],"sources":["../src/exports.ts"],"sourcesContent":["import { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ExportInfo } from './schemas';\n\nexport const analyzeExports = (sourceFile: SourceFile) => {\n const exports: ExportInfo[] = [];\n\n // Export declarations (export ...)\n sourceFile.getExportDeclarations().forEach(exportDecl => {\n const moduleSpecifier = exportDecl.getModuleSpecifierValue();\n const exportText = exportDecl.getText();\n\n // Named exports\n const namedExports = exportDecl.getNamedExports();\n namedExports.forEach(namedExport => {\n exports.push({\n name: namedExport.getName(),\n kind: 'named',\n text: exportText,\n moduleSpecifier,\n });\n });\n\n // Namespace export (export * from '...')\n if (exportDecl.isNamespaceExport()) {\n exports.push({\n name: '*',\n kind: 'namespace',\n text: exportText,\n moduleSpecifier,\n });\n }\n });\n\n // Export assignments (export = ...)\n sourceFile.getExportAssignments().forEach(exportAssignment => {\n if (exportAssignment.isExportEquals()) {\n exports.push({\n name: 'default',\n kind: 'default',\n text: exportAssignment.getText(),\n });\n }\n });\n\n // Exported declarations (export function, export class, etc.)\n sourceFile.getExportedDeclarations().forEach((declarations, name) => {\n declarations.forEach(decl => {\n let declarationKind: ExportInfo['declarationKind'];\n\n if (decl.getKind() === SyntaxKind.FunctionDeclaration) {\n declarationKind = 'function';\n } else if (decl.getKind() === SyntaxKind.ClassDeclaration) {\n declarationKind = 'class';\n } else if (decl.getKind() === SyntaxKind.InterfaceDeclaration) {\n declarationKind = 'interface';\n } else if (decl.getKind() === SyntaxKind.TypeAliasDeclaration) {\n declarationKind = 'type';\n } else if (decl.getKind() === SyntaxKind.VariableDeclaration) {\n declarationKind = 'variable';\n } else if (decl.getKind() === SyntaxKind.EnumDeclaration) {\n declarationKind = 'enum';\n }\n\n exports.push({\n name,\n kind: name === 'default' ? 'default' : 'named',\n text: decl.getText(),\n declarationKind,\n });\n });\n });\n\n return exports;\n};\n"],"mappings":";;AAGA,MAAa,kBAAkB,eAA2B;CACxD,MAAM,UAAwB,
|
|
1
|
+
{"version":3,"file":"exports.js","names":[],"sources":["../src/exports.ts"],"sourcesContent":["import { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ExportInfo } from './schemas';\n\nexport const analyzeExports = (sourceFile: SourceFile) => {\n const exports: ExportInfo[] = [];\n\n // Export declarations (export ...)\n sourceFile.getExportDeclarations().forEach(exportDecl => {\n const moduleSpecifier = exportDecl.getModuleSpecifierValue();\n const exportText = exportDecl.getText();\n\n // Named exports\n const namedExports = exportDecl.getNamedExports();\n namedExports.forEach(namedExport => {\n exports.push({\n name: namedExport.getName(),\n kind: 'named',\n text: exportText,\n moduleSpecifier,\n });\n });\n\n // Namespace export (export * from '...')\n if (exportDecl.isNamespaceExport()) {\n exports.push({\n name: '*',\n kind: 'namespace',\n text: exportText,\n moduleSpecifier,\n });\n }\n });\n\n // Export assignments (export = ...)\n sourceFile.getExportAssignments().forEach(exportAssignment => {\n if (exportAssignment.isExportEquals()) {\n exports.push({\n name: 'default',\n kind: 'default',\n text: exportAssignment.getText(),\n });\n }\n });\n\n // Exported declarations (export function, export class, etc.)\n sourceFile.getExportedDeclarations().forEach((declarations, name) => {\n declarations.forEach(decl => {\n let declarationKind: ExportInfo['declarationKind'];\n\n if (decl.getKind() === SyntaxKind.FunctionDeclaration) {\n declarationKind = 'function';\n } else if (decl.getKind() === SyntaxKind.ClassDeclaration) {\n declarationKind = 'class';\n } else if (decl.getKind() === SyntaxKind.InterfaceDeclaration) {\n declarationKind = 'interface';\n } else if (decl.getKind() === SyntaxKind.TypeAliasDeclaration) {\n declarationKind = 'type';\n } else if (decl.getKind() === SyntaxKind.VariableDeclaration) {\n declarationKind = 'variable';\n } else if (decl.getKind() === SyntaxKind.EnumDeclaration) {\n declarationKind = 'enum';\n }\n\n exports.push({\n name,\n kind: name === 'default' ? 'default' : 'named',\n text: decl.getText(),\n declarationKind,\n });\n });\n });\n\n return exports;\n};\n"],"mappings":";;AAGA,MAAa,kBAAkB,eAA2B;CACxD,MAAM,UAAwB,CAAC;CAG/B,WAAW,sBAAsB,CAAC,CAAC,SAAQ,eAAc;EACvD,MAAM,kBAAkB,WAAW,wBAAwB;EAC3D,MAAM,aAAa,WAAW,QAAQ;EAItC,WADgC,gBACrB,CAAC,CAAC,SAAQ,gBAAe;GAClC,QAAQ,KAAK;IACX,MAAM,YAAY,QAAQ;IAC1B,MAAM;IACN,MAAM;IACN;GACF,CAAC;EACH,CAAC;EAGD,IAAI,WAAW,kBAAkB,GAC/B,QAAQ,KAAK;GACX,MAAM;GACN,MAAM;GACN,MAAM;GACN;EACF,CAAC;CAEL,CAAC;CAGD,WAAW,qBAAqB,CAAC,CAAC,SAAQ,qBAAoB;EAC5D,IAAI,iBAAiB,eAAe,GAClC,QAAQ,KAAK;GACX,MAAM;GACN,MAAM;GACN,MAAM,iBAAiB,QAAQ;EACjC,CAAC;CAEL,CAAC;CAGD,WAAW,wBAAwB,CAAC,CAAC,SAAS,cAAc,SAAS;EACnE,aAAa,SAAQ,SAAQ;GAC3B,IAAI;GAEJ,IAAI,KAAK,QAAQ,MAAM,WAAW,qBAChC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAM,WAAW,kBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAM,WAAW,sBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAM,WAAW,sBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAM,WAAW,qBACvC,kBAAkB;QACb,IAAI,KAAK,QAAQ,MAAM,WAAW,iBACvC,kBAAkB;GAGpB,QAAQ,KAAK;IACX;IACA,MAAM,SAAS,YAAY,YAAY;IACvC,MAAM,KAAK,QAAQ;IACnB;GACF,CAAC;EACH,CAAC;CACH,CAAC;CAED,OAAO;AACT"}
|
package/lib/functions/add.cjs
CHANGED
|
@@ -2,9 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_constants = require("../constants.cjs");
|
|
4
4
|
const require_helpers = require("../helpers.cjs");
|
|
5
|
+
const require_config = require("../config.cjs");
|
|
5
6
|
let path = require("path");
|
|
6
7
|
let edit_json_file = require("edit-json-file");
|
|
7
|
-
edit_json_file = require_runtime.__toESM(edit_json_file);
|
|
8
|
+
edit_json_file = require_runtime.__toESM(edit_json_file, 1);
|
|
8
9
|
//#region src/functions/add.ts
|
|
9
10
|
const processFileAnalysis = (analysis, cwd, additionals, pathsEntries, files, CODEBASE_ANALYSIS) => {
|
|
10
11
|
const relativePath = analysis.relativePath;
|
|
@@ -38,7 +39,7 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
38
39
|
if (paths.length === 0) return console.warn("No files specified for addition.");
|
|
39
40
|
try {
|
|
40
41
|
const cwd = process.cwd();
|
|
41
|
-
let file = (0, edit_json_file.default)((0, path.join)(cwd,
|
|
42
|
+
let file = (0, edit_json_file.default)((0, path.join)(cwd, require_config.config.json));
|
|
42
43
|
if (!file) return;
|
|
43
44
|
const files = file.get(require_constants.FILES_PROPERTY);
|
|
44
45
|
const root = require_helpers.getFolderPath(file.get(require_constants.PATH_PROPERTY));
|
|
@@ -49,7 +50,7 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
49
50
|
});
|
|
50
51
|
const entries = new Set(pathsEntries.concat(additionals).filter(([, val]) => !!val));
|
|
51
52
|
require_helpers.consoleStars();
|
|
52
|
-
console.log(`🔧
|
|
53
|
+
console.log(`🔧 Creation of files (${entries.size} files)...`);
|
|
53
54
|
let success = 0;
|
|
54
55
|
const length = entries.size;
|
|
55
56
|
entries.forEach(([, fileAnalysis]) => {
|
|
@@ -61,10 +62,10 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
61
62
|
}
|
|
62
63
|
});
|
|
63
64
|
file.save();
|
|
64
|
-
console.log(`✅
|
|
65
|
+
console.log(`✅ Files created! (${success}/${length})`);
|
|
65
66
|
file = void 0;
|
|
66
67
|
} catch {
|
|
67
|
-
console.error(`❌
|
|
68
|
+
console.error(`❌ Error during file creation`);
|
|
68
69
|
return false;
|
|
69
70
|
}
|
|
70
71
|
require_helpers.consoleStars();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.cjs","names":["transformModule","
|
|
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 'node: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 file?.set(FILES_PROPERTY, files);\n success++;\n }\n });\n\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,kBAAkB,UAAU,kBAAkB,GAAG,MAAM;EACzD,IAAI,CAAC,OAAO;EAEZ,YAAY,KAAK,CAAC,OAAO,KAAK,CAAC;EAC/B,IAAI,KAAK,KAAK;EAEd,MAAM,UAAU,MAAM,QAAQ,QAAQ,EAAE,sBAAsB;GAC5D,MAAM,QAAQA,gBAAAA,gBAAgB;IAC5B;IACA,cAAc,MAAM;IACpB;GACF,CAAC;GAED,MAAM,QAAQ,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,QAAO,MAC7C,KAAK,SAAS,CAAC,CACjB;GAEA,IAAI,MAAM,SAAS,GAAG,OAAO;GAE7B,OAAO,MAAM,OAAM,MAAK,CAAC,IAAI,SAAS,CAAC,CAAC;EAC1C,CAAC;EAED,MAAM,SAAS;GAAE,GAAG;GAAO;EAAQ;EAGnC,IAFmB,OAAO,QAAQ,SAAS,GAGzC,oBACE,QACA,KACA,aACA,cACA,OACA,iBACF;CAEJ,CAAC;AACH;AAEA,MAAa,OACX,mBACA,GAAG,UACA;CAEH,IADgB,MAAM,WAAW,GACpB,OAAO,QAAQ,KAAK,kCAAkC;CACnE,IAAI;EACF,MAAM,MAAM,QAAQ,IAAI;EAExB,IAAI,QAAA,GAAA,eAAA,QAAA,EAAA,GAAA,KAAA,KAAA,CADc,KAAKC,eAAAA,OAAO,IACa,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,QAAQ,KAAK,IAAIC,kBAAAA,cAAc;EACrC,MAAM,OAAOC,gBAAAA,cAAc,KAAK,IAAIC,kBAAAA,aAAa,CAAW;EAI5D,MAAM,cAA0D,CAAC;EAEjE,MAAM,eAAe,OAAO,QAAQ,iBAAiB,CAAC,CACnD,QAAQ,CAAC,SAAS,MAAM,MAAK,MAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CACrD,QAAQ,CAAC,SAAS,CAAC,MAAM,SAAS,GAAG,CAAC;EAEzC,aAAa,SAAS,GAAG,cAAc;GACrC,oBACE,UACA,KACA,aACA,cACA,OACA,iBACF;EACF,CAAC;EAED,MAAM,UAAU,IAAI,IAClB,aAAa,OAAO,WAAW,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,GAAG,CAC5D;EAEA,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,MAAM,IAAIH,kBAAAA,gBAAgB,KAAK;IAC/B;GACF;EACF,CAAC;EAED,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.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/functions/add.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,YAAY,CAAC;AAmEjE,eAAO,MAAM,GAAG,GACd,mBAAmB,gBAAgB,EACnC,GAAG,OAAO,MAAM,EAAE,mBA8DnB,CAAC"}
|
package/lib/functions/add.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FILES_PROPERTY,
|
|
1
|
+
import { FILES_PROPERTY, PATH_PROPERTY } from "../constants.js";
|
|
2
2
|
import { consoleStars, getFolderPath, transformModule, writeFileAnalysis } from "../helpers.js";
|
|
3
|
+
import { config } from "../config.js";
|
|
3
4
|
import { dirname, join, relative, resolve } from "path";
|
|
4
5
|
import edit from "edit-json-file";
|
|
5
6
|
//#region src/functions/add.ts
|
|
@@ -35,7 +36,7 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
35
36
|
if (paths.length === 0) return console.warn("No files specified for addition.");
|
|
36
37
|
try {
|
|
37
38
|
const cwd = process.cwd();
|
|
38
|
-
let file = edit(join(cwd,
|
|
39
|
+
let file = edit(join(cwd, config.json));
|
|
39
40
|
if (!file) return;
|
|
40
41
|
const files = file.get(FILES_PROPERTY);
|
|
41
42
|
const root = getFolderPath(file.get(PATH_PROPERTY));
|
|
@@ -46,7 +47,7 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
46
47
|
});
|
|
47
48
|
const entries = new Set(pathsEntries.concat(additionals).filter(([, val]) => !!val));
|
|
48
49
|
consoleStars();
|
|
49
|
-
console.log(`🔧
|
|
50
|
+
console.log(`🔧 Creation of files (${entries.size} files)...`);
|
|
50
51
|
let success = 0;
|
|
51
52
|
const length = entries.size;
|
|
52
53
|
entries.forEach(([, fileAnalysis]) => {
|
|
@@ -58,10 +59,10 @@ const add = (CODEBASE_ANALYSIS, ...paths) => {
|
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
61
|
file.save();
|
|
61
|
-
console.log(`✅
|
|
62
|
+
console.log(`✅ Files created! (${success}/${length})`);
|
|
62
63
|
file = void 0;
|
|
63
64
|
} catch {
|
|
64
|
-
console.error(`❌
|
|
65
|
+
console.error(`❌ Error during file creation`);
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
67
68
|
consoleStars();
|
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
|
|
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 'node: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 file?.set(FILES_PROPERTY, files);\n success++;\n }\n });\n\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,CAAC,OAAO,KAAK,CAAC;EAC/B,IAAI,KAAK,KAAK;EAEd,MAAM,UAAU,MAAM,QAAQ,QAAQ,EAAE,sBAAsB;GAC5D,MAAM,QAAQ,gBAAgB;IAC5B;IACA,cAAc,MAAM;IACpB;GACF,CAAC;GAED,MAAM,QAAQ,CAAC,OAAO,GAAG,MAAM,OAAO,CAAC,CAAC,QAAO,MAC7C,KAAK,SAAS,CAAC,CACjB;GAEA,IAAI,MAAM,SAAS,GAAG,OAAO;GAE7B,OAAO,MAAM,OAAM,MAAK,CAAC,IAAI,SAAS,CAAC,CAAC;EAC1C,CAAC;EAED,MAAM,SAAS;GAAE,GAAG;GAAO;EAAQ;EAGnC,IAFmB,OAAO,QAAQ,SAAS,GAGzC,oBACE,QACA,KACA,aACA,cACA,OACA,iBACF;CAEJ,CAAC;AACH;AAEA,MAAa,OACX,mBACA,GAAG,UACA;CAEH,IADgB,MAAM,WAAW,GACpB,OAAO,QAAQ,KAAK,kCAAkC;CACnE,IAAI;EACF,MAAM,MAAM,QAAQ,IAAI;EAExB,IAAI,OAA+B,KADtB,KAAK,KAAK,OAAO,IACa,CAAC;EAE5C,IAAI,CAAC,MAAM;EAEX,MAAM,QAAQ,KAAK,IAAI,cAAc;EACrC,MAAM,OAAO,cAAc,KAAK,IAAI,aAAa,CAAW;EAI5D,MAAM,cAA0D,CAAC;EAEjE,MAAM,eAAe,OAAO,QAAQ,iBAAiB,CAAC,CACnD,QAAQ,CAAC,SAAS,MAAM,MAAK,MAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CACrD,QAAQ,CAAC,SAAS,CAAC,MAAM,SAAS,GAAG,CAAC;EAEzC,aAAa,SAAS,GAAG,cAAc;GACrC,oBACE,UACA,KACA,aACA,cACA,OACA,iBACF;EACF,CAAC;EAED,MAAM,UAAU,IAAI,IAClB,aAAa,OAAO,WAAW,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,GAAG,CAC5D;EAEA,aAAa;EACb,QAAQ,IAAI,yBAAyB,QAAQ,KAAK,WAAW;EAE7D,IAAI,UAAU;EACd,MAAM,SAAS,QAAQ;EAEvB,QAAQ,SAAS,GAAG,kBAAkB;GACpC,MAAM,QAAQ,kBAAkB,cAAc,IAAI;GAClD,IAAI,OAAO;IACT,MAAM,KAAK,KAAK;IAChB,MAAM,IAAI,gBAAgB,KAAK;IAC/B;GACF;EACF,CAAC;EAED,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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_constants = require("../constants.cjs");
|
|
4
3
|
const require_analyse = require("../analyse.cjs");
|
|
5
4
|
let path = require("path");
|
|
@@ -31,7 +30,7 @@ const transformJSON = (data) => {
|
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Main execution function
|
|
35
34
|
*/
|
|
36
35
|
const generate = ({ output = require_constants.CODEBASE_FILE, excludes, src = require_constants.SRC_DIR } = {}) => {
|
|
37
36
|
const _output = output.endsWith("codebase.json") ? output : `${output}.codebase.json`;
|
|
@@ -41,13 +40,13 @@ const generate = ({ output = require_constants.CODEBASE_FILE, excludes, src = re
|
|
|
41
40
|
excludes
|
|
42
41
|
}));
|
|
43
42
|
(0, fs.writeFileSync)(_output, JSON.stringify(transformed, null, 2));
|
|
44
|
-
console.log(`📁
|
|
45
|
-
console.log(`📊
|
|
46
|
-
console.log(` -
|
|
43
|
+
console.log(`📁 Analysis saved in: ${(0, path.relative)(process.cwd(), _output)}`);
|
|
44
|
+
console.log(`📊 Statistics:`);
|
|
45
|
+
console.log(` - Files analyzed: ${transformed.STATS.files}`);
|
|
47
46
|
console.log(` - Total imports: ${transformed.STATS.imports}`);
|
|
48
47
|
console.log(` - Total exports: ${transformed.STATS.exports}`);
|
|
49
48
|
} catch (error) {
|
|
50
|
-
console.error("❌
|
|
49
|
+
console.error("❌ Error during codebase analysis:", error);
|
|
51
50
|
process.exit(1);
|
|
52
51
|
}
|
|
53
52
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.cjs","names":["CODEBASE_FILE","SRC_DIR","analyze"],"sources":["../../src/functions/generate.ts"],"sourcesContent":["import { writeFileSync } from
|
|
1
|
+
{"version":3,"file":"generate.cjs","names":["CODEBASE_FILE","SRC_DIR","analyze"],"sources":["../../src/functions/generate.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { CODEBASE_FILE, SRC_DIR } from '../constants';\nimport { analyze } from '../analyse';\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 = 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,eACT,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 { CodebaseAnalysis } from
|
|
1
|
+
import { CodebaseAnalysis } from '../schemas';
|
|
2
2
|
export declare const transformJSON: (data: CodebaseAnalysis) => {
|
|
3
3
|
STATS: {
|
|
4
4
|
files: number;
|
|
@@ -15,6 +15,7 @@ export type GenerateOptions = {
|
|
|
15
15
|
src?: string;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Main execution function
|
|
19
19
|
*/
|
|
20
20
|
export declare const generate: ({ output, excludes, src, }?: GenerateOptions) => boolean;
|
|
21
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/functions/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,aAAa,GAAI,MAAM,gBAAgB;;;;;;;;;CAuCnD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,6BAItB,eAAoB,YAyBtB,CAAC"}
|
|
@@ -29,7 +29,7 @@ const transformJSON = (data) => {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Main execution function
|
|
33
33
|
*/
|
|
34
34
|
const generate = ({ output = CODEBASE_FILE, excludes, src = SRC_DIR } = {}) => {
|
|
35
35
|
const _output = output.endsWith("codebase.json") ? output : `${output}.codebase.json`;
|
|
@@ -39,13 +39,13 @@ const generate = ({ output = CODEBASE_FILE, excludes, src = SRC_DIR } = {}) => {
|
|
|
39
39
|
excludes
|
|
40
40
|
}));
|
|
41
41
|
writeFileSync(_output, JSON.stringify(transformed, null, 2));
|
|
42
|
-
console.log(`📁
|
|
43
|
-
console.log(`📊
|
|
44
|
-
console.log(` -
|
|
42
|
+
console.log(`📁 Analysis saved in: ${relative(process.cwd(), _output)}`);
|
|
43
|
+
console.log(`📊 Statistics:`);
|
|
44
|
+
console.log(` - Files analyzed: ${transformed.STATS.files}`);
|
|
45
45
|
console.log(` - Total imports: ${transformed.STATS.imports}`);
|
|
46
46
|
console.log(` - Total exports: ${transformed.STATS.exports}`);
|
|
47
47
|
} catch (error) {
|
|
48
|
-
console.error("❌
|
|
48
|
+
console.error("❌ Error during codebase analysis:", error);
|
|
49
49
|
process.exit(1);
|
|
50
50
|
}
|
|
51
51
|
return true;
|
|
@@ -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 'node:fs';\nimport { relative } from 'node:path';\nimport { CODEBASE_FILE, SRC_DIR } from '../constants';\nimport { analyze } from '../analyse';\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 = 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,eACT,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"}
|
package/lib/functions/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
package/lib/functions/init.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_constants = require("../constants.cjs");
|
|
4
3
|
const require_helpers = require("../helpers.cjs");
|
|
4
|
+
const require_config = require("../config.cjs");
|
|
5
5
|
let path = require("path");
|
|
6
6
|
let fs = require("fs");
|
|
7
7
|
//#region src/functions/init.ts
|
|
@@ -10,31 +10,44 @@ const createTypesStructure = (folderPath, CODEBASE_ANALYSIS) => {
|
|
|
10
10
|
return key.endsWith("types") || key.endsWith("constants");
|
|
11
11
|
});
|
|
12
12
|
const PATHS = [];
|
|
13
|
-
console.log(`🔧
|
|
13
|
+
console.log(`🔧 Creating types structure (${entries.length} files)...`);
|
|
14
14
|
for (const [, fileAnalysis] of entries) {
|
|
15
15
|
const file = require_helpers.writeFileAnalysis(fileAnalysis, folderPath);
|
|
16
16
|
if (file) PATHS.push(file);
|
|
17
17
|
}
|
|
18
|
-
console.log(`✅
|
|
18
|
+
console.log(`✅ Types structure successfully created!`);
|
|
19
19
|
return PATHS;
|
|
20
20
|
};
|
|
21
|
-
const
|
|
21
|
+
const initConfig = ({ root, json, path: path$1 = require_constants.DEFAULT_PATH_KEY, bin = require_constants.DEFAULT_CLI_NAME }) => {
|
|
22
|
+
require_config.config.bin = bin;
|
|
23
|
+
require_config.config.json = json;
|
|
24
|
+
require_config.config.tsConfigPath = path$1;
|
|
25
|
+
require_config.config.root = root;
|
|
26
|
+
return {
|
|
27
|
+
root,
|
|
28
|
+
json,
|
|
29
|
+
path: path$1,
|
|
30
|
+
bin
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const init = (CODEBASE_ANALYSIS, options) => {
|
|
34
|
+
const { root, json, path: path$2, bin } = initConfig(options);
|
|
22
35
|
const cwd = process.cwd();
|
|
23
36
|
const configFile = (0, path.join)(cwd, json);
|
|
24
37
|
if ((0, fs.existsSync)(configFile)) return true;
|
|
25
38
|
const folderPath = require_helpers.getFolderPath(root);
|
|
26
39
|
try {
|
|
27
40
|
(0, fs.mkdirSync)(folderPath, { recursive: true });
|
|
28
|
-
console.log(`✅
|
|
41
|
+
console.log(`✅ Folder ${bin} created in: ${root}`);
|
|
29
42
|
} catch (error) {
|
|
30
|
-
console.error(`❌
|
|
43
|
+
console.error(`❌ Error creating the folder ${bin}:`, error);
|
|
31
44
|
return false;
|
|
32
45
|
}
|
|
33
46
|
let files = [];
|
|
34
47
|
try {
|
|
35
48
|
files = createTypesStructure(folderPath, CODEBASE_ANALYSIS);
|
|
36
49
|
} catch {
|
|
37
|
-
console.error(`❌
|
|
50
|
+
console.error(`❌ Error creating the types structure:`);
|
|
38
51
|
return false;
|
|
39
52
|
}
|
|
40
53
|
const tsconfigPath = (0, path.join)(cwd, "tsconfig.json");
|
|
@@ -44,27 +57,27 @@ const init = (CODEBASE_ANALYSIS, { root, json }) => {
|
|
|
44
57
|
if (!tsconfig.compilerOptions) tsconfig.compilerOptions = {};
|
|
45
58
|
if (!tsconfig.compilerOptions.paths) tsconfig.compilerOptions.paths = {};
|
|
46
59
|
const relativePath = (0, path.relative)(process.cwd(), folderPath);
|
|
47
|
-
tsconfig.compilerOptions.paths[
|
|
60
|
+
tsconfig.compilerOptions.paths[path$2] = [`./${relativePath}/*`];
|
|
48
61
|
(0, fs.writeFileSync)(tsconfigPath, JSON.stringify(tsconfig, null, 2), "utf8");
|
|
49
|
-
console.log(`✅ Path
|
|
62
|
+
console.log(`✅ Path ${path$2} added to tsconfig.json`);
|
|
50
63
|
} catch (error) {
|
|
51
|
-
console.error(`❌
|
|
64
|
+
console.error(`❌ Error updating tsconfig.json:`, error);
|
|
52
65
|
return false;
|
|
53
66
|
}
|
|
54
|
-
else console.warn(`⚠️
|
|
55
|
-
const
|
|
67
|
+
else console.warn(`⚠️ File tsconfig.json not found, path not added`);
|
|
68
|
+
const jsonConfig = {
|
|
56
69
|
version: "1.0.0",
|
|
57
70
|
[require_constants.PROPERTIES.PATH]: root,
|
|
58
71
|
[require_constants.PROPERTIES.FILES]: files
|
|
59
72
|
};
|
|
60
73
|
try {
|
|
61
|
-
(0, fs.writeFileSync)(configFile, JSON.stringify(
|
|
62
|
-
console.log(`✅
|
|
74
|
+
(0, fs.writeFileSync)(configFile, JSON.stringify(jsonConfig, null, 2), "utf8");
|
|
75
|
+
console.log(`✅ File ${json} created at the root of the project`);
|
|
63
76
|
} catch (error) {
|
|
64
|
-
console.error(`❌
|
|
77
|
+
console.error(`❌ Error creating the file ${json}:`, error);
|
|
65
78
|
return false;
|
|
66
79
|
}
|
|
67
|
-
console.log(`🎉
|
|
80
|
+
console.log(`🎉 Bemedev initialization completed successfully!`);
|
|
68
81
|
return true;
|
|
69
82
|
};
|
|
70
83
|
//#endregion
|