@nitwel/sandbox 1.0.4 → 1.0.6

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/dist/cli.js CHANGED
@@ -16,8 +16,7 @@ program
16
16
  .option('--docker.suffix <suffix>', 'Adds a suffix to the docker project. Can be used to ensure uniqueness')
17
17
  .option('-e, --extras <extras>', 'Enable redis,maildev,saml or other extras')
18
18
  .option('--silent', 'Silence all logs except for errors')
19
- .option('-i, --instances <instances>', 'Horizontally scale directus to a given number of instances', '1')
20
- .option('--killPorts', 'Forcefully kills all processes that occupy ports that the api would use');
19
+ .option('-i, --instances <instances>', 'Horizontally scale directus to a given number of instances', '1');
21
20
  program.parse();
22
21
  const options = program.opts();
23
22
  const sb = await sandbox(program.args[0], {
package/dist/config.d.ts CHANGED
@@ -33,6 +33,7 @@ declare const baseConfig: {
33
33
  readonly maria: {
34
34
  readonly TZ: "0" | "UTC";
35
35
  readonly ADMIN_EMAIL: "admin@example.com";
36
+ readonly PROJECT_OWNER: "admin@example.com";
36
37
  readonly ADMIN_PASSWORD: "pw";
37
38
  readonly ADMIN_TOKEN: "admin";
38
39
  readonly SECRET: "directus-test";
@@ -67,6 +68,7 @@ declare const baseConfig: {
67
68
  readonly postgres: {
68
69
  readonly TZ: "0" | "UTC";
69
70
  readonly ADMIN_EMAIL: "admin@example.com";
71
+ readonly PROJECT_OWNER: "admin@example.com";
70
72
  readonly ADMIN_PASSWORD: "pw";
71
73
  readonly ADMIN_TOKEN: "admin";
72
74
  readonly SECRET: "directus-test";
@@ -101,6 +103,7 @@ declare const baseConfig: {
101
103
  readonly sqlite: {
102
104
  readonly TZ: "0" | "UTC";
103
105
  readonly ADMIN_EMAIL: "admin@example.com";
106
+ readonly PROJECT_OWNER: "admin@example.com";
104
107
  readonly ADMIN_PASSWORD: "pw";
105
108
  readonly ADMIN_TOKEN: "admin";
106
109
  readonly SECRET: "directus-test";
@@ -130,6 +133,7 @@ declare const baseConfig: {
130
133
  readonly cockroachdb: {
131
134
  readonly TZ: "0" | "UTC";
132
135
  readonly ADMIN_EMAIL: "admin@example.com";
136
+ readonly PROJECT_OWNER: "admin@example.com";
133
137
  readonly ADMIN_PASSWORD: "pw";
134
138
  readonly ADMIN_TOKEN: "admin";
135
139
  readonly SECRET: "directus-test";
@@ -165,6 +169,7 @@ declare const baseConfig: {
165
169
  readonly mssql: {
166
170
  readonly TZ: "0" | "UTC";
167
171
  readonly ADMIN_EMAIL: "admin@example.com";
172
+ readonly PROJECT_OWNER: "admin@example.com";
168
173
  readonly ADMIN_PASSWORD: "pw";
169
174
  readonly ADMIN_TOKEN: "admin";
170
175
  readonly SECRET: "directus-test";
@@ -199,6 +204,7 @@ declare const baseConfig: {
199
204
  readonly mysql: {
200
205
  readonly TZ: "0" | "UTC";
201
206
  readonly ADMIN_EMAIL: "admin@example.com";
207
+ readonly PROJECT_OWNER: "admin@example.com";
202
208
  readonly ADMIN_PASSWORD: "pw";
203
209
  readonly ADMIN_TOKEN: "admin";
204
210
  readonly SECRET: "directus-test";
@@ -233,6 +239,7 @@ declare const baseConfig: {
233
239
  readonly oracle: {
234
240
  readonly TZ: "0" | "UTC";
235
241
  readonly ADMIN_EMAIL: "admin@example.com";
242
+ readonly PROJECT_OWNER: "admin@example.com";
236
243
  readonly ADMIN_PASSWORD: "pw";
237
244
  readonly ADMIN_TOKEN: "admin";
238
245
  readonly SECRET: "directus-test";
package/dist/config.js CHANGED
@@ -4,6 +4,7 @@ const isWindows = ['win32', 'win64'].includes(process.platform);
4
4
  const directusConfig = {
5
5
  TZ: isWindows ? '0' : 'UTC',
6
6
  ADMIN_EMAIL: 'admin@example.com',
7
+ PROJECT_OWNER: 'admin@example.com',
7
8
  ADMIN_PASSWORD: 'pw',
8
9
  ADMIN_TOKEN: 'admin',
9
10
  SECRET: 'directus-test',
package/dist/sandbox.d.ts CHANGED
@@ -40,8 +40,6 @@ export type Options = {
40
40
  schema: string | undefined;
41
41
  /** Start the api with debugger */
42
42
  inspect: boolean;
43
- /** Forcefully kills all processes that occupy ports that the api would use */
44
- killPorts: boolean;
45
43
  /** Enable redis,maildev,saml or other extras */
46
44
  extras: {
47
45
  /** Used for caching, forced to true if instances > 1 */
package/dist/sandbox.js CHANGED
@@ -30,7 +30,6 @@ async function getOptions(options) {
30
30
  schema: undefined,
31
31
  silent: false,
32
32
  export: false,
33
- killPorts: false,
34
33
  extras: {
35
34
  redis: false,
36
35
  maildev: false,
package/dist/steps/api.js CHANGED
@@ -4,8 +4,7 @@ import {} from '../config.js';
4
4
  import {} from '../logger.js';
5
5
  import { apiFolder } from '../sandbox.js';
6
6
  import chalk from 'chalk';
7
- import { portToPid } from 'pid-port';
8
- import { createInterface } from 'readline/promises';
7
+ import { detect } from 'detect-port';
9
8
  export async function buildDirectus(opts, logger, onRebuild) {
10
9
  const start = performance.now();
11
10
  logger.info('Rebuilding Directus');
@@ -71,33 +70,11 @@ export async function startDirectus(opts, env, logger) {
71
70
  const apiCount = Math.max(1, Number(opts.instances));
72
71
  const apiPorts = [...Array(apiCount).keys()].flatMap((i) => Number(env.PORT) + i * (opts.inspect ? 2 : 1));
73
72
  const allPorts = apiPorts.flatMap((port) => (opts.inspect ? [port, port + 1] : [port]));
74
- const occupiedPorts = (await Promise.allSettled(allPorts.map((port) => portToPid(port))))
73
+ const occupiedPorts = (await Promise.allSettled(allPorts.map((port) => detect(port))))
75
74
  .map((result, i) => (result.status === 'fulfilled' ? [result.value, allPorts[i]] : undefined))
76
- .filter((val) => val);
77
- let killPorts;
78
- for (const [pid, port] of occupiedPorts) {
79
- logger.warn(`Port ${port} is occupied by pid ${pid}`);
80
- }
81
- if (opts.killPorts) {
82
- killPorts = true;
83
- }
84
- else {
85
- if (occupiedPorts.length > 0) {
86
- const rl = createInterface({ input: process.stdin, output: process.stdout });
87
- const result = (await rl.question('Would you like to kill all occupying processes? (Y/N) ')).toLowerCase();
88
- killPorts = result === 'y' || result === 'yes';
89
- }
90
- }
91
- if (killPorts) {
92
- for (const [pid] of occupiedPorts) {
93
- try {
94
- process.kill(pid, 'SIGKILL');
95
- logger.info(`Killed process ${pid}`);
96
- }
97
- catch (err) {
98
- logger.error(`Failed to kill process ${pid}: ${err.message}`);
99
- }
100
- }
75
+ .filter((val) => val && val[0] !== val[1]);
76
+ for (const [port] of occupiedPorts) {
77
+ logger.warn(`Port ${port} is already occupied`);
101
78
  }
102
79
  return await Promise.all(apiPorts.map((port) => {
103
80
  const newLogger = apiCount > 1 ? logger.addGroup(`API ${port}`) : logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitwel/sandbox",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Toolkit for spinning up directus test environments",
5
5
  "homepage": "https://directus.io",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "author": "Nils Twelker (nils@directus.io)",
21
21
  "license": "MIT",
22
22
  "private": false,
23
- "devDependencies": {
23
+ "dependencies": {
24
24
  "@directus/tsconfig": "3.0.0",
25
25
  "@directus/utils": "13.0.9",
26
26
  "@types/lodash-es": "4.17.12",
@@ -28,9 +28,9 @@
28
28
  "chalk": "5.4.1",
29
29
  "commander": "14.0.0",
30
30
  "copyfiles": "2.4.1",
31
+ "detect-port": "2.1.0",
31
32
  "get-port": "7.1.0",
32
33
  "lodash-es": "4.17.21",
33
- "pid-port": "1.0.2",
34
34
  "tsdown": "0.14.2",
35
35
  "tsx": "4.20.3",
36
36
  "typedoc": "0.28.12",