bdy 1.18.24-dev-pipeline → 1.18.26-dev

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.
Files changed (34) hide show
  1. package/distTs/package.json +1 -2
  2. package/distTs/src/api/client.js +2 -9
  3. package/distTs/src/command/login.js +56 -19
  4. package/distTs/src/command/pipeline/run.js +125 -7
  5. package/distTs/src/command/project/get.js +18 -0
  6. package/distTs/src/command/project/link.js +11 -11
  7. package/distTs/src/command/project/set.js +31 -0
  8. package/distTs/src/command/sandbox/create.js +3 -2
  9. package/distTs/src/command/sandbox/get/yaml.js +30 -0
  10. package/distTs/src/command/vt/scrape.js +193 -0
  11. package/distTs/src/input.js +10 -6
  12. package/distTs/src/output.js +32 -82
  13. package/distTs/src/texts.js +39 -29
  14. package/distTs/src/tunnel/api/buddy.js +9 -15
  15. package/package.json +1 -2
  16. package/distTs/src/command/crawl/validation.js +0 -151
  17. package/distTs/src/command/crawl.js +0 -144
  18. package/distTs/src/command/pipeline/run/start.js +0 -101
  19. package/distTs/src/command/pipeline/run/status.js +0 -34
  20. package/distTs/src/command/tests/capture/validation.js +0 -59
  21. package/distTs/src/command/tests/capture.js +0 -100
  22. package/distTs/src/command/tests/unit/upload.js +0 -86
  23. package/distTs/src/command/tests/unit.js +0 -11
  24. package/distTs/src/command/tests/visual/session/close.js +0 -27
  25. package/distTs/src/command/tests/visual/session/create.js +0 -82
  26. package/distTs/src/command/tests/visual/session.js +0 -13
  27. package/distTs/src/command/tests/visual/setup.js +0 -20
  28. package/distTs/src/command/tests/visual/shared/validation.js +0 -118
  29. package/distTs/src/command/tests/visual/upload.js +0 -138
  30. package/distTs/src/command/tests/visual.js +0 -15
  31. package/distTs/src/command/tests.js +0 -15
  32. package/distTs/src/output/pipeline.js +0 -915
  33. package/distTs/src/types/crawl.js +0 -2
  34. package/distTs/src/types/pipeline.js +0 -424
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.18.24-dev-pipeline",
4
+ "version": "1.18.26-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -55,7 +55,6 @@
55
55
  "mime-db": "1.52.0",
56
56
  "mime-types": "2.1.35",
57
57
  "netmask": "2.0.2",
58
- "node-fetch": "3.3.2",
59
58
  "node-forge": "1.3.3",
60
59
  "open": "11.0.0",
61
60
  "path-is-inside": "1.0.2",
@@ -216,13 +216,6 @@ class ApiClient {
216
216
  throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
217
217
  }
218
218
  }
219
- async getPipelineRunActionExecution(workspace, project, pipelineId, executionId, actionExecutionId) {
220
- return await this.request({
221
- method: 'GET',
222
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}/action_executions/${encodeURIComponent(actionExecutionId)}`,
223
- parseResponseBody: true,
224
- });
225
- }
226
219
  async getPipelineRun(workspace, project, pipelineId, executionId) {
227
220
  return await this.request({
228
221
  method: 'GET',
@@ -728,14 +721,14 @@ class ApiClient {
728
721
  return await this.request({
729
722
  method: 'POST',
730
723
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/stop`,
731
- parseResponseBody: true,
724
+ parseResponseBody: true
732
725
  });
733
726
  }
734
727
  async startSandboxApp(workspace, sandboxId, appId) {
735
728
  return await this.request({
736
729
  method: 'POST',
737
730
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/start`,
738
- parseResponseBody: true,
731
+ parseResponseBody: true
739
732
  });
740
733
  }
741
734
  async getSandboxAppLogs(workspace, sandboxId, appId, cursor) {
@@ -9,10 +9,9 @@ const node_http_1 = __importDefault(require("node:http"));
9
9
  const texts_1 = require("../texts");
10
10
  const utils_1 = require("../utils");
11
11
  const input_1 = __importDefault(require("../input"));
12
- const logger_1 = __importDefault(require("../logger"));
12
+ const uuid_1 = require("uuid");
13
13
  const OAUTH_CLIENT_APP_PORT = 7596;
14
14
  const OAUTH_CLIENT_APP_HOST = 'localhost';
15
- const OAUTH_CLIENT_APP_REDIRECT_URL = `http://localhost:${OAUTH_CLIENT_APP_PORT}`;
16
15
  const OAUTH_CLIENT_APP_SCOPES = [
17
16
  'WORKSPACE',
18
17
  'MEMBER_EMAIL',
@@ -32,45 +31,84 @@ const OAUTH_CLIENT_APP_SCOPES = [
32
31
  'TUNNEL_MANAGE',
33
32
  'UNIT_TEST_MANAGE',
34
33
  ];
34
+ function getRedirectUrl(api) {
35
+ return `https://${api}/oauth2/cli`;
36
+ }
35
37
  async function oauthServer(api, clientId, clientSecret) {
36
38
  const ApiClient = require('../api/client').default;
37
39
  const open = require('open').default;
40
+ const redirectUrl = getRedirectUrl(api);
38
41
  return new Promise((resolve) => {
39
- const s = node_http_1.default.createServer(async (req, res) => {
40
- const url = new URL(req.url || '', `http://${OAUTH_CLIENT_APP_HOST}`);
41
- const urlCode = url.searchParams.get('code');
42
- if (!urlCode) {
43
- res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
44
- return;
45
- }
42
+ const state = (0, uuid_1.v4)();
43
+ const abortCode = new AbortController();
44
+ const exchange = async (urlCode, urlState, res) => {
46
45
  const client = new ApiClient(new URL(`https://${api}`));
47
46
  try {
48
- const response = await client.exchangeAppToken(urlCode, clientId, clientSecret, OAUTH_CLIENT_APP_REDIRECT_URL);
49
- res.end(texts_1.ERR_LOGIN_HTTP_SUCCESS);
47
+ const response = await client.exchangeAppToken(urlCode, clientId, clientSecret, redirectUrl);
48
+ if (res)
49
+ res.end(urlState);
50
50
  s.close();
51
+ abortCode.abort('OK');
51
52
  resolve({
52
53
  token: response.access_token,
53
54
  refreshToken: response.refresh_token,
54
55
  });
56
+ return true;
55
57
  }
56
58
  catch {
59
+ if (res)
60
+ res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
61
+ return false;
62
+ }
63
+ };
64
+ const s = node_http_1.default.createServer(async (req, res) => {
65
+ res.setHeader('access-control-allow-origin', '*');
66
+ const url = new URL(req.url || '', `http://${OAUTH_CLIENT_APP_HOST}`);
67
+ const urlCode = url.searchParams.get('code');
68
+ const urlState = url.searchParams.get('state');
69
+ if (!urlCode || urlState !== state) {
57
70
  res.end(texts_1.ERR_LOGIN_HTTP_FAILED);
58
- s.close();
59
- output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_FAILED);
71
+ return;
60
72
  }
73
+ await exchange(urlCode, urlState, res);
61
74
  });
62
75
  s.on('error', () => {
63
76
  s.close();
64
77
  output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_SERVER_PORT_TAKEN);
65
78
  });
66
- s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST, () => {
67
- const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CLIENT_APP_REDIRECT_URL)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}`;
68
- open(url);
79
+ s.listen(OAUTH_CLIENT_APP_PORT, OAUTH_CLIENT_APP_HOST, async () => {
80
+ const url = `https://${api}/oauth2/authorize?type=web_server&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=${encodeURIComponent(OAUTH_CLIENT_APP_SCOPES.join(' '))}&state=${encodeURIComponent(state)}`;
81
+ try {
82
+ await open(url);
83
+ }
84
+ catch {
85
+ // do nothing
86
+ }
87
+ output_1.default.normal(texts_1.TXT_LOGIN_OPEN_URL);
88
+ output_1.default.normal(url.replace(/%/g, '%%'));
89
+ output_1.default.normal('');
90
+ for (;;) {
91
+ try {
92
+ const code = await output_1.default.inputString(texts_1.TXT_LOGIN_PROVIDE_CODE, undefined, false, abortCode.signal);
93
+ const success = await exchange(code, state);
94
+ if (success)
95
+ break;
96
+ }
97
+ catch (err) {
98
+ if (err.name === 'AbortPromptError') {
99
+ break;
100
+ }
101
+ else if (err.name === 'ExitPromptError') {
102
+ output_1.default.exitError(texts_1.ERR_LOGIN_HTTP_CANCEL);
103
+ }
104
+ }
105
+ }
69
106
  });
70
107
  });
71
108
  }
72
109
  async function getOrCreateApp(api) {
73
110
  const ApiClient = require('../api/client').default;
111
+ const redirectUrl = getRedirectUrl(api);
74
112
  const client = new ApiClient(new URL(`https://${api}`));
75
113
  let clientId = cfg_1.default.getApiClientId();
76
114
  let clientSecret = cfg_1.default.getApiClientSecret();
@@ -81,7 +119,7 @@ async function getOrCreateApp(api) {
81
119
  const app = await client.getApp(clientId);
82
120
  if (!app ||
83
121
  !app.redirect_uris ||
84
- !app.redirect_uris.includes(OAUTH_CLIENT_APP_REDIRECT_URL)) {
122
+ !app.redirect_uris.includes(redirectUrl)) {
85
123
  clear = true;
86
124
  }
87
125
  }
@@ -95,7 +133,7 @@ async function getOrCreateApp(api) {
95
133
  }
96
134
  }
97
135
  if (!clientId || !clientSecret || !clientToken) {
98
- const app = await client.registerApp('Buddy CLI', OAUTH_CLIENT_APP_REDIRECT_URL);
136
+ const app = await client.registerApp('Buddy CLI', redirectUrl);
99
137
  clientId = app.client_id;
100
138
  clientSecret = app.client_secret;
101
139
  clientToken = app.registration_access_token;
@@ -139,7 +177,6 @@ commandLogin.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
139
177
  commandLogin.option('--region <region>', texts_1.OPTION_REST_API_REGION);
140
178
  commandLogin.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
141
179
  commandLogin.action(async (options) => {
142
- logger_1.default.info(options);
143
180
  output_1.default.handleSignals();
144
181
  cfg_1.default.clearLogin();
145
182
  let api = options.api || process.env.BUDDY_API_ENDPOINT;
@@ -5,12 +5,130 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../utils");
7
7
  const texts_1 = require("../../texts");
8
- const status_1 = __importDefault(require("./run/status"));
9
- const start_1 = __importDefault(require("./run/start"));
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const format_1 = __importDefault(require("../../format"));
10
11
  const commandPipelineRun = (0, utils_1.newCommand)('run', texts_1.DESC_COMMAND_PIPELINE_RUN);
11
- commandPipelineRun.addCommand(start_1.default);
12
- commandPipelineRun.addCommand(status_1.default);
13
- commandPipelineRun.addHelpText('after', `
14
- EXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_START}
15
- ${texts_1.EXAMPLE_PIPELINE_RUN_STATUS}`);
12
+ commandPipelineRun.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineRun.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineRun.option('-b, --branch <branch>', texts_1.OPTION_PIPELINE_RUN_BRANCH);
15
+ commandPipelineRun.option('-t, --tag <tag>', texts_1.OPTION_PIPELINE_RUN_TAG);
16
+ commandPipelineRun.option('-pr, --pull-request <pull request>', texts_1.OPTION_PIPELINE_RUN_PULL_REQUEST);
17
+ commandPipelineRun.option('-r, --revision <revision>', texts_1.OPTION_PIPELINE_RUN_REVISION);
18
+ commandPipelineRun.option('--comment <comment>', texts_1.OPTION_PIPELINE_RUN_COMMENT);
19
+ commandPipelineRun.option('-f, --refresh', texts_1.OPTION_PIPELINE_RUN_REFRESH);
20
+ commandPipelineRun.option('-c, --clear-cache', texts_1.OPTION_PIPELINE_RUN_CLEAR_CACHE);
21
+ commandPipelineRun.option('--priority <priority>', texts_1.OPTION_PIPELINE_RUN_PRIORITY);
22
+ commandPipelineRun.option('-v, --variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
23
+ commandPipelineRun.option('-vm, --variable-masked <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
24
+ commandPipelineRun.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
25
+ commandPipelineRun.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
26
+ commandPipelineRun.option('--wait [minutes]', texts_1.OPTION_PIPELINE_RUN_WAIT);
27
+ commandPipelineRun.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
28
+ commandPipelineRun.usage('<identifier> [options]');
29
+ commandPipelineRun.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN);
30
+ commandPipelineRun.action(async (identifier, options) => {
31
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
32
+ const project = input_1.default.restApiProject(options.project);
33
+ const client = input_1.default.restApiTokenClient();
34
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
35
+ if (!data || !data.domain) {
36
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
37
+ }
38
+ if (!data.project_identifier) {
39
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
40
+ }
41
+ if (!data.pipeline_id) {
42
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
43
+ }
44
+ const body = {};
45
+ if (options.branch) {
46
+ body.branch = {
47
+ name: options.branch,
48
+ };
49
+ }
50
+ if (options.tag) {
51
+ body.tag = {
52
+ name: options.tag,
53
+ };
54
+ }
55
+ if (options.pullRequest) {
56
+ body.pull_request = {
57
+ name: `pull/${options.pullRequest}`,
58
+ };
59
+ }
60
+ if (options.revision) {
61
+ body.to_revision = {
62
+ revision: options.revision,
63
+ };
64
+ }
65
+ if (options.comment) {
66
+ body.comment = options.comment;
67
+ }
68
+ if (options.refresh) {
69
+ body.refresh = true;
70
+ }
71
+ if (options.clearCache) {
72
+ body.clear_cache = true;
73
+ }
74
+ const priority = input_1.default.pipelineRunPriority(options.priority);
75
+ if (priority) {
76
+ body.priority = priority;
77
+ }
78
+ body.variables = [];
79
+ if (options.variable) {
80
+ body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
81
+ }
82
+ if (options.variableMasked) {
83
+ body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableMasked, true));
84
+ }
85
+ const delay = input_1.default.pipelineRunDelay(options.schedule);
86
+ if (delay) {
87
+ body.delay_until = delay;
88
+ }
89
+ const actions = input_1.default.pipelineRunAction(options.action);
90
+ if (actions) {
91
+ body.actions_to_run = actions;
92
+ }
93
+ const result = await client.pipelineRun(workspace, project, data.pipeline_id, body);
94
+ if (options.wait) {
95
+ const minutes = input_1.default.pipelineRunWaitTime(options.wait);
96
+ wait(minutes, workspace, project, data.pipeline_id, result.id, result.html_url, client);
97
+ }
98
+ else {
99
+ output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_SUCCESS)(result.html_url));
100
+ }
101
+ });
102
+ const wait = (minutes, workspace, project, pipelineId, runId, htmlUrl, client) => {
103
+ const start = Date.now();
104
+ output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_WAIT)(minutes));
105
+ let fetchCounter = 1;
106
+ const ts1 = setTimeout(() => {
107
+ output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WAIT_TIMEOUT);
108
+ }, minutes * 60 * 1000);
109
+ const ts2 = setInterval(async () => {
110
+ output_1.default.clearPreviousLine();
111
+ output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_STILL_WAITING)(formatWaitTime(start)));
112
+ if (fetchCounter >= 3) {
113
+ const run = await client.getPipelineRun(workspace, project, pipelineId, runId);
114
+ if (!['INPROGRESS', 'ENQUEUED', 'TERMINATING'].includes(run.status)) {
115
+ clearTimeout(ts1);
116
+ clearInterval(ts2);
117
+ output_1.default.clearPreviousLine();
118
+ if (run.status === 'SUCCESSFUL') {
119
+ output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY)(htmlUrl));
120
+ }
121
+ else {
122
+ output_1.default.exitError((0, texts_1.TXT_PIPELINE_RUN_FINISH_FAILED)(run.status, htmlUrl));
123
+ }
124
+ }
125
+ fetchCounter = 0;
126
+ }
127
+ fetchCounter += 1;
128
+ }, 1000);
129
+ };
130
+ const formatWaitTime = (start) => {
131
+ const elapsed = Math.floor((Date.now() - start) / 1000);
132
+ return format_1.default.pipelineRunWaitTime(elapsed);
133
+ };
16
134
  exports.default = commandPipelineRun;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
7
+ const output_1 = __importDefault(require("../../output"));
8
+ const texts_1 = require("../../texts");
9
+ const utils_1 = require("../../utils");
10
+ const commandProjectGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PROJECT_GET);
11
+ commandProjectGet.action(async () => {
12
+ const project = cfg_1.default.getProject();
13
+ if (!project) {
14
+ output_1.default.exitError(texts_1.TXT_PROJECT_NONE);
15
+ }
16
+ output_1.default.exitNormal(project);
17
+ });
18
+ exports.default = commandProjectGet;
@@ -23,7 +23,7 @@ commandProjectLink.action(async (dir, options) => {
23
23
  ProjectCfg.init(path, workspace, project);
24
24
  output_1.default.okSign();
25
25
  output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_LINK_TO, false);
26
- output_1.default.cyan(` ${url}`);
26
+ output_1.default.light(` ${url}`);
27
27
  await initRepo(workspace, project, path, git, options);
28
28
  tryNow();
29
29
  output_1.default.exitNormal();
@@ -54,13 +54,13 @@ const tryNow = () => {
54
54
  output_1.default.arrowSign();
55
55
  output_1.default.label(texts_1.OPT_COMMAND_PROJECT_LINK_TRY_NOW);
56
56
  output_1.default.dim('$ ', false);
57
- output_1.default.cyan('bdy tunnel http 3000 ', false);
57
+ output_1.default.light('bdy tunnel http 3000 ', false);
58
58
  output_1.default.muted(' Expose localhost:3000 to the internet');
59
59
  output_1.default.dim('$ ', false);
60
- output_1.default.cyan('bdy package publish . ', false);
60
+ output_1.default.light('bdy package publish . ', false);
61
61
  output_1.default.muted(' Publish a package from the current project');
62
62
  output_1.default.dim('$ ', false);
63
- output_1.default.cyan('bdy sandbox create --run "npm start" ', false);
63
+ output_1.default.light('bdy sandbox create --run "npm start" ', false);
64
64
  output_1.default.muted(' Spin up a cloud sandbox and run your app');
65
65
  };
66
66
  const initRepo = async (workspace, project, path, git, options) => {
@@ -89,16 +89,16 @@ const initRepo = async (workspace, project, path, git, options) => {
89
89
  });
90
90
  output_1.default.okSign();
91
91
  output_1.default.normal('Remote ', false);
92
- output_1.default.cyan('origin ', false);
92
+ output_1.default.light('origin ', false);
93
93
  output_1.default.normal('set to ', false);
94
- output_1.default.cyan(remote);
94
+ output_1.default.light(remote);
95
95
  }
96
96
  else if (remotes.origin !== remote) {
97
97
  output_1.default.yellow(texts_1.OPT_COMMAND_PROJECT_LINK_HAS_REMOTE);
98
98
  output_1.default.normal('Current origin: ', false);
99
- output_1.default.cyan(remotes.origin);
99
+ output_1.default.light(remotes.origin);
100
100
  output_1.default.normal('Buddy project: ', false);
101
- output_1.default.cyan(remote);
101
+ output_1.default.light(remote);
102
102
  const opt = await output_1.default.inputMenuAdv(texts_1.OPT_COMMAND_PROJECT_LINK_SET_GIT_REMOTE, [
103
103
  {
104
104
  name: 'Add buddy remote',
@@ -127,9 +127,9 @@ const initRepo = async (workspace, project, path, git, options) => {
127
127
  });
128
128
  output_1.default.okSign();
129
129
  output_1.default.normal('Remote ', false);
130
- output_1.default.cyan('buddy ', false);
130
+ output_1.default.light('buddy ', false);
131
131
  output_1.default.normal('set to ', false);
132
- output_1.default.cyan(remote);
132
+ output_1.default.light(remote);
133
133
  }
134
134
  else if (opt === 'origin') {
135
135
  await (0, utils_1.execLocally)(`git remote rm origin`, {
@@ -140,7 +140,7 @@ const initRepo = async (workspace, project, path, git, options) => {
140
140
  });
141
141
  output_1.default.okSign();
142
142
  output_1.default.normal('Origin replaced with ', false);
143
- output_1.default.cyan(remote);
143
+ output_1.default.light(remote);
144
144
  }
145
145
  else {
146
146
  return;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
7
+ const output_1 = __importDefault(require("../../output"));
8
+ const texts_1 = require("../../texts");
9
+ const utils_1 = require("../../utils");
10
+ const input_1 = __importDefault(require("../../input"));
11
+ const commandProjectSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_PROJECT_SET);
12
+ commandProjectSet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandProjectSet.argument('[project]', texts_1.ARG_COMMAND_PROJECT_NAME);
14
+ commandProjectSet.action(async (project, options) => {
15
+ output_1.default.handleSignals();
16
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
17
+ const client = input_1.default.restApiTokenClient();
18
+ if (project) {
19
+ await client.getProject(workspace, project);
20
+ }
21
+ else {
22
+ const response = await client.getProjects(workspace);
23
+ project = await output_1.default.selectProject(response.projects);
24
+ }
25
+ cfg_1.default.setProject(project);
26
+ if (!project)
27
+ output_1.default.exitSuccess(texts_1.TXT_PROJECT_SET_CLEARED);
28
+ else
29
+ output_1.default.exitSuccess((0, texts_1.TXT_PROJECT_SET_SUCCESS)(project));
30
+ });
31
+ exports.default = commandProjectSet;
@@ -139,9 +139,10 @@ commandSandboxCreate.action(async (options) => {
139
139
  }
140
140
  }
141
141
  output_1.default.green((0, texts_1.TXT_SANDBOX_CREATED)(result.identifier));
142
- output_1.default.normal(result.html_url);
142
+ output_1.default.dim('SSH: ', false);
143
143
  output_1.default.cyan(`ssh ${result.ssh_host} -p ${result.ssh_port}`);
144
- //
144
+ output_1.default.dim('Web terminal: ', false);
145
+ output_1.default.cyan(result.html_url);
145
146
  output_1.default.exitNormal();
146
147
  });
147
148
  exports.default = commandSandboxCreate;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const commandSandboxGetYaml = (0, utils_1.newCommand)('yaml', texts_1.DESC_COMMAND_SANDBOX_GET_YAML);
11
+ commandSandboxGetYaml.hideVersionUpdate = true;
12
+ commandSandboxGetYaml.alias('yml');
13
+ commandSandboxGetYaml.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
+ commandSandboxGetYaml.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
+ commandSandboxGetYaml.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
16
+ commandSandboxGetYaml.action(async (identifier, options) => {
17
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
18
+ const project = input_1.default.restApiProject(options.project);
19
+ const client = input_1.default.restApiTokenClient();
20
+ let result = await client.listSandboxes(workspace, project);
21
+ const sandboxes = result.sandboxes || [];
22
+ const found = sandboxes.find((s) => s.identifier === identifier);
23
+ if (!found) {
24
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
25
+ }
26
+ const sandboxId = found.id;
27
+ result = await client.getSandboxYaml(workspace, sandboxId);
28
+ output_1.default.exitNormal(Buffer.from(result.yaml, 'base64').toString('utf8'));
29
+ });
30
+ exports.default = commandSandboxGetYaml;