@blakearoberts/visage 0.0.5-rc.2 → 0.0.5-rc.4
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/certs.d.ts.map +1 -1
- package/dist/compose.d.ts.map +1 -1
- package/dist/index.js +24 -28
- package/dist/render/compose.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/certs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certs.d.ts","sourceRoot":"","sources":["../src/certs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"certs.d.ts","sourceRoot":"","sources":["../src/certs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCrE"}
|
package/dist/compose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,CAsD7D"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
2
|
import { basename, resolve, join } from 'node:path';
|
|
3
|
-
import { readFileSync, mkdirSync, chmodSync,
|
|
3
|
+
import { readFileSync, openSync, mkdirSync, chmodSync, rmSync, appendFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { parse, stringify } from 'yaml';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import { homedir } from 'node:os';
|
|
5
|
+
import { spawnSync, spawn } from 'node:child_process';
|
|
7
6
|
import { hashSync } from 'bcryptjs';
|
|
8
7
|
import { Eta } from 'eta';
|
|
9
8
|
|
|
@@ -465,20 +464,15 @@ function isVisageEdgeRequest(request, edgeKey) {
|
|
|
465
464
|
return typeof header === 'string' && header === edgeKey;
|
|
466
465
|
}
|
|
467
466
|
|
|
468
|
-
const CACHE_HOME = process.env.XDG_CACHE_HOME || join(homedir(), '.cache');
|
|
469
467
|
async function ensureCerts(config) {
|
|
470
|
-
const CAROOT = join(CACHE_HOME, 'visage/ca');
|
|
471
|
-
mkdirSync(CAROOT, { recursive: true, mode: 0o700 });
|
|
472
|
-
chmodSync(CAROOT, 0o700);
|
|
473
468
|
const mkcert = resolveMkcert();
|
|
474
469
|
const out = openSync(join(config.cache, 'logs', 'mkcert.log'), 'w');
|
|
475
|
-
const env = { CAROOT, TRUST_STORES: 'system', ...process.env };
|
|
476
470
|
const tty = process.stdin.isTTY;
|
|
477
471
|
const stdio = [tty ? 'inherit' : 'ignore', out, out];
|
|
478
|
-
|
|
472
|
+
{
|
|
479
473
|
// mkcert -install is idempotent;
|
|
480
474
|
// CA files alone don't prove trust-store state.
|
|
481
|
-
const result = spawnSync(mkcert, ['-install'], {
|
|
475
|
+
const result = spawnSync(mkcert, ['-install'], { stdio });
|
|
482
476
|
if (result.error)
|
|
483
477
|
throw result.error;
|
|
484
478
|
if (result.status !== 0) {
|
|
@@ -494,7 +488,7 @@ async function ensureCerts(config) {
|
|
|
494
488
|
rmSync(key, { force: true });
|
|
495
489
|
const names = [...new Set([config.host, 'localhost', '127.0.0.1', '::1'])];
|
|
496
490
|
const args = ['-cert-file', cert, '-key-file', key, ...names];
|
|
497
|
-
const result = spawnSync(mkcert, args, {
|
|
491
|
+
const result = spawnSync(mkcert, args, { stdio });
|
|
498
492
|
if (result.error)
|
|
499
493
|
throw result.error;
|
|
500
494
|
if (result.status !== 0) {
|
|
@@ -570,8 +564,6 @@ function mkcertInstallInstructions() {
|
|
|
570
564
|
}
|
|
571
565
|
|
|
572
566
|
function startCompose(config) {
|
|
573
|
-
const logs = join(config.cache, 'logs');
|
|
574
|
-
const output = openSync(join(logs, 'compose.log'), 'w');
|
|
575
567
|
const compose = [
|
|
576
568
|
'compose',
|
|
577
569
|
'--ansi=never',
|
|
@@ -579,6 +571,7 @@ function startCompose(config) {
|
|
|
579
571
|
`--project-name=${config.compose.name}`,
|
|
580
572
|
`--profile=${process.platform}`,
|
|
581
573
|
];
|
|
574
|
+
const dir = join(config.cache, 'logs');
|
|
582
575
|
const env = {
|
|
583
576
|
COMPOSE_MENU: 'false',
|
|
584
577
|
...(config.oauth2.public
|
|
@@ -588,12 +581,9 @@ function startCompose(config) {
|
|
|
588
581
|
[config.secrets.edgeKey]: config.edgeKey,
|
|
589
582
|
[config.secrets.cookieSecret]: randomBytes(32).toString('base64url'),
|
|
590
583
|
};
|
|
591
|
-
const opts = {
|
|
592
|
-
cwd: config.cache,
|
|
593
|
-
stdio: ['ignore', output, output],
|
|
594
|
-
env,
|
|
595
|
-
};
|
|
584
|
+
const opts = { cwd: config.cache, env };
|
|
596
585
|
function up() {
|
|
586
|
+
const out = openSync(join(dir, 'compose.log'), 'w');
|
|
597
587
|
const args = [
|
|
598
588
|
...compose,
|
|
599
589
|
'up',
|
|
@@ -601,11 +591,17 @@ function startCompose(config) {
|
|
|
601
591
|
'--force-recreate',
|
|
602
592
|
'--remove-orphans',
|
|
603
593
|
];
|
|
604
|
-
return spawnSync('docker', args, opts);
|
|
594
|
+
return spawnSync('docker', args, { ...opts, stdio: ['ignore', out, out] });
|
|
605
595
|
}
|
|
606
596
|
function down() {
|
|
597
|
+
const out = openSync(join(dir, 'compose.log'), 'a');
|
|
607
598
|
const args = [...compose, 'down', '--remove-orphans'];
|
|
608
|
-
return spawnSync('docker', args, opts);
|
|
599
|
+
return spawnSync('docker', args, { ...opts, stdio: ['ignore', out, out] });
|
|
600
|
+
}
|
|
601
|
+
function follow() {
|
|
602
|
+
const out = openSync(join(dir, 'container.log'), 'w');
|
|
603
|
+
const args = [...compose, 'logs', '--follow'];
|
|
604
|
+
return spawn('docker', args, { ...opts, stdio: ['ignore', out, out] });
|
|
609
605
|
}
|
|
610
606
|
down();
|
|
611
607
|
const result = up();
|
|
@@ -615,7 +611,11 @@ function startCompose(config) {
|
|
|
615
611
|
down();
|
|
616
612
|
throw new Error('Failed to start Docker Compose');
|
|
617
613
|
}
|
|
618
|
-
|
|
614
|
+
const logs = follow();
|
|
615
|
+
return () => {
|
|
616
|
+
down();
|
|
617
|
+
logs.kill('SIGINT');
|
|
618
|
+
};
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
const HOSTS_FILE = '/etc/hosts';
|
|
@@ -670,12 +670,6 @@ function writeComposeConfig(config) {
|
|
|
670
670
|
}
|
|
671
671
|
function renderComposeConfig(config) {
|
|
672
672
|
const { dex, nginx, oauth2_proxy, ...services } = config.services;
|
|
673
|
-
const bridge = spawnSync('docker', [
|
|
674
|
-
'network',
|
|
675
|
-
'inspect',
|
|
676
|
-
'bridge',
|
|
677
|
-
'--format={{ (index .IPAM.Config 0).Gateway }}',
|
|
678
|
-
], { encoding: 'utf8' }).stdout.trim();
|
|
679
673
|
return stringify({
|
|
680
674
|
secrets: {
|
|
681
675
|
[config.secrets.cookieSecret]: {
|
|
@@ -711,7 +705,9 @@ function renderComposeConfig(config) {
|
|
|
711
705
|
? {
|
|
712
706
|
vite_loopback: {
|
|
713
707
|
image: DockerImages.socat.image,
|
|
714
|
-
command: `tcp-listen:${config.upstreams.vite.port},fork,bind
|
|
708
|
+
command: `tcp-listen:${config.upstreams.vite.port},fork,bind=host.docker.internal ` +
|
|
709
|
+
`tcp-connect:127.0.0.1:${config.upstreams.vite.port}`,
|
|
710
|
+
extra_hosts: ['host.docker.internal:host-gateway'],
|
|
715
711
|
network_mode: 'host',
|
|
716
712
|
profiles: ['linux'],
|
|
717
713
|
restart: 'always',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/render/compose.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/render/compose.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAI7D"}
|
package/package.json
CHANGED