@celonis/content-cli 0.2.9 → 0.2.10

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.
@@ -40,9 +40,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
40
40
  yield this.contentService.batchPush(profile, this.packageManagerFactory.createPushManagers(spaceKey));
41
41
  });
42
42
  }
43
- listPackages(profile) {
43
+ listPackages(profile, jsonResponse) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- yield this.contentService.findAll(profile, this.packageManagerFactory.createManager());
45
+ yield this.contentService.findAll(profile, this.packageManagerFactory.createListManager(jsonResponse));
46
46
  });
47
47
  }
48
48
  }
@@ -25,9 +25,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  this.contentService = new content_service_1.ContentService();
26
26
  this.spaceManagerFactory = new space_manager_factory_1.SpaceManagerFactory();
27
27
  }
28
- listSpaces(profile) {
28
+ listSpaces(profile, jsonResponse) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- yield this.contentService.findAll(profile, this.spaceManagerFactory.createManager());
30
+ yield this.contentService.findAll(profile, this.spaceManagerFactory.createListManager(jsonResponse));
31
31
  });
32
32
  }
33
33
  }
@@ -15,10 +15,13 @@
15
15
  const package_manager_1 = require("../manager/package.manager");
16
16
  class PackageManagerFactory {
17
17
  createPullManager(key, store, newKey, draft) {
18
- return this.createManager(key, null, null, store, newKey, false, draft);
18
+ return this.createManager(key, null, null, store, newKey, false, draft, null);
19
19
  }
20
20
  createPushManager(spaceKey, fileName, newKey, overwrite) {
21
- return this.createManager(null, spaceKey, fileName, false, newKey, overwrite, false);
21
+ return this.createManager(null, spaceKey, fileName, false, newKey, overwrite, false, null);
22
+ }
23
+ createListManager(jsonResponse) {
24
+ return this.createManager(null, null, null, false, null, false, false, jsonResponse);
22
25
  }
23
26
  createPushManagers(spaceKey) {
24
27
  const filePaths = fs.readdirSync(process.cwd());
@@ -34,7 +37,7 @@
34
37
  return this.createPushManager(spaceKey, filePath);
35
38
  });
36
39
  }
37
- createManager(key, spaceKey, fileName, store, newKey, overwrite, draft) {
40
+ createManager(key, spaceKey, fileName, store, newKey, overwrite, draft, jsonResponse) {
38
41
  const packageManager = new package_manager_1.PackageManager();
39
42
  if (fileName) {
40
43
  packageManager.fileName = this.resolvePackageFilePath(fileName);
@@ -45,6 +48,7 @@
45
48
  packageManager.newKey = newKey;
46
49
  packageManager.overwrite = overwrite;
47
50
  packageManager.draft = draft;
51
+ packageManager.jsonResponse = jsonResponse;
48
52
  return packageManager;
49
53
  }
50
54
  isPackageFilePath(filePath) {
@@ -11,8 +11,13 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const space_manager_1 = require("../manager/space.manager");
13
13
  class SpaceManagerFactory {
14
- createManager() {
15
- return new space_manager_1.SpaceManager();
14
+ createListManager(jsonResponse) {
15
+ return this.createManager(jsonResponse);
16
+ }
17
+ createManager(jsonResponse) {
18
+ const spaceManager = new space_manager_1.SpaceManager();
19
+ spaceManager.jsonResponse = jsonResponse;
20
+ return spaceManager;
16
21
  }
17
22
  }
18
23
  exports.SpaceManagerFactory = SpaceManagerFactory;
@@ -25,6 +25,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  class BaseManager {
26
26
  constructor() {
27
27
  this.httpClientService = new http_client_service_1.HttpClientService();
28
+ this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
28
29
  }
29
30
  get profile() {
30
31
  return this._profile;
@@ -40,7 +41,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
40
41
  .then(data => {
41
42
  try {
42
43
  const filename = this.writeToFile(data);
43
- logger_1.logger.info("File downloaded successfully. New filename: " + filename);
44
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
44
45
  resolve();
45
46
  }
46
47
  catch (e) {
@@ -62,7 +63,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
62
63
  .pullFileData(this.getConfig().pullUrl, this._profile)
63
64
  .then(data => {
64
65
  const filename = this.writeStreamToFile(data);
65
- logger_1.logger.info("File downloaded successfully. New filename: " + filename);
66
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
66
67
  resolve();
67
68
  })
68
69
  .catch(err => {
@@ -122,9 +123,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
122
123
  }
123
124
  writeToFile(data) {
124
125
  const filename = this.getConfig().exportFileName;
125
- fs.writeFileSync(path.resolve(process.cwd(), filename), this.getSerializedFileContent(data), {
126
- encoding: "utf-8",
127
- });
126
+ this.writeToFileWithGivenName(data, filename);
128
127
  return filename;
129
128
  }
130
129
  writeStreamToFile(data) {
@@ -132,6 +131,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
132
131
  fs.writeFileSync(filename, data);
133
132
  return filename;
134
133
  }
134
+ writeToFileWithGivenName(data, filename) {
135
+ fs.writeFileSync(path.resolve(process.cwd(), filename), this.getSerializedFileContent(data), {
136
+ encoding: "utf-8",
137
+ });
138
+ }
135
139
  }
136
140
  exports.BaseManager = BaseManager;
137
141
  });
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./base.manager", "fs", "../../util/logger"], factory);
7
+ define(["require", "exports", "./base.manager", "fs", "../../util/logger", "uuid"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -12,6 +12,7 @@
12
12
  const base_manager_1 = require("./base.manager");
13
13
  const fs = require("fs");
14
14
  const logger_1 = require("../../util/logger");
15
+ const uuid_1 = require("uuid");
15
16
  class PackageManager extends base_manager_1.BaseManager {
16
17
  get key() {
17
18
  return this._key;
@@ -55,6 +56,12 @@
55
56
  set draft(value) {
56
57
  this._draft = value;
57
58
  }
59
+ get jsonResponse() {
60
+ return this._jsonResponse;
61
+ }
62
+ set jsonResponse(value) {
63
+ this._jsonResponse = value;
64
+ }
58
65
  getConfig() {
59
66
  return {
60
67
  pushUrl: this.profile.team.replace(/\/?$/, this.buildPushUrl()),
@@ -83,9 +90,16 @@
83
90
  return this.getPushUrlWithParams(pushUrl);
84
91
  }
85
92
  listPackages(nodes) {
86
- nodes.forEach(node => {
87
- logger_1.logger.info(`${node.name} - Key: "${node.key}"`);
88
- });
93
+ if (this.jsonResponse) {
94
+ const filename = uuid_1.v4() + ".json";
95
+ this.writeToFileWithGivenName(JSON.stringify(nodes, ["key", "name", "changeDate", "activatedDraftId", "spaceId"]), filename);
96
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
97
+ }
98
+ else {
99
+ nodes.forEach(node => {
100
+ logger_1.logger.info(`${node.name} - Key: "${node.key}"`);
101
+ });
102
+ }
89
103
  }
90
104
  validateOptions() {
91
105
  if (this.newKey && this.overwrite) {
@@ -4,25 +4,20 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./base.manager", "../../util/logger"], factory);
7
+ define(["require", "exports", "./base.manager", "../../util/logger", "uuid"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const base_manager_1 = require("./base.manager");
13
13
  const logger_1 = require("../../util/logger");
14
+ const uuid_1 = require("uuid");
14
15
  class SpaceManager extends base_manager_1.BaseManager {
15
- get id() {
16
- return this._id;
16
+ get jsonResponse() {
17
+ return this._jsonResponse;
17
18
  }
18
- set id(value) {
19
- this._id = value;
20
- }
21
- get name() {
22
- return this._name;
23
- }
24
- set name(value) {
25
- this._name = value;
19
+ set jsonResponse(value) {
20
+ this._jsonResponse = value;
26
21
  }
27
22
  getConfig() {
28
23
  return {
@@ -31,15 +26,22 @@
31
26
  };
32
27
  }
33
28
  listSpaces(nodes) {
34
- nodes.forEach(node => {
35
- logger_1.logger.info(`${node.id} - Name: "${node.name}"`);
36
- });
29
+ if (this.jsonResponse) {
30
+ const filename = uuid_1.v4() + ".json";
31
+ this.writeToFileWithGivenName(JSON.stringify(nodes, ["id", "name"]), filename);
32
+ logger_1.logger.info(this.fileDownloadedMessage + filename);
33
+ }
34
+ else {
35
+ nodes.forEach(node => {
36
+ logger_1.logger.info(`${node.id} - Name: "${node.name}"`);
37
+ });
38
+ }
37
39
  }
38
40
  getBody() {
39
41
  return {};
40
42
  }
41
43
  getSerializedFileContent(data) {
42
- return "";
44
+ return data;
43
45
  }
44
46
  }
45
47
  exports.SpaceManager = SpaceManager;
@@ -27,8 +27,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27
27
  .command("packages")
28
28
  .description("Command to list all packages")
29
29
  .option("-p, --profile <profile>", "Profile which you want to use to list packages")
30
+ .option("--json", "Return response as json type", "")
30
31
  .action((cmd) => __awaiter(this, void 0, void 0, function* () {
31
- yield new package_command_1.PackageCommand().listPackages(cmd.profile);
32
+ yield new package_command_1.PackageCommand().listPackages(cmd.profile, cmd.json);
32
33
  process.exit();
33
34
  }));
34
35
  return program;
@@ -38,8 +39,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
38
39
  .command("spaces")
39
40
  .description("Command to list all spaces")
40
41
  .option("-p, --profile <profile>", "Profile which you want to use to list spaces")
42
+ .option("--json", "Return response as json type", "")
41
43
  .action((cmd) => __awaiter(this, void 0, void 0, function* () {
42
- yield new space_command_1.SpaceCommand().listSpaces(cmd.profile);
44
+ yield new space_command_1.SpaceCommand().listSpaces(cmd.profile, cmd.json);
43
45
  process.exit();
44
46
  }));
45
47
  return program;
@@ -4,5 +4,5 @@ export declare class PackageCommand {
4
4
  pullPackage(profile: string, key: string, store: boolean, newKey: string, draft: boolean): Promise<void>;
5
5
  pushPackage(profile: string, spaceKey: string, fileName: string, newKey: string, overwrite: boolean): Promise<void>;
6
6
  pushPackages(profile: string, spaceKey: string): Promise<void>;
7
- listPackages(profile: string): Promise<void>;
7
+ listPackages(profile: string, jsonResponse: boolean): Promise<void>;
8
8
  }
@@ -1,5 +1,5 @@
1
1
  export declare class SpaceCommand {
2
2
  private contentService;
3
3
  private spaceManagerFactory;
4
- listSpaces(profile: string): Promise<void>;
4
+ listSpaces(profile: string, jsonResponse: boolean): Promise<void>;
5
5
  }
@@ -2,8 +2,9 @@ import { PackageManager } from "../manager/package.manager";
2
2
  export declare class PackageManagerFactory {
3
3
  createPullManager(key: string, store?: boolean, newKey?: string, draft?: boolean): PackageManager;
4
4
  createPushManager(spaceKey: string, fileName: string, newKey?: string, overwrite?: boolean): PackageManager;
5
+ createListManager(jsonResponse: boolean): PackageManager;
5
6
  createPushManagers(spaceKey: string): PackageManager[];
6
- createManager(key?: string, spaceKey?: string, fileName?: string, store?: boolean, newKey?: string, overwrite?: boolean, draft?: boolean): PackageManager;
7
+ createManager(key?: string, spaceKey?: string, fileName?: string, store?: boolean, newKey?: string, overwrite?: boolean, draft?: boolean, jsonResponse?: boolean): PackageManager;
7
8
  private isPackageFilePath;
8
9
  private resolvePackageFilePath;
9
10
  }
@@ -1,4 +1,5 @@
1
1
  import { SpaceManager } from "../manager/space.manager";
2
2
  export declare class SpaceManagerFactory {
3
- createManager(): SpaceManager;
3
+ createListManager(jsonResponse: boolean): SpaceManager;
4
+ createManager(jsonResponse?: boolean): SpaceManager;
4
5
  }
@@ -5,6 +5,7 @@ export declare abstract class BaseManager {
5
5
  get profile(): Profile;
6
6
  set profile(value: Profile);
7
7
  private _profile;
8
+ protected readonly fileDownloadedMessage = "File downloaded successfully. New filename: ";
8
9
  pull(): Promise<any>;
9
10
  pullFile(): Promise<any>;
10
11
  push(): Promise<any>;
@@ -12,6 +13,7 @@ export declare abstract class BaseManager {
12
13
  findAll(): Promise<any>;
13
14
  protected writeToFile(data: any): string;
14
15
  protected writeStreamToFile(data: any): string;
16
+ protected writeToFileWithGivenName(data: any, filename: string): void;
15
17
  protected abstract getConfig(): ManagerConfig;
16
18
  protected abstract getBody(): object;
17
19
  protected abstract getSerializedFileContent(data: any): string;
@@ -13,6 +13,7 @@ export declare class PackageManager extends BaseManager {
13
13
  private _newKey;
14
14
  private _overwrite;
15
15
  private _draft;
16
+ private _jsonResponse;
16
17
  get key(): string;
17
18
  set key(value: string);
18
19
  get spaceKey(): string;
@@ -27,6 +28,8 @@ export declare class PackageManager extends BaseManager {
27
28
  set overwrite(value: boolean);
28
29
  get draft(): boolean;
29
30
  set draft(value: boolean);
31
+ get jsonResponse(): boolean;
32
+ set jsonResponse(value: boolean);
30
33
  getConfig(): ManagerConfig;
31
34
  getBody(): any;
32
35
  protected getSerializedFileContent(data: any): string;
@@ -2,12 +2,9 @@ import { ManagerConfig } from "../../interfaces/manager-config.interface";
2
2
  import { BaseManager } from "./base.manager";
3
3
  export declare class SpaceManager extends BaseManager {
4
4
  private static BASE_URL;
5
- private _id;
6
- private _name;
7
- get id(): string;
8
- set id(value: string);
9
- get name(): string;
10
- set name(value: string);
5
+ private _jsonResponse;
6
+ get jsonResponse(): boolean;
7
+ set jsonResponse(value: boolean);
11
8
  getConfig(): ManagerConfig;
12
9
  private listSpaces;
13
10
  protected getBody(): object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celonis/content-cli",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "CLI Tool to help manage content in Celonis EMS",
5
5
  "main": "content-cli.js",
6
6
  "bin": {