@dotcom-tool-kit/node 4.0.1 → 4.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/lib/tasks/node.d.ts +2 -2
- package/lib/tasks/node.d.ts.map +1 -1
- package/lib/tasks/node.js +11 -4
- package/package.json +5 -5
- package/readme.md +7 -6
package/lib/tasks/node.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Task } from '@dotcom-tool-kit/base';
|
|
1
|
+
import { Task, TaskRunContext } from '@dotcom-tool-kit/base';
|
|
2
2
|
import { NodeSchema } from '@dotcom-tool-kit/schemas/lib/tasks/node';
|
|
3
3
|
export default class Node extends Task<{
|
|
4
4
|
task: typeof NodeSchema;
|
|
5
5
|
}> {
|
|
6
|
-
run(): Promise<void>;
|
|
6
|
+
run({ cwd, config }: TaskRunContext): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=node.d.ts.map
|
package/lib/tasks/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tasks/node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tasks/node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AAOpE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI,CAAC;IAAE,IAAI,EAAE,OAAO,UAAU,CAAA;CAAE,CAAC;IAC3D,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAuD1D"}
|
package/lib/tasks/node.js
CHANGED
|
@@ -8,14 +8,19 @@ const doppler_1 = require("@dotcom-tool-kit/doppler");
|
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const get_port_1 = tslib_1.__importDefault(require("get-port"));
|
|
10
10
|
const wait_port_1 = tslib_1.__importDefault(require("wait-port"));
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
12
|
class Node extends base_1.Task {
|
|
12
|
-
async run() {
|
|
13
|
+
async run({ cwd, config }) {
|
|
13
14
|
const { entry, args, useDoppler, ports } = this.options;
|
|
14
15
|
let dopplerEnv = {};
|
|
15
16
|
if (useDoppler) {
|
|
16
|
-
const doppler = new doppler_1.DopplerEnvVars(this.logger, 'dev');
|
|
17
|
+
const doppler = new doppler_1.DopplerEnvVars(this.logger, 'dev', config.pluginOptions['@dotcom-tool-kit/doppler']?.options);
|
|
17
18
|
dopplerEnv = await doppler.get();
|
|
18
19
|
}
|
|
20
|
+
const execArgv = [...process.execArgv];
|
|
21
|
+
if (this.options.watch) {
|
|
22
|
+
execArgv.push('--watch');
|
|
23
|
+
}
|
|
19
24
|
const port = ports
|
|
20
25
|
? Number(process.env.PORT) ||
|
|
21
26
|
(await (0, get_port_1.default)({
|
|
@@ -23,13 +28,15 @@ class Node extends base_1.Task {
|
|
|
23
28
|
}))
|
|
24
29
|
: false;
|
|
25
30
|
this.logger.verbose('starting the child node process...');
|
|
26
|
-
const child = (0, child_process_1.fork)(entry, args, {
|
|
31
|
+
const child = (0, child_process_1.fork)(path_1.default.resolve(cwd, entry), args, {
|
|
27
32
|
env: {
|
|
28
33
|
...dopplerEnv,
|
|
29
34
|
PORT: port.toString(),
|
|
30
35
|
...process.env
|
|
31
36
|
},
|
|
32
|
-
|
|
37
|
+
execArgv,
|
|
38
|
+
silent: true,
|
|
39
|
+
cwd
|
|
33
40
|
});
|
|
34
41
|
(0, logger_1.hookFork)(this.logger, entry, child);
|
|
35
42
|
if (port) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/node",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dotcom-tool-kit/base": "^1.
|
|
14
|
-
"@dotcom-tool-kit/error": "^4.0.
|
|
13
|
+
"@dotcom-tool-kit/base": "^1.1.0",
|
|
14
|
+
"@dotcom-tool-kit/error": "^4.0.1",
|
|
15
15
|
"@dotcom-tool-kit/state": "^4.0.0",
|
|
16
|
-
"@dotcom-tool-kit/doppler": "^2.0.
|
|
16
|
+
"@dotcom-tool-kit/doppler": "^2.0.3",
|
|
17
17
|
"get-port": "^5.1.1",
|
|
18
18
|
"tslib": "^2.3.1",
|
|
19
19
|
"wait-port": "^0.2.9"
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"npm": "7.x || 8.x || 9.x || 10.x"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@dotcom-tool-kit/schemas": "^1.
|
|
40
|
+
"@dotcom-tool-kit/schemas": "^1.2.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/readme.md
CHANGED
|
@@ -27,12 +27,13 @@ plugins:
|
|
|
27
27
|
Run a Node.js application for local development.
|
|
28
28
|
#### Task options
|
|
29
29
|
|
|
30
|
-
| Property | Description
|
|
31
|
-
| :----------- |
|
|
32
|
-
| `entry` | path to the node application
|
|
33
|
-
| `args` | additional arguments to pass to your application
|
|
34
|
-
| `useDoppler` | whether to run the application with environment variables from Doppler
|
|
35
|
-
| `ports` | ports to try to bind to for this application. set to `false` for an entry point that wouldn't bind to a port, such as a worker process or one-off script.
|
|
30
|
+
| Property | Description | Type | Default |
|
|
31
|
+
| :----------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------- | :------------------ |
|
|
32
|
+
| `entry` | path to the node application | `string` | `'./server/app.js'` |
|
|
33
|
+
| `args` | additional arguments to pass to your application | `Array<string>` | |
|
|
34
|
+
| `useDoppler` | whether to run the application with environment variables from Doppler | `boolean` | `true` |
|
|
35
|
+
| `ports` | ports to try to bind to for this application. set to `false` for an entry point that wouldn't bind to a port, such as a worker process or one-off script. | `Array<number> \| false` | `[3001,3002,3003]` |
|
|
36
|
+
| `watch` | run Node in watch mode, which restarts your application when the entrypoint or any imported files are changed. **nb** this option is experimental in versions of Node before v20.13. | `boolean` | |
|
|
36
37
|
|
|
37
38
|
_All properties are optional._
|
|
38
39
|
<!-- end autogenerated docs -->
|