@celonis/content-cli 1.12.0 → 1.13.1
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/commands/action-flows/action-flow/action-flow.service.js +4 -2
- package/commands/asset-registry/asset-registry-api.js +33 -7
- package/commands/asset-registry/asset-registry.service.js +25 -3
- package/commands/asset-registry/module.js +15 -0
- package/commands/configuration-management/api/single-package-export-api.js +38 -0
- package/commands/configuration-management/module.js +26 -5
- package/commands/configuration-management/single-package-export.service.js +64 -0
- package/commands/configuration-management/single-package-import.service.js +32 -12
- package/commands/configuration-management/variable.service.js +12 -14
- package/commands/studio/manager/package.manager.js +1 -1
- package/commands/studio/module.js +8 -4
- package/commands/t2tc/module.js +1 -1
- package/commands/t2tc/t2tc-package.service.js +5 -3
- package/content-cli.js +61 -35
- package/core/command/module-handler.js +5 -0
- package/core/utils/file-service.js +34 -17
- package/core/utils/path.js +17 -0
- package/lib/commands/asset-registry/asset-registry-api.d.ts +5 -0
- package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +5 -0
- package/lib/commands/asset-registry/asset-registry.service.d.ts +3 -1
- package/lib/commands/asset-registry/module.d.ts +1 -0
- package/lib/commands/configuration-management/api/single-package-export-api.d.ts +7 -0
- package/lib/commands/configuration-management/module.d.ts +1 -0
- package/lib/commands/configuration-management/single-package-export.service.d.ts +8 -0
- package/lib/commands/configuration-management/single-package-import.service.d.ts +2 -1
- package/lib/content-cli.d.ts +15 -1
- package/lib/core/utils/file-service.d.ts +7 -1
- package/lib/core/utils/path.d.ts +1 -0
- package/package.json +4 -4
|
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "uuid", "adm-zip", "form-data", "fs", "./action-flow-api", "../../../core/utils/file-service", "../../../core/utils/logger", "../../../core/utils/file.constants"], factory);
|
|
16
|
+
define(["require", "exports", "uuid", "adm-zip", "form-data", "fs", "./action-flow-api", "../../../core/utils/file-service", "../../../core/utils/logger", "../../../core/utils/file.constants", "node:path"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -27,6 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
const file_service_1 = require("../../../core/utils/file-service");
|
|
28
28
|
const logger_1 = require("../../../core/utils/logger");
|
|
29
29
|
const file_constants_1 = require("../../../core/utils/file.constants");
|
|
30
|
+
const node_path_1 = require("node:path");
|
|
30
31
|
class ActionFlowService {
|
|
31
32
|
constructor(context) {
|
|
32
33
|
this.actionFlowApi = new action_flow_api_1.ActionFlowApi(context);
|
|
@@ -43,7 +44,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
44
|
this.attachMetadataFile(metadataFilePath, zip);
|
|
44
45
|
}
|
|
45
46
|
const fileName = "action-flows_export_" + (0, uuid_1.v4)() + ".zip";
|
|
46
|
-
|
|
47
|
+
const fullFilePath = (0, node_path_1.resolve)(process.cwd(), fileName);
|
|
48
|
+
zip.writeZip(fullFilePath, () => fs.chmodSync(fullFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
47
49
|
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + fileName);
|
|
48
50
|
});
|
|
49
51
|
}
|
|
@@ -13,13 +13,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "./asset-registry-error"], factory);
|
|
16
|
+
define(["require", "exports", "./asset-registry-error", "../../core/utils/path"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.AssetRegistryApi = void 0;
|
|
22
22
|
const asset_registry_error_1 = require("./asset-registry-error");
|
|
23
|
+
const path_1 = require("../../core/utils/path");
|
|
23
24
|
class AssetRegistryApi {
|
|
24
25
|
constructor(context) {
|
|
25
26
|
this.httpClient = () => context.httpClient;
|
|
@@ -27,45 +28,70 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
28
|
listTypes() {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
30
|
return this.httpClient()
|
|
30
|
-
.get("
|
|
31
|
+
.get(AssetRegistryApi.endpointUrl("types"))
|
|
31
32
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)("listing asset registry types", e));
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
listSkills() {
|
|
35
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
37
|
return this.httpClient()
|
|
37
|
-
.get("
|
|
38
|
+
.get(AssetRegistryApi.endpointUrl("skills"))
|
|
38
39
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)("listing asset registry skills", e));
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
getType(assetType) {
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
return this.httpClient()
|
|
44
|
-
.get(
|
|
45
|
+
.get(AssetRegistryApi.endpointUrl("types", encodeURIComponent(assetType)))
|
|
45
46
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting asset type '${assetType}'`, e));
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
getSchema(assetType) {
|
|
49
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
51
|
return this.httpClient()
|
|
51
|
-
.get(
|
|
52
|
+
.get(AssetRegistryApi.endpointUrl("schemas", encodeURIComponent(assetType)))
|
|
52
53
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting schema for asset type '${assetType}'`, e));
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
getExamples(assetType) {
|
|
56
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
58
|
return this.httpClient()
|
|
58
|
-
.get(
|
|
59
|
+
.get(AssetRegistryApi.endpointUrl("examples", encodeURIComponent(assetType)))
|
|
59
60
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`getting examples for asset type '${assetType}'`, e));
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
validate(assetType, body) {
|
|
63
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
65
|
return this.httpClient()
|
|
65
|
-
.post(
|
|
66
|
+
.post(AssetRegistryApi.endpointUrl("validate", encodeURIComponent(assetType)), body)
|
|
66
67
|
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(`validating asset type '${assetType}'`, e));
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
getSkillFile(skillPath, filePath) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const operation = filePath
|
|
73
|
+
? `getting skill file '${filePath}' for '${skillPath}'`
|
|
74
|
+
: `getting SKILL.md for '${skillPath}'`;
|
|
75
|
+
const url = this.buildSkillFileUrl(skillPath, filePath);
|
|
76
|
+
return this.httpClient()
|
|
77
|
+
.getFile(url)
|
|
78
|
+
.catch((e) => (0, asset_registry_error_1.handleAssetRegistryApiError)(operation, e));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
buildSkillFileUrl(skillPath, filePath) {
|
|
82
|
+
const segments = ["skills", encodePathSegments(skillPath)];
|
|
83
|
+
if (filePath) {
|
|
84
|
+
segments.push(encodePathSegments(filePath));
|
|
85
|
+
}
|
|
86
|
+
return AssetRegistryApi.endpointUrl(...segments);
|
|
87
|
+
}
|
|
88
|
+
static endpointUrl(...segments) {
|
|
89
|
+
return `${AssetRegistryApi.BASE_URL}/${segments.join("/")}`;
|
|
90
|
+
}
|
|
69
91
|
}
|
|
70
92
|
exports.AssetRegistryApi = AssetRegistryApi;
|
|
93
|
+
AssetRegistryApi.BASE_URL = "/pacman/api/core/asset-registry";
|
|
94
|
+
function encodePathSegments(value) {
|
|
95
|
+
return (0, path_1.trimSlashes)(value).split("/").map(encodeURIComponent).join("/");
|
|
96
|
+
}
|
|
71
97
|
});
|
|
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "./asset-registry-api", "../../core/utils/file-service", "../../core/utils/logger", "uuid", "
|
|
16
|
+
define(["require", "exports", "./asset-registry-api", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/path", "uuid", "node:path"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -22,8 +22,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
const asset_registry_api_1 = require("./asset-registry-api");
|
|
23
23
|
const file_service_1 = require("../../core/utils/file-service");
|
|
24
24
|
const logger_1 = require("../../core/utils/logger");
|
|
25
|
+
const path_1 = require("../../core/utils/path");
|
|
25
26
|
const uuid_1 = require("uuid");
|
|
26
|
-
const
|
|
27
|
+
const path = require("node:path");
|
|
27
28
|
class AssetRegistryService {
|
|
28
29
|
constructor(context) {
|
|
29
30
|
this.api = new asset_registry_api_1.AssetRegistryApi(context);
|
|
@@ -48,6 +49,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
}
|
|
52
|
+
getSkillFile(opts) {
|
|
53
|
+
var _a;
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const filename = this.resolveLocalFilename(opts.file);
|
|
56
|
+
const targetDir = (_a = opts.output) !== null && _a !== void 0 ? _a : ".";
|
|
57
|
+
const buffer = yield this.api.getSkillFile(opts.path, opts.file);
|
|
58
|
+
const absolutePath = file_service_1.fileService.writeBufferToPath(targetDir, filename, buffer);
|
|
59
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + absolutePath);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
resolveLocalFilename(file) {
|
|
63
|
+
if (!file) {
|
|
64
|
+
return "SKILL.md";
|
|
65
|
+
}
|
|
66
|
+
const trimmed = (0, path_1.trimSlashes)(file);
|
|
67
|
+
const base = trimmed ? path.basename(trimmed) : "";
|
|
68
|
+
if (!base) {
|
|
69
|
+
throw new logger_1.FatalError(`--file must point to a file, got '${file}'.`);
|
|
70
|
+
}
|
|
71
|
+
return base;
|
|
72
|
+
}
|
|
51
73
|
listSkills(jsonResponse) {
|
|
52
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
75
|
const response = yield this.api.listSkills();
|
|
@@ -107,7 +129,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
107
129
|
throw new logger_1.FatalError("Option -f is mutually exclusive with --packageKey, --nodeKey and --configuration.");
|
|
108
130
|
}
|
|
109
131
|
if (hasFile) {
|
|
110
|
-
return this.parseJson(
|
|
132
|
+
return this.parseJson(file_service_1.fileService.readFile(opts.file), `-f ${opts.file}`);
|
|
111
133
|
}
|
|
112
134
|
if (hasNodeKey && hasConfig) {
|
|
113
135
|
throw new logger_1.FatalError("Options --nodeKey and --configuration are mutually exclusive. Use --nodeKey to validate a stored node, or --configuration to validate a configuration. For full control, use -f.");
|
|
@@ -57,6 +57,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
57
57
|
.description("List all available agent skills (name, description, path)")
|
|
58
58
|
.option("--json", "Return the response as a JSON file")
|
|
59
59
|
.action(this.listSkills);
|
|
60
|
+
skillsCommand.command("get")
|
|
61
|
+
.description("Download a skill file (defaults to SKILL.md)")
|
|
62
|
+
.requiredOption("--path <path>", "Skill path from 'skills list' (e.g. platform/<skill> or asset/<assetType>/<skill>)")
|
|
63
|
+
.option("--file <file>", "Relative path of a reference file within the skill (defaults to SKILL.md)")
|
|
64
|
+
.option("--output <output>", "Destination directory (defaults to current working directory)")
|
|
65
|
+
.action(this.getSkillFile);
|
|
60
66
|
}
|
|
61
67
|
listTypes(context, command, options) {
|
|
62
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -95,6 +101,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
95
101
|
yield new asset_registry_service_1.AssetRegistryService(context).listSkills(!!options.json);
|
|
96
102
|
});
|
|
97
103
|
}
|
|
104
|
+
getSkillFile(context, command, options) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
yield new asset_registry_service_1.AssetRegistryService(context).getSkillFile({
|
|
107
|
+
path: options.path,
|
|
108
|
+
file: options.file,
|
|
109
|
+
output: options.output,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
98
113
|
}
|
|
99
114
|
return Module;
|
|
100
115
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
(function (factory) {
|
|
11
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
12
|
+
var v = factory(require, exports);
|
|
13
|
+
if (v !== undefined) module.exports = v;
|
|
14
|
+
}
|
|
15
|
+
else if (typeof define === "function" && define.amd) {
|
|
16
|
+
define(["require", "exports", "../../../core/utils/logger"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.SinglePackageExportApi = void 0;
|
|
22
|
+
const logger_1 = require("../../../core/utils/logger");
|
|
23
|
+
class SinglePackageExportApi {
|
|
24
|
+
constructor(context) {
|
|
25
|
+
this.httpClient = () => context.httpClient;
|
|
26
|
+
}
|
|
27
|
+
exportPackage(packageKey) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return this.httpClient()
|
|
30
|
+
.getFile(`/pacman/api/core/staging/packages/${packageKey}/export-file`)
|
|
31
|
+
.catch(e => {
|
|
32
|
+
throw new logger_1.FatalError(`Problem exporting package ${packageKey}: ${e}`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SinglePackageExportApi = SinglePackageExportApi;
|
|
38
|
+
});
|
|
@@ -16,7 +16,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
if (v !== undefined) module.exports = v;
|
|
17
17
|
}
|
|
18
18
|
else if (typeof define === "function" && define.amd) {
|
|
19
|
-
define(["require", "exports", "../../core/command/module-handler", "./config-command.service", "./staging-package.service", "./metadata.service", "../t2tc/t2tc-command.service", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service", "./package-version-command.service", "./package-validation.service", "./single-package-import.service"], factory);
|
|
19
|
+
define(["require", "exports", "../../core/command/module-handler", "./config-command.service", "./staging-package.service", "./metadata.service", "../t2tc/t2tc-command.service", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service", "./package-version-command.service", "./package-validation.service", "./single-package-import.service", "./single-package-export.service"], factory);
|
|
20
20
|
}
|
|
21
21
|
})(function (require, exports) {
|
|
22
22
|
"use strict";
|
|
@@ -32,6 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
const package_version_command_service_1 = require("./package-version-command.service");
|
|
33
33
|
const package_validation_service_1 = require("./package-validation.service");
|
|
34
34
|
const single_package_import_service_1 = require("./single-package-import.service");
|
|
35
|
+
const single_package_export_service_1 = require("./single-package-export.service");
|
|
35
36
|
class Module extends module_handler_1.IModule {
|
|
36
37
|
register(context, configurator) {
|
|
37
38
|
const configCommand = configurator.command("config")
|
|
@@ -80,16 +81,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
80
81
|
const packageCommand = configCommand.command("package")
|
|
81
82
|
.description("Commands for working with a single package.");
|
|
82
83
|
packageCommand.command("import")
|
|
83
|
-
.description("Import a package from a zip file or
|
|
84
|
+
.description("Import a package from a zip file, directory, or Git branch. Uses the package format, which is not interchangeable with the 't2tc package export' / 't2tc package import' batch archive.")
|
|
84
85
|
.option("-f, --file <file>", "Package zip file (relative path)")
|
|
85
86
|
.option("-d, --directory <directory>", "Package directory (relative path)")
|
|
86
87
|
.option("--overwrite", "Flag to allow overwriting an existing package with the same key")
|
|
87
88
|
.option("--json", "Return the response as a JSON file")
|
|
89
|
+
.option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
90
|
+
.option("--gitBranch <gitBranch>", "Git branch from which you want to pull the package and import")
|
|
88
91
|
.action(this.importSinglePackage);
|
|
92
|
+
packageCommand.command("export")
|
|
93
|
+
.description("Export a single package's staging (draft) version to an unzipped directory (or a single zip with --zip, or to a Git branch with --gitBranch). Uses the package format, which is not interchangeable with the 't2tc package export' / 't2tc package import' batch archive.")
|
|
94
|
+
.requiredOption("--packageKey <packageKey>", "Key of the package to export")
|
|
95
|
+
.option("--zip", "Export the package as a single <packageKey>.zip file instead of an unzipped <packageKey> directory", false)
|
|
96
|
+
.option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
97
|
+
.option("--gitBranch <gitBranch>", "Git branch in which you want to push the exported package")
|
|
98
|
+
.action(this.exportSinglePackage);
|
|
89
99
|
packageCommand.command("validate")
|
|
90
100
|
.description("Validate package node configurations")
|
|
91
101
|
.requiredOption("--packageKey <packageKey>", "Key of the package to validate")
|
|
92
|
-
.option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS). Defaults to SCHEMA.", ["SCHEMA"])
|
|
102
|
+
.option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS, PIG_SEMANTICS, DATA_PIPELINES (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS PIG_SEMANTICS DATA_PIPELINES). Defaults to SCHEMA.", ["SCHEMA"])
|
|
93
103
|
.option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
|
|
94
104
|
.option("--json", "Return the response as a JSON file")
|
|
95
105
|
.action(this.validatePackage);
|
|
@@ -102,7 +112,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
102
112
|
.description("[Deprecated] Use 'config package validate' instead. Validate package node configurations.")
|
|
103
113
|
.deprecationNotice("'config validate' is deprecated and will be removed in a future release. Use 'config package validate' instead.")
|
|
104
114
|
.requiredOption("--packageKey <packageKey>", "Key of the package to validate")
|
|
105
|
-
.option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS). Defaults to SCHEMA.", ["SCHEMA"])
|
|
115
|
+
.option("--layers <layers...>", "Validation layers to run. Allowed values: SCHEMA, BUSINESS, PACKAGE_SETTINGS, PIG_SEMANTICS, DATA_PIPELINES (can be combined, e.g. --layers SCHEMA BUSINESS PACKAGE_SETTINGS PIG_SEMANTICS DATA_PIPELINES). Defaults to SCHEMA.", ["SCHEMA"])
|
|
106
116
|
.option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
|
|
107
117
|
.option("--json", "Return the response as a JSON file")
|
|
108
118
|
.action(this.validatePackage);
|
|
@@ -271,7 +281,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
271
281
|
}
|
|
272
282
|
importSinglePackage(context, command, options) {
|
|
273
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
-
|
|
284
|
+
if (options.gitProfile && !options.gitBranch) {
|
|
285
|
+
throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
|
|
286
|
+
}
|
|
287
|
+
yield new single_package_import_service_1.SinglePackageImportService(context).importPackage(options.file, options.directory, options.overwrite, options.json, options.gitBranch);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
exportSinglePackage(context, command, options) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
if (options.gitProfile && !options.gitBranch) {
|
|
293
|
+
throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
|
|
294
|
+
}
|
|
295
|
+
yield new single_package_export_service_1.SinglePackageExportService(context).exportPackage(options.packageKey, options.zip, options.gitBranch);
|
|
275
296
|
});
|
|
276
297
|
}
|
|
277
298
|
diffPackages(context, command, options) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
(function (factory) {
|
|
11
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
12
|
+
var v = factory(require, exports);
|
|
13
|
+
if (v !== undefined) module.exports = v;
|
|
14
|
+
}
|
|
15
|
+
else if (typeof define === "function" && define.amd) {
|
|
16
|
+
define(["require", "exports", "node:fs", "../../core/utils/file-service", "../../core/utils/logger", "../../core/git-profile/git/git.service", "./api/single-package-export-api", "node:path"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.SinglePackageExportService = void 0;
|
|
22
|
+
const fs = require("node:fs");
|
|
23
|
+
const file_service_1 = require("../../core/utils/file-service");
|
|
24
|
+
const logger_1 = require("../../core/utils/logger");
|
|
25
|
+
const git_service_1 = require("../../core/git-profile/git/git.service");
|
|
26
|
+
const single_package_export_api_1 = require("./api/single-package-export-api");
|
|
27
|
+
const node_path_1 = require("node:path");
|
|
28
|
+
class SinglePackageExportService {
|
|
29
|
+
constructor(context) {
|
|
30
|
+
this.singlePackageExportApi = new single_package_export_api_1.SinglePackageExportApi(context);
|
|
31
|
+
this.gitService = new git_service_1.GitService(context);
|
|
32
|
+
}
|
|
33
|
+
exportPackage(packageKey, zip, gitBranch) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const packageData = yield this.singlePackageExportApi.exportPackage(packageKey);
|
|
36
|
+
if (gitBranch) {
|
|
37
|
+
yield this.exportToGitBranch(packageData, gitBranch);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (zip) {
|
|
41
|
+
const fileName = `${packageKey}.zip`;
|
|
42
|
+
file_service_1.fileService.writeBufferToFileWithGivenName(packageData, (0, node_path_1.resolve)(process.cwd(), fileName));
|
|
43
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + fileName);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
file_service_1.fileService.extractZipBufferToDirectory(packageData, packageKey);
|
|
47
|
+
logger_1.logger.info(`Successful export. Exported directory: ${packageKey}`);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exportToGitBranch(packageData, gitBranch) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const extractedDirectory = file_service_1.fileService.extractZipBufferToTempDirectory(packageData);
|
|
53
|
+
try {
|
|
54
|
+
yield this.gitService.pushToBranch(extractedDirectory, gitBranch);
|
|
55
|
+
logger_1.logger.info("Successfully exported package to branch: " + gitBranch);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
fs.rmSync(extractedDirectory, { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.SinglePackageExportService = SinglePackageExportService;
|
|
64
|
+
});
|
|
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "uuid", "form-data", "node:stream", "adm-zip", "node:fs", "../../core/utils/file-service", "../../core/utils/logger", "./api/single-package-import-api"], factory);
|
|
16
|
+
define(["require", "exports", "uuid", "form-data", "node:stream", "adm-zip", "node:fs", "../../core/utils/file-service", "../../core/utils/logger", "../../core/git-profile/git/git.service", "./api/single-package-import-api"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -26,23 +26,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
26
|
const fs = require("node:fs");
|
|
27
27
|
const file_service_1 = require("../../core/utils/file-service");
|
|
28
28
|
const logger_1 = require("../../core/utils/logger");
|
|
29
|
+
const git_service_1 = require("../../core/git-profile/git/git.service");
|
|
29
30
|
const single_package_import_api_1 = require("./api/single-package-import-api");
|
|
30
31
|
class SinglePackageImportService {
|
|
31
32
|
constructor(context) {
|
|
32
33
|
this.singlePackageImportApi = new single_package_import_api_1.SinglePackageImportApi(context);
|
|
34
|
+
this.gitService = new git_service_1.GitService(context);
|
|
33
35
|
}
|
|
34
|
-
importPackage(file, directory, overwrite, jsonResponse) {
|
|
36
|
+
importPackage(file, directory, overwrite, jsonResponse, gitBranch) {
|
|
35
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
38
|
+
if ((file || directory) && gitBranch) {
|
|
39
|
+
throw new Error("You cannot use --file or --directory together with --gitBranch. Only one import source can be defined.");
|
|
40
|
+
}
|
|
41
|
+
if (!file && !directory && !gitBranch) {
|
|
42
|
+
throw new Error("You must provide a --file, a --directory, or a --gitBranch option to import a package.");
|
|
43
|
+
}
|
|
44
|
+
let gitTempDir;
|
|
37
45
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
let resolvedSource;
|
|
47
|
+
if (gitBranch) {
|
|
48
|
+
gitTempDir = yield this.gitService.pullFromBranch(gitBranch);
|
|
49
|
+
resolvedSource = { zipPath: file_service_1.fileService.zipDirectoryAsSinglePackage(gitTempDir), isTemporary: true };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
resolvedSource = this.resolveSource(file, directory);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const packageZip = new AdmZip(resolvedSource.zipPath);
|
|
56
|
+
const formData = this.buildBodyForImport(packageZip, resolvedSource.zipPath);
|
|
57
|
+
const result = yield this.singlePackageImportApi.importPackage(formData, overwrite);
|
|
58
|
+
this.outputResult(result, jsonResponse);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
if (resolvedSource.isTemporary) {
|
|
62
|
+
fs.rmSync(resolvedSource.zipPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
}
|
|
43
66
|
finally {
|
|
44
|
-
if (
|
|
45
|
-
fs.rmSync(
|
|
67
|
+
if (gitTempDir) {
|
|
68
|
+
fs.rmSync(gitTempDir, { recursive: true, force: true });
|
|
46
69
|
}
|
|
47
70
|
}
|
|
48
71
|
});
|
|
@@ -51,9 +74,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
51
74
|
if (file && directory) {
|
|
52
75
|
throw new Error("You cannot use both --file and --directory options at the same time. Only one import source can be defined.");
|
|
53
76
|
}
|
|
54
|
-
if (!file && !directory) {
|
|
55
|
-
throw new Error("You must provide either a --file or a --directory option to import a package.");
|
|
56
|
-
}
|
|
57
77
|
if (file) {
|
|
58
78
|
if (file_service_1.fileService.isDirectory(file)) {
|
|
59
79
|
throw new Error("The --file option accepts only zip files.");
|
|
@@ -84,25 +84,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
84
84
|
}
|
|
85
85
|
getVersionedVariablesByKeyVersionPairs(keysByVersion, keysByVersionFile) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const variablesExportRequest =
|
|
87
|
+
const variablesExportRequest = this.buildKeyVersionPairs(keysByVersion, keysByVersionFile);
|
|
88
88
|
const variableManifests = yield this.variableApi.findVariablesWithValuesByPackageKeysAndVersion(variablesExportRequest);
|
|
89
89
|
return (0, connection_variable_helper_1.fixConnectionVariables)(variableManifests);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
buildKeyVersionPairs(keysByVersion, keysByVersionFile) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return variablesExportRequest;
|
|
105
|
-
});
|
|
93
|
+
let variablesExportRequest = [];
|
|
94
|
+
if (keysByVersion.length !== 0) {
|
|
95
|
+
variablesExportRequest = this.buildKeyAndVersionPairsFromArrayInput(keysByVersion);
|
|
96
|
+
}
|
|
97
|
+
else if (keysByVersion.length === 0 && keysByVersionFile !== "") {
|
|
98
|
+
variablesExportRequest = file_service_1.fileService.readFileToJson(keysByVersionFile);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new logger_1.FatalError("Please provide keysByVersion mappings or file path!");
|
|
102
|
+
}
|
|
103
|
+
return variablesExportRequest;
|
|
106
104
|
}
|
|
107
105
|
buildKeyAndVersionPairsFromArrayInput(keysByVersion) {
|
|
108
106
|
return keysByVersion.map(keyAndVersion => {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
validateOptions() {
|
|
94
94
|
if (this.newKey && this.overwrite) {
|
|
95
95
|
logger_1.logger.error("You cannot overwrite a package and set a new key at the same time. Please use only one of the options.");
|
|
96
|
-
process.exit();
|
|
96
|
+
process.exit(1);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
getPushUrlWithParams(pushUrl) {
|
|
@@ -29,7 +29,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
29
29
|
register(context, configurator) {
|
|
30
30
|
const listCommand = configurator.command("list");
|
|
31
31
|
listCommand.command("packages")
|
|
32
|
-
.description("Command to list all packages")
|
|
32
|
+
.description("[Deprecated] Use 'config package list' instead. Command to list all packages")
|
|
33
|
+
.deprecationNotice("'list packages' is deprecated and will be removed in a future release. Use 'config package list' instead.")
|
|
33
34
|
.option("--json", "Return response as json type", "")
|
|
34
35
|
.option("--includeDependencies", "Include variables and dependencies", "")
|
|
35
36
|
.option("--packageKeys <packageKeys...>", "Lists only given package keys")
|
|
@@ -49,7 +50,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
49
50
|
.requiredOption("--key <key>", "Key of asset you want to pull")
|
|
50
51
|
.action(this.pullAsset);
|
|
51
52
|
pullCommand.command("package")
|
|
52
|
-
.description("Command to pull a package")
|
|
53
|
+
.description("[Deprecated] Use 'config package export' instead. Command to pull a package")
|
|
54
|
+
.deprecationNotice("'pull package' is deprecated and will be removed in a future release. Use 'config package export' instead.")
|
|
53
55
|
.requiredOption("--key <key>", "Key of the package you want to pull")
|
|
54
56
|
.option("--store", "Pull package with store deployment metadata")
|
|
55
57
|
.option("--newKey <newKey>", "Define a new key for your package")
|
|
@@ -66,14 +68,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
66
68
|
.requiredOption("--package <packageKey>", "Key of the package you want to push assets to")
|
|
67
69
|
.action(this.pushAssets);
|
|
68
70
|
pushCommand.command("package")
|
|
69
|
-
.description("Command to push a package to Studio")
|
|
71
|
+
.description("[Deprecated] Use 'config package import' instead. Command to push a package to Studio")
|
|
72
|
+
.deprecationNotice("'push package' is deprecated and will be removed in a future release. Use 'config package import' instead.")
|
|
70
73
|
.option("--newKey <newKey>", "Define a new key for your package")
|
|
71
74
|
.option("--overwrite", "Overwrite package and its assets")
|
|
72
75
|
.requiredOption("-f, --file <file>", "The file you want to push")
|
|
73
76
|
.requiredOption("--spaceKey <spaceKey>", "The key of the destination space")
|
|
74
77
|
.action(this.pushPackage);
|
|
75
78
|
pushCommand.command("packages")
|
|
76
|
-
.description("Command to push packages to Studio")
|
|
79
|
+
.description("[Deprecated] Use 'config package import' (single package) instead. Command to push packages to Studio")
|
|
80
|
+
.deprecationNotice("'push packages' is deprecated and will be removed in a future release. Use 'config package import' (single package) instead.")
|
|
77
81
|
.requiredOption("--spaceKey <spaceKey>", "The key of the destination space")
|
|
78
82
|
.action(this.pushPackages);
|
|
79
83
|
pushCommand.command("widget")
|
package/commands/t2tc/module.js
CHANGED
|
@@ -38,7 +38,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
38
38
|
.option("--staging", "List staging packages instead", false)
|
|
39
39
|
.action(this.listPackages);
|
|
40
40
|
t2tcPackageCommand.command("export")
|
|
41
|
-
.description("Export one or more packages into a Team-to-Team Copy archive. The archive is consumed by 't2tc package import' / 't2tc package diff'.")
|
|
41
|
+
.description("Export one or more packages into a Team-to-Team Copy archive. The archive is consumed by 't2tc package import' / 't2tc package diff'. To export a single standalone package, use 'config package export'.")
|
|
42
42
|
.option("--packageKeys <packageKeys...>", "Keys of packages to export. Exports the latest deployed version only")
|
|
43
43
|
.option("--keysByVersion <keysByVersion...>", "Keys of packages to export by version")
|
|
44
44
|
.option("--withDependencies", "Include variables and dependencies", "")
|
|
@@ -13,7 +13,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "uuid", "form-data", "stream", "adm-zip", "./batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/t2tc-package-api", "../configuration-management/api/variable-api", "../configuration-management/connection-variable.helper", "./studio.service", "../../core/git-profile/git/git.service", "fs", "../../core/utils/file.constants"], factory);
|
|
16
|
+
define(["require", "exports", "uuid", "form-data", "stream", "adm-zip", "./batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/t2tc-package-api", "../configuration-management/api/variable-api", "../configuration-management/connection-variable.helper", "./studio.service", "../../core/git-profile/git/git.service", "fs", "../../core/utils/file.constants", "node:path"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -35,6 +35,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35
35
|
const git_service_1 = require("../../core/git-profile/git/git.service");
|
|
36
36
|
const fs = require("fs");
|
|
37
37
|
const file_constants_1 = require("../../core/utils/file.constants");
|
|
38
|
+
const node_path_1 = require("node:path");
|
|
38
39
|
class T2tcPackageService {
|
|
39
40
|
constructor(context) {
|
|
40
41
|
this.t2tcPackageApi = new t2tc_package_api_1.T2tcPackageApi(context);
|
|
@@ -138,7 +139,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
138
139
|
const postPackageImportData = yield this.t2tcPackageApi.importPackages(formData, overwrite, performValidation);
|
|
139
140
|
yield this.studioService.processImportedPackages(configs, existingStudioPackages, studioManifests);
|
|
140
141
|
if (gitBranch) {
|
|
141
|
-
fs.rmSync(temporaryGitFolder, { recursive: true });
|
|
142
|
+
fs.rmSync(temporaryGitFolder, { recursive: true, force: true });
|
|
142
143
|
}
|
|
143
144
|
fs.rmSync(sourceToBeImported);
|
|
144
145
|
const reportFileName = "config_import_report_" + (0, uuid_1.v4)() + ".json";
|
|
@@ -229,7 +230,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
229
230
|
else {
|
|
230
231
|
const fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
231
232
|
const filename = `export_${(0, uuid_1.v4)()}.zip`;
|
|
232
|
-
|
|
233
|
+
const fullFilePath = (0, node_path_1.resolve)(process.cwd(), filename);
|
|
234
|
+
exportedZip.writeZip(fullFilePath, () => fs.chmodSync(fullFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
233
235
|
logger_1.logger.info(fileDownloadedMessage + filename);
|
|
234
236
|
}
|
|
235
237
|
}
|
package/content-cli.js
CHANGED
|
@@ -19,6 +19,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
})(function (require, exports) {
|
|
20
20
|
"use strict";
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.createProgram = void 0;
|
|
22
23
|
const semverSatisfies = require("semver/functions/satisfies");
|
|
23
24
|
const commander_1 = require("commander");
|
|
24
25
|
const module_handler_1 = require("./core/command/module-handler");
|
|
@@ -31,61 +32,86 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
32
|
*
|
|
32
33
|
* This is the main entry point for the CLI.
|
|
33
34
|
*/
|
|
34
|
-
// Check if the Node.js version satisfies the minimum requirements
|
|
35
35
|
const requiredVersion = ">=10.10.0";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
program.configureHelp({
|
|
43
|
-
formatHelp: (cmd, helper) => new CustomHelp_1.ContentCLIHelp().formatHelp(cmd, helper),
|
|
44
|
-
subcommandTerm: cmd => new CustomHelp_1.ContentCLIHelp().subcommandTerm(cmd),
|
|
45
|
-
optionTerm: opt => new CustomHelp_1.ContentCLIHelp().optionTerm(opt),
|
|
46
|
-
});
|
|
47
|
-
program.version(version_1.VersionUtils.getCurrentCliVersion());
|
|
48
|
-
program.option("-q, --quietmode", "Reduce output to a minimum", false);
|
|
49
|
-
program.option("-p, --profile [profile]");
|
|
50
|
-
program.option("--gitProfile [gitProfile]", "Git profile to use");
|
|
51
|
-
program.option("--debug", "Print debug messages", false);
|
|
52
|
-
program.option("--dev", "Development Mode", false);
|
|
53
|
-
program.parseOptions(process.argv);
|
|
54
|
-
if (!program.opts().quietmode) {
|
|
55
|
-
console.log(`Content CLI - (C) Copyright 2025 - Celonis SE - Version ${version_1.VersionUtils.getCurrentCliVersion()}`);
|
|
56
|
-
console.log();
|
|
36
|
+
function addDefaultOptions(program) {
|
|
37
|
+
program.option("-q, --quietmode", "Reduce output to a minimum", false);
|
|
38
|
+
program.option("-p, --profile [profile]");
|
|
39
|
+
program.option("--gitProfile [gitProfile]", "Git profile to use");
|
|
40
|
+
program.option("--debug", "Print debug messages", false);
|
|
41
|
+
program.option("--dev", "Development Mode", false);
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Build a fully-configured Commander program without parsing argv
|
|
45
|
+
*/
|
|
46
|
+
function createProgram(context, opts = {}) {
|
|
47
|
+
var _a;
|
|
48
|
+
const program = new commander_1.Command();
|
|
49
|
+
program.configureHelp({
|
|
50
|
+
formatHelp: (cmd, helper) => new CustomHelp_1.ContentCLIHelp().formatHelp(cmd, helper),
|
|
51
|
+
subcommandTerm: cmd => new CustomHelp_1.ContentCLIHelp().subcommandTerm(cmd),
|
|
52
|
+
optionTerm: opt => new CustomHelp_1.ContentCLIHelp().optionTerm(opt),
|
|
61
53
|
});
|
|
54
|
+
program.version(version_1.VersionUtils.getCurrentCliVersion());
|
|
55
|
+
addDefaultOptions(program);
|
|
56
|
+
const moduleHandler = new module_handler_1.ModuleHandler(program, context);
|
|
57
|
+
configureRootCommands(moduleHandler.configurator);
|
|
58
|
+
if (opts.modules) {
|
|
59
|
+
for (const moduleClass of opts.modules) {
|
|
60
|
+
const moduleInstance = new moduleClass();
|
|
61
|
+
moduleInstance.register(context, moduleHandler.configurator);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const rootPath = __dirname;
|
|
66
|
+
const devMode = (_a = opts.devMode) !== null && _a !== void 0 ? _a : !!program.opts().dev;
|
|
67
|
+
moduleHandler.discoverAndRegisterModules(rootPath, devMode);
|
|
68
|
+
}
|
|
69
|
+
return program;
|
|
62
70
|
}
|
|
71
|
+
exports.createProgram = createProgram;
|
|
63
72
|
/**
|
|
64
73
|
* To support the legacy command structure, we have to configure some root commands
|
|
65
74
|
* that the individual modules will extend.
|
|
66
75
|
*/
|
|
67
76
|
function configureRootCommands(configurator) {
|
|
68
|
-
configurator.command("list")
|
|
69
|
-
.description("Commands to list content.")
|
|
70
|
-
.alias("ls");
|
|
77
|
+
configurator.command("list").description("Commands to list content.").alias("ls");
|
|
71
78
|
}
|
|
72
79
|
function run() {
|
|
73
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
81
|
+
if (!semverSatisfies(process.version, requiredVersion)) {
|
|
82
|
+
logger_1.logger.error(`Node version ${process.version} not supported. Please upgrade your node version to ${requiredVersion}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
// Parse global options up-front so banner/debug-level decisions can use
|
|
86
|
+
// them before module discovery runs.
|
|
87
|
+
const bootstrapProgram = new commander_1.Command();
|
|
88
|
+
addDefaultOptions(bootstrapProgram);
|
|
89
|
+
bootstrapProgram.allowUnknownOption(true);
|
|
90
|
+
bootstrapProgram.parseOptions(process.argv);
|
|
91
|
+
const globalOpts = bootstrapProgram.opts();
|
|
92
|
+
if (!globalOpts.quietmode) {
|
|
93
|
+
console.log(`Content CLI - (C) Copyright 2025 - Celonis SE - Version ${version_1.VersionUtils.getCurrentCliVersion()}`);
|
|
94
|
+
console.log();
|
|
95
|
+
}
|
|
96
|
+
if (globalOpts.debug) {
|
|
97
|
+
logger_1.logger.transports.forEach(t => {
|
|
98
|
+
t.level = "debug";
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const context = new cli_context_1.Context(globalOpts);
|
|
75
102
|
yield context.init();
|
|
76
|
-
const
|
|
77
|
-
configureRootCommands(moduleHandler.configurator);
|
|
78
|
-
moduleHandler.discoverAndRegisterModules(__dirname, program.opts().dev);
|
|
103
|
+
const program = createProgram(context, { devMode: !!globalOpts.dev });
|
|
79
104
|
try {
|
|
80
|
-
program.
|
|
105
|
+
yield program.parseAsync(process.argv);
|
|
81
106
|
}
|
|
82
107
|
catch (error) {
|
|
83
108
|
logger_1.logger.error(`An unexpected error occurred: ${error}`);
|
|
84
109
|
}
|
|
85
110
|
});
|
|
86
111
|
}
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
if (require.main === module) {
|
|
113
|
+
run();
|
|
114
|
+
}
|
|
89
115
|
process.on("uncaughtException", (error, origin) => {
|
|
90
116
|
console.error("\n💥 UNCAUGHT EXCEPTION!\n");
|
|
91
117
|
console.error("Error:", error);
|
|
@@ -200,7 +200,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
200
200
|
yield handler(this.ctx, this.cmd, this.cmd.optsWithGlobals());
|
|
201
201
|
}
|
|
202
202
|
catch (error) {
|
|
203
|
+
if (error instanceof logger_1.GracefulError) {
|
|
204
|
+
logger_1.logger.error(error.message);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
203
207
|
logger_1.logger.error(`An unexpected error occured executing a command: ${error}`);
|
|
208
|
+
process.exitCode = 1;
|
|
204
209
|
}
|
|
205
210
|
}));
|
|
206
211
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
(function (factory) {
|
|
11
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
12
3
|
var v = factory(require, exports);
|
|
@@ -33,12 +24,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
24
|
mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
|
|
34
25
|
});
|
|
35
26
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return JSON.parse(fileContent);
|
|
27
|
+
writeBufferToFileWithGivenName(data, filename) {
|
|
28
|
+
fs.writeFileSync(path.resolve(process.cwd(), filename), data, {
|
|
29
|
+
mode: file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS,
|
|
40
30
|
});
|
|
41
31
|
}
|
|
32
|
+
writeBufferToPath(targetDir, filename, data) {
|
|
33
|
+
const resolvedDir = path.resolve(process.cwd(), targetDir);
|
|
34
|
+
const absolutePath = path.join(resolvedDir, filename);
|
|
35
|
+
this.mkdirRecursive(resolvedDir);
|
|
36
|
+
this.writeBufferToFileWithGivenName(data, absolutePath);
|
|
37
|
+
return absolutePath;
|
|
38
|
+
}
|
|
39
|
+
extractZipBufferToDirectory(data, targetDir) {
|
|
40
|
+
const targetPath = path.resolve(process.cwd(), targetDir);
|
|
41
|
+
this.mkdirRecursive(targetPath);
|
|
42
|
+
new AdmZip(data).extractAllTo(targetPath, true, true);
|
|
43
|
+
this.restrictFilePermissions(targetPath);
|
|
44
|
+
}
|
|
45
|
+
extractZipBufferToTempDirectory(data) {
|
|
46
|
+
const tempDir = path.join(os.tmpdir(), `content-cli-${(0, uuid_1.v4)()}`);
|
|
47
|
+
this.mkdirRecursive(tempDir);
|
|
48
|
+
new AdmZip(data).extractAllTo(tempDir, true, true);
|
|
49
|
+
this.restrictFilePermissions(tempDir);
|
|
50
|
+
return tempDir;
|
|
51
|
+
}
|
|
52
|
+
readFileToJson(fileName) {
|
|
53
|
+
const fileContent = this.readFile(fileName);
|
|
54
|
+
return JSON.parse(fileContent);
|
|
55
|
+
}
|
|
42
56
|
readFile(filename) {
|
|
43
57
|
if (!fs.existsSync(path.resolve(process.cwd(), filename))) {
|
|
44
58
|
logger_1.logger.error(new logger_1.FatalError(`The provided file '${filename}' does not exit`));
|
|
@@ -50,7 +64,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
50
64
|
return this.extractExportedZipWithNestedZipsToDir(zipFile, tempDir);
|
|
51
65
|
}
|
|
52
66
|
extractExportedZipWithNestedZipsToDir(zipFile, targetDir) {
|
|
53
|
-
|
|
67
|
+
this.mkdirRecursive(targetDir);
|
|
54
68
|
zipFile.extractAllTo(targetDir, true, true);
|
|
55
69
|
const files = fs.readdirSync(targetDir);
|
|
56
70
|
for (const file of files) {
|
|
@@ -58,7 +72,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
58
72
|
if (file.endsWith(".zip")) {
|
|
59
73
|
const nestedZip = new AdmZip(innerZipPath);
|
|
60
74
|
const nestedDir = innerZipPath.replace(/\.zip$/, "");
|
|
61
|
-
|
|
75
|
+
this.mkdirRecursive(nestedDir);
|
|
62
76
|
nestedZip.extractAllTo(nestedDir, true, true);
|
|
63
77
|
fs.rmSync(innerZipPath); // Optionally remove the inner zip
|
|
64
78
|
}
|
|
@@ -90,7 +104,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
90
104
|
}
|
|
91
105
|
});
|
|
92
106
|
const tempDir = path.join(os.tmpdir(), "content-cli-exports");
|
|
93
|
-
|
|
107
|
+
this.mkdirRecursive(tempDir);
|
|
94
108
|
const zipFilePath = path.join(tempDir, `export_${(0, uuid_1.v4)()}.zip`);
|
|
95
109
|
finalZip.writeZip(zipFilePath, () => fs.chmodSync(zipFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
96
110
|
return zipFilePath;
|
|
@@ -102,7 +116,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
102
116
|
const zip = new AdmZip();
|
|
103
117
|
zip.addLocalFolder(sourceDir);
|
|
104
118
|
const tempDir = path.join(os.tmpdir(), "content-cli-imports");
|
|
105
|
-
|
|
119
|
+
this.mkdirRecursive(tempDir);
|
|
106
120
|
const zipFilePath = path.join(tempDir, `single_package_${(0, uuid_1.v4)()}.zip`);
|
|
107
121
|
zip.writeZip(zipFilePath, () => fs.chmodSync(zipFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
108
122
|
return zipFilePath;
|
|
@@ -110,6 +124,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
110
124
|
getSerializedFileContent(data) {
|
|
111
125
|
return data;
|
|
112
126
|
}
|
|
127
|
+
mkdirRecursive(dir) {
|
|
128
|
+
fs.mkdirSync(dir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
|
|
129
|
+
}
|
|
113
130
|
restrictFilePermissions(targetDir) {
|
|
114
131
|
var _a;
|
|
115
132
|
const files = fs.readdirSync(targetDir);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.trimSlashes = void 0;
|
|
13
|
+
function trimSlashes(value) {
|
|
14
|
+
return value.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
15
|
+
}
|
|
16
|
+
exports.trimSlashes = trimSlashes;
|
|
17
|
+
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Context } from "../../core/command/cli-context";
|
|
2
3
|
import { AgentSkillsResponse, AssetRegistryDescriptor, AssetRegistryMetadata } from "./asset-registry.interfaces";
|
|
3
4
|
export declare class AssetRegistryApi {
|
|
5
|
+
private static readonly BASE_URL;
|
|
4
6
|
private httpClient;
|
|
5
7
|
constructor(context: Context);
|
|
6
8
|
listTypes(): Promise<AssetRegistryMetadata>;
|
|
@@ -9,4 +11,7 @@ export declare class AssetRegistryApi {
|
|
|
9
11
|
getSchema(assetType: string): Promise<any>;
|
|
10
12
|
getExamples(assetType: string): Promise<any>;
|
|
11
13
|
validate(assetType: string, body: any): Promise<any>;
|
|
14
|
+
getSkillFile(skillPath: string, filePath?: string): Promise<Buffer>;
|
|
15
|
+
private buildSkillFileUrl;
|
|
16
|
+
private static endpointUrl;
|
|
12
17
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ValidateOptions } from "./asset-registry.interfaces";
|
|
1
|
+
import { GetSkillFileOptions, ValidateOptions } from "./asset-registry.interfaces";
|
|
2
2
|
import { Context } from "../../core/command/cli-context";
|
|
3
3
|
export declare class AssetRegistryService {
|
|
4
4
|
private api;
|
|
5
5
|
constructor(context: Context);
|
|
6
6
|
listTypes(jsonResponse: boolean): Promise<void>;
|
|
7
|
+
getSkillFile(opts: GetSkillFileOptions): Promise<void>;
|
|
8
|
+
private resolveLocalFilename;
|
|
7
9
|
listSkills(jsonResponse: boolean): Promise<void>;
|
|
8
10
|
getType(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
9
11
|
getSchema(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from "../../core/command/cli-context";
|
|
2
|
+
export declare class SinglePackageExportService {
|
|
3
|
+
private readonly singlePackageExportApi;
|
|
4
|
+
private readonly gitService;
|
|
5
|
+
constructor(context: Context);
|
|
6
|
+
exportPackage(packageKey: string, zip: boolean, gitBranch: string): Promise<void>;
|
|
7
|
+
private exportToGitBranch;
|
|
8
|
+
}
|
|
@@ -2,8 +2,9 @@ import { Context } from "../../core/command/cli-context";
|
|
|
2
2
|
export declare class SinglePackageImportService {
|
|
3
3
|
private static readonly MAX_UNCOMPRESSED_ZIP_SIZE;
|
|
4
4
|
private readonly singlePackageImportApi;
|
|
5
|
+
private readonly gitService;
|
|
5
6
|
constructor(context: Context);
|
|
6
|
-
importPackage(file: string, directory: string, overwrite: boolean, jsonResponse: boolean): Promise<void>;
|
|
7
|
+
importPackage(file: string, directory: string, overwrite: boolean, jsonResponse: boolean, gitBranch: string): Promise<void>;
|
|
7
8
|
private resolveSource;
|
|
8
9
|
private buildBodyForImport;
|
|
9
10
|
private assertUncompressedSizeWithinLimit;
|
package/lib/content-cli.d.ts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { IModuleConstructor } from "./core/command/module-handler";
|
|
4
|
+
import { Context } from "./core/command/cli-context";
|
|
5
|
+
export interface CreateProgramOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Explicit list of module classes to register. When provided, the factory
|
|
8
|
+
* skips automatic, filesystem-based module discovery.
|
|
9
|
+
*/
|
|
10
|
+
modules?: IModuleConstructor[];
|
|
11
|
+
devMode?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a fully-configured Commander program without parsing argv
|
|
15
|
+
*/
|
|
16
|
+
export declare function createProgram(context: Context, opts?: CreateProgramOptions): Command;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import AdmZip = require("adm-zip");
|
|
2
3
|
export declare class FileService {
|
|
3
4
|
static readonly fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
4
5
|
writeToFileWithGivenName(data: any, filename: string): void;
|
|
5
|
-
|
|
6
|
+
writeBufferToFileWithGivenName(data: Buffer, filename: string): void;
|
|
7
|
+
writeBufferToPath(targetDir: string, filename: string, data: Buffer): string;
|
|
8
|
+
extractZipBufferToDirectory(data: Buffer, targetDir: string): void;
|
|
9
|
+
extractZipBufferToTempDirectory(data: Buffer): string;
|
|
10
|
+
readFileToJson(fileName: string): any;
|
|
6
11
|
readFile(filename: string): string;
|
|
7
12
|
extractExportedZipWithNestedZips(zipFile: AdmZip): string;
|
|
8
13
|
extractExportedZipWithNestedZipsToDir(zipFile: AdmZip, targetDir: string): string;
|
|
@@ -10,6 +15,7 @@ export declare class FileService {
|
|
|
10
15
|
zipDirectoryInBatchExportFormat(sourceDir: string): string;
|
|
11
16
|
zipDirectoryAsSinglePackage(sourceDir: string): string;
|
|
12
17
|
private getSerializedFileContent;
|
|
18
|
+
private mkdirRecursive;
|
|
13
19
|
private restrictFilePermissions;
|
|
14
20
|
}
|
|
15
21
|
export declare const fileService: FileService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function trimSlashes(value: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celonis/content-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "CLI Tool to help manage content in Celonis Platform",
|
|
5
5
|
"main": "content-cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"adm-zip": "0.5.14",
|
|
22
22
|
"chalk": "4.1.2",
|
|
23
23
|
"uuid": "9.0.1",
|
|
24
|
-
"axios": "1.
|
|
24
|
+
"axios": "1.16.0",
|
|
25
25
|
"commander": "13.1.0",
|
|
26
|
-
"form-data": "4.0.
|
|
26
|
+
"form-data": "4.0.6",
|
|
27
27
|
"openid-client": "5.6.1",
|
|
28
28
|
"hpagent": "1.2.0",
|
|
29
29
|
"@github/keytar": "7.10.6",
|
|
30
30
|
"semver": "7.6.3",
|
|
31
|
-
"simple-git": "3.
|
|
31
|
+
"simple-git": "3.36.0",
|
|
32
32
|
"valid-url": "1.0.9",
|
|
33
33
|
"winston": "3.17.0",
|
|
34
34
|
"yaml": "2.8.3"
|