ras-stack 0.31.0 → 0.33.0

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/README.md CHANGED
@@ -35,16 +35,16 @@ An application can use one surface without adopting the others. The npm package
35
35
 
36
36
  These combinations are tested here and in production. [Sealed Lists](https://github.com/richardsolomou/sealed-lists), [Praetorium](https://github.com/richardsolomou/praetorium.gg), and [STL Quest](https://github.com/richardsolomou/stl.quest) use the application and runtime pieces. [BaseKit](https://github.com/richardsolomou/basekit) and [tro.gg](https://github.com/richardsolomou/tro.gg) use only the tooling that fits their different architectures.
37
37
 
38
- | Layer | Supported technology | What `ras-stack` centralizes |
39
- | ------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
40
- | Runtime and tooling | Node 24, ESM TypeScript, pnpm, Just, Oxlint | Compiler/linter bases, setup actions, and version synchronization |
41
- | Web application | TanStack Start 1, React 19, TanStack Query 5 | Request binding, mutation-origin checks, canonical hosts, health handlers, and Query defaults |
42
- | Authentication | Better Auth | Secure option builders, origins, secrets, tokens, failure classification, and React action state |
43
- | Data | Drizzle, `better-sqlite3` 12–13, Postgres.js 3 | Connection lifecycle, safety defaults, migrations, target selection, and conformance checks |
44
- | Realtime | Centrifuge 5, Centrifugo 6, Caddy 2 | Publishing, tokens, browser/React lifecycle, presence, proxy configuration, binaries, and supervision |
45
- | Email and uploads | Nodemailer 9, `tus-js-client` 4 | SMTP configuration/delivery and promise-based resumable uploads |
46
- | Observability | PostHog JS 1, React 1, Node 5 | Initialization, error defaults, request correlation, proxy routes, shutdown, and coverage decisions |
47
- | Delivery | GitHub Actions, Changesets, Dokploy, Docker | Checks, releases, preview lifecycle/status, production assets, and runtime binaries |
38
+ | Layer | Supported technology | What `ras-stack` centralizes |
39
+ | ------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
40
+ | Runtime and tooling | Node, ESM TypeScript, pnpm, Just, Oxlint | Compiler/linter bases, setup actions, and version synchronization |
41
+ | Web application | TanStack Start, React, TanStack Query | Request binding, mutation-origin checks, canonical hosts, health handlers, and Query defaults |
42
+ | Authentication | Better Auth | Secure option builders, origins, secrets, tokens, failure classification, and React action state |
43
+ | Data | Drizzle, `better-sqlite3`, Postgres.js | Connection lifecycle, safety defaults, migrations, target selection, and conformance checks |
44
+ | Realtime | Centrifuge, Centrifugo, Caddy | Publishing, tokens, browser/React lifecycle, presence, proxy configuration, binaries, and supervision |
45
+ | Email and uploads | Nodemailer, `tus-js-client` | SMTP configuration/delivery and promise-based resumable uploads |
46
+ | Observability | PostHog JS, React, and Node SDKs | Initialization, error defaults, request correlation, proxy routes, shutdown, and coverage decisions |
47
+ | Delivery | GitHub Actions, Changesets, Dokploy, Docker | Checks, releases, preview lifecycle/status, production assets, and runtime binaries |
48
48
 
49
49
  Applications still configure every upstream library directly. This table describes what is tested together, not a replacement API.
50
50
 
@@ -82,10 +82,10 @@ Start with the narrowest public entrypoint that owns the repeated mechanic:
82
82
  | RPC, mutation-origin, health, and canonical-host handling | `ras-stack/server`, `ras-stack/tanstack/server` | Routes, authorization, logging, and health work |
83
83
  | SQLite or PostgreSQL lifecycle | `ras-stack/database/*` | Schemas, migrations, repositories, and transactions |
84
84
  | Realtime publication and browser lifecycle | `ras-stack/realtime/*` | Channels, tickets, payloads, presence models, and invalidation |
85
- | Email, uploads, and production assets | `ras-stack/email`, `ras-stack/uploads`, `ras-stack-assets` | Templates, metadata, quotas, storage, and asset contents |
86
- | Production or development realtime runtime | `ras-stack/runtime`, `ras-stack-realtime` | Images, ports, secrets, volumes, and distributed policy |
85
+ | Email, uploads, and production assets | `ras-stack/email`, `ras-stack/uploads`, `ras assets` | Templates, metadata, quotas, storage, and asset contents |
86
+ | Production or development realtime runtime | `ras-stack/runtime`, `ras realtime` | Images, ports, secrets, volumes, and distributed policy |
87
87
  | Compiler, lint, CI, release, and preview mechanics | `ras-stack/config/*`, `actions/*`, `.github/workflows/*`, `ras-stack/preview/*` | Triggers, permissions, services, deployment, and verification |
88
- | Generated repository policy and adoption checks | `ras-stack-policy` | Which policies apply and every declared exception |
88
+ | Generated repository policy and adoption checks | `ras policy` | Which policies apply and every declared exception |
89
89
 
90
90
  ## Guides 📚
91
91
 
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export declare function runAssetsCli(arguments_: string[]): Promise<void>;
package/dist/build/cli.js CHANGED
@@ -1,12 +1,11 @@
1
- #!/usr/bin/env node
2
1
  import { checkServerAssets, loadServerAssetsConfig, syncServerAssets } from './index.js';
3
- const command = process.argv[2];
4
- const configFile = process.argv[3];
5
- if (command !== 'check' && command !== 'sync') {
6
- console.error('usage: ras-stack-assets <check|sync> [config-file]');
7
- process.exitCode = 2;
8
- }
9
- else {
2
+ export async function runAssetsCli(arguments_) {
3
+ const [command, configFile] = arguments_;
4
+ if (command !== 'check' && command !== 'sync') {
5
+ console.error('usage: ras assets <check|sync> [config-file]');
6
+ process.exitCode = 2;
7
+ return;
8
+ }
10
9
  const root = process.cwd();
11
10
  const config = await loadServerAssetsConfig(root, configFile);
12
11
  if (command === 'sync') {
@@ -17,7 +16,7 @@ else {
17
16
  for (const destination of drift)
18
17
  console.error(`server asset drift: ${destination}`);
19
18
  if (drift.length > 0) {
20
- console.error('run ras-stack-assets sync after the production build');
19
+ console.error('run ras assets sync after the production build');
21
20
  process.exitCode = 1;
22
21
  }
23
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/build/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAExF,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAClC,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;IAC9C,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACnE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC;KAAM,CAAC;IACN,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC1B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7D,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACnD,KAAK,MAAM,WAAW,IAAI,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,EAAE,CAAC,CAAA;QACpF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAA;YACrE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { checkServerAssets, loadServerAssetsConfig, syncServerAssets } from './index.js'\n\nconst command = process.argv[2]\nconst configFile = process.argv[3]\nif (command !== 'check' && command !== 'sync') {\n console.error('usage: ras-stack-assets <check|sync> [config-file]')\n process.exitCode = 2\n} else {\n const root = process.cwd()\n const config = await loadServerAssetsConfig(root, configFile)\n if (command === 'sync') {\n await syncServerAssets(root, config)\n } else {\n const drift = await checkServerAssets(root, config)\n for (const destination of drift) console.error(`server asset drift: ${destination}`)\n if (drift.length > 0) {\n console.error('run ras-stack-assets sync after the production build')\n process.exitCode = 1\n }\n }\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/build/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAExF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAoB;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,UAAU,CAAA;IACxC,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9C,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;QAC7D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC1B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7D,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACnD,KAAK,MAAM,WAAW,IAAI,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,EAAE,CAAC,CAAA;QACpF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;YAC/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { checkServerAssets, loadServerAssetsConfig, syncServerAssets } from './index.js'\n\nexport async function runAssetsCli(arguments_: string[]): Promise<void> {\n const [command, configFile] = arguments_\n if (command !== 'check' && command !== 'sync') {\n console.error('usage: ras assets <check|sync> [config-file]')\n process.exitCode = 2\n return\n }\n\n const root = process.cwd()\n const config = await loadServerAssetsConfig(root, configFile)\n if (command === 'sync') {\n await syncServerAssets(root, config)\n } else {\n const drift = await checkServerAssets(root, config)\n for (const destination of drift) console.error(`server asset drift: ${destination}`)\n if (drift.length > 0) {\n console.error('run ras assets sync after the production build')\n process.exitCode = 1\n }\n }\n}\n"]}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { runAssetsCli } from './build/cli.js';
3
+ import { runPolicyCli } from './policy/cli.js';
4
+ import { runPreviewCli } from './preview/cli.js';
5
+ import { runRealtimeCli } from './runtime/dev-cli.js';
6
+ declare const commands: {
7
+ readonly assets: typeof runAssetsCli;
8
+ readonly policy: typeof runPolicyCli;
9
+ readonly preview: typeof runPreviewCli;
10
+ readonly realtime: typeof runRealtimeCli;
11
+ };
12
+ export type RasCommand = keyof typeof commands;
13
+ export declare function parseRasCommand(arguments_: string[]): {
14
+ arguments: string[];
15
+ command: RasCommand;
16
+ } | undefined;
17
+ export declare function runRasCli(arguments_: string[]): Promise<void>;
18
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { runAssetsCli } from './build/cli.js';
3
+ import { runPolicyCli } from './policy/cli.js';
4
+ import { runPreviewCli } from './preview/cli.js';
5
+ import { runRealtimeCli } from './runtime/dev-cli.js';
6
+ const commands = {
7
+ assets: runAssetsCli,
8
+ policy: runPolicyCli,
9
+ preview: runPreviewCli,
10
+ realtime: runRealtimeCli,
11
+ };
12
+ export function parseRasCommand(arguments_) {
13
+ const [command, ...argumentsRest] = arguments_;
14
+ if (!(command && Object.hasOwn(commands, command)))
15
+ return undefined;
16
+ return { arguments: argumentsRest, command: command };
17
+ }
18
+ export async function runRasCli(arguments_) {
19
+ const parsed = parseRasCommand(arguments_);
20
+ if (!parsed) {
21
+ console.error('usage: ras <assets|policy|preview|realtime> [arguments]');
22
+ process.exitCode = 2;
23
+ return;
24
+ }
25
+ await commands[parsed.command](parsed.arguments);
26
+ }
27
+ if (import.meta.main)
28
+ await runRasCli(process.argv.slice(2));
29
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,MAAM,QAAQ,GAAG;IACf,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;CAChB,CAAA;AAIV,MAAM,UAAU,eAAe,CAAC,UAAoB;IAClD,MAAM,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,GAAG,UAAU,CAAA;IAC9C,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IACpE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,OAAqB,EAAE,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAoB;IAClD,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAA;QACxE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IACD,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAClD,CAAC;AAED,IAAI,OAAO,IAAI,CAAC,IAAI;IAAE,MAAM,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { runAssetsCli } from './build/cli.js'\nimport { runPolicyCli } from './policy/cli.js'\nimport { runPreviewCli } from './preview/cli.js'\nimport { runRealtimeCli } from './runtime/dev-cli.js'\n\nconst commands = {\n assets: runAssetsCli,\n policy: runPolicyCli,\n preview: runPreviewCli,\n realtime: runRealtimeCli,\n} as const\n\nexport type RasCommand = keyof typeof commands\n\nexport function parseRasCommand(arguments_: string[]): { arguments: string[]; command: RasCommand } | undefined {\n const [command, ...argumentsRest] = arguments_\n if (!(command && Object.hasOwn(commands, command))) return undefined\n return { arguments: argumentsRest, command: command as RasCommand }\n}\n\nexport async function runRasCli(arguments_: string[]): Promise<void> {\n const parsed = parseRasCommand(arguments_)\n if (!parsed) {\n console.error('usage: ras <assets|policy|preview|realtime> [arguments]')\n process.exitCode = 2\n return\n }\n await commands[parsed.command](parsed.arguments)\n}\n\nif (import.meta.main) await runRasCli(process.argv.slice(2))\n"]}
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export declare function runPolicyCli(arguments_: string[]): Promise<void>;
@@ -1,23 +1,24 @@
1
- #!/usr/bin/env node
2
1
  import { readFile } from 'node:fs/promises';
3
2
  import { resolve } from 'node:path';
4
3
  import { fleetConfig, fleetMarkdown, inspectFleet } from './fleet.js';
5
4
  import { checkRepositoryPolicy, syncAdoptionPolicy, syncRepositoryPolicy } from './index.js';
6
- const command = process.argv[2];
7
- if (command !== 'check' && command !== 'sync' && command !== 'fleet') {
8
- console.error('usage: ras-stack-policy <check|sync|fleet> [adoption]');
9
- process.exitCode = 2;
10
- }
11
- else if (command === 'fleet') {
12
- const path = resolve(process.argv[3] ?? 'ras-stack.fleet.json');
13
- const config = fleetConfig(JSON.parse(await readFile(path, 'utf8')));
14
- const results = await inspectFleet(config);
15
- process.stdout.write(fleetMarkdown(results));
16
- if (results.some((result) => result.drift.length > 0))
17
- process.exitCode = 1;
18
- }
19
- else {
20
- const adoption = process.argv[3] === 'adoption';
5
+ export async function runPolicyCli(arguments_) {
6
+ const [command, argument] = arguments_;
7
+ if (command !== 'check' && command !== 'sync' && command !== 'fleet') {
8
+ console.error('usage: ras policy <check|sync|fleet> [adoption]');
9
+ process.exitCode = 2;
10
+ return;
11
+ }
12
+ if (command === 'fleet') {
13
+ const path = resolve(argument ?? 'ras-stack.fleet.json');
14
+ const config = fleetConfig(JSON.parse(await readFile(path, 'utf8')));
15
+ const results = await inspectFleet(config);
16
+ process.stdout.write(fleetMarkdown(results));
17
+ if (results.some((result) => result.drift.length > 0))
18
+ process.exitCode = 1;
19
+ return;
20
+ }
21
+ const adoption = argument === 'adoption';
21
22
  const changed = adoption
22
23
  ? await syncAdoptionPolicy(process.cwd(), command === 'check' ? 'check' : 'write')
23
24
  : command === 'check'
@@ -26,7 +27,7 @@ else {
26
27
  if (command === 'check' && changed.length > 0) {
27
28
  for (const message of changed)
28
29
  console.error(message);
29
- console.error(`run ras-stack-policy sync${adoption ? ' adoption' : ''} and commit the result`);
30
+ console.error(`run ras policy sync${adoption ? ' adoption' : ''} and commit the result`);
30
31
  process.exitCode = 1;
31
32
  }
32
33
  else if (command === 'sync') {
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/policy/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE5F,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC/B,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;IACrE,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAA;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,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KAAK,CAAC,4BAA4B,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAA;QAC9F,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACtB,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,KAAK,MAAM,IAAI,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { readFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { fleetConfig, fleetMarkdown, inspectFleet } from './fleet.js'\nimport { checkRepositoryPolicy, syncAdoptionPolicy, syncRepositoryPolicy } from './index.js'\n\nconst command = process.argv[2]\nif (command !== 'check' && command !== 'sync' && command !== 'fleet') {\n console.error('usage: ras-stack-policy <check|sync|fleet> [adoption]')\n process.exitCode = 2\n} else if (command === 'fleet') {\n const path = resolve(process.argv[3] ?? 'ras-stack.fleet.json')\n const config = fleetConfig(JSON.parse(await readFile(path, 'utf8')))\n const results = await inspectFleet(config)\n process.stdout.write(fleetMarkdown(results))\n if (results.some((result) => result.drift.length > 0)) process.exitCode = 1\n} else {\n const adoption = process.argv[3] === 'adoption'\n const changed = adoption\n ? await syncAdoptionPolicy(process.cwd(), command === 'check' ? 'check' : 'write')\n : command === 'check'\n ? await checkRepositoryPolicy(process.cwd())\n : await syncRepositoryPolicy(process.cwd(), 'write')\n if (command === 'check' && changed.length > 0) {\n for (const message of changed) console.error(message)\n console.error(`run ras-stack-policy sync${adoption ? ' adoption' : ''} and commit the result`)\n process.exitCode = 1\n } else if (command === 'sync') {\n for (const path of changed) console.log(`updated ${path}`)\n }\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/policy/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EA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CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QAClF,CAAC,CAAC,OAAO,KAAK,OAAO;YACnB,CAAC,CAAC,MAAM,qBAAqB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAC5C,CAAC,CAAC,MAAM,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;IACxD,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,KAAK,MAAM,OAAO,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACrD,OAAO,CAAC,KAAK,CAAC,sBAAsB,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAA;QACxF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACtB,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,KAAK,MAAM,IAAI,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport { fleetConfig, fleetMarkdown, inspectFleet } from './fleet.js'\nimport { checkRepositoryPolicy, syncAdoptionPolicy, syncRepositoryPolicy } from './index.js'\n\nexport async function runPolicyCli(arguments_: string[]): Promise<void> {\n const [command, argument] = arguments_\n if (command !== 'check' && command !== 'sync' && command !== 'fleet') {\n console.error('usage: ras policy <check|sync|fleet> [adoption]')\n process.exitCode = 2\n return\n }\n\n if (command === 'fleet') {\n const path = resolve(argument ?? 'ras-stack.fleet.json')\n const config = fleetConfig(JSON.parse(await readFile(path, 'utf8')))\n const results = await inspectFleet(config)\n process.stdout.write(fleetMarkdown(results))\n if (results.some((result) => result.drift.length > 0)) process.exitCode = 1\n return\n }\n\n const adoption = argument === 'adoption'\n const changed = adoption\n ? await syncAdoptionPolicy(process.cwd(), command === 'check' ? 'check' : 'write')\n : command === 'check'\n ? await checkRepositoryPolicy(process.cwd())\n : await syncRepositoryPolicy(process.cwd(), 'write')\n if (command === 'check' && changed.length > 0) {\n for (const message of changed) console.error(message)\n console.error(`run ras policy sync${adoption ? ' adoption' : ''} and commit the result`)\n process.exitCode = 1\n } else if (command === 'sync') {\n for (const path of changed) console.log(`updated ${path}`)\n }\n}\n"]}
@@ -5,8 +5,9 @@ export type PostHogCoverage = {
5
5
  browser: {
6
6
  analytics: PostHogCoverageDecision;
7
7
  errorTracking: PostHogCoverageDecision;
8
- sessionReplay: PostHogCoverageDecision;
9
8
  featureFlags: PostHogCoverageDecision;
9
+ identity: PostHogCoverageDecision;
10
+ sessionReplay: PostHogCoverageDecision;
10
11
  };
11
12
  server: {
12
13
  analytics: PostHogCoverageDecision;
@@ -14,8 +14,9 @@ function coverageDecisions(coverage) {
14
14
  return [
15
15
  ['browser.analytics', coverage.browser.analytics],
16
16
  ['browser.errorTracking', coverage.browser.errorTracking],
17
- ['browser.sessionReplay', coverage.browser.sessionReplay],
18
17
  ['browser.featureFlags', coverage.browser.featureFlags],
18
+ ['browser.identity', coverage.browser.identity],
19
+ ['browser.sessionReplay', coverage.browser.sessionReplay],
19
20
  ['server.analytics', coverage.server.analytics],
20
21
  ['server.errorTracking', coverage.server.errorTracking],
21
22
  ['server.logs', coverage.server.logs],
@@ -1 +1 @@
1
- {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/posthog/coverage.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,qBAAqB,CAAC,QAAyB;IAC7D,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3D,IAAI,QAAQ,KAAK,IAAI;YAAE,SAAQ;QAC/B,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,+CAA+C,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oCAAoC,CAAC,CAAA;IAC7F,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAyB;IAClD,OAAO;QACL,CAAC,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;QACjD,CAAC,uBAAuB,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QACzD,CAAC,uBAAuB,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QACzD,CAAC,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;QACvD,CAAC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;QAC/C,CAAC,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;QACvD,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC;KACpC,CAAA;AACH,CAAC","sourcesContent":["export type PostHogCoverageDecision = true | { disabled: string }\n\nexport type PostHogCoverage = {\n browser: {\n analytics: PostHogCoverageDecision\n errorTracking: PostHogCoverageDecision\n sessionReplay: PostHogCoverageDecision\n featureFlags: PostHogCoverageDecision\n }\n server: {\n analytics: PostHogCoverageDecision\n errorTracking: PostHogCoverageDecision\n logs: PostHogCoverageDecision\n }\n sourceMaps: PostHogCoverageDecision\n}\n\nexport function definePostHogCoverage(coverage: PostHogCoverage) {\n for (const [area, decision] of coverageDecisions(coverage)) {\n if (decision === true) continue\n if (!decision || typeof decision !== 'object' || typeof decision.disabled !== 'string') {\n throw new Error(`${area} must be enabled or include a disabled reason`)\n }\n if (!decision.disabled.trim()) throw new Error(`${area} disabled reason must not be empty`)\n }\n return coverage\n}\n\nfunction coverageDecisions(coverage: PostHogCoverage): Array<[string, PostHogCoverageDecision]> {\n return [\n ['browser.analytics', coverage.browser.analytics],\n ['browser.errorTracking', coverage.browser.errorTracking],\n ['browser.sessionReplay', coverage.browser.sessionReplay],\n ['browser.featureFlags', coverage.browser.featureFlags],\n ['server.analytics', coverage.server.analytics],\n ['server.errorTracking', coverage.server.errorTracking],\n ['server.logs', coverage.server.logs],\n ['sourceMaps', coverage.sourceMaps],\n ]\n}\n"]}
1
+ {"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/posthog/coverage.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,qBAAqB,CAAC,QAAyB;IAC7D,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3D,IAAI,QAAQ,KAAK,IAAI;YAAE,SAAQ;QAC/B,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,+CAA+C,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oCAAoC,CAAC,CAAA;IAC7F,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAyB;IAClD,OAAO;QACL,CAAC,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;QACjD,CAAC,uBAAuB,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QACzD,CAAC,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;QACvD,CAAC,kBAAkB,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC/C,CAAC,uBAAuB,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QACzD,CAAC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;QAC/C,CAAC,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;QACvD,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC;KACpC,CAAA;AACH,CAAC","sourcesContent":["export type PostHogCoverageDecision = true | { disabled: string }\n\nexport type PostHogCoverage = {\n browser: {\n analytics: PostHogCoverageDecision\n errorTracking: PostHogCoverageDecision\n featureFlags: PostHogCoverageDecision\n identity: PostHogCoverageDecision\n sessionReplay: PostHogCoverageDecision\n }\n server: {\n analytics: PostHogCoverageDecision\n errorTracking: PostHogCoverageDecision\n logs: PostHogCoverageDecision\n }\n sourceMaps: PostHogCoverageDecision\n}\n\nexport function definePostHogCoverage(coverage: PostHogCoverage) {\n for (const [area, decision] of coverageDecisions(coverage)) {\n if (decision === true) continue\n if (!decision || typeof decision !== 'object' || typeof decision.disabled !== 'string') {\n throw new Error(`${area} must be enabled or include a disabled reason`)\n }\n if (!decision.disabled.trim()) throw new Error(`${area} disabled reason must not be empty`)\n }\n return coverage\n}\n\nfunction coverageDecisions(coverage: PostHogCoverage): Array<[string, PostHogCoverageDecision]> {\n return [\n ['browser.analytics', coverage.browser.analytics],\n ['browser.errorTracking', coverage.browser.errorTracking],\n ['browser.featureFlags', coverage.browser.featureFlags],\n ['browser.identity', coverage.browser.identity],\n ['browser.sessionReplay', coverage.browser.sessionReplay],\n ['server.analytics', coverage.server.analytics],\n ['server.errorTracking', coverage.server.errorTracking],\n ['server.logs', coverage.server.logs],\n ['sourceMaps', coverage.sourceMaps],\n ]\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
- import type { PostHogConfig } from 'posthog-js';
2
+ import type { PostHogConfig, Properties } from 'posthog-js';
3
3
  import type { PostHogEnvironment } from './config.js';
4
4
  export declare function PostHogIntegration({ children, environment, fallback, options, }: {
5
5
  children?: ReactNode;
@@ -17,3 +17,21 @@ export declare function PostHogIntegration({ children, environment, fallback, op
17
17
  }) & {
18
18
  children?: ReactNode | undefined;
19
19
  }> | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null | undefined;
20
+ export type BetterAuthUser = {
21
+ id: string;
22
+ };
23
+ export type BetterAuthSession<User extends BetterAuthUser = BetterAuthUser> = {
24
+ user: User;
25
+ };
26
+ export type BetterAuthSessionState<User extends BetterAuthUser = BetterAuthUser> = {
27
+ data?: BetterAuthSession<User> | null;
28
+ error?: unknown;
29
+ isPending: boolean;
30
+ };
31
+ export type BetterAuthReactClient<User extends BetterAuthUser = BetterAuthUser> = {
32
+ useSession: () => BetterAuthSessionState<User>;
33
+ };
34
+ export declare function PostHogBetterAuthIdentity<User extends BetterAuthUser>({ authClient, properties, }: {
35
+ authClient: BetterAuthReactClient<User>;
36
+ properties?: (user: User) => Properties;
37
+ }): null;
@@ -1,5 +1,5 @@
1
- import { PostHogErrorBoundary, PostHogProvider } from '@posthog/react';
2
- import { createElement } from 'react';
1
+ import { PostHogErrorBoundary, PostHogProvider, usePostHog } from '@posthog/react';
2
+ import { createElement, useEffect, useRef } from 'react';
3
3
  import { postHogBrowserOptions } from './client.js';
4
4
  export function PostHogIntegration({ children, environment, fallback = createElement('main', null, 'Something went wrong. Refresh the page to try again.'), options, }) {
5
5
  if (!environment)
@@ -15,4 +15,25 @@ export function PostHogIntegration({ children, environment, fallback = createEle
15
15
  }),
16
16
  }, createElement(PostHogErrorBoundary, { fallback }, children));
17
17
  }
18
+ export function PostHogBetterAuthIdentity({ authClient, properties, }) {
19
+ const session = authClient.useSession();
20
+ const posthog = usePostHog();
21
+ const identified = useRef(undefined);
22
+ const propertiesRef = useRef(properties);
23
+ propertiesRef.current = properties;
24
+ useEffect(() => {
25
+ if (session.isPending || session.error)
26
+ return;
27
+ const user = session.data?.user;
28
+ if (user) {
29
+ posthog.identify(user.id, propertiesRef.current?.(user));
30
+ identified.current = user.id;
31
+ }
32
+ else if (identified.current) {
33
+ posthog.reset();
34
+ identified.current = undefined;
35
+ }
36
+ }, [posthog, session.data?.user, session.error, session.isPending]);
37
+ return null;
38
+ }
18
39
  //# sourceMappingURL=react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/posthog/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,WAAW,EACX,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,sDAAsD,CAAC,EAC9F,OAAO,GAMR;IACC,IAAI,CAAC,WAAW;QAAE,OAAO,QAAQ,CAAA;IACjC,MAAM,gBAAgB,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC/F,OAAO,aAAa,CAClB,eAAe,EACf;QACE,MAAM,EAAE,WAAW,CAAC,YAAY;QAChC,OAAO,EAAE,qBAAqB,CAAC;YAC7B,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC;KACH,EACD,aAAa,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAC5D,CAAA;AACH,CAAC","sourcesContent":["import { PostHogErrorBoundary, PostHogProvider } from '@posthog/react'\nimport { createElement, type ReactNode } from 'react'\nimport type { PostHogConfig } from 'posthog-js'\nimport { postHogBrowserOptions } from './client.js'\nimport type { PostHogEnvironment } from './config.js'\n\nexport function PostHogIntegration({\n children,\n environment,\n fallback = createElement('main', null, 'Something went wrong. Refresh the page to try again.'),\n options,\n}: {\n children?: ReactNode\n environment: PostHogEnvironment | undefined\n fallback?: ReactNode\n options?: Partial<PostHogConfig>\n}) {\n if (!environment) return children\n const tracingHostnames = typeof window === 'undefined' ? undefined : [window.location.hostname]\n return createElement(\n PostHogProvider,\n {\n apiKey: environment.projectToken,\n options: postHogBrowserOptions({\n apiHost: '/ingest',\n uiHost: environment.uiHost,\n ...(tracingHostnames ? { tracingHostnames } : {}),\n ...(options ? { options } : {}),\n }),\n },\n createElement(PostHogErrorBoundary, { fallback }, children),\n )\n}\n"]}
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/posthog/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,WAAW,EACX,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,sDAAsD,CAAC,EAC9F,OAAO,GAMR;IACC,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AAI,CAAC,CAAC,CAAA;YACxD,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAA;QAC9B,CAAC;aAAM,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YAC9B,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,UAAU,CAAC,OAAO,GAAG,SAAS,CAAA;QAChC,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;IAEnE,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { PostHogErrorBoundary, PostHogProvider, usePostHog } from '@posthog/react'\nimport { createElement, type ReactNode, useEffect, useRef } from 'react'\nimport type { PostHogConfig, Properties } from 'posthog-js'\nimport { postHogBrowserOptions } from './client.js'\nimport type { PostHogEnvironment } from './config.js'\n\nexport function PostHogIntegration({\n children,\n environment,\n fallback = createElement('main', null, 'Something went wrong. Refresh the page to try again.'),\n options,\n}: {\n children?: ReactNode\n environment: PostHogEnvironment | undefined\n fallback?: ReactNode\n options?: Partial<PostHogConfig>\n}) {\n if (!environment) return children\n const tracingHostnames = typeof window === 'undefined' ? undefined : [window.location.hostname]\n return createElement(\n PostHogProvider,\n {\n apiKey: environment.projectToken,\n options: postHogBrowserOptions({\n apiHost: '/ingest',\n uiHost: environment.uiHost,\n ...(tracingHostnames ? { tracingHostnames } : {}),\n ...(options ? { options } : {}),\n }),\n },\n createElement(PostHogErrorBoundary, { fallback }, children),\n )\n}\n\nexport type BetterAuthUser = { id: string }\nexport type BetterAuthSession<User extends BetterAuthUser = BetterAuthUser> = { user: User }\nexport type BetterAuthSessionState<User extends BetterAuthUser = BetterAuthUser> = {\n data?: BetterAuthSession<User> | null\n error?: unknown\n isPending: boolean\n}\nexport type BetterAuthReactClient<User extends BetterAuthUser = BetterAuthUser> = {\n useSession: () => BetterAuthSessionState<User>\n}\n\nexport function PostHogBetterAuthIdentity<User extends BetterAuthUser>({\n authClient,\n properties,\n}: {\n authClient: BetterAuthReactClient<User>\n properties?: (user: User) => Properties\n}) {\n const session = authClient.useSession()\n const posthog = usePostHog()\n const identified = useRef<string | undefined>(undefined)\n const propertiesRef = useRef(properties)\n propertiesRef.current = properties\n\n useEffect(() => {\n if (session.isPending || session.error) return\n const user = session.data?.user\n if (user) {\n posthog.identify(user.id, propertiesRef.current?.(user))\n identified.current = user.id\n } else if (identified.current) {\n posthog.reset()\n identified.current = undefined\n }\n }, [posthog, session.data?.user, session.error, session.isPending])\n\n return null\n}\n"]}
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export declare function runPreviewCli(arguments_: string[]): Promise<void>;
@@ -1,7 +1,8 @@
1
- #!/usr/bin/env node
2
1
  import { previewStatusFromEnvironment } from './environment.js';
3
2
  import { reportPreviewStatus } from './github.js';
4
- const { options, status } = previewStatusFromEnvironment(process.argv[2]);
5
- await reportPreviewStatus(options, status);
6
- console.log(`Preview status set to ${status.state}`);
3
+ export async function runPreviewCli(arguments_) {
4
+ const { options, status } = previewStatusFromEnvironment(arguments_[0]);
5
+ await reportPreviewStatus(options, status);
6
+ console.log(`Preview status set to ${status.state}`);
7
+ }
7
8
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/preview/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,4BAA4B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACzE,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC1C,OAAO,CAAC,GAAG,CAAC,yBAAyB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\nimport { previewStatusFromEnvironment } from './environment.js'\nimport { reportPreviewStatus } from './github.js'\n\nconst { options, status } = previewStatusFromEnvironment(process.argv[2])\nawait reportPreviewStatus(options, status)\nconsole.log(`Preview status set to ${status.state}`)\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/preview/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAoB;IACtD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACvE,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC1C,OAAO,CAAC,GAAG,CAAC,yBAAyB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;AACtD,CAAC","sourcesContent":["import { previewStatusFromEnvironment } from './environment.js'\nimport { reportPreviewStatus } from './github.js'\n\nexport async function runPreviewCli(arguments_: string[]): Promise<void> {\n const { options, status } = previewStatusFromEnvironment(arguments_[0])\n await reportPreviewStatus(options, status)\n console.log(`Preview status set to ${status.state}`)\n}\n"]}
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export declare function runRealtimeCli(arguments_: string[]): Promise<void>;
@@ -1,10 +1,11 @@
1
- #!/usr/bin/env node
2
1
  import { parseRealtimeDevArguments, runRealtimeDev } from './dev.js';
3
- try {
4
- await runRealtimeDev(parseRealtimeDevArguments(process.argv.slice(2)));
5
- }
6
- catch (error) {
7
- console.error(error instanceof Error ? error.message : error);
8
- process.exitCode = 1;
2
+ export async function runRealtimeCli(arguments_) {
3
+ try {
4
+ await runRealtimeDev(parseRealtimeDevArguments(arguments_));
5
+ }
6
+ catch (error) {
7
+ console.error(error instanceof Error ? error.message : error);
8
+ process.exitCode = 1;
9
+ }
9
10
  }
10
11
  //# sourceMappingURL=dev-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-cli.js","sourceRoot":"","sources":["../../src/runtime/dev-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEpE,IAAI,CAAC;IACH,MAAM,cAAc,CAAC,yBAAyB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxE,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC7D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { parseRealtimeDevArguments, runRealtimeDev } from './dev.js'\n\ntry {\n await runRealtimeDev(parseRealtimeDevArguments(process.argv.slice(2)))\n} catch (error) {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n}\n"]}
1
+ {"version":3,"file":"dev-cli.js","sourceRoot":"","sources":["../../src/runtime/dev-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEpE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAoB;IACvD,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAC7D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;IACtB,CAAC;AACH,CAAC","sourcesContent":["import { parseRealtimeDevArguments, runRealtimeDev } from './dev.js'\n\nexport async function runRealtimeCli(arguments_: string[]): Promise<void> {\n try {\n await runRealtimeDev(parseRealtimeDevArguments(arguments_))\n } catch (error) {\n console.error(error instanceof Error ? error.message : error)\n process.exitCode = 1\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ras-stack",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "Composable full-stack primitives shared across Richard Solomou's applications.",
5
5
  "keywords": [
6
6
  "authentication",
@@ -17,10 +17,7 @@
17
17
  "url": "git+https://github.com/richardsolomou/ras-stack.git"
18
18
  },
19
19
  "bin": {
20
- "ras-stack-assets": "./dist/build/cli.js",
21
- "ras-stack-policy": "./dist/policy/cli.js",
22
- "ras-stack-preview": "./dist/preview/cli.js",
23
- "ras-stack-realtime": "./dist/runtime/dev-cli.js"
20
+ "ras": "./dist/cli.js"
24
21
  },
25
22
  "files": [
26
23
  "dist",
@@ -151,7 +148,7 @@
151
148
  "format:check": "oxfmt --check .",
152
149
  "test": "vitest run --config vitest.config.ts",
153
150
  "package:check": "node scripts/checkPackedPackage.mjs",
154
- "check": "pnpm format:check && pnpm lint && pnpm config:check && pnpm typecheck && pnpm test && pnpm build && pnpm package:check && pnpm --filter @ras-stack/example-full-stack check && node dist/policy/cli.js check",
151
+ "check": "pnpm format:check && pnpm lint && pnpm config:check && pnpm typecheck && pnpm test && pnpm build && pnpm package:check && pnpm --filter @ras-stack/example-full-stack check && node dist/cli.js policy check",
155
152
  "version-packages": "changeset version"
156
153
  },
157
154
  "dependencies": {