bdy 1.22.38-stage → 1.22.39-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.
- package/distTs/package.json +1 -1
- package/distTs/src/command/sandbox/create.js +1 -1
- package/distTs/src/input.js +77 -69
- package/distTs/src/texts.js +13 -4
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -35,7 +35,7 @@ commandSandboxCreate.option('--app-command <commands...>', texts_1.OPTION_SANDBO
|
|
|
35
35
|
commandSandboxCreate.option('--app-dir <directory>', texts_1.OPTION_SANDBOX_APP_DIR);
|
|
36
36
|
commandSandboxCreate.option('--tag <tags...>', texts_1.OPTION_SANDBOX_TAGS);
|
|
37
37
|
commandSandboxCreate.option('--timeout <seconds>', texts_1.OPTION_SANDBOX_TIMEOUT);
|
|
38
|
-
commandSandboxCreate.option('--fetch
|
|
38
|
+
commandSandboxCreate.option('--fetch [fetch...]', texts_1.OPTION_SANDBOX_FETCH);
|
|
39
39
|
commandSandboxCreate.option('-v, --variable <variables...>', texts_1.OPTION_RUN_VAR);
|
|
40
40
|
commandSandboxCreate.option('-vf, --variables-from-file <filepath>', texts_1.OPTION_RUN_VAR_FILE);
|
|
41
41
|
commandSandboxCreate.option('-vff, --variable-from-file <variables...>', texts_1.OPTION_RUN_SINGLE_VAR_FILE);
|
package/distTs/src/input.js
CHANGED
|
@@ -492,82 +492,90 @@ class Input {
|
|
|
492
492
|
static sandboxFetch(fetchList) {
|
|
493
493
|
const fetch = [];
|
|
494
494
|
const SEP = '\x00';
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const key = p.substring(0, idx).trim();
|
|
513
|
-
const val = p.substring(idx + 1).trim();
|
|
514
|
-
if (key === 'url' && val) {
|
|
515
|
-
if (repository || type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
516
|
-
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str));
|
|
495
|
+
if (Array.isArray(fetchList)) {
|
|
496
|
+
fetchList.forEach((str) => {
|
|
497
|
+
let type = sandbox_1.SANDBOX_FETCH.PROJECT_REPO;
|
|
498
|
+
let repository = '';
|
|
499
|
+
let ref = '';
|
|
500
|
+
let path = '';
|
|
501
|
+
let build = '';
|
|
502
|
+
let artifact = '';
|
|
503
|
+
const parts = str
|
|
504
|
+
.replace(/\\,/g, SEP)
|
|
505
|
+
.split(',')
|
|
506
|
+
.map((p) => p.split(SEP).join(','));
|
|
507
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
508
|
+
const p = parts[i];
|
|
509
|
+
const idx = p.indexOf('=');
|
|
510
|
+
if (idx < 0) {
|
|
511
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'No key=val delimiter'));
|
|
517
512
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
513
|
+
const key = p.substring(0, idx).trim();
|
|
514
|
+
const val = p.substring(idx + 1).trim();
|
|
515
|
+
if (key === 'url' && val) {
|
|
516
|
+
if (repository || type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
517
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param url defined twice'));
|
|
518
|
+
}
|
|
519
|
+
type = sandbox_1.SANDBOX_FETCH.PUBLIC_REPO;
|
|
520
|
+
repository = val;
|
|
524
521
|
}
|
|
525
|
-
path
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
522
|
+
else if (key === 'path' && val) {
|
|
523
|
+
if (path) {
|
|
524
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param path defined twice'));
|
|
525
|
+
}
|
|
526
|
+
path = val;
|
|
530
527
|
}
|
|
531
|
-
ref
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
528
|
+
else if (key === 'ref' && val) {
|
|
529
|
+
if (ref) {
|
|
530
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param ref defined twice'));
|
|
531
|
+
}
|
|
532
|
+
ref = val;
|
|
536
533
|
}
|
|
537
|
-
build
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
534
|
+
else if (key === 'build' && val) {
|
|
535
|
+
if (build) {
|
|
536
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param build defined twice'));
|
|
537
|
+
}
|
|
538
|
+
build = val;
|
|
539
|
+
}
|
|
540
|
+
else if (key === 'artifact' && val) {
|
|
541
|
+
if (artifact) {
|
|
542
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Param artifact defined twice'));
|
|
543
|
+
}
|
|
544
|
+
if (type !== sandbox_1.SANDBOX_FETCH.PROJECT_REPO) {
|
|
545
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Cant mix artifact with repository'));
|
|
546
|
+
}
|
|
547
|
+
type = sandbox_1.SANDBOX_FETCH.ARTIFACT;
|
|
548
|
+
artifact = val;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Unknown param'));
|
|
542
552
|
}
|
|
543
|
-
type = sandbox_1.SANDBOX_FETCH.ARTIFACT;
|
|
544
|
-
artifact = val;
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str));
|
|
548
553
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str));
|
|
554
|
+
const f = {
|
|
555
|
+
type,
|
|
556
|
+
};
|
|
557
|
+
if (path)
|
|
558
|
+
f.path = path;
|
|
559
|
+
if (repository)
|
|
560
|
+
f.repository = repository;
|
|
561
|
+
if (build)
|
|
562
|
+
f.build_command = build;
|
|
563
|
+
if (ref) {
|
|
564
|
+
if (type === sandbox_1.SANDBOX_FETCH.ARTIFACT) {
|
|
565
|
+
output_1.default.exitError((0, texts_1.ERR_WRONG_FETCH)(str, 'Cant mix repository with artifact'));
|
|
566
|
+
}
|
|
567
|
+
f.ref = ref;
|
|
564
568
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
569
|
+
if (artifact)
|
|
570
|
+
f.artifact = artifact;
|
|
571
|
+
fetch.push(f);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
else if (fetchList) {
|
|
575
|
+
fetch.push({
|
|
576
|
+
type: sandbox_1.SANDBOX_FETCH.PROJECT_REPO,
|
|
577
|
+
});
|
|
578
|
+
}
|
|
571
579
|
return fetch;
|
|
572
580
|
}
|
|
573
581
|
static runVariables(options) {
|
package/distTs/src/texts.js
CHANGED
|
@@ -63,7 +63,7 @@ const ERR_RUN_PIPELINE_WRONG_ACTION = (str) => `Action id has wrong value: ${str
|
|
|
63
63
|
exports.ERR_RUN_PIPELINE_WRONG_ACTION = ERR_RUN_PIPELINE_WRONG_ACTION;
|
|
64
64
|
const ERR_RUN_WRONG_VARIABLE = (v) => `Variable has wrong format: ${v}`;
|
|
65
65
|
exports.ERR_RUN_WRONG_VARIABLE = ERR_RUN_WRONG_VARIABLE;
|
|
66
|
-
const ERR_WRONG_FETCH = (v) => `Fetch has wrong format: ${v}`;
|
|
66
|
+
const ERR_WRONG_FETCH = (v, msg) => `Fetch has wrong format: ${v}. ${msg}`;
|
|
67
67
|
exports.ERR_WRONG_FETCH = ERR_WRONG_FETCH;
|
|
68
68
|
exports.ERR_AGENT_NOT_REGISTERED = 'Agent not registered. Exiting.';
|
|
69
69
|
exports.ERR_SAVING_AGENT_CONFIG = 'Failed saving agent config. Exiting.';
|
|
@@ -611,7 +611,12 @@ exports.OPTION_SANDBOX_TAGS = 'Tags to add on creation (can be used multiple tim
|
|
|
611
611
|
exports.OPTION_SANDBOX_YAML = 'Complete sandbox YAML. To specify file use @path/to/file format in value';
|
|
612
612
|
exports.OPTION_SANDBOX_APP_COMMAND = 'Application command to run at startup (can be used multiple times)';
|
|
613
613
|
exports.OPTION_SANDBOX_APP_DIR = 'Application directory of the sandbox';
|
|
614
|
-
exports.OPTION_SANDBOX_FETCH =
|
|
614
|
+
exports.OPTION_SANDBOX_FETCH = `Fetch sources (can be used multiple times).
|
|
615
|
+
Format: "path=target/directory,url=repository-url,ref=branch/tag/commit,build=command-to-run,artifact=artifact:version"
|
|
616
|
+
To use "," in value use \\,
|
|
617
|
+
For project repository use path (optional), ref (optional), build (optional)
|
|
618
|
+
For external repository use url (required), path (optional), ref (optional), build (optional)
|
|
619
|
+
For artifact use artifact (required), path (optional), build (optional)`;
|
|
615
620
|
exports.OPTION_SANDBOX_TIMEOUT = 'The timeout in seconds after which the sandbox will be automatically stopped';
|
|
616
621
|
exports.OPTION_SANDBOX_RUNTIME = 'Command runtime: BASH, JAVASCRIPT, TYPESCRIPT, PYTHON (default: BASH)';
|
|
617
622
|
// Sandbox errors
|
|
@@ -1002,14 +1007,18 @@ EXAMPLES:
|
|
|
1002
1007
|
bdy sb create -i "test" --install-command "apt-get update && apt-get install curl -y" --wait-for-configure
|
|
1003
1008
|
### create sandbox with custom resources and tag it:
|
|
1004
1009
|
bdy sb create --resources 4x8 --tag "tag1" --tag "tag2"
|
|
1005
|
-
### create sandbox and fetch project repository from default branch
|
|
1006
|
-
bdy sb create --fetch
|
|
1010
|
+
### create sandbox and fetch project repository from default branch to working directory
|
|
1011
|
+
bdy sb create --fetch
|
|
1007
1012
|
### create sandbox and fetch public repository
|
|
1008
1013
|
bdy sb create --fetch "path=/home/buddy/repo,url=https://public-repo.com,ref=feature-branch"
|
|
1009
1014
|
### create sandbox and fetch artifact
|
|
1010
1015
|
bdy sb create --fetch "path=/home/buddy/repo,artifact=name@version"
|
|
1011
1016
|
### create sandbox, fetch project repo branch and build
|
|
1012
1017
|
bdy sb create --fetch "path=/home/buddy/repo,ref=branch,build=npm install && npm run build"
|
|
1018
|
+
### create sandbox and pass custom variables
|
|
1019
|
+
bdy sb create -v key:val -v a:b
|
|
1020
|
+
### create sandbox and pass custom variables from file
|
|
1021
|
+
bdy sb create -vf path/to/env/file
|
|
1013
1022
|
### create sandbox from yaml file:
|
|
1014
1023
|
bdy sb create --yaml @./test.yml"`;
|
|
1015
1024
|
const EXAMPLE_TUNNEL_HTTP = (agent) => `
|