@prisma/cli 3.0.0-dev.93.1 → 3.0.0-dev.95.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.
@@ -1,7 +1,7 @@
1
1
  import { attachCommandDescriptor } from "../../shell/command-meta.js";
2
2
  import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
3
3
  import { configureRuntimeCommand } from "../../shell/runtime.js";
4
- import { runAuthLogin, runAuthLogout, runAuthWhoAmI, runAuthWorkspaceList, runAuthWorkspaceLogout, runAuthWorkspaceSelect, runAuthWorkspaceUse } from "../../controllers/auth.js";
4
+ import { runAuthLogin, runAuthLogout, runAuthWhoAmI, runAuthWorkspaceList, runAuthWorkspaceLogout, runAuthWorkspaceUse } from "../../controllers/auth.js";
5
5
  import { runCommand } from "../../shell/command-runner.js";
6
6
  import { renderAuthSuccess, renderAuthWorkspaceList, renderAuthWorkspaceLogout, renderAuthWorkspaceUse, serializeAuthWorkspaceList, serializeAuthWorkspaceLogout, serializeAuthWorkspaceUse } from "../../presenters/auth.js";
7
7
  import { Command, Option } from "commander";
@@ -54,7 +54,6 @@ function createAuthWorkspaceCommand(runtime) {
54
54
  addCompactGlobalFlags(workspace);
55
55
  workspace.addCommand(createAuthWorkspaceListCommand(runtime));
56
56
  workspace.addCommand(createAuthWorkspaceUseCommand(runtime));
57
- workspace.addCommand(createAuthWorkspaceSelectCommand(runtime));
58
57
  workspace.addCommand(createAuthWorkspaceLogoutCommand(runtime));
59
58
  return workspace;
60
59
  }
@@ -69,17 +68,6 @@ function createAuthWorkspaceListCommand(runtime) {
69
68
  });
70
69
  return command;
71
70
  }
72
- function createAuthWorkspaceSelectCommand(runtime) {
73
- const command = attachCommandDescriptor(configureRuntimeCommand(new Command("select"), runtime), "auth.workspace.select");
74
- addGlobalFlags(command);
75
- command.action(async (options) => {
76
- await runCommand(runtime, "auth.workspace.select", options, (context) => runAuthWorkspaceSelect(context), {
77
- renderHuman: (context, descriptor, result) => renderAuthWorkspaceUse(context, descriptor, result),
78
- renderJson: (result) => serializeAuthWorkspaceUse(result)
79
- });
80
- });
81
- return command;
82
- }
83
71
  function createAuthWorkspaceLogoutCommand(runtime) {
84
72
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logout"), runtime), "auth.workspace.logout");
85
73
  command.argument("<id-or-name>", "Workspace id or exact name");
@@ -94,7 +82,7 @@ function createAuthWorkspaceLogoutCommand(runtime) {
94
82
  }
95
83
  function createAuthWorkspaceUseCommand(runtime) {
96
84
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("use"), runtime), "auth.workspace.use");
97
- command.argument("<id-or-name>", "Workspace id or exact name");
85
+ command.argument("[id-or-name]", "Workspace id or exact name");
98
86
  addGlobalFlags(command);
99
87
  command.action(async (workspaceRef, options) => {
100
88
  await runCommand(runtime, "auth.workspace.use", options, (context) => runAuthWorkspaceUse(context, typeof workspaceRef === "string" ? workspaceRef : void 0), {
@@ -42,20 +42,15 @@ async function runAuthWorkspaceList(context) {
42
42
  };
43
43
  }
44
44
  async function runAuthWorkspaceUse(context, workspaceRef) {
45
- if (!workspaceRef?.trim()) throw usageError("Workspace required", "auth workspace use needs a workspace id or cached workspace name.", "Pass a workspace from prisma-cli auth workspace list.", ["prisma-cli auth workspace list"], "auth");
45
+ const trimmedWorkspaceRef = workspaceRef?.trim();
46
+ const selectedWorkspaceRef = trimmedWorkspaceRef ? trimmedWorkspaceRef : await selectWorkspaceSession(context);
46
47
  return {
47
48
  command: "auth.workspace.use",
48
- result: isRealMode(context) ? await useRealAuthWorkspace(context, workspaceRef) : await createAuthUseCases(createCliUseCaseGateways(context)).useWorkspace(workspaceRef),
49
+ result: isRealMode(context) ? await useRealAuthWorkspace(context, selectedWorkspaceRef) : await createAuthUseCases(createCliUseCaseGateways(context)).useWorkspace(selectedWorkspaceRef),
49
50
  warnings: [],
50
51
  nextSteps: ["prisma-cli auth whoami", "prisma-cli project list"]
51
52
  };
52
53
  }
53
- async function runAuthWorkspaceSelect(context) {
54
- return {
55
- ...await runAuthWorkspaceUse(context, await selectWorkspaceSession(context)),
56
- command: "auth.workspace.select"
57
- };
58
- }
59
54
  async function runAuthWorkspaceLogout(context, workspaceRef) {
60
55
  if (!workspaceRef?.trim()) throw usageError("Workspace required", "auth workspace logout needs a workspace id or cached workspace name.", "Pass a workspace from prisma-cli auth workspace list.", ["prisma-cli auth workspace list"], "auth");
61
56
  const result = isRealMode(context) ? await logoutRealAuthWorkspace(context, workspaceRef) : await createAuthUseCases(createCliUseCaseGateways(context)).logoutWorkspace(workspaceRef);
@@ -167,7 +162,7 @@ async function selectWorkspaceSession(context) {
167
162
  const workspaces = (realMode ? await listRealAuthWorkspaces(context) : await createAuthUseCases(createCliUseCaseGateways(context)).listWorkspaces()).workspaces.filter((workspace) => workspace.switchable);
168
163
  if (workspaces.length === 0) throw usageError("No authenticated workspaces", "There are no local OAuth workspace sessions to select.", "Run prisma-cli auth login and authorize a workspace.", ["prisma-cli auth login"], "auth");
169
164
  if (workspaces.length === 1) return workspaces[0].id;
170
- if (!canPrompt(context)) throw usageError("Interactive workspace selection unavailable", "auth workspace select needs an interactive terminal when more than one workspace is available.", "Run prisma-cli auth workspace use <id-or-name> with a workspace from prisma-cli auth workspace list.", ["prisma-cli auth workspace list"], "auth");
165
+ if (!canPrompt(context)) throw usageError("Interactive workspace selection unavailable", "auth workspace use needs an interactive terminal when no workspace is provided and more than one workspace is available.", "Run prisma-cli auth workspace use <id-or-name> with a workspace from prisma-cli auth workspace list.", ["prisma-cli auth workspace list"], "auth");
171
166
  return (await createSelectPromptPort(context).select({
172
167
  message: "Select a workspace",
173
168
  choices: workspaces.map((workspace) => ({
@@ -242,4 +237,4 @@ function createAuthSuccess(command, result, nextSteps) {
242
237
  };
243
238
  }
244
239
  //#endregion
245
- export { requireAuthenticatedAuthState, runAuthLogin, runAuthLogout, runAuthWhoAmI, runAuthWorkspaceList, runAuthWorkspaceLogout, runAuthWorkspaceSelect, runAuthWorkspaceUse };
240
+ export { requireAuthenticatedAuthState, runAuthLogin, runAuthLogout, runAuthWhoAmI, runAuthWorkspaceList, runAuthWorkspaceLogout, runAuthWorkspaceUse };
@@ -60,7 +60,7 @@ const DESCRIPTORS = [
60
60
  description: "Manage local authenticated workspaces",
61
61
  examples: [
62
62
  "prisma-cli auth workspace list",
63
- "prisma-cli auth workspace select",
63
+ "prisma-cli auth workspace use",
64
64
  "prisma-cli auth workspace use wksp_123",
65
65
  "prisma-cli auth workspace logout wksp_123"
66
66
  ]
@@ -85,18 +85,11 @@ const DESCRIPTORS = [
85
85
  "use"
86
86
  ],
87
87
  description: "Switch the local CLI workspace",
88
- examples: ["prisma-cli auth workspace use wksp_123", "prisma-cli auth workspace use \"Acme Inc\""]
89
- },
90
- {
91
- id: "auth.workspace.select",
92
- path: [
93
- "prisma",
94
- "auth",
95
- "workspace",
96
- "select"
97
- ],
98
- description: "Interactively select the local CLI workspace",
99
- examples: ["prisma-cli auth workspace select"]
88
+ examples: [
89
+ "prisma-cli auth workspace use",
90
+ "prisma-cli auth workspace use wksp_123",
91
+ "prisma-cli auth workspace use \"Acme Inc\""
92
+ ]
100
93
  },
101
94
  {
102
95
  id: "auth.workspace.logout",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli",
3
- "version": "3.0.0-dev.93.1",
3
+ "version": "3.0.0-dev.95.1",
4
4
  "description": "Command-line interface for the Prisma Developer Platform.",
5
5
  "type": "module",
6
6
  "bin": {