@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
|
@@ -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", "./branch/branch.command.service", "./branch/branch-export-import.command.service", "../../core/utils/branches"], factory);
|
|
20
20
|
}
|
|
21
21
|
})(function (require, exports) {
|
|
22
22
|
"use strict";
|
|
@@ -32,10 +32,81 @@ 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");
|
|
36
|
+
const branch_command_service_1 = require("./branch/branch.command.service");
|
|
37
|
+
const branch_export_import_command_service_1 = require("./branch/branch-export-import.command.service");
|
|
38
|
+
const branches_1 = require("../../core/utils/branches");
|
|
35
39
|
class Module extends module_handler_1.IModule {
|
|
36
40
|
register(context, configurator) {
|
|
37
41
|
const configCommand = configurator.command("config")
|
|
38
42
|
.description("Manage package configurations and their resources (package, nodes, versions, variables, metadata). Note: 'config list/export/import/diff' are deprecated — bulk Team-to-Team Copy operations have moved to the 't2tc package' group, and single-package operations live under 'config package'.");
|
|
43
|
+
const branchCommand = configCommand.command("branch").beta()
|
|
44
|
+
.description("Author, merge, and mirror package branches");
|
|
45
|
+
const branchSettingsCommand = branchCommand.command("settings").beta()
|
|
46
|
+
.description("Commands to manage branch settings on a package");
|
|
47
|
+
branchSettingsCommand.command("set").beta()
|
|
48
|
+
.description("Configure branch settings on a main package")
|
|
49
|
+
.requiredOption("--packageKey <packageKey>", "Main package key")
|
|
50
|
+
.requiredOption("--enabled <enabled>", "true|false")
|
|
51
|
+
.option("--json", "Write response to a JSON file", false)
|
|
52
|
+
.action(this.setBranchSettings);
|
|
53
|
+
branchCommand.command("create").beta()
|
|
54
|
+
.description("Create a new branch from a source version")
|
|
55
|
+
.requiredOption("--packageKey <packageKey>", "Main package key to branch from")
|
|
56
|
+
.requiredOption("--branchKey <branchKey>", "New branch key")
|
|
57
|
+
.requiredOption("--sourceVersion <sourceVersion>", "Source version to branch from. Must be an existing version; 'LATEST' is not supported here")
|
|
58
|
+
.option("--validate", "Only validate the request without creating the branch", false)
|
|
59
|
+
.option("--json", "Write response to a JSON file", false)
|
|
60
|
+
.action(this.createBranch);
|
|
61
|
+
branchCommand.command("list").beta()
|
|
62
|
+
.description("List branches of a main package")
|
|
63
|
+
.requiredOption("--packageKey <packageKey>", "Main package key")
|
|
64
|
+
.option("--json", "Write response to a JSON file", false)
|
|
65
|
+
.action(this.listBranches);
|
|
66
|
+
branchCommand.command("delete").beta()
|
|
67
|
+
.description("Delete a branch")
|
|
68
|
+
.requiredOption("--packageKey <packageKey>", "Main package key (no '@')")
|
|
69
|
+
.requiredOption("--branchKey <branchKey>", "Branch key to delete")
|
|
70
|
+
.action(this.deleteBranch);
|
|
71
|
+
const branchMergeCommand = branchCommand.command("merge").beta()
|
|
72
|
+
.description("Commands to preview and apply branch merges");
|
|
73
|
+
branchMergeCommand.command("preview").beta()
|
|
74
|
+
.description("Preview the changes a merge would apply to a target branch")
|
|
75
|
+
.requiredOption("--packageKey <packageKey>", "Target package key (main package key or '<mainPackageKey>@<branchKey>')")
|
|
76
|
+
.requiredOption("--sourceKey <sourceKey>", "Source package key (main package key or '<mainPackageKey>@<branchKey>')")
|
|
77
|
+
.requiredOption("--sourceVersion <sourceVersion>", "Source version (or 'LATEST')")
|
|
78
|
+
.option("--json", "Write response to a JSON file", false)
|
|
79
|
+
.action(this.previewBranchMerge);
|
|
80
|
+
branchMergeCommand.command("apply").beta()
|
|
81
|
+
.description("Merge changes from a source into a target branch")
|
|
82
|
+
.requiredOption("--packageKey <packageKey>", "Target package key (main package key or '<mainPackageKey>@<branchKey>')")
|
|
83
|
+
.option("-f, --file <file>", "Path to a JSON file containing the MergeBranchTransport payload")
|
|
84
|
+
.option("--sourceKey <sourceKey>", "Source package key, main package key or '<mainPackageKey>@<branchKey>' (overrides the file's 'sourceKey')")
|
|
85
|
+
.option("--sourceVersion <sourceVersion>", "Source version (overrides the file's 'sourceVersion'; or 'LATEST')")
|
|
86
|
+
.option("--bump <bump>", "Version bump for the new published version: PATCH (the default when neither --bump nor --newVersion is given)")
|
|
87
|
+
.option("--newVersion <newVersion>", "Pin the new published version to an explicit semver")
|
|
88
|
+
.option("--summary <summary>", "Summary of changes for the new published version")
|
|
89
|
+
.option("--json", "Write response to a JSON file", false)
|
|
90
|
+
.action(this.applyBranchMerge);
|
|
91
|
+
branchCommand.command("export").beta()
|
|
92
|
+
.description("Export a branch's package, rewriting the package.json key to the main package key. Writes an unzipped '<packageKey>' directory by default (or a '<packageKey>.zip' with --zip), or pushes to the Git branch named after --branchKey when --gitProfile is set.")
|
|
93
|
+
.requiredOption("--packageKey <packageKey>", "Main package key (no '@')")
|
|
94
|
+
.option("--branchKey <branchKey>", "Branch key to export. The Git branch, when pushing, is named after this value. Mutually exclusive with --all")
|
|
95
|
+
.option("--all", "Push the main package and every one of its branches to Git. Requires --gitProfile and is mutually exclusive with --branchKey", false)
|
|
96
|
+
.option("--zip", "Export the branch as a single '<packageKey>.zip' file instead of an unzipped directory (local export only)", false)
|
|
97
|
+
.option("--gitProfile <gitProfile>", "Git profile to use. When set, the export is pushed to Git instead of written locally")
|
|
98
|
+
.option("--json", "Write response to a JSON file", false)
|
|
99
|
+
.action(this.exportBranch);
|
|
100
|
+
branchCommand.command("import").beta()
|
|
101
|
+
.description("Import a branch's package from a zip file, directory, or Git branch, restoring the package.json key to '<packageKey>@<branchKey>'. Pulls the Git branch named after --branchKey when --gitProfile is set; otherwise reads --file or --directory.")
|
|
102
|
+
.requiredOption("--packageKey <packageKey>", "Main package key (no '@')")
|
|
103
|
+
.requiredOption("--branchKey <branchKey>", "Branch key to import into. The Git branch, when pulling, is named after this value")
|
|
104
|
+
.option("-f, --file <file>", "Package zip file (relative path). Mutually exclusive with --directory and --gitProfile")
|
|
105
|
+
.option("-d, --directory <directory>", "Package directory (relative path). Mutually exclusive with --file and --gitProfile")
|
|
106
|
+
.option("--overwrite", "Flag to allow overwriting an existing package with the same key", false)
|
|
107
|
+
.option("--gitProfile <gitProfile>", "Git profile to use. When set, the package is pulled from Git instead of read locally")
|
|
108
|
+
.option("--json", "Write response to a JSON file", false)
|
|
109
|
+
.action(this.importBranch);
|
|
39
110
|
configCommand.command("list")
|
|
40
111
|
.description("[Deprecated] Use 't2tc package list' instead. List packages in the target team.")
|
|
41
112
|
.deprecationNotice("'config list' is deprecated and will be removed in a future release. Use 't2tc package list' instead.")
|
|
@@ -80,16 +151,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
80
151
|
const packageCommand = configCommand.command("package")
|
|
81
152
|
.description("Commands for working with a single package.");
|
|
82
153
|
packageCommand.command("import")
|
|
83
|
-
.description("Import a package from a zip file or
|
|
154
|
+
.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
155
|
.option("-f, --file <file>", "Package zip file (relative path)")
|
|
85
156
|
.option("-d, --directory <directory>", "Package directory (relative path)")
|
|
86
157
|
.option("--overwrite", "Flag to allow overwriting an existing package with the same key")
|
|
87
158
|
.option("--json", "Return the response as a JSON file")
|
|
159
|
+
.option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
160
|
+
.option("--gitBranch <gitBranch>", "Git branch from which you want to pull the package and import")
|
|
88
161
|
.action(this.importSinglePackage);
|
|
162
|
+
packageCommand.command("export")
|
|
163
|
+
.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.")
|
|
164
|
+
.requiredOption("--packageKey <packageKey>", "Key of the package to export")
|
|
165
|
+
.option("--zip", "Export the package as a single <packageKey>.zip file instead of an unzipped <packageKey> directory", false)
|
|
166
|
+
.option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
167
|
+
.option("--gitBranch <gitBranch>", "Git branch in which you want to push the exported package")
|
|
168
|
+
.action(this.exportSinglePackage);
|
|
89
169
|
packageCommand.command("validate")
|
|
90
170
|
.description("Validate package node configurations")
|
|
91
171
|
.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"])
|
|
172
|
+
.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
173
|
.option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
|
|
94
174
|
.option("--json", "Return the response as a JSON file")
|
|
95
175
|
.action(this.validatePackage);
|
|
@@ -102,7 +182,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
102
182
|
.description("[Deprecated] Use 'config package validate' instead. Validate package node configurations.")
|
|
103
183
|
.deprecationNotice("'config validate' is deprecated and will be removed in a future release. Use 'config package validate' instead.")
|
|
104
184
|
.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"])
|
|
185
|
+
.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
186
|
.option("--nodeKeys <nodeKeys...>", "Specific node keys to validate (default: all nodes)")
|
|
107
187
|
.option("--json", "Return the response as a JSON file")
|
|
108
188
|
.action(this.validatePackage);
|
|
@@ -208,6 +288,99 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
208
288
|
.option("--params <params>", "Variable query params")
|
|
209
289
|
.action(this.listAssignments);
|
|
210
290
|
}
|
|
291
|
+
setBranchSettings(context, command, options) {
|
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
const enabled = String(options.enabled).toLowerCase();
|
|
294
|
+
if (enabled !== "true" && enabled !== "false") {
|
|
295
|
+
throw new Error("Please provide either 'true' or 'false' for --enabled.");
|
|
296
|
+
}
|
|
297
|
+
yield new branch_command_service_1.BranchCommandService(context).setBranchingEnabled(options.packageKey, enabled === "true", !!options.json);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
createBranch(context, command, options) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
yield new branch_command_service_1.BranchCommandService(context).createBranch(options.packageKey, options.branchKey, options.sourceVersion, !!options.validate, !!options.json);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
listBranches(context, command, options) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
yield new branch_command_service_1.BranchCommandService(context).listBranches(options.packageKey, !!options.json);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
deleteBranch(context, command, options) {
|
|
311
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
+
yield new branch_command_service_1.BranchCommandService(context).deleteBranch(options.packageKey, options.branchKey);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
previewBranchMerge(context, command, options) {
|
|
316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
+
yield new branch_command_service_1.BranchCommandService(context).mergePreview(options.packageKey, options.sourceKey, options.sourceVersion, !!options.json);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
applyBranchMerge(context, command, options) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
322
|
+
yield new branch_command_service_1.BranchCommandService(context).mergeApply(options.packageKey, {
|
|
323
|
+
sourceKey: options.sourceKey,
|
|
324
|
+
sourceVersion: options.sourceVersion,
|
|
325
|
+
file: options.file,
|
|
326
|
+
bump: options.bump,
|
|
327
|
+
version: options.newVersion,
|
|
328
|
+
summary: options.summary,
|
|
329
|
+
jsonResponse: !!options.json,
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
exportBranch(context, command, options) {
|
|
334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
335
|
+
const gitEnabled = !!options.gitProfile;
|
|
336
|
+
const service = new branch_export_import_command_service_1.BranchExportImportCommandService(context);
|
|
337
|
+
if (options.all) {
|
|
338
|
+
if (options.branchKey) {
|
|
339
|
+
throw new Error("Please provide either --branchKey or --all, but not both.");
|
|
340
|
+
}
|
|
341
|
+
if (!gitEnabled) {
|
|
342
|
+
throw new Error("--all pushes to Git and requires a Git profile. Please provide --gitProfile.");
|
|
343
|
+
}
|
|
344
|
+
yield service.exportAll(options.packageKey, !!options.json);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (!options.branchKey) {
|
|
348
|
+
throw new Error("Please provide --branchKey, or use --all to export every branch.");
|
|
349
|
+
}
|
|
350
|
+
if (options.branchKey.toLowerCase() === branches_1.BranchUtils.MAIN_BRANCH_KEY) {
|
|
351
|
+
throw new Error(`'${branches_1.BranchUtils.MAIN_BRANCH_KEY}' is a reserved branch key. The main package is exported only with --all.`);
|
|
352
|
+
}
|
|
353
|
+
yield service.exportBranch(options.packageKey, options.branchKey, {
|
|
354
|
+
zip: !!options.zip,
|
|
355
|
+
gitEnabled,
|
|
356
|
+
jsonResponse: !!options.json,
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
importBranch(context, command, options) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
const gitEnabled = !!options.gitProfile;
|
|
363
|
+
if (options.branchKey.toLowerCase() === branches_1.BranchUtils.MAIN_BRANCH_KEY) {
|
|
364
|
+
throw new Error(`'${branches_1.BranchUtils.MAIN_BRANCH_KEY}' is a reserved branch key. Use 'config package import' to import into the main package.`);
|
|
365
|
+
}
|
|
366
|
+
if (gitEnabled && (options.file || options.directory)) {
|
|
367
|
+
throw new Error("You cannot use --file or --directory together with --gitProfile. Only one import source can be defined.");
|
|
368
|
+
}
|
|
369
|
+
if (!gitEnabled && !options.file && !options.directory) {
|
|
370
|
+
throw new Error("You must provide a --file, a --directory, or a --gitProfile option to import a branch.");
|
|
371
|
+
}
|
|
372
|
+
if (options.file && options.directory) {
|
|
373
|
+
throw new Error("You cannot use both --file and --directory options at the same time. Only one import source can be defined.");
|
|
374
|
+
}
|
|
375
|
+
yield new branch_export_import_command_service_1.BranchExportImportCommandService(context).importBranch(options.packageKey, options.branchKey, {
|
|
376
|
+
file: options.file,
|
|
377
|
+
directory: options.directory,
|
|
378
|
+
overwrite: !!options.overwrite,
|
|
379
|
+
gitEnabled,
|
|
380
|
+
jsonResponse: !!options.json,
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
211
384
|
listPackages(context, command, options) {
|
|
212
385
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
386
|
if (options.staging && (options.withDependencies || options.packageKeys || options.keysByVersion || options.variableValue || options.variableType)) {
|
|
@@ -271,7 +444,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
271
444
|
}
|
|
272
445
|
importSinglePackage(context, command, options) {
|
|
273
446
|
return __awaiter(this, void 0, void 0, function* () {
|
|
274
|
-
|
|
447
|
+
if (options.gitProfile && !options.gitBranch) {
|
|
448
|
+
throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
|
|
449
|
+
}
|
|
450
|
+
yield new single_package_import_service_1.SinglePackageImportService(context).importPackage(options.file, options.directory, options.overwrite, options.json, options.gitBranch);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
exportSinglePackage(context, command, options) {
|
|
454
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
455
|
+
if (options.gitProfile && !options.gitBranch) {
|
|
456
|
+
throw new Error("Please specify a branch using --gitBranch when using a Git profile.");
|
|
457
|
+
}
|
|
458
|
+
yield new single_package_export_service_1.SinglePackageExportService(context).exportPackage(options.packageKey, options.zip, options.gitBranch);
|
|
275
459
|
});
|
|
276
460
|
}
|
|
277
461
|
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 = SinglePackageImportService.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.");
|
|
@@ -65,19 +85,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
65
85
|
}
|
|
66
86
|
return { zipPath: file_service_1.fileService.zipDirectoryAsSinglePackage(directory), isTemporary: true };
|
|
67
87
|
}
|
|
68
|
-
buildBodyForImport(packageZip, sourcePath) {
|
|
69
|
-
|
|
88
|
+
static buildBodyForImport(packageZip, sourcePath) {
|
|
89
|
+
SinglePackageImportService.assertUncompressedSizeWithinLimit(packageZip, sourcePath);
|
|
70
90
|
const formData = new FormData();
|
|
71
|
-
formData.append("packageFile",
|
|
91
|
+
formData.append("packageFile", SinglePackageImportService.getReadableStream(packageZip), { filename: "package.zip" });
|
|
72
92
|
return formData;
|
|
73
93
|
}
|
|
74
|
-
assertUncompressedSizeWithinLimit(packageZip, sourcePath) {
|
|
94
|
+
static assertUncompressedSizeWithinLimit(packageZip, sourcePath) {
|
|
75
95
|
const totalUncompressedBytes = packageZip.getEntries().reduce((sum, entry) => sum + entry.header.size, 0);
|
|
76
96
|
if (totalUncompressedBytes > SinglePackageImportService.MAX_UNCOMPRESSED_ZIP_SIZE) {
|
|
77
97
|
throw new Error(`Failed to handle zip file "${sourcePath}": uncompressed size ${(totalUncompressedBytes / (Math.pow(1024, 3))).toFixed(2)} GB exceeds the 4 GB limit.`);
|
|
78
98
|
}
|
|
79
99
|
}
|
|
80
|
-
getReadableStream(packageZip) {
|
|
100
|
+
static getReadableStream(packageZip) {
|
|
81
101
|
return new node_stream_1.Readable({
|
|
82
102
|
read() {
|
|
83
103
|
this.push(packageZip.toBuffer());
|
|
@@ -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 => {
|
|
@@ -30,13 +30,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
30
30
|
.description("Command to list all connections in a Data Pool")
|
|
31
31
|
.requiredOption("--dataPoolId <dataPoolId>", "ID of the data pool")
|
|
32
32
|
.action(this.listConnections);
|
|
33
|
-
const getCommand = configurator.command("get")
|
|
33
|
+
const getCommand = configurator.command("get")
|
|
34
|
+
.description("get data pool connection");
|
|
34
35
|
getCommand.command("connection")
|
|
35
36
|
.description("Programmatically read properties of your connections")
|
|
36
37
|
.requiredOption("--dataPoolId <dataPoolId>", "Id of the data pool you want to update")
|
|
37
38
|
.requiredOption("--connectionId <connectionId>", "Id of the connection you want to update")
|
|
38
39
|
.action(this.getCommandProperties);
|
|
39
|
-
const setCommand = configurator.command("set")
|
|
40
|
+
const setCommand = configurator.command("set")
|
|
41
|
+
.description("set data pool connection");
|
|
40
42
|
setCommand.command("connection")
|
|
41
43
|
.description("Programmatically update properties of your connections")
|
|
42
44
|
.requiredOption("--dataPoolId <dataPoolId>", "Id of the data pool you want to update")
|
|
@@ -52,7 +52,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
52
52
|
pushCommand.command("data-pools")
|
|
53
53
|
.description("Command to push data pools")
|
|
54
54
|
.action(this.pushDataPools);
|
|
55
|
-
const updateCommand = configurator.command("update")
|
|
55
|
+
const updateCommand = configurator.command("update")
|
|
56
|
+
.description("Update data pool");
|
|
56
57
|
updateCommand.command("data-pool")
|
|
57
58
|
.description("Command to update a data pool using a data pool configuration file")
|
|
58
59
|
.requiredOption("--id <id>", "Id of the data pool you want to update")
|
|
@@ -21,9 +21,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
const deployment_service_1 = require("./deployment.service");
|
|
22
22
|
class Module extends module_handler_1.IModule {
|
|
23
23
|
register(context, configurator) {
|
|
24
|
-
const deploymentCommand = configurator.command("deployment")
|
|
24
|
+
const deploymentCommand = configurator.command("deployment")
|
|
25
|
+
.description("Create deployments, list their history, check active deployments, and retrieve deployables and targets");
|
|
25
26
|
deploymentCommand.command("create")
|
|
26
|
-
.beta()
|
|
27
27
|
.description("Create a new deployment")
|
|
28
28
|
.requiredOption("--packageKey <packageKey>", "Identifier of the package to deploy")
|
|
29
29
|
.requiredOption("--packageVersion <packageVersion>", "Version of the package to deploy")
|
|
@@ -31,9 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
.requiredOption("--targetId <targetId>", "Identifier of the target to deploy to")
|
|
32
32
|
.option("--json", "Return the response as a JSON file")
|
|
33
33
|
.action(this.createDeployment);
|
|
34
|
-
const listCommand = deploymentCommand.command("list")
|
|
34
|
+
const listCommand = deploymentCommand.command("list")
|
|
35
|
+
.description("List deployment history, active deployments, deployables or targets");
|
|
35
36
|
listCommand.command("history")
|
|
36
|
-
.beta()
|
|
37
37
|
.description("List deployment history")
|
|
38
38
|
.option("--packageKey <packageKey>", "Filter deployment history by package key")
|
|
39
39
|
.option("--targetId <targetId>", "Filter deployment history by target ID")
|
|
@@ -45,7 +45,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
45
45
|
.option("--json", "Return the response as a JSON file")
|
|
46
46
|
.action(this.listDeploymentHistory);
|
|
47
47
|
listCommand.command("active")
|
|
48
|
-
.beta()
|
|
49
48
|
.description("Get the active deployment(s) for a given target or package.\n" +
|
|
50
49
|
"You can use the command to list the active deployment(s) for a specific target or for a specific package.\n" +
|
|
51
50
|
"The targetIds filter is available only for getting the active deployments for a given package. \n" +
|
|
@@ -58,13 +57,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
58
57
|
.option("--json", "Return the response as a JSON file")
|
|
59
58
|
.action(this.listActiveDeployments);
|
|
60
59
|
listCommand.command("deployables")
|
|
61
|
-
.beta()
|
|
62
60
|
.description("List all deployables")
|
|
63
61
|
.option("--flavor <flavor>", "Filter deployables by flavor")
|
|
64
62
|
.option("--json", "Return the response as a JSON file")
|
|
65
63
|
.action(this.listDeployables);
|
|
66
64
|
listCommand.command("targets")
|
|
67
|
-
.beta()
|
|
68
65
|
.description("List all targets for a given deployable type and package key")
|
|
69
66
|
.requiredOption("--deployableType <deployableType>", "The type of the deployable")
|
|
70
67
|
.requiredOption("--packageKey <packageKey>", "Identifier of the package to list targets for")
|
|
@@ -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", "")
|