@bemedev/codebase 0.0.1
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/LICENSE +21 -0
- package/README.md +39 -0
- package/lib/analyse.cjs +68 -0
- package/lib/analyse.cjs.map +1 -0
- package/lib/analyse.d.ts +10 -0
- package/lib/analyse.d.ts.map +1 -0
- package/lib/analyse.js +66 -0
- package/lib/analyse.js.map +1 -0
- package/lib/analyse.utils.cjs +240 -0
- package/lib/analyse.utils.cjs.map +1 -0
- package/lib/analyse.utils.d.ts +30 -0
- package/lib/analyse.utils.d.ts.map +1 -0
- package/lib/analyse.utils.js +232 -0
- package/lib/analyse.utils.js.map +1 -0
- package/lib/cli/cli.cjs +27 -0
- package/lib/cli/cli.cjs.map +1 -0
- package/lib/cli/cli.d.ts +12 -0
- package/lib/cli/cli.d.ts.map +1 -0
- package/lib/cli/cli.js +25 -0
- package/lib/cli/cli.js.map +1 -0
- package/lib/cli/constants.cjs +6 -0
- package/lib/cli/constants.cjs.map +1 -0
- package/lib/cli/constants.d.ts +2 -0
- package/lib/cli/constants.d.ts.map +1 -0
- package/lib/cli/constants.js +4 -0
- package/lib/cli/constants.js.map +1 -0
- package/lib/cli/index.cjs +8 -0
- package/lib/cli/index.cjs.map +1 -0
- package/lib/cli/index.d.ts +3 -0
- package/lib/cli/index.d.ts.map +1 -0
- package/lib/cli/index.js +6 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/constants.cjs +40 -0
- package/lib/constants.cjs.map +1 -0
- package/lib/constants.d.ts +17 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +31 -0
- package/lib/constants.js.map +1 -0
- package/lib/exports.cjs +75 -0
- package/lib/exports.cjs.map +1 -0
- package/lib/exports.d.ts +4 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js +73 -0
- package/lib/exports.js.map +1 -0
- package/lib/functions/add.cjs +85 -0
- package/lib/functions/add.cjs.map +1 -0
- package/lib/functions/add.d.ts +3 -0
- package/lib/functions/add.d.ts.map +1 -0
- package/lib/functions/add.js +83 -0
- package/lib/functions/add.js.map +1 -0
- package/lib/functions/generate.cjs +61 -0
- package/lib/functions/generate.cjs.map +1 -0
- package/lib/functions/generate.d.ts +25 -0
- package/lib/functions/generate.d.ts.map +1 -0
- package/lib/functions/generate.js +58 -0
- package/lib/functions/generate.js.map +1 -0
- package/lib/functions/index.cjs +16 -0
- package/lib/functions/index.cjs.map +1 -0
- package/lib/functions/index.d.ts +5 -0
- package/lib/functions/index.d.ts.map +1 -0
- package/lib/functions/index.js +5 -0
- package/lib/functions/index.js.map +1 -0
- package/lib/functions/init.cjs +104 -0
- package/lib/functions/init.cjs.map +1 -0
- package/lib/functions/init.d.ts +12 -0
- package/lib/functions/init.d.ts.map +1 -0
- package/lib/functions/init.js +101 -0
- package/lib/functions/init.js.map +1 -0
- package/lib/functions/remove.cjs +108 -0
- package/lib/functions/remove.cjs.map +1 -0
- package/lib/functions/remove.d.ts +3 -0
- package/lib/functions/remove.d.ts.map +1 -0
- package/lib/functions/remove.js +106 -0
- package/lib/functions/remove.js.map +1 -0
- package/lib/helpers.cjs +47 -0
- package/lib/helpers.cjs.map +1 -0
- package/lib/helpers.d.ts +11 -0
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +42 -0
- package/lib/helpers.js.map +1 -0
- package/lib/imports.cjs +128 -0
- package/lib/imports.cjs.map +1 -0
- package/lib/imports.d.ts +8 -0
- package/lib/imports.d.ts.map +1 -0
- package/lib/imports.js +125 -0
- package/lib/imports.js.map +1 -0
- package/lib/index.cjs +16 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/schemas.cjs +80 -0
- package/lib/schemas.cjs.map +1 -0
- package/lib/schemas.d.ts +90 -0
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js +53 -0
- package/lib/schemas.js.map +1 -0
- package/lib/types.d.ts +43 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils.cjs +14 -0
- package/lib/utils.cjs.map +1 -0
- package/lib/utils.d.ts +6 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +12 -0
- package/lib/utils.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.cjs","sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './types';\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('.')\n ? relativePath\n : `./${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 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 });\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 });\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 });\n }\n\n // Side-effect import (import '...')\n if (!defaultImport && !namespaceImport && namedImports.length === 0) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\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 { ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import * 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.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"names":["join","relative","SyntaxKind"],"mappings":";;;;;AAIA;;AAEG;AACH,MAAM,sBAAsB,GAAG,CAC7B,UAAsB,EACtB,eAAuB,KACb;IACV,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,kBAAkB,EAAE,CAAC,KAAK;AAEhE,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,eAAe;IAElC,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,kBAAkB,EAAE,CAAC,OAAO;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;;IAGpC,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,EAAE;;QAExC,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,CAAA,CAAA,EAAI,YAAY,CAAA,CAAA,CAAG,CAAC;QAC7C,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC;QAE1C,IAAI,KAAK,EAAE;;AAET,YAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;;AAGzB,YAAA,IAAI,aAAa,GAAG,OAAO,GAAGA,SAAI,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK;AAE1D,YAAA,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;AACZ,gBAAA,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACtD;;AAGA,YAAA,MAAM,aAAa,GAAGC,aAAQ,CAC5B,OAAO,CAAC,GAAG,EAAE,EACb,UAAU,CAAC,gBAAgB,EAAE,CAC9B;YACD,MAAM,YAAY,GAAGA,aAAQ,C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d,OAAO,CAAA,YAAA,EAAe,GAAG,CAAC,OAAO,UAAU,GAAG,CAAC,eAAe,CAAA,EAAA,CAAI;YACpE,KAAK,aAAa,EAAE;AAClB,gBAAA,IAAI,GAAG,CAAC,SAAS,EAAE;AACjB,oBAAA,OAAO,CAAA,2BAAA,EAA8B,GAAG,CAAC,eAAe,IAAI;gBAC9D;AACA,gBAAA,OAAO,CAAA,QAAA,EAAW,GAAG,CAAC,eAAe,IAAI;YAC3C;AAEA,YAAA,KAAK,SAAS;gBACZ,OAAO,CAAA,OAAA,EAAU,GAAG,CAAC,OAAO,UAAU,GAAG,CAAC,eAAe,CAAA,EAAA,CAAI;AAC/D,YAAA;AACE,gBAAA,OAAO,EAAE;;AAEf,IAAA,CAAC,CAAC;AACJ;;;;;"}
|
package/lib/imports.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
import type { ImportInfo } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Analyse les imports d'un fichier
|
|
5
|
+
*/
|
|
6
|
+
export declare const analyzeImports: (sourceFile: SourceFile) => ImportInfo[];
|
|
7
|
+
export declare const buildImportStrings: (imports: ImportInfo[]) => string[];
|
|
8
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../src/imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmD1C;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,UAAU,KAAG,UAAU,EA0EjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,UAAU,EAAE,aAsBvD,CAAC"}
|
package/lib/imports.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { join, relative } from 'path';
|
|
2
|
+
import { SyntaxKind } from 'ts-morph';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Résout le moduleSpecifier en utilisant les paths du tsconfig si il commence par "#"
|
|
6
|
+
*/
|
|
7
|
+
const resolveModuleSpecifier = (sourceFile, moduleSpecifier) => {
|
|
8
|
+
const paths = sourceFile.getProject().getCompilerOptions().paths;
|
|
9
|
+
if (!paths)
|
|
10
|
+
return moduleSpecifier;
|
|
11
|
+
const baseUrl = sourceFile.getProject().getCompilerOptions().baseUrl;
|
|
12
|
+
const paths2 = Object.entries(paths);
|
|
13
|
+
// Chercher la correspondance dans les paths
|
|
14
|
+
for (const [pattern, mappings] of paths2) {
|
|
15
|
+
// Remplacer * par une regex pour matcher
|
|
16
|
+
const regexPattern = pattern.replace(/\*/g, '(.*)');
|
|
17
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
18
|
+
const match = moduleSpecifier.match(regex);
|
|
19
|
+
if (match) {
|
|
20
|
+
// Prendre le premier mapping disponible
|
|
21
|
+
const first = mappings[0];
|
|
22
|
+
// Résoudre le chemin absolu
|
|
23
|
+
let relativedPath = baseUrl ? join(baseUrl, first) : first;
|
|
24
|
+
if (match[1]) {
|
|
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;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Analyse les imports d'un fichier
|
|
40
|
+
*/
|
|
41
|
+
const analyzeImports = (sourceFile) => {
|
|
42
|
+
const imports = [];
|
|
43
|
+
// Import declarations (import ... from '...')
|
|
44
|
+
sourceFile.getImportDeclarations().forEach(importDecl => {
|
|
45
|
+
const rawModuleSpecifier = importDecl.getModuleSpecifierValue();
|
|
46
|
+
const moduleSpecifier = resolveModuleSpecifier(sourceFile, rawModuleSpecifier);
|
|
47
|
+
// Import default
|
|
48
|
+
const defaultImport = importDecl.getDefaultImport();
|
|
49
|
+
if (defaultImport) {
|
|
50
|
+
imports.push({
|
|
51
|
+
moduleSpecifier,
|
|
52
|
+
kind: 'default',
|
|
53
|
+
default: defaultImport.getText(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Import namespace (* as name)
|
|
57
|
+
const namespaceImport = importDecl.getNamespaceImport();
|
|
58
|
+
if (namespaceImport) {
|
|
59
|
+
imports.push({
|
|
60
|
+
moduleSpecifier,
|
|
61
|
+
kind: 'namespace',
|
|
62
|
+
default: namespaceImport.getText(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Named imports ({ name1, name2 })
|
|
66
|
+
const namedImports = importDecl.getNamedImports();
|
|
67
|
+
if (namedImports.length > 0) {
|
|
68
|
+
imports.push({
|
|
69
|
+
moduleSpecifier,
|
|
70
|
+
kind: 'named',
|
|
71
|
+
namedImports: namedImports.map(ni => ni.getName()),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Side-effect import (import '...')
|
|
75
|
+
if (!defaultImport && !namespaceImport && namedImports.length === 0) {
|
|
76
|
+
imports.push({
|
|
77
|
+
moduleSpecifier,
|
|
78
|
+
kind: 'side-effect',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
// Dynamic imports (import('...'))
|
|
83
|
+
sourceFile
|
|
84
|
+
.getDescendantsOfKind(SyntaxKind.CallExpression)
|
|
85
|
+
.forEach(callExpr => {
|
|
86
|
+
if (callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword) {
|
|
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;
|
|
100
|
+
};
|
|
101
|
+
const buildImportStrings = (imports) => {
|
|
102
|
+
return imports.map(imp => {
|
|
103
|
+
switch (imp.kind) {
|
|
104
|
+
case 'named': {
|
|
105
|
+
const namedImports = imp.namedImports?.join(', ') || '';
|
|
106
|
+
return `import { ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
107
|
+
}
|
|
108
|
+
case 'namespace':
|
|
109
|
+
return `import * as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
110
|
+
case 'side-effect': {
|
|
111
|
+
if (imp.isDynamic) {
|
|
112
|
+
return `// Dynamic import: import('${imp.moduleSpecifier}')`;
|
|
113
|
+
}
|
|
114
|
+
return `import '${imp.moduleSpecifier}';`;
|
|
115
|
+
}
|
|
116
|
+
case 'default':
|
|
117
|
+
return `import ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
118
|
+
default:
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { analyzeImports, buildImportStrings };
|
|
125
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sources":["../src/imports.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { SourceFile, SyntaxKind } from 'ts-morph';\nimport type { ImportInfo } from './types';\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('.')\n ? relativePath\n : `./${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 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 });\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 });\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 });\n }\n\n // Side-effect import (import '...')\n if (!defaultImport && !namespaceImport && namedImports.length === 0) {\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\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 { ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import * 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.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"names":[],"mappings":";;;AAIA;;AAEG;AACH,MAAM,sBAAsB,GAAG,CAC7B,UAAsB,EACtB,eAAuB,KACb;IACV,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,kBAAkB,EAAE,CAAC,KAAK;AAEhE,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,eAAe;IAElC,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,kBAAkB,EAAE,CAAC,OAAO;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAA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"}
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var functions_add = require('./functions/add.cjs');
|
|
4
|
+
var functions_generate = require('./functions/generate.cjs');
|
|
5
|
+
var functions_init = require('./functions/init.cjs');
|
|
6
|
+
var functions_remove = require('./functions/remove.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.add = functions_add.add;
|
|
11
|
+
exports.generate = functions_generate.generate;
|
|
12
|
+
exports.transformJSON = functions_generate.transformJSON;
|
|
13
|
+
exports.createTypesStructure = functions_init.createTypesStructure;
|
|
14
|
+
exports.init = functions_init.init;
|
|
15
|
+
exports.remove = functions_remove.remove;
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/lib/schemas.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var v = require('valibot');
|
|
4
|
+
var constants = require('./constants.cjs');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var v__namespace = /*#__PURE__*/_interopNamespaceDefault(v);
|
|
24
|
+
|
|
25
|
+
// Schema pour DeclarationKind
|
|
26
|
+
const DeclarationKindSchema = v__namespace.picklist([
|
|
27
|
+
'function',
|
|
28
|
+
'class',
|
|
29
|
+
'interface',
|
|
30
|
+
'type',
|
|
31
|
+
'variable',
|
|
32
|
+
'const',
|
|
33
|
+
'let',
|
|
34
|
+
'enum',
|
|
35
|
+
]);
|
|
36
|
+
// Schema pour ImportInfo
|
|
37
|
+
const ImportInfoSchema = v__namespace.object({
|
|
38
|
+
moduleSpecifier: v__namespace.string(),
|
|
39
|
+
kind: v__namespace.picklist(['default', 'named', 'namespace', 'side-effect']),
|
|
40
|
+
namedImports: v__namespace.optional(v__namespace.array(v__namespace.string())),
|
|
41
|
+
default: v__namespace.optional(v__namespace.string()),
|
|
42
|
+
isDynamic: v__namespace.optional(v__namespace.boolean()),
|
|
43
|
+
});
|
|
44
|
+
// Schema pour ExportInfo
|
|
45
|
+
const ExportInfoSchema = v__namespace.object({
|
|
46
|
+
name: v__namespace.string(),
|
|
47
|
+
kind: v__namespace.picklist(['default', 'named', 'namespace']),
|
|
48
|
+
text: v__namespace.optional(v__namespace.string()),
|
|
49
|
+
moduleSpecifier: v__namespace.optional(v__namespace.string()),
|
|
50
|
+
declarationKind: v__namespace.optional(DeclarationKindSchema),
|
|
51
|
+
});
|
|
52
|
+
// Schema pour FileAnalysis
|
|
53
|
+
const FileAnalysisSchema = v__namespace.object({
|
|
54
|
+
relativePath: v__namespace.string(),
|
|
55
|
+
imports: v__namespace.array(ImportInfoSchema),
|
|
56
|
+
exports: v__namespace.optional(v__namespace.array(ExportInfoSchema)),
|
|
57
|
+
text: v__namespace.string(),
|
|
58
|
+
});
|
|
59
|
+
// Schema pour CodebaseAnalysis
|
|
60
|
+
const CodebaseAnalysisSchema = v__namespace.record(v__namespace.string(), FileAnalysisSchema);
|
|
61
|
+
// Schema pour les statistiques d'analyse
|
|
62
|
+
const AnalysisStatsSchema = v__namespace.object({
|
|
63
|
+
files: v__namespace.number(),
|
|
64
|
+
imports: v__namespace.number(),
|
|
65
|
+
exports: v__namespace.number(),
|
|
66
|
+
});
|
|
67
|
+
// Schema complet pour un fichier .code contenant l'analyse complète
|
|
68
|
+
const CodeAnalysisFileSchema = v__namespace.object({
|
|
69
|
+
[constants.PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,
|
|
70
|
+
[constants.PROPERTIES.STATS]: v__namespace.optional(AnalysisStatsSchema),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
exports.AnalysisStatsSchema = AnalysisStatsSchema;
|
|
74
|
+
exports.CodeAnalysisFileSchema = CodeAnalysisFileSchema;
|
|
75
|
+
exports.CodebaseAnalysisSchema = CodebaseAnalysisSchema;
|
|
76
|
+
exports.DeclarationKindSchema = DeclarationKindSchema;
|
|
77
|
+
exports.ExportInfoSchema = ExportInfoSchema;
|
|
78
|
+
exports.FileAnalysisSchema = FileAnalysisSchema;
|
|
79
|
+
exports.ImportInfoSchema = ImportInfoSchema;
|
|
80
|
+
//# sourceMappingURL=schemas.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.cjs","sources":["../src/schemas.ts"],"sourcesContent":["import * as v from 'valibot';\nimport { PROPERTIES } from './constants';\n\n// Schema pour DeclarationKind\nexport const DeclarationKindSchema = v.picklist([\n 'function',\n 'class',\n 'interface',\n 'type',\n 'variable',\n 'const',\n 'let',\n 'enum',\n]);\n\n// Schema pour ImportInfo\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});\n\n// Schema pour ExportInfo\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\n// Schema pour FileAnalysis\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(\n v.string(),\n FileAnalysisSchema,\n);\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<\n typeof CodebaseAnalysisSchema\n>;\nexport type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;\nexport type CodeAnalysisFile = v.InferOutput<\n typeof CodeAnalysisFileSchema\n>;\n"],"names":["v","PROPERTIES"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACO,MAAM,qBAAqB,GAAGA,YAAC,CAAC,QAAQ,CAAC;IAC9C,UAAU;IACV,OAAO;IACP,WAAW;IACX,MAAM;IACN,UAAU;IACV,OAAO;IACP,KAAK;IACL,MAAM;AACP,CAAA;AAED;AACO,MAA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;AACO,MAAM,sBAAsB,GAAGA,YAAC,CAAC,MAAM,CAC5CA,YAAC,CAAC,MAAM,EAAE,EACV,kBAAkB;AAGpB;AACO,MAAM,mBAAmB,GAAGA,YAAC,CAAC,MAAM,CAAC;AAC1C,IAAA,KAAK,EAAEA,YAAC,CAAC,MAAM,EAAE;AACjB,IAAA,OAAO,EAAEA,YAAC,CAAC,MAAM,EAAE;AACnB,IAAA,OAAO,EAAEA,YAAC,CAAC,MAAM,EAAE;AACpB,CAAA;AAED;AACO,MAAM,sBAAsB,GAAGA,YAAC,CAAC,MAAM,CAAC;AAC7C,IAAA,CAACC,oBAAU,CAAC,iBAAiB,GAAG,sBAAsB;IACtD,CAACA,oBAAU,CAAC,KAAK,GAAGD,YAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;AACpD,CAAA;;;;;;;;;;"}
|
package/lib/schemas.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const DeclarationKindSchema: v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>;
|
|
3
|
+
export declare const ImportInfoSchema: v.ObjectSchema<{
|
|
4
|
+
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
5
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace", "side-effect"], undefined>;
|
|
6
|
+
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
7
|
+
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8
|
+
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
9
|
+
}, undefined>;
|
|
10
|
+
export declare const ExportInfoSchema: v.ObjectSchema<{
|
|
11
|
+
readonly name: v.StringSchema<undefined>;
|
|
12
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace"], undefined>;
|
|
13
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
14
|
+
readonly moduleSpecifier: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
15
|
+
readonly declarationKind: v.OptionalSchema<v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>, undefined>;
|
|
16
|
+
}, undefined>;
|
|
17
|
+
export declare const FileAnalysisSchema: v.ObjectSchema<{
|
|
18
|
+
readonly relativePath: v.StringSchema<undefined>;
|
|
19
|
+
readonly imports: v.ArraySchema<v.ObjectSchema<{
|
|
20
|
+
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
21
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace", "side-effect"], undefined>;
|
|
22
|
+
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
23
|
+
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
|
+
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
25
|
+
}, undefined>, undefined>;
|
|
26
|
+
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
27
|
+
readonly name: v.StringSchema<undefined>;
|
|
28
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace"], undefined>;
|
|
29
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
30
|
+
readonly moduleSpecifier: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
31
|
+
readonly declarationKind: v.OptionalSchema<v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>, undefined>;
|
|
32
|
+
}, undefined>, undefined>, undefined>;
|
|
33
|
+
readonly text: v.StringSchema<undefined>;
|
|
34
|
+
}, undefined>;
|
|
35
|
+
export declare const CodebaseAnalysisSchema: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
36
|
+
readonly relativePath: v.StringSchema<undefined>;
|
|
37
|
+
readonly imports: v.ArraySchema<v.ObjectSchema<{
|
|
38
|
+
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
39
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace", "side-effect"], undefined>;
|
|
40
|
+
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
41
|
+
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
43
|
+
}, undefined>, undefined>;
|
|
44
|
+
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
45
|
+
readonly name: v.StringSchema<undefined>;
|
|
46
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace"], undefined>;
|
|
47
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
48
|
+
readonly moduleSpecifier: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
49
|
+
readonly declarationKind: v.OptionalSchema<v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>, undefined>;
|
|
50
|
+
}, undefined>, undefined>, undefined>;
|
|
51
|
+
readonly text: v.StringSchema<undefined>;
|
|
52
|
+
}, undefined>, undefined>;
|
|
53
|
+
export declare const AnalysisStatsSchema: v.ObjectSchema<{
|
|
54
|
+
readonly files: v.NumberSchema<undefined>;
|
|
55
|
+
readonly imports: v.NumberSchema<undefined>;
|
|
56
|
+
readonly exports: v.NumberSchema<undefined>;
|
|
57
|
+
}, undefined>;
|
|
58
|
+
export declare const CodeAnalysisFileSchema: v.ObjectSchema<{
|
|
59
|
+
readonly CODEBASE_ANALYSIS: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
60
|
+
readonly relativePath: v.StringSchema<undefined>;
|
|
61
|
+
readonly imports: v.ArraySchema<v.ObjectSchema<{
|
|
62
|
+
readonly moduleSpecifier: v.StringSchema<undefined>;
|
|
63
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace", "side-effect"], undefined>;
|
|
64
|
+
readonly namedImports: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
65
|
+
readonly default: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
|
+
readonly isDynamic: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
67
|
+
}, undefined>, undefined>;
|
|
68
|
+
readonly exports: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
69
|
+
readonly name: v.StringSchema<undefined>;
|
|
70
|
+
readonly kind: v.PicklistSchema<["default", "named", "namespace"], undefined>;
|
|
71
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
72
|
+
readonly moduleSpecifier: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
73
|
+
readonly declarationKind: v.OptionalSchema<v.PicklistSchema<["function", "class", "interface", "type", "variable", "const", "let", "enum"], undefined>, undefined>;
|
|
74
|
+
}, undefined>, undefined>, undefined>;
|
|
75
|
+
readonly text: v.StringSchema<undefined>;
|
|
76
|
+
}, undefined>, undefined>;
|
|
77
|
+
readonly STATS: v.OptionalSchema<v.ObjectSchema<{
|
|
78
|
+
readonly files: v.NumberSchema<undefined>;
|
|
79
|
+
readonly imports: v.NumberSchema<undefined>;
|
|
80
|
+
readonly exports: v.NumberSchema<undefined>;
|
|
81
|
+
}, undefined>, undefined>;
|
|
82
|
+
}, undefined>;
|
|
83
|
+
export type DeclarationKind = v.InferOutput<typeof DeclarationKindSchema>;
|
|
84
|
+
export type ImportInfo = v.InferOutput<typeof ImportInfoSchema>;
|
|
85
|
+
export type ExportInfo = v.InferOutput<typeof ExportInfoSchema>;
|
|
86
|
+
export type FileAnalysis = v.InferOutput<typeof FileAnalysisSchema>;
|
|
87
|
+
export type CodebaseAnalysis = v.InferOutput<typeof CodebaseAnalysisSchema>;
|
|
88
|
+
export type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;
|
|
89
|
+
export type CodeAnalysisFile = v.InferOutput<typeof CodeAnalysisFileSchema>;
|
|
90
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAI7B,eAAO,MAAM,qBAAqB,6GAShC,CAAC;AAGH,eAAO,MAAM,gBAAgB;;;;;;aAM3B,CAAC;AAGH,eAAO,MAAM,gBAAgB;;;;;;aAM3B,CAAC;AAGH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;aAK7B,CAAC;AAGH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;yBAGlC,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;aAI9B,CAAC;AAGH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;aAGjC,CAAC;AAGH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAC1C,OAAO,sBAAsB,CAC9B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAC1C,OAAO,sBAAsB,CAC9B,CAAC"}
|
package/lib/schemas.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { PROPERTIES } from './constants.js';
|
|
3
|
+
|
|
4
|
+
// Schema pour DeclarationKind
|
|
5
|
+
const DeclarationKindSchema = v.picklist([
|
|
6
|
+
'function',
|
|
7
|
+
'class',
|
|
8
|
+
'interface',
|
|
9
|
+
'type',
|
|
10
|
+
'variable',
|
|
11
|
+
'const',
|
|
12
|
+
'let',
|
|
13
|
+
'enum',
|
|
14
|
+
]);
|
|
15
|
+
// Schema pour ImportInfo
|
|
16
|
+
const ImportInfoSchema = v.object({
|
|
17
|
+
moduleSpecifier: v.string(),
|
|
18
|
+
kind: v.picklist(['default', 'named', 'namespace', 'side-effect']),
|
|
19
|
+
namedImports: v.optional(v.array(v.string())),
|
|
20
|
+
default: v.optional(v.string()),
|
|
21
|
+
isDynamic: v.optional(v.boolean()),
|
|
22
|
+
});
|
|
23
|
+
// Schema pour ExportInfo
|
|
24
|
+
const ExportInfoSchema = v.object({
|
|
25
|
+
name: v.string(),
|
|
26
|
+
kind: v.picklist(['default', 'named', 'namespace']),
|
|
27
|
+
text: v.optional(v.string()),
|
|
28
|
+
moduleSpecifier: v.optional(v.string()),
|
|
29
|
+
declarationKind: v.optional(DeclarationKindSchema),
|
|
30
|
+
});
|
|
31
|
+
// Schema pour FileAnalysis
|
|
32
|
+
const FileAnalysisSchema = v.object({
|
|
33
|
+
relativePath: v.string(),
|
|
34
|
+
imports: v.array(ImportInfoSchema),
|
|
35
|
+
exports: v.optional(v.array(ExportInfoSchema)),
|
|
36
|
+
text: v.string(),
|
|
37
|
+
});
|
|
38
|
+
// Schema pour CodebaseAnalysis
|
|
39
|
+
const CodebaseAnalysisSchema = v.record(v.string(), FileAnalysisSchema);
|
|
40
|
+
// Schema pour les statistiques d'analyse
|
|
41
|
+
const AnalysisStatsSchema = v.object({
|
|
42
|
+
files: v.number(),
|
|
43
|
+
imports: v.number(),
|
|
44
|
+
exports: v.number(),
|
|
45
|
+
});
|
|
46
|
+
// Schema complet pour un fichier .code contenant l'analyse complète
|
|
47
|
+
const CodeAnalysisFileSchema = v.object({
|
|
48
|
+
[PROPERTIES.CODEBASE_ANALYSIS]: CodebaseAnalysisSchema,
|
|
49
|
+
[PROPERTIES.STATS]: v.optional(AnalysisStatsSchema),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export { AnalysisStatsSchema, CodeAnalysisFileSchema, CodebaseAnalysisSchema, DeclarationKindSchema, ExportInfoSchema, FileAnalysisSchema, ImportInfoSchema };
|
|
53
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sources":["../src/schemas.ts"],"sourcesContent":["import * as v from 'valibot';\nimport { PROPERTIES } from './constants';\n\n// Schema pour DeclarationKind\nexport const DeclarationKindSchema = v.picklist([\n 'function',\n 'class',\n 'interface',\n 'type',\n 'variable',\n 'const',\n 'let',\n 'enum',\n]);\n\n// Schema pour ImportInfo\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});\n\n// Schema pour ExportInfo\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\n// Schema pour FileAnalysis\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(\n v.string(),\n FileAnalysisSchema,\n);\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<\n typeof CodebaseAnalysisSchema\n>;\nexport type AnalysisStats = v.InferOutput<typeof AnalysisStatsSchema>;\nexport type CodeAnalysisFile = v.InferOutput<\n typeof CodeAnalysisFileSchema\n>;\n"],"names":[],"mappings":";;;AAGA;AACO,MAAM,qBAAqB,GAAG,CAAC,CAAC,QAAQ,CAAC;IAC9C,UAAU;IACV,OAAO;IACP,WAAW;IACX,MAAM;IACN,UAAU;IACV,OAAO;IACP,KAAK;IACL,MAAM;AACP,CAAA;AAED;AACO,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC,IAAA,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;AAC3B,IAAA,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAClE,IAAA,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACnC,CAAA;AAED;AACO,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC,IAAA,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;AAChB,IAAA,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,C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ImportInfo = {
|
|
3
|
+
/** Module importé (ex: './utils', 'fs', etc.) */
|
|
4
|
+
moduleSpecifier: string;
|
|
5
|
+
/** Type d'import (default, named, namespace, etc.) */
|
|
6
|
+
kind: 'default' | 'named' | 'namespace' | 'side-effect';
|
|
7
|
+
/** Noms importés pour les imports named */
|
|
8
|
+
namedImports?: string[];
|
|
9
|
+
/** Nom de l'import default ou namespace */
|
|
10
|
+
default?: string;
|
|
11
|
+
/** Import dynamique */
|
|
12
|
+
isDynamic?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type ExportInfo = {
|
|
15
|
+
/** Nom de l'export */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Type d'export */
|
|
18
|
+
kind: 'default' | 'named' | 'namespace';
|
|
19
|
+
/** Texte complet de l'export */
|
|
20
|
+
text?: string;
|
|
21
|
+
/** Si c'est un re-export, le module source */
|
|
22
|
+
moduleSpecifier?: string;
|
|
23
|
+
/** Si c'est une déclaration (function, class, etc.) */
|
|
24
|
+
declarationKind?: DeclarationKind;
|
|
25
|
+
};
|
|
26
|
+
export type FileAnalysis = {
|
|
27
|
+
/** Chemin relatif du fichier depuis src/ */
|
|
28
|
+
relativePath: string;
|
|
29
|
+
/** Liste des imports du fichier */
|
|
30
|
+
imports: ImportInfo[];
|
|
31
|
+
/** Liste des exports du fichier */
|
|
32
|
+
exports: ExportInfo[];
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
35
|
+
export type CodebaseAnalysis = Record<string, FileAnalysis>;
|
|
36
|
+
/**
|
|
37
|
+
* NOmit type - Auto-generated expression
|
|
38
|
+
*
|
|
39
|
+
* ⚠️ WARNING: This expression is auto-generated and should not be modified.
|
|
40
|
+
* @author chlbri (bri_lvi@icloud.com)
|
|
41
|
+
*/
|
|
42
|
+
export type NOmit<T, K extends keyof T> = Omit<T, K>;
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sour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ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convertit un chemin de fichier en clé dot notation comme dans .manifest.ts
|
|
5
|
+
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
6
|
+
*/
|
|
7
|
+
function pathToDotNotation(filePath) {
|
|
8
|
+
return filePath
|
|
9
|
+
.replace(/\.ts$/, '') // Enlever l'extension .ts
|
|
10
|
+
.replace(/\//g, '.'); // Remplacer les / par des .
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.pathToDotNotation = pathToDotNotation;
|
|
14
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../src/utils.ts"],"sourcesContent":["/**\n * Convertit un chemin de fichier en clé dot notation comme dans .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$/, '') // Enlever l'extension .ts\n .replace(/\\//g, '.'); // Remplacer les / par des .\n}\n"],"names":[],"mappings":";;AAAA;;;AAGG;AACG,SAAU,iBAAiB,CAAC,QAAgB,EAAA;AAChD,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AACpB,SAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzB;;;;"}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convertit un chemin de fichier en clé dot notation comme dans .manifest.ts
|
|
3
|
+
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
4
|
+
*/
|
|
5
|
+
export declare function pathToDotNotation(filePath: string): string;
|
|
6
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +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,CAI1D"}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convertit un chemin de fichier en clé dot notation comme dans .manifest.ts
|
|
3
|
+
* Ex: 'features/arrays/castings/all.ts' -> 'features.arrays.castings.all'
|
|
4
|
+
*/
|
|
5
|
+
function pathToDotNotation(filePath) {
|
|
6
|
+
return filePath
|
|
7
|
+
.replace(/\.ts$/, '') // Enlever l'extension .ts
|
|
8
|
+
.replace(/\//g, '.'); // Remplacer les / par des .
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { pathToDotNotation };
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["/**\n * Convertit un chemin de fichier en clé dot notation comme dans .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$/, '') // Enlever l'extension .ts\n .replace(/\\//g, '.'); // Remplacer les / par des .\n}\n"],"names":[],"mappings":"AAAA;;;AAGG;AACG,SAAU,iBAAiB,CAAC,QAAgB,EAAA;AAChD,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AACpB,SAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzB;;;;"}
|