@adonisjs/assembler 8.0.0-next.21 → 8.0.0-next.23
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/build/helpers-DDurYRsZ.js +72 -0
- package/build/index.js +916 -1665
- package/build/main-1eXSE5Xo.js +185 -0
- package/build/main-Byxt3AdL.js +240 -0
- package/build/src/code_scanners/routes_scanner/main.js +4 -8
- package/build/src/code_transformer/main.js +276 -622
- package/build/src/debug.d.ts +1 -1
- package/build/src/helpers.js +2 -16
- package/build/src/index_generator/main.js +3 -7
- package/build/src/types/main.js +1 -0
- package/build/virtual_file_system-DM1KRNbk.js +283 -0
- package/package.json +28 -25
- package/build/chunk-JFBQ4OEM.js +0 -434
- package/build/chunk-NAASGAFO.js +0 -478
- package/build/chunk-NR7VMFWO.js +0 -468
- package/build/chunk-TIKQQRMX.js +0 -116
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { parseImports } from "parse-imports";
|
|
2
|
+
async function findImport(code, importReference) {
|
|
3
|
+
const importIdentifier = importReference.split(".")[0];
|
|
4
|
+
for (const $import of await parseImports(code, {})) {
|
|
5
|
+
if (!$import.importClause) continue;
|
|
6
|
+
if (!$import.moduleSpecifier.value) continue;
|
|
7
|
+
if ($import.importClause.default === importIdentifier) return {
|
|
8
|
+
specifier: $import.moduleSpecifier.value,
|
|
9
|
+
isConstant: $import.moduleSpecifier.isConstant,
|
|
10
|
+
clause: {
|
|
11
|
+
type: "default",
|
|
12
|
+
value: importIdentifier
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if ($import.importClause.namespace === importIdentifier) return {
|
|
16
|
+
specifier: $import.moduleSpecifier.value,
|
|
17
|
+
isConstant: $import.moduleSpecifier.isConstant,
|
|
18
|
+
clause: {
|
|
19
|
+
type: "namespace",
|
|
20
|
+
value: importIdentifier
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const namedImport = $import.importClause.named.find(({ binding }) => {
|
|
24
|
+
return binding === importIdentifier;
|
|
25
|
+
});
|
|
26
|
+
if (namedImport) return {
|
|
27
|
+
specifier: $import.moduleSpecifier.value,
|
|
28
|
+
isConstant: $import.moduleSpecifier.isConstant,
|
|
29
|
+
clause: {
|
|
30
|
+
type: "named",
|
|
31
|
+
value: namedImport.specifier,
|
|
32
|
+
...namedImport.binding !== namedImport.specifier ? { alias: namedImport.binding } : {}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function inspectClass(node) {
|
|
39
|
+
return node.find({ rule: { kind: "class_declaration" } });
|
|
40
|
+
}
|
|
41
|
+
function inspectClassMethods(node) {
|
|
42
|
+
return node.findAll({ rule: { kind: "method_definition" } });
|
|
43
|
+
}
|
|
44
|
+
function nodeToPlainText(node) {
|
|
45
|
+
let out = [];
|
|
46
|
+
function toText(one) {
|
|
47
|
+
const children = one.children();
|
|
48
|
+
if (!children.length) out.push(one.text());
|
|
49
|
+
else children.forEach((child) => toText(child));
|
|
50
|
+
}
|
|
51
|
+
toText(node);
|
|
52
|
+
return out.join("");
|
|
53
|
+
}
|
|
54
|
+
function inspectMethodArguments(node, methodCalls) {
|
|
55
|
+
return node.findAll({ rule: { any: methodCalls.map((methodCall) => {
|
|
56
|
+
return { pattern: {
|
|
57
|
+
context: `${methodCall}($$$ARGUMENTS)`,
|
|
58
|
+
selector: "call_expression"
|
|
59
|
+
} };
|
|
60
|
+
}) } }).flatMap((matchingExpression) => {
|
|
61
|
+
return matchingExpression.findAll({ rule: { kind: "arguments" } });
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function searchValidatorDirectUsage(node) {
|
|
65
|
+
return node.findAll({ rule: { pattern: {
|
|
66
|
+
context: "$$$VALIDATOR.validate($$$)",
|
|
67
|
+
selector: "call_expression"
|
|
68
|
+
} } }).flatMap((expression) => {
|
|
69
|
+
return expression.getMultipleMatches("VALIDATOR");
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export { nodeToPlainText as a, inspectMethodArguments as i, inspectClass as n, searchValidatorDirectUsage as o, inspectClassMethods as r, findImport as t };
|