bdy 1.17.29-dev → 1.18.0-dev-scrape-869b6rbvf
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/distTs/package.json +1 -1
- package/distTs/src/api/client.js +70 -6
- package/distTs/src/command/domain/buy.js +278 -0
- package/distTs/src/command/domain/get.js +45 -0
- package/distTs/src/command/domain/list.js +27 -0
- package/distTs/src/command/domain.js +15 -0
- package/distTs/src/command/project/link.js +1 -1
- package/distTs/src/command/scrape/validation.js +157 -0
- package/distTs/src/command/{vt/scrape.js → scrape.js} +43 -93
- package/distTs/src/command/vt/close.js +1 -1
- package/distTs/src/command/vt/compare/validation.js +6 -120
- package/distTs/src/command/vt/compare.js +1 -1
- package/distTs/src/command/vt/exec.js +1 -1
- package/distTs/src/command/vt/shared/validation.js +118 -0
- package/distTs/src/command/vt/storybook.js +1 -1
- package/distTs/src/command/vt.js +0 -2
- package/distTs/src/index.js +4 -0
- package/distTs/src/output.js +22 -3
- package/distTs/src/texts.js +36 -21
- package/distTs/src/visualTest/context.js +3 -2
- package/distTs/src/visualTest/requests.js +39 -24
- package/distTs/src/visualTest/validation.js +5 -2
- package/package.json +1 -1
- package/distTs/src/command/project/get.js +0 -18
- package/distTs/src/command/project/set.js +0 -31
- package/distTs/src/command/sandbox/get/yaml.js +0 -30
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -253,7 +253,7 @@ class ApiClient {
|
|
|
253
253
|
method: 'POST',
|
|
254
254
|
path: `/workspaces/${encodeURIComponent(workspace)}/projects`,
|
|
255
255
|
body,
|
|
256
|
-
parseResponseBody: true
|
|
256
|
+
parseResponseBody: true,
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
async pipelineRun(workspace, project, pipelineId, body) {
|
|
@@ -278,14 +278,14 @@ class ApiClient {
|
|
|
278
278
|
method: 'POST',
|
|
279
279
|
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/yaml?project_name=${encodeURIComponent(project)}`,
|
|
280
280
|
body,
|
|
281
|
-
parseResponseBody: true
|
|
281
|
+
parseResponseBody: true,
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
async getSandboxYaml(workspace, sandboxId) {
|
|
285
285
|
return await this.request({
|
|
286
286
|
method: 'GET',
|
|
287
287
|
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/yaml`,
|
|
288
|
-
parseResponseBody: true
|
|
288
|
+
parseResponseBody: true,
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
async updateSandboxByYaml(workspace, sandboxId, body) {
|
|
@@ -293,7 +293,7 @@ class ApiClient {
|
|
|
293
293
|
method: 'PATCH',
|
|
294
294
|
path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/yaml`,
|
|
295
295
|
body,
|
|
296
|
-
parseResponseBody: true
|
|
296
|
+
parseResponseBody: true,
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
async sandboxDownloadFile(workspace, sandboxId, remotePath) {
|
|
@@ -359,6 +359,70 @@ class ApiClient {
|
|
|
359
359
|
parseResponseBody: true,
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
+
async domainBuy(workspace, name, onOwnerBehalf = false, autoRenew = true) {
|
|
363
|
+
return await this.request({
|
|
364
|
+
method: 'POST',
|
|
365
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/register`,
|
|
366
|
+
body: {
|
|
367
|
+
name,
|
|
368
|
+
on_owner_behalf: onOwnerBehalf,
|
|
369
|
+
auto_renew: autoRenew,
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
async domainClaim(workspace, name, onOwnerBehalf = false) {
|
|
374
|
+
return await this.request({
|
|
375
|
+
method: 'POST',
|
|
376
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/claim`,
|
|
377
|
+
body: {
|
|
378
|
+
name,
|
|
379
|
+
on_owner_behalf: onOwnerBehalf,
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async domainSearch(workspace, domains) {
|
|
384
|
+
return await this.request({
|
|
385
|
+
method: 'POST',
|
|
386
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/search`,
|
|
387
|
+
body: { domains },
|
|
388
|
+
parseResponseBody: true,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
async getDomains(workspace) {
|
|
392
|
+
return await this.request({
|
|
393
|
+
method: 'GET',
|
|
394
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains`,
|
|
395
|
+
parseResponseBody: true,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
async getDomain(workspace, id) {
|
|
399
|
+
return await this.request({
|
|
400
|
+
method: 'GET',
|
|
401
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/${encodeURIComponent(id)}`,
|
|
402
|
+
parseResponseBody: true,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async domainSuggest(workspace, prompt, tlds, limit) {
|
|
406
|
+
const body = {
|
|
407
|
+
prompt,
|
|
408
|
+
limit,
|
|
409
|
+
};
|
|
410
|
+
if (tlds.length > 0)
|
|
411
|
+
body.tlds = tlds;
|
|
412
|
+
return await this.request({
|
|
413
|
+
method: 'POST',
|
|
414
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/suggest`,
|
|
415
|
+
body,
|
|
416
|
+
parseResponseBody: true,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
async domainClaimable(workspace, name) {
|
|
420
|
+
return await this.request({
|
|
421
|
+
method: 'GET',
|
|
422
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/domains/claimable/${encodeURIComponent(name)}`,
|
|
423
|
+
parseResponseBody: true,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
362
426
|
async registerApp(name, redirectUrl) {
|
|
363
427
|
return await this.request({
|
|
364
428
|
method: 'POST',
|
|
@@ -569,7 +633,7 @@ class ApiClient {
|
|
|
569
633
|
return await this.request({
|
|
570
634
|
method: 'GET',
|
|
571
635
|
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}`,
|
|
572
|
-
parseResponseBody: true
|
|
636
|
+
parseResponseBody: true,
|
|
573
637
|
});
|
|
574
638
|
}
|
|
575
639
|
async getProjects(workspace, page = 1, perPage = 100) {
|
|
@@ -626,7 +690,7 @@ class ApiClient {
|
|
|
626
690
|
async getSandboxByIdentifier(workspace, project, sandbox) {
|
|
627
691
|
const opts = {
|
|
628
692
|
project,
|
|
629
|
-
sandbox
|
|
693
|
+
sandbox,
|
|
630
694
|
};
|
|
631
695
|
return await this.getResourceByIdentifier(workspace, opts);
|
|
632
696
|
}
|
|
@@ -0,0 +1,278 @@
|
|
|
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 output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const popularTlds = [
|
|
11
|
+
'com',
|
|
12
|
+
'ai',
|
|
13
|
+
'io',
|
|
14
|
+
'net',
|
|
15
|
+
'cloud',
|
|
16
|
+
'dev',
|
|
17
|
+
'app',
|
|
18
|
+
'info',
|
|
19
|
+
'blog',
|
|
20
|
+
'run',
|
|
21
|
+
'me',
|
|
22
|
+
'at',
|
|
23
|
+
'nl',
|
|
24
|
+
'xyz',
|
|
25
|
+
'org',
|
|
26
|
+
'co',
|
|
27
|
+
'tech',
|
|
28
|
+
'studio',
|
|
29
|
+
'sh',
|
|
30
|
+
'space',
|
|
31
|
+
'fyi',
|
|
32
|
+
'link',
|
|
33
|
+
'es',
|
|
34
|
+
'art',
|
|
35
|
+
'club',
|
|
36
|
+
'inc',
|
|
37
|
+
'pro',
|
|
38
|
+
'store',
|
|
39
|
+
'shop',
|
|
40
|
+
'one',
|
|
41
|
+
'biz',
|
|
42
|
+
'vip',
|
|
43
|
+
'tube',
|
|
44
|
+
'online',
|
|
45
|
+
'design',
|
|
46
|
+
'realty',
|
|
47
|
+
'audio',
|
|
48
|
+
'lol',
|
|
49
|
+
'pics',
|
|
50
|
+
'love',
|
|
51
|
+
'baby',
|
|
52
|
+
'lat',
|
|
53
|
+
'so',
|
|
54
|
+
'homes',
|
|
55
|
+
'beauty',
|
|
56
|
+
'buzz',
|
|
57
|
+
'mom',
|
|
58
|
+
'my',
|
|
59
|
+
];
|
|
60
|
+
const commandDomainBuy = (0, utils_1.newCommand)('buy', texts_1.DESC_COMMAND_DOMAIN_BUY);
|
|
61
|
+
commandDomainBuy.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
62
|
+
commandDomainBuy.option('-d, --tld <tld...>', texts_1.OPT_COMMAND_DOMAIN_BUY_TLD);
|
|
63
|
+
commandDomainBuy.option('-o, --owner-behalf', texts_1.OPT_COMMAND_DOMAIN_BUY_OWNER);
|
|
64
|
+
commandDomainBuy.argument('[domain|prompt]', texts_1.OPT_COMMAND_DOMAIN_PHRASE);
|
|
65
|
+
commandDomainBuy.action(async (text, options) => {
|
|
66
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
67
|
+
const client = input_1.default.restApiTokenClient();
|
|
68
|
+
const tlds = getAllowedTlds(options.tld);
|
|
69
|
+
const prompt = (text || '').trim().toLowerCase();
|
|
70
|
+
const onOwnerBehalf = !!options.ownerBehalf;
|
|
71
|
+
if (output_1.default.isTTY()) {
|
|
72
|
+
await interactive(client, workspace, prompt, tlds, onOwnerBehalf);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
await nonInteractive(client, workspace, prompt, tlds, onOwnerBehalf);
|
|
76
|
+
}
|
|
77
|
+
output_1.default.exitNormal();
|
|
78
|
+
});
|
|
79
|
+
const formatDomainPrice = (price) => {
|
|
80
|
+
const sign = price.currency === 'USD' ? '$' : '€';
|
|
81
|
+
const value = price.price * price.min_duration;
|
|
82
|
+
const duration = price.min_duration === 1 ? '1yr' : `${price.min_duration}yrs`;
|
|
83
|
+
return `${sign}${value.toFixed(2)} (${duration})`;
|
|
84
|
+
};
|
|
85
|
+
const formatClaim = (domain, available) => {
|
|
86
|
+
if (available) {
|
|
87
|
+
return `${output_1.default.getGreenColor(domain)} (Free)`;
|
|
88
|
+
}
|
|
89
|
+
return output_1.default.getDimColor(`${domain} (Unavailable)`);
|
|
90
|
+
};
|
|
91
|
+
const formatDomain = (domain) => {
|
|
92
|
+
if (!domain.available || domain.premium) {
|
|
93
|
+
return output_1.default.getDimColor(`${domain.name} (Unavailable)`);
|
|
94
|
+
}
|
|
95
|
+
return `${output_1.default.getGreenColor(domain.name)} ${formatDomainPrice(domain.prices.create)} / ${formatDomainPrice(domain.prices.renew)}`;
|
|
96
|
+
};
|
|
97
|
+
const isValidDomain = (prompt) => {
|
|
98
|
+
return /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/i.test(prompt);
|
|
99
|
+
};
|
|
100
|
+
const isValidSubdomain = (prompt) => {
|
|
101
|
+
return /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(prompt);
|
|
102
|
+
};
|
|
103
|
+
const getSubdomain = (domain) => {
|
|
104
|
+
const idx = domain.indexOf('.');
|
|
105
|
+
if (idx < 0)
|
|
106
|
+
return '';
|
|
107
|
+
return domain.substring(0, idx);
|
|
108
|
+
};
|
|
109
|
+
const getTld = (domain) => {
|
|
110
|
+
const idx = domain.lastIndexOf('.');
|
|
111
|
+
if (idx < 0)
|
|
112
|
+
return '';
|
|
113
|
+
return domain.substring(idx + 1);
|
|
114
|
+
};
|
|
115
|
+
const claimNonInteractive = async (client, workspace, domain, onOwnerBehalf) => {
|
|
116
|
+
output_1.default.arrowSign();
|
|
117
|
+
output_1.default.normal(`Matched: ${formatClaim(domain, true)}`);
|
|
118
|
+
await client.domainClaim(workspace, domain, onOwnerBehalf);
|
|
119
|
+
output_1.default.okSign();
|
|
120
|
+
output_1.default.normal(`${domain} claimed`);
|
|
121
|
+
};
|
|
122
|
+
const buyNonInteractive = async (client, workspace, domain, onOwnerBehalf) => {
|
|
123
|
+
output_1.default.arrowSign();
|
|
124
|
+
output_1.default.normal(`Matched: ${formatDomain(domain)}`);
|
|
125
|
+
if (domain.available && !domain.premium) {
|
|
126
|
+
await client.domainBuy(workspace, domain.name, onOwnerBehalf, true);
|
|
127
|
+
output_1.default.okSign();
|
|
128
|
+
output_1.default.normal(`${domain.name} bought`);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const interactive = async (client, workspace, prompt, tlds, onOwnerBehalf) => {
|
|
132
|
+
if (!prompt) {
|
|
133
|
+
prompt = await output_1.default.inputString(texts_1.TXT_COMMAND_DOMAIN_BUY_PROVIDE_PROMPT);
|
|
134
|
+
}
|
|
135
|
+
if (!prompt) {
|
|
136
|
+
output_1.default.exitError(texts_1.TXT_COMMAND_DOMAIN_BUY_PROMPT_REQUIRED);
|
|
137
|
+
}
|
|
138
|
+
output_1.default.arrowSign();
|
|
139
|
+
output_1.default.normal(`Searching...`);
|
|
140
|
+
let items = [];
|
|
141
|
+
const createValue = (type, name) => {
|
|
142
|
+
return `${type}:${name}`;
|
|
143
|
+
};
|
|
144
|
+
if (isValidDomain(prompt)) {
|
|
145
|
+
const subdomain = getSubdomain(prompt);
|
|
146
|
+
const claims = await client.domainClaimable(workspace, subdomain);
|
|
147
|
+
const claimable = claims.domains.find((c) => `${subdomain}.${c.domain}` === prompt);
|
|
148
|
+
if (claimable) {
|
|
149
|
+
items.push(output_1.default.createMenuSeparator('Matched'));
|
|
150
|
+
items.push(output_1.default.createMenuItem(formatClaim(prompt, claimable.available), createValue('claim', prompt)));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const search = await client.domainSearch(workspace, [prompt]);
|
|
154
|
+
const buyable = search.domains.find((d) => d.name === prompt);
|
|
155
|
+
if (buyable) {
|
|
156
|
+
items.push(output_1.default.createMenuSeparator('Matched'));
|
|
157
|
+
items.push(output_1.default.createMenuItem(formatDomain(buyable), createValue('domain', prompt)));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (isValidSubdomain(prompt)) {
|
|
162
|
+
const claims = await client.domainClaimable(workspace, prompt);
|
|
163
|
+
const domains = [];
|
|
164
|
+
const searchTlds = tlds.length > 0 ? tlds : popularTlds;
|
|
165
|
+
searchTlds.forEach((tld) => {
|
|
166
|
+
domains.push(`${prompt}.${tld}`);
|
|
167
|
+
});
|
|
168
|
+
const search = await client.domainSearch(workspace, domains);
|
|
169
|
+
if (claims.domains.length > 0 || search.domains.length > 0) {
|
|
170
|
+
const claimsAvailable = claims.domains.filter((c) => (c.available && !tlds.length) || tlds.includes(c.domain));
|
|
171
|
+
const claimsUnavailable = claims.domains.filter((c) => (!c.available && !tlds.length) || tlds.includes(c.domain));
|
|
172
|
+
search.domains = search.domains.sort((a, b) => {
|
|
173
|
+
const aTld = getTld(a.name);
|
|
174
|
+
const bTld = getTld(b.name);
|
|
175
|
+
const aIdx = popularTlds.indexOf(aTld);
|
|
176
|
+
const bIdx = popularTlds.indexOf(bTld);
|
|
177
|
+
return aIdx < bIdx ? -1 : 1;
|
|
178
|
+
});
|
|
179
|
+
const domainsAvailable = search.domains.filter((d) => d.available && !d.premium);
|
|
180
|
+
const domainsUnavailable = search.domains.filter((d) => !d.available || d.premium);
|
|
181
|
+
domainsAvailable.forEach((d) => {
|
|
182
|
+
items.push(output_1.default.createMenuItem(formatDomain(d), createValue('domain', d.name)));
|
|
183
|
+
});
|
|
184
|
+
claimsAvailable.forEach((c, i) => {
|
|
185
|
+
const domain = `${prompt}.${c.domain}`;
|
|
186
|
+
const item = output_1.default.createMenuItem(formatClaim(domain, true), createValue('claim', domain));
|
|
187
|
+
if (i < 5)
|
|
188
|
+
items.unshift(item);
|
|
189
|
+
else
|
|
190
|
+
items.push(item);
|
|
191
|
+
});
|
|
192
|
+
domainsUnavailable.forEach((d) => {
|
|
193
|
+
items.push(output_1.default.createMenuItem(formatDomain(d), createValue('domain', d.name)));
|
|
194
|
+
});
|
|
195
|
+
claimsUnavailable.forEach((c) => {
|
|
196
|
+
const domain = `${prompt}.${c.domain}`;
|
|
197
|
+
const item = output_1.default.createMenuItem(formatClaim(domain, false), createValue('claim', domain));
|
|
198
|
+
items.push(item);
|
|
199
|
+
});
|
|
200
|
+
if (items.length > 10)
|
|
201
|
+
items = items.filter((_, i) => i < 10);
|
|
202
|
+
items.unshift(output_1.default.createMenuSeparator('Matched'));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const suggestions = await client.domainSuggest(workspace, prompt, tlds, 5);
|
|
206
|
+
if (suggestions.domains.length > 0 || suggestions.claims.length > 0) {
|
|
207
|
+
items.push(output_1.default.createMenuSeparator('Suggestions'));
|
|
208
|
+
let i = 0;
|
|
209
|
+
suggestions.claims.forEach((c) => {
|
|
210
|
+
if (i >= 10)
|
|
211
|
+
return;
|
|
212
|
+
items.push(output_1.default.createMenuItem(formatClaim(c, true), createValue('claim', c)));
|
|
213
|
+
i += 1;
|
|
214
|
+
});
|
|
215
|
+
suggestions.domains.forEach((d) => {
|
|
216
|
+
if (i >= 10)
|
|
217
|
+
return;
|
|
218
|
+
items.push(output_1.default.createMenuItem(formatDomain(d), createValue('domain', d.name)));
|
|
219
|
+
i += 1;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
output_1.default.clearPreviousLine();
|
|
223
|
+
if (!items.length) {
|
|
224
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NOT_FOUND);
|
|
225
|
+
}
|
|
226
|
+
const value = await output_1.default.inputMenuAdv(texts_1.TXT_COMMAND_DOMAIN_BUY_SELECT_DOMAIN, items);
|
|
227
|
+
const [type, name] = value.split(':');
|
|
228
|
+
if (type === 'claim') {
|
|
229
|
+
await client.domainClaim(workspace, name, onOwnerBehalf);
|
|
230
|
+
output_1.default.okSign();
|
|
231
|
+
output_1.default.normal(`${name} claimed`);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
await client.domainBuy(workspace, name, onOwnerBehalf);
|
|
235
|
+
output_1.default.okSign();
|
|
236
|
+
output_1.default.normal(`${name} bought`);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const nonInteractive = async (client, workspace, prompt, tlds, onOwnerBehalf) => {
|
|
240
|
+
if (!prompt) {
|
|
241
|
+
output_1.default.exitError(texts_1.TXT_COMMAND_DOMAIN_BUY_PROMPT_REQUIRED);
|
|
242
|
+
}
|
|
243
|
+
if (isValidDomain(prompt)) {
|
|
244
|
+
const subdomain = getSubdomain(prompt);
|
|
245
|
+
const claims = await client.domainClaimable(workspace, subdomain);
|
|
246
|
+
const claimable = claims.domains.find((c) => c.available && `${subdomain}.${c.domain}` === prompt);
|
|
247
|
+
if (claimable) {
|
|
248
|
+
await claimNonInteractive(client, workspace, prompt, onOwnerBehalf);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const { domains } = await client.domainSearch(workspace, [prompt]);
|
|
252
|
+
await buyNonInteractive(client, workspace, domains[0], onOwnerBehalf);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
output_1.default.arrowSign();
|
|
256
|
+
output_1.default.normal(`Searching...`);
|
|
257
|
+
const suggestions = await client.domainSuggest(workspace, prompt, tlds, 5);
|
|
258
|
+
output_1.default.clearPreviousLine();
|
|
259
|
+
if (suggestions.claims.length > 0) {
|
|
260
|
+
await claimNonInteractive(client, workspace, suggestions.claims[0], onOwnerBehalf);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (suggestions.domains.length > 0) {
|
|
264
|
+
await buyNonInteractive(client, workspace, suggestions.domains[0], onOwnerBehalf);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NOT_FOUND);
|
|
268
|
+
};
|
|
269
|
+
const getAllowedTlds = (tld) => {
|
|
270
|
+
const result = [];
|
|
271
|
+
if (tld) {
|
|
272
|
+
tld.forEach((t) => {
|
|
273
|
+
result.push(...t.split(',').map((t) => t.replace(/^\./, '')));
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
};
|
|
278
|
+
exports.default = commandDomainBuy;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 commandDomainGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_DOMAIN_GET);
|
|
11
|
+
commandDomainGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
+
commandDomainGet.argument('<id|name>', texts_1.OPTION_COMMAND_DOMAIN_IDENTIFIER);
|
|
13
|
+
commandDomainGet.action(async (name, options) => {
|
|
14
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
15
|
+
const client = input_1.default.restApiTokenClient();
|
|
16
|
+
let domain;
|
|
17
|
+
try {
|
|
18
|
+
domain = await client.getDomain(workspace, name);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
const response = await client.getDomains(workspace);
|
|
22
|
+
domain = (response.domains || []).find((d) => d.name === name);
|
|
23
|
+
if (domain) {
|
|
24
|
+
domain = await client.getDomain(workspace, domain.id);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!domain) {
|
|
28
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NOT_FOUND);
|
|
29
|
+
}
|
|
30
|
+
const props = {
|
|
31
|
+
Name: domain.name,
|
|
32
|
+
ID: domain.id,
|
|
33
|
+
Type: domain.type,
|
|
34
|
+
};
|
|
35
|
+
if (domain.type === 'REGISTERED') {
|
|
36
|
+
if (domain.expiry_date) {
|
|
37
|
+
props.Expires = domain.expiry_date;
|
|
38
|
+
}
|
|
39
|
+
props.Renew = domain.auto_renew ? 'Auto' : 'Manual';
|
|
40
|
+
}
|
|
41
|
+
props.URL = domain.html_url;
|
|
42
|
+
output_1.default.object(props);
|
|
43
|
+
output_1.default.exitNormal();
|
|
44
|
+
});
|
|
45
|
+
exports.default = commandDomainGet;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 commandDomainList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_DOMAIN_LIST);
|
|
11
|
+
commandDomainList.alias('ls');
|
|
12
|
+
commandDomainList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDomainList.action(async (options) => {
|
|
14
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
15
|
+
const client = input_1.default.restApiTokenClient();
|
|
16
|
+
const response = await client.getDomains(workspace);
|
|
17
|
+
if (!response.domains || response.domains.length === 0) {
|
|
18
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NO_DOMAINS);
|
|
19
|
+
}
|
|
20
|
+
const data = [['NAME', 'ID', 'URL']];
|
|
21
|
+
for (const d of response.domains) {
|
|
22
|
+
data.push([d.name, d.id, d.html_url]);
|
|
23
|
+
}
|
|
24
|
+
output_1.default.table(data);
|
|
25
|
+
output_1.default.exitNormal();
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandDomainList;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 buy_1 = __importDefault(require("./domain/buy"));
|
|
9
|
+
const list_1 = __importDefault(require("./domain/list"));
|
|
10
|
+
const get_1 = __importDefault(require("./domain/get"));
|
|
11
|
+
const commandDomain = (0, utils_1.newCommand)('domain', texts_1.DESC_COMMAND_DOMAIN);
|
|
12
|
+
commandDomain.addCommand(buy_1.default);
|
|
13
|
+
commandDomain.addCommand(list_1.default);
|
|
14
|
+
commandDomain.addCommand(get_1.default);
|
|
15
|
+
exports.default = commandDomain;
|
|
@@ -51,7 +51,7 @@ const getRemoteNames = (str) => {
|
|
|
51
51
|
return names;
|
|
52
52
|
};
|
|
53
53
|
const tryNow = () => {
|
|
54
|
-
output_1.default.
|
|
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
57
|
output_1.default.light('bdy tunnel http 3000 ', false);
|
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
exports.validateInputAndOptions = validateInputAndOptions;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const validation_1 = require("../vt/shared/validation");
|
|
10
|
+
const urlSchema = zod_1.z.string().url().optional();
|
|
11
|
+
const browserSchema = zod_1.z.enum(['chrome', 'firefox', 'safari']);
|
|
12
|
+
const browsersListSchema = zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.transform((value) => value
|
|
15
|
+
.split(',')
|
|
16
|
+
.map((browser) => browser.trim().toLowerCase())
|
|
17
|
+
.filter((browser) => browser.length > 0))
|
|
18
|
+
.refine((browsers) => browsers.length > 0, {
|
|
19
|
+
message: 'Invalid browsers list. Supported values: chrome,firefox,safari',
|
|
20
|
+
})
|
|
21
|
+
.pipe(zod_1.z.array(browserSchema))
|
|
22
|
+
.transform((browsers) => Array.from(new Set(browsers.map((browser) => browser === 'chrome'
|
|
23
|
+
? 'CHROMIUM'
|
|
24
|
+
: browser === 'firefox'
|
|
25
|
+
? 'FIREFOX'
|
|
26
|
+
: 'WEBKIT'))));
|
|
27
|
+
const optionsSchema = zod_1.z.object({
|
|
28
|
+
follow: zod_1.z.boolean(),
|
|
29
|
+
respectRobots: zod_1.z.boolean(),
|
|
30
|
+
outputType: zod_1.z.enum(['jpeg', 'png', 'md', 'html']).optional(),
|
|
31
|
+
outputTypes: zod_1.z.string().optional(),
|
|
32
|
+
quality: zod_1.z.coerce.number().min(1).max(100).optional(),
|
|
33
|
+
outputDir: zod_1.z.string().default('.'),
|
|
34
|
+
fullPage: zod_1.z.boolean().optional(),
|
|
35
|
+
cssSelector: zod_1.z.string().optional(),
|
|
36
|
+
xpathSelector: zod_1.z.string().optional(),
|
|
37
|
+
colorScheme: zod_1.z.enum(['LIGHT', 'DARK', 'LIGHT_AND_DARK']).optional(),
|
|
38
|
+
browsers: browsersListSchema.optional(),
|
|
39
|
+
devices: zod_1.z.string().optional(),
|
|
40
|
+
delay: zod_1.z.coerce.number().min(0).max(10000),
|
|
41
|
+
waitFor: validation_1.waitForSchema,
|
|
42
|
+
cookie: validation_1.cookieSchema,
|
|
43
|
+
header: validation_1.headerSchema,
|
|
44
|
+
localStorage: zod_1.z
|
|
45
|
+
.array(zod_1.z.string().regex(/^(?:([^:]+)::)?([^=]+)=(.*)$/, {
|
|
46
|
+
message: "LocalStorage option must follow pattern '[scope::]key=value' (scope is optional)",
|
|
47
|
+
}))
|
|
48
|
+
.optional()
|
|
49
|
+
.transform((value) => value?.map((v) => {
|
|
50
|
+
const { scope, key, value } = (0, validation_1.parseScopedKeyValue)(v);
|
|
51
|
+
return { scope, key, value };
|
|
52
|
+
})),
|
|
53
|
+
});
|
|
54
|
+
function validateInputAndOptions(input, options) {
|
|
55
|
+
try {
|
|
56
|
+
const url = urlSchema.parse(input);
|
|
57
|
+
const { follow, respectRobots, outputType, outputTypes: rawOutputTypes, quality, outputDir, fullPage, cssSelector, xpathSelector, colorScheme, browsers: parsedBrowsers, devices: rawDevices, delay, waitFor, cookie, header, localStorage, } = optionsSchema.parse(options);
|
|
58
|
+
let parsedOutputTypes;
|
|
59
|
+
if (rawOutputTypes) {
|
|
60
|
+
try {
|
|
61
|
+
const outputTypeEntrySchema = zod_1.z.array(zod_1.z
|
|
62
|
+
.object({
|
|
63
|
+
type: zod_1.z.string().transform((v) => v.toUpperCase()),
|
|
64
|
+
selector: zod_1.z
|
|
65
|
+
.object({
|
|
66
|
+
type: zod_1.z.enum(['CSS', 'XPATH']).optional(),
|
|
67
|
+
value: zod_1.z.string().optional(),
|
|
68
|
+
})
|
|
69
|
+
.optional(),
|
|
70
|
+
quality: zod_1.z.number().min(1).max(100).optional(),
|
|
71
|
+
})
|
|
72
|
+
.transform((data) => ({
|
|
73
|
+
...data,
|
|
74
|
+
type: data.type,
|
|
75
|
+
})));
|
|
76
|
+
parsedOutputTypes = outputTypeEntrySchema.parse(JSON.parse(rawOutputTypes));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
output_1.default.exitError("Invalid --outputTypes value. Use JSON array, e.g. --outputTypes '[{\"type\":\"png\"},{\"type\":\"jpeg\",\"quality\":80}]'");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (outputType) {
|
|
83
|
+
if (typeof quality === 'number' && outputType !== 'jpeg') {
|
|
84
|
+
output_1.default.exitError('Quality is only supported for jpeg output type, use --outputType jpeg');
|
|
85
|
+
}
|
|
86
|
+
if (cssSelector && xpathSelector) {
|
|
87
|
+
output_1.default.exitError('Only one of --cssSelector or --xpathSelector can be used');
|
|
88
|
+
}
|
|
89
|
+
const entry = {
|
|
90
|
+
type: outputType.toUpperCase(),
|
|
91
|
+
};
|
|
92
|
+
if (cssSelector) {
|
|
93
|
+
entry.selector = { type: 'CSS', value: cssSelector };
|
|
94
|
+
}
|
|
95
|
+
else if (xpathSelector) {
|
|
96
|
+
entry.selector = { type: 'XPATH', value: xpathSelector };
|
|
97
|
+
}
|
|
98
|
+
if (typeof quality === 'number') {
|
|
99
|
+
entry.quality = quality;
|
|
100
|
+
}
|
|
101
|
+
parsedOutputTypes = [entry];
|
|
102
|
+
}
|
|
103
|
+
let parsedDevices;
|
|
104
|
+
if (rawDevices) {
|
|
105
|
+
try {
|
|
106
|
+
const viewportSchema = zod_1.z
|
|
107
|
+
.object({
|
|
108
|
+
width: zod_1.z.number().positive(),
|
|
109
|
+
height: zod_1.z.number().positive(),
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
const deviceSchema = zod_1.z.array(zod_1.z
|
|
113
|
+
.object({
|
|
114
|
+
viewport: viewportSchema,
|
|
115
|
+
screen: viewportSchema.optional(),
|
|
116
|
+
devicePixelRatio: zod_1.z.number().positive().optional(),
|
|
117
|
+
isMobile: zod_1.z.boolean().optional(),
|
|
118
|
+
})
|
|
119
|
+
.strict()
|
|
120
|
+
.transform((data) => ({
|
|
121
|
+
viewport: data.viewport,
|
|
122
|
+
screen: data.screen ?? data.viewport,
|
|
123
|
+
devicePixelRatio: data.devicePixelRatio ?? 1,
|
|
124
|
+
isMobile: data.isMobile ?? false,
|
|
125
|
+
})));
|
|
126
|
+
parsedDevices = deviceSchema.parse(JSON.parse(rawDevices));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
output_1.default.exitError('Invalid --devices value. Use JSON array, e.g. --devices \'[{"viewport":{"width":1920,"height":1080}}]\'');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
url,
|
|
134
|
+
follow,
|
|
135
|
+
respectRobots,
|
|
136
|
+
outputTypes: parsedOutputTypes,
|
|
137
|
+
outputDir,
|
|
138
|
+
fullPage,
|
|
139
|
+
colorScheme,
|
|
140
|
+
browsers: parsedBrowsers,
|
|
141
|
+
devices: parsedDevices,
|
|
142
|
+
cookies: cookie,
|
|
143
|
+
requestHeaders: header,
|
|
144
|
+
delay,
|
|
145
|
+
waitForSelectors: waitFor,
|
|
146
|
+
localStorage,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (error instanceof zod_1.ZodError) {
|
|
151
|
+
output_1.default.exitError(error.errors.map((e) => `${e.path}: ${e.message}`).join(', '));
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|