@zuplo/cli 6.52.15 → 6.52.17
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/__tests__/integration/jest-mocks-setup.js +8 -0
- package/dist/__tests__/integration/jest-mocks-setup.js.map +1 -1
- package/dist/__tests__/integration/link.integration.test.js +8 -5
- package/dist/__tests__/integration/link.integration.test.js.map +1 -1
- package/dist/cmds/delete.d.ts.map +1 -1
- package/dist/cmds/delete.js +14 -6
- package/dist/cmds/delete.js.map +1 -1
- package/dist/cmds/deploy.d.ts.map +1 -1
- package/dist/cmds/deploy.js +21 -6
- package/dist/cmds/deploy.js.map +1 -1
- package/dist/cmds/link.d.ts.map +1 -1
- package/dist/cmds/link.js +21 -6
- package/dist/cmds/link.js.map +1 -1
- package/dist/cmds/list.d.ts.map +1 -1
- package/dist/cmds/list.js +14 -6
- package/dist/cmds/list.js.map +1 -1
- package/dist/cmds/tunnel/create.d.ts.map +1 -1
- package/dist/cmds/tunnel/create.js +2 -2
- package/dist/cmds/tunnel/create.js.map +1 -1
- package/dist/cmds/tunnel/delete.d.ts.map +1 -1
- package/dist/cmds/tunnel/delete.js +2 -2
- package/dist/cmds/tunnel/delete.js.map +1 -1
- package/dist/cmds/tunnel/describe.d.ts.map +1 -1
- package/dist/cmds/tunnel/describe.js +2 -2
- package/dist/cmds/tunnel/describe.js.map +1 -1
- package/dist/cmds/tunnel/list.d.ts.map +1 -1
- package/dist/cmds/tunnel/list.js +2 -3
- package/dist/cmds/tunnel/list.js.map +1 -1
- package/dist/cmds/tunnel/rotate-token.d.ts.map +1 -1
- package/dist/cmds/tunnel/rotate-token.js +2 -2
- package/dist/cmds/tunnel/rotate-token.js.map +1 -1
- package/dist/cmds/tunnel/services/describe.d.ts.map +1 -1
- package/dist/cmds/tunnel/services/describe.js +2 -2
- package/dist/cmds/tunnel/services/describe.js.map +1 -1
- package/dist/cmds/tunnel/services/update.d.ts.map +1 -1
- package/dist/cmds/tunnel/services/update.js +2 -2
- package/dist/cmds/tunnel/services/update.js.map +1 -1
- package/dist/cmds/variable/create.d.ts.map +1 -1
- package/dist/cmds/variable/create.js +14 -6
- package/dist/cmds/variable/create.js.map +1 -1
- package/dist/cmds/variable/update.d.ts.map +1 -1
- package/dist/cmds/variable/update.js +14 -6
- package/dist/cmds/variable/update.js.map +1 -1
- package/dist/common/middleware/get-account-param.d.ts +4 -0
- package/dist/common/middleware/get-account-param.d.ts.map +1 -0
- package/dist/common/middleware/get-account-param.js +53 -0
- package/dist/common/middleware/get-account-param.js.map +1 -0
- package/dist/common/middleware/get-environment-param.d.ts +4 -0
- package/dist/common/middleware/get-environment-param.d.ts.map +1 -0
- package/dist/common/middleware/get-environment-param.js +141 -0
- package/dist/common/middleware/get-environment-param.js.map +1 -0
- package/dist/common/middleware/get-project-param.d.ts +4 -0
- package/dist/common/middleware/get-project-param.d.ts.map +1 -0
- package/dist/common/middleware/get-project-param.js +59 -0
- package/dist/common/middleware/get-project-param.js.map +1 -0
- package/dist/common/middleware/user-configuration.d.ts.map +1 -1
- package/dist/common/middleware/user-configuration.js +2 -1
- package/dist/common/middleware/user-configuration.js.map +1 -1
- package/dist/common/utils/pretty-print-environment-prompt.d.ts +6 -0
- package/dist/common/utils/pretty-print-environment-prompt.d.ts.map +1 -0
- package/dist/common/utils/pretty-print-environment-prompt.js +23 -0
- package/dist/common/utils/pretty-print-environment-prompt.js.map +1 -0
- package/dist/common/validators/file-system-validator.d.ts.map +1 -1
- package/dist/common/validators/file-system-validator.js +2 -3
- package/dist/common/validators/file-system-validator.js.map +1 -1
- package/dist/common/validators/project-name-validator.d.ts.map +1 -1
- package/dist/common/validators/project-name-validator.js +2 -1
- package/dist/common/validators/project-name-validator.js.map +1 -1
- package/dist/link/handler.d.ts.map +1 -1
- package/dist/link/handler.js +6 -138
- package/dist/link/handler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/common/builders/authenticated-command-builder.d.ts +0 -25
- package/dist/common/builders/authenticated-command-builder.d.ts.map +0 -1
- package/dist/common/builders/authenticated-command-builder.js +0 -87
- package/dist/common/builders/authenticated-command-builder.js.map +0 -1
- package/dist/common/builders/authenticated-command-builder.spec.d.ts +0 -2
- package/dist/common/builders/authenticated-command-builder.spec.d.ts.map +0 -1
- package/dist/common/builders/authenticated-command-builder.spec.js +0 -268
- package/dist/common/builders/authenticated-command-builder.spec.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-environment-param.js","sourceRoot":"","sources":["../../../src/common/middleware/get-environment-param.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oCAAoC,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAM3F,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAgC;IACrE,IAAI,IAAI,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAID,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAExC,IAA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C;YAClC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YACD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAI/B,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBAEtB,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;gBAE3B,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9C,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC;oBACjC,IAAI;oBACJ,YAAY;oBACZ,YAAY,CAAC,OAAO;iBACrB,CAAC,CAAC;gBACH,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;oBACnD,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACtC,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;oBAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACvB,MAAM,IAAI,KAAK,CACb,qDAAqD,CACtD,CAAC;oBACJ,CAAC;oBACD,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC;gBACpC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { select } from \"@inquirer/prompts\";\nimport { simpleGit } from \"simple-git\";\nimport { Environment } from \"../api/lib.js\";\nimport { logger } from \"../logger.js\";\nimport { printCriticalFailureToConsoleAndExit, textOrJson } from \"../output.js\";\nimport settings from \"../settings.js\";\nimport { prettyPrintEnvironmentPrompt } from \"../utils/pretty-print-environment-prompt.js\";\n\n/**\n * Middleware that ensures a environment is provided in argv. If not, prompts the user.\n * Note: must be called after get account param and get project param.\n */\nexport async function fetchEnvironment(argv: { [key: string]: unknown }) {\n if (argv.environment && typeof argv.environment === \"string\") {\n return;\n }\n\n if (!argv.account || typeof argv.account !== \"string\") {\n throw new Error(\"Invalid state: account is not set.\");\n }\n if (!argv.project || typeof argv.project !== \"string\") {\n throw new Error(\"Invalid state: project is not set.\");\n }\n\n // 1. Check if the dir argument is set and if we are in a git repository\n // If we are, get the current branch and use that as the environment name.\n const branch = await getGitBranch(argv);\n\n if (branch && !argv[\"fetch-environments\"]) {\n // If the branch is set, use that as the environment name\n argv.environment = branch;\n } else {\n const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;\n\n const queryParams: Record<string, string> = {\n // This is safe because of the previous middleware where we set the account and project.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n accountName: argv.account!,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n projectName: argv.project!,\n };\n\n // Create the query string using URLSearchParams\n const url = new URL(baseUrl);\n url.search = new URLSearchParams(queryParams).toString();\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (response.ok) {\n let environmentJsonFromDeveloperAPI = (await response.json()) as {\n data: Environment[];\n };\n\n let numDevelopmentEnvironments =\n environmentJsonFromDeveloperAPI.data.filter((env) => {\n return env.environmentType === \"development\";\n }).length;\n\n if (numDevelopmentEnvironments <= 0) {\n // Create one on-the-fly\n const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n accountName: argv.account,\n projectName: argv.project,\n environmentType: \"development\",\n }),\n });\n\n if (!createDevelopmenEnvironmentResponse.ok) {\n logger.debug(\n {\n status: createDevelopmenEnvironmentResponse.status,\n statusText: createDevelopmenEnvironmentResponse.statusText,\n },\n \"Failed to create a new instance of development environment\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Failed to create a new development environment. Please try again later.\"\n );\n }\n\n numDevelopmentEnvironments++;\n\n // Re-fetch\n const updatedResponse = await fetch(url, {\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n environmentJsonFromDeveloperAPI = (await updatedResponse.json()) as {\n data: Environment[];\n };\n }\n\n const environments = environmentJsonFromDeveloperAPI.data\n .map((env) => {\n return {\n [prettyPrintEnvironmentPrompt(\n env,\n numDevelopmentEnvironments == 1\n )]: env.name,\n };\n })\n .reduce((acc, curr) => {\n return { ...acc, ...curr };\n });\n\n try {\n argv.environment = await select({\n message: \"Select the environment\",\n choices: Object.entries(environments)\n .map(([key, value]) => {\n return {\n name: key,\n value: value,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name)),\n });\n } catch (error) {\n if (error.isTtyError || error.name === \"ExitPromptError\") {\n process.exit(0);\n }\n logger.trace(\"Failed to select account\", error);\n process.exit(1);\n }\n } else {\n logger.trace(\n {\n status: response.status,\n statusText: response.statusText,\n response: textOrJson(await response.text()),\n },\n \"Failed to request environments for project\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to request environments for the project.\"\n );\n }\n }\n}\nasync function getGitBranch(argv: { [key: string]: unknown }) {\n let branch: string | undefined;\n const dir = argv.dir;\n if (dir && typeof dir === \"string\") {\n const git = simpleGit({ baseDir: dir });\n const isGitRepo = await git.checkIsRepo();\n if (isGitRepo) {\n // Get the current branch from Git\n const status = await git.status();\n if (!status.current) {\n throw new Error(\"Invalid state: Directory is in detached head state.\");\n }\n branch = status.current.trim();\n\n // @NOTE - gitlab returns HEAD as the current branch when running git.status()\n // https://forum.gitlab.com/t/why-i-cant-get-the-branch-name/72462/6\n if (branch === \"HEAD\") {\n // Fetch remote branches to ensure the latest information\n await git.fetch([\"--all\"]);\n\n const branchCommit = await git.branch([\"-a\"]);\n const branchRef = await git.branch([\n \"-r\",\n \"--contains\",\n branchCommit.current,\n ]);\n if (branchRef && branchRef.all && branchRef.all[0]) {\n const originBranch = branchRef.all[0];\n const cleanOriginBranch = originBranch.replace(/^origin\\//, \"\");\n if (!cleanOriginBranch) {\n throw new Error(\n \"Invalid state: Directory is in detached head state.\"\n );\n }\n branch = cleanOriginBranch.trim();\n }\n }\n }\n }\n return branch;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-project-param.d.ts","sourceRoot":"","sources":["../../../src/common/middleware/get-project-param.ts"],"names":[],"mappings":"AASA,wBAAsB,YAAY,CAAC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,iBAmElE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { select } from "@inquirer/prompts";
|
|
2
|
+
import { logger } from "../logger.js";
|
|
3
|
+
import { printCriticalFailureToConsoleAndExit, textOrJson } from "../output.js";
|
|
4
|
+
import settings from "../settings.js";
|
|
5
|
+
export async function fetchProject(argv) {
|
|
6
|
+
if (argv.project && typeof argv.project === "string") {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!argv.account || typeof argv.account !== "string") {
|
|
10
|
+
throw new Error("Invalid state: account is not set.");
|
|
11
|
+
}
|
|
12
|
+
const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/projects`;
|
|
13
|
+
const queryParams = {
|
|
14
|
+
accountName: argv.account,
|
|
15
|
+
};
|
|
16
|
+
const url = new URL(baseUrl);
|
|
17
|
+
url.search = new URLSearchParams(queryParams).toString();
|
|
18
|
+
const response = await fetch(url, {
|
|
19
|
+
method: "GET",
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${argv.authToken}`,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
if (response.ok) {
|
|
25
|
+
const projectsJson = await response.json();
|
|
26
|
+
try {
|
|
27
|
+
argv.project = await select({
|
|
28
|
+
message: "Select the project",
|
|
29
|
+
choices: projectsJson.data
|
|
30
|
+
.map((project) => {
|
|
31
|
+
return {
|
|
32
|
+
name: project.name,
|
|
33
|
+
value: project.name,
|
|
34
|
+
};
|
|
35
|
+
})
|
|
36
|
+
.sort((a, b) => a.name.localeCompare(b.name)),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error.isTtyError || error.name === "ExitPromptError") {
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
logger.trace("Failed to select account", error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if (response.status === 404) {
|
|
49
|
+
await printCriticalFailureToConsoleAndExit("You don't have any projects configured for this account. Create a project in the Zuplo dashboard and try again.");
|
|
50
|
+
}
|
|
51
|
+
logger.trace({
|
|
52
|
+
status: response.status,
|
|
53
|
+
statusText: response.statusText,
|
|
54
|
+
response: textOrJson(await response.text()),
|
|
55
|
+
}, "Failed to request projects for account");
|
|
56
|
+
await printCriticalFailureToConsoleAndExit("Error: Failed to request projects for the account.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=get-project-param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-project-param.js","sourceRoot":"","sources":["../../../src/common/middleware/get-project-param.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oCAAoC,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAMtC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAgC;IACjE,IAAI,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACrD,OAAO;IACT,CAAC;IAED,IAAI,CAAC,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K,iBAAiB,EAAE,CAAC;gBACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,oCAAoC,CACxC,iHAAiH,CAClH,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,KAAK,CACV;YACE,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,QAAQ,EAAE,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC5C,EACD,wCAAwC,CACzC,CAAC;QACF,MAAM,oCAAoC,CACxC,oDAAoD,CACrD,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { select } from \"@inquirer/prompts\";\nimport { logger } from \"../logger.js\";\nimport { printCriticalFailureToConsoleAndExit, textOrJson } from \"../output.js\";\nimport settings from \"../settings.js\";\n\n/**\n * Middleware that ensures a project is provided in argv. If not, prompts the user.\n * Note: must be called after get account param.\n */\nexport async function fetchProject(argv: { [key: string]: unknown }) {\n if (argv.project && typeof argv.project === \"string\") {\n return;\n }\n\n if (!argv.account || typeof argv.account !== \"string\") {\n throw new Error(\"Invalid state: account is not set.\");\n }\n\n const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/projects`;\n const queryParams: Record<string, string> = {\n // This is safe because of the previous middleware where we set the account.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n accountName: argv.account!,\n };\n\n // Create the query string using URLSearchParams\n const url = new URL(baseUrl);\n url.search = new URLSearchParams(queryParams).toString();\n\n // Make a call to the API key\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (response.ok) {\n const projectsJson: { data: { name: string }[] } = await response.json();\n try {\n argv.project = await select({\n message: \"Select the project\",\n choices: projectsJson.data\n .map((project) => {\n return {\n name: project.name,\n value: project.name,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name)),\n });\n } catch (error) {\n if (error.isTtyError || error.name === \"ExitPromptError\") {\n process.exit(0);\n }\n logger.trace(\"Failed to select account\", error);\n process.exit(1);\n }\n } else {\n if (response.status === 404) {\n await printCriticalFailureToConsoleAndExit(\n \"You don't have any projects configured for this account. Create a project in the Zuplo dashboard and try again.\"\n );\n }\n logger.trace(\n {\n status: response.status,\n statusText: response.statusText,\n response: textOrJson(await response.text()),\n },\n \"Failed to request projects for account\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to request projects for the account.\"\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-configuration.d.ts","sourceRoot":"","sources":["../../../src/common/middleware/user-configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-configuration.d.ts","sourceRoot":"","sources":["../../../src/common/middleware/user-configuration.ts"],"names":[],"mappings":"AA6BA,wBAAsB,SAAS,CAAC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,iBAiD/D"}
|
|
@@ -4,7 +4,7 @@ import { join, relative } from "node:path";
|
|
|
4
4
|
import { parse } from "jsonc-parser";
|
|
5
5
|
import { ZUPLO_FALLBACK_JSON_FILE, ZUPLO_PREFERRED_JSON_FILE, } from "../constants.js";
|
|
6
6
|
import { logger } from "../logger.js";
|
|
7
|
-
import { printCriticalFailureToConsoleAndExit } from "../output.js";
|
|
7
|
+
import { printCriticalFailureToConsoleAndExit, printWarningToConsole, } from "../output.js";
|
|
8
8
|
import settings from "../settings.js";
|
|
9
9
|
export async function configure(argv) {
|
|
10
10
|
const cliParametersConfiguration = { ...argv };
|
|
@@ -19,6 +19,7 @@ export async function configure(argv) {
|
|
|
19
19
|
Object.assign(argv, omitNull(apiKeyMetadata));
|
|
20
20
|
const { project: zuploJsoncProject } = await processZuploConfigurationFile(argv.dir);
|
|
21
21
|
if (zuploJsoncProject) {
|
|
22
|
+
printWarningToConsole("The project name in zuplo.jsonc is deprecated. Please remove the project key from zuplo.jsonc and use the --project flag or ZUPLO_PROJECT environment variable instead.");
|
|
22
23
|
argv.project = zuploJsoncProject;
|
|
23
24
|
}
|
|
24
25
|
Object.assign(argv, cliParametersConfiguration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-configuration.js","sourceRoot":"","sources":["../../../src/common/middleware/user-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAc,KAAK,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"user-configuration.js","sourceRoot":"","sources":["../../../src/common/middleware/user-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAc,KAAK,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GAC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s\";\nimport { readFile } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\nimport { ParseError, parse } from \"jsonc-parser\";\nimport {\n ZUPLO_FALLBACK_JSON_FILE,\n ZUPLO_PREFERRED_JSON_FILE,\n} from \"../constants.js\";\nimport { logger } from \"../logger.js\";\nimport {\n printCriticalFailureToConsoleAndExit,\n printWarningToConsole,\n} from \"../output.js\";\nimport settings from \"../settings.js\";\n\n/**\n * This is the middleware to set the context for the CLI calls.\n *\n * It can be used to set sensible configurations such as account and project that are gotten from the API, zuplo.jsonc, --parameters\n *\n * The order of setting a configuration is\n * 1. API key\n * 2. zuplo.jsonc\n * 3. --parameters from the CLI invocation\n *\n * Note that --parameters objects can also come from .env file because of https://yargs.js.org/docs/#api-reference-envprefix\n *\n * @param argv - The yargs object\n */\nexport async function configure(argv: { [key: string]: unknown }) {\n // Clone the original value (for merging at the end)\n // The original is the most specific since it can only contain things from --parameters\n // It will always be applied last to override anything from zuplo.jsonc or the API key\n const cliParametersConfiguration = { ...argv };\n\n // Make a call to the API key\n const whoAmIResponse = await fetch(\n `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`,\n {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${argv.authToken}`,\n },\n }\n );\n\n if (whoAmIResponse.ok) {\n // Note that the algorithms below are based on \"addition\"\n // You cannot unset/remove a value from the configuration by setting it to null/undefined\n // Do be mindful of parameters that might be the same value since things might be overridden\n\n // Merge any non-null values from the API key\n const apiKeyMetadata = await whoAmIResponse.json();\n Object.assign(argv, omitNull(apiKeyMetadata));\n\n // Merge any non-null values from zuplo.jsonc\n // For now, only merge project since zuplo.jsonc could have many keys that might conflict\n const { project: zuploJsoncProject } = await processZuploConfigurationFile(\n argv.dir as string | undefined\n );\n if (zuploJsoncProject) {\n printWarningToConsole(\n \"The project name in zuplo.jsonc is deprecated. Please remove the project key from zuplo.jsonc and use the --project flag or ZUPLO_PROJECT environment variable instead.\"\n );\n argv.project = zuploJsoncProject;\n }\n\n // Merge any non-null values from --parameters\n Object.assign(argv, cliParametersConfiguration);\n } else {\n logger.trace(\n { status: whoAmIResponse.status, statusText: whoAmIResponse.statusText },\n \"Failed to determine who-am-i\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to validate the API key. Check your API key.\"\n );\n }\n}\n\nasync function processZuploConfigurationFile(\n sourceDirectory: string | undefined\n) {\n const normalizedDir = join(relative(process.cwd(), sourceDirectory ?? \".\"));\n const preferredPath = join(normalizedDir, ZUPLO_PREFERRED_JSON_FILE);\n const fallbackPath = join(normalizedDir, ZUPLO_FALLBACK_JSON_FILE);\n let fileContents = \"{}\";\n if (existsSync(preferredPath)) {\n fileContents = await readFile(preferredPath, \"utf-8\");\n } else if (existsSync(fallbackPath)) {\n fileContents = await readFile(fallbackPath, \"utf-8\");\n } else {\n logger.trace(\"No zuplo.jsonc file found\");\n return {};\n }\n\n // If we get here, we have a zuplo.jsonc (or, zuplo.json) file\n // That means we should report any issues with it.\n const errors: ParseError[] = [];\n const data = parse(fileContents, errors, { allowTrailingComma: true });\n if (errors.length > 0) {\n logger.trace(errors[0], \"Failed to parse zuplo.jsonc\");\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to parse the values from zuplo.jsonc. Check your zuplo.jsonc file.\"\n );\n }\n return data;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst omitNull = (obj: any) => {\n Object.keys(obj)\n .filter((k) => obj[k] === null)\n .forEach((k) => delete obj[k]);\n return obj;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print-environment-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,WAAW,EAChB,4BAA4B,EAAE,OAAO,UAuBtC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function prettyPrintEnvironmentPrompt(env, hasSingleDevelopmentInstance) {
|
|
2
|
+
let environmentType = env.environmentType.toLowerCase();
|
|
3
|
+
let branchName = env.branchName;
|
|
4
|
+
let name = env.name;
|
|
5
|
+
switch (environmentType) {
|
|
6
|
+
case "working-copy":
|
|
7
|
+
case "working_copy":
|
|
8
|
+
case "development":
|
|
9
|
+
if (hasSingleDevelopmentInstance) {
|
|
10
|
+
name = "Default for local development";
|
|
11
|
+
environmentType = "development";
|
|
12
|
+
branchName = "";
|
|
13
|
+
return `${name} (${environmentType})`;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
environmentType = "development";
|
|
17
|
+
branchName = "";
|
|
18
|
+
return `${name} (${environmentType})`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return `${name} (${environmentType}, ${branchName})`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=pretty-print-environment-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print-environment-prompt.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B,CAC1C,GAAgB,EAChB,4BAAqC;IAErC,IAAI,eAAe,GAAG,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAChC,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpB,QAAQ,eAAe,EAAE,CAAC;QACxB,KAAK,cAAc,CAAC;QACpB,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,IAAI,4BAA4B,EAAE,CAAC;gBACjC,IAAI,GAAG,+BAA+B,CAAC;gBACvC,eAAe,GAAG,aAAa,CAAC;gBAChC,UAAU,GAAG,EAAE,CAAC;gBAChB,OAAO,GAAG,IAAI,KAAK,eAAe,GAAG,CAAC;YACxC,CAAC;iBAAM,CAAC;gBAEN,eAAe,GAAG,aAAa,CAAC;gBAChC,UAAU,GAAG,EAAE,CAAC;gBAChB,OAAO,GAAG,IAAI,KAAK,eAAe,GAAG,CAAC;YACxC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,IAAI,KAAK,eAAe,KAAK,UAAU,GAAG,CAAC;AACvD,CAAC","sourcesContent":["import { Environment } from \"../api/lib.js\";\n\nexport function prettyPrintEnvironmentPrompt(\n env: Environment,\n hasSingleDevelopmentInstance: boolean\n) {\n let environmentType = env.environmentType.toLowerCase();\n let branchName = env.branchName;\n let name = env.name;\n\n switch (environmentType) {\n case \"working-copy\":\n case \"working_copy\":\n case \"development\":\n if (hasSingleDevelopmentInstance) {\n name = \"Default for local development\";\n environmentType = \"development\";\n branchName = \"\";\n return `${name} (${environmentType})`;\n } else {\n // For the case of working copy the branch name is actually \"main\" but it doesn't mean anything\n environmentType = \"development\";\n branchName = \"\";\n return `${name} (${environmentType})`;\n }\n }\n return `${name} (${environmentType}, ${branchName})`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-system-validator.d.ts","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"file-system-validator.d.ts","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEtE,qBAAa,mCAAoC,SAAQ,KAAK;;CAO7D;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAK1C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAO1C;AAED,qBAAa,wBAAyB,SAAQ,KAAK;;CAOlD;AAED,qBAAa,YAAa,SAAQ,KAAK;;CAOtC;AAED,qBAAa,eAAgB,SAAQ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ACd,MAAM,GAAG,SAAS;EACqC,CAAC;AAEvE,eAAO,MAAM,2BAA2B;SACjC,MAAM;EACuD,CAAC"}
|
|
@@ -3,10 +3,9 @@ import path from "node:path";
|
|
|
3
3
|
import { simpleGit } from "simple-git";
|
|
4
4
|
import { findTestFiles } from "../../test/test-files.js";
|
|
5
5
|
import { CompositeValidator } from "./lib.js";
|
|
6
|
-
import { ProjectIsSetValidator } from "./project-name-validator.js";
|
|
7
6
|
export class GitBranchOrEnvironmentRequiredError extends Error {
|
|
8
7
|
constructor() {
|
|
9
|
-
super("Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument.");
|
|
8
|
+
super("Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument or set `--use-git-branch false` to pick one.");
|
|
10
9
|
Object.setPrototypeOf(this, NotAGitRepoError.prototype);
|
|
11
10
|
}
|
|
12
11
|
}
|
|
@@ -166,6 +165,6 @@ export class ZuploProjectHasTestsValidator {
|
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
|
-
export const validDeployDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new
|
|
168
|
+
export const validDeployDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new GitBranchOrEnvironmentValidator());
|
|
170
169
|
export const validTestDirectoryValidator = new CompositeValidator(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());
|
|
171
170
|
//# sourceMappingURL=file-system-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-system-validator.js","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAA0B,MA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B,EAAE,EAC3B,IAAI,+BAA+B,EAAE,CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,kBAAkB,CAE9D,IAAI,qBAAqB,EAAE,EAAE,IAAI,6BAA6B,EAAE,CAAC,CAAC","sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { simpleGit } from \"simple-git\";\nimport { findTestFiles } from \"../../test/test-files.js\";\nimport { CompositeValidator, Result, ValidationRule } from \"./lib.js\";\nimport { ProjectIsSetValidator } from \"./project-name-validator.js\";\n\nexport class GitBranchOrEnvironmentRequiredError extends Error {\n constructor() {\n super(\n \"Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument.\"\n );\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAGitRepoError extends Error {\n constructor() {\n super(\"Invalid directory: The project directory is not a Git repository.\");\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAZuploProject extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory is not the root of a Zuplo project.\"\n );\n Object.setPrototypeOf(this, NotAZuploProject.prototype);\n }\n}\n\nexport class ZuploProjectMissingTests extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory does not contain any tests (*.test.ts) in the /tests folder. Create a at least one test of the form some-name.test.ts\"\n );\n Object.setPrototypeOf(this, ZuploProjectMissingTests.prototype);\n }\n}\n\nexport class NoGitCommits extends Error {\n constructor() {\n super(\n \"Invalid Git state: The project directory does not contain any commits. Make a commit before deploying.\"\n );\n Object.setPrototypeOf(this, NoGitCommits.prototype);\n }\n}\n\nexport class NotOnAGitBranch extends Error {\n constructor() {\n super(\n \"Invalid Git state: You are not on a branch. Run `git checkout -b <branch-name>` to create a new branch.\"\n );\n Object.setPrototypeOf(this, NotOnAGitBranch.prototype);\n }\n}\n\nexport class GitVersionControlValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n await simpleGit({ baseDir: dir }).status();\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NotAGitRepoError(),\n };\n }\n }\n}\n\n/**\n * Checks if either the current branch is set as the environment or if\n * the environment is explicitly set\n */\nexport class GitBranchOrEnvironmentValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: {\n dir: string;\n environment: string | undefined;\n }): Promise<Result> {\n const { dir, environment } = option;\n if (typeof environment === \"string\") {\n return {\n ok: true,\n };\n }\n try {\n if (await simpleGit({ baseDir: dir }).checkIsRepo()) {\n await simpleGit({ baseDir: dir }).status();\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (branch.current) {\n return {\n ok: true,\n };\n }\n }\n } catch {\n // Ignore\n }\n return {\n ok: false,\n error: new GitBranchOrEnvironmentRequiredError(),\n };\n }\n}\n\nexport class GitCommitValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n const git = simpleGit({ baseDir: dir });\n const commits = await git.log({ maxCount: 1 });\n if (commits.total === 0) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n }\n}\n\nexport class GitBranchValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (!branch.current) {\n return {\n ok: false,\n error: new NotOnAGitBranch(),\n };\n }\n\n return { ok: true };\n }\n}\n\nexport class ZuploProjectValidator implements ValidationRule<{ dir: string }> {\n async validate(options: { dir: string }): Promise<Result> {\n const { dir } = options;\n try {\n const dirPath = path.join(path.normalize(dir), \"config\");\n if (existsSync(dirPath)) {\n const files = readdirSync(dirPath);\n const existingOASFiles =\n files.filter((file) => file.endsWith(\".oas.json\")).length >= 1;\n if (existingOASFiles === true) {\n return { ok: true };\n }\n }\n return {\n ok: false,\n error: new NotAZuploProject(),\n };\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport class ZuploProjectHasTestsValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n if (findTestFiles(dir).length >= 1) {\n return { ok: true };\n } else {\n return {\n ok: false,\n error: new ZuploProjectMissingTests(),\n };\n }\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport const validDeployDirectoryValidator = new CompositeValidator<{\n dir: string;\n project: string | undefined;\n environment: string | undefined;\n}>(\n new ZuploProjectValidator(),\n new ProjectIsSetValidator(),\n new GitBranchOrEnvironmentValidator()\n);\n\nexport const validTestDirectoryValidator = new CompositeValidator<{\n dir: string;\n}>(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());\n"]}
|
|
1
|
+
{"version":3,"file":"file-system-validator.js","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAA0B,MAAM,UAAU,CAAC;AAEtE,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IAC5D;QACE,KAAK,CACH,4JAA4J,CAC7J,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE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gBACtB,CAAC;YACH,CAAC;YACD,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,IAAI,gBAAgB,EAAE;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,6BAA6B;IAGxC,KAAK,CAAC,QAAQ,CAAC,MAAuB;QACpC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC;YACH,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACnC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;YACtB,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,IAAI,wBAAwB,EAAE;iBACtC,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,kBAAkB,CAIhE,IAAI,qBAAqB,EAAE,EAAE,IAAI,+BAA+B,EAAE,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,kBAAkB,CAE9D,IAAI,qBAAqB,EAAE,EAAE,IAAI,6BAA6B,EAAE,CAAC,CAAC","sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { simpleGit } from \"simple-git\";\nimport { findTestFiles } from \"../../test/test-files.js\";\nimport { CompositeValidator, Result, ValidationRule } from \"./lib.js\";\n\nexport class GitBranchOrEnvironmentRequiredError extends Error {\n constructor() {\n super(\n \"Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument or set `--use-git-branch false` to pick one.\"\n );\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAGitRepoError extends Error {\n constructor() {\n super(\"Invalid directory: The project directory is not a Git repository.\");\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAZuploProject extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory is not the root of a Zuplo project.\"\n );\n Object.setPrototypeOf(this, NotAZuploProject.prototype);\n }\n}\n\nexport class ZuploProjectMissingTests extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory does not contain any tests (*.test.ts) in the /tests folder. Create a at least one test of the form some-name.test.ts\"\n );\n Object.setPrototypeOf(this, ZuploProjectMissingTests.prototype);\n }\n}\n\nexport class NoGitCommits extends Error {\n constructor() {\n super(\n \"Invalid Git state: The project directory does not contain any commits. Make a commit before deploying.\"\n );\n Object.setPrototypeOf(this, NoGitCommits.prototype);\n }\n}\n\nexport class NotOnAGitBranch extends Error {\n constructor() {\n super(\n \"Invalid Git state: You are not on a branch. Run `git checkout -b <branch-name>` to create a new branch.\"\n );\n Object.setPrototypeOf(this, NotOnAGitBranch.prototype);\n }\n}\n\nexport class GitVersionControlValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n await simpleGit({ baseDir: dir }).status();\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NotAGitRepoError(),\n };\n }\n }\n}\n\n/**\n * Checks if either the current branch is set as the environment or if\n * the environment is explicitly set\n */\nexport class GitBranchOrEnvironmentValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: {\n dir: string;\n environment: string | undefined;\n }): Promise<Result> {\n const { dir, environment } = option;\n if (typeof environment === \"string\") {\n return {\n ok: true,\n };\n }\n try {\n if (await simpleGit({ baseDir: dir }).checkIsRepo()) {\n await simpleGit({ baseDir: dir }).status();\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (branch.current) {\n return {\n ok: true,\n };\n }\n }\n } catch {\n // Ignore\n }\n return {\n ok: false,\n error: new GitBranchOrEnvironmentRequiredError(),\n };\n }\n}\n\nexport class GitCommitValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n const git = simpleGit({ baseDir: dir });\n const commits = await git.log({ maxCount: 1 });\n if (commits.total === 0) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n }\n}\n\nexport class GitBranchValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (!branch.current) {\n return {\n ok: false,\n error: new NotOnAGitBranch(),\n };\n }\n\n return { ok: true };\n }\n}\n\nexport class ZuploProjectValidator implements ValidationRule<{ dir: string }> {\n async validate(options: { dir: string }): Promise<Result> {\n const { dir } = options;\n try {\n const dirPath = path.join(path.normalize(dir), \"config\");\n if (existsSync(dirPath)) {\n const files = readdirSync(dirPath);\n const existingOASFiles =\n files.filter((file) => file.endsWith(\".oas.json\")).length >= 1;\n if (existingOASFiles === true) {\n return { ok: true };\n }\n }\n return {\n ok: false,\n error: new NotAZuploProject(),\n };\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport class ZuploProjectHasTestsValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n if (findTestFiles(dir).length >= 1) {\n return { ok: true };\n } else {\n return {\n ok: false,\n error: new ZuploProjectMissingTests(),\n };\n }\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport const validDeployDirectoryValidator = new CompositeValidator<{\n dir: string;\n project: string | undefined;\n environment: string | undefined;\n}>(new ZuploProjectValidator(), new GitBranchOrEnvironmentValidator());\n\nexport const validTestDirectoryValidator = new CompositeValidator<{\n dir: string;\n}>(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-name-validator.d.ts","sourceRoot":"","sources":["../../../src/common/validators/project-name-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElD,qBAAa,eAAgB,SAAQ,KAAK;;
|
|
1
|
+
{"version":3,"file":"project-name-validator.d.ts","sourceRoot":"","sources":["../../../src/common/validators/project-name-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElD,qBAAa,eAAgB,SAAQ,KAAK;;CASzC;AAED,qBAAa,qBACX,YAAW,cAAc,CAAC;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;IAEpD,QAAQ,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAUvE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export class ProjectIsNotSet extends Error {
|
|
2
2
|
constructor() {
|
|
3
3
|
super(`Missing project name. This command requires a project to be specified. Either specify it using --project or set it in zuplo.jsonc.
|
|
4
|
-
|
|
4
|
+
Fetching it from the zuplo.jsonc is deprecated.
|
|
5
|
+
`);
|
|
5
6
|
Object.setPrototypeOf(this, ProjectIsNotSet.prototype);
|
|
6
7
|
}
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-name-validator.js","sourceRoot":"","sources":["../../../src/common/validators/project-name-validator.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC;QACE,KAAK,CACH
|
|
1
|
+
{"version":3,"file":"project-name-validator.js","sourceRoot":"","sources":["../../../src/common/validators/project-name-validator.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC;QACE,KAAK,CACH;;OAEC,CACF,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AAED,MAAM,OAAO,qBAAqB;IAGhC,KAAK,CAAC,QAAQ,CAAC,IAAqC;QAClD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,IAAI,eAAe,EAAE;aAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Result, ValidationRule } from \"./lib.js\";\n\nexport class ProjectIsNotSet extends Error {\n constructor() {\n super(\n `Missing project name. This command requires a project to be specified. Either specify it using --project or set it in zuplo.jsonc.\n Fetching it from the zuplo.jsonc is deprecated.\n `\n );\n Object.setPrototypeOf(this, ProjectIsNotSet.prototype);\n }\n}\n\nexport class ProjectIsSetValidator\n implements ValidationRule<{ project: string | undefined }>\n{\n async validate(argv: { project: string | undefined }): Promise<Result> {\n if (!argv.project) {\n return {\n ok: false,\n error: new ProjectIsNotSet(),\n };\n } else {\n return { ok: true };\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/link/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/link/handler.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,iBAoBzC"}
|
package/dist/link/handler.js
CHANGED
|
@@ -1,145 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logger } from "../common/logger.js";
|
|
3
|
-
import { printCriticalFailureToConsoleAndExit, printResultToConsoleAndExitGracefully, textOrJson, } from "../common/output.js";
|
|
4
|
-
import settings from "../common/settings.js";
|
|
1
|
+
import { printResultToConsoleAndExitGracefully } from "../common/output.js";
|
|
5
2
|
import { pullSystemConfig, safeMergeConfig } from "./populate.js";
|
|
6
|
-
function prettyPrintEnvironmentPrompt(env, hasSingleDevelopmentInstance) {
|
|
7
|
-
let environmentType = env.environmentType.toLowerCase();
|
|
8
|
-
let branchName = env.branchName;
|
|
9
|
-
let name = env.name;
|
|
10
|
-
switch (environmentType) {
|
|
11
|
-
case "working-copy":
|
|
12
|
-
case "working_copy":
|
|
13
|
-
case "development":
|
|
14
|
-
if (hasSingleDevelopmentInstance) {
|
|
15
|
-
name = "Default for local development";
|
|
16
|
-
environmentType = "development";
|
|
17
|
-
branchName = "";
|
|
18
|
-
return `${name} (${environmentType})`;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
environmentType = "development";
|
|
22
|
-
branchName = "";
|
|
23
|
-
return `${name} (${environmentType})`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return `${name} (${environmentType}, ${branchName})`;
|
|
27
|
-
}
|
|
28
3
|
export async function link(argv) {
|
|
29
4
|
const account = argv.account;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
headers: {
|
|
35
|
-
authorization: `Bearer ${argv.authToken}`,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
if (!projectResponse.ok) {
|
|
39
|
-
logger.error({
|
|
40
|
-
status: projectResponse.status,
|
|
41
|
-
statusText: projectResponse.statusText,
|
|
42
|
-
response: textOrJson(await projectResponse.text()),
|
|
43
|
-
}, "Failed to list projects.");
|
|
44
|
-
await printCriticalFailureToConsoleAndExit("Error: Failed to list your projects. Try again later.");
|
|
45
|
-
}
|
|
46
|
-
const projectJson = (await projectResponse.json());
|
|
47
|
-
if (projectJson.data.length === 1) {
|
|
48
|
-
project = projectJson.data[0].name;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
project = await select({
|
|
52
|
-
message: "Select the project to work with",
|
|
53
|
-
choices: projectJson.data.map((prj) => {
|
|
54
|
-
return {
|
|
55
|
-
name: prj.name,
|
|
56
|
-
value: prj.name,
|
|
57
|
-
};
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (!environment) {
|
|
63
|
-
const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;
|
|
64
|
-
const queryParams = {
|
|
65
|
-
accountName: account,
|
|
66
|
-
projectName: project,
|
|
67
|
-
};
|
|
68
|
-
const url = new URL(baseUrl);
|
|
69
|
-
url.search = new URLSearchParams(queryParams).toString();
|
|
70
|
-
let environmentResponseFromDeveloperAPI = await fetch(url, {
|
|
71
|
-
headers: {
|
|
72
|
-
authorization: `Bearer ${argv.authToken}`,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
if (!environmentResponseFromDeveloperAPI.ok) {
|
|
76
|
-
logger.error({
|
|
77
|
-
status: environmentResponseFromDeveloperAPI.status,
|
|
78
|
-
statusText: environmentResponseFromDeveloperAPI.statusText,
|
|
79
|
-
}, "Failed to link to a project in your account");
|
|
80
|
-
await printCriticalFailureToConsoleAndExit("Check that the project specified in your zuplo.jsonc exists and that you have access to it.");
|
|
81
|
-
}
|
|
82
|
-
let environmentJsonFromDeveloperAPI = (await environmentResponseFromDeveloperAPI.json());
|
|
83
|
-
let numDevelopmentEnvironments = environmentJsonFromDeveloperAPI.data.filter((env) => {
|
|
84
|
-
return env.environmentType === "development";
|
|
85
|
-
}).length;
|
|
86
|
-
if (numDevelopmentEnvironments <= 0) {
|
|
87
|
-
const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
headers: {
|
|
90
|
-
authorization: `Bearer ${argv.authToken}`,
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
},
|
|
93
|
-
body: JSON.stringify({
|
|
94
|
-
accountName: account,
|
|
95
|
-
projectName: project,
|
|
96
|
-
environmentType: "development",
|
|
97
|
-
}),
|
|
98
|
-
});
|
|
99
|
-
if (!createDevelopmenEnvironmentResponse.ok) {
|
|
100
|
-
logger.debug({
|
|
101
|
-
status: createDevelopmenEnvironmentResponse.status,
|
|
102
|
-
statusText: createDevelopmenEnvironmentResponse.statusText,
|
|
103
|
-
}, "Failed to create a new instance of development environment");
|
|
104
|
-
await printCriticalFailureToConsoleAndExit("Failed to create a new development environment. Please try again later.");
|
|
105
|
-
}
|
|
106
|
-
numDevelopmentEnvironments++;
|
|
107
|
-
environmentResponseFromDeveloperAPI = await fetch(url, {
|
|
108
|
-
headers: {
|
|
109
|
-
authorization: `Bearer ${argv.authToken}`,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
environmentJsonFromDeveloperAPI =
|
|
113
|
-
(await environmentResponseFromDeveloperAPI.json());
|
|
114
|
-
}
|
|
115
|
-
const environments = Object.assign({}, environmentJsonFromDeveloperAPI.data
|
|
116
|
-
.map((env) => {
|
|
117
|
-
return {
|
|
118
|
-
[prettyPrintEnvironmentPrompt(env, numDevelopmentEnvironments == 1)]: env.name,
|
|
119
|
-
};
|
|
120
|
-
})
|
|
121
|
-
.reduce((acc, curr) => {
|
|
122
|
-
return { ...acc, ...curr };
|
|
123
|
-
}));
|
|
124
|
-
if (Object.values(environments).length === 1) {
|
|
125
|
-
environment = Object.values(environments)[0];
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
environment = await select({
|
|
129
|
-
message: "Select the environment to work with",
|
|
130
|
-
choices: Object.entries(environments).map(([key, value]) => {
|
|
131
|
-
return {
|
|
132
|
-
name: key,
|
|
133
|
-
value,
|
|
134
|
-
};
|
|
135
|
-
}),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
argv.environment = environment;
|
|
140
|
-
if (project) {
|
|
141
|
-
await safeMergeConfig(argv.dir, project);
|
|
5
|
+
const project = argv.project;
|
|
6
|
+
const environment = argv.environment;
|
|
7
|
+
if (!account || !project || !environment) {
|
|
8
|
+
throw new Error("Invalid state: account, project, or environment is not set.");
|
|
142
9
|
}
|
|
10
|
+
await safeMergeConfig(argv.dir, project);
|
|
143
11
|
await pullSystemConfig(argv);
|
|
144
12
|
await printResultToConsoleAndExitGracefully(`
|
|
145
13
|
Successfully linked your local directory to the ${project} project in the ${account} account.
|
package/dist/link/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/link/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,oCAAoC,EACpC,qCAAqC,EACrC,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAUlE,SAAS,4BAA4B,CACnC,GAAgB,EAChB,4BAAqC;IAErC,IAAI,eAAe,GAAG,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAChC,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpB,QAAQ,eAAe,EAAE,CAAC;QACxB,KAAK,cAAc,CAAC;QACpB,KAAK,c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C,GAAG,EAAE,EAAE;YACX,OAAO;gBACL,CAAC,4BAA4B,CAC3B,GAAG,EACH,0BAA0B,IAAI,CAAC,CAChC,CAAC,EAAE,GAAG,CAAC,IAAI;aACb,CAAC;QACJ,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACpB,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;QAC7B,CAAC,CAAC,CACL,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7C,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,MAAM,MAAM,CAAC;gBACzB,OAAO,EAAE,qCAAqC;gBAC9C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;oBACzD,OAAO;wBACL,IAAI,EAAE,GAAG;wBACT,KAAK;qBACN,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAG/B,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,qCAAqC,CAAC;kDACI,OAAO,mBAAmB,OAAO;kEACjB,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { select } from \"@inquirer/prompts\";\nimport { Environment, Project } from \"../common/api/lib.js\";\nimport { logger } from \"../common/logger.js\";\nimport {\n printCriticalFailureToConsoleAndExit,\n printResultToConsoleAndExitGracefully,\n textOrJson,\n} from \"../common/output.js\";\nimport settings from \"../common/settings.js\";\nimport { pullSystemConfig, safeMergeConfig } from \"./populate.js\";\n\nexport interface Arguments {\n dir: string;\n authToken: string;\n account?: string;\n project?: string;\n environment?: string;\n}\n\nfunction prettyPrintEnvironmentPrompt(\n env: Environment,\n hasSingleDevelopmentInstance: boolean\n) {\n let environmentType = env.environmentType.toLowerCase();\n let branchName = env.branchName;\n let name = env.name;\n\n switch (environmentType) {\n case \"working-copy\":\n case \"working_copy\":\n case \"development\":\n if (hasSingleDevelopmentInstance) {\n name = \"Default for local development\";\n environmentType = \"development\";\n branchName = \"\";\n return `${name} (${environmentType})`;\n } else {\n // For the case of working copy the branch name is actually \"main\" but it doesn't mean anything\n environmentType = \"development\";\n branchName = \"\";\n return `${name} (${environmentType})`;\n }\n }\n return `${name} (${environmentType}, ${branchName})`;\n}\n\nexport async function link(argv: Arguments) {\n const account = argv.account;\n let environment = argv.environment;\n\n // List the projects\n let project = argv.project;\n if (!environment && !project) {\n const projectResponse = await fetch(\n `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/projects`,\n {\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n },\n }\n );\n\n if (!projectResponse.ok) {\n logger.error(\n {\n status: projectResponse.status,\n statusText: projectResponse.statusText,\n response: textOrJson(await projectResponse.text()),\n },\n \"Failed to list projects.\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to list your projects. Try again later.\"\n );\n }\n\n // Ask the user to select a project, if necessary\n const projectJson = (await projectResponse.json()) as { data: Project[] };\n if (projectJson.data.length === 1) {\n project = projectJson.data[0].name;\n } else {\n project = await select({\n message: \"Select the project to work with\",\n choices: projectJson.data.map((prj) => {\n return {\n name: prj.name,\n value: prj.name,\n };\n }),\n });\n }\n }\n\n if (!environment) {\n const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;\n\n const queryParams: Record<string, string> = {\n // This is safe because of the flow above where we finalize the account and project\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n accountName: account!,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n projectName: project!,\n };\n\n // Create the query string using URLSearchParams\n const url = new URL(baseUrl);\n url.search = new URLSearchParams(queryParams).toString();\n let environmentResponseFromDeveloperAPI = await fetch(url, {\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (!environmentResponseFromDeveloperAPI.ok) {\n logger.error(\n {\n status: environmentResponseFromDeveloperAPI.status,\n statusText: environmentResponseFromDeveloperAPI.statusText,\n },\n \"Failed to link to a project in your account\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Check that the project specified in your zuplo.jsonc exists and that you have access to it.\"\n );\n }\n\n let environmentJsonFromDeveloperAPI =\n (await environmentResponseFromDeveloperAPI.json()) as {\n data: Environment[];\n };\n\n let numDevelopmentEnvironments =\n environmentJsonFromDeveloperAPI.data.filter((env) => {\n return env.environmentType === \"development\";\n }).length;\n\n if (numDevelopmentEnvironments <= 0) {\n // Create one on-the-fly\n const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n accountName: account,\n projectName: project,\n environmentType: \"development\",\n }),\n });\n\n if (!createDevelopmenEnvironmentResponse.ok) {\n logger.debug(\n {\n status: createDevelopmenEnvironmentResponse.status,\n statusText: createDevelopmenEnvironmentResponse.statusText,\n },\n \"Failed to create a new instance of development environment\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Failed to create a new development environment. Please try again later.\"\n );\n }\n\n numDevelopmentEnvironments++;\n\n // Re-fetch\n environmentResponseFromDeveloperAPI = await fetch(url, {\n headers: {\n authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n environmentJsonFromDeveloperAPI =\n (await environmentResponseFromDeveloperAPI.json()) as {\n data: Environment[];\n };\n }\n\n const environments = Object.assign(\n {},\n environmentJsonFromDeveloperAPI.data\n .map((env) => {\n return {\n [prettyPrintEnvironmentPrompt(\n env,\n numDevelopmentEnvironments == 1\n )]: env.name,\n };\n })\n .reduce((acc, curr) => {\n return { ...acc, ...curr };\n })\n );\n\n if (Object.values(environments).length === 1) {\n environment = Object.values(environments)[0];\n } else {\n environment = await select({\n message: \"Select the environment to work with\",\n choices: Object.entries(environments).map(([key, value]) => {\n return {\n name: key,\n value,\n };\n }),\n });\n }\n }\n\n argv.environment = environment;\n\n // Safely merge the values in the .zuplo.jsonc file\n if (project) {\n await safeMergeConfig(argv.dir, project);\n }\n\n // Safely merge in other auxillary files\n await pullSystemConfig(argv);\n\n await printResultToConsoleAndExitGracefully(`\nSuccessfully linked your local directory to the ${project} project in the ${account} account.\n.env.zuplo and zuplo.jsonc have been updated with the new values.`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/link/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAUlE,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAe;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAErC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IAGD,MAAM,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAGzC,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,qCAAqC,CAAC;kDACI,OAAO,mBAAmB,OAAO;kEACjB,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { printResultToConsoleAndExitGracefully } from \"../common/output.js\";\nimport { pullSystemConfig, safeMergeConfig } from \"./populate.js\";\n\nexport interface Arguments {\n dir: string;\n authToken: string;\n account?: string;\n project?: string;\n environment?: string;\n}\n\nexport async function link(argv: Arguments) {\n const account = argv.account;\n const project = argv.project;\n const environment = argv.environment;\n\n if (!account || !project || !environment) {\n throw new Error(\n \"Invalid state: account, project, or environment is not set.\"\n );\n }\n\n // Create a zuplo.jsonc file if it doesn't exist\n await safeMergeConfig(argv.dir, project);\n\n // Safely merge in other auxiliary files\n await pullSystemConfig(argv);\n\n await printResultToConsoleAndExitGracefully(`\nSuccessfully linked your local directory to the ${project} project in the ${account} account.\n.env.zuplo and zuplo.jsonc have been updated with the new values.`);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/cli.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/engine.test.ts","../src/__tests__/import-openapi-utils.test.ts","../src/__tests__/import-openapi.test.ts","../src/__tests__/oas-test-data.ts","../src/__tests__/outdated.test.ts","../src/__tests__/tsconfig-upgrader.test.ts","../src/__tests__/integration/delete.integration.test.ts","../src/__tests__/integration/deploy.integration.test.ts","../src/__tests__/integration/jest-mocks-setup.ts","../src/__tests__/integration/jest-setup.ts","../src/__tests__/integration/link.integration.test.ts","../src/__tests__/integration/list.integration.test.ts","../src/__tests__/integration/test-utils.ts","../src/__tests__/integration/tunnel.integration.test.ts","../src/__tests__/integration/variable.integration.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/convert.ts","../src/cmds/delete.ts","../src/cmds/deploy.ts","../src/cmds/dev.ts","../src/cmds/editor.ts","../src/cmds/link.ts","../src/cmds/list.ts","../src/cmds/login.ts","../src/cmds/test.ts","../src/cmds/project/import-openapi.ts","../src/cmds/project/index.ts","../src/cmds/project/update.ts","../src/cmds/source/import-openapi.ts","../src/cmds/source/index.ts","../src/cmds/source/upgrade.ts","../src/cmds/tunnel/create.ts","../src/cmds/tunnel/delete.ts","../src/cmds/tunnel/describe.ts","../src/cmds/tunnel/index.ts","../src/cmds/tunnel/list.ts","../src/cmds/tunnel/rotate-token.ts","../src/cmds/tunnel/services/describe.ts","../src/cmds/tunnel/services/index.ts","../src/cmds/tunnel/services/update.ts","../src/cmds/variable/create.ts","../src/cmds/variable/index.ts","../src/cmds/variable/update.ts","../src/common/alias.ts","../src/common/args.ts","../src/common/constants.ts","../src/common/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.ts","../src/common/settings.ts","../src/common/worker-output.ts","../src/common/analytics/lib.ts","../src/common/api/lib.ts","../src/common/
|
|
1
|
+
{"root":["../src/cli.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/engine.test.ts","../src/__tests__/import-openapi-utils.test.ts","../src/__tests__/import-openapi.test.ts","../src/__tests__/oas-test-data.ts","../src/__tests__/outdated.test.ts","../src/__tests__/tsconfig-upgrader.test.ts","../src/__tests__/integration/delete.integration.test.ts","../src/__tests__/integration/deploy.integration.test.ts","../src/__tests__/integration/jest-mocks-setup.ts","../src/__tests__/integration/jest-setup.ts","../src/__tests__/integration/link.integration.test.ts","../src/__tests__/integration/list.integration.test.ts","../src/__tests__/integration/test-utils.ts","../src/__tests__/integration/tunnel.integration.test.ts","../src/__tests__/integration/variable.integration.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/convert.ts","../src/cmds/delete.ts","../src/cmds/deploy.ts","../src/cmds/dev.ts","../src/cmds/editor.ts","../src/cmds/link.ts","../src/cmds/list.ts","../src/cmds/login.ts","../src/cmds/test.ts","../src/cmds/project/import-openapi.ts","../src/cmds/project/index.ts","../src/cmds/project/update.ts","../src/cmds/source/import-openapi.ts","../src/cmds/source/index.ts","../src/cmds/source/upgrade.ts","../src/cmds/tunnel/create.ts","../src/cmds/tunnel/delete.ts","../src/cmds/tunnel/describe.ts","../src/cmds/tunnel/index.ts","../src/cmds/tunnel/list.ts","../src/cmds/tunnel/rotate-token.ts","../src/cmds/tunnel/services/describe.ts","../src/cmds/tunnel/services/index.ts","../src/cmds/tunnel/services/update.ts","../src/cmds/variable/create.ts","../src/cmds/variable/index.ts","../src/cmds/variable/update.ts","../src/common/alias.ts","../src/common/args.ts","../src/common/constants.ts","../src/common/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.ts","../src/common/settings.ts","../src/common/worker-output.ts","../src/common/analytics/lib.ts","../src/common/api/lib.ts","../src/common/machine-id/lib.ts","../src/common/middleware/authentication.ts","../src/common/middleware/get-account-param.ts","../src/common/middleware/get-environment-param.ts","../src/common/middleware/get-project-param.ts","../src/common/middleware/logging.ts","../src/common/middleware/user-configuration.ts","../src/common/middleware/user-identification.ts","../src/common/upgraders/lib.ts","../src/common/upgraders/package-json-upgrader.ts","../src/common/upgraders/tsconfig-upgrader.ts","../src/common/upgraders/vscode-settings-json-upgrader.ts","../src/common/utils/box.ts","../src/common/utils/ports.ts","../src/common/utils/pretty-print-environment-prompt.ts","../src/common/utils/types.ts","../src/common/utils/urls.ts","../src/common/validators/file-system-validator.ts","../src/common/validators/lib.ts","../src/common/validators/project-name-validator.ts","../src/common/xdg/lib.ts","../src/compile/handler.ts","../src/convert/engine.ts","../src/convert/handler.ts","../src/convert/routes.legacy.ts","../src/delete/handler.ts","../src/delete/poll-deployment.ts","../src/deploy/archive.ts","../src/deploy/environments.ts","../src/deploy/file-upload.ts","../src/deploy/handler.ts","../src/deploy/poll-deployment.ts","../src/dev/handler.ts","../src/editor/handler.ts","../src/editor/assets/index-7e947de6.js","../src/editor/server/cors-plugin.ts","../src/editor/server/server.ts","../src/editor/server/xfs.ts","../src/link/handler.ts","../src/link/populate.ts","../src/list/handler.ts","../src/login/html.ts","../src/login/login.ts","../src/login/server.ts","../src/login/tokens.ts","../src/project/import-openapi/handler.ts","../src/project/import-openapi/interfaces.ts","../src/project/import-openapi/utils.ts","../src/project/update/handler.ts","../src/test/esbuild-config.ts","../src/test/handler.ts","../src/test/invoke-test.ts","../src/test/test-files.test.ts","../src/test/test-files.ts","../src/test/esbuild-plugins/node-test-prep-plugin.ts","../src/tunnel/models.ts","../src/tunnel/create/handler.ts","../src/tunnel/delete/handler.ts","../src/tunnel/delete/poll-teardown-operation.ts","../src/tunnel/describe/handler.ts","../src/tunnel/list/handler.ts","../src/tunnel/rotate-token/handler.ts","../src/tunnel/services/describe/handler.ts","../src/tunnel/services/update/handler.ts","../src/tunnel/services/update/poll-provisioning-operations.ts","../src/variable/models.ts","../src/variable/create/handler.ts","../src/variable/update/handler.ts"],"version":"5.8.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "6.52.
|
|
3
|
+
"version": "6.52.17",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@opentelemetry/api": "1.9.0",
|
|
30
30
|
"@sentry/node": "9.22.0",
|
|
31
31
|
"@swc/core": "1.10.18",
|
|
32
|
-
"@zuplo/core": "6.52.
|
|
33
|
-
"@zuplo/openapi-tools": "6.52.
|
|
34
|
-
"@zuplo/runtime": "6.52.
|
|
32
|
+
"@zuplo/core": "6.52.17",
|
|
33
|
+
"@zuplo/openapi-tools": "6.52.17",
|
|
34
|
+
"@zuplo/runtime": "6.52.17",
|
|
35
35
|
"as-table": "1.0.55",
|
|
36
36
|
"chalk": "5.4.1",
|
|
37
37
|
"chokidar": "3.5.3",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Argv, MiddlewareFunction } from "yargs";
|
|
2
|
-
import type { ValidationRule } from "../validators/lib.js";
|
|
3
|
-
export interface AuthenticatedCommandOptions {
|
|
4
|
-
requireSelfHostedEndpoint?: boolean;
|
|
5
|
-
additionalValidators?: ValidationRule<unknown>[];
|
|
6
|
-
additionalMiddleware?: MiddlewareFunction[];
|
|
7
|
-
}
|
|
8
|
-
export declare class AuthenticatedCommandBuilder {
|
|
9
|
-
private options;
|
|
10
|
-
private constructor();
|
|
11
|
-
build(yargs: Argv, customBuilder?: (yargs: Argv) => Argv): Argv;
|
|
12
|
-
static create(
|
|
13
|
-
options?: AuthenticatedCommandOptions
|
|
14
|
-
): AuthenticatedCommandBuilder;
|
|
15
|
-
static withSelfHosted(
|
|
16
|
-
options?: Omit<AuthenticatedCommandOptions, "requireSelfHostedEndpoint">
|
|
17
|
-
): AuthenticatedCommandBuilder;
|
|
18
|
-
static withMiddleware(
|
|
19
|
-
middleware: MiddlewareFunction[],
|
|
20
|
-
options?: Omit<AuthenticatedCommandOptions, "middleware">
|
|
21
|
-
): AuthenticatedCommandBuilder;
|
|
22
|
-
private addStandardOptions;
|
|
23
|
-
private addValidationChecks;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=authenticated-command-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authenticated-command-builder.d.ts","sourceRoot":"","sources":["../../../src/common/builders/authenticated-command-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAOtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAY3D,MAAM,WAAW,2BAA2B;IAC1C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IAEjD,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC7C;AAmED,qBAAa,2BAA2B;IACtC,OAAO,CAAC,OAAO,CAA8B;IAE7C,OAAO;IAUP,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAyB/D,MAAM,CAAC,MAAM,CACX,OAAO,CAAC,EAAE,2BAA2B,GACpC,2BAA2B;IAO9B,MAAM,CAAC,cAAc,CACnB,OAAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,2BAA2B,CAAC,GACvE,2BAA2B;IAY9B,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,kBAAkB,EAAE,EAChC,OAAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,YAAY,CAAC,GACxD,2BAA2B;IAO9B,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,mBAAmB;CA+B5B"}
|