@govuk-pay/cli 0.0.84 → 0.0.86
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/package.json
CHANGED
|
@@ -1314,10 +1314,10 @@ GEM
|
|
|
1314
1314
|
mime-types (3.4.1)
|
|
1315
1315
|
mime-types-data (~> 3.2015)
|
|
1316
1316
|
mime-types-data (3.2022.0105)
|
|
1317
|
-
mini_portile2 (2.8.
|
|
1317
|
+
mini_portile2 (2.8.9)
|
|
1318
1318
|
minitest (5.19.0)
|
|
1319
1319
|
netrc (0.11.0)
|
|
1320
|
-
nokogiri (1.18.
|
|
1320
|
+
nokogiri (1.18.9)
|
|
1321
1321
|
mini_portile2 (~> 2.8.2)
|
|
1322
1322
|
racc (~> 1.4)
|
|
1323
1323
|
optimist (3.0.1)
|
|
@@ -1342,8 +1342,7 @@ GEM
|
|
|
1342
1342
|
http-cookie (>= 1.0.2, < 2.0)
|
|
1343
1343
|
mime-types (>= 1.16, < 4.0)
|
|
1344
1344
|
netrc (~> 0.8)
|
|
1345
|
-
rexml (3.
|
|
1346
|
-
strscan
|
|
1345
|
+
rexml (3.4.2)
|
|
1347
1346
|
rgl (0.5.9)
|
|
1348
1347
|
pairing_heap (>= 0.3.0)
|
|
1349
1348
|
rexml (~> 3.2, >= 3.2.4)
|
|
@@ -1381,7 +1380,6 @@ GEM
|
|
|
1381
1380
|
unicode-display_width (>= 1.5, < 3.0)
|
|
1382
1381
|
unicode_utils (~> 1.4)
|
|
1383
1382
|
strings-ansi (0.2.0)
|
|
1384
|
-
strscan (3.1.0)
|
|
1385
1383
|
thor (1.4.0)
|
|
1386
1384
|
tty-color (0.6.0)
|
|
1387
1385
|
tty-cursor (0.7.1)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const openurl_1 = require("openurl");
|
|
9
|
+
const node_os_1 = require("node:os");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const pay_local_cluster_js_1 = require("../config/pay_local_cluster.js");
|
|
12
|
+
const standardContent_1 = require("../../../core/standardContent");
|
|
13
|
+
const servicesConfig = (0, pay_local_cluster_js_1.loadServicesConfig)();
|
|
14
|
+
exports.command = 'db_schema <app_name>';
|
|
15
|
+
exports.desc = 'Generate DB schema for <app_name>';
|
|
16
|
+
const builder = (yargs) => {
|
|
17
|
+
return yargs
|
|
18
|
+
.usage(`$0 local db_schema <app_name> \n\n${exports.desc}`)
|
|
19
|
+
.positional('app_name', {
|
|
20
|
+
type: 'string',
|
|
21
|
+
choices: Object.values(servicesConfig).filter(service => service.db).map(service => service.name).sort(),
|
|
22
|
+
description: 'The name of the app to generate database schema for'
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.builder = builder;
|
|
26
|
+
exports.handler = dbSchemaHandler;
|
|
27
|
+
async function dbSchemaHandler(argv) {
|
|
28
|
+
await (0, standardContent_1.showHeader)();
|
|
29
|
+
const service = argv.app_name;
|
|
30
|
+
if (!(service in servicesConfig)) {
|
|
31
|
+
console.error(`The service specified (${service}) was not defined in the service_config.yaml file`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const serviceConfig = servicesConfig[service];
|
|
35
|
+
if (!serviceConfig.db) {
|
|
36
|
+
console.error(`The service specified (${serviceConfig.name}) does not have a database`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await generateDBSchema(serviceConfig);
|
|
40
|
+
}
|
|
41
|
+
exports.default = dbSchemaHandler;
|
|
42
|
+
async function generateDBSchema(serviceConfig) {
|
|
43
|
+
if (serviceConfig.db_port === undefined) {
|
|
44
|
+
throw new Error(`Service config for ${serviceConfig.name} is missing db_port specification`);
|
|
45
|
+
}
|
|
46
|
+
const destinationDirectory = node_path_1.default.join((0, node_os_1.homedir)(), 'tmp', 'erd', serviceConfig.name);
|
|
47
|
+
const args = [
|
|
48
|
+
'run',
|
|
49
|
+
'--rm',
|
|
50
|
+
'-v', `${destinationDirectory}:/output`,
|
|
51
|
+
'schemaspy/schemaspy',
|
|
52
|
+
'-t', 'pgsql',
|
|
53
|
+
'-db', serviceConfig.name,
|
|
54
|
+
'-host', 'host.docker.internal',
|
|
55
|
+
'-port', String(serviceConfig.db_port),
|
|
56
|
+
'-u', serviceConfig.name,
|
|
57
|
+
'-p', 'mysecretpassword',
|
|
58
|
+
'-hq',
|
|
59
|
+
'-renderer:cairo',
|
|
60
|
+
'-imageformat', 'svg',
|
|
61
|
+
'-I', '(databasechangelog*)|(databasechangeloglock)'
|
|
62
|
+
];
|
|
63
|
+
const output = (0, node_child_process_1.spawnSync)('docker', args, { stdio: 'inherit' });
|
|
64
|
+
if (output?.status === 0) {
|
|
65
|
+
(0, openurl_1.open)(`${destinationDirectory}/index.html`);
|
|
66
|
+
}
|
|
67
|
+
}
|