@adonisjs/assembler 6.1.0-0 → 6.1.2-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/src/dev_server.js +25 -3
- package/build/src/run.d.ts +2 -1
- package/build/src/run.js +14 -2
- package/build/src/types.d.ts +9 -0
- package/package.json +7 -6
package/build/src/dev_server.js
CHANGED
|
@@ -2,8 +2,8 @@ import getPort from 'get-port';
|
|
|
2
2
|
import picomatch from 'picomatch';
|
|
3
3
|
import { cliui } from '@poppinss/cliui';
|
|
4
4
|
import { EnvLoader, EnvParser } from '@adonisjs/env';
|
|
5
|
-
import { run } from './run.js';
|
|
6
5
|
import { watch } from './watch.js';
|
|
6
|
+
import { run, runNode } from './run.js';
|
|
7
7
|
const ui = cliui();
|
|
8
8
|
export class DevServer {
|
|
9
9
|
#cwd;
|
|
@@ -15,6 +15,7 @@ export class DevServer {
|
|
|
15
15
|
#isMetaFileWithReloadsEnabled;
|
|
16
16
|
#isMetaFileWithReloadsDisabled;
|
|
17
17
|
#watcher;
|
|
18
|
+
#assetsServerProcess;
|
|
18
19
|
#onError;
|
|
19
20
|
#onClose;
|
|
20
21
|
get #colors() {
|
|
@@ -65,7 +66,7 @@ export class DevServer {
|
|
|
65
66
|
return getPort({ port: 3333 });
|
|
66
67
|
}
|
|
67
68
|
#startHTTPServer(port, mode) {
|
|
68
|
-
this.#httpServerProcess =
|
|
69
|
+
this.#httpServerProcess = runNode(this.#cwd, {
|
|
69
70
|
script: this.#scriptFile,
|
|
70
71
|
env: { PORT: port, ...this.#options.env },
|
|
71
72
|
nodeArgs: this.#options.nodeArgs,
|
|
@@ -96,6 +97,25 @@ export class DevServer {
|
|
|
96
97
|
this.#watcher?.close();
|
|
97
98
|
});
|
|
98
99
|
}
|
|
100
|
+
#startAssetsServer() {
|
|
101
|
+
const assetsBundler = this.#options.assets;
|
|
102
|
+
if (!assetsBundler?.serve) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.#logger.info(`starting "${assetsBundler.driver}" dev server...`);
|
|
106
|
+
this.#assetsServerProcess = run(assetsBundler.cmd, {
|
|
107
|
+
script: this.#scriptFile,
|
|
108
|
+
scriptArgs: this.#options.scriptArgs,
|
|
109
|
+
});
|
|
110
|
+
this.#assetsServerProcess
|
|
111
|
+
.then((result) => {
|
|
112
|
+
this.#logger.warning(`"${assetsBundler.driver}" dev server closed with status code "${result.exitCode}"`);
|
|
113
|
+
})
|
|
114
|
+
.catch((error) => {
|
|
115
|
+
this.#logger.warning(`unable to connect to "${assetsBundler.driver}" dev server`);
|
|
116
|
+
this.#logger.fatal(error);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
99
119
|
#restart(port) {
|
|
100
120
|
if (this.#httpServerProcess) {
|
|
101
121
|
this.#httpServerProcess.removeAllListeners();
|
|
@@ -119,13 +139,15 @@ export class DevServer {
|
|
|
119
139
|
this.#clearScreen();
|
|
120
140
|
this.#logger.info('starting HTTP server...');
|
|
121
141
|
this.#startHTTPServer(String(await this.#getPort()), 'nonblocking');
|
|
142
|
+
this.#startAssetsServer();
|
|
122
143
|
}
|
|
123
144
|
async startAndWatch(ts, options) {
|
|
145
|
+
const port = String(await this.#getPort());
|
|
124
146
|
this.#isWatching = true;
|
|
125
147
|
this.#clearScreen();
|
|
126
|
-
const port = String(await this.#getPort());
|
|
127
148
|
this.#logger.info('starting HTTP server...');
|
|
128
149
|
this.#startHTTPServer(port, 'blocking');
|
|
150
|
+
this.#startAssetsServer();
|
|
129
151
|
const output = watch(this.#cwd, ts, options || {});
|
|
130
152
|
if (!output) {
|
|
131
153
|
this.#onClose?.(1);
|
package/build/src/run.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { RunOptions } from './types.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function runNode(cwd: string | URL, options: RunOptions): import("execa").ExecaChildProcess<string>;
|
|
4
|
+
export declare function run(cwd: string | URL, options: Omit<RunOptions, 'nodeArgs'>): import("execa").ExecaChildProcess<string>;
|
package/build/src/run.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { execaNode } from 'execa';
|
|
1
|
+
import { execaNode, execa } from 'execa';
|
|
2
2
|
const DEFAULT_NODE_ARGS = [
|
|
3
3
|
'--loader=ts-node/esm',
|
|
4
4
|
'--no-warnings',
|
|
5
5
|
'--experimental-import-meta-resolve',
|
|
6
6
|
];
|
|
7
|
-
export function
|
|
7
|
+
export function runNode(cwd, options) {
|
|
8
8
|
const childProces = execaNode(options.script, options.scriptArgs, {
|
|
9
9
|
nodeOptions: DEFAULT_NODE_ARGS.concat(options.nodeArgs),
|
|
10
10
|
preferLocal: true,
|
|
@@ -17,3 +17,15 @@ export function run(cwd, options) {
|
|
|
17
17
|
});
|
|
18
18
|
return childProces;
|
|
19
19
|
}
|
|
20
|
+
export function run(cwd, options) {
|
|
21
|
+
const childProces = execa(options.script, options.scriptArgs, {
|
|
22
|
+
preferLocal: true,
|
|
23
|
+
windowsHide: false,
|
|
24
|
+
localDir: cwd,
|
|
25
|
+
cwd,
|
|
26
|
+
buffer: false,
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
env: options.env,
|
|
29
|
+
});
|
|
30
|
+
return childProces;
|
|
31
|
+
}
|
package/build/src/types.d.ts
CHANGED
|
@@ -17,6 +17,15 @@ export type DevServerOptions = {
|
|
|
17
17
|
pattern: string;
|
|
18
18
|
reloadServer: boolean;
|
|
19
19
|
}[];
|
|
20
|
+
assets?: {
|
|
21
|
+
serve: false;
|
|
22
|
+
driver?: string;
|
|
23
|
+
cmd?: string;
|
|
24
|
+
} | {
|
|
25
|
+
serve: true;
|
|
26
|
+
driver: string;
|
|
27
|
+
cmd: string;
|
|
28
|
+
};
|
|
20
29
|
};
|
|
21
30
|
export type BundlerOptions = {
|
|
22
31
|
metaFiles?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/assembler",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2-0",
|
|
4
4
|
"description": "Provides utilities to run AdonisJS development server and build project for production",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -42,12 +42,9 @@
|
|
|
42
42
|
"@japa/run-failed-tests": "^1.1.1",
|
|
43
43
|
"@japa/runner": "^2.5.1",
|
|
44
44
|
"@japa/spec-reporter": "^1.3.3",
|
|
45
|
-
"@poppinss/cliui": "^6.1.1-0",
|
|
46
|
-
"@poppinss/dev-utils": "^2.0.3",
|
|
47
45
|
"@swc/core": "^1.3.36",
|
|
48
|
-
"@types/node": "^18.14.
|
|
46
|
+
"@types/node": "^18.14.3",
|
|
49
47
|
"c8": "^7.13.0",
|
|
50
|
-
"copyfiles": "^2.4.1",
|
|
51
48
|
"cross-env": "^7.0.3",
|
|
52
49
|
"del-cli": "^5.0.0",
|
|
53
50
|
"eslint": "^8.34.0",
|
|
@@ -64,7 +61,8 @@
|
|
|
64
61
|
},
|
|
65
62
|
"dependencies": {
|
|
66
63
|
"@adonisjs/env": "^4.2.0-0",
|
|
67
|
-
"@poppinss/chokidar-ts": "^4.
|
|
64
|
+
"@poppinss/chokidar-ts": "^4.1.0-0",
|
|
65
|
+
"@poppinss/cliui": "^6.1.1-0",
|
|
68
66
|
"@types/fs-extra": "^11.0.1",
|
|
69
67
|
"@types/picomatch": "^2.3.0",
|
|
70
68
|
"cpy": "^9.0.1",
|
|
@@ -74,6 +72,9 @@
|
|
|
74
72
|
"picomatch": "^2.3.1",
|
|
75
73
|
"slash": "^5.0.0"
|
|
76
74
|
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"typescript": "^4.0.0 || ^5.0.0"
|
|
77
|
+
},
|
|
77
78
|
"repository": {
|
|
78
79
|
"type": "git",
|
|
79
80
|
"url": "git+ssh://git@github.com/adonisjs/assembler.git"
|