@bemedev/codebase 0.1.2 → 0.1.3
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/CHANGE_LOG.md +18 -0
- package/lib/imports.cjs +9 -3
- package/lib/imports.cjs.map +1 -1
- package/lib/imports.d.ts.map +1 -1
- package/lib/imports.js +9 -3
- package/lib/imports.js.map +1 -1
- package/lib/schemas.cjs +1 -0
- package/lib/schemas.cjs.map +1 -1
- package/lib/schemas.d.ts +4 -0
- package/lib/schemas.d.ts.map +1 -1
- package/lib/schemas.js +1 -0
- package/lib/schemas.js.map +1 -1
- package/package.json +1 -1
package/CHANGE_LOG.md
CHANGED
|
@@ -6,6 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
<summary>
|
|
8
8
|
|
|
9
|
+
### Version [0.1.3] --> _2025/12/27 16:37_
|
|
10
|
+
|
|
11
|
+
</summary>
|
|
12
|
+
|
|
13
|
+
- Filter out undefined module specifiers from exports in transformJSON
|
|
14
|
+
- Update CI workflows for improved version and dependency management
|
|
15
|
+
- Adding type imports support
|
|
16
|
+
- Update dependencies (glob 11.0.3 → 11.1.0)
|
|
17
|
+
- <u>Test coverage **_100%_**</u>
|
|
18
|
+
|
|
19
|
+
</details>
|
|
20
|
+
|
|
21
|
+
<br/>
|
|
22
|
+
|
|
23
|
+
<details>
|
|
24
|
+
|
|
25
|
+
<summary>
|
|
26
|
+
|
|
9
27
|
### Version [0.1.2] --> _2025/09/05 19:42_
|
|
10
28
|
|
|
11
29
|
</summary>
|
package/lib/imports.cjs
CHANGED
|
@@ -44,6 +44,8 @@ const analyzeImports = (sourceFile) => {
|
|
|
44
44
|
const imports = [];
|
|
45
45
|
// Import declarations (import ... from '...')
|
|
46
46
|
sourceFile.getImportDeclarations().forEach(importDecl => {
|
|
47
|
+
// Determine if this is a type-only import
|
|
48
|
+
const isTypeOnly = importDecl.isTypeOnly();
|
|
47
49
|
const rawModuleSpecifier = importDecl.getModuleSpecifierValue();
|
|
48
50
|
const moduleSpecifier = resolveModuleSpecifier(sourceFile, rawModuleSpecifier);
|
|
49
51
|
// Import default
|
|
@@ -53,6 +55,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
53
55
|
moduleSpecifier,
|
|
54
56
|
kind: 'default',
|
|
55
57
|
default: defaultImport.getText(),
|
|
58
|
+
isTypeOnly,
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
61
|
// Import namespace (* as name)
|
|
@@ -62,6 +65,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
62
65
|
moduleSpecifier,
|
|
63
66
|
kind: 'namespace',
|
|
64
67
|
default: namespaceImport.getText(),
|
|
68
|
+
isTypeOnly,
|
|
65
69
|
});
|
|
66
70
|
}
|
|
67
71
|
// Named imports ({ name1, name2 })
|
|
@@ -71,6 +75,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
71
75
|
moduleSpecifier,
|
|
72
76
|
kind: 'named',
|
|
73
77
|
namedImports: namedImports.map(ni => ni.getName()),
|
|
78
|
+
isTypeOnly,
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
// Side-effect import (import '...')
|
|
@@ -78,6 +83,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
78
83
|
imports.push({
|
|
79
84
|
moduleSpecifier,
|
|
80
85
|
kind: 'side-effect',
|
|
86
|
+
isTypeOnly,
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
89
|
});
|
|
@@ -105,10 +111,10 @@ const buildImportStrings = (imports) => {
|
|
|
105
111
|
switch (imp.kind) {
|
|
106
112
|
case 'named': {
|
|
107
113
|
const namedImports = imp.namedImports?.join(', ') || '';
|
|
108
|
-
return `import { ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
114
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
109
115
|
}
|
|
110
116
|
case 'namespace':
|
|
111
|
-
return `import * as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
117
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
112
118
|
case 'side-effect': {
|
|
113
119
|
if (imp.isDynamic) {
|
|
114
120
|
return `// Dynamic import: import('${imp.moduleSpecifier}')`;
|
|
@@ -116,7 +122,7 @@ const buildImportStrings = (imports) => {
|
|
|
116
122
|
return `import '${imp.moduleSpecifier}';`;
|
|
117
123
|
}
|
|
118
124
|
case 'default':
|
|
119
|
-
return `import ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
125
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;
|
|
120
126
|
default:
|
|
121
127
|
return '';
|
|
122
128
|
}
|
package/lib/imports.cjs.map
CHANGED
|
@@ -1 +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 './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('.')\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,CAAC,aAAa,EAAE,aAAa,CAAC;;AAG3D,YAAA,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG;AAChC,kBAAE;AACF,kBAAE,CAAA,EAAA,EAAK,YAAY,CAAA,CAAE;QACzB;IACF;AAEA,IAAA,OAAO,eAAe;AACxB,CAAC;AAED;;AAEG;AACI,MAAM,cAAc,GAAG,CAAC,UAAsB,KAAkB;IACrE,MAAM,OAAO,GAAiB,EAAE;;IAGhC,UAAU,CAAC,qBAAqB,EAAE,CAAC,OAAO,CAAC,UAAU,IAAG;
|
|
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 './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('.')\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 // 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 (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"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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A,EAAA,CAAI;AAC/F,YAAA;AACE,gBAAA,OAAO,EAAE;;AAEf,IAAA,CAAC,CAAC;AACJ;;;;;"}
|
package/lib/imports.d.ts.map
CHANGED
|
@@ -1 +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,WAAW,CAAC;AAmD5C;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,UAAU,KAAG,UAAU,
|
|
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,WAAW,CAAC;AAmD5C;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,UAAU,KAAG,UAAU,EAiFjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,UAAU,EAAE,aAsBvD,CAAC"}
|
package/lib/imports.js
CHANGED
|
@@ -42,6 +42,8 @@ const analyzeImports = (sourceFile) => {
|
|
|
42
42
|
const imports = [];
|
|
43
43
|
// Import declarations (import ... from '...')
|
|
44
44
|
sourceFile.getImportDeclarations().forEach(importDecl => {
|
|
45
|
+
// Determine if this is a type-only import
|
|
46
|
+
const isTypeOnly = importDecl.isTypeOnly();
|
|
45
47
|
const rawModuleSpecifier = importDecl.getModuleSpecifierValue();
|
|
46
48
|
const moduleSpecifier = resolveModuleSpecifier(sourceFile, rawModuleSpecifier);
|
|
47
49
|
// Import default
|
|
@@ -51,6 +53,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
51
53
|
moduleSpecifier,
|
|
52
54
|
kind: 'default',
|
|
53
55
|
default: defaultImport.getText(),
|
|
56
|
+
isTypeOnly,
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
// Import namespace (* as name)
|
|
@@ -60,6 +63,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
60
63
|
moduleSpecifier,
|
|
61
64
|
kind: 'namespace',
|
|
62
65
|
default: namespaceImport.getText(),
|
|
66
|
+
isTypeOnly,
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
69
|
// Named imports ({ name1, name2 })
|
|
@@ -69,6 +73,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
69
73
|
moduleSpecifier,
|
|
70
74
|
kind: 'named',
|
|
71
75
|
namedImports: namedImports.map(ni => ni.getName()),
|
|
76
|
+
isTypeOnly,
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
79
|
// Side-effect import (import '...')
|
|
@@ -76,6 +81,7 @@ const analyzeImports = (sourceFile) => {
|
|
|
76
81
|
imports.push({
|
|
77
82
|
moduleSpecifier,
|
|
78
83
|
kind: 'side-effect',
|
|
84
|
+
isTypeOnly,
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
});
|
|
@@ -103,10 +109,10 @@ const buildImportStrings = (imports) => {
|
|
|
103
109
|
switch (imp.kind) {
|
|
104
110
|
case 'named': {
|
|
105
111
|
const namedImports = imp.namedImports?.join(', ') || '';
|
|
106
|
-
return `import { ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
112
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;
|
|
107
113
|
}
|
|
108
114
|
case 'namespace':
|
|
109
|
-
return `import * as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
115
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
110
116
|
case 'side-effect': {
|
|
111
117
|
if (imp.isDynamic) {
|
|
112
118
|
return `// Dynamic import: import('${imp.moduleSpecifier}')`;
|
|
@@ -114,7 +120,7 @@ const buildImportStrings = (imports) => {
|
|
|
114
120
|
return `import '${imp.moduleSpecifier}';`;
|
|
115
121
|
}
|
|
116
122
|
case 'default':
|
|
117
|
-
return `import ${imp.default} from '${imp.moduleSpecifier}';`;
|
|
123
|
+
return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;
|
|
118
124
|
default:
|
|
119
125
|
return '';
|
|
120
126
|
}
|
package/lib/imports.js.map
CHANGED
|
@@ -1 +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 './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('.')\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,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,GAAG,IAAI,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,GAAG,QAAQ,CAC5B,OAAO,CAAC,GAAG,EAAE,EACb,UAAU,CAAC,gBAAgB,EAAE,CAC9B;YACD,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;;AAG3D,YAAA,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG;AAChC,kBAAE;AACF,kBAAE,CAAA,EAAA,EAAK,YAAY,CAAA,CAAE;QACzB;IACF;AAEA,IAAA,OAAO,eAAe;AACxB,CAAC;AAED;;AAEG;AACI,MAAM,cAAc,GAAG,CAAC,UAAsB,KAAkB;IACrE,MAAM,OAAO,GAAiB,EAAE;;IAGhC,UAAU,CAAC,qBAAqB,EAAE,CAAC,OAAO,CAAC,UAAU,IAAG;
|
|
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 './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('.')\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 // 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 (\n callExpr.getExpression().getKind() === SyntaxKind.ImportKeyword\n ) {\n const arg = callExpr.getArguments()[0];\n if (arg && arg.getKind() === SyntaxKind.StringLiteral) {\n const rawModuleSpecifier = arg.getText().replace(/['\"]/g, '');\n const moduleSpecifier = resolveModuleSpecifier(\n sourceFile,\n rawModuleSpecifier,\n );\n imports.push({\n moduleSpecifier,\n kind: 'side-effect',\n isDynamic: true,\n });\n }\n }\n });\n\n return imports;\n};\n\nexport const buildImportStrings = (imports: ImportInfo[]) => {\n return imports.map(imp => {\n switch (imp.kind) {\n case 'named': {\n const namedImports = imp.namedImports?.join(', ') || '';\n return `import ${imp.isTypeOnly ? 'type ' : ''}{ ${namedImports} } from '${imp.moduleSpecifier}';`;\n }\n case 'namespace':\n return `import ${imp.isTypeOnly ? 'type ' : ''}* as ${imp.default} from '${imp.moduleSpecifier}';`;\n case 'side-effect': {\n if (imp.isDynamic) {\n return `// Dynamic import: import('${imp.moduleSpecifier}')`;\n }\n return `import '${imp.moduleSpecifier}';`;\n }\n\n case 'default':\n return `import ${imp.isTypeOnly ? 'type ' : ''}${imp.default} from '${imp.moduleSpecifier}';`;\n default:\n return '';\n }\n });\n};\n"],"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,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,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK;AAE1D,YAAA,IAA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AAO;AAChB;AAEO,MAAM,kBAAkB,GAAG,CAAC,OAAqB,KAAI;AAC1D,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,IAAG;AACvB,QAAA,QAAQ,GAAG,CAAC,IAAI;YACd,KAAK,OAAO,EAAE;AACZ,gBAAA,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;AACvD,gBAAA,OAAO,UAAU,GAAG,CAAC,UAAU,GAAG,OAAO,GAAG,EAAE,KAAK,YAAY,CAAA,SAAA,EAAY,GAAG,CAAC,eAAe,IAAI;YACpG;AACA,YAAA,KAAK,WAAW;gBACd,OAAO,CAAA,OAAA,EAAU,GAAG,CAAC,UAAU,GAAG,OAAO,GAAG,EAAE,CAAA,KAAA,EAAQ,GAAG,CAAC,OAAO,UAAU,GAAG,CAAC,eAAe,CAAA,EAAA,CAAI;YACpG,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,UAAU,GAAG,OAAO,GAAG,EAAE,CAAA,EAAG,GAAG,CAAC,OAAO,UAAU,GAAG,CAAC,eAAe,CAAA,EAAA,CAAI;AAC/F,YAAA;AACE,gBAAA,OAAO,EAAE;;AAEf,IAAA,CAAC,CAAC;AACJ;;;;"}
|
package/lib/schemas.cjs
CHANGED
|
@@ -38,6 +38,7 @@ const ImportInfoSchema = v__namespace.object({
|
|
|
38
38
|
namedImports: v__namespace.optional(v__namespace.array(v__namespace.string())),
|
|
39
39
|
default: v__namespace.optional(v__namespace.string()),
|
|
40
40
|
isDynamic: v__namespace.optional(v__namespace.boolean()),
|
|
41
|
+
isTypeOnly: v__namespace.optional(v__namespace.boolean()),
|
|
41
42
|
});
|
|
42
43
|
const ExportInfoSchema = v__namespace.object({
|
|
43
44
|
name: v__namespace.string(),
|
package/lib/schemas.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.cjs","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});\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(\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":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,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;AAEM,MAAM,gBAAgB,GAAGA,YAAC,CAAC,MAAM,CAAC;AACvC,IAAA,eAAe,EAAEA,YAAC,CAAC,MAAM,EAAE;AAC3B,IAAA,IAAI,EAAEA,YAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAClE,IAAA,YAAY,EAAEA,YAAC,CAAC,QAAQ,CAACA,YAAC,CAAC,KAAK,CAACA,YAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAEA,YAAC,CAAC,QAAQ,CAACA,YAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAEA,YAAC,CAAC,QAAQ,CAACA,YAAC,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.cjs","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(\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":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,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;AAEM,MAAM,gBAAgB,GAAGA,YAAC,CAAC,MAAM,CAAC;AACvC,IAAA,eAAe,EAAEA,YAAC,CAAC,MAAM,EA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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
CHANGED
|
@@ -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>;
|
package/lib/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,eAAO,MAAM,qBAAqB,6GAShC,CAAC;AAEH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,eAAO,MAAM,qBAAqB,6GAShC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;aAO3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;aAM3B,CAAC;AAEH,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
CHANGED
|
@@ -17,6 +17,7 @@ const ImportInfoSchema = v.object({
|
|
|
17
17
|
namedImports: v.optional(v.array(v.string())),
|
|
18
18
|
default: v.optional(v.string()),
|
|
19
19
|
isDynamic: v.optional(v.boolean()),
|
|
20
|
+
isTypeOnly: v.optional(v.boolean()),
|
|
20
21
|
});
|
|
21
22
|
const ExportInfoSchema = v.object({
|
|
22
23
|
name: v.string(),
|
package/lib/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","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});\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(\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":";;;AAGO,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;AAEM,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;
|
|
1
|
+
{"version":3,"file":"schemas.js","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(\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":";;;AAGO,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;AAEM,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,CA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