@celonis/content-cli 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
24
24
  constructor(context) {
25
25
  this.httpClient = () => context.httpClient;
26
26
  }
27
- findAll(packageKey, nodeKey, version) {
27
+ findAllStaging(packageKey, nodeKey) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.httpClient()
30
+ .get(`/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}/dependencies`)
31
+ .catch((e) => {
32
+ throw new logger_1.FatalError(`Problem finding dependencies for node ${nodeKey} in package ${packageKey}: ${e}`);
33
+ });
34
+ });
35
+ }
36
+ findAllByVersion(packageKey, nodeKey, version) {
28
37
  return __awaiter(this, void 0, void 0, function* () {
29
38
  const queryParams = new URLSearchParams();
30
39
  queryParams.set("version", version);
@@ -0,0 +1,38 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../../../core/utils/logger"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PackageVersionApi = void 0;
22
+ const logger_1 = require("../../../core/utils/logger");
23
+ class PackageVersionApi {
24
+ constructor(context) {
25
+ this.httpClient = () => context.httpClient;
26
+ }
27
+ findOne(packageKey, version) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return this.httpClient()
30
+ .get(`/pacman/api/core/packages/${packageKey}/versions/${version}`)
31
+ .catch(e => {
32
+ throw new logger_1.FatalError(`Problem finding Package with key '${packageKey}' and version '${version}': ${e}`);
33
+ });
34
+ });
35
+ }
36
+ }
37
+ exports.PackageVersionApi = PackageVersionApi;
38
+ });
@@ -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
+ });
@@ -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", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service"], factory);
19
+ define(["require", "exports", "../../core/command/module-handler", "./config-command.service", "./variable-command.service", "./node.service", "./node-diff.service", "./node-dependency.service", "./package-version-command.service"], factory);
20
20
  }
21
21
  })(function (require, exports) {
22
22
  "use strict";
@@ -26,6 +26,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
26
26
  const node_service_1 = require("./node.service");
27
27
  const node_diff_service_1 = require("./node-diff.service");
28
28
  const node_dependency_service_1 = require("./node-dependency.service");
29
+ const package_version_command_service_1 = require("./package-version-command.service");
29
30
  class Module extends module_handler_1.IModule {
30
31
  register(context, configurator) {
31
32
  const configCommand = configurator.command("config");
@@ -44,8 +45,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
44
45
  .option("--keysByVersion <keysByVersion...>", "Keys of packages to export by version")
45
46
  .option("--withDependencies", "Include variables and dependencies", "")
46
47
  .option("--unzip", "Unzip the exported file", "")
47
- .betaOption("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
48
- .betaOption("--gitBranch <gitBranch>", "Git branch in which you want to push the exported file")
48
+ .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
49
+ .option("--gitBranch <gitBranch>", "Git branch in which you want to push the exported file")
49
50
  .action(this.batchExportPackages);
50
51
  const metadataCommand = configCommand.command("metadata")
51
52
  .description("Commands related to package metadata");
@@ -58,8 +59,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
58
59
  configCommand.command("import")
59
60
  .description("Command to import package configs")
60
61
  .option("--overwrite", "Flag to allow overwriting of packages")
61
- .betaOption("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
62
- .betaOption("--gitBranch <gitBranch>", "Git branch from which you want to pull the exported file and import")
62
+ .option("--gitProfile <gitProfile>", "Git profile which you want to use for the Git operations")
63
+ .option("--gitBranch <gitBranch>", "Git branch from which you want to pull the exported file and import")
63
64
  .option("-f, --file <file>", "Exported packages file (relative path)")
64
65
  .option("-d, --directory <directory>", "Exported packages directory (relative path)")
65
66
  .action(this.batchImportPackages);
@@ -69,6 +70,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
69
70
  .option("--json", "Return the response as a JSON file")
70
71
  .requiredOption("-f, --file <file>", "Exported packages file (relative or absolute path)")
71
72
  .action(this.diffPackages);
73
+ const configVersionCommand = configCommand.command("versions")
74
+ .description("Commands related to Package version metadata");
75
+ configVersionCommand.command("get")
76
+ .description("Get version metadata for a specific package version")
77
+ .requiredOption("--packageKey <packageKey>", "Identifier of the package")
78
+ .requiredOption("--packageVersion <packageVersion>", "Version of the package. Can be a specific version or \"LATEST\" keyword, which will return the most recently created version.")
79
+ .option("--json", "Return the response as a JSON file")
80
+ .action(this.getPackageVersion);
72
81
  const variablesCommand = configCommand.command("variables")
73
82
  .description("Commands related to variable configs");
74
83
  variablesCommand.command("list")
@@ -110,7 +119,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
110
119
  .description("List dependencies of a specific node in a package")
111
120
  .requiredOption("--packageKey <packageKey>", "Identifier of the package")
112
121
  .requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
113
- .requiredOption("--packageVersion <packageVersion>", "Version of the package")
122
+ .option("--packageVersion <packageVersion>", "Version of the package. If not sent, the staging state of the package will be used.")
114
123
  .option("--json", "Return the response as a JSON file")
115
124
  .action(this.listNodeDependencies);
116
125
  const listCommand = configurator.command("list");
@@ -144,6 +153,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
144
153
  yield new config_command_service_1.ConfigCommandService(context).batchExportPackagesMetadata(options.packageKeys, options.json);
145
154
  });
146
155
  }
156
+ getPackageVersion(context, command, options) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ yield new package_version_command_service_1.PackageVersionCommandService(context).getPackageVersion(options.packageKey, options.packageVersion, options.json);
159
+ });
160
+ }
147
161
  batchImportPackages(context, command, options) {
148
162
  return __awaiter(this, void 0, void 0, function* () {
149
163
  if (options.gitProfile && !options.gitBranch) {
@@ -185,6 +199,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
185
199
  }
186
200
  listNodeDependencies(context, command, options) {
187
201
  return __awaiter(this, void 0, void 0, function* () {
202
+ if (options.packageVersion === "") {
203
+ throw new Error("Please specify a valid package version");
204
+ }
188
205
  yield new node_dependency_service_1.NodeDependencyService(context).listNodeDependencies(options.packageKey, options.nodeKey, options.packageVersion, options.json);
189
206
  });
190
207
  }
@@ -29,7 +29,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
29
  }
30
30
  listNodeDependencies(packageKey, nodeKey, version, jsonResponse) {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- const dependencies = yield this.nodeDependencyApi.findAll(packageKey, nodeKey, version);
32
+ let dependencies;
33
+ if (version) {
34
+ dependencies = yield this.nodeDependencyApi.findAllByVersion(packageKey, nodeKey, version);
35
+ }
36
+ else {
37
+ dependencies = yield this.nodeDependencyApi.findAllStaging(packageKey, nodeKey);
38
+ }
33
39
  if (jsonResponse) {
34
40
  const filename = (0, uuid_1.v4)() + ".json";
35
41
  file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(dependencies, null, 2), filename);
@@ -0,0 +1,34 @@
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", "./package-version.service"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PackageVersionCommandService = void 0;
22
+ const package_version_service_1 = require("./package-version.service");
23
+ class PackageVersionCommandService {
24
+ constructor(context) {
25
+ this.packageVersionService = new package_version_service_1.PackageVersionService(context);
26
+ }
27
+ getPackageVersion(packageKey, version, jsonResponse) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ yield this.packageVersionService.findPackageVersion(packageKey, version, jsonResponse);
30
+ });
31
+ }
32
+ }
33
+ exports.PackageVersionCommandService = PackageVersionCommandService;
34
+ });
@@ -0,0 +1,55 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ (function (factory) {
11
+ if (typeof module === "object" && typeof module.exports === "object") {
12
+ var v = factory(require, exports);
13
+ if (v !== undefined) module.exports = v;
14
+ }
15
+ else if (typeof define === "function" && define.amd) {
16
+ define(["require", "exports", "../../core/utils/file-service", "../../core/utils/logger", "uuid", "./api/package-version-api"], factory);
17
+ }
18
+ })(function (require, exports) {
19
+ "use strict";
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.PackageVersionService = void 0;
22
+ const file_service_1 = require("../../core/utils/file-service");
23
+ const logger_1 = require("../../core/utils/logger");
24
+ const uuid_1 = require("uuid");
25
+ const package_version_api_1 = require("./api/package-version-api");
26
+ class PackageVersionService {
27
+ constructor(context) {
28
+ this.packageVersionApi = new package_version_api_1.PackageVersionApi(context);
29
+ }
30
+ findPackageVersion(packageKey, version, jsonResponse) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const packageVersionTransport = yield this.packageVersionApi.findOne(packageKey, version);
33
+ if (jsonResponse) {
34
+ const filename = (0, uuid_1.v4)() + ".json";
35
+ file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(packageVersionTransport, null, 2), filename);
36
+ logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
37
+ }
38
+ else {
39
+ this.printPackageVersionTransport(packageVersionTransport);
40
+ }
41
+ });
42
+ }
43
+ printPackageVersionTransport(packageVersionTransport) {
44
+ logger_1.logger.info(`Package Key: ${packageVersionTransport.packageKey}`);
45
+ logger_1.logger.info(`Version: ${packageVersionTransport.version}`);
46
+ logger_1.logger.info(`History ID: ${packageVersionTransport.historyId}`);
47
+ logger_1.logger.info(`Change Date: ${new Date(packageVersionTransport.changeDate).toISOString()}`);
48
+ logger_1.logger.info(`Publish Date: ${new Date(packageVersionTransport.publishDate).toISOString()}`);
49
+ logger_1.logger.info(`Publish Message: ${packageVersionTransport.publishMessage}`);
50
+ logger_1.logger.info(`Deployed: ${packageVersionTransport.deployed}`);
51
+ logger_1.logger.info(`Published By: ${packageVersionTransport.publishedBy}`);
52
+ }
53
+ }
54
+ exports.PackageVersionService = PackageVersionService;
55
+ });
@@ -25,23 +25,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  class Module extends module_handler_1.IModule {
26
26
  register(context, configurator) {
27
27
  const gitCommand = configurator.command("git")
28
- .beta()
29
28
  .description("Commands related to Git settings");
30
29
  const gitProfileCommand = gitCommand.command("profile")
31
- .beta()
32
30
  .description("Manage Git profiles required to use git-related operations.");
33
31
  gitProfileCommand.command("list")
34
32
  .description("Command to list all stored Git profiles")
35
- .beta()
36
33
  .action(this.listProfiles);
37
34
  gitProfileCommand.command("create")
38
35
  .description("Command to create a new Git profile")
39
36
  .option("--setAsDefault", "Set this Git profile as default")
40
- .beta()
41
37
  .action(this.createProfile);
42
38
  gitProfileCommand.command("default <profile>")
43
39
  .description("Command to set a Git profile as default")
44
- .beta()
45
40
  .action(this.defaultProfile);
46
41
  }
47
42
  defaultProfile(context, command) {
@@ -38,7 +38,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
38
38
  }
39
39
  get httpClient() {
40
40
  if (!this._httpClient) {
41
- throw new logger_1.FatalError("No profile provided. Please provide a profile or a TEAM_URL and API_TOKEN through env variables");
41
+ throw new logger_1.FatalError("No profile provided. Please provide a profile or a team url and api token through env variables");
42
42
  }
43
43
  return this._httpClient;
44
44
  }
@@ -40,6 +40,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
40
40
  findProfile(profileName) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
42
  return new Promise((resolve, reject) => {
43
+ this.mapCelonisEnvProfile();
43
44
  this.checkIfMissingProfile(profileName, reject);
44
45
  try {
45
46
  if (process.env.TEAM_URL && process.env.API_TOKEN) {
@@ -311,6 +312,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
311
312
  reject("Profile not found");
312
313
  }
313
314
  }
315
+ mapCelonisEnvProfile() {
316
+ if (!process.env.CELONIS_URL) {
317
+ return;
318
+ }
319
+ process.env.TEAM_URL = process.env.CELONIS_URL;
320
+ if (process.env.CELONIS_API_TOKEN) {
321
+ process.env.API_TOKEN = process.env.CELONIS_API_TOKEN;
322
+ }
323
+ else {
324
+ delete process.env.API_TOKEN;
325
+ }
326
+ }
314
327
  }
315
328
  exports.ProfileService = ProfileService;
316
329
  exports.profileService = new ProfileService();
@@ -63,20 +63,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
63
63
  }
64
64
  return targetDir;
65
65
  }
66
- copyDirectoryToCurrentLocation(sourceDir, targetName) {
67
- fs.mkdirSync(targetName, { recursive: true });
68
- fs.cpSync(sourceDir, targetName, { recursive: true });
69
- }
70
66
  isDirectory(sourcePath) {
71
67
  var _a;
72
68
  return (_a = fs.statSync(sourcePath)) === null || _a === void 0 ? void 0 : _a.isDirectory();
73
69
  }
74
70
  zipDirectoryInBatchExportFormat(sourceDir) {
71
+ if (fs.lstatSync(sourceDir).isSymbolicLink()) {
72
+ throw new logger_1.FatalError("Source directory cannot be a symbolic link.");
73
+ }
75
74
  const files = fs.readdirSync(sourceDir);
76
75
  const finalZip = new AdmZip();
77
76
  files.forEach(file => {
78
77
  const fullPath = path.join(sourceDir, file);
79
- const stat = fs.statSync(fullPath);
78
+ const stat = fs.lstatSync(fullPath);
80
79
  if (stat.isDirectory()) {
81
80
  const zip = new AdmZip();
82
81
  zip.addLocalFolder(fullPath);
@@ -3,5 +3,6 @@ import { NodeDependencyTransport } from "../interfaces/node-dependency.interface
3
3
  export declare class NodeDependencyApi {
4
4
  private httpClient;
5
5
  constructor(context: Context);
6
- findAll(packageKey: string, nodeKey: string, version: string): Promise<NodeDependencyTransport[]>;
6
+ findAllStaging(packageKey: string, nodeKey: string): Promise<NodeDependencyTransport[]>;
7
+ findAllByVersion(packageKey: string, nodeKey: string, version: string): Promise<NodeDependencyTransport[]>;
7
8
  }
@@ -0,0 +1,7 @@
1
+ import { Context } from "../../../core/command/cli-context";
2
+ import { PackageVersionTransport } from "../interfaces/package-version.interfaces";
3
+ export declare class PackageVersionApi {
4
+ private httpClient;
5
+ constructor(context: Context);
6
+ findOne(packageKey: string, version: string): Promise<PackageVersionTransport>;
7
+ }
@@ -0,0 +1,10 @@
1
+ export interface PackageVersionTransport {
2
+ packageKey: string;
3
+ historyId: string;
4
+ version: string;
5
+ changeDate: string;
6
+ publishDate: string;
7
+ publishMessage: string;
8
+ deployed: boolean;
9
+ publishedBy: string;
10
+ }
@@ -8,6 +8,7 @@ declare class Module extends IModule {
8
8
  private listActivePackages;
9
9
  private batchExportPackages;
10
10
  private batchExportPackagesMetadata;
11
+ private getPackageVersion;
11
12
  private batchImportPackages;
12
13
  private diffPackages;
13
14
  private listVariables;
@@ -0,0 +1,6 @@
1
+ import { Context } from "../../core/command/cli-context";
2
+ export declare class PackageVersionCommandService {
3
+ private packageVersionService;
4
+ constructor(context: Context);
5
+ getPackageVersion(packageKey: string, version: string, jsonResponse: boolean): Promise<void>;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Context } from "../../core/command/cli-context";
2
+ export declare class PackageVersionService {
3
+ private packageVersionApi;
4
+ constructor(context: Context);
5
+ findPackageVersion(packageKey: string, version: string, jsonResponse: boolean): Promise<void>;
6
+ private printPackageVersionTransport;
7
+ }
@@ -22,5 +22,6 @@ export declare class ProfileService {
22
22
  private isProfileExpired;
23
23
  private tryKeyAuthentication;
24
24
  private checkIfMissingProfile;
25
+ private mapCelonisEnvProfile;
25
26
  }
26
27
  export declare const profileService: ProfileService;
@@ -6,7 +6,6 @@ export declare class FileService {
6
6
  readFile(filename: string): string;
7
7
  extractExportedZipWithNestedZips(zipFile: AdmZip): string;
8
8
  extractExportedZipWithNestedZipsToDir(zipFile: AdmZip, targetDir: string): string;
9
- copyDirectoryToCurrentLocation(sourceDir: string, targetName: string): void;
10
9
  isDirectory(sourcePath: string): boolean;
11
10
  zipDirectoryInBatchExportFormat(sourceDir: string): string;
12
11
  private getSerializedFileContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celonis/content-cli",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "CLI Tool to help manage content in Celonis Platform",
5
5
  "main": "content-cli.js",
6
6
  "bin": {
@@ -53,5 +53,8 @@
53
53
  "prettier --write",
54
54
  "git add"
55
55
  ]
56
+ },
57
+ "repository": {
58
+ "url": "https://github.com/celonis/content-cli"
56
59
  }
57
60
  }