@basaltkit/deploy 0.4.1 → 0.5.1

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.
Files changed (53) hide show
  1. package/README.md +284 -23
  2. package/dist/answers.d.ts +70 -0
  3. package/dist/answers.js +196 -0
  4. package/dist/apache.js +11 -2
  5. package/dist/audit.d.ts +20 -0
  6. package/dist/audit.js +26 -0
  7. package/dist/backup.d.ts +17 -1
  8. package/dist/backup.js +56 -1
  9. package/dist/bin.js +9 -1
  10. package/dist/bootstrap.d.ts +68 -18
  11. package/dist/bootstrap.js +177 -45
  12. package/dist/caddy.js +2 -1
  13. package/dist/check.js +18 -5
  14. package/dist/checks.js +1 -1
  15. package/dist/cli.d.ts +22 -1
  16. package/dist/cli.js +498 -57
  17. package/dist/compose.d.ts +1 -1
  18. package/dist/compose.js +6 -1
  19. package/dist/config.d.ts +25 -2
  20. package/dist/config.js +65 -3
  21. package/dist/context.d.ts +43 -13
  22. package/dist/context.js +50 -7
  23. package/dist/detach.d.ts +23 -0
  24. package/dist/detach.js +105 -0
  25. package/dist/env-step.d.ts +16 -1
  26. package/dist/env-step.js +61 -5
  27. package/dist/events.d.ts +168 -0
  28. package/dist/events.js +477 -0
  29. package/dist/host.d.ts +179 -7
  30. package/dist/host.js +317 -42
  31. package/dist/index.d.ts +10 -5
  32. package/dist/index.js +7 -3
  33. package/dist/init.d.ts +2 -0
  34. package/dist/init.js +2 -1
  35. package/dist/install-plan.d.ts +40 -0
  36. package/dist/install-plan.js +437 -0
  37. package/dist/json-host.d.ts +32 -0
  38. package/dist/json-host.js +106 -0
  39. package/dist/lock.d.ts +45 -0
  40. package/dist/lock.js +128 -0
  41. package/dist/pipeline.d.ts +51 -3
  42. package/dist/pipeline.js +339 -173
  43. package/dist/protocol.d.ts +364 -0
  44. package/dist/protocol.js +134 -0
  45. package/dist/runs.d.ts +75 -0
  46. package/dist/runs.js +287 -0
  47. package/dist/state.d.ts +26 -13
  48. package/dist/state.js +68 -4
  49. package/dist/trust.d.ts +63 -0
  50. package/dist/trust.js +159 -0
  51. package/dist/version.d.ts +2 -0
  52. package/dist/version.js +10 -0
  53. package/package.json +5 -1
package/dist/check.js CHANGED
@@ -9,17 +9,30 @@ import { isAbsolute, join, resolve } from 'node:path';
9
9
  * `src/` only still gets its deploy config checked.
10
10
  */
11
11
  export async function check(host, dir, file, config) {
12
- host.out.step('check');
12
+ const started = host.now().getTime();
13
+ let types;
14
+ try {
15
+ types = await checkTypes(host, dir, file, config);
16
+ }
17
+ finally {
18
+ // Every step that starts ends, also when checkTypes throws (a read-only checkout).
19
+ host.out.stepEnd?.('check', types === undefined || types === 'failed' ? 'failed' : 'ok', host.now().getTime() - started);
20
+ }
21
+ host.out.result?.('check', { file, app: config.app, runtime: config.runtime.kind, ...(config.proxy ? { proxy: config.proxy.kind } : {}), types });
22
+ return types === 'failed' ? 1 : 0;
23
+ }
24
+ async function checkTypes(host, dir, file, config) {
25
+ host.out.step('check', 'check');
13
26
  host.out.ok(`${file}: valid for ${config.app} (${config.runtime.kind}${config.proxy ? `, ${config.proxy.kind}` : ''})`);
14
27
  const path = isAbsolute(file) ? file : resolve(dir, file);
15
28
  if (!/\.[cm]?ts$/.test(path)) {
16
29
  host.out.info('not TypeScript: no types to check');
17
- return 0;
30
+ return 'not-typescript';
18
31
  }
19
32
  const tsc = join(dir, 'node_modules', '.bin', 'tsc');
20
33
  if (!(await host.stat(tsc))) {
21
34
  host.out.warn(`types not checked: no ${tsc} (add typescript to the app's devDependencies)`);
22
- return 0;
35
+ return 'no-tsc';
23
36
  }
24
37
  const base = join(dir, 'tsconfig.json');
25
38
  const project = {
@@ -41,12 +54,12 @@ export async function check(host, dir, file, config) {
41
54
  const result = await host.exec(tsc, ['-p', tsconfig, '--pretty', 'false'], { cwd: dir });
42
55
  if (result.code === 0) {
43
56
  host.out.ok(`${file}: types check`);
44
- return 0;
57
+ return 'ok';
45
58
  }
46
59
  const errors = `${result.stdout}${result.stderr}`.trim().split('\n').filter(Boolean);
47
60
  for (const line of errors)
48
61
  host.out.error(line.startsWith(dir) ? line.slice(dir.length + 1) : line);
49
- return 1;
62
+ return 'failed';
50
63
  }
51
64
  finally {
52
65
  await host.remove(tsconfig);
package/dist/checks.js CHANGED
@@ -40,7 +40,7 @@ export async function tlsFindings(ctx) {
40
40
  ...(name === config.domain ? {} : { fix: `issue a wildcard: certbot certonly --dns-cloudflare -d ${config.domain} -d '*.${config.domain}', and make *.${config.domain} DNS-only` }),
41
41
  });
42
42
  }
43
- else if (!cert.trusted) {
43
+ if (!cert.trusted) {
44
44
  findings.push({ id: 'C8', level: 'warning', message: `the certificate served for ${label} is not trusted by browsers (${cert.trustError ?? 'unknown reason'}) — a Cloudflare Origin certificate behind a DNS-only record?` });
45
45
  }
46
46
  const days = Math.floor((cert.validTo.getTime() - host.now().getTime()) / 86_400_000);
package/dist/cli.d.ts CHANGED
@@ -2,7 +2,28 @@ import { type DeployConfig } from './config.js';
2
2
  import { type DeployContext } from './context.js';
3
3
  import { type Host } from './host.js';
4
4
  export declare const USAGE: string;
5
+ /**
6
+ * `basalt-deploy ui` (RFC 0009 §3.4): a hint, nothing else. The UI is a
7
+ * separate package that runs on the operator's machine and drives this CLI
8
+ * over ssh; this package gains no listener and no dependency for it.
9
+ */
10
+ export declare const UI_HINT = "The deploy UI runs on YOUR machine, never on the server: it listens on\n127.0.0.1 only and drives this server over your own ssh, as the app user.\n\nOn your machine (not here, and not in the app's package.json \u2014 the deploy\ninstalls devDependencies on the server):\n\n npx @basaltkit/deploy-ui@<exact version>\n\nIt opens your browser. Add a target (ssh destination and this checkout's\ndirectory), check the connection, plan, deploy. See the @basaltkit/deploy-ui\nREADME for its security model.\n";
11
+ /** Another deploy holds the lock: nothing was done. */
12
+ export declare const EXIT_LOCKED = 3;
13
+ /** A signal stopped the command at a step boundary. */
14
+ export declare const EXIT_ABORTED = 130;
5
15
  /** Loads deploy.config.ts with the app's own tsx when it has one, else Node's type stripping. */
6
16
  export declare function loadConfig(dir: string, file: string): Promise<DeployConfig>;
7
17
  export declare function createContext(host: Host, dir: string, config: DeployConfig): Promise<DeployContext>;
8
- export declare function main(argv: string[], host?: Host, cwd?: string): Promise<number>;
18
+ /** The process's own stdin and stdout, which the machine protocol uses (RFC 0008 §3.3). */
19
+ export interface CliIO {
20
+ /** stdout as it was before anything replaced `process.stdout.write`. */
21
+ write(text: string): void;
22
+ stdin(): AsyncIterable<string | Uint8Array>;
23
+ /** Turns writes to `process.stdout` and `process.stderr` into `sink` calls, until the returned function is called. */
24
+ capture(sink: (text: string) => void): () => void;
25
+ /** One plain line on stderr: the event writer itself failed. */
26
+ stderr(text: string): void;
27
+ }
28
+ export declare function processIO(stream?: NodeJS.WritableStream, input?: AsyncIterable<string | Uint8Array>, errors?: NodeJS.WritableStream): CliIO;
29
+ export declare function main(argv: string[], host?: Host, cwd?: string, io?: CliIO): Promise<number>;