contensis-cli 1.1.2-beta.0 → 1.1.2-beta.10
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/commands/copy.js +70 -0
- package/dist/commands/copy.js.map +7 -0
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/dev.js +11 -4
- package/dist/commands/dev.js.map +2 -2
- package/dist/commands/get.js +1 -0
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +24 -3
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +1 -6
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +7 -3
- package/dist/commands/index.js.map +2 -2
- package/dist/factories/RequestHandlerFactory.js +214 -0
- package/dist/factories/RequestHandlerFactory.js.map +7 -0
- package/dist/localisation/en-GB.js +30 -5
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +159 -0
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +7 -0
- package/dist/providers/GitHubCliModuleProvider.js +117 -0
- package/dist/providers/GitHubCliModuleProvider.js.map +7 -0
- package/dist/providers/HttpProvider.js +72 -0
- package/dist/providers/HttpProvider.js.map +7 -0
- package/dist/providers/ManifestProvider.js +53 -0
- package/dist/providers/ManifestProvider.js.map +7 -0
- package/dist/providers/file-provider.js +14 -0
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisAuthService.js +19 -11
- package/dist/services/ContensisAuthService.js.map +2 -2
- package/dist/services/ContensisCliService.js +88 -14
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/services/ContensisDevService.js +34 -58
- package/dist/services/ContensisDevService.js.map +3 -3
- package/dist/shell.js +1 -0
- package/dist/shell.js.map +2 -2
- package/dist/util/api-ids.js +110 -0
- package/dist/util/api-ids.js.map +7 -0
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/debug.js +29 -0
- package/dist/util/debug.js.map +7 -0
- package/dist/util/fetch.js +65 -0
- package/dist/util/fetch.js.map +7 -0
- package/dist/util/index.js.map +1 -1
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -3
- package/src/commands/copy.ts +79 -0
- package/src/commands/create.ts +0 -1
- package/src/commands/dev.ts +14 -6
- package/src/commands/get.ts +12 -11
- package/src/commands/globalOptions.ts +25 -2
- package/src/commands/import.ts +4 -8
- package/src/commands/index.ts +7 -3
- package/src/factories/RequestHandlerFactory.ts +246 -0
- package/src/localisation/en-GB.ts +55 -12
- package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +200 -0
- package/src/providers/GitHubCliModuleProvider.ts +127 -0
- package/src/providers/HttpProvider.ts +50 -0
- package/src/providers/ManifestProvider.ts +43 -0
- package/src/providers/file-provider.ts +13 -0
- package/src/services/ContensisAuthService.ts +23 -14
- package/src/services/ContensisCliService.ts +112 -15
- package/src/services/ContensisDevService.ts +52 -87
- package/src/shell.ts +2 -1
- package/src/util/api-ids.ts +111 -0
- package/src/util/console.printer.ts +2 -1
- package/src/util/debug.ts +1 -0
- package/src/util/fetch.ts +74 -0
- package/src/util/index.ts +1 -1
- package/src/util/logger.ts +0 -1
- package/src/version.ts +1 -1
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js +0 -56
- package/dist/mappers/DevRequests-to-RequestHanderSiteConfigYaml.js.map +0 -7
- package/src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts +0 -44
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import ansiEscapes from 'ansi-escapes';
|
|
2
2
|
import to from 'await-to-js';
|
|
3
|
-
import { spawn } from 'child_process';
|
|
4
3
|
import inquirer from 'inquirer';
|
|
5
4
|
import { createSpinner } from 'nanospinner';
|
|
6
|
-
import path from 'path';
|
|
7
5
|
|
|
8
6
|
import { Role } from 'contensis-management-api/lib/models';
|
|
9
7
|
import { MigrateRequest } from 'migratortron';
|
|
10
8
|
|
|
11
9
|
import ContensisRole from './ContensisRoleService';
|
|
10
|
+
import { createRequestHandler } from '~/factories/RequestHandlerFactory';
|
|
12
11
|
import { OutputOptionsConstructorArg } from '~/models/CliService';
|
|
13
12
|
import { EnvContentsToAdd } from '~/models/DevService';
|
|
14
|
-
import { mapSiteConfigYaml } from '~/mappers/DevRequests-to-RequestHanderSiteConfigYaml';
|
|
15
13
|
import { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';
|
|
14
|
+
import RequestHandlerArgs from '~/mappers/DevRequests-to-RequestHanderCliArgs';
|
|
16
15
|
import { deployKeyRole } from '~/mappers/DevInit-to-RolePermissions';
|
|
17
|
-
import {
|
|
16
|
+
import { readFile, writeFile } from '~/providers/file-provider';
|
|
18
17
|
import { diffFileContent } from '~/util/diff';
|
|
19
18
|
import { mergeDotEnvFileContents } from '~/util/dotenv';
|
|
20
19
|
import { findByIdOrName } from '~/util/find';
|
|
21
20
|
import { GitHelper } from '~/util/git';
|
|
22
21
|
import { jsonFormatter } from '~/util/json.formatter';
|
|
23
22
|
import { winSlash } from '~/util/os';
|
|
24
|
-
import { stringifyYaml } from '~/util/yaml';
|
|
25
23
|
import { mergeContentsToAddWithGitignore } from '~/util/gitignore';
|
|
26
24
|
|
|
27
25
|
class ContensisDev extends ContensisRole {
|
|
@@ -413,90 +411,57 @@ class ContensisDev extends ContensisRole {
|
|
|
413
411
|
}
|
|
414
412
|
};
|
|
415
413
|
|
|
416
|
-
ExecRequestHandler = async (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
log.raw(data);
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
child?.stderr?.on('data', data => {
|
|
466
|
-
log.error(data);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
child.on('spawn', () => {
|
|
470
|
-
isRunning = true;
|
|
471
|
-
log.help(
|
|
472
|
-
`You may see a firewall popup requesting network access, it is safe to approve`
|
|
473
|
-
);
|
|
474
|
-
// log.getPrefix = () => Logger.infoText(`[rqh]`);
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
child.on('exit', code => {
|
|
478
|
-
isRunning = false;
|
|
479
|
-
|
|
480
|
-
log[code === 0 ? 'success' : 'warning'](
|
|
481
|
-
`Request handler exited with code ${code}\n`
|
|
482
|
-
);
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
child.on('error', error => {
|
|
486
|
-
isRunning = false;
|
|
487
|
-
log.error(`Could not launch request handler due to error \n${error}`);
|
|
488
|
-
});
|
|
414
|
+
ExecRequestHandler = async (
|
|
415
|
+
blockId: string[],
|
|
416
|
+
overrideArgs: string[] = [],
|
|
417
|
+
version?: string
|
|
418
|
+
) => {
|
|
419
|
+
const { debug, log, messages } = this;
|
|
420
|
+
|
|
421
|
+
const spinner = !debug
|
|
422
|
+
? createSpinner(messages.devrequests.launch())
|
|
423
|
+
: log.info(messages.devrequests.launch());
|
|
424
|
+
|
|
425
|
+
// Ensure request handler is available to use
|
|
426
|
+
const requestHandler = await createRequestHandler(version);
|
|
427
|
+
|
|
428
|
+
// Generate args for request handler using CLI methods
|
|
429
|
+
const args = new RequestHandlerArgs(this);
|
|
430
|
+
spinner?.start();
|
|
431
|
+
await args.Create();
|
|
432
|
+
spinner?.success();
|
|
433
|
+
|
|
434
|
+
// Prompt block id and dev uri to run locally (if not supplied)
|
|
435
|
+
const blockIdChoices = args.siteConfig?.blocks.map(block => block.id) || [];
|
|
436
|
+
blockIdChoices.push('none');
|
|
437
|
+
const defaultDeveloperUri = 'http://localhost:3000';
|
|
438
|
+
|
|
439
|
+
const { overrideBlockId, overrideUri } = blockId.length
|
|
440
|
+
? {
|
|
441
|
+
overrideBlockId: blockId[0],
|
|
442
|
+
overrideUri: blockId?.[1] || defaultDeveloperUri,
|
|
443
|
+
}
|
|
444
|
+
: await inquirer.prompt([
|
|
445
|
+
{
|
|
446
|
+
type: 'list',
|
|
447
|
+
prefix: '🧱',
|
|
448
|
+
message: messages.devrequests.overrideBlock(),
|
|
449
|
+
name: 'overrideBlockId',
|
|
450
|
+
choices: blockIdChoices,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
type: 'input',
|
|
454
|
+
prefix: '🔗',
|
|
455
|
+
message: messages.devrequests.overrideUri(),
|
|
456
|
+
name: 'overrideUri',
|
|
457
|
+
default: defaultDeveloperUri,
|
|
458
|
+
},
|
|
459
|
+
]);
|
|
489
460
|
|
|
490
|
-
|
|
461
|
+
args.overrideBlock(overrideBlockId, overrideUri);
|
|
491
462
|
|
|
492
|
-
//
|
|
493
|
-
|
|
494
|
-
if (!isRunning) {
|
|
495
|
-
// log.getPrefix = getPrefixOld; // restore logger state
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
499
|
-
}
|
|
463
|
+
// Launch request handler
|
|
464
|
+
await requestHandler(args.getArgs(overrideArgs));
|
|
500
465
|
};
|
|
501
466
|
}
|
|
502
467
|
export const devCommand = (
|
package/src/shell.ts
CHANGED
|
@@ -135,6 +135,7 @@ class ContensisShell {
|
|
|
135
135
|
availableCommands.push('login', 'list projects', 'set project');
|
|
136
136
|
if (userId)
|
|
137
137
|
availableCommands.push(
|
|
138
|
+
'copy field',
|
|
138
139
|
'create key',
|
|
139
140
|
'create project',
|
|
140
141
|
'create role',
|
|
@@ -306,4 +307,4 @@ process.stdin.on('data', key => {
|
|
|
306
307
|
}
|
|
307
308
|
});
|
|
308
309
|
|
|
309
|
-
//
|
|
310
|
+
// process.env.http_proxy = 'http://127.0.0.1:8888';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export const sanitiseId = (id: string) =>
|
|
2
|
+
id
|
|
3
|
+
.split('.')
|
|
4
|
+
.map(part => toApiId(part, 'camelCase', true))
|
|
5
|
+
.join('.');
|
|
6
|
+
|
|
7
|
+
export const sanitiseIds = (arr: string[]) => arr.map(sanitiseId);
|
|
8
|
+
|
|
9
|
+
// borrowed from packages\contensis\components\app\src\utils.ts
|
|
10
|
+
|
|
11
|
+
export function isApiId(id: string, mode: 'camelCase' | 'snake-case'): boolean {
|
|
12
|
+
if (!id) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const validChars = mode === 'camelCase' ? /[^a-zA-Z0-9]/g : /[^a-z0-9-]/g;
|
|
16
|
+
if (id !== id.replace(validChars, '')) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (!id.substr(0, 1).replace(/[^a-z]/g, '')) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function toApiId(
|
|
26
|
+
name: string,
|
|
27
|
+
mode: 'camelCase' | 'snake-case',
|
|
28
|
+
isId: boolean
|
|
29
|
+
) {
|
|
30
|
+
if (!name) {
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
const validChars =
|
|
34
|
+
mode === 'camelCase' ? /[^a-zA-Z0-9 ]/g : /[^a-zA-Z0-9 -]/g;
|
|
35
|
+
let id = name.replace(validChars, '');
|
|
36
|
+
id = id.replace(/-/g, ' ');
|
|
37
|
+
id = id.trim();
|
|
38
|
+
|
|
39
|
+
const noStart = '0123456789 '.split('');
|
|
40
|
+
id = id
|
|
41
|
+
.split('')
|
|
42
|
+
.reduce(
|
|
43
|
+
(prev, char) => (prev || !noStart.includes(char) ? prev + char : prev),
|
|
44
|
+
''
|
|
45
|
+
);
|
|
46
|
+
return mode === 'camelCase' ? toCamelCase(id, isId) : toSnakeCase(id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function toSnakeCase(sentence: string): string {
|
|
50
|
+
sentence = (sentence || '').trim();
|
|
51
|
+
if (!sentence) {
|
|
52
|
+
return sentence;
|
|
53
|
+
}
|
|
54
|
+
sentence = sentence.toLowerCase();
|
|
55
|
+
return sentence
|
|
56
|
+
.split(' ')
|
|
57
|
+
.filter(w => !!w)
|
|
58
|
+
.join('-');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function toCamelCase(sentence: string, isId: boolean): string {
|
|
62
|
+
sentence = (sentence || '').trim();
|
|
63
|
+
if (!sentence) {
|
|
64
|
+
return sentence;
|
|
65
|
+
}
|
|
66
|
+
if (sentence.length < 2) {
|
|
67
|
+
return sentence.toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
const words = sentence.split(' ');
|
|
70
|
+
if (isId && words.length === 1) {
|
|
71
|
+
return words[0].substr(0, 1).toLowerCase() + words[0].substr(1);
|
|
72
|
+
}
|
|
73
|
+
const result = words
|
|
74
|
+
.filter(w => !!w)
|
|
75
|
+
.map((w, index) =>
|
|
76
|
+
index === 0 ? firstWordToCamelCase(w) : wordToCamelCase(w)
|
|
77
|
+
)
|
|
78
|
+
.join('');
|
|
79
|
+
|
|
80
|
+
return result
|
|
81
|
+
.split('.')
|
|
82
|
+
.map((w, index) => (index === 0 ? w : wordToCamelCase(w)))
|
|
83
|
+
.join('.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function firstWordToCamelCase(word: string) {
|
|
87
|
+
return isUpperCase(word)
|
|
88
|
+
? word.toLowerCase()
|
|
89
|
+
: lowerCaseInitialCapitalLettersExceptLast(word);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function wordToCamelCase(word: string) {
|
|
93
|
+
return word.substr(0, 1).toUpperCase() + word.substr(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function lowerCaseInitialCapitalLettersExceptLast(value: string): string {
|
|
97
|
+
return value.split('').reduce((prev, char, index) => {
|
|
98
|
+
if (index === 0) {
|
|
99
|
+
char = char.toLowerCase();
|
|
100
|
+
} else if (isUpperCase(char)) {
|
|
101
|
+
if (index + 1 < value.length && isUpperCase(value.charAt(index + 1))) {
|
|
102
|
+
char = char.toLowerCase();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return prev + char;
|
|
106
|
+
}, '');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isUpperCase(value: string): boolean {
|
|
110
|
+
return value === value.toUpperCase();
|
|
111
|
+
}
|
|
@@ -4,6 +4,7 @@ import { deconstructApiError } from './error';
|
|
|
4
4
|
import { Logger, addNewLines } from './logger';
|
|
5
5
|
import {
|
|
6
6
|
BlockVersion,
|
|
7
|
+
CopyFieldResult,
|
|
7
8
|
EntriesResult,
|
|
8
9
|
MigrateModelsResult,
|
|
9
10
|
MigrateNodesTree,
|
|
@@ -116,7 +117,7 @@ export const printBlockVersion = (
|
|
|
116
117
|
|
|
117
118
|
export const printEntriesMigrateResult = (
|
|
118
119
|
{ log, messages, currentProject }: ContensisCli,
|
|
119
|
-
migrateResult: EntriesResult,
|
|
120
|
+
migrateResult: EntriesResult | CopyFieldResult,
|
|
120
121
|
{
|
|
121
122
|
action = 'import',
|
|
122
123
|
showDiff = false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isDebug = () => ['true', '1'].includes(process.env.debug || '');
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { DoRetry, FetchInit, fetchWithDefaults } from 'enterprise-fetch';
|
|
2
|
+
import { Logger } from './logger';
|
|
3
|
+
|
|
4
|
+
const retryPolicy = {
|
|
5
|
+
retries: 2,
|
|
6
|
+
minTimeout: 400,
|
|
7
|
+
factor: 2,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const applyTimeout = (s: number) =>
|
|
11
|
+
process.env.NODE_ENV === 'test' ? 2 * 1000 : s * 1000;
|
|
12
|
+
|
|
13
|
+
export const doRetry = ({ silent = false } = {}) => {
|
|
14
|
+
const fn: DoRetry = async (
|
|
15
|
+
attempt: number,
|
|
16
|
+
res: Response | AppError,
|
|
17
|
+
{ url, options } = { url: '', options: {} }
|
|
18
|
+
) => {
|
|
19
|
+
// Get the retry policy from options or fetchDefaults
|
|
20
|
+
const { retry = retryPolicy } = options || ({} as any);
|
|
21
|
+
let shouldRetry = false;
|
|
22
|
+
|
|
23
|
+
// Retry request on any network error, or 4xx or 5xx status codes
|
|
24
|
+
if (
|
|
25
|
+
!res.status ||
|
|
26
|
+
(res.status >= 400 && ![400, 404, 409, 422, 500].includes(res.status))
|
|
27
|
+
)
|
|
28
|
+
if (
|
|
29
|
+
!('message' in res) ||
|
|
30
|
+
('message' in res &&
|
|
31
|
+
!(res.message as string).includes('Nock: No match'))
|
|
32
|
+
)
|
|
33
|
+
shouldRetry = true;
|
|
34
|
+
|
|
35
|
+
if (attempt <= retry.retries) {
|
|
36
|
+
// If a res has a status it is a HTTP error
|
|
37
|
+
// With no status it could be a fetch error or app error
|
|
38
|
+
const errorMessage = !res.status
|
|
39
|
+
? `${('name' in res && res.name) || ('type' in res && res.type)}: ${
|
|
40
|
+
'message' in res && res.message
|
|
41
|
+
}`
|
|
42
|
+
: `${res.status}: ${res.statusText}`;
|
|
43
|
+
|
|
44
|
+
if (!silent)
|
|
45
|
+
Logger.warning(
|
|
46
|
+
`[fetch] ${
|
|
47
|
+
shouldRetry
|
|
48
|
+
? `attempt ${attempt}/${retry.retries}`
|
|
49
|
+
: 'non-retriable'
|
|
50
|
+
} ${errorMessage} ${url || ''}`
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
shouldRetry = false;
|
|
54
|
+
}
|
|
55
|
+
return await Promise.resolve(shouldRetry);
|
|
56
|
+
};
|
|
57
|
+
return fn;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const fetchDefaults = {
|
|
61
|
+
// The timeout to apply to requests that do not supply a timeout option
|
|
62
|
+
timeout: applyTimeout(60),
|
|
63
|
+
// Retry policy for all fetch requests
|
|
64
|
+
retry: retryPolicy,
|
|
65
|
+
// Do retry function to examine failures and apply custom retry logic
|
|
66
|
+
// return true to retry the fetch call
|
|
67
|
+
doRetry: doRetry(),
|
|
68
|
+
} as FetchInit;
|
|
69
|
+
|
|
70
|
+
export const enhancedFetch = fetchWithDefaults(fetchDefaults);
|
|
71
|
+
// export const assetFetch = fetchWithDefaults({
|
|
72
|
+
// ...fetchDefaults,
|
|
73
|
+
// timeout: applyTimeout(1200),
|
|
74
|
+
// });
|
package/src/util/index.ts
CHANGED
package/src/util/logger.ts
CHANGED
|
@@ -57,7 +57,6 @@ export class Logger {
|
|
|
57
57
|
else console.log(message);
|
|
58
58
|
};
|
|
59
59
|
static warning: LogMethod = content => {
|
|
60
|
-
// if (process.env.DEBUG === 'true') {
|
|
61
60
|
const message = `${Logger.getPrefix()} ${Logger.warningText(
|
|
62
61
|
`${Logger.isUserTerminal ? '⚠️ ' : '[WARN]'} ${content}`
|
|
63
62
|
)}\n`;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.1.2-beta.
|
|
1
|
+
export const LIB_VERSION = "1.1.2-beta.10";
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var DevRequests_to_RequestHanderSiteConfigYaml_exports = {};
|
|
20
|
-
__export(DevRequests_to_RequestHanderSiteConfigYaml_exports, {
|
|
21
|
-
mapSiteConfigYaml: () => mapSiteConfigYaml
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(DevRequests_to_RequestHanderSiteConfigYaml_exports);
|
|
24
|
-
const mapSiteConfigYaml = async (cli) => {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
const credentials = await cli.GetCredentials(cli.env.lastUserId);
|
|
27
|
-
const blocks = [];
|
|
28
|
-
const blocksRaw = await cli.PrintBlocks();
|
|
29
|
-
for (const block of blocksRaw || []) {
|
|
30
|
-
const versions = await cli.PrintBlockVersions(
|
|
31
|
-
block.id,
|
|
32
|
-
"default",
|
|
33
|
-
"latest"
|
|
34
|
-
);
|
|
35
|
-
if (versions == null ? void 0 : versions[0]) {
|
|
36
|
-
blocks.push({
|
|
37
|
-
id: versions[0].id,
|
|
38
|
-
baseUri: versions[0].previewUrl
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const siteConfig = {
|
|
43
|
-
alias: cli.currentEnv,
|
|
44
|
-
projectId: cli.currentProject,
|
|
45
|
-
accessToken: "",
|
|
46
|
-
clientId: ((_a = credentials == null ? void 0 : credentials.current) == null ? void 0 : _a.account) || "",
|
|
47
|
-
sharedSecret: ((_b = credentials == null ? void 0 : credentials.current) == null ? void 0 : _b.password) || "",
|
|
48
|
-
blocks
|
|
49
|
-
};
|
|
50
|
-
return siteConfig;
|
|
51
|
-
};
|
|
52
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
-
0 && (module.exports = {
|
|
54
|
-
mapSiteConfigYaml
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=DevRequests-to-RequestHanderSiteConfigYaml.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/mappers/DevRequests-to-RequestHanderSiteConfigYaml.ts"],
|
|
4
|
-
"sourcesContent": ["import ContensisCli from '~/services/ContensisCliService';\n\ninterface ISiteConfigYaml {\n alias: string;\n projectId: string;\n accessToken: string;\n clientId: string;\n sharedSecret: string;\n blocks: {\n id: string;\n baseUri: string;\n }[];\n}\n\nexport const mapSiteConfigYaml = async (cli: ContensisCli) => {\n const credentials = await cli.GetCredentials(cli.env.lastUserId);\n\n const blocks = [];\n const blocksRaw = await cli.PrintBlocks();\n\n for (const block of blocksRaw || []) {\n const versions = await cli.PrintBlockVersions(\n block.id,\n 'default',\n 'latest'\n );\n if (versions?.[0]) {\n blocks.push({\n id: versions[0].id,\n baseUri: versions[0].previewUrl,\n });\n }\n }\n\n const siteConfig: ISiteConfigYaml = {\n alias: cli.currentEnv,\n projectId: cli.currentProject,\n accessToken: '',\n clientId: credentials?.current?.account || '',\n sharedSecret: credentials?.current?.password || '',\n blocks,\n };\n return siteConfig;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,MAAM,oBAAoB,OAAO,QAAsB;AAd9D;AAeE,QAAM,cAAc,MAAM,IAAI,eAAe,IAAI,IAAI,UAAU;AAE/D,QAAM,SAAS,CAAC;AAChB,QAAM,YAAY,MAAM,IAAI,YAAY;AAExC,aAAW,SAAS,aAAa,CAAC,GAAG;AACnC,UAAM,WAAW,MAAM,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AACA,QAAI,qCAAW,IAAI;AACjB,aAAO,KAAK;AAAA,QACV,IAAI,SAAS,GAAG;AAAA,QAChB,SAAS,SAAS,GAAG;AAAA,MACvB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,aAA8B;AAAA,IAClC,OAAO,IAAI;AAAA,IACX,WAAW,IAAI;AAAA,IACf,aAAa;AAAA,IACb,YAAU,gDAAa,YAAb,mBAAsB,YAAW;AAAA,IAC3C,gBAAc,gDAAa,YAAb,mBAAsB,aAAY;AAAA,IAChD;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import ContensisCli from '~/services/ContensisCliService';
|
|
2
|
-
|
|
3
|
-
interface ISiteConfigYaml {
|
|
4
|
-
alias: string;
|
|
5
|
-
projectId: string;
|
|
6
|
-
accessToken: string;
|
|
7
|
-
clientId: string;
|
|
8
|
-
sharedSecret: string;
|
|
9
|
-
blocks: {
|
|
10
|
-
id: string;
|
|
11
|
-
baseUri: string;
|
|
12
|
-
}[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const mapSiteConfigYaml = async (cli: ContensisCli) => {
|
|
16
|
-
const credentials = await cli.GetCredentials(cli.env.lastUserId);
|
|
17
|
-
|
|
18
|
-
const blocks = [];
|
|
19
|
-
const blocksRaw = await cli.PrintBlocks();
|
|
20
|
-
|
|
21
|
-
for (const block of blocksRaw || []) {
|
|
22
|
-
const versions = await cli.PrintBlockVersions(
|
|
23
|
-
block.id,
|
|
24
|
-
'default',
|
|
25
|
-
'latest'
|
|
26
|
-
);
|
|
27
|
-
if (versions?.[0]) {
|
|
28
|
-
blocks.push({
|
|
29
|
-
id: versions[0].id,
|
|
30
|
-
baseUri: versions[0].previewUrl,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const siteConfig: ISiteConfigYaml = {
|
|
36
|
-
alias: cli.currentEnv,
|
|
37
|
-
projectId: cli.currentProject,
|
|
38
|
-
accessToken: '',
|
|
39
|
-
clientId: credentials?.current?.account || '',
|
|
40
|
-
sharedSecret: credentials?.current?.password || '',
|
|
41
|
-
blocks,
|
|
42
|
-
};
|
|
43
|
-
return siteConfig;
|
|
44
|
-
};
|