@adonisjs/assembler 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/chunk-DF48asd8.js +9 -0
- package/build/{codemod_exception-CzQgXAAf.js → codemod_exception-BMNJZ0i1.js} +143 -0
- package/build/index.js +934 -7
- package/build/main-DEUzrVBq.js +565 -0
- package/build/main-INOi9swJ.js +471 -0
- package/build/src/code_scanners/routes_scanner/main.js +3 -171
- package/build/src/code_transformer/main.js +481 -2
- package/build/src/file_system.d.ts +1 -1
- package/build/src/helpers.js +133 -0
- package/build/src/index_generator/main.js +3 -28
- package/build/src/types/main.js +1 -0
- package/build/src/utils.d.ts +0 -2
- package/build/{virtual_file_system-bGeoWsK-.js → virtual_file_system-dzfXNwEp.js} +287 -0
- package/package.json +9 -9
- package/build/source-dVeugJ0e.js +0 -166
- package/build/validator_extractor-Ccio_Ndi.js +0 -82
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.1.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -45,31 +45,31 @@
|
|
|
45
45
|
"@japa/runner": "^5.3.0",
|
|
46
46
|
"@japa/snapshot": "^2.0.10",
|
|
47
47
|
"@poppinss/ts-exec": "^1.4.4",
|
|
48
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
49
|
-
"@types/node": "^25.
|
|
48
|
+
"@release-it/conventional-changelog": "^10.0.6",
|
|
49
|
+
"@types/node": "^25.5.0",
|
|
50
50
|
"@types/picomatch": "^4.0.2",
|
|
51
51
|
"@types/pretty-hrtime": "^1.0.3",
|
|
52
52
|
"c8": "^11.0.0",
|
|
53
53
|
"cross-env": "^10.1.0",
|
|
54
54
|
"del-cli": "^7.0.0",
|
|
55
|
-
"eslint": "^10.0.
|
|
56
|
-
"hot-hook": "^0.
|
|
55
|
+
"eslint": "^10.0.3",
|
|
56
|
+
"hot-hook": "^1.0.0",
|
|
57
57
|
"p-event": "^7.1.0",
|
|
58
58
|
"prettier": "^3.8.1",
|
|
59
59
|
"release-it": "^19.2.4",
|
|
60
|
-
"tsdown": "^0.
|
|
60
|
+
"tsdown": "^0.21.4",
|
|
61
61
|
"typedoc": "^0.28.17",
|
|
62
62
|
"typescript": "^5.9.3"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@adonisjs/env": "^7.0.0",
|
|
66
66
|
"@antfu/install-pkg": "^1.1.0",
|
|
67
|
-
"@ast-grep/napi": "^0.
|
|
67
|
+
"@ast-grep/napi": "^0.42.0",
|
|
68
68
|
"@poppinss/cliui": "^6.7.0",
|
|
69
69
|
"@poppinss/hooks": "^7.3.0",
|
|
70
|
-
"@poppinss/utils": "^7.0.
|
|
70
|
+
"@poppinss/utils": "^7.0.1",
|
|
71
71
|
"chokidar": "^5.0.0",
|
|
72
|
-
"dedent": "^1.7.
|
|
72
|
+
"dedent": "^1.7.2",
|
|
73
73
|
"execa": "^9.6.1",
|
|
74
74
|
"fast-glob": "^3.3.3",
|
|
75
75
|
"fdir": "^6.5.0",
|
package/build/source-dVeugJ0e.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { f as throttle, l as removeExtension, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-bGeoWsK-.js";
|
|
2
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import string from "@poppinss/utils/string";
|
|
4
|
-
import { dirname, join, relative } from "node:path/posix";
|
|
5
|
-
import StringBuilder from "@poppinss/utils/string_builder";
|
|
6
|
-
var FileBuffer = class FileBuffer {
|
|
7
|
-
#eol = false;
|
|
8
|
-
#buffer = [];
|
|
9
|
-
#identationSize = 0;
|
|
10
|
-
#compiledOutput;
|
|
11
|
-
create() {
|
|
12
|
-
return new FileBuffer();
|
|
13
|
-
}
|
|
14
|
-
get size() {
|
|
15
|
-
return this.#buffer.length;
|
|
16
|
-
}
|
|
17
|
-
eol(enabled) {
|
|
18
|
-
this.#eol = enabled;
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
writeLine(text) {
|
|
22
|
-
if (typeof text === "string") this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}\n`);
|
|
23
|
-
else {
|
|
24
|
-
this.#buffer.push(text);
|
|
25
|
-
this.#buffer.push("");
|
|
26
|
-
}
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
write(text) {
|
|
30
|
-
if (typeof text === "string") this.#buffer.push(`${" ".repeat(this.#identationSize)}${text}`);
|
|
31
|
-
else this.#buffer.push(text);
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
indent() {
|
|
35
|
-
this.#identationSize += 2;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
dedent() {
|
|
39
|
-
this.#identationSize -= 2;
|
|
40
|
-
if (this.#identationSize < 0) this.#identationSize = 0;
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
toString() {
|
|
44
|
-
return this.flush();
|
|
45
|
-
}
|
|
46
|
-
flush() {
|
|
47
|
-
if (this.#compiledOutput !== void 0) return this.#compiledOutput;
|
|
48
|
-
this.#compiledOutput = this.#buffer.join("\n");
|
|
49
|
-
return this.#eol ? `${this.#compiledOutput}\n` : this.#compiledOutput;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var IndexGeneratorSource = class {
|
|
53
|
-
#appRoot;
|
|
54
|
-
#output;
|
|
55
|
-
#source;
|
|
56
|
-
#outputDirname;
|
|
57
|
-
#vfs;
|
|
58
|
-
#config;
|
|
59
|
-
#cliLogger;
|
|
60
|
-
#generateOutput = throttle(async () => {
|
|
61
|
-
const buffer = new FileBuffer().eol(true);
|
|
62
|
-
if (this.#config.comment) buffer.writeLine(this.#textToComment(typeof this.#config.comment === "string" ? this.#config.comment : `This file is automatically generated.\nDO NOT EDIT manually`));
|
|
63
|
-
if (this.#config.as === "barrelFile") this.#asBarrelFile(this.#vfs, buffer, this.#config.exportName, this.#config.disableLazyImports);
|
|
64
|
-
else this.#config.as(this.#vfs, buffer, this.#config, { toImportPath: this.#createBarrelFileImportGenerator(this.#source, this.#outputDirname, this.#config) });
|
|
65
|
-
await mkdir(dirname(this.#output), { recursive: true });
|
|
66
|
-
await writeFile(this.#output, buffer.flush());
|
|
67
|
-
});
|
|
68
|
-
name;
|
|
69
|
-
constructor(name, appRoot, cliLogger, config) {
|
|
70
|
-
this.name = name;
|
|
71
|
-
this.#config = config;
|
|
72
|
-
this.#appRoot = appRoot;
|
|
73
|
-
this.#cliLogger = cliLogger;
|
|
74
|
-
this.#source = join(this.#appRoot, this.#config.source);
|
|
75
|
-
this.#output = join(this.#appRoot, this.#config.output);
|
|
76
|
-
this.#outputDirname = dirname(this.#output);
|
|
77
|
-
this.#vfs = new VirtualFileSystem(this.#source, {
|
|
78
|
-
glob: this.#config.glob,
|
|
79
|
-
filter: this.#config.filter
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
#treeToString(input, buffer) {
|
|
83
|
-
Object.keys(input).forEach((key) => {
|
|
84
|
-
const value = input[key];
|
|
85
|
-
if (typeof value === "string") buffer.write(`${key}: ${value},`);
|
|
86
|
-
else {
|
|
87
|
-
buffer.write(`${key}: {`).indent();
|
|
88
|
-
this.#treeToString(value, buffer);
|
|
89
|
-
buffer.dedent().write(`},`);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
#textToComment(text) {
|
|
94
|
-
return `/**\n * ${text.split("\n").join("\n * ")}\n */`;
|
|
95
|
-
}
|
|
96
|
-
#createBarrelFileKeyGenerator(config) {
|
|
97
|
-
return function(key) {
|
|
98
|
-
let paths = key.split("/");
|
|
99
|
-
let baseName = new StringBuilder(paths.pop());
|
|
100
|
-
if (config.skipSegments?.length) paths = paths.filter((p) => !config.skipSegments.includes(p));
|
|
101
|
-
if (config.computeBaseName) baseName = config.computeBaseName(baseName);
|
|
102
|
-
else baseName = baseName.removeSuffix(config.removeSuffix ?? "").pascalCase();
|
|
103
|
-
return [...paths.map((p) => string.camelCase(p)), baseName.toString()].join("/");
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
#createBarrelFileImportGenerator(source, outputDirname, config) {
|
|
107
|
-
return function(filePath) {
|
|
108
|
-
if (config.importAlias) {
|
|
109
|
-
debug_default("converting \"%s\" to import alias, source \"%s\"", filePath, source);
|
|
110
|
-
return removeExtension(filePath.replace(source, config.importAlias));
|
|
111
|
-
}
|
|
112
|
-
debug_default("converting \"%s\" to relative import, source \"%s\"", filePath, outputDirname);
|
|
113
|
-
return relative(outputDirname, filePath);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
#asBarrelFile(vfs, buffer, exportName, disableLazyImports) {
|
|
117
|
-
const useEagerImports = disableLazyImports === true ? true : false;
|
|
118
|
-
const keyGenerator = this.#createBarrelFileKeyGenerator(this.#config);
|
|
119
|
-
const importsBuffer = buffer.create();
|
|
120
|
-
const importGenerator = this.#createBarrelFileImportGenerator(this.#source, this.#outputDirname, this.#config);
|
|
121
|
-
const tree = vfs.asTree({
|
|
122
|
-
transformKey: keyGenerator,
|
|
123
|
-
transformValue: (filePath, key) => {
|
|
124
|
-
if (useEagerImports) {
|
|
125
|
-
const importKey = new StringBuilder(key).pascalCase().toString();
|
|
126
|
-
importsBuffer.write(`import ${importKey} from '${importGenerator(filePath)}'`);
|
|
127
|
-
return importKey;
|
|
128
|
-
}
|
|
129
|
-
return `() => import('${importGenerator(filePath)}')`;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
if (!Object.keys(tree).length) {
|
|
133
|
-
buffer.write(`export const ${exportName} = {}`);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (useEagerImports) buffer.writeLine(importsBuffer);
|
|
137
|
-
buffer.write(`export const ${exportName} = {`).indent();
|
|
138
|
-
this.#treeToString(tree, buffer);
|
|
139
|
-
buffer.dedent().write(`}`);
|
|
140
|
-
}
|
|
141
|
-
#logCreation(startTime) {
|
|
142
|
-
this.#cliLogger.info(`created ${this.#config.output}`, { startTime });
|
|
143
|
-
}
|
|
144
|
-
async addFile(filePath) {
|
|
145
|
-
if (this.#vfs.add(filePath)) {
|
|
146
|
-
debug_default("file added, re-generating \"%s\" index", this.name);
|
|
147
|
-
const startTime = process.hrtime();
|
|
148
|
-
await this.#generateOutput();
|
|
149
|
-
this.#logCreation(startTime);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async removeFile(filePath) {
|
|
153
|
-
if (this.#vfs.remove(filePath)) {
|
|
154
|
-
debug_default("file removed, re-generating \"%s\" index", this.name);
|
|
155
|
-
const startTime = process.hrtime();
|
|
156
|
-
await this.#generateOutput();
|
|
157
|
-
this.#logCreation(startTime);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
async generate() {
|
|
161
|
-
debug_default("generating \"%s\" index", this.name);
|
|
162
|
-
await this.#vfs.scan();
|
|
163
|
-
await this.#generateOutput();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
export { FileBuffer as n, IndexGeneratorSource as t };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { i as isRelative, m as debug_default } from "./virtual_file_system-bGeoWsK-.js";
|
|
2
|
-
import { findImport, inspectClass, inspectClassMethods, inspectMethodArguments, nodeToPlainText, searchValidatorDirectUsage } from "./src/helpers.js";
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import string from "@poppinss/utils/string";
|
|
5
|
-
import { join, relative } from "node:path";
|
|
6
|
-
import { resolve } from "import-meta-resolve";
|
|
7
|
-
var PathsResolver = class {
|
|
8
|
-
#appRoot;
|
|
9
|
-
#resolvedPaths = {};
|
|
10
|
-
#resolver = (specifier, parentPath) => resolve(specifier, parentPath);
|
|
11
|
-
constructor(appRoot) {
|
|
12
|
-
this.#appRoot = pathToFileURL(join(appRoot, "index.js")).href;
|
|
13
|
-
}
|
|
14
|
-
use(resolver) {
|
|
15
|
-
this.#resolver = resolver;
|
|
16
|
-
}
|
|
17
|
-
resolve(specifier, rewriteAliasImportExtension = false) {
|
|
18
|
-
if (isRelative(specifier)) throw new Error("Cannot resolve relative paths using PathsResolver");
|
|
19
|
-
const cacheKey = specifier;
|
|
20
|
-
const cached = this.#resolvedPaths[cacheKey];
|
|
21
|
-
if (cached) return cached;
|
|
22
|
-
let resolvedPath = fileURLToPath(this.#resolver(specifier, this.#appRoot));
|
|
23
|
-
if (rewriteAliasImportExtension && specifier.startsWith("#") && resolvedPath.endsWith(".js")) resolvedPath = resolvedPath.replace(/\.js$/, ".ts");
|
|
24
|
-
this.#resolvedPaths[cacheKey] = resolvedPath;
|
|
25
|
-
return this.#resolvedPaths[cacheKey];
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
async function extractValidators(appRoot, vfs, controller) {
|
|
29
|
-
const root = await vfs.get(controller.path);
|
|
30
|
-
const fileContents = root.text();
|
|
31
|
-
const controllerClass = inspectClass(root);
|
|
32
|
-
if (!controllerClass) {
|
|
33
|
-
debug_default(`No class defined within the "%s"`, controller.import.specifier);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const method = inspectClassMethods(controllerClass).find((methodNode) => {
|
|
37
|
-
return methodNode.find({ rule: { kind: "property_identifier" } })?.text() === controller.method;
|
|
38
|
-
});
|
|
39
|
-
if (!method) {
|
|
40
|
-
debug_default(`Unable to find "%s" method in "%s"`, controller.method, controller.import.specifier);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const validationCalls = inspectMethodArguments(method, [
|
|
44
|
-
"request.validateUsing",
|
|
45
|
-
"$CTX.request.validateUsing",
|
|
46
|
-
"vine.validate"
|
|
47
|
-
]).map((node) => {
|
|
48
|
-
const firstArg = node.find({ rule: { any: [{ kind: "identifier" }, { kind: "member_expression" }] } });
|
|
49
|
-
if (!firstArg) return;
|
|
50
|
-
return nodeToPlainText(firstArg);
|
|
51
|
-
}).filter((node) => node !== void 0).concat(searchValidatorDirectUsage(method).map((node) => nodeToPlainText(node)));
|
|
52
|
-
if (!validationCalls.length) {
|
|
53
|
-
debug_default(`Unable to detect any validation calls in "%s.%s" method`, controller.import.specifier, controller.method);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const controllerName = controllerClass.find({ rule: { kind: "type_identifier" } }).text();
|
|
57
|
-
const controllerURL = pathToFileURL(controller.path);
|
|
58
|
-
return (await Promise.all(validationCalls.map(async (validationCall) => {
|
|
59
|
-
if (validationCall.split(".")[0] === controllerName) return {
|
|
60
|
-
name: validationCall,
|
|
61
|
-
import: {
|
|
62
|
-
specifier: controller.import.specifier,
|
|
63
|
-
type: "default",
|
|
64
|
-
value: controllerName
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const importCall = await findImport(fileContents, validationCall);
|
|
68
|
-
if (!importCall) {
|
|
69
|
-
debug_default("Unable to find import for \"%s\" used by \"%s.%s\" method", validationCall, controller.import.specifier, controller.method);
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
name: validationCall,
|
|
74
|
-
import: {
|
|
75
|
-
specifier: isRelative(importCall.specifier) ? string.toUnixSlash(relative(appRoot, fileURLToPath(new URL(importCall.specifier, controllerURL)))) : importCall.specifier,
|
|
76
|
-
type: importCall.clause.type,
|
|
77
|
-
value: importCall.clause.value
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}))).filter((value) => !!value);
|
|
81
|
-
}
|
|
82
|
-
export { PathsResolver as n, extractValidators as t };
|