@dotcom-tool-kit/node 3.4.1 → 4.0.0-beta.1
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/.toolkitrc.yml +6 -1
- package/lib/tasks/node.d.ts +5 -4
- package/lib/tasks/node.d.ts.map +1 -1
- package/lib/tasks/node.js +26 -29
- package/package.json +10 -7
- package/readme.md +14 -11
- package/lib/index.d.ts +0 -3
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -6
package/.toolkitrc.yml
CHANGED
package/lib/tasks/node.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Task } from '@dotcom-tool-kit/
|
|
2
|
-
import { NodeSchema } from '@dotcom-tool-kit/
|
|
3
|
-
export default class Node extends Task<
|
|
4
|
-
|
|
1
|
+
import { Task } from '@dotcom-tool-kit/base';
|
|
2
|
+
import { NodeSchema } from '@dotcom-tool-kit/schemas/lib/tasks/node';
|
|
3
|
+
export default class Node extends Task<{
|
|
4
|
+
task: typeof NodeSchema;
|
|
5
|
+
}> {
|
|
5
6
|
run(): Promise<void>;
|
|
6
7
|
}
|
|
7
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":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tasks/node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AAMpE,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI,CAAC;IAAE,IAAI,EAAE,OAAO,UAAU,CAAA;CAAE,CAAC;IAC3D,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2C3B"}
|
package/lib/tasks/node.js
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const error_1 = require("@dotcom-tool-kit/error");
|
|
5
4
|
const logger_1 = require("@dotcom-tool-kit/logger");
|
|
6
5
|
const state_1 = require("@dotcom-tool-kit/state");
|
|
7
|
-
const
|
|
6
|
+
const base_1 = require("@dotcom-tool-kit/base");
|
|
8
7
|
const doppler_1 = require("@dotcom-tool-kit/doppler");
|
|
9
8
|
const child_process_1 = require("child_process");
|
|
10
9
|
const get_port_1 = tslib_1.__importDefault(require("get-port"));
|
|
11
10
|
const wait_port_1 = tslib_1.__importDefault(require("wait-port"));
|
|
12
|
-
class Node extends
|
|
11
|
+
class Node extends base_1.Task {
|
|
13
12
|
async run() {
|
|
14
|
-
const { entry, args,
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const port = Number(process.env.PORT) ||
|
|
21
|
-
(await (0, get_port_1.default)({
|
|
22
|
-
port: ports
|
|
23
|
-
}));
|
|
24
|
-
if (!entry) {
|
|
25
|
-
const error = new error_1.ToolKitError(`the ${logger_1.styles.task('Node')} task requires an ${logger_1.styles.option('entry')} option`);
|
|
26
|
-
error.details = `this is the entrypoint for your app, e.g. ${logger_1.styles.filepath('server/app.js')}`;
|
|
27
|
-
throw error;
|
|
13
|
+
const { entry, args, useDoppler, ports } = this.options;
|
|
14
|
+
let dopplerEnv = {};
|
|
15
|
+
if (useDoppler) {
|
|
16
|
+
const doppler = new doppler_1.DopplerEnvVars(this.logger, 'dev');
|
|
17
|
+
dopplerEnv = await doppler.get();
|
|
28
18
|
}
|
|
19
|
+
const port = ports
|
|
20
|
+
? Number(process.env.PORT) ||
|
|
21
|
+
(await (0, get_port_1.default)({
|
|
22
|
+
port: ports
|
|
23
|
+
}))
|
|
24
|
+
: false;
|
|
29
25
|
this.logger.verbose('starting the child node process...');
|
|
30
26
|
const child = (0, child_process_1.fork)(entry, args, {
|
|
31
27
|
env: {
|
|
32
|
-
...
|
|
28
|
+
...dopplerEnv,
|
|
33
29
|
PORT: port.toString(),
|
|
34
30
|
...process.env
|
|
35
31
|
},
|
|
36
32
|
silent: true
|
|
37
33
|
});
|
|
38
34
|
(0, logger_1.hookFork)(this.logger, entry, child);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
if (port) {
|
|
36
|
+
const unhook = (0, logger_1.hookConsole)(this.logger, 'wait-port');
|
|
37
|
+
try {
|
|
38
|
+
await (0, wait_port_1.default)({
|
|
39
|
+
host: 'localhost',
|
|
40
|
+
port
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
unhook();
|
|
45
|
+
}
|
|
46
|
+
(0, state_1.writeState)('local', { port });
|
|
48
47
|
}
|
|
49
|
-
(0, state_1.writeState)('local', { port });
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
exports.default = Node;
|
|
53
|
-
Node.description = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
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/
|
|
14
|
-
"@dotcom-tool-kit/
|
|
15
|
-
"@dotcom-tool-kit/
|
|
16
|
-
"@dotcom-tool-kit/doppler": "
|
|
13
|
+
"@dotcom-tool-kit/base": "4.0.0-beta.0",
|
|
14
|
+
"@dotcom-tool-kit/error": "4.0.0-beta.0",
|
|
15
|
+
"@dotcom-tool-kit/state": "4.0.0-beta.0",
|
|
16
|
+
"@dotcom-tool-kit/doppler": "2.0.0-beta.0",
|
|
17
17
|
"get-port": "^5.1.1",
|
|
18
18
|
"tslib": "^2.3.1",
|
|
19
19
|
"wait-port": "^0.2.9"
|
|
@@ -30,10 +30,13 @@
|
|
|
30
30
|
".toolkitrc.yml"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"dotcom-tool-kit": "
|
|
33
|
+
"dotcom-tool-kit": "4.0.0-beta.1"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": "
|
|
36
|
+
"node": "18.x || 20.x",
|
|
37
37
|
"npm": "7.x || 8.x || 9.x || 10.x"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@dotcom-tool-kit/schemas": "2.0.0-beta.0"
|
|
38
41
|
}
|
|
39
42
|
}
|
package/readme.md
CHANGED
|
@@ -19,17 +19,20 @@ plugins:
|
|
|
19
19
|
- '@dotcom-tool-kit/node'
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
<!-- begin autogenerated docs -->
|
|
23
|
+
## Tasks
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|-|-|-|
|
|
26
|
-
| `entry` | path to the node application | `'./server/app.js'` |
|
|
27
|
-
| `args` | additional arguments to pass to your application | `[]` |
|
|
28
|
-
| `useVault` | option to run the application with environment variables from Vault | `true` |
|
|
29
|
-
| `ports` | ports to try to bind to for this application | `[3001, 3002, 3003]` |
|
|
25
|
+
### `Node`
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
Run a Node.js application for local development.
|
|
28
|
+
#### Task options
|
|
29
|
+
|
|
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]` |
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
| `Node` | Run node application | `run:local` |
|
|
37
|
+
_All properties are optional._
|
|
38
|
+
<!-- end autogenerated docs -->
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,cAAc,CAAA;AAE/B,eAAO,MAAM,KAAK,iBAAS,CAAA"}
|
package/lib/index.js
DELETED