@adonisjs/assembler 8.0.0-next.23 → 8.0.0-next.25
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/index.js +7 -7
- package/build/{main-1eXSE5Xo.js → main-XUXlmlEy.js} +5 -2
- package/build/{main-Byxt3AdL.js → main-nSQGnZZV.js} +8 -10
- package/build/src/code_scanners/routes_scanner/main.js +2 -2
- package/build/src/index_generator/main.js +2 -2
- package/build/src/types/code_scanners.d.ts +5 -5
- package/build/src/types/common.d.ts +3 -2
- package/build/src/types/hooks.d.ts +4 -1
- package/build/src/utils.d.ts +3 -1
- package/build/{virtual_file_system-DM1KRNbk.js → virtual_file_system-bGeoWsK-.js} +3 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as loadHooks, c as readTsConfig, d as runNode, f as throttle, m as debug_default, n as copyFiles, o as memoize, p as watch, r as getPort, s as parseConfig, t as VirtualFileSystem, u as run } from "./virtual_file_system-
|
|
2
|
-
import { n as FileBuffer, t as IndexGenerator } from "./main-
|
|
3
|
-
import { t as RoutesScanner } from "./main-
|
|
1
|
+
import { a as loadHooks, c as readTsConfig, d as runNode, f as throttle, m as debug_default, n as copyFiles, o as memoize, p as watch, r as getPort, s as parseConfig, t as VirtualFileSystem, u as run } from "./virtual_file_system-bGeoWsK-.js";
|
|
2
|
+
import { n as FileBuffer, t as IndexGenerator } from "./main-XUXlmlEy.js";
|
|
3
|
+
import { t as RoutesScanner } from "./main-nSQGnZZV.js";
|
|
4
4
|
import "./helpers-DDurYRsZ.js";
|
|
5
5
|
import dedent from "dedent";
|
|
6
6
|
import fs, { readFile, unlink } from "node:fs/promises";
|
|
@@ -108,7 +108,7 @@ var Bundler = class {
|
|
|
108
108
|
"buildFinished"
|
|
109
109
|
]);
|
|
110
110
|
this.#indexGenerator = new IndexGenerator(this.cwdPath, this.ui.logger);
|
|
111
|
-
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
111
|
+
await this.#hooks.runner("init").run(this, this.#hooks, this.#indexGenerator);
|
|
112
112
|
this.#hooks.clear("init");
|
|
113
113
|
this.ui.logger.info("generating indexes...");
|
|
114
114
|
await this.#indexGenerator.generate();
|
|
@@ -568,7 +568,7 @@ var DevServer = class DevServer {
|
|
|
568
568
|
]);
|
|
569
569
|
this.#registerServerRestartHooks();
|
|
570
570
|
this.#setupKeyboardShortcuts();
|
|
571
|
-
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
571
|
+
await this.#hooks.runner("init").run(this, this.#hooks, this.#indexGenerator);
|
|
572
572
|
this.#hooks.clear("init");
|
|
573
573
|
this.ui.logger.info("generating indexes...");
|
|
574
574
|
await this.#indexGenerator.generate();
|
|
@@ -855,7 +855,7 @@ var TestRunner = class {
|
|
|
855
855
|
"testsStarting",
|
|
856
856
|
"testsFinished"
|
|
857
857
|
]);
|
|
858
|
-
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
858
|
+
await this.#hooks.runner("init").run(this, this.#hooks, this.#indexGenerator);
|
|
859
859
|
this.#hooks.clear("init");
|
|
860
860
|
this.ui.logger.info("generating indexes...");
|
|
861
861
|
await this.#indexGenerator.generate();
|
|
@@ -888,7 +888,7 @@ var TestRunner = class {
|
|
|
888
888
|
"fileRemoved"
|
|
889
889
|
]);
|
|
890
890
|
this.#registerServerRestartHooks();
|
|
891
|
-
await this.#hooks.runner("init").run(this, this.#indexGenerator);
|
|
891
|
+
await this.#hooks.runner("init").run(this, this.#hooks, this.#indexGenerator);
|
|
892
892
|
this.#hooks.clear("init");
|
|
893
893
|
this.ui.logger.info("generating indexes...");
|
|
894
894
|
await this.#indexGenerator.generate();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as throttle, l as removeExtension, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-
|
|
1
|
+
import { f as throttle, l as removeExtension, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-bGeoWsK-.js";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import string from "@poppinss/utils/string";
|
|
4
4
|
import { dirname, join, relative } from "node:path/posix";
|
|
@@ -73,7 +73,10 @@ var IndexGeneratorSource = class {
|
|
|
73
73
|
this.#source = join(this.#appRoot, this.#config.source);
|
|
74
74
|
this.#output = join(this.#appRoot, this.#config.output);
|
|
75
75
|
this.#outputDirname = dirname(this.#output);
|
|
76
|
-
this.#vfs = new VirtualFileSystem(this.#source, {
|
|
76
|
+
this.#vfs = new VirtualFileSystem(this.#source, {
|
|
77
|
+
glob: this.#config.glob,
|
|
78
|
+
filter: this.#config.filter
|
|
79
|
+
});
|
|
77
80
|
}
|
|
78
81
|
#treeToString(input, buffer) {
|
|
79
82
|
Object.keys(input).forEach((key) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as isRelative, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-
|
|
1
|
+
import { i as isRelative, m as debug_default, t as VirtualFileSystem } from "./virtual_file_system-bGeoWsK-.js";
|
|
2
2
|
import { a as nodeToPlainText, i as inspectMethodArguments, n as inspectClass, o as searchValidatorDirectUsage, r as inspectClassMethods, t as findImport } from "./helpers-DDurYRsZ.js";
|
|
3
3
|
import { cliui } from "@poppinss/cliui";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -79,6 +79,7 @@ async function extractValidators(appRoot, vfs, controller) {
|
|
|
79
79
|
}))).filter((value) => !!value);
|
|
80
80
|
}
|
|
81
81
|
var RoutesScanner = class {
|
|
82
|
+
#filter = () => false;
|
|
82
83
|
#appRoot;
|
|
83
84
|
#controllerRoutes = {};
|
|
84
85
|
#scannedRoutes = [];
|
|
@@ -88,7 +89,6 @@ var RoutesScanner = class {
|
|
|
88
89
|
ui = cliui();
|
|
89
90
|
pathsResolver;
|
|
90
91
|
rules = {
|
|
91
|
-
skip: [],
|
|
92
92
|
request: {},
|
|
93
93
|
response: {}
|
|
94
94
|
};
|
|
@@ -96,11 +96,9 @@ var RoutesScanner = class {
|
|
|
96
96
|
this.#appRoot = appRoot;
|
|
97
97
|
this.pathsResolver = new PathsResolver(appRoot);
|
|
98
98
|
rulesCollection.forEach((rules) => {
|
|
99
|
-
this.rules.skip = this.rules.skip.concat(rules.skip);
|
|
100
99
|
Object.assign(this.rules.request, rules.request);
|
|
101
100
|
Object.assign(this.rules.response, rules.response);
|
|
102
101
|
});
|
|
103
|
-
this.rules.skip = Array.from(new Set([...this.rules.skip]));
|
|
104
102
|
}
|
|
105
103
|
#prepareRequestTypes(route) {
|
|
106
104
|
if (!route.validators) return;
|
|
@@ -166,16 +164,16 @@ var RoutesScanner = class {
|
|
|
166
164
|
const controller = await this.#inspectControllerSpecifier(route.handler.importExpression, route.handler.method);
|
|
167
165
|
if (!controller) return this.#processRouteWithoutController(route);
|
|
168
166
|
debug_default("processing route \"%s\" with inspected controller %O", route.name, controller);
|
|
169
|
-
|
|
170
|
-
if (this
|
|
167
|
+
route.name = route.name ?? new StringBuilder(controller.name).removeSuffix("Controller").snakeCase().suffix(`.${string.snakeCase(controller.method)}`).toString();
|
|
168
|
+
if (this.#filter(route)) return;
|
|
171
169
|
const scannedRoute = {
|
|
172
|
-
name:
|
|
170
|
+
name: route.name,
|
|
173
171
|
domain: route.domain,
|
|
174
172
|
methods: route.methods,
|
|
175
173
|
pattern: route.pattern,
|
|
176
174
|
tokens: route.tokens,
|
|
177
|
-
request: this.rules.request[
|
|
178
|
-
response: this.rules.response[
|
|
175
|
+
request: this.rules.request[route.name],
|
|
176
|
+
response: this.rules.response[route.name],
|
|
179
177
|
controller
|
|
180
178
|
};
|
|
181
179
|
debug_default("scanned route %O", scannedRoute);
|
|
@@ -189,7 +187,7 @@ var RoutesScanner = class {
|
|
|
189
187
|
}
|
|
190
188
|
}
|
|
191
189
|
async #processRoute(route, vfs) {
|
|
192
|
-
if (route.name && this
|
|
190
|
+
if (route.name && this.#filter(route)) {
|
|
193
191
|
debug_default("route skipped route: %O, rules: %O", route, this.rules);
|
|
194
192
|
return;
|
|
195
193
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../../virtual_file_system-
|
|
2
|
-
import { t as RoutesScanner } from "../../../main-
|
|
1
|
+
import "../../../virtual_file_system-bGeoWsK-.js";
|
|
2
|
+
import { t as RoutesScanner } from "../../../main-nSQGnZZV.js";
|
|
3
3
|
import "../../../helpers-DDurYRsZ.js";
|
|
4
4
|
export { RoutesScanner };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../../virtual_file_system-
|
|
2
|
-
import { t as IndexGenerator } from "../../main-
|
|
1
|
+
import "../../virtual_file_system-bGeoWsK-.js";
|
|
2
|
+
import { t as IndexGenerator } from "../../main-XUXlmlEy.js";
|
|
3
3
|
export { IndexGenerator };
|
|
@@ -186,6 +186,11 @@ export type RoutesListItem = {
|
|
|
186
186
|
end: string;
|
|
187
187
|
}[];
|
|
188
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* The filter fn to exclude routes from being processed. Return true
|
|
191
|
+
* to filter out (aka exclude) the route
|
|
192
|
+
*/
|
|
193
|
+
export type RoutesScannerFilterFn = (route: RoutesListItem) => boolean;
|
|
189
194
|
/**
|
|
190
195
|
* Configuration rules accepted by the routes scanner to customize
|
|
191
196
|
* the scanning behavior and override type inference.
|
|
@@ -208,11 +213,6 @@ export type RoutesListItem = {
|
|
|
208
213
|
* }
|
|
209
214
|
*/
|
|
210
215
|
export type RoutesScannerRules = {
|
|
211
|
-
/**
|
|
212
|
-
* An array of route names or controller+method paths to skip from processing.
|
|
213
|
-
* Useful for excluding routes that don't need type generation.
|
|
214
|
-
*/
|
|
215
|
-
skip: string[];
|
|
216
216
|
/**
|
|
217
217
|
* Define custom response types for specific routes by their name
|
|
218
218
|
* or controller+method path. Overrides automatic type inference.
|
|
@@ -4,6 +4,7 @@ import type StringBuilder from '@poppinss/utils/string_builder';
|
|
|
4
4
|
import { type AllHooks } from './hooks.ts';
|
|
5
5
|
import { type FileBuffer } from '../file_buffer.ts';
|
|
6
6
|
import { type VirtualFileSystem } from '../virtual_file_system.ts';
|
|
7
|
+
import { type FilterPredicate } from 'fdir';
|
|
7
8
|
/**
|
|
8
9
|
* Recursive file tree structure for representing nested directory hierarchies
|
|
9
10
|
*/
|
|
@@ -15,6 +16,7 @@ export type RecursiveFileTree = {
|
|
|
15
16
|
*/
|
|
16
17
|
export type VirtualFileSystemOptions = {
|
|
17
18
|
glob?: string[];
|
|
19
|
+
filter?: FilterPredicate;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* Source configuration accepted by the index generator
|
|
@@ -35,11 +37,10 @@ export type IndexGeneratorSourceConfig = ({
|
|
|
35
37
|
computeBaseName?: (baseName: StringBuilder) => StringBuilder;
|
|
36
38
|
source: string;
|
|
37
39
|
output: string;
|
|
38
|
-
glob?: string[];
|
|
39
40
|
importAlias?: string;
|
|
40
41
|
removeSuffix?: string;
|
|
41
42
|
skipSegments?: string[];
|
|
42
|
-
};
|
|
43
|
+
} & VirtualFileSystemOptions;
|
|
43
44
|
/**
|
|
44
45
|
* Marks a given optional property as required
|
|
45
46
|
*
|
|
@@ -6,6 +6,7 @@ import { type TestRunner } from '../test_runner.ts';
|
|
|
6
6
|
import { type RoutesListItem } from './code_scanners.ts';
|
|
7
7
|
import { type IndexGenerator } from '../index_generator/main.ts';
|
|
8
8
|
import { type RoutesScanner } from '../code_scanners/routes_scanner/main.ts';
|
|
9
|
+
import type Hooks from '@poppinss/hooks';
|
|
9
10
|
/**
|
|
10
11
|
* Defines a hook that can be either a lazy import or an object with a run method.
|
|
11
12
|
* This type provides flexibility in how hooks are defined and imported, supporting
|
|
@@ -45,7 +46,9 @@ export type CommonHooks = {
|
|
|
45
46
|
*
|
|
46
47
|
* @param parent - The parent instance (DevServer, TestRunner, or Bundler)
|
|
47
48
|
*/
|
|
48
|
-
init: DefineHook<(parent: DevServer | TestRunner | Bundler,
|
|
49
|
+
init: DefineHook<(parent: DevServer | TestRunner | Bundler, hooks: Hooks<{
|
|
50
|
+
[P in keyof AllHooks]: [HookParams<P>, HookParams<P>];
|
|
51
|
+
}>, indexGenerator: IndexGenerator) => AsyncOrSync<void>>[];
|
|
49
52
|
};
|
|
50
53
|
/**
|
|
51
54
|
* Hooks executed by the dev server around the router.
|
package/build/src/utils.d.ts
CHANGED
|
@@ -148,7 +148,9 @@ export declare function isRelative(pathValue: string): boolean;
|
|
|
148
148
|
* @param names - Array of hook names to load
|
|
149
149
|
* @returns Promise resolving to configured Hooks instance
|
|
150
150
|
*/
|
|
151
|
-
export declare function loadHooks<K extends keyof AllHooks>(rcFileHooks: Partial<AllHooks> | undefined, names: K[]): Promise<Hooks<{
|
|
151
|
+
export declare function loadHooks<K extends keyof AllHooks>(rcFileHooks: Partial<AllHooks> | undefined, names: K[]): Promise<Hooks<{
|
|
152
|
+
[P in K]: [HookParams<P>, HookParams<P>];
|
|
153
|
+
}>>;
|
|
152
154
|
/**
|
|
153
155
|
* Wraps a function inside another function that throttles the concurrent
|
|
154
156
|
* executions of a function. If the function is called too quickly, then
|
|
@@ -211,7 +211,9 @@ var VirtualFileSystem = class {
|
|
|
211
211
|
}
|
|
212
212
|
async scan() {
|
|
213
213
|
debug_default("fetching entities from source \"%s\"", this.#source);
|
|
214
|
-
const
|
|
214
|
+
const crawler = new fdir().globWithOptions(this.#options.glob ?? DEFAULT_GLOB, this.#picoMatchOptions).withFullPaths();
|
|
215
|
+
if (this.#options.filter) crawler.filter(this.#options.filter);
|
|
216
|
+
const filesList = await crawler.crawl(this.#source).withPromise();
|
|
215
217
|
debug_default("scanned files %O", filesList);
|
|
216
218
|
const sortedFiles = filesList.sort(naturalSort);
|
|
217
219
|
this.#files.clear();
|
package/package.json
CHANGED