@celonis/content-cli 1.12.0 → 1.14.0
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/README.md +17 -5
- package/commands/action-flows/action-flow/action-flow.service.js +4 -2
- package/commands/action-flows/module.js +2 -1
- package/commands/asset-registry/asset-registry-api.js +9 -12
- package/commands/asset-registry/asset-registry.service.js +2 -31
- package/commands/asset-registry/module.js +0 -11
- package/commands/bookmarks/bookmarks-api.js +49 -0
- package/commands/bookmarks/bookmarks-command.service.js +46 -0
- package/commands/bookmarks/bookmarks.interfaces.js +12 -0
- package/commands/bookmarks/module.js +49 -0
- package/commands/configuration-management/api/single-package-export-api.js +38 -0
- package/commands/configuration-management/branch/api/branch.api.js +88 -0
- package/commands/configuration-management/branch/branch-export-import.command.service.js +276 -0
- package/commands/configuration-management/branch/branch.command.service.js +178 -0
- package/commands/configuration-management/branch/interfaces/branch.interfaces.js +41 -0
- package/commands/configuration-management/module.js +189 -5
- package/commands/configuration-management/single-package-export.service.js +64 -0
- package/commands/configuration-management/single-package-import.service.js +37 -17
- package/commands/configuration-management/variable.service.js +12 -14
- package/commands/data-pipeline/connection/connection.commands.js +4 -2
- package/commands/data-pipeline/data-pool/data-pool.commands.js +2 -1
- package/commands/deployment/module.js +4 -7
- 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 +65 -35
- package/core/command/module-handler.js +13 -1
- package/core/feature-flag/feature-disabled-error.js +52 -0
- package/core/utils/branches.js +10 -0
- package/core/utils/file-service.js +27 -17
- package/lib/commands/asset-registry/asset-registry-api.d.ts +4 -3
- package/lib/commands/asset-registry/asset-registry.interfaces.d.ts +0 -12
- package/lib/commands/asset-registry/asset-registry.service.d.ts +1 -3
- package/lib/commands/asset-registry/module.d.ts +0 -1
- package/lib/commands/bookmarks/bookmarks-api.d.ts +8 -0
- package/lib/commands/bookmarks/bookmarks-command.service.d.ts +7 -0
- package/lib/commands/bookmarks/bookmarks.interfaces.d.ts +34 -0
- package/lib/commands/bookmarks/module.d.ts +8 -0
- package/lib/commands/configuration-management/api/single-package-export-api.d.ts +7 -0
- package/lib/commands/configuration-management/branch/api/branch.api.d.ts +12 -0
- package/lib/commands/configuration-management/branch/branch-export-import.command.service.d.ts +36 -0
- package/lib/commands/configuration-management/branch/branch.command.service.d.ts +18 -0
- package/lib/commands/configuration-management/branch/interfaces/branch.interfaces.d.ts +139 -0
- package/lib/commands/configuration-management/module.d.ts +9 -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 +7 -4
- package/lib/content-cli.d.ts +15 -1
- package/lib/core/command/module-handler.d.ts +4 -4
- package/lib/core/feature-flag/feature-disabled-error.d.ts +16 -0
- package/lib/core/utils/branches.d.ts +3 -0
- package/lib/core/utils/file-service.d.ts +6 -1
- package/package.json +5 -5
|
@@ -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,90 @@ 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
|
-
|
|
70
|
-
|
|
77
|
+
configurator.command("list").description("Commands to list content.").alias("ls");
|
|
78
|
+
configurator.command("export").description("Export resource: action flow or data pool");
|
|
79
|
+
configurator.command("import").description("Import resource: action flow or data pool");
|
|
80
|
+
configurator.command("pull").description("Pull resource: skill, bookmark, view bookmark, data pool or asset");
|
|
81
|
+
configurator.command("push").description("Push resource: asset, skill, bookmark, view bookmark, CTP or data pool");
|
|
71
82
|
}
|
|
72
83
|
function run() {
|
|
73
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
|
|
85
|
+
if (!semverSatisfies(process.version, requiredVersion)) {
|
|
86
|
+
logger_1.logger.error(`Node version ${process.version} not supported. Please upgrade your node version to ${requiredVersion}`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
// Parse global options up-front so banner/debug-level decisions can use
|
|
90
|
+
// them before module discovery runs.
|
|
91
|
+
const bootstrapProgram = new commander_1.Command();
|
|
92
|
+
addDefaultOptions(bootstrapProgram);
|
|
93
|
+
bootstrapProgram.allowUnknownOption(true);
|
|
94
|
+
bootstrapProgram.parseOptions(process.argv);
|
|
95
|
+
const globalOpts = bootstrapProgram.opts();
|
|
96
|
+
if (!globalOpts.quietmode) {
|
|
97
|
+
console.log(`Content CLI - (C) Copyright 2025 - Celonis SE - Version ${version_1.VersionUtils.getCurrentCliVersion()}`);
|
|
98
|
+
console.log();
|
|
99
|
+
}
|
|
100
|
+
if (globalOpts.debug) {
|
|
101
|
+
logger_1.logger.transports.forEach(t => {
|
|
102
|
+
t.level = "debug";
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const context = new cli_context_1.Context(globalOpts);
|
|
75
106
|
yield context.init();
|
|
76
|
-
const
|
|
77
|
-
configureRootCommands(moduleHandler.configurator);
|
|
78
|
-
moduleHandler.discoverAndRegisterModules(__dirname, program.opts().dev);
|
|
107
|
+
const program = createProgram(context, { devMode: !!globalOpts.dev });
|
|
79
108
|
try {
|
|
80
|
-
program.
|
|
109
|
+
yield program.parseAsync(process.argv);
|
|
81
110
|
}
|
|
82
111
|
catch (error) {
|
|
83
112
|
logger_1.logger.error(`An unexpected error occurred: ${error}`);
|
|
84
113
|
}
|
|
85
114
|
});
|
|
86
115
|
}
|
|
87
|
-
|
|
88
|
-
|
|
116
|
+
if (require.main === module) {
|
|
117
|
+
run();
|
|
118
|
+
}
|
|
89
119
|
process.on("uncaughtException", (error, origin) => {
|
|
90
120
|
console.error("\n💥 UNCAUGHT EXCEPTION!\n");
|
|
91
121
|
console.error("Error:", error);
|
|
@@ -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", "path", "fs", "commander", "../utils/logger", "chalk"], factory);
|
|
16
|
+
define(["require", "exports", "path", "fs", "commander", "../utils/logger", "../feature-flag/feature-disabled-error", "chalk"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -23,6 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
const fs = require("fs");
|
|
24
24
|
const commander_1 = require("commander");
|
|
25
25
|
const logger_1 = require("../utils/logger");
|
|
26
|
+
const feature_disabled_error_1 = require("../feature-flag/feature-disabled-error");
|
|
26
27
|
const chalk = require("chalk");
|
|
27
28
|
class IModule {
|
|
28
29
|
}
|
|
@@ -200,7 +201,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
200
201
|
yield handler(this.ctx, this.cmd, this.cmd.optsWithGlobals());
|
|
201
202
|
}
|
|
202
203
|
catch (error) {
|
|
204
|
+
if (error instanceof logger_1.GracefulError) {
|
|
205
|
+
logger_1.logger.error(error.message);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// Backend gates early-access features; translate its "feature disabled"
|
|
209
|
+
// rejection into a clear message instead of a raw error.
|
|
210
|
+
if ((0, feature_disabled_error_1.isFeatureDisabledError)(error)) {
|
|
211
|
+
logger_1.logger.error(`'${this.cmd.name()}' is not enabled for your team. Contact support to request access.`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
203
214
|
logger_1.logger.error(`An unexpected error occured executing a command: ${error}`);
|
|
215
|
+
process.exitCode = 1;
|
|
204
216
|
}
|
|
205
217
|
}));
|
|
206
218
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.isFeatureDisabledError = exports.FEATURE_DISABLED_CODE = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Recognizes the backend's "feature not enabled" response so the CLI can surface a
|
|
15
|
+
* clear message instead of a raw error. Enforcement stays entirely in the backend
|
|
16
|
+
* (pacman); the CLI only translates the response — it never decides entitlement.
|
|
17
|
+
*
|
|
18
|
+
* The backend rejects a flag-gated request with 403 and a machine-readable body:
|
|
19
|
+
* {"errorCode":"feature-disabled", ...} (pacman's standard ErrorTransport). Keying
|
|
20
|
+
* off the stable code (rather than a free-text message) keeps this robust.
|
|
21
|
+
*/
|
|
22
|
+
exports.FEATURE_DISABLED_CODE = "feature-disabled";
|
|
23
|
+
/**
|
|
24
|
+
* True when the given error represents a backend "feature disabled" rejection.
|
|
25
|
+
* HttpClient rejects with the stringified response body (often wrapped as
|
|
26
|
+
* "FatalError: {json}"), so we extract and parse the embedded JSON payload.
|
|
27
|
+
*/
|
|
28
|
+
function isFeatureDisabledError(error) {
|
|
29
|
+
return extractErrorCode(error) === exports.FEATURE_DISABLED_CODE;
|
|
30
|
+
}
|
|
31
|
+
exports.isFeatureDisabledError = isFeatureDisabledError;
|
|
32
|
+
function extractErrorCode(error) {
|
|
33
|
+
let text = "";
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
text = error.message;
|
|
36
|
+
}
|
|
37
|
+
else if (typeof error === "string") {
|
|
38
|
+
text = error;
|
|
39
|
+
}
|
|
40
|
+
const jsonStart = text.indexOf("{");
|
|
41
|
+
if (jsonStart === -1) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const payload = JSON.parse(text.slice(jsonStart));
|
|
46
|
+
return typeof payload.errorCode === "string" ? payload.errorCode : undefined;
|
|
47
|
+
}
|
|
48
|
+
catch (_a) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
package/core/utils/branches.js
CHANGED
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
}
|
|
18
18
|
return packageKey.includes(BranchUtils.BRANCH_SEPARATOR);
|
|
19
19
|
}
|
|
20
|
+
static constructBranchKey(projectKey, branchKey) {
|
|
21
|
+
return `${projectKey}${BranchUtils.BRANCH_SEPARATOR}${branchKey}`;
|
|
22
|
+
}
|
|
23
|
+
static extractProjectKey(packageKey) {
|
|
24
|
+
if (!BranchUtils.isBranchPackageKey(packageKey)) {
|
|
25
|
+
return packageKey;
|
|
26
|
+
}
|
|
27
|
+
return packageKey.substring(0, packageKey.indexOf(BranchUtils.BRANCH_SEPARATOR));
|
|
28
|
+
}
|
|
20
29
|
}
|
|
21
30
|
exports.BranchUtils = BranchUtils;
|
|
31
|
+
BranchUtils.MAIN_BRANCH_KEY = "main";
|
|
22
32
|
BranchUtils.BRANCH_SEPARATOR = "@";
|
|
23
33
|
});
|
|
@@ -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,28 @@ 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
|
+
extractZipBufferToDirectory(data, targetDir) {
|
|
33
|
+
const targetPath = path.resolve(process.cwd(), targetDir);
|
|
34
|
+
this.mkdirRecursive(targetPath);
|
|
35
|
+
new AdmZip(data).extractAllTo(targetPath, true, true);
|
|
36
|
+
this.restrictFilePermissions(targetPath);
|
|
37
|
+
}
|
|
38
|
+
extractZipBufferToTempDirectory(data) {
|
|
39
|
+
const tempDir = path.join(os.tmpdir(), `content-cli-${(0, uuid_1.v4)()}`);
|
|
40
|
+
this.mkdirRecursive(tempDir);
|
|
41
|
+
new AdmZip(data).extractAllTo(tempDir, true, true);
|
|
42
|
+
this.restrictFilePermissions(tempDir);
|
|
43
|
+
return tempDir;
|
|
44
|
+
}
|
|
45
|
+
readFileToJson(fileName) {
|
|
46
|
+
const fileContent = this.readFile(fileName);
|
|
47
|
+
return JSON.parse(fileContent);
|
|
48
|
+
}
|
|
42
49
|
readFile(filename) {
|
|
43
50
|
if (!fs.existsSync(path.resolve(process.cwd(), filename))) {
|
|
44
51
|
logger_1.logger.error(new logger_1.FatalError(`The provided file '${filename}' does not exit`));
|
|
@@ -50,7 +57,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
50
57
|
return this.extractExportedZipWithNestedZipsToDir(zipFile, tempDir);
|
|
51
58
|
}
|
|
52
59
|
extractExportedZipWithNestedZipsToDir(zipFile, targetDir) {
|
|
53
|
-
|
|
60
|
+
this.mkdirRecursive(targetDir);
|
|
54
61
|
zipFile.extractAllTo(targetDir, true, true);
|
|
55
62
|
const files = fs.readdirSync(targetDir);
|
|
56
63
|
for (const file of files) {
|
|
@@ -58,7 +65,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
58
65
|
if (file.endsWith(".zip")) {
|
|
59
66
|
const nestedZip = new AdmZip(innerZipPath);
|
|
60
67
|
const nestedDir = innerZipPath.replace(/\.zip$/, "");
|
|
61
|
-
|
|
68
|
+
this.mkdirRecursive(nestedDir);
|
|
62
69
|
nestedZip.extractAllTo(nestedDir, true, true);
|
|
63
70
|
fs.rmSync(innerZipPath); // Optionally remove the inner zip
|
|
64
71
|
}
|
|
@@ -90,7 +97,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
90
97
|
}
|
|
91
98
|
});
|
|
92
99
|
const tempDir = path.join(os.tmpdir(), "content-cli-exports");
|
|
93
|
-
|
|
100
|
+
this.mkdirRecursive(tempDir);
|
|
94
101
|
const zipFilePath = path.join(tempDir, `export_${(0, uuid_1.v4)()}.zip`);
|
|
95
102
|
finalZip.writeZip(zipFilePath, () => fs.chmodSync(zipFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
96
103
|
return zipFilePath;
|
|
@@ -102,7 +109,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
102
109
|
const zip = new AdmZip();
|
|
103
110
|
zip.addLocalFolder(sourceDir);
|
|
104
111
|
const tempDir = path.join(os.tmpdir(), "content-cli-imports");
|
|
105
|
-
|
|
112
|
+
this.mkdirRecursive(tempDir);
|
|
106
113
|
const zipFilePath = path.join(tempDir, `single_package_${(0, uuid_1.v4)()}.zip`);
|
|
107
114
|
zip.writeZip(zipFilePath, () => fs.chmodSync(zipFilePath, file_constants_1.FileConstants.DEFAULT_FILE_PERMISSIONS));
|
|
108
115
|
return zipFilePath;
|
|
@@ -110,6 +117,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
110
117
|
getSerializedFileContent(data) {
|
|
111
118
|
return data;
|
|
112
119
|
}
|
|
120
|
+
mkdirRecursive(dir) {
|
|
121
|
+
fs.mkdirSync(dir, { recursive: true, mode: file_constants_1.FileConstants.DEFAULT_FOLDER_PERMISSIONS });
|
|
122
|
+
}
|
|
113
123
|
restrictFilePermissions(targetDir) {
|
|
114
124
|
var _a;
|
|
115
125
|
const files = fs.readdirSync(targetDir);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Context } from "../../core/command/cli-context";
|
|
2
|
-
import {
|
|
2
|
+
import { AssetRegistryDescriptor, AssetRegistryMetadata } from "./asset-registry.interfaces";
|
|
3
3
|
export declare class AssetRegistryApi {
|
|
4
|
-
private
|
|
4
|
+
private static readonly BASE_URL;
|
|
5
|
+
private readonly httpClient;
|
|
5
6
|
constructor(context: Context);
|
|
6
7
|
listTypes(): Promise<AssetRegistryMetadata>;
|
|
7
|
-
listSkills(): Promise<AgentSkillsResponse>;
|
|
8
8
|
getType(assetType: string): Promise<AssetRegistryDescriptor>;
|
|
9
9
|
getSchema(assetType: string): Promise<any>;
|
|
10
10
|
getExamples(assetType: string): Promise<any>;
|
|
11
11
|
validate(assetType: string, body: any): Promise<any>;
|
|
12
|
+
private static endpointUrl;
|
|
12
13
|
}
|
|
@@ -36,15 +36,3 @@ export interface ValidateOptions {
|
|
|
36
36
|
file?: string;
|
|
37
37
|
json: boolean;
|
|
38
38
|
}
|
|
39
|
-
export interface AgentSkillMetadata {
|
|
40
|
-
version: string;
|
|
41
|
-
}
|
|
42
|
-
export interface AgentSkill {
|
|
43
|
-
name: string;
|
|
44
|
-
description: string;
|
|
45
|
-
path: string;
|
|
46
|
-
metadata: AgentSkillMetadata;
|
|
47
|
-
}
|
|
48
|
-
export interface AgentSkillsResponse {
|
|
49
|
-
skills: AgentSkill[];
|
|
50
|
-
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ValidateOptions } from "./asset-registry.interfaces";
|
|
2
2
|
import { Context } from "../../core/command/cli-context";
|
|
3
3
|
export declare class AssetRegistryService {
|
|
4
|
-
private api;
|
|
4
|
+
private readonly api;
|
|
5
5
|
constructor(context: Context);
|
|
6
6
|
listTypes(jsonResponse: boolean): Promise<void>;
|
|
7
|
-
listSkills(jsonResponse: boolean): Promise<void>;
|
|
8
7
|
getType(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
9
8
|
getSchema(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
10
9
|
getExamples(assetType: string, jsonResponse: boolean): Promise<void>;
|
|
@@ -14,6 +13,5 @@ export declare class AssetRegistryService {
|
|
|
14
13
|
private parseJson;
|
|
15
14
|
private outputResponse;
|
|
16
15
|
private logDescriptorSummary;
|
|
17
|
-
private logSkillSummary;
|
|
18
16
|
private logDescriptorDetail;
|
|
19
17
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from "../../core/command/cli-context";
|
|
2
|
+
import { BookmarksExport, BookmarksImportRequest, BookmarksImportResult } from "./bookmarks.interfaces";
|
|
3
|
+
export declare class BookmarksApi {
|
|
4
|
+
private readonly httpClient;
|
|
5
|
+
constructor(context: Context);
|
|
6
|
+
exportBookmarks(packageKey: string): Promise<BookmarksExport>;
|
|
7
|
+
importBookmarks(packageKey: string, payload: BookmarksImportRequest): Promise<BookmarksImportResult>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context } from "../../core/command/cli-context";
|
|
2
|
+
export declare class BookmarksCommandService {
|
|
3
|
+
private readonly bookmarksApi;
|
|
4
|
+
constructor(context: Context);
|
|
5
|
+
exportBookmarks(packageKey: string, file?: string): Promise<void>;
|
|
6
|
+
importBookmarks(packageKey: string, file: string): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface BookmarkEntry {
|
|
2
|
+
assetKey: string;
|
|
3
|
+
assetType: string;
|
|
4
|
+
bookmark: BookmarkDetails;
|
|
5
|
+
preference: BookmarkPreference;
|
|
6
|
+
}
|
|
7
|
+
export interface BookmarkDetails {
|
|
8
|
+
name: string;
|
|
9
|
+
ownerId: string;
|
|
10
|
+
sharedByLink: boolean;
|
|
11
|
+
published: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface BookmarkPreference {
|
|
14
|
+
configuration: string;
|
|
15
|
+
shareable: boolean;
|
|
16
|
+
mode: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BookmarksExport {
|
|
20
|
+
packageKey: string;
|
|
21
|
+
entries: BookmarkEntry[];
|
|
22
|
+
}
|
|
23
|
+
export interface BookmarksImportRequest {
|
|
24
|
+
entries: BookmarkEntry[];
|
|
25
|
+
}
|
|
26
|
+
export interface BookmarksImportResultEntry {
|
|
27
|
+
assetKey: string;
|
|
28
|
+
status: string;
|
|
29
|
+
reason: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface BookmarksImportResult {
|
|
32
|
+
packageKey: string;
|
|
33
|
+
entries: BookmarksImportResultEntry[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Configurator, IModule } from "../../core/command/module-handler";
|
|
2
|
+
import { Context } from "../../core/command/cli-context";
|
|
3
|
+
declare class Module extends IModule {
|
|
4
|
+
register(context: Context, configurator: Configurator): void;
|
|
5
|
+
private exportBookmarks;
|
|
6
|
+
private importBookmarks;
|
|
7
|
+
}
|
|
8
|
+
export = Module;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context } from "../../../../core/command/cli-context";
|
|
2
|
+
import { BranchingSettingsTransport, BranchTransport, CreateBranchTransport, MergeBranchTransport, MergePreviewRequestTransport, MergePreviewTransport, PackageVersionCreatedTransport } from "../interfaces/branch.interfaces";
|
|
3
|
+
export declare class BranchApi {
|
|
4
|
+
private readonly httpClient;
|
|
5
|
+
constructor(context: Context);
|
|
6
|
+
configureBranchingSettings(packageKey: string, transport: BranchingSettingsTransport): Promise<BranchingSettingsTransport>;
|
|
7
|
+
createBranch(packageKey: string, transport: CreateBranchTransport, validate?: boolean): Promise<BranchTransport | void>;
|
|
8
|
+
listBranches(packageKey: string): Promise<BranchTransport[]>;
|
|
9
|
+
mergePreview(packageKey: string, transport: MergePreviewRequestTransport): Promise<MergePreviewTransport>;
|
|
10
|
+
merge(packageKey: string, transport: MergeBranchTransport): Promise<PackageVersionCreatedTransport>;
|
|
11
|
+
deleteBranch(branchPackageKey: string): Promise<void>;
|
|
12
|
+
}
|
package/lib/commands/configuration-management/branch/branch-export-import.command.service.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context } from "../../../core/command/cli-context";
|
|
2
|
+
export interface BranchExportOptions {
|
|
3
|
+
zip?: boolean;
|
|
4
|
+
gitEnabled?: boolean;
|
|
5
|
+
jsonResponse?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface BranchImportOptions {
|
|
8
|
+
file?: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
overwrite?: boolean;
|
|
11
|
+
gitEnabled?: boolean;
|
|
12
|
+
jsonResponse?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class BranchExportImportCommandService {
|
|
15
|
+
private readonly singlePackageExportApi;
|
|
16
|
+
private readonly singlePackageImportApi;
|
|
17
|
+
private readonly branchApi;
|
|
18
|
+
private readonly gitService;
|
|
19
|
+
constructor(context: Context);
|
|
20
|
+
exportBranch(packageKey: string, branchKey: string, options?: BranchExportOptions): Promise<void>;
|
|
21
|
+
exportAll(packageKey: string, jsonResponse?: boolean): Promise<void>;
|
|
22
|
+
importBranch(packageKey: string, branchKey: string, options?: BranchImportOptions): Promise<void>;
|
|
23
|
+
private pushBranchToGit;
|
|
24
|
+
private pushMainPackage;
|
|
25
|
+
private exportRewrittenPackageDir;
|
|
26
|
+
private writeLocalArtifact;
|
|
27
|
+
private prepareLocalWorkingDir;
|
|
28
|
+
private importPackageSourceDir;
|
|
29
|
+
private normalizeToProjectKey;
|
|
30
|
+
private restoreBranchKey;
|
|
31
|
+
private replaceFieldValue;
|
|
32
|
+
private escapeRegExp;
|
|
33
|
+
private removeDir;
|
|
34
|
+
private static isExportableBranch;
|
|
35
|
+
private static writeJson;
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Context } from "../../../core/command/cli-context";
|
|
2
|
+
import { BranchTransport, BranchingSettingsTransport, MergeApplyOptions, MergePreviewTransport, PackageVersionCreatedTransport } from "./interfaces/branch.interfaces";
|
|
3
|
+
export declare class BranchCommandService {
|
|
4
|
+
private readonly branchApi;
|
|
5
|
+
constructor(context: Context);
|
|
6
|
+
setBranchingEnabled(packageKey: string, enabled: boolean, jsonResponse: boolean): Promise<BranchingSettingsTransport>;
|
|
7
|
+
createBranch(packageKey: string, branchKey: string, sourceVersion: string, validate: boolean, jsonResponse: boolean): Promise<BranchTransport | void>;
|
|
8
|
+
listBranches(packageKey: string, jsonResponse: boolean): Promise<BranchTransport[]>;
|
|
9
|
+
deleteBranch(packageKey: string, branchKey: string): Promise<void>;
|
|
10
|
+
mergePreview(targetPackageKey: string, sourceKey: string, sourceVersion: string, jsonResponse: boolean): Promise<MergePreviewTransport>;
|
|
11
|
+
mergeApply(targetPackageKey: string, options: MergeApplyOptions): Promise<PackageVersionCreatedTransport>;
|
|
12
|
+
private static buildVersionCreate;
|
|
13
|
+
private static writeJson;
|
|
14
|
+
private static printBranch;
|
|
15
|
+
private static printPreviewSummary;
|
|
16
|
+
private static countConflictPaths;
|
|
17
|
+
private static isInConflict;
|
|
18
|
+
}
|