@nitwel/sandbox 1.0.1 → 1.0.3
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/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/docker/postgres.yml +0 -1
- package/dist/find-directus.d.ts +2 -0
- package/dist/find-directus.js +22 -0
- package/dist/sandbox.js +2 -1
- package/dist/steps/docker.js +5 -2
- package/package.json +2 -2
package/dist/config.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ declare const baseConfig: {
|
|
|
96
96
|
readonly DB_PASSWORD: "secret";
|
|
97
97
|
readonly DB_PORT: "$PORT";
|
|
98
98
|
readonly DB_DATABASE: "directus";
|
|
99
|
-
readonly DB_VERSION: "18-alpine";
|
|
99
|
+
readonly DB_VERSION: "18-3.6-alpine";
|
|
100
100
|
};
|
|
101
101
|
readonly sqlite: {
|
|
102
102
|
readonly TZ: "0" | "UTC";
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
+
import { directusFolder } from './find-directus.js';
|
|
2
3
|
const isWindows = ['win32', 'win64'].includes(process.platform);
|
|
3
4
|
const directusConfig = {
|
|
4
5
|
TZ: isWindows ? '0' : 'UTC',
|
|
@@ -9,7 +10,7 @@ const directusConfig = {
|
|
|
9
10
|
TELEMETRY: 'false',
|
|
10
11
|
CACHE_SCHEMA: 'true',
|
|
11
12
|
CACHE_SCHEMA_MAX_ITERATIONS: '100',
|
|
12
|
-
CONFIG_PATH: join(
|
|
13
|
+
CONFIG_PATH: join(directusFolder, '.env'), // Override to non existent file so process envs aren't overwritten by file envs
|
|
13
14
|
RATE_LIMITER_ENABLED: 'false',
|
|
14
15
|
PRESSURE_LIMITER_ENABLED: 'false',
|
|
15
16
|
LOG_LEVEL: 'info',
|
|
@@ -75,7 +76,7 @@ const postgres = {
|
|
|
75
76
|
DB_PASSWORD: 'secret',
|
|
76
77
|
DB_PORT: '$PORT',
|
|
77
78
|
DB_DATABASE: 'directus',
|
|
78
|
-
DB_VERSION: '18-alpine',
|
|
79
|
+
DB_VERSION: '18-3.6-alpine',
|
|
79
80
|
...directusConfig,
|
|
80
81
|
};
|
|
81
82
|
const sqlite = {
|
package/dist/docker/postgres.yml
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
export const directusFolder = findDirectus();
|
|
4
|
+
export function findDirectus() {
|
|
5
|
+
let currentDir = process.cwd();
|
|
6
|
+
while (true) {
|
|
7
|
+
const packagePath = join(currentDir, 'package.json');
|
|
8
|
+
if (existsSync(packagePath)) {
|
|
9
|
+
const file = readFileSync(packagePath, 'utf-8');
|
|
10
|
+
const json = JSON.parse(file);
|
|
11
|
+
if (json['name'] === 'directus-monorepo') {
|
|
12
|
+
return currentDir;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const parentDir = dirname(currentDir);
|
|
16
|
+
if (parentDir === currentDir) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
currentDir = parentDir;
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Sandbox is not executed in the directus monorepo');
|
|
22
|
+
}
|
package/dist/sandbox.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createLogger } from './logger.js';
|
|
|
6
6
|
import { buildDirectus, bootstrap, dockerDown, dockerUp, loadSchema, saveSchema, startDirectus, } from './steps/index.js';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import getPort from 'get-port';
|
|
9
|
+
import { directusFolder } from './find-directus.js';
|
|
9
10
|
async function getOptions(options) {
|
|
10
11
|
if (options?.schema === true)
|
|
11
12
|
options.schema = 'snapshot.json';
|
|
@@ -39,7 +40,7 @@ async function getOptions(options) {
|
|
|
39
40
|
cache: false,
|
|
40
41
|
}, options);
|
|
41
42
|
}
|
|
42
|
-
export const apiFolder = join(
|
|
43
|
+
export const apiFolder = join(directusFolder, 'api');
|
|
43
44
|
export const databases = [
|
|
44
45
|
'maria',
|
|
45
46
|
'cockroachdb',
|
package/dist/steps/docker.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
|
-
import { join } from 'path';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
3
|
import {} from '../config.js';
|
|
4
4
|
import {} from '../logger.js';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
const fileName = fileURLToPath(import.meta.url);
|
|
8
|
+
const folderName = dirname(fileName);
|
|
6
9
|
export async function dockerUp(database, opts, env, logger) {
|
|
7
10
|
const start = performance.now();
|
|
8
11
|
logger.info('Starting up Docker containers');
|
|
@@ -19,7 +22,7 @@ export async function dockerUp(database, opts, env, logger) {
|
|
|
19
22
|
'compose',
|
|
20
23
|
'-p',
|
|
21
24
|
project,
|
|
22
|
-
...files.flatMap((file) => ['-f', join(
|
|
25
|
+
...files.flatMap((file) => ['-f', join(folderName, '..', 'docker', `${file}.yml`)]),
|
|
23
26
|
'up',
|
|
24
27
|
'-d',
|
|
25
28
|
'--wait',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitwel/sandbox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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
|
-
"
|
|
23
|
+
"devDependencies": {
|
|
24
24
|
"@directus/tsconfig": "3.0.0",
|
|
25
25
|
"@directus/utils": "13.0.9",
|
|
26
26
|
"@types/lodash-es": "4.17.12",
|