@zuplo/cli 1.135.0 → 1.137.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/dist/cmds/link.js CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6247c8c4-d880-5d58-a70d-da8c9cd6a68a")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0be777a5-8b5e-574a-8780-387d75ffa1a8")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { configure } from "../common/middleware/user-configuration.js";
5
5
  import { identify } from "../common/middleware/user-identification.js";
6
6
  import setBlocking from "../common/output.js";
7
- import { validLinkDirectoryValidator } from "../common/validators/file-system-validator.js";
7
+ import { ZuploProjectValidator } from "../common/validators/file-system-validator.js";
8
8
  import { YargsChecker } from "../common/validators/lib.js";
9
9
  import { link } from "../link/handler.js";
10
10
  export default {
@@ -23,10 +23,6 @@ export default {
23
23
  type: "string",
24
24
  describe: "The API Key from Zuplo",
25
25
  envVar: "API_KEY",
26
- })
27
- .option("account", {
28
- type: "string",
29
- describe: "The account name",
30
26
  })
31
27
  .option("project", {
32
28
  type: "string",
@@ -39,7 +35,7 @@ export default {
39
35
  .demandOption(["api-key"])
40
36
  .middleware([setBlocking, configure, identify])
41
37
  .check(async (argv) => {
42
- return await new YargsChecker(validLinkDirectoryValidator).check(argv);
38
+ return await new YargsChecker(new ZuploProjectValidator()).check(argv);
43
39
  });
44
40
  },
45
41
  handler: async (argv) => {
@@ -48,4 +44,4 @@ export default {
48
44
  },
49
45
  };
50
46
  //# sourceMappingURL=link.js.map
51
- //# debugId=6247c8c4-d880-5d58-a70d-da8c9cd6a68a
47
+ //# debugId=0be777a5-8b5e-574a-8780-387d75ffa1a8
@@ -1,11 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="06344ac3-9b00-5aab-b199-3e6faa6f3a3d")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9e5192b9-6633-50a5-9d82-31772de9bdcc")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { identify } from "../common/middleware/user-identification.js";
5
5
  import setBlocking from "../common/output.js";
6
6
  import { login } from "../login/handler.js";
7
7
  export default {
8
- desc: "Authenticates the user",
8
+ desc: false,
9
9
  command: "login",
10
10
  builder: (yargs) => {
11
11
  return yargs
@@ -21,4 +21,4 @@ export default {
21
21
  },
22
22
  };
23
23
  //# sourceMappingURL=login.js.map
24
- //# debugId=06344ac3-9b00-5aab-b199-3e6faa6f3a3d
24
+ //# debugId=9e5192b9-6633-50a5-9d82-31772de9bdcc
@@ -1,12 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ec896cd1-5086-5370-b8b3-2b5276946dee")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a750d299-a353-5bcd-b91f-5638e7666ba6")}catch(e){}}();
3
3
  import fg from "fast-glob";
4
4
  import { existsSync, readdirSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { simpleGit } from "simple-git";
7
7
  import { TEST_IN_FOLDER } from "../constants.js";
8
8
  import { CompositeValidator } from "./lib.js";
9
- import { IsZupLinkInvocableValidator } from "./login-state-validator.js";
10
9
  import { ProjectIsSetValidator } from "./project-name-validator.js";
11
10
  export class NotAGitRepoError extends Error {
12
11
  constructor() {
@@ -161,6 +160,5 @@ export class ZuploProjectHasTestsValidator {
161
160
  }
162
161
  export const validDeployDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new GitVersionControlValidator(), new GitCommitValidator(), new GitBranchValidator(), new GitRemoteValidator(), new ProjectIsSetValidator());
163
162
  export const validTestDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());
164
- export const validLinkDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new IsZupLinkInvocableValidator());
165
163
  //# sourceMappingURL=file-system-validator.js.map
166
- //# debugId=ec896cd1-5086-5370-b8b3-2b5276946dee
164
+ //# debugId=a750d299-a353-5bcd-b91f-5638e7666ba6
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="925b9d73-a4de-58c0-8f9c-d757c8155db7")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5c4fd488-f729-519e-94c7-406abc7a3013")}catch(e){}}();
3
3
  import dotenv from "dotenv";
4
4
  import { cpSync, existsSync, readFileSync } from "node:fs";
5
5
  import { join, relative, resolve } from "node:path";
@@ -27,7 +27,7 @@ export async function compile(argv) {
27
27
  process.env.__ZUPLO_CONFIG = btoa(JSON.stringify(config));
28
28
  const core = await import("@zuplo/core");
29
29
  const zupPort = argv.port;
30
- await core.default.compileWorkerdServer({
30
+ await core.compileWorkerdServer({
31
31
  sourceDirectory,
32
32
  port: zupPort,
33
33
  binaryName: argv["binary-name"],
@@ -44,4 +44,4 @@ export async function compile(argv) {
44
44
  printDiagnosticsToConsole(`The binary is available at ${sourceDirectory}/dist/${argv["binary-name"]}`);
45
45
  }
46
46
  //# sourceMappingURL=handler.js.map
47
- //# debugId=925b9d73-a4de-58c0-8f9c-d757c8155db7
47
+ //# debugId=5c4fd488-f729-519e-94c7-406abc7a3013
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cb40a32c-281e-5053-b199-7372a7cf977b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fe162c2d-58d1-5c9a-908d-f03546eabbc5")}catch(e){}}();
3
3
  import { readFileSync } from "node:fs";
4
4
  import { parse } from "node:path";
5
5
  import { MAX_PRETTY_BRANCH_NAME as MAX_PRETTY_BRANCH_LENGTH } from "../common/constants.js";
@@ -66,7 +66,7 @@ async function deployToSaas(argv) {
66
66
  }
67
67
  }
68
68
  async function deployToSelfHosted(argv) {
69
- let endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
69
+ const endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
70
70
  const archiveMetadata = await archive(argv);
71
71
  logger.debug(`Tarball created locally at ${archiveMetadata}`);
72
72
  const { project } = argv;
@@ -102,7 +102,7 @@ async function deployToSelfHosted(argv) {
102
102
  }
103
103
  }
104
104
  else {
105
- logger.error(JSON.stringify(await uploadUrlResponse.json(), null, 2), "Failed to upload to self-hosted build endpoint");
105
+ logger.error(await uploadUrlResponse.text(), "Failed to upload to self-hosted build endpoint");
106
106
  await printCriticalFailureToConsoleAndExit("Error: Failed to upload to self-hosted build endpoint");
107
107
  }
108
108
  }
@@ -117,4 +117,4 @@ export const getPrettyBranch = (branch) => {
117
117
  .substring(0, MAX_PRETTY_BRANCH_LENGTH));
118
118
  };
119
119
  //# sourceMappingURL=handler.js.map
120
- //# debugId=cb40a32c-281e-5053-b199-7372a7cf977b
120
+ //# debugId=fe162c2d-58d1-5c9a-908d-f03546eabbc5
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="249e5ca0-cf2e-5cef-a5c8-0d053825f965")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="578699eb-40b5-5250-9349-02c17f8b59b6")}catch(e){}}();
3
3
  import dotenv from "dotenv";
4
4
  import { cpSync, existsSync, readFileSync } from "node:fs";
5
5
  import { join, relative, resolve } from "node:path";
@@ -41,19 +41,19 @@ export async function dev(argv) {
41
41
  const zupDebugPort = argv.debugPort;
42
42
  const isZupPortAvailable = await isPortAvailable("localhost", zupPort);
43
43
  if (!isZupPortAvailable) {
44
- printCriticalFailureToConsoleAndExit(`Port ${zupPort} is already in use. Please specify a different port using --port.`);
44
+ await printCriticalFailureToConsoleAndExit(`Port ${zupPort} is already in use. Please specify a different port using --port.`);
45
45
  }
46
46
  const isZupEditorPortAvailable = await isPortAvailable("localhost", zupEditorPort);
47
47
  if (!isZupEditorPortAvailable) {
48
- printCriticalFailureToConsoleAndExit(`Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`);
48
+ await printCriticalFailureToConsoleAndExit(`Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`);
49
49
  }
50
50
  if (zupDebugPort) {
51
51
  const isZupDebugPortAvailable = await isPortAvailable("localhost", zupDebugPort);
52
52
  if (!isZupDebugPortAvailable) {
53
- printCriticalFailureToConsoleAndExit(`Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`);
53
+ await printCriticalFailureToConsoleAndExit(`Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`);
54
54
  }
55
55
  }
56
- await core.default.startDevServer({
56
+ await core.startDevServer({
57
57
  sourceDirectory,
58
58
  port: zupPort,
59
59
  debugPort: argv.debugPort ?? undefined,
@@ -102,4 +102,4 @@ export async function dev(argv) {
102
102
  });
103
103
  }
104
104
  //# sourceMappingURL=handler.js.map
105
- //# debugId=249e5ca0-cf2e-5cef-a5c8-0d053825f965
105
+ //# debugId=578699eb-40b5-5250-9349-02c17f8b59b6
@@ -1,70 +1,40 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ed7a03fb-41e9-565b-95ab-4e4d54930128")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f5e0af3e-c906-5b69-ba89-acd89c389920")}catch(e){}}();
3
3
  import { select } from "@inquirer/prompts";
4
- import { readFile } from "node:fs/promises";
5
- import { join } from "node:path";
6
- import { ZUPLO_AUTH_FILE_NAME } from "../common/constants.js";
7
4
  import { logger } from "../common/logger.js";
8
5
  import { printCriticalFailureToConsoleAndExit, printResultToConsoleAndExitGracefully, textOrJson, } from "../common/output.js";
9
6
  import settings from "../common/settings.js";
10
- import { ZUPLO_XDG_STATE_HOME } from "../common/xdg/lib.js";
11
7
  import { pullSystemConfig, safeMergeConfig } from "./populate.js";
12
- function prettyPrintEnvironmentPrompt(env) {
13
- const name = env.name;
8
+ function prettyPrintEnvironmentPrompt(env, hasSingleDevelopmentInstance) {
14
9
  let environmentType = env.environmentType.toLowerCase();
15
10
  let branchName = env.branchName;
11
+ let name = env.name;
16
12
  switch (environmentType) {
17
13
  case "working-copy":
18
14
  case "working_copy":
19
- environmentType = "development";
20
- branchName = "(via portal.zuplo.com)";
21
- break;
15
+ case "development":
16
+ if (hasSingleDevelopmentInstance) {
17
+ name = "Default for local development";
18
+ environmentType = "development";
19
+ branchName = "";
20
+ return `${name} (${environmentType})`;
21
+ }
22
+ else {
23
+ environmentType = "development";
24
+ branchName = "";
25
+ return `${name} (${environmentType})`;
26
+ }
22
27
  }
23
- return `${env.name} (${environmentType}, ${branchName})`;
28
+ return `${name} (${environmentType}, ${branchName})`;
24
29
  }
25
30
  export async function link(argv) {
31
+ const account = argv.account;
26
32
  let environment = argv.environment;
27
- let authJson = undefined;
28
- if (!environment) {
29
- const rawAuth = await readFile(join(ZUPLO_XDG_STATE_HOME, ZUPLO_AUTH_FILE_NAME), "utf-8");
30
- authJson = JSON.parse(rawAuth);
31
- }
32
- let account = argv.account;
33
- if (!environment && !account) {
34
- const accountResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts`, {
35
- headers: {
36
- authorization: `Bearer ${authJson.access_token}`,
37
- },
38
- });
39
- if (!accountResponse.ok) {
40
- logger.error({
41
- status: accountResponse.status,
42
- statusText: accountResponse.statusText,
43
- response: textOrJson(await accountResponse.text()),
44
- }, "Failed to list accounts.");
45
- await printCriticalFailureToConsoleAndExit("Error: Failed to list your accounts. Try again later.");
46
- }
47
- const accountJson = (await accountResponse.json());
48
- if (accountJson.length === 1) {
49
- account = accountJson[0].name;
50
- }
51
- else {
52
- account = await select({
53
- message: "Select the account to work with",
54
- choices: accountJson.map((acc) => {
55
- return {
56
- name: acc.name,
57
- value: acc.name,
58
- };
59
- }),
60
- });
61
- }
62
- }
63
33
  let project = argv.project;
64
34
  if (!environment && !project) {
65
- const projectResponse = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts/${account}/projects`, {
35
+ const projectResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/projects`, {
66
36
  headers: {
67
- authorization: `Bearer ${authJson.access_token}`,
37
+ authorization: `Bearer ${argv["api-key"]}`,
68
38
  },
69
39
  });
70
40
  if (!projectResponse.ok) {
@@ -92,30 +62,55 @@ export async function link(argv) {
92
62
  }
93
63
  }
94
64
  if (!environment) {
95
- const environmentResponseFromZuploAPI = await fetch(`${settings.ZUPLO_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
96
- headers: {
97
- authorization: `Bearer ${authJson.access_token}`,
98
- },
99
- });
100
- const environmentJsonFromZuploAPI = (await environmentResponseFromZuploAPI.json());
101
- const environmentResponseFromDeveloperAPI = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
65
+ const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;
66
+ const queryParams = {
67
+ accountName: account,
68
+ projectName: project,
69
+ };
70
+ const url = new URL(baseUrl);
71
+ url.search = new URLSearchParams(queryParams).toString();
72
+ let environmentResponseFromDeveloperAPI = await fetch(url, {
102
73
  headers: {
103
74
  authorization: `Bearer ${argv["api-key"]}`,
104
75
  },
105
76
  });
106
- const environmentJsonFromDeveloperAPI = (await environmentResponseFromDeveloperAPI.json());
107
- const environments = Object.assign({}, environmentJsonFromZuploAPI.data
108
- .map((env) => {
109
- return {
110
- [prettyPrintEnvironmentPrompt(env)]: env.name,
111
- };
112
- })
113
- .reduce((acc, curr) => {
114
- return { ...acc, ...curr };
115
- }), environmentJsonFromDeveloperAPI.data
77
+ let environmentJsonFromDeveloperAPI = (await environmentResponseFromDeveloperAPI.json());
78
+ let numDevelopmentEnvironments = environmentJsonFromDeveloperAPI.data.filter((env) => {
79
+ return env.environmentType === "development";
80
+ }).length;
81
+ if (numDevelopmentEnvironments <= 0) {
82
+ const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {
83
+ method: "POST",
84
+ headers: {
85
+ authorization: `Bearer ${argv["api-key"]}`,
86
+ "Content-Type": "application/json",
87
+ },
88
+ body: JSON.stringify({
89
+ accountName: account,
90
+ projectName: project,
91
+ environmentType: "development",
92
+ }),
93
+ });
94
+ if (!createDevelopmenEnvironmentResponse.ok) {
95
+ logger.debug({
96
+ status: createDevelopmenEnvironmentResponse.status,
97
+ statusText: createDevelopmenEnvironmentResponse.statusText,
98
+ }, "Failed to create a new instance of development environment");
99
+ await printCriticalFailureToConsoleAndExit("Failed to create a new development environment. Please try again later.");
100
+ }
101
+ numDevelopmentEnvironments++;
102
+ environmentResponseFromDeveloperAPI = await fetch(url, {
103
+ headers: {
104
+ authorization: `Bearer ${argv["api-key"]}`,
105
+ },
106
+ });
107
+ environmentJsonFromDeveloperAPI =
108
+ (await environmentResponseFromDeveloperAPI.json());
109
+ }
110
+ const environments = Object.assign({}, environmentJsonFromDeveloperAPI.data
116
111
  .map((env) => {
117
112
  return {
118
- [prettyPrintEnvironmentPrompt(env)]: env.name,
113
+ [prettyPrintEnvironmentPrompt(env, numDevelopmentEnvironments == 1)]: env.name,
119
114
  };
120
115
  })
121
116
  .reduce((acc, curr) => {
@@ -146,4 +141,4 @@ Successfully linked your local directory to the ${project} project in the ${acco
146
141
  .env.zuplo and zuplo.jsonc have been updated with the new values.`);
147
142
  }
148
143
  //# sourceMappingURL=handler.js.map
149
- //# debugId=ed7a03fb-41e9-565b-95ab-4e4d54930128
144
+ //# debugId=f5e0af3e-c906-5b69-ba89-acd89c389920
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9bf817d9-a39a-5f35-9cdf-764d79d64533")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f2551837-2c92-5d06-a4ed-dc11de482182")}catch(e){}}();
3
3
  import { logger } from "../common/logger.js";
4
4
  import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, textOrJson, } from "../common/output.js";
5
5
  import settings from "../common/settings.js";
@@ -36,7 +36,7 @@ async function listFromSaas(argv) {
36
36
  }
37
37
  }
38
38
  async function listFromSelfHosted(argv) {
39
- let endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
39
+ const endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
40
40
  const listResponse = await fetch(`${endpoint}/v1/deployments`, {
41
41
  method: "GET",
42
42
  headers: {
@@ -56,4 +56,4 @@ async function listFromSelfHosted(argv) {
56
56
  }
57
57
  }
58
58
  //# sourceMappingURL=handler.js.map
59
- //# debugId=9bf817d9-a39a-5f35-9cdf-764d79d64533
59
+ //# debugId=f2551837-2c92-5d06-a4ed-dc11de482182
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.135.0",
3
+ "version": "1.137.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",
@@ -64,10 +64,10 @@
64
64
  "@opentelemetry/api": "^1.8.0",
65
65
  "@sentry/node": "7.69.0",
66
66
  "@swc/core": "1.3.78",
67
- "@zuplo/core": "5.2393.0",
67
+ "@zuplo/core": "5.2458.0",
68
68
  "@zuplo/deno-bin": "1.37.1",
69
69
  "@zuplo/pino-pretty-configurations": "^1.5.0",
70
- "@zuplo/runtime": "5.2393.0",
70
+ "@zuplo/runtime": "5.2458.0",
71
71
  "chalk": "^5.1.2",
72
72
  "chokidar": "^3.5.3",
73
73
  "dotenv": "^16.3.1",