@celonis/content-cli 0.8.2 → 0.8.4
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/api/diff-api.js +37 -0
- package/commands/config.command.js +5 -1
- package/content-cli-config.js +15 -0
- package/interfaces/diff-package.transport.js +12 -0
- package/lib/api/diff-api.d.ts +9 -0
- package/lib/commands/config.command.d.ts +1 -0
- package/lib/content-cli-config.d.ts +1 -0
- package/lib/interfaces/diff-package.transport.d.ts +16 -0
- package/lib/interfaces/package-export-transport.d.ts +3 -5
- package/lib/services/package-manager/diff-service.d.ts +11 -0
- package/package.json +1 -1
- package/services/package-manager/diff-service.js +90 -0
- package/services/studio/studio.service.js +3 -3
package/api/diff-api.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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", "../services/http-client-service.v2"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.diffApi = void 0;
|
|
22
|
+
const http_client_service_v2_1 = require("../services/http-client-service.v2");
|
|
23
|
+
class DiffApi {
|
|
24
|
+
diffPackages(data) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return http_client_service_v2_1.httpClientV2.postFile("/package-manager/api/core/packages/diff/configuration", data);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
hasChanges(data) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return http_client_service_v2_1.httpClientV2.postFile("/package-manager/api/core/packages/diff/configuration/has-changes", data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
DiffApi.INSTANCE = new DiffApi();
|
|
36
|
+
exports.diffApi = DiffApi.INSTANCE;
|
|
37
|
+
});
|
|
@@ -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", "../services/package-manager/batch-import-export-service", "../services/package-manager/variable-service"], factory);
|
|
16
|
+
define(["require", "exports", "../services/package-manager/batch-import-export-service", "../services/package-manager/variable-service", "../services/package-manager/diff-service"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -21,6 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
exports.ConfigCommand = void 0;
|
|
22
22
|
const batch_import_export_service_1 = require("../services/package-manager/batch-import-export-service");
|
|
23
23
|
const variable_service_1 = require("../services/package-manager/variable-service");
|
|
24
|
+
const diff_service_1 = require("../services/package-manager/diff-service");
|
|
24
25
|
class ConfigCommand {
|
|
25
26
|
listActivePackages(jsonResponse, flavors, withDependencies, packageKeys) {
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -48,6 +49,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
48
49
|
batchImportPackages(file, overwrite) {
|
|
49
50
|
return batch_import_export_service_1.batchImportExportService.batchImportPackages(file, overwrite);
|
|
50
51
|
}
|
|
52
|
+
diffPackages(file, hasChanges, jsonResponse) {
|
|
53
|
+
return diff_service_1.diffService.diffPackages(file, hasChanges, jsonResponse);
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
exports.ConfigCommand = ConfigCommand;
|
|
53
57
|
});
|
package/content-cli-config.js
CHANGED
|
@@ -81,6 +81,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
81
81
|
}));
|
|
82
82
|
return program;
|
|
83
83
|
}
|
|
84
|
+
static diff(program) {
|
|
85
|
+
program
|
|
86
|
+
.command("diff")
|
|
87
|
+
.description("Command to diff configs of packages")
|
|
88
|
+
.option("-p, --profile <profile>", "Profile of the team/realm which you want to use to diff the packages with")
|
|
89
|
+
.option("--hasChanges", "Flag to return only the information if the package has changes without the actual changes")
|
|
90
|
+
.option("--json", "Return the response as a JSON file")
|
|
91
|
+
.requiredOption("-f, --file <file>", "Exported packages file (relative or absolute path)")
|
|
92
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
yield new config_command_1.ConfigCommand().diffPackages(cmd.file, cmd.hasChanges, cmd.json);
|
|
94
|
+
process.exit();
|
|
95
|
+
}));
|
|
96
|
+
return program;
|
|
97
|
+
}
|
|
84
98
|
}
|
|
85
99
|
exports.Config = Config;
|
|
86
100
|
const loadAllCommands = () => {
|
|
@@ -88,6 +102,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
88
102
|
Config.listVariables(commander);
|
|
89
103
|
Config.export(commander);
|
|
90
104
|
Config.import(commander);
|
|
105
|
+
Config.diff(commander);
|
|
91
106
|
commander.parse(process.argv);
|
|
92
107
|
};
|
|
93
108
|
context_initializer_1.ContextInitializer.initContext()
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PackageDiffTransport } from "../interfaces/diff-package.transport";
|
|
2
|
+
import * as FormData from "form-data";
|
|
3
|
+
declare class DiffApi {
|
|
4
|
+
static readonly INSTANCE: DiffApi;
|
|
5
|
+
diffPackages(data: FormData): Promise<PackageDiffTransport[]>;
|
|
6
|
+
hasChanges(data: FormData): Promise<PackageDiffTransport[]>;
|
|
7
|
+
}
|
|
8
|
+
export declare const diffApi: DiffApi;
|
|
9
|
+
export {};
|
|
@@ -3,4 +3,5 @@ export declare class ConfigCommand {
|
|
|
3
3
|
listVariables(jsonResponse: boolean, keysByVersion: string[], keysByVersionFile: string): Promise<void>;
|
|
4
4
|
batchExportPackages(packageKeys: string[], withDependencies?: boolean): Promise<void>;
|
|
5
5
|
batchImportPackages(file: string, overwrite: boolean): Promise<void>;
|
|
6
|
+
diffPackages(file: string, hasChanges: boolean, jsonResponse: boolean): Promise<void>;
|
|
6
7
|
}
|
|
@@ -5,5 +5,6 @@ export declare class Config {
|
|
|
5
5
|
static listVariables(program: CommanderStatic): CommanderStatic;
|
|
6
6
|
static export(program: CommanderStatic): CommanderStatic;
|
|
7
7
|
static import(program: CommanderStatic): CommanderStatic;
|
|
8
|
+
static diff(program: CommanderStatic): CommanderStatic;
|
|
8
9
|
}
|
|
9
10
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ConfigurationChangeTransport {
|
|
2
|
+
op: string;
|
|
3
|
+
path: string;
|
|
4
|
+
from: string;
|
|
5
|
+
value: object;
|
|
6
|
+
}
|
|
7
|
+
export interface NodeDiffTransport {
|
|
8
|
+
nodeKey: string;
|
|
9
|
+
changes: ConfigurationChangeTransport[];
|
|
10
|
+
}
|
|
11
|
+
export interface PackageDiffTransport {
|
|
12
|
+
packageKey: string;
|
|
13
|
+
hasChanges: boolean;
|
|
14
|
+
packageChanges: ConfigurationChangeTransport[];
|
|
15
|
+
nodesWithChanges: NodeDiffTransport[];
|
|
16
|
+
}
|
|
@@ -42,16 +42,14 @@ export interface PackageKeyAndVersionPair {
|
|
|
42
42
|
export interface NodeExportTransport {
|
|
43
43
|
key: string;
|
|
44
44
|
parentNodeKey: string;
|
|
45
|
-
packageNodeKey: string;
|
|
46
45
|
name: string;
|
|
47
46
|
type: string;
|
|
48
47
|
exportSerializationType: string;
|
|
49
|
-
|
|
48
|
+
configuration: string;
|
|
50
49
|
schemaVersion: number;
|
|
51
|
-
|
|
52
|
-
versionedMetdata: object;
|
|
50
|
+
spaceId: string;
|
|
53
51
|
invalidContent?: boolean;
|
|
54
|
-
serializedDocument
|
|
52
|
+
serializedDocument?: Buffer;
|
|
55
53
|
}
|
|
56
54
|
export interface NodeSerializedContent {
|
|
57
55
|
variables: VariableDefinition[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class DiffService {
|
|
2
|
+
diffPackages(file: string, hasChanges: boolean, jsonResponse: boolean): Promise<void>;
|
|
3
|
+
private hasChanges;
|
|
4
|
+
private diffPackagesAndReturnDiff;
|
|
5
|
+
private buildBodyForDiff;
|
|
6
|
+
private getReadableStream;
|
|
7
|
+
private exportListOfPackageDiffs;
|
|
8
|
+
private buildStringResponse;
|
|
9
|
+
}
|
|
10
|
+
export declare const diffService: DiffService;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
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", "adm-zip", "stream", "form-data", "../../api/diff-api", "../file-service", "../../util/logger", "uuid"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.diffService = void 0;
|
|
22
|
+
const AdmZip = require("adm-zip");
|
|
23
|
+
const stream_1 = require("stream");
|
|
24
|
+
const FormData = require("form-data");
|
|
25
|
+
const diff_api_1 = require("../../api/diff-api");
|
|
26
|
+
const file_service_1 = require("../file-service");
|
|
27
|
+
const logger_1 = require("../../util/logger");
|
|
28
|
+
const uuid_1 = require("uuid");
|
|
29
|
+
class DiffService {
|
|
30
|
+
diffPackages(file, hasChanges, jsonResponse) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (hasChanges) {
|
|
33
|
+
yield this.hasChanges(file, jsonResponse);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
yield this.diffPackagesAndReturnDiff(file, jsonResponse);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
hasChanges(file, jsonResponse) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const packages = new AdmZip(file);
|
|
43
|
+
const formData = this.buildBodyForDiff(packages);
|
|
44
|
+
const returnedHasChangesData = yield diff_api_1.diffApi.hasChanges(formData);
|
|
45
|
+
if (jsonResponse) {
|
|
46
|
+
this.exportListOfPackageDiffs(returnedHasChangesData);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
logger_1.logger.info(this.buildStringResponse(returnedHasChangesData));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
diffPackagesAndReturnDiff(file, jsonResponse) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const packages = new AdmZip(file);
|
|
56
|
+
const formData = this.buildBodyForDiff(packages);
|
|
57
|
+
const returnedHasChangesData = yield diff_api_1.diffApi.diffPackages(formData);
|
|
58
|
+
if (jsonResponse) {
|
|
59
|
+
this.exportListOfPackageDiffs(returnedHasChangesData);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
logger_1.logger.info(this.buildStringResponse(returnedHasChangesData));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
buildBodyForDiff(packages) {
|
|
67
|
+
const formData = new FormData();
|
|
68
|
+
const readableStream = this.getReadableStream(packages);
|
|
69
|
+
formData.append("file", readableStream, { filename: "packages.zip" });
|
|
70
|
+
return formData;
|
|
71
|
+
}
|
|
72
|
+
getReadableStream(packages) {
|
|
73
|
+
return new stream_1.Readable({
|
|
74
|
+
read() {
|
|
75
|
+
this.push(packages.toBuffer());
|
|
76
|
+
this.push(null);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exportListOfPackageDiffs(packageDiffs) {
|
|
81
|
+
const filename = (0, uuid_1.v4)() + ".json";
|
|
82
|
+
file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packageDiffs), filename);
|
|
83
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
|
|
84
|
+
}
|
|
85
|
+
buildStringResponse(packageDiffs) {
|
|
86
|
+
return "\n" + JSON.stringify(packageDiffs, null, 2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.diffService = new DiffService();
|
|
90
|
+
});
|
|
@@ -129,10 +129,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
129
129
|
}
|
|
130
130
|
const packageEntry = packageZip.getEntry("package.yml");
|
|
131
131
|
const exportedNode = (0, yaml_1.parse)(packageEntry.getData().toString());
|
|
132
|
-
const nodeContent = (0, yaml_1.parse)(exportedNode.
|
|
132
|
+
const nodeContent = (0, yaml_1.parse)(exportedNode.configuration);
|
|
133
133
|
nodeContent.variables = nodeContent.variables.map(variable => (Object.assign(Object.assign({}, variable), { metadata: variable.type === package_manager_interfaces_1.PackageManagerVariableType.CONNECTION ?
|
|
134
134
|
connectionVariablesByKey.get(variable.key).metadata : variable.metadata })));
|
|
135
|
-
exportedNode.
|
|
135
|
+
exportedNode.configuration = (0, yaml_1.stringify)(nodeContent);
|
|
136
136
|
packageZip.updateFile(packageEntry, Buffer.from((0, yaml_1.stringify)(exportedNode)));
|
|
137
137
|
}
|
|
138
138
|
getPackageKeyAndVersion(zipName) {
|
|
@@ -211,7 +211,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
211
211
|
}
|
|
212
212
|
updateSpaceIdForNode(nodeContent, spaceId) {
|
|
213
213
|
const exportedNode = (0, yaml_1.parse)(nodeContent);
|
|
214
|
-
const oldSpaceId = exportedNode.
|
|
214
|
+
const oldSpaceId = exportedNode.spaceId;
|
|
215
215
|
nodeContent = nodeContent.replace(new RegExp(oldSpaceId, "g"), spaceId);
|
|
216
216
|
return nodeContent;
|
|
217
217
|
}
|