@rigkit/provider-gcloud-cli 0.2.2 → 0.2.3

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
@@ -14,11 +14,13 @@ import {
14
14
 
15
15
  const app = workflow("example", {
16
16
  providers: {
17
- gcloudConfig: copyGcloudConfig.provider(),
17
+ gcloudConfig: copyGcloudConfig.provider({
18
+ requireAuth: true,
19
+ }),
18
20
  },
19
21
  });
20
22
 
21
- // Inside workspace.onOpen:
23
+ // Inside a workspace operation:
22
24
  const gcloudConfigFiles = await providers.gcloudConfig.configFiles();
23
25
  for (const step of gcloudConfigCopyInjectionSteps(gcloudConfigFiles)) {
24
26
  await vm.exec(step.command, { name: step.name, env: step.env });
@@ -28,4 +30,4 @@ const verified = await vm.probe(gcloudCopiedConfigReadyCommand());
28
30
  if (!verified.ok) throw new Error("gcloud did not accept the copied config files");
29
31
  ```
30
32
 
31
- If local `gcloud` is missing, provider startup fails with the Google Cloud SDK install URL. If it is not authenticated, startup asks the user to run `gcloud auth login`.
33
+ By default, provider startup requires local `gcloud` to be installed and authenticated before Rigkit runs project commands. If local `gcloud` is missing, startup fails with the Google Cloud SDK install URL. If it is not authenticated, startup asks the user to run `gcloud auth login`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigkit/provider-gcloud-cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,8 +17,8 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "zod": "^4",
20
- "@rigkit/engine": "0.2.2",
21
- "@rigkit/sdk": "0.2.2"
20
+ "@rigkit/engine": "0.2.3",
21
+ "@rigkit/sdk": "0.2.3"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/bun": "latest",
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  assertLocalGcloudReady,
6
6
  createGcloudConfigCopyController,
7
7
  GCLOUD_CONFIG_COPY_PROVIDER_ID,
8
+ requiresLocalGcloudAuth,
8
9
  type GcloudConfigCopyConfig,
9
10
  type GcloudConfigCopyRuntime,
10
11
  } from "./provider.ts";
@@ -12,6 +13,7 @@ import { createGcloudAuthStore } from "./store.ts";
12
13
 
13
14
  const gcloudConfigCopyProviderConfigSchema = z.object({
14
15
  command: z.optional(z.string()),
16
+ requireAuth: z.optional(z.boolean()),
15
17
  key: z.optional(z.string()),
16
18
  account: z.optional(z.string()),
17
19
  scopes: z.optional(z.array(z.string())),
@@ -42,7 +44,9 @@ export const gcloudConfigCopyProviderPlugin: BaseProviderPlugin = {
42
44
  providerId: GCLOUD_CONFIG_COPY_PROVIDER_ID,
43
45
  async createProvider({ provider, storage }) {
44
46
  const config = parseGcloudConfigCopyProviderConfig(provider.config);
45
- await assertLocalGcloudReady(config);
47
+ if (requiresLocalGcloudAuth(config)) {
48
+ await assertLocalGcloudReady(config);
49
+ }
46
50
  return createGcloudConfigCopyController(config, createGcloudAuthStore(storage));
47
51
  },
48
52
  };
@@ -53,6 +57,7 @@ export {
53
57
  DEFAULT_GCLOUD_INSTALL_URL,
54
58
  GCLOUD_CONFIG_COPY_PROVIDER_ID,
55
59
  createGcloudConfigCopyController,
60
+ requiresLocalGcloudAuth,
56
61
  } from "./provider.ts";
57
62
  export {
58
63
  DEFAULT_GCLOUD_ACCESS_TOKEN_EXPIRES_AT_PATH,
@@ -3,10 +3,57 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { createStateStore } from "@rigkit/engine";
6
- import { createGcloudConfigCopyController, assertLocalGcloudReady, type GcloudCommandRunner } from "./provider.ts";
6
+ import { gcloudConfigCopyProviderPlugin } from "./index.ts";
7
+ import {
8
+ GCLOUD_CONFIG_COPY_PROVIDER_ID,
9
+ assertLocalGcloudReady,
10
+ createGcloudConfigCopyController,
11
+ requiresLocalGcloudAuth,
12
+ type GcloudCommandRunner,
13
+ } from "./provider.ts";
7
14
  import { createGcloudAuthStore } from "./store.ts";
8
15
 
9
16
  describe("local gcloud config copy provider", () => {
17
+ test("requires startup auth by default", async () => {
18
+ expect(requiresLocalGcloudAuth({})).toBe(true);
19
+ expect(requiresLocalGcloudAuth({ requireAuth: true })).toBe(true);
20
+
21
+ const projectDir = mkdtempSync(join(tmpdir(), "rigkit-gcloud-"));
22
+ const state = createStateStore({ projectDir });
23
+ await state.syncSchema();
24
+
25
+ await expect(
26
+ gcloudConfigCopyProviderPlugin.createProvider({
27
+ provider: {
28
+ providerId: GCLOUD_CONFIG_COPY_PROVIDER_ID,
29
+ config: { command: join(projectDir, "missing-gcloud") },
30
+ },
31
+ storage: state.providerStorage("gcloud.config.copy"),
32
+ }),
33
+ ).rejects.toThrow("Local gcloud CLI is required");
34
+ });
35
+
36
+ test("can skip startup auth explicitly", async () => {
37
+ expect(requiresLocalGcloudAuth({ requireAuth: false })).toBe(false);
38
+
39
+ const projectDir = mkdtempSync(join(tmpdir(), "rigkit-gcloud-"));
40
+ const state = createStateStore({ projectDir });
41
+ await state.syncSchema();
42
+
43
+ const controller = await gcloudConfigCopyProviderPlugin.createProvider({
44
+ provider: {
45
+ providerId: GCLOUD_CONFIG_COPY_PROVIDER_ID,
46
+ config: {
47
+ command: join(projectDir, "missing-gcloud"),
48
+ requireAuth: false,
49
+ },
50
+ },
51
+ storage: state.providerStorage("gcloud.config.copy"),
52
+ });
53
+
54
+ expect(controller.providerId).toBe(GCLOUD_CONFIG_COPY_PROVIDER_ID);
55
+ });
56
+
10
57
  test("fails startup when local gcloud is missing", async () => {
11
58
  const runner: GcloudCommandRunner = async () => ({
12
59
  stdout: "",
package/src/provider.ts CHANGED
@@ -24,6 +24,7 @@ const DEFAULT_ACCESS_TOKEN_LIFETIME_SECONDS = 55 * 60;
24
24
 
25
25
  export type GcloudConfigCopyConfig = {
26
26
  command?: string;
27
+ requireAuth?: boolean;
27
28
  key?: string;
28
29
  account?: string;
29
30
  scopes?: readonly string[];
@@ -113,6 +114,10 @@ export async function assertLocalGcloudReady(
113
114
  }
114
115
  }
115
116
 
117
+ export function requiresLocalGcloudAuth(config: GcloudConfigCopyConfig): boolean {
118
+ return config.requireAuth ?? true;
119
+ }
120
+
116
121
  async function freshAccessToken(input: {
117
122
  config: GcloudConfigCopyConfig;
118
123
  store: GcloudAuthStore;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RIGKIT_PROVIDER_GCLOUD_CLI_VERSION = "0.2.2";
1
+ export const RIGKIT_PROVIDER_GCLOUD_CLI_VERSION = "0.2.3";