@adonisjs/assembler 6.1.3-23 → 6.1.3-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.d.ts +109 -3
- package/build/index.js +920 -11
- package/build/src/code_transformer/main.d.ts +48 -4
- package/build/src/code_transformer/main.js +394 -210
- package/build/src/types.d.ts +12 -11
- package/build/src/types.js +0 -9
- package/package.json +29 -16
- package/build/src/assets_dev_server.d.ts +0 -32
- package/build/src/assets_dev_server.js +0 -158
- package/build/src/bundler.d.ts +0 -19
- package/build/src/bundler.js +0 -205
- package/build/src/code_transformer/rc_file_transformer.d.ts +0 -43
- package/build/src/code_transformer/rc_file_transformer.js +0 -272
- package/build/src/debug.d.ts +0 -3
- package/build/src/debug.js +0 -10
- package/build/src/dev_server.d.ts +0 -47
- package/build/src/dev_server.js +0 -253
- package/build/src/helpers.d.ts +0 -50
- package/build/src/helpers.js +0 -183
- package/build/src/test_runner.d.ts +0 -47
- package/build/src/test_runner.js +0 -310
package/build/src/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
/**
|
|
3
2
|
* Options needed to run a script file
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
type RunOptions = {
|
|
6
5
|
script: string;
|
|
7
6
|
scriptArgs: string[];
|
|
8
7
|
nodeArgs: string[];
|
|
@@ -12,27 +11,27 @@ export type RunOptions = {
|
|
|
12
11
|
/**
|
|
13
12
|
* Watcher options
|
|
14
13
|
*/
|
|
15
|
-
|
|
14
|
+
type WatchOptions = {
|
|
16
15
|
poll?: boolean;
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
19
18
|
* Meta file config defined in ".adonisrc.json" file
|
|
20
19
|
*/
|
|
21
|
-
|
|
20
|
+
type MetaFile = {
|
|
22
21
|
pattern: string;
|
|
23
22
|
reloadServer: boolean;
|
|
24
23
|
};
|
|
25
24
|
/**
|
|
26
25
|
* Test suite defined in ".adonisrc.json" file
|
|
27
26
|
*/
|
|
28
|
-
|
|
27
|
+
type Suite = {
|
|
29
28
|
files: string | string[];
|
|
30
29
|
name: string;
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
33
32
|
* Options accepted by assets bundler
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
type AssetsBundlerOptions = {
|
|
36
35
|
serve: false;
|
|
37
36
|
args?: string[];
|
|
38
37
|
driver?: string;
|
|
@@ -46,7 +45,7 @@ export type AssetsBundlerOptions = {
|
|
|
46
45
|
/**
|
|
47
46
|
* Options accepted by the dev server
|
|
48
47
|
*/
|
|
49
|
-
|
|
48
|
+
type DevServerOptions = {
|
|
50
49
|
scriptArgs: string[];
|
|
51
50
|
nodeArgs: string[];
|
|
52
51
|
clearScreen?: boolean;
|
|
@@ -57,7 +56,7 @@ export type DevServerOptions = {
|
|
|
57
56
|
/**
|
|
58
57
|
* Options accepted by the test runner
|
|
59
58
|
*/
|
|
60
|
-
|
|
59
|
+
type TestRunnerOptions = {
|
|
61
60
|
/**
|
|
62
61
|
* Filter arguments are provided as a key-value
|
|
63
62
|
* pair, so that we can mutate them (if needed)
|
|
@@ -88,7 +87,7 @@ export type TestRunnerOptions = {
|
|
|
88
87
|
/**
|
|
89
88
|
* Options accepted by the project bundler
|
|
90
89
|
*/
|
|
91
|
-
|
|
90
|
+
type BundlerOptions = {
|
|
92
91
|
metaFiles?: MetaFile[];
|
|
93
92
|
assets?: AssetsBundlerOptions;
|
|
94
93
|
};
|
|
@@ -96,7 +95,7 @@ export type BundlerOptions = {
|
|
|
96
95
|
* Entry to add a middleware to a given middleware stack
|
|
97
96
|
* via the CodeTransformer
|
|
98
97
|
*/
|
|
99
|
-
|
|
98
|
+
type AddMiddlewareEntry = {
|
|
100
99
|
/**
|
|
101
100
|
* If you are adding a named middleware, then you must
|
|
102
101
|
* define the name.
|
|
@@ -123,7 +122,7 @@ export type AddMiddlewareEntry = {
|
|
|
123
122
|
* Defines the structure of an environment variable validation
|
|
124
123
|
* definition
|
|
125
124
|
*/
|
|
126
|
-
|
|
125
|
+
type EnvValidationDefinition = {
|
|
127
126
|
/**
|
|
128
127
|
* Write a leading comment on top of your variables
|
|
129
128
|
*/
|
|
@@ -136,3 +135,5 @@ export type EnvValidationDefinition = {
|
|
|
136
135
|
*/
|
|
137
136
|
variables: Record<string, string>;
|
|
138
137
|
};
|
|
138
|
+
|
|
139
|
+
export { AddMiddlewareEntry, AssetsBundlerOptions, BundlerOptions, DevServerOptions, EnvValidationDefinition, MetaFile, RunOptions, Suite, TestRunnerOptions, WatchOptions };
|
package/build/src/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
3
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
4
|
-
"version": "6.1.3-
|
|
4
|
+
"version": "6.1.3-25",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
8
8
|
"main": "build/index.js",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"files": [
|
|
11
|
-
"build
|
|
12
|
-
"build/index.d.ts",
|
|
13
|
-
"build/index.js"
|
|
11
|
+
"build"
|
|
14
12
|
],
|
|
15
13
|
"exports": {
|
|
16
14
|
".": "./build/index.js",
|
|
@@ -23,7 +21,7 @@
|
|
|
23
21
|
"lint": "eslint . --ext=.ts",
|
|
24
22
|
"clean": "del-cli build",
|
|
25
23
|
"typecheck": "tsc --noEmit",
|
|
26
|
-
"compile": "npm run lint && npm run clean &&
|
|
24
|
+
"compile": "npm run lint && npm run clean && tsup-node",
|
|
27
25
|
"build": "npm run compile",
|
|
28
26
|
"release": "np",
|
|
29
27
|
"version": "npm run build",
|
|
@@ -33,19 +31,20 @@
|
|
|
33
31
|
"quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
36
|
-
"@adonisjs/application": "^
|
|
34
|
+
"@adonisjs/application": "^8.0.0-0",
|
|
37
35
|
"@adonisjs/eslint-config": "^1.1.8",
|
|
38
36
|
"@adonisjs/prettier-config": "^1.1.8",
|
|
39
37
|
"@adonisjs/tsconfig": "^1.1.8",
|
|
40
38
|
"@commitlint/cli": "^17.6.7",
|
|
41
39
|
"@commitlint/config-conventional": "^17.6.7",
|
|
42
|
-
"@japa/assert": "^2.0.0
|
|
43
|
-
"@japa/file-system": "^2.0.0
|
|
44
|
-
"@japa/runner": "^3.0.
|
|
45
|
-
"@japa/snapshot": "2.0.0
|
|
46
|
-
"@swc/core": "
|
|
40
|
+
"@japa/assert": "^2.0.0",
|
|
41
|
+
"@japa/file-system": "^2.0.0",
|
|
42
|
+
"@japa/runner": "^3.0.2",
|
|
43
|
+
"@japa/snapshot": "^2.0.0",
|
|
44
|
+
"@swc/core": "1.3.82",
|
|
47
45
|
"@types/node": "^20.4.5",
|
|
48
46
|
"@types/picomatch": "^2.3.0",
|
|
47
|
+
"@types/pretty-hrtime": "^1.0.1",
|
|
49
48
|
"c8": "^8.0.1",
|
|
50
49
|
"cross-env": "^7.0.3",
|
|
51
50
|
"dedent": "^1.5.1",
|
|
@@ -57,20 +56,22 @@
|
|
|
57
56
|
"p-event": "^6.0.0",
|
|
58
57
|
"prettier": "^3.0.0",
|
|
59
58
|
"ts-node": "^10.9.1",
|
|
59
|
+
"tsup": "^7.2.0",
|
|
60
60
|
"typescript": "^5.1.6"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@adonisjs/env": "^4.2.0-
|
|
64
|
-
"@poppinss/chokidar-ts": "^4.1.0
|
|
65
|
-
"@poppinss/cliui": "^6.
|
|
63
|
+
"@adonisjs/env": "^4.2.0-6",
|
|
64
|
+
"@poppinss/chokidar-ts": "^4.1.0",
|
|
65
|
+
"@poppinss/cliui": "^6.2.0",
|
|
66
66
|
"cpy": "^10.1.0",
|
|
67
|
-
"execa": "^
|
|
67
|
+
"execa": "^8.0.1",
|
|
68
68
|
"fast-glob": "^3.3.1",
|
|
69
69
|
"get-port": "^7.0.0",
|
|
70
70
|
"junk": "^4.0.1",
|
|
71
71
|
"picomatch": "^2.3.1",
|
|
72
|
+
"pretty-hrtime": "^1.0.3",
|
|
72
73
|
"slash": "^5.1.0",
|
|
73
|
-
"ts-morph": "^
|
|
74
|
+
"ts-morph": "^20.0.0"
|
|
74
75
|
},
|
|
75
76
|
"peerDependencies": {
|
|
76
77
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
@@ -122,5 +123,17 @@
|
|
|
122
123
|
"src/test_runner.ts",
|
|
123
124
|
"src/assets_dev_server.ts"
|
|
124
125
|
]
|
|
126
|
+
},
|
|
127
|
+
"tsup": {
|
|
128
|
+
"entry": [
|
|
129
|
+
"./index.ts",
|
|
130
|
+
"./src/code_transformer/main.ts",
|
|
131
|
+
"./src/types.ts"
|
|
132
|
+
],
|
|
133
|
+
"outDir": "./build",
|
|
134
|
+
"clean": true,
|
|
135
|
+
"format": "esm",
|
|
136
|
+
"dts": true,
|
|
137
|
+
"target": "esnext"
|
|
125
138
|
}
|
|
126
139
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { type Logger } from '@poppinss/cliui';
|
|
3
|
-
import type { AssetsBundlerOptions } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Exposes the API to start the development server for processing assets during
|
|
6
|
-
* development.
|
|
7
|
-
*
|
|
8
|
-
* - Here we are running the assets dev server in a child process.
|
|
9
|
-
* - Piping the output from the child process and reformatting it before writing it to
|
|
10
|
-
* process streams.
|
|
11
|
-
*
|
|
12
|
-
* AssetsDevServer is agnostic and can run any assets dev server. Be it Vite or Encore or
|
|
13
|
-
* even Webpack directly.
|
|
14
|
-
*/
|
|
15
|
-
export declare class AssetsDevServer {
|
|
16
|
-
#private;
|
|
17
|
-
constructor(cwd: URL, options?: AssetsBundlerOptions);
|
|
18
|
-
/**
|
|
19
|
-
* Set a custom CLI UI logger
|
|
20
|
-
*/
|
|
21
|
-
setLogger(logger: Logger): this;
|
|
22
|
-
/**
|
|
23
|
-
* Starts the assets bundler server. The assets bundler server process is
|
|
24
|
-
* considered as the secondary process and therefore we do not perform
|
|
25
|
-
* any cleanup if it dies.
|
|
26
|
-
*/
|
|
27
|
-
start(): void;
|
|
28
|
-
/**
|
|
29
|
-
* Stop the dev server
|
|
30
|
-
*/
|
|
31
|
-
stop(): void;
|
|
32
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import { cliui } from '@poppinss/cliui';
|
|
10
|
-
import { run } from './helpers.js';
|
|
11
|
-
/**
|
|
12
|
-
* Instance of CLIUI
|
|
13
|
-
*/
|
|
14
|
-
const ui = cliui();
|
|
15
|
-
/**
|
|
16
|
-
* Exposes the API to start the development server for processing assets during
|
|
17
|
-
* development.
|
|
18
|
-
*
|
|
19
|
-
* - Here we are running the assets dev server in a child process.
|
|
20
|
-
* - Piping the output from the child process and reformatting it before writing it to
|
|
21
|
-
* process streams.
|
|
22
|
-
*
|
|
23
|
-
* AssetsDevServer is agnostic and can run any assets dev server. Be it Vite or Encore or
|
|
24
|
-
* even Webpack directly.
|
|
25
|
-
*/
|
|
26
|
-
export class AssetsDevServer {
|
|
27
|
-
#cwd;
|
|
28
|
-
#logger = ui.logger;
|
|
29
|
-
#options;
|
|
30
|
-
#devServer;
|
|
31
|
-
/**
|
|
32
|
-
* Getting reference to colors library from logger
|
|
33
|
-
*/
|
|
34
|
-
get #colors() {
|
|
35
|
-
return this.#logger.getColors();
|
|
36
|
-
}
|
|
37
|
-
constructor(cwd, options) {
|
|
38
|
-
this.#cwd = cwd;
|
|
39
|
-
this.#options = options;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Logs messages from vite dev server stdout and stderr
|
|
43
|
-
*/
|
|
44
|
-
#logViteDevServerMessage(data) {
|
|
45
|
-
const dataString = data.toString();
|
|
46
|
-
const lines = dataString.split('\n');
|
|
47
|
-
/**
|
|
48
|
-
* Logging VITE ready in message with proper
|
|
49
|
-
* spaces and newlines
|
|
50
|
-
*/
|
|
51
|
-
if (dataString.includes('ready in')) {
|
|
52
|
-
console.log('');
|
|
53
|
-
console.log(dataString.trim());
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Put a wrapper around vite network address log
|
|
58
|
-
*/
|
|
59
|
-
if (dataString.includes('Local') && dataString.includes('Network')) {
|
|
60
|
-
const sticker = ui.sticker().useColors(this.#colors).useRenderer(this.#logger.getRenderer());
|
|
61
|
-
lines.forEach((line) => {
|
|
62
|
-
if (line.trim()) {
|
|
63
|
-
sticker.add(line);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
sticker.render();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Log rest of the lines
|
|
71
|
-
*/
|
|
72
|
-
lines.forEach((line) => {
|
|
73
|
-
if (line.trim()) {
|
|
74
|
-
console.log(line);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Logs messages from assets dev server stdout and stderr
|
|
80
|
-
*/
|
|
81
|
-
#logAssetsDevServerMessage(data) {
|
|
82
|
-
const dataString = data.toString();
|
|
83
|
-
const lines = dataString.split('\n');
|
|
84
|
-
lines.forEach((line) => {
|
|
85
|
-
if (line.trim()) {
|
|
86
|
-
console.log(line);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Set a custom CLI UI logger
|
|
92
|
-
*/
|
|
93
|
-
setLogger(logger) {
|
|
94
|
-
this.#logger = logger;
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Starts the assets bundler server. The assets bundler server process is
|
|
99
|
-
* considered as the secondary process and therefore we do not perform
|
|
100
|
-
* any cleanup if it dies.
|
|
101
|
-
*/
|
|
102
|
-
start() {
|
|
103
|
-
if (!this.#options?.serve) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.#logger.info(`starting "${this.#options.driver}" dev server...`);
|
|
107
|
-
/**
|
|
108
|
-
* Create child process
|
|
109
|
-
*/
|
|
110
|
-
this.#devServer = run(this.#cwd, {
|
|
111
|
-
script: this.#options.cmd,
|
|
112
|
-
/**
|
|
113
|
-
* We do not inherit the stdio for vite and encore, because in
|
|
114
|
-
* inherit mode they own the stdin and interrupts the
|
|
115
|
-
* `Ctrl + C` command.
|
|
116
|
-
*/
|
|
117
|
-
stdio: 'pipe',
|
|
118
|
-
scriptArgs: this.#options.args,
|
|
119
|
-
});
|
|
120
|
-
/**
|
|
121
|
-
* Log child process messages
|
|
122
|
-
*/
|
|
123
|
-
this.#devServer.stdout?.on('data', (data) => {
|
|
124
|
-
if (this.#options.driver === 'vite') {
|
|
125
|
-
this.#logViteDevServerMessage(data);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
this.#logAssetsDevServerMessage(data);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
this.#devServer.stderr?.on('data', (data) => {
|
|
132
|
-
if (this.#options.driver === 'vite') {
|
|
133
|
-
this.#logViteDevServerMessage(data);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
this.#logAssetsDevServerMessage(data);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
this.#devServer
|
|
140
|
-
.then((result) => {
|
|
141
|
-
this.#logger.warning(`"${this.#options.driver}" dev server closed with status code "${result.exitCode}"`);
|
|
142
|
-
})
|
|
143
|
-
.catch((error) => {
|
|
144
|
-
this.#logger.warning(`unable to connect to "${this.#options.driver}" dev server`);
|
|
145
|
-
this.#logger.fatal(error);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Stop the dev server
|
|
150
|
-
*/
|
|
151
|
-
stop() {
|
|
152
|
-
if (this.#devServer) {
|
|
153
|
-
this.#devServer.removeAllListeners();
|
|
154
|
-
this.#devServer.kill('SIGKILL');
|
|
155
|
-
this.#devServer = undefined;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
package/build/src/bundler.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type tsStatic from 'typescript';
|
|
3
|
-
import { type Logger } from '@poppinss/cliui';
|
|
4
|
-
import type { BundlerOptions } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* The bundler class exposes the API to build an AdonisJS project.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Bundler {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(cwd: URL, ts: typeof tsStatic, options: BundlerOptions);
|
|
11
|
-
/**
|
|
12
|
-
* Set a custom CLI UI logger
|
|
13
|
-
*/
|
|
14
|
-
setLogger(logger: Logger): this;
|
|
15
|
-
/**
|
|
16
|
-
* Bundles the application to be run in production
|
|
17
|
-
*/
|
|
18
|
-
bundle(stopOnError?: boolean, client?: 'npm' | 'yarn' | 'pnpm'): Promise<boolean>;
|
|
19
|
-
}
|
package/build/src/bundler.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/assembler
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import slash from 'slash';
|
|
10
|
-
import fs from 'node:fs/promises';
|
|
11
|
-
import { relative } from 'node:path';
|
|
12
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
-
import { cliui } from '@poppinss/cliui';
|
|
14
|
-
import { run, parseConfig, copyFiles } from './helpers.js';
|
|
15
|
-
/**
|
|
16
|
-
* Instance of CLIUI
|
|
17
|
-
*/
|
|
18
|
-
const ui = cliui();
|
|
19
|
-
/**
|
|
20
|
-
* The bundler class exposes the API to build an AdonisJS project.
|
|
21
|
-
*/
|
|
22
|
-
export class Bundler {
|
|
23
|
-
#cwd;
|
|
24
|
-
#cwdPath;
|
|
25
|
-
#ts;
|
|
26
|
-
#logger = ui.logger;
|
|
27
|
-
#options;
|
|
28
|
-
/**
|
|
29
|
-
* Getting reference to colors library from logger
|
|
30
|
-
*/
|
|
31
|
-
get #colors() {
|
|
32
|
-
return this.#logger.getColors();
|
|
33
|
-
}
|
|
34
|
-
constructor(cwd, ts, options) {
|
|
35
|
-
this.#cwd = cwd;
|
|
36
|
-
this.#cwdPath = fileURLToPath(this.#cwd);
|
|
37
|
-
this.#ts = ts;
|
|
38
|
-
this.#options = options;
|
|
39
|
-
}
|
|
40
|
-
#getRelativeName(filePath) {
|
|
41
|
-
return slash(relative(this.#cwdPath, filePath));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Cleans up the build directory
|
|
45
|
-
*/
|
|
46
|
-
async #cleanupBuildDirectory(outDir) {
|
|
47
|
-
await fs.rm(outDir, { recursive: true, force: true, maxRetries: 5 });
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Runs assets bundler command to build assets.
|
|
51
|
-
*/
|
|
52
|
-
async #buildAssets() {
|
|
53
|
-
const assetsBundler = this.#options.assets;
|
|
54
|
-
if (!assetsBundler?.serve) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
this.#logger.info('compiling frontend assets', { suffix: assetsBundler.cmd });
|
|
59
|
-
await run(this.#cwd, {
|
|
60
|
-
stdio: 'inherit',
|
|
61
|
-
script: assetsBundler.cmd,
|
|
62
|
-
scriptArgs: assetsBundler.args,
|
|
63
|
-
});
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Runs tsc command to build the source.
|
|
72
|
-
*/
|
|
73
|
-
async #runTsc(outDir) {
|
|
74
|
-
try {
|
|
75
|
-
await run(this.#cwd, {
|
|
76
|
-
stdio: 'inherit',
|
|
77
|
-
script: 'tsc',
|
|
78
|
-
scriptArgs: ['--outDir', outDir],
|
|
79
|
-
});
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Copy files to destination directory
|
|
88
|
-
*/
|
|
89
|
-
async #copyFiles(files, outDir) {
|
|
90
|
-
try {
|
|
91
|
-
await copyFiles(files, this.#cwdPath, outDir);
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
if (!error.message.includes("the file doesn't exist")) {
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Copy meta files to the output directory
|
|
101
|
-
*/
|
|
102
|
-
async #copyMetaFiles(outDir, additionalFilesToCopy) {
|
|
103
|
-
const metaFiles = (this.#options.metaFiles || [])
|
|
104
|
-
.map((file) => file.pattern)
|
|
105
|
-
.concat(additionalFilesToCopy);
|
|
106
|
-
await this.#copyFiles(metaFiles, outDir);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Returns the lock file name for a given packages client
|
|
110
|
-
*/
|
|
111
|
-
#getClientLockFile(client) {
|
|
112
|
-
switch (client) {
|
|
113
|
-
case 'npm':
|
|
114
|
-
return 'package-lock.json';
|
|
115
|
-
case 'yarn':
|
|
116
|
-
return 'yarn.lock';
|
|
117
|
-
case 'pnpm':
|
|
118
|
-
return 'pnpm-lock.yaml';
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns the installation command for a given packages client
|
|
123
|
-
*/
|
|
124
|
-
#getClientInstallCommand(client) {
|
|
125
|
-
switch (client) {
|
|
126
|
-
case 'npm':
|
|
127
|
-
return 'npm ci --omit="dev"';
|
|
128
|
-
case 'yarn':
|
|
129
|
-
return 'yarn install --production';
|
|
130
|
-
case 'pnpm':
|
|
131
|
-
return 'pnpm i --prod';
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Set a custom CLI UI logger
|
|
136
|
-
*/
|
|
137
|
-
setLogger(logger) {
|
|
138
|
-
this.#logger = logger;
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Bundles the application to be run in production
|
|
143
|
-
*/
|
|
144
|
-
async bundle(stopOnError = true, client = 'npm') {
|
|
145
|
-
/**
|
|
146
|
-
* Step 1: Parse config file to get the build output directory
|
|
147
|
-
*/
|
|
148
|
-
const config = parseConfig(this.#cwd, this.#ts);
|
|
149
|
-
if (!config) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Step 2: Cleanup existing build directory (if any)
|
|
154
|
-
*/
|
|
155
|
-
const outDir = config.options.outDir || fileURLToPath(new URL('build/', this.#cwd));
|
|
156
|
-
this.#logger.info('cleaning up output directory', { suffix: this.#getRelativeName(outDir) });
|
|
157
|
-
await this.#cleanupBuildDirectory(outDir);
|
|
158
|
-
/**
|
|
159
|
-
* Step 3: Build frontend assets
|
|
160
|
-
*/
|
|
161
|
-
if (!(await this.#buildAssets())) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Step 4: Build typescript source code
|
|
166
|
-
*/
|
|
167
|
-
this.#logger.info('compiling typescript source', { suffix: 'tsc' });
|
|
168
|
-
const buildCompleted = await this.#runTsc(outDir);
|
|
169
|
-
await this.#copyFiles(['ace.js'], outDir);
|
|
170
|
-
/**
|
|
171
|
-
* Remove incomplete build directory when tsc build
|
|
172
|
-
* failed and stopOnError is set to true.
|
|
173
|
-
*/
|
|
174
|
-
if (!buildCompleted && stopOnError) {
|
|
175
|
-
await this.#cleanupBuildDirectory(outDir);
|
|
176
|
-
const instructions = ui
|
|
177
|
-
.sticker()
|
|
178
|
-
.fullScreen()
|
|
179
|
-
.drawBorder((borderChar, colors) => colors.red(borderChar));
|
|
180
|
-
instructions.add(this.#colors.red('Cannot complete the build process as there are TypeScript errors.'));
|
|
181
|
-
instructions.add(this.#colors.red('Use "--ignore-ts-errors" flag to ignore TypeScript errors and continue the build.'));
|
|
182
|
-
this.#logger.logError(instructions.prepare());
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Step 5: Copy meta files to the build directory
|
|
187
|
-
*/
|
|
188
|
-
const pkgFiles = ['package.json', this.#getClientLockFile(client)];
|
|
189
|
-
this.#logger.info('copying meta files to the output directory');
|
|
190
|
-
await this.#copyMetaFiles(outDir, pkgFiles);
|
|
191
|
-
this.#logger.success('build completed');
|
|
192
|
-
this.#logger.log('');
|
|
193
|
-
/**
|
|
194
|
-
* Next steps
|
|
195
|
-
*/
|
|
196
|
-
ui.instructions()
|
|
197
|
-
.useRenderer(this.#logger.getRenderer())
|
|
198
|
-
.heading('Run the following commands to start the server in production')
|
|
199
|
-
.add(this.#colors.cyan(`cd ${this.#getRelativeName(outDir)}`))
|
|
200
|
-
.add(this.#colors.cyan(this.#getClientInstallCommand(client)))
|
|
201
|
-
.add(this.#colors.cyan('node bin/server.js'))
|
|
202
|
-
.render();
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { Project } from 'ts-morph';
|
|
3
|
-
import type { AppEnvironments } from '@adonisjs/application/types';
|
|
4
|
-
/**
|
|
5
|
-
* RcFileTransformer is used to transform the `adonisrc.ts` file
|
|
6
|
-
* for adding new commands, providers, meta files etc
|
|
7
|
-
*/
|
|
8
|
-
export declare class RcFileTransformer {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(cwd: URL, project: Project);
|
|
11
|
-
/**
|
|
12
|
-
* Add a new command to the rcFile
|
|
13
|
-
*/
|
|
14
|
-
addCommand(commandPath: string): this;
|
|
15
|
-
/**
|
|
16
|
-
* Add a new preloaded file to the rcFile
|
|
17
|
-
*/
|
|
18
|
-
addPreloadFile(modulePath: string, environments?: AppEnvironments[]): this;
|
|
19
|
-
/**
|
|
20
|
-
* Add a new provider to the rcFile
|
|
21
|
-
*/
|
|
22
|
-
addProvider(providerPath: string, environments?: AppEnvironments[]): this;
|
|
23
|
-
/**
|
|
24
|
-
* Add a new meta file to the rcFile
|
|
25
|
-
*/
|
|
26
|
-
addMetaFile(globPattern: string, reloadServer?: boolean): this;
|
|
27
|
-
/**
|
|
28
|
-
* Set directory name and path
|
|
29
|
-
*/
|
|
30
|
-
setDirectory(key: string, value: string): this;
|
|
31
|
-
/**
|
|
32
|
-
* Set command alias
|
|
33
|
-
*/
|
|
34
|
-
setCommandAlias(alias: string, command: string): this;
|
|
35
|
-
/**
|
|
36
|
-
* Add a new test suite to the rcFile
|
|
37
|
-
*/
|
|
38
|
-
addSuite(suiteName: string, files: string | string[], timeout?: number): this;
|
|
39
|
-
/**
|
|
40
|
-
* Save the adonisrc.ts file
|
|
41
|
-
*/
|
|
42
|
-
save(): Promise<void>;
|
|
43
|
-
}
|