@celonis/content-cli 0.3.2 → 0.3.3
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/asset-api.js +41 -0
- package/commands/asset.command.js +12 -1
- package/content-cli-list.js +16 -1
- package/lib/api/asset-api.d.ts +8 -0
- package/lib/commands/asset.command.d.ts +1 -0
- package/lib/content-cli-list.d.ts +1 -0
- package/lib/services/package-manager/asset-service.d.ts +7 -0
- package/package.json +1 -1
- package/services/package-manager/asset-service.js +48 -0
package/api/asset-api.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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", "../util/logger"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const http_client_service_v2_1 = require("../services/http-client-service.v2");
|
|
22
|
+
const logger_1 = require("../util/logger");
|
|
23
|
+
class AssetApi {
|
|
24
|
+
findAllAssets(assetType) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return http_client_service_v2_1.httpClientV2.get(this.getFindAllAssetsUrl(assetType)).catch(e => {
|
|
27
|
+
throw new logger_1.FatalError(`Problem getting assets: ${e}`);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getFindAllAssetsUrl(assetType) {
|
|
32
|
+
const findAllAssetsUrl = "/package-manager/api/nodes";
|
|
33
|
+
if (assetType) {
|
|
34
|
+
return `${findAllAssetsUrl}?assetType=${assetType}`;
|
|
35
|
+
}
|
|
36
|
+
return findAllAssetsUrl;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
AssetApi.INSTANCE = new AssetApi();
|
|
40
|
+
exports.assetApi = AssetApi.INSTANCE;
|
|
41
|
+
});
|
|
@@ -13,13 +13,14 @@ 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/content.service", "../content/factory/asset-manager.factory"], factory);
|
|
16
|
+
define(["require", "exports", "../services/content.service", "../content/factory/asset-manager.factory", "../services/package-manager/asset-service"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const content_service_1 = require("../services/content.service");
|
|
22
22
|
const asset_manager_factory_1 = require("../content/factory/asset-manager.factory");
|
|
23
|
+
const asset_service_1 = require("../services/package-manager/asset-service");
|
|
23
24
|
class AssetCommand {
|
|
24
25
|
constructor() {
|
|
25
26
|
this.contentService = new content_service_1.ContentService();
|
|
@@ -40,6 +41,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
41
|
yield this.contentService.batchPush(profile, this.assetManagerFactory.createManagers(packageKey));
|
|
41
42
|
});
|
|
42
43
|
}
|
|
44
|
+
listAssets(profile, jsonResponse, assetType) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (jsonResponse) {
|
|
47
|
+
yield asset_service_1.assetService.findAndExportAllAssets(assetType);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
yield asset_service_1.assetService.listAssets(assetType);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
exports.AssetCommand = AssetCommand;
|
|
45
56
|
});
|
package/content-cli-list.js
CHANGED
|
@@ -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", "./commands/package.command", "./commands/space.command", "commander", "./services/context.service", "./util/logger"], factory);
|
|
16
|
+
define(["require", "exports", "./commands/package.command", "./commands/space.command", "./commands/asset.command", "commander", "./services/context.service", "./util/logger"], 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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
const package_command_1 = require("./commands/package.command");
|
|
23
23
|
const space_command_1 = require("./commands/space.command");
|
|
24
|
+
const asset_command_1 = require("./commands/asset.command");
|
|
24
25
|
const commander = require("commander");
|
|
25
26
|
const context_service_1 = require("./services/context.service");
|
|
26
27
|
const logger_1 = require("./util/logger");
|
|
@@ -50,6 +51,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
50
51
|
}));
|
|
51
52
|
return program;
|
|
52
53
|
}
|
|
54
|
+
static assets(program) {
|
|
55
|
+
program
|
|
56
|
+
.command("assets")
|
|
57
|
+
.description("Command to list all assets")
|
|
58
|
+
.option("-p, --profile <profile>", "Profile which you want to use to list assets")
|
|
59
|
+
.option("--json", "Return response as json type", "")
|
|
60
|
+
.option("--assetType <assetType>", "type of assets")
|
|
61
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
yield new asset_command_1.AssetCommand().listAssets(cmd.profile, cmd.json, cmd.assetType);
|
|
63
|
+
process.exit();
|
|
64
|
+
}));
|
|
65
|
+
return program;
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
68
|
exports.List = List;
|
|
55
69
|
const options = commander.parseOptions(process.argv);
|
|
@@ -60,6 +74,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
60
74
|
context_service_1.contextService.resolveProfile(options.unknown[indexOfProfileOption + 1]).then(() => {
|
|
61
75
|
List.packages(commander);
|
|
62
76
|
List.spaces(commander);
|
|
77
|
+
List.assets(commander);
|
|
63
78
|
commander.parse(process.argv);
|
|
64
79
|
}).catch(e => {
|
|
65
80
|
console.log(e);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SaveContentNode } from "../interfaces/save-content-node.interface";
|
|
2
|
+
declare class AssetApi {
|
|
3
|
+
static readonly INSTANCE: AssetApi;
|
|
4
|
+
findAllAssets(assetType: string): Promise<SaveContentNode[]>;
|
|
5
|
+
private getFindAllAssetsUrl;
|
|
6
|
+
}
|
|
7
|
+
export declare const assetApi: AssetApi;
|
|
8
|
+
export {};
|
|
@@ -4,4 +4,5 @@ export declare class AssetCommand {
|
|
|
4
4
|
pullAsset(profile: string, key: string): Promise<void>;
|
|
5
5
|
pushAsset(profile: string, fileName: string, packageKey: string): Promise<void>;
|
|
6
6
|
pushAssets(profile: string, packageKey: string): Promise<void>;
|
|
7
|
+
listAssets(profile: string, jsonResponse: boolean, assetType: string): Promise<void>;
|
|
7
8
|
}
|
|
@@ -3,5 +3,6 @@ declare type CommanderStatic = commander.CommanderStatic;
|
|
|
3
3
|
export declare class List {
|
|
4
4
|
static packages(program: CommanderStatic): CommanderStatic;
|
|
5
5
|
static spaces(program: CommanderStatic): CommanderStatic;
|
|
6
|
+
static assets(program: CommanderStatic): CommanderStatic;
|
|
6
7
|
}
|
|
7
8
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare class AssetService {
|
|
2
|
+
protected readonly fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
3
|
+
listAssets(assetType: string): Promise<void>;
|
|
4
|
+
findAndExportAllAssets(assetType: string): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare const assetService: AssetService;
|
|
7
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
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", "../../util/logger", "../../api/asset-api", "uuid", "../file-service"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const logger_1 = require("../../util/logger");
|
|
22
|
+
const asset_api_1 = require("../../api/asset-api");
|
|
23
|
+
const uuid_1 = require("uuid");
|
|
24
|
+
const file_service_1 = require("../file-service");
|
|
25
|
+
class AssetService {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
28
|
+
}
|
|
29
|
+
listAssets(assetType) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const nodes = yield asset_api_1.assetApi.findAllAssets(assetType);
|
|
32
|
+
nodes.forEach(node => {
|
|
33
|
+
logger_1.logger.info(`${node.name} - Key: "${node.key}"`);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
findAndExportAllAssets(assetType) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const fieldsToInclude = ["key", "name", "assetType", "rootNodeKey", "activatedDraftId"];
|
|
40
|
+
const nodes = yield asset_api_1.assetApi.findAllAssets(assetType);
|
|
41
|
+
const filename = uuid_1.v4() + ".json";
|
|
42
|
+
file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodes, fieldsToInclude), filename);
|
|
43
|
+
logger_1.logger.info(this.fileDownloadedMessage + filename);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.assetService = new AssetService();
|
|
48
|
+
});
|