@ollie-shop/cli 1.1.0 → 1.2.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.
package/src/index.tsx CHANGED
@@ -1,8 +1,11 @@
1
1
  import { render } from "ink";
2
2
  import { App } from "./cli.js";
3
+ import { businessRuleCommand } from "./commands/business-rule-cmd.js";
3
4
  import { componentCommand } from "./commands/component-cmd.js";
5
+ import { deployCommand } from "./commands/deploy-cmd.js";
4
6
  import { initCommand } from "./commands/init-cmd.js";
5
7
  import { schemaCommand } from "./commands/schema-cmd.js";
8
+ import { statusCommand } from "./commands/status-cmd.js";
6
9
  import { storeCommand } from "./commands/store-cmd.js";
7
10
  import { versionCommand } from "./commands/version-cmd.js";
8
11
  import { whoamiCommand } from "./commands/whoami.js";
@@ -17,8 +20,11 @@ const AGENT_COMMANDS: Record<
17
20
  store: storeCommand,
18
21
  version: versionCommand,
19
22
  component: componentCommand,
23
+ "business-rule": businessRuleCommand,
20
24
  schema: schemaCommand,
21
25
  init: initCommand,
26
+ deploy: deployCommand,
27
+ status: statusCommand,
22
28
  };
23
29
 
24
30
  const parsed = parseArgs(process.argv);
@@ -1,15 +1,10 @@
1
1
  import { type SupabaseClient, createClient } from "@supabase/supabase-js";
2
2
  import { getCredentials } from "./auth.js";
3
3
 
4
- function requireEnv(name: string): string {
5
- const value = process.env[name];
6
- if (!value) {
7
- throw new Error(
8
- `Missing required environment variable: ${name}. Set it in your .env file or shell.`,
9
- );
10
- }
11
- return value;
12
- }
4
+ // tsup inlines these from CI env vars at build time (see tsup.config.ts).
5
+ declare const __OLLIE_SUPABASE_URL__: string;
6
+ declare const __OLLIE_SUPABASE_ANON_KEY__: string;
7
+ declare const __OLLIE_BUILDER_URL__: string;
13
8
 
14
9
  export async function getAuthenticatedClient(): Promise<SupabaseClient> {
15
10
  const credentials = await getCredentials();
@@ -17,8 +12,9 @@ export async function getAuthenticatedClient(): Promise<SupabaseClient> {
17
12
  throw new Error("Not authenticated. Run `ollieshop login` first.");
18
13
  }
19
14
 
20
- const supabaseUrl = requireEnv("OLLIE_SUPABASE_URL");
21
- const supabaseAnonKey = requireEnv("OLLIE_SUPABASE_ANON_KEY");
15
+ const supabaseUrl = process.env.OLLIE_SUPABASE_URL || __OLLIE_SUPABASE_URL__;
16
+ const supabaseAnonKey =
17
+ process.env.OLLIE_SUPABASE_ANON_KEY || __OLLIE_SUPABASE_ANON_KEY__;
22
18
 
23
19
  const client = createClient(supabaseUrl, supabaseAnonKey, {
24
20
  auth: {
@@ -35,6 +31,18 @@ export async function getAuthenticatedClient(): Promise<SupabaseClient> {
35
31
  return client;
36
32
  }
37
33
 
34
+ export function getBuilderUrl(): string {
35
+ return process.env.OLLIE_BUILDER_URL || __OLLIE_BUILDER_URL__;
36
+ }
37
+
38
+ export async function getAuthToken(): Promise<string> {
39
+ const credentials = await getCredentials();
40
+ if (!credentials) {
41
+ throw new Error("Not authenticated. Run `ollieshop login` first.");
42
+ }
43
+ return credentials.accessToken;
44
+ }
45
+
38
46
  export async function getOrganizationId(
39
47
  client: SupabaseClient,
40
48
  ): Promise<string> {
package/tsup.config.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { defineConfig } from "tsup";
2
2
 
3
+ // CI injects SUPABASE_URL/SUPABASE_ANON_KEY/BUILDER_URL from GH Actions vars;
4
+ // locally they're empty and the CLI falls back to runtime process.env.
5
+ const env = (k: string) => JSON.stringify(process.env[k] ?? "");
6
+
3
7
  export default defineConfig({
4
8
  entry: ["src/index.tsx"],
5
9
  format: ["esm"],
@@ -7,7 +11,10 @@ export default defineConfig({
7
11
  dts: false,
8
12
  clean: true,
9
13
  sourcemap: false,
10
- banner: {
11
- js: "#!/usr/bin/env node",
14
+ banner: { js: "#!/usr/bin/env node" },
15
+ define: {
16
+ __OLLIE_SUPABASE_URL__: env("SUPABASE_URL"),
17
+ __OLLIE_SUPABASE_ANON_KEY__: env("SUPABASE_ANON_KEY"),
18
+ __OLLIE_BUILDER_URL__: env("BUILDER_URL"),
12
19
  },
13
20
  });