@celonis/content-cli 1.1.0 → 1.1.2
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/configuration-management/batch-import-export.service.js +26 -12
- package/commands/configuration-management/config-command.service.js +20 -9
- package/commands/configuration-management/module.js +4 -2
- package/core/command/module-handler.js +3 -1
- package/core/utils/file-service.js +15 -7
- package/lib/commands/configuration-management/batch-import-export.service.d.ts +3 -2
- package/lib/commands/configuration-management/config-command.service.d.ts +2 -2
- package/lib/core/utils/file-service.d.ts +3 -1
- package/package.json +1 -1
|
@@ -60,7 +60,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
60
60
|
this.exportListOfPackages(packagesToExport);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch) {
|
|
63
|
+
batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch, unzip) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
let exportedPackagesData;
|
|
66
66
|
if (packageKeys) {
|
|
@@ -93,12 +93,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
93
93
|
const extractedDirectory = file_service_1.fileService.extractExportedZipWithNestedZips(exportedPackagesZip);
|
|
94
94
|
yield this.gitService.pushToBranch(extractedDirectory, gitBranch);
|
|
95
95
|
logger_1.logger.info("Successfully exported packages to branch: " + gitBranch);
|
|
96
|
+
fs.rmSync(extractedDirectory, { recursive: true });
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
|
|
99
|
-
const filename = `export_${(0, uuid_1.v4)()}.zip`;
|
|
100
|
-
exportedPackagesZip.writeZip(filename);
|
|
101
|
-
logger_1.logger.info(fileDownloadedMessage + filename);
|
|
99
|
+
this.downloadZip(exportedPackagesZip, unzip);
|
|
102
100
|
}
|
|
103
101
|
});
|
|
104
102
|
}
|
|
@@ -115,17 +113,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
115
113
|
}
|
|
116
114
|
});
|
|
117
115
|
}
|
|
118
|
-
batchImportPackages(
|
|
116
|
+
batchImportPackages(sourcePath, overwrite, gitBranch) {
|
|
119
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
let
|
|
118
|
+
let sourceToBeImported;
|
|
121
119
|
if (gitBranch) {
|
|
122
|
-
|
|
123
|
-
fileToBeImported = file_service_1.fileService.zipDirectoryInBatchExportFormat(fileToBeImported);
|
|
120
|
+
sourceToBeImported = yield this.gitService.pullFromBranch(gitBranch);
|
|
124
121
|
}
|
|
125
122
|
else {
|
|
126
|
-
|
|
123
|
+
sourceToBeImported = sourcePath;
|
|
124
|
+
if (file_service_1.fileService.isDirectory(sourcePath)) {
|
|
125
|
+
sourceToBeImported = file_service_1.fileService.zipDirectoryInBatchExportFormat(sourceToBeImported);
|
|
126
|
+
}
|
|
127
127
|
}
|
|
128
|
-
let configs = new AdmZip(
|
|
128
|
+
let configs = new AdmZip(sourceToBeImported);
|
|
129
129
|
const studioManifests = this.parseEntryData(configs, batch_export_import_constants_1.BatchExportImportConstants.STUDIO_FILE_NAME);
|
|
130
130
|
const variablesManifests = this.parseEntryData(configs, batch_export_import_constants_1.BatchExportImportConstants.VARIABLES_FILE_NAME);
|
|
131
131
|
configs = yield this.studioService.mapSpaces(configs, studioManifests);
|
|
@@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
134
134
|
const postPackageImportData = yield this.batchImportExportApi.importPackages(formData, overwrite);
|
|
135
135
|
yield this.studioService.processImportedPackages(configs, existingStudioPackages, studioManifests);
|
|
136
136
|
if (gitBranch) {
|
|
137
|
-
fs.rmSync(
|
|
137
|
+
fs.rmSync(sourceToBeImported);
|
|
138
138
|
}
|
|
139
139
|
const reportFileName = "config_import_report_" + (0, uuid_1.v4)() + ".json";
|
|
140
140
|
file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(postPackageImportData), reportFileName);
|
|
@@ -211,6 +211,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
211
211
|
}
|
|
212
212
|
return null;
|
|
213
213
|
}
|
|
214
|
+
downloadZip(exportedZip, unzip) {
|
|
215
|
+
if (unzip) {
|
|
216
|
+
const fileDownloadedMessage = "Successful download. Downloaded directory: ";
|
|
217
|
+
const targetDirectoryName = `export_${(0, uuid_1.v4)()}`;
|
|
218
|
+
file_service_1.fileService.extractExportedZipWithNestedZipsToDir(exportedZip, targetDirectoryName);
|
|
219
|
+
logger_1.logger.info(fileDownloadedMessage + targetDirectoryName);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
223
|
+
const filename = `export_${(0, uuid_1.v4)()}.zip`;
|
|
224
|
+
exportedZip.writeZip(filename);
|
|
225
|
+
logger_1.logger.info(fileDownloadedMessage + filename);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
214
228
|
}
|
|
215
229
|
exports.BatchImportExportService = BatchImportExportService;
|
|
216
230
|
});
|
|
@@ -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", "./batch-import-export.service", "./variable.service", "./diff.service"], factory);
|
|
16
|
+
define(["require", "exports", "./batch-import-export.service", "./variable.service", "./diff.service", "../../core/utils/file-service"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -22,6 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
const batch_import_export_service_1 = require("./batch-import-export.service");
|
|
23
23
|
const variable_service_1 = require("./variable.service");
|
|
24
24
|
const diff_service_1 = require("./diff.service");
|
|
25
|
+
const file_service_1 = require("../../core/utils/file-service");
|
|
25
26
|
class ConfigCommandService {
|
|
26
27
|
constructor(context) {
|
|
27
28
|
this.batchImportExportService = new batch_import_export_service_1.BatchImportExportService(context);
|
|
@@ -52,20 +53,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch) {
|
|
56
|
-
return this.batchImportExportService.batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch);
|
|
56
|
+
batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch, unzip) {
|
|
57
|
+
return this.batchImportExportService.batchExportPackages(packageKeys, packageKeysByVersion, withDependencies, gitBranch, unzip);
|
|
57
58
|
}
|
|
58
59
|
batchExportPackagesMetadata(packageKeys, jsonResponse) {
|
|
59
60
|
return this.batchImportExportService.batchExportPackagesMetadata(packageKeys, jsonResponse);
|
|
60
61
|
}
|
|
61
|
-
batchImportPackages(file, overwrite, gitBranch) {
|
|
62
|
-
if (file && gitBranch) {
|
|
63
|
-
throw new Error("You cannot use both file and gitBranch options at the same time. Only one import source can be defined.");
|
|
62
|
+
batchImportPackages(file, directory, overwrite, gitBranch) {
|
|
63
|
+
if ((directory || file) && gitBranch) {
|
|
64
|
+
throw new Error("You cannot use both file/directory and gitBranch options at the same time. Only one import source can be defined.");
|
|
64
65
|
}
|
|
65
|
-
if (!file && !gitBranch) {
|
|
66
|
-
throw new Error("You must provide either a file or a gitBranch option to import packages.");
|
|
66
|
+
if (!directory && !file && !gitBranch) {
|
|
67
|
+
throw new Error("You must provide either a file/directory or a gitBranch option to import packages.");
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
if (file && directory) {
|
|
70
|
+
throw new Error("You cannot use both file and directory options at the same time. Only one import source can be defined.");
|
|
71
|
+
}
|
|
72
|
+
if (file && file_service_1.fileService.isDirectory(file)) {
|
|
73
|
+
throw new Error("The file option accepts only zip files.");
|
|
74
|
+
}
|
|
75
|
+
if (directory && !file_service_1.fileService.isDirectory(directory)) {
|
|
76
|
+
throw new Error("The directory option accepts only directories.");
|
|
77
|
+
}
|
|
78
|
+
const sourcePath = file !== null && file !== void 0 ? file : directory;
|
|
79
|
+
return this.batchImportExportService.batchImportPackages(sourcePath, overwrite, gitBranch);
|
|
69
80
|
}
|
|
70
81
|
diffPackages(file, hasChanges, jsonResponse) {
|
|
71
82
|
return this.diffService.diffPackages(file, hasChanges, jsonResponse);
|
|
@@ -40,6 +40,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
40
|
.option("--packageKeys <packageKeys...>", "Keys of packages to export. Exports the latest deployed version only")
|
|
41
41
|
.option("--keysByVersion <keysByVersion...>", "Keys of packages to export by version")
|
|
42
42
|
.option("--withDependencies", "Include variables and dependencies", "")
|
|
43
|
+
.option("--unzip", "Unzip the exported file", "")
|
|
43
44
|
.betaOption("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
44
45
|
.betaOption("--gitBranch <gitBranch>", "Git branch in which you want to push the exported file")
|
|
45
46
|
.action(this.batchExportPackages);
|
|
@@ -57,6 +58,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
57
58
|
.betaOption("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
|
|
58
59
|
.betaOption("--gitBranch <gitBranch>", "Git branch from which you want to pull the exported file and import")
|
|
59
60
|
.option("-f, --file <file>", "Exported packages file (relative path)")
|
|
61
|
+
.option("-d, --directory <directory>", "Exported packages directory (relative path)")
|
|
60
62
|
.action(this.batchImportPackages);
|
|
61
63
|
configCommand.command("diff")
|
|
62
64
|
.description("Command to diff configs of packages")
|
|
@@ -92,7 +94,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
92
94
|
throw new Error("Please provide either --packageKeys or --keysByVersion, but not both.");
|
|
93
95
|
}
|
|
94
96
|
options.withDependencies = (_a = options.withDependencies) !== null && _a !== void 0 ? _a : false;
|
|
95
|
-
yield new config_command_service_1.ConfigCommandService(context).batchExportPackages(options.packageKeys, options.keysByVersion, options.withDependencies, options.gitBranch);
|
|
97
|
+
yield new config_command_service_1.ConfigCommandService(context).batchExportPackages(options.packageKeys, options.keysByVersion, options.withDependencies, options.gitBranch, options.unzip);
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
batchExportPackagesMetadata(context, command, options) {
|
|
@@ -102,7 +104,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
102
104
|
}
|
|
103
105
|
batchImportPackages(context, command, options) {
|
|
104
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
yield new config_command_service_1.ConfigCommandService(context).batchImportPackages(options.file, options.overwrite, options.gitBranch);
|
|
107
|
+
yield new config_command_service_1.ConfigCommandService(context).batchImportPackages(options.file, options.directory, options.overwrite, options.gitBranch);
|
|
106
108
|
});
|
|
107
109
|
}
|
|
108
110
|
diffPackages(context, command, options) {
|
|
@@ -218,8 +218,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
218
218
|
if (this.cmd.isBeta) {
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
+
const providedOptions = this.cmd.opts();
|
|
221
222
|
for (const option of this.cmd.options) {
|
|
222
|
-
|
|
223
|
+
const optionName = option.attributeName();
|
|
224
|
+
if (option.isBeta && Object.hasOwn(providedOptions, optionName)) {
|
|
223
225
|
logger_1.logger.info(chalk.yellow(`The option '${option.long}' is in beta and may change in future releases.`));
|
|
224
226
|
}
|
|
225
227
|
}
|
|
@@ -31,9 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
encoding: "utf-8",
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
createDirectoryWithGivenName(dirName) {
|
|
35
|
-
fs.mkdirSync(path.resolve(process.cwd(), dirName));
|
|
36
|
-
}
|
|
37
34
|
readFileToJson(fileName) {
|
|
38
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
36
|
const fileContent = this.readFile(fileName);
|
|
@@ -49,10 +46,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
49
46
|
extractExportedZipWithNestedZips(zipFile) {
|
|
50
47
|
const tempDir = path.join(os.tmpdir(), `${(0, uuid_1.v4)()}`);
|
|
51
48
|
fs.mkdirSync(tempDir, { recursive: true });
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
return this.extractExportedZipWithNestedZipsToDir(zipFile, tempDir);
|
|
50
|
+
}
|
|
51
|
+
extractExportedZipWithNestedZipsToDir(zipFile, targetDir) {
|
|
52
|
+
zipFile.extractAllTo(targetDir, true);
|
|
53
|
+
const files = fs.readdirSync(targetDir);
|
|
54
54
|
for (const file of files) {
|
|
55
|
-
const innerZipPath = path.join(
|
|
55
|
+
const innerZipPath = path.join(targetDir, file);
|
|
56
56
|
if (file.endsWith(".zip")) {
|
|
57
57
|
const nestedZip = new AdmZip(innerZipPath);
|
|
58
58
|
const nestedDir = innerZipPath.replace(/\.zip$/, "");
|
|
@@ -61,7 +61,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
61
61
|
fs.rmSync(innerZipPath); // Optionally remove the inner zip
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return targetDir;
|
|
65
|
+
}
|
|
66
|
+
copyDirectoryToCurrentLocation(sourceDir, targetName) {
|
|
67
|
+
fs.mkdirSync(targetName, { recursive: true });
|
|
68
|
+
fs.cpSync(sourceDir, targetName, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
isDirectory(sourcePath) {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = fs.statSync(sourcePath)) === null || _a === void 0 ? void 0 : _a.isDirectory();
|
|
65
73
|
}
|
|
66
74
|
zipDirectoryInBatchExportFormat(sourceDir) {
|
|
67
75
|
const files = fs.readdirSync(sourceDir);
|
|
@@ -7,9 +7,9 @@ export declare class BatchImportExportService {
|
|
|
7
7
|
constructor(context: Context);
|
|
8
8
|
listActivePackages(flavors: string[]): Promise<void>;
|
|
9
9
|
findAndExportListOfActivePackages(flavors: string[], packageKeys: string[], withDependencies: boolean): Promise<void>;
|
|
10
|
-
batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string): Promise<void>;
|
|
10
|
+
batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string, unzip: boolean): Promise<void>;
|
|
11
11
|
batchExportPackagesMetadata(packageKeys: string[], jsonResponse: boolean): Promise<void>;
|
|
12
|
-
batchImportPackages(
|
|
12
|
+
batchImportPackages(sourcePath: string, overwrite: boolean, gitBranch: string): Promise<void>;
|
|
13
13
|
findAndExportListOfActivePackagesByVariableValue(flavors: string[], variableValue: string, variableType: string): Promise<void>;
|
|
14
14
|
listActivePackagesByVariableValue(flavors: string[], variableValue: string, variableType: string): Promise<void>;
|
|
15
15
|
private exportListOfPackages;
|
|
@@ -19,4 +19,5 @@ export declare class BatchImportExportService {
|
|
|
19
19
|
private buildBodyForImport;
|
|
20
20
|
private getReadableStream;
|
|
21
21
|
private parseEntryData;
|
|
22
|
+
private downloadZip;
|
|
22
23
|
}
|
|
@@ -6,9 +6,9 @@ export declare class ConfigCommandService {
|
|
|
6
6
|
constructor(context: Context);
|
|
7
7
|
listActivePackages(jsonResponse: boolean, flavors: string[], withDependencies: boolean, packageKeys: string[], variableValue: string, variableType: string): Promise<void>;
|
|
8
8
|
listVariables(jsonResponse: boolean, keysByVersion: string[], keysByVersionFile: string): Promise<void>;
|
|
9
|
-
batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string): Promise<void>;
|
|
9
|
+
batchExportPackages(packageKeys: string[], packageKeysByVersion: string[], withDependencies: boolean, gitBranch: string, unzip: boolean): Promise<void>;
|
|
10
10
|
batchExportPackagesMetadata(packageKeys: string[], jsonResponse: boolean): Promise<void>;
|
|
11
|
-
batchImportPackages(file: string, overwrite: boolean, gitBranch: string): Promise<void>;
|
|
11
|
+
batchImportPackages(file: string, directory: string, overwrite: boolean, gitBranch: string): Promise<void>;
|
|
12
12
|
diffPackages(file: string, hasChanges: boolean, jsonResponse: boolean): Promise<void>;
|
|
13
13
|
private listPackagesByVariableValue;
|
|
14
14
|
}
|
|
@@ -2,10 +2,12 @@ import AdmZip = require("adm-zip");
|
|
|
2
2
|
export declare class FileService {
|
|
3
3
|
static readonly fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
4
4
|
writeToFileWithGivenName(data: any, filename: string): void;
|
|
5
|
-
createDirectoryWithGivenName(dirName: string): void;
|
|
6
5
|
readFileToJson<T>(fileName: string): Promise<T>;
|
|
7
6
|
readFile(filename: string): string;
|
|
8
7
|
extractExportedZipWithNestedZips(zipFile: AdmZip): string;
|
|
8
|
+
extractExportedZipWithNestedZipsToDir(zipFile: AdmZip, targetDir: string): string;
|
|
9
|
+
copyDirectoryToCurrentLocation(sourceDir: string, targetName: string): void;
|
|
10
|
+
isDirectory(sourcePath: string): boolean;
|
|
9
11
|
zipDirectoryInBatchExportFormat(sourceDir: string): string;
|
|
10
12
|
private getSerializedFileContent;
|
|
11
13
|
}
|