@adonisjs/assembler 8.0.0-next.3 → 8.0.0-next.30
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/README.md +87 -59
- package/build/codemod_exception-vyN1VXuX.js +137 -0
- package/build/helpers-DDurYRsZ.js +72 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +925 -1319
- package/build/main-BeV45LeF.js +246 -0
- package/build/main-CknPN3rJ.js +188 -0
- package/build/src/bundler.d.ts +44 -3
- package/build/src/code_scanners/routes_scanner/main.d.ts +63 -11
- package/build/src/code_scanners/routes_scanner/main.js +4 -0
- package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +12 -4
- package/build/src/code_transformer/main.d.ts +53 -43
- package/build/src/code_transformer/main.js +354 -599
- package/build/src/code_transformer/rc_file_transformer.d.ts +83 -5
- package/build/src/debug.d.ts +13 -1
- package/build/src/dev_server.d.ts +92 -17
- package/build/src/exceptions/codemod_exception.d.ts +178 -0
- package/build/src/file_buffer.d.ts +87 -0
- package/build/src/file_system.d.ts +46 -8
- package/build/src/helpers.d.ts +79 -4
- package/build/src/helpers.js +2 -0
- package/build/src/index_generator/main.d.ts +68 -0
- package/build/src/index_generator/main.js +3 -0
- package/build/src/index_generator/source.d.ts +60 -0
- package/build/src/paths_resolver.d.ts +29 -3
- package/build/src/shortcuts_manager.d.ts +42 -4
- package/build/src/test_runner.d.ts +57 -12
- package/build/src/types/code_scanners.d.ts +160 -30
- package/build/src/types/code_transformer.d.ts +69 -19
- package/build/src/types/common.d.ts +233 -55
- package/build/src/types/hooks.d.ts +238 -22
- package/build/src/types/main.d.ts +15 -1
- package/build/src/types/main.js +1 -0
- package/build/src/utils.d.ts +96 -15
- package/build/src/virtual_file_system.d.ts +112 -0
- package/build/virtual_file_system-bGeoWsK-.js +285 -0
- package/package.json +46 -36
- package/build/chunk-RR4HCA4M.js +0 -7
- package/build/src/ast_file_system.d.ts +0 -17
|
@@ -1,44 +1,81 @@
|
|
|
1
|
-
import { type OneOrMore } from '@poppinss/utils/types';
|
|
2
1
|
import { installPackage, detectPackageManager } from '@antfu/install-pkg';
|
|
3
2
|
import { Project } from 'ts-morph';
|
|
4
3
|
import { RcFileTransformer } from './rc_file_transformer.ts';
|
|
5
4
|
import type { MiddlewareNode, EnvValidationNode, BouncerPolicyNode } from '../types/code_transformer.ts';
|
|
6
5
|
/**
|
|
7
|
-
* This class is responsible for
|
|
6
|
+
* This class is responsible for transforming AdonisJS project code,
|
|
7
|
+
* including updating middleware, environment validations, and other
|
|
8
|
+
* code generation tasks.
|
|
9
|
+
*
|
|
10
|
+
* The CodeTransformer provides methods for modifying various AdonisJS
|
|
11
|
+
* configuration files and code structures using AST manipulation through
|
|
12
|
+
* ts-morph. It can update middleware stacks, add environment validations,
|
|
13
|
+
* register plugins, and modify RC file configurations.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const transformer = new CodeTransformer(cwd)
|
|
17
|
+
* await transformer.addMiddlewareToStack('server', [{
|
|
18
|
+
* path: '#middleware/cors_middleware',
|
|
19
|
+
* position: 'before'
|
|
20
|
+
* }])
|
|
8
21
|
*/
|
|
9
22
|
export declare class CodeTransformer {
|
|
10
23
|
#private;
|
|
11
24
|
/**
|
|
12
|
-
*
|
|
13
|
-
* the package manager
|
|
25
|
+
* Utility function for installing packages
|
|
14
26
|
*/
|
|
15
27
|
installPackage: typeof installPackage;
|
|
28
|
+
/**
|
|
29
|
+
* Utility function for detecting the package manager
|
|
30
|
+
*/
|
|
16
31
|
detectPackageManager: typeof detectPackageManager;
|
|
17
32
|
/**
|
|
18
|
-
* The TsMorph project
|
|
33
|
+
* The TsMorph project instance for AST manipulation
|
|
19
34
|
*/
|
|
20
35
|
project: Project;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new CodeTransformer instance
|
|
38
|
+
*
|
|
39
|
+
* @param cwd - The current working directory URL
|
|
40
|
+
*/
|
|
21
41
|
constructor(cwd: URL);
|
|
22
42
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
43
|
+
* Get directories configured in adonisrc.ts, with defaults fallback.
|
|
44
|
+
*
|
|
45
|
+
* This method reads the adonisrc.ts file and extracts the directories
|
|
46
|
+
* configuration. If a directory is not configured, the default value is used.
|
|
47
|
+
*
|
|
48
|
+
* @returns Object containing directory paths
|
|
49
|
+
*/
|
|
50
|
+
getDirectories(): Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Add new env variable validation in the `env.ts` file
|
|
53
|
+
*
|
|
54
|
+
* @param definition - Environment validation definition containing variables and comment
|
|
25
55
|
*/
|
|
26
56
|
defineEnvValidations(definition: EnvValidationNode): Promise<void>;
|
|
27
57
|
/**
|
|
28
|
-
* Define new middlewares inside the `start/kernel.ts`
|
|
29
|
-
* file
|
|
58
|
+
* Define new middlewares inside the `start/kernel.ts` file
|
|
30
59
|
*
|
|
31
60
|
* This function is highly based on some assumptions
|
|
32
61
|
* and will not work if you significantly tweaked
|
|
33
62
|
* your `start/kernel.ts` file.
|
|
63
|
+
*
|
|
64
|
+
* @param stack - The middleware stack to add to ('server', 'router', or 'named')
|
|
65
|
+
* @param middleware - Array of middleware entries to add
|
|
34
66
|
*/
|
|
35
67
|
addMiddlewareToStack(stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]): Promise<void>;
|
|
36
68
|
/**
|
|
37
|
-
* Update the `adonisrc.ts` file
|
|
69
|
+
* Update the `adonisrc.ts` file using the provided callback
|
|
70
|
+
*
|
|
71
|
+
* @param callback - Function that receives the RcFileTransformer for modifications
|
|
38
72
|
*/
|
|
39
73
|
updateRcFile(callback: (transformer: RcFileTransformer) => void): Promise<void>;
|
|
40
74
|
/**
|
|
41
75
|
* Add a new Japa plugin in the `tests/bootstrap.ts` file
|
|
76
|
+
*
|
|
77
|
+
* @param pluginCall - The plugin function call to add
|
|
78
|
+
* @param importDeclarations - Import declarations needed for the plugin
|
|
42
79
|
*/
|
|
43
80
|
addJapaPlugin(pluginCall: string, importDeclarations: {
|
|
44
81
|
isNamed: boolean;
|
|
@@ -46,7 +83,10 @@ export declare class CodeTransformer {
|
|
|
46
83
|
identifier: string;
|
|
47
84
|
}[]): Promise<void>;
|
|
48
85
|
/**
|
|
49
|
-
* Add a new Vite plugin
|
|
86
|
+
* Add a new Vite plugin to the `vite.config.ts` file
|
|
87
|
+
*
|
|
88
|
+
* @param pluginCall - The plugin function call to add
|
|
89
|
+
* @param importDeclarations - Import declarations needed for the plugin
|
|
50
90
|
*/
|
|
51
91
|
addVitePlugin(pluginCall: string, importDeclarations: {
|
|
52
92
|
isNamed: boolean;
|
|
@@ -56,38 +96,8 @@ export declare class CodeTransformer {
|
|
|
56
96
|
/**
|
|
57
97
|
* Adds a policy to the list of `policies` object configured
|
|
58
98
|
* inside the `app/policies/main.ts` file.
|
|
59
|
-
*/
|
|
60
|
-
addPolicies(policies: BouncerPolicyNode[]): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Creates an index file that exports an object in which the key is the PascalCase
|
|
63
|
-
* name of the entity and the value is a dynamic import.
|
|
64
|
-
*
|
|
65
|
-
* For example, in case of controllers, the index file will be the list of controller
|
|
66
|
-
* names pointing a dynamically imported controller file.
|
|
67
99
|
*
|
|
68
|
-
*
|
|
69
|
-
* export const controllers = {
|
|
70
|
-
* LoginController: () => import('#controllers/login_controller'),
|
|
71
|
-
* LogoutController: () => import('#controllers/logout_controller'),
|
|
72
|
-
* }
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @param source
|
|
76
|
-
* @param outputPath
|
|
77
|
-
* @param importAlias
|
|
100
|
+
* @param policies - Array of bouncer policy entries to add
|
|
78
101
|
*/
|
|
79
|
-
|
|
80
|
-
source: string;
|
|
81
|
-
importAlias?: string;
|
|
82
|
-
allowedExtensions?: string[];
|
|
83
|
-
}>, output: {
|
|
84
|
-
destination: string;
|
|
85
|
-
exportName?: string;
|
|
86
|
-
removeNameSuffix?: string;
|
|
87
|
-
computeBaseName?: (filePath: string, sourcePath: string) => string;
|
|
88
|
-
computeOutput?: (entries: {
|
|
89
|
-
name: string;
|
|
90
|
-
importPath: string;
|
|
91
|
-
}[]) => string;
|
|
92
|
-
}): Promise<void>;
|
|
102
|
+
addPolicies(policies: BouncerPolicyNode[]): Promise<void>;
|
|
93
103
|
}
|