@zuplo/cli 1.136.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]="
|
|
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 {
|
|
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(
|
|
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=
|
|
47
|
+
//# debugId=0be777a5-8b5e-574a-8780-387d75ffa1a8
|
package/dist/cmds/login.js
CHANGED
|
@@ -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]="
|
|
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:
|
|
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=
|
|
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]="
|
|
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=
|
|
164
|
+
//# debugId=a750d299-a353-5bcd-b91f-5638e7666ba6
|
package/dist/link/handler.js
CHANGED
|
@@ -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]="
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 `${
|
|
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.
|
|
35
|
+
const projectResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/projects`, {
|
|
66
36
|
headers: {
|
|
67
|
-
authorization: `Bearer ${
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
const
|
|
101
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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=
|
|
144
|
+
//# debugId=f5e0af3e-c906-5b69-ba89-acd89c389920
|