@bemedev/codebase 0.1.2 → 0.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 +8 -8
- package/lib/_virtual/_rolldown/runtime.cjs +23 -0
- package/lib/analyse.cjs +48 -62
- package/lib/analyse.cjs.map +1 -1
- package/lib/analyse.d.ts +21 -3
- package/lib/analyse.js +45 -60
- package/lib/analyse.js.map +1 -1
- package/lib/analyse.utils.cjs +154 -205
- package/lib/analyse.utils.cjs.map +1 -1
- package/lib/analyse.utils.d.ts +1 -2
- package/lib/analyse.utils.js +153 -203
- package/lib/analyse.utils.js.map +1 -1
- package/lib/cli/cli.cjs +28 -27
- package/lib/cli/cli.cjs.map +1 -1
- package/lib/cli/cli.d.ts +0 -1
- package/lib/cli/cli.js +25 -24
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/constants.cjs +6 -5
- package/lib/cli/constants.cjs.map +1 -1
- package/lib/cli/constants.d.ts +0 -1
- package/lib/cli/constants.js +5 -3
- package/lib/cli/constants.js.map +1 -1
- package/lib/cli/index.cjs +6 -6
- package/lib/cli/index.cjs.map +1 -1
- package/lib/cli/index.d.ts +0 -1
- package/lib/cli/index.js +7 -4
- package/lib/cli/index.js.map +1 -1
- package/lib/constants.cjs +26 -28
- package/lib/constants.cjs.map +1 -1
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +24 -26
- package/lib/constants.js.map +1 -1
- package/lib/exports.cjs +51 -72
- package/lib/exports.cjs.map +1 -1
- package/lib/exports.d.ts +1 -2
- package/lib/exports.js +49 -70
- package/lib/exports.js.map +1 -1
- package/lib/functions/add.cjs +71 -84
- package/lib/functions/add.cjs.map +1 -1
- package/lib/functions/add.d.ts +1 -2
- package/lib/functions/add.js +68 -82
- package/lib/functions/add.js.map +1 -1
- package/lib/functions/generate.cjs +53 -56
- package/lib/functions/generate.cjs.map +1 -1
- package/lib/functions/generate.d.ts +1 -2
- package/lib/functions/generate.js +51 -54
- package/lib/functions/generate.js.map +1 -1
- package/lib/functions/index.cjs +11 -16
- package/lib/functions/index.d.ts +0 -1
- package/lib/functions/index.js +5 -5
- package/lib/functions/init.cjs +68 -97
- package/lib/functions/init.cjs.map +1 -1
- package/lib/functions/init.d.ts +1 -2
- package/lib/functions/init.js +66 -95
- package/lib/functions/init.js.map +1 -1
- package/lib/functions/remove.cjs +85 -103
- package/lib/functions/remove.cjs.map +1 -1
- package/lib/functions/remove.d.ts +1 -2
- package/lib/functions/remove.js +82 -101
- package/lib/functions/remove.js.map +1 -1
- package/lib/helpers.cjs +32 -38
- package/lib/helpers.cjs.map +1 -1
- package/lib/helpers.d.ts +3 -4
- package/lib/helpers.js +30 -36
- package/lib/helpers.js.map +1 -1
- package/lib/imports.cjs +88 -118
- package/lib/imports.cjs.map +1 -1
- package/lib/imports.d.ts +2 -3
- package/lib/imports.js +86 -116
- package/lib/imports.js.map +1 -1
- package/lib/index.cjs +22 -24
- package/lib/index.d.ts +4 -4
- package/lib/index.js +8 -6
- package/lib/schemas.cjs +53 -63
- package/lib/schemas.cjs.map +1 -1
- package/lib/schemas.d.ts +5 -2
- package/lib/schemas.js +43 -35
- package/lib/schemas.js.map +1 -1
- package/lib/types.d.ts +0 -1
- package/lib/utils.cjs +9 -10
- package/lib/utils.cjs.map +1 -1
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +8 -8
- package/lib/utils.js.map +1 -1
- package/package.json +56 -44
- package/CHANGE_LOG.md +0 -143
- package/lib/analyse.d.ts.map +0 -1
- package/lib/analyse.utils.d.ts.map +0 -1
- package/lib/cli/cli.d.ts.map +0 -1
- package/lib/cli/constants.d.ts.map +0 -1
- package/lib/cli/index.d.ts.map +0 -1
- package/lib/constants.d.ts.map +0 -1
- package/lib/exports.d.ts.map +0 -1
- package/lib/functions/add.d.ts.map +0 -1
- package/lib/functions/generate.d.ts.map +0 -1
- package/lib/functions/index.cjs.map +0 -1
- package/lib/functions/index.d.ts.map +0 -1
- package/lib/functions/index.js.map +0 -1
- package/lib/functions/init.d.ts.map +0 -1
- package/lib/functions/remove.d.ts.map +0 -1
- package/lib/helpers.d.ts.map +0 -1
- package/lib/imports.d.ts.map +0 -1
- package/lib/index.cjs.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/schemas.d.ts.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/utils.d.ts.map +0 -1
package/lib/imports.js
CHANGED
|
@@ -1,125 +1,95 @@
|
|
|
1
|
-
import { join, relative } from
|
|
2
|
-
import { SyntaxKind } from
|
|
3
|
-
|
|
1
|
+
import { join, relative } from "path";
|
|
2
|
+
import { SyntaxKind } from "ts-morph";
|
|
3
|
+
//#region src/imports.ts
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* Résout le moduleSpecifier en utilisant les paths du tsconfig si il commence par "#"
|
|
6
|
+
*/
|
|
7
7
|
const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
relativedPath = relativedPath.replace('*', match[1]);
|
|
26
|
-
}
|
|
27
|
-
// Calculer le chemin relatif depuis le fichier source actuel
|
|
28
|
-
const sourceFileDir = relative(process.cwd(), sourceFile.getDirectoryPath());
|
|
29
|
-
const relativePath = relative(sourceFileDir, relativedPath);
|
|
30
|
-
// S'assurer que le chemin relatif commence par ./ ou ../
|
|
31
|
-
return relativePath.startsWith('.')
|
|
32
|
-
? relativePath
|
|
33
|
-
: `./${relativePath}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return moduleSpecifier;
|
|
8
|
+
const paths = sourceFile.getProject().getCompilerOptions().paths;
|
|
9
|
+
if (!paths) return moduleSpecifier;
|
|
10
|
+
const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;
|
|
11
|
+
const paths2 = Object.entries(paths);
|
|
12
|
+
for (const [pattern, mappings] of paths2) {
|
|
13
|
+
const regexPattern = pattern.replace(/\*/g, "(.*)");
|
|
14
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
15
|
+
const match = moduleSpecifier.match(regex);
|
|
16
|
+
if (match) {
|
|
17
|
+
const first = mappings[0];
|
|
18
|
+
let relativedPath = baseUrl ? join(baseUrl, first) : first;
|
|
19
|
+
if (match[1]) relativedPath = relativedPath.replace("*", match[1]);
|
|
20
|
+
const relativePath = relative(relative(process.cwd(), sourceFile.getDirectoryPath()), relativedPath);
|
|
21
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return moduleSpecifier;
|
|
37
25
|
};
|
|
38
26
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
* Analyse les imports d'un fichier
|
|
28
|
+
*/
|
|
41
29
|
const analyzeImports = (sourceFile) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const arg = callExpr.getArguments()[0];
|
|
88
|
-
if (arg && arg.getKind() === SyntaxKind.StringLiteral) {
|
|
89
|
-
const rawModuleSpecifier = arg.getText().replace(/['"]/g, '');
|
|
90
|
-
const moduleSpecifier = resolveModuleSpecifier(sourceFile, rawModuleSpecifier);
|
|
91
|
-
imports.push({
|
|
92
|
-
moduleSpecifier,
|
|
93
|
-
kind: 'side-effect',
|
|
94
|
-
isDynamic: true,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return imports;
|
|
30
|
+
const imports = [];
|
|
31
|
+
sourceFile.getImportDeclarations().forEach((importDecl) => {
|
|
32
|
+
const isTypeOnly = importDecl.isTypeOnly();
|
|
33
|
+
const moduleSpecifier = resolveModuleSpecifier(sourceFile, importDecl.getModuleSpecifierValue());
|
|
34
|
+
const defaultImport = importDecl.getDefaultImport();
|
|
35
|
+
if (defaultImport) imports.push({
|
|
36
|
+
moduleSpecifier,
|
|
37
|
+
kind: "default",
|
|
38
|
+
default: defaultImport.getText(),
|
|
39
|
+
isTypeOnly
|
|
40
|
+
});
|
|
41
|
+
const namespaceImport = importDecl.getNamespaceImport();
|
|
42
|
+
if (namespaceImport) imports.push({
|
|
43
|
+
moduleSpecifier,
|
|
44
|
+
kind: "namespace",
|
|
45
|
+
default: namespaceImport.getText(),
|
|
46
|
+
isTypeOnly
|
|
47
|
+
});
|
|
48
|
+
const namedImports = importDecl.getNamedImports();
|
|
49
|
+
if (namedImports.length > 0) imports.push({
|
|
50
|
+
moduleSpecifier,
|
|
51
|
+
kind: "named",
|
|
52
|
+
namedImports: namedImports.map((ni) => ni.getName()),
|
|
53
|
+
isTypeOnly
|
|
54
|
+
});
|
|
55
|
+
if (!defaultImport && !namespaceImport && namedImports.length === 0) imports.push({
|
|
56
|
+
moduleSpecifier,
|
|
57
|
+
kind: "side-effect",
|
|
58
|
+
isTypeOnly
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).forEach((callExpr) => {
|
|
62
|
+
if (callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword) {
|
|
63
|
+
const arg = callExpr.getArguments()[0];
|
|
64
|
+
if (arg && arg.getKind() === SyntaxKind.StringLiteral) {
|
|
65
|
+
const moduleSpecifier = resolveModuleSpecifier(sourceFile, arg.getText().replace(/['"]/g, ""));
|
|
66
|
+
imports.push({
|
|
67
|
+
moduleSpecifier,
|
|
68
|
+
kind: "side-effect",
|
|
69
|
+
isDynamic: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return imports;
|
|
100
75
|
};
|
|
101
76
|
const buildImportStrings = (imports) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
case 'default':
|
|
117
|
-
return `import ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
118
|
-
default:
|
|
119
|
-
return '';
|
|
120
|
-
}
|
|
121
|
-
});
|
|
77
|
+
return imports.map((imp) => {
|
|
78
|
+
switch (imp.kind) {
|
|
79
|
+
case "named": {
|
|
80
|
+
const namedImports = imp.namedImports?.join(", ") || "";
|
|
81
|
+
return `import ${imp.isTypeOnly ? "type " : ""}{ ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
82
|
+
}
|
|
83
|
+
case "namespace": return `import ${imp.isTypeOnly ? "type " : ""}* as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
84
|
+
case "side-effect":
|
|
85
|
+
if (imp.isDynamic) return `// Dynamic import: import('${imp.moduleSpecifier}')`;
|
|
86
|
+
return `import '${imp.moduleSpecifier}';`;
|
|
87
|
+
case "default": return `import ${imp.isTypeOnly ? "type " : ""}${imp.default} from '${imp.moduleSpecifier}';`;
|
|
88
|
+
default: return "";
|
|
89
|
+
}
|
|
90
|
+
});
|
|
122
91
|
};
|
|
123
|
-
|
|
92
|
+
//#endregion
|
|
124
93
|
export { analyzeImports, buildImportStrings };
|
|
125
|
-
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=imports.js.map
|
package/lib/imports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.js","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 \"node:path\";\nimport { SourceFile, SyntaxKind } from \"ts-morph\";\nimport type { ImportInfo } from \"./schemas\";\n\n/**\n * Résout le moduleSpecifier en utilisant les paths du tsconfig si il commence par \"#\"\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 // Chercher la correspondance dans les paths\n for (const [pattern, mappings] of paths2) {\n // Remplacer * par une regex pour matcher\n const regexPattern = pattern.replace(/\\*/g, \"(.*)\");\n const regex = new RegExp(`^${regexPattern}$`);\n const match = moduleSpecifier.match(regex);\n\n if (match) {\n // Prendre le premier mapping disponible\n const first = mappings[0];\n\n // Résoudre le chemin absolu\n let relativedPath = baseUrl ? join(baseUrl, first) : first;\n\n if (match[1]) {\n relativedPath = relativedPath.replace(\"*\", match[1]);\n }\n\n // Calculer le chemin relatif depuis le fichier source actuel\n const sourceFileDir = relative(\n process.cwd(),\n sourceFile.getDirectoryPath(),\n );\n const relativePath = relative(sourceFileDir, relativedPath);\n\n // S'assurer que le chemin relatif commence par ./ ou ../\n return relativePath.startsWith(\".\") ? relativePath : `./${relativePath}`;\n }\n }\n\n return moduleSpecifier;\n};\n\n/**\n * Analyse les imports d'un fichier\n */\nexport const analyzeImports = (sourceFile: SourceFile): 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 (!defaultImport && !namespaceImport && namedImports.length === 0) {\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 (callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword) {\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,YAAY,CAAC,oBAAoB,CAAC;AAE3D,KAAI,CAAC,MAAO,QAAO;CAEnB,MAAM,UAAU,WAAW,YAAY,CAAC,oBAAoB,CAAC;CAC7D,MAAM,SAAS,OAAO,QAAQ,MAAM;AAGpC,MAAK,MAAM,CAAC,SAAS,aAAa,QAAQ;EAExC,MAAM,eAAe,QAAQ,QAAQ,OAAO,OAAO;EACnD,MAAM,QAAQ,IAAI,OAAO,IAAI,aAAa,GAAG;EAC7C,MAAM,QAAQ,gBAAgB,MAAM,MAAM;AAE1C,MAAI,OAAO;GAET,MAAM,QAAQ,SAAS;GAGvB,IAAI,gBAAgB,UAAU,KAAK,SAAS,MAAM,GAAG;AAErD,OAAI,MAAM,GACR,iBAAgB,cAAc,QAAQ,KAAK,MAAM,GAAG;GAQtD,MAAM,eAAe,SAJC,SACpB,QAAQ,KAAK,EACb,WAAW,kBAAkB,CAC9B,EAC4C,cAAc;AAG3D,UAAO,aAAa,WAAW,IAAI,GAAG,eAAe,KAAK;;;AAI9D,QAAO;;;;;AAMT,MAAa,kBAAkB,eAAyC;CACtE,MAAM,UAAwB,EAAE;AAGhC,YAAW,uBAAuB,CAAC,SAAS,eAAe;EAEzD,MAAM,aAAa,WAAW,YAAY;EAG1C,MAAM,kBAAkB,uBACtB,YAFyB,WAAW,yBAAyB,CAI9D;EAGD,MAAM,gBAAgB,WAAW,kBAAkB;AACnD,MAAI,cACF,SAAQ,KAAK;GACX;GACA,MAAM;GACN,SAAS,cAAc,SAAS;GAChC;GACD,CAAC;EAIJ,MAAM,kBAAkB,WAAW,oBAAoB;AACvD,MAAI,gBACF,SAAQ,KAAK;GACX;GACA,MAAM;GACN,SAAS,gBAAgB,SAAS;GAClC;GACD,CAAC;EAIJ,MAAM,eAAe,WAAW,iBAAiB;AACjD,MAAI,aAAa,SAAS,EACxB,SAAQ,KAAK;GACX;GACA,MAAM;GACN,cAAc,aAAa,KAAK,OAAO,GAAG,SAAS,CAAC;GACpD;GACD,CAAC;AAIJ,MAAI,CAAC,iBAAiB,CAAC,mBAAmB,aAAa,WAAW,EAChE,SAAQ,KAAK;GACX;GACA,MAAM;GACN;GACD,CAAC;GAEJ;AAGF,YACG,qBAAqB,WAAW,eAAe,CAC/C,SAAS,aAAa;AACrB,MAAI,SAAS,eAAe,CAAC,SAAS,KAAK,WAAW,eAAe;GACnE,MAAM,MAAM,SAAS,cAAc,CAAC;AACpC,OAAI,OAAO,IAAI,SAAS,KAAK,WAAW,eAAe;IAErD,MAAM,kBAAkB,uBACtB,YAFyB,IAAI,SAAS,CAAC,QAAQ,SAAS,GAAG,CAI5D;AACD,YAAQ,KAAK;KACX;KACA,MAAM;KACN,WAAW;KACZ,CAAC;;;GAGN;AAEJ,QAAO;;AAGT,MAAa,sBAAsB,YAA0B;AAC3D,QAAO,QAAQ,KAAK,QAAQ;AAC1B,UAAQ,IAAI,MAAZ;GACE,KAAK,SAAS;IACZ,MAAM,eAAe,IAAI,cAAc,KAAK,KAAK,IAAI;AACrD,WAAO,UAAU,IAAI,aAAa,UAAU,GAAG,IAAI,aAAa,WAAW,IAAI,gBAAgB;;GAEjG,KAAK,YACH,QAAO,UAAU,IAAI,aAAa,UAAU,GAAG,OAAO,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GACjG,KAAK;AACH,QAAI,IAAI,UACN,QAAO,8BAA8B,IAAI,gBAAgB;AAE3D,WAAO,WAAW,IAAI,gBAAgB;GAGxC,KAAK,UACH,QAAO,UAAU,IAAI,aAAa,UAAU,KAAK,IAAI,QAAQ,SAAS,IAAI,gBAAgB;GAC5F,QACE,QAAO;;GAEX"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.ImportInfoSchema = schemas.ImportInfoSchema;
|
|
24
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_schemas = require("./schemas.cjs");
|
|
3
|
+
const require_analyse = require("./analyse.cjs");
|
|
4
|
+
const require_functions_add = require("./functions/add.cjs");
|
|
5
|
+
const require_functions_generate = require("./functions/generate.cjs");
|
|
6
|
+
const require_functions_init = require("./functions/init.cjs");
|
|
7
|
+
const require_functions_remove = require("./functions/remove.cjs");
|
|
8
|
+
require("./functions/index.cjs");
|
|
9
|
+
exports.AnalysisStatsSchema = require_schemas.AnalysisStatsSchema;
|
|
10
|
+
exports.CodeAnalysisFileSchema = require_schemas.CodeAnalysisFileSchema;
|
|
11
|
+
exports.CodebaseAnalysisSchema = require_schemas.CodebaseAnalysisSchema;
|
|
12
|
+
exports.DeclarationKindSchema = require_schemas.DeclarationKindSchema;
|
|
13
|
+
exports.ExportInfoSchema = require_schemas.ExportInfoSchema;
|
|
14
|
+
exports.FileAnalysisSchema = require_schemas.FileAnalysisSchema;
|
|
15
|
+
exports.ImportInfoSchema = require_schemas.ImportInfoSchema;
|
|
16
|
+
exports.add = require_functions_add.add;
|
|
17
|
+
exports.analyze = require_analyse.analyze;
|
|
18
|
+
exports.createTypesStructure = require_functions_init.createTypesStructure;
|
|
19
|
+
exports.generate = require_functions_generate.generate;
|
|
20
|
+
exports.init = require_functions_init.init;
|
|
21
|
+
exports.remove = require_functions_remove.remove;
|
|
22
|
+
exports.transformJSON = require_functions_generate.transformJSON;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
|
|
1
|
+
export * from "./analyse";
|
|
2
|
+
export * from "./functions";
|
|
3
|
+
export * from "./schemas";
|
|
4
|
+
export * from "./types";
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema } from "./schemas.js";
|
|
2
|
+
import { analyze } from "./analyse.js";
|
|
3
|
+
import { add } from "./functions/add.js";
|
|
4
|
+
import { generate, transformJSON } from "./functions/generate.js";
|
|
5
|
+
import { createTypesStructure, init } from "./functions/init.js";
|
|
6
|
+
import { remove } from "./functions/remove.js";
|
|
7
|
+
import "./functions/index.js";
|
|
8
|
+
export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema, add, analyze, createTypesStructure, generate, init, remove, transformJSON };
|
package/lib/schemas.cjs
CHANGED
|
@@ -1,71 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
n.default = e;
|
|
20
|
-
return Object.freeze(n);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var v__namespace = /*#__PURE__*/_interopNamespaceDefault(v);
|
|
24
|
-
|
|
25
|
-
const DeclarationKindSchema = v__namespace.picklist([
|
|
26
|
-
'function',
|
|
27
|
-
'class',
|
|
28
|
-
'interface',
|
|
29
|
-
'type',
|
|
30
|
-
'variable',
|
|
31
|
-
'const',
|
|
32
|
-
'let',
|
|
33
|
-
'enum',
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_constants = require("./constants.cjs");
|
|
4
|
+
let valibot = require("valibot");
|
|
5
|
+
valibot = require_runtime.__toESM(valibot);
|
|
6
|
+
//#region src/schemas.ts
|
|
7
|
+
const DeclarationKindSchema = valibot.picklist([
|
|
8
|
+
"function",
|
|
9
|
+
"class",
|
|
10
|
+
"interface",
|
|
11
|
+
"type",
|
|
12
|
+
"variable",
|
|
13
|
+
"const",
|
|
14
|
+
"let",
|
|
15
|
+
"enum"
|
|
34
16
|
]);
|
|
35
|
-
const ImportInfoSchema =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
const ImportInfoSchema = valibot.object({
|
|
18
|
+
moduleSpecifier: valibot.string(),
|
|
19
|
+
kind: valibot.picklist([
|
|
20
|
+
"default",
|
|
21
|
+
"named",
|
|
22
|
+
"namespace",
|
|
23
|
+
"side-effect"
|
|
24
|
+
]),
|
|
25
|
+
namedImports: valibot.optional(valibot.array(valibot.string())),
|
|
26
|
+
default: valibot.optional(valibot.string()),
|
|
27
|
+
isDynamic: valibot.optional(valibot.boolean()),
|
|
28
|
+
isTypeOnly: valibot.optional(valibot.boolean())
|
|
41
29
|
});
|
|
42
|
-
const ExportInfoSchema =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
const ExportInfoSchema = valibot.object({
|
|
31
|
+
name: valibot.string(),
|
|
32
|
+
kind: valibot.picklist([
|
|
33
|
+
"default",
|
|
34
|
+
"named",
|
|
35
|
+
"namespace"
|
|
36
|
+
]),
|
|
37
|
+
text: valibot.optional(valibot.string()),
|
|
38
|
+
moduleSpecifier: valibot.optional(valibot.string()),
|
|
39
|
+
declarationKind: valibot.optional(DeclarationKindSchema)
|
|
48
40
|
});
|
|
49
|
-
const FileAnalysisSchema =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
const FileAnalysisSchema = valibot.object({
|
|
42
|
+
relativePath: valibot.string(),
|
|
43
|
+
imports: valibot.array(ImportInfoSchema),
|
|
44
|
+
exports: valibot.optional(valibot.array(ExportInfoSchema)),
|
|
45
|
+
text: valibot.string()
|
|
54
46
|
});
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
imports: v__namespace.number(),
|
|
61
|
-
exports: v__namespace.number(),
|
|
47
|
+
const CodebaseAnalysisSchema = valibot.record(valibot.string(), FileAnalysisSchema);
|
|
48
|
+
const AnalysisStatsSchema = valibot.object({
|
|
49
|
+
files: valibot.number(),
|
|
50
|
+
imports: valibot.number(),
|
|
51
|
+
exports: valibot.number()
|
|
62
52
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
[constants.PROPERTIES.STATS]: v__namespace.optional(AnalysisStatsSchema),
|
|
53
|
+
const CodeAnalysisFileSchema = valibot.object({
|
|
54
|
+
[require_constants.PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,
|
|
55
|
+
[require_constants.PROPERTIES.STATS]: valibot.optional(AnalysisStatsSchema)
|
|
67
56
|
});
|
|
68
|
-
|
|
57
|
+
//#endregion
|
|
69
58
|
exports.AnalysisStatsSchema = AnalysisStatsSchema;
|
|
70
59
|
exports.CodeAnalysisFileSchema = CodeAnalysisFileSchema;
|
|
71
60
|
exports.CodebaseAnalysisSchema = CodebaseAnalysisSchema;
|
|
@@ -73,4 +62,5 @@ exports.DeclarationKindSchema = DeclarationKindSchema;
|
|
|
73
62
|
exports.ExportInfoSchema = ExportInfoSchema;
|
|
74
63
|
exports.FileAnalysisSchema = FileAnalysisSchema;
|
|
75
64
|
exports.ImportInfoSchema = ImportInfoSchema;
|
|
76
|
-
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=schemas.cjs.map
|
package/lib/schemas.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.cjs","sources":["../src/schemas.ts"],"sourcesContent":["import * as v from
|
|
1
|
+
{"version":3,"file":"schemas.cjs","names":["v","PROPERTIES"],"sources":["../src/schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PROPERTIES } from \"./constants\";\n\nexport const DeclarationKindSchema = v.picklist([\n \"function\",\n \"class\",\n \"interface\",\n \"type\",\n \"variable\",\n \"const\",\n \"let\",\n \"enum\",\n]);\n\nexport const ImportInfoSchema = v.object({\n moduleSpecifier: v.string(),\n kind: v.picklist([\"default\", \"named\", \"namespace\", \"side-effect\"]),\n namedImports: v.optional(v.array(v.string())),\n default: v.optional(v.string()),\n isDynamic: v.optional(v.boolean()),\n isTypeOnly: v.optional(v.boolean()),\n});\n\nexport const ExportInfoSchema = v.object({\n name: v.string(),\n kind: v.picklist([\"default\", \"named\", \"namespace\"]),\n text: v.optional(v.string()),\n moduleSpecifier: v.optional(v.string()),\n declarationKind: v.optional(DeclarationKindSchema),\n});\n\nexport const FileAnalysisSchema = v.object({\n relativePath: v.string(),\n imports: v.array(ImportInfoSchema),\n exports: v.optional(v.array(ExportInfoSchema)),\n text: v.string(),\n});\n\n// Schema pour CodebaseAnalysis\nexport const CodebaseAnalysisSchema = v.record(v.string(), FileAnalysisSchema);\n\n// Schema pour les statistiques d'analyse\nexport const AnalysisStatsSchema = v.object({\n files: v.number(),\n imports: v.number(),\n exports: v.number(),\n});\n\n// Schema complet pour un fichier .code contenant l'analyse complète\nexport const CodeAnalysisFileSchema = v.object({\n [PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,\n [PROPERTIES.STATS]: v.optional(AnalysisStatsSchema),\n});\n\n// Types inférés des schémas\nexport type DeclarationKind = v.InferOutput<typeof DeclarationKindSchema>;\nexport type ImportInfo = v.InferOutput<typeof ImportInfoSchema>;\nexport type ExportInfo = v.InferOutput<typeof ExportInfoSchema>;\nexport type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;\nexport type CodebaseAnalysis = v.InferOutput<typeof CodebaseAnalysisSchema>;\nexport type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;\nexport type CodeAnalysisFile = v.InferOutput<typeof CodeAnalysisFileSchema>;\n"],"mappings":";;;;;;AAGA,MAAa,wBAAwBA,QAAE,SAAS;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAa,mBAAmBA,QAAE,OAAO;CACvC,iBAAiBA,QAAE,QAAQ;CAC3B,MAAMA,QAAE,SAAS;EAAC;EAAW;EAAS;EAAa;EAAc,CAAC;CAClE,cAAcA,QAAE,SAASA,QAAE,MAAMA,QAAE,QAAQ,CAAC,CAAC;CAC7C,SAASA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC/B,WAAWA,QAAE,SAASA,QAAE,SAAS,CAAC;CAClC,YAAYA,QAAE,SAASA,QAAE,SAAS,CAAC;CACpC,CAAC;AAEF,MAAa,mBAAmBA,QAAE,OAAO;CACvC,MAAMA,QAAE,QAAQ;CAChB,MAAMA,QAAE,SAAS;EAAC;EAAW;EAAS;EAAY,CAAC;CACnD,MAAMA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC5B,iBAAiBA,QAAE,SAASA,QAAE,QAAQ,CAAC;CACvC,iBAAiBA,QAAE,SAAS,sBAAsB;CACnD,CAAC;AAEF,MAAa,qBAAqBA,QAAE,OAAO;CACzC,cAAcA,QAAE,QAAQ;CACxB,SAASA,QAAE,MAAM,iBAAiB;CAClC,SAASA,QAAE,SAASA,QAAE,MAAM,iBAAiB,CAAC;CAC9C,MAAMA,QAAE,QAAQ;CACjB,CAAC;AAGF,MAAa,yBAAyBA,QAAE,OAAOA,QAAE,QAAQ,EAAE,mBAAmB;AAG9E,MAAa,sBAAsBA,QAAE,OAAO;CAC1C,OAAOA,QAAE,QAAQ;CACjB,SAASA,QAAE,QAAQ;CACnB,SAASA,QAAE,QAAQ;CACpB,CAAC;AAGF,MAAa,yBAAyBA,QAAE,OAAO;EAC5CC,kBAAAA,WAAW,oBAAoB;EAC/BA,kBAAAA,WAAW,QAAQD,QAAE,SAAS,oBAAoB;CACpD,CAAC"}
|
package/lib/schemas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const DeclarationKindSchema: v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>;
|
|
3
3
|
export declare const ImportInfoSchema: v.ObjectSchema<{
|
|
4
4
|
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
@@ -6,6 +6,7 @@ export declare const ImportInfoSchema: v.ObjectSchema<{
|
|
|
6
6
|
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
7
7
|
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8
8
|
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
9
|
+
readonly isTypeOnly: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
9
10
|
}, undefined>;
|
|
10
11
|
export declare const ExportInfoSchema: v.ObjectSchema<{
|
|
11
12
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -22,6 +23,7 @@ export declare const FileAnalysisSchema: v.ObjectSchema<{
|
|
|
22
23
|
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
23
24
|
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
25
|
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
26
|
+
readonly isTypeOnly: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
25
27
|
}, undefined>, undefined>;
|
|
26
28
|
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
27
29
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -40,6 +42,7 @@ export declare const CodebaseAnalysisSchema: v.RecordSchema<v.StringSchema<undef
|
|
|
40
42
|
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
41
43
|
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
44
|
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
45
|
+
readonly isTypeOnly: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
43
46
|
}, undefined>, undefined>;
|
|
44
47
|
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
45
48
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -64,6 +67,7 @@ export declare const CodeAnalysisFileSchema: v.ObjectSchema<{
|
|
|
64
67
|
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
65
68
|
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
69
|
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
70
|
+
readonly isTypeOnly: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
67
71
|
}, undefined>, undefined>;
|
|
68
72
|
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
69
73
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -87,4 +91,3 @@ export type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;
|
|
|
87
91
|
export type CodebaseAnalysis = v.InferOutput<typeof CodebaseAnalysisSchema>;
|
|
88
92
|
export type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;
|
|
89
93
|
export type CodeAnalysisFile = v.InferOutput<typeof CodeAnalysisFileSchema>;
|
|
90
|
-
//# sourceMappingURL=schemas.d.ts.map
|