@blakearoberts/visage 0.0.5-rc.3 → 0.0.5-rc.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"certs.d.ts","sourceRoot":"","sources":["../src/certs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCrE"}
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"}
@@ -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,CAmD7D"}
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, openSync, rmSync, appendFileSync, writeFileSync } from 'node:fs';
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
- if (process.env.CI !== 'true') {
472
+ {
479
473
  // mkcert -install is idempotent;
480
474
  // CA files alone don't prove trust-store state.
481
- const result = spawnSync(mkcert, ['-install'], { env, stdio });
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, { env, stdio });
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
- return down;
614
+ const logs = follow();
615
+ return () => {
616
+ down();
617
+ logs.kill('SIGINT');
618
+ };
619
619
  }
620
620
 
621
621
  const HOSTS_FILE = '/etc/hosts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blakearoberts/visage",
3
- "version": "0.0.5-rc.3",
3
+ "version": "0.0.5-rc.5",
4
4
  "description": "Vite plugin for local development with HMR and OIDC session cookie lifecycle semantics.",
5
5
  "type": "module",
6
6
  "author": "Blake Roberts",