@celonis/content-cli 1.2.1 → 1.2.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/commands/configuration-management/batch-import-export.service.js +5 -5
- package/commands/git-profile/git-profile-command.service.js +2 -3
- package/content-cli.js +1 -0
- package/core/git-profile/git/git.service.js +17 -8
- package/core/git-profile/git-profile.interface.js +1 -1
- package/core/git-profile/git-profile.service.js +8 -7
- package/core/git-profile/git-profile.validator.js +1 -5
- package/lib/core/git-profile/git-profile.interface.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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", "uuid", "form-data", "stream", "adm-zip", "./interfaces/batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/batch-import-export-api", "./studio.service", "../../core/git-profile/git/git.service", "
|
|
16
|
+
define(["require", "exports", "uuid", "form-data", "stream", "adm-zip", "./interfaces/batch-export-import.constants", "../../core/utils/file-service", "../../core/utils/logger", "../../core/utils/json", "../studio/api/package-api", "./api/batch-import-export-api", "./studio.service", "../../core/git-profile/git/git.service", "fs"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -31,7 +31,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
const batch_import_export_api_1 = require("./api/batch-import-export-api");
|
|
32
32
|
const studio_service_1 = require("./studio.service");
|
|
33
33
|
const git_service_1 = require("../../core/git-profile/git/git.service");
|
|
34
|
-
const fs = require("
|
|
34
|
+
const fs = require("fs");
|
|
35
35
|
class BatchImportExportService {
|
|
36
36
|
constructor(context) {
|
|
37
37
|
this.batchImportExportApi = new batch_import_export_api_1.BatchImportExportApi(context);
|
|
@@ -121,9 +121,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
123
|
sourceToBeImported = sourcePath;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
}
|
|
125
|
+
if (file_service_1.fileService.isDirectory(sourceToBeImported)) {
|
|
126
|
+
sourceToBeImported = file_service_1.fileService.zipDirectoryInBatchExportFormat(sourceToBeImported);
|
|
127
127
|
}
|
|
128
128
|
let configs = new AdmZip(sourceToBeImported);
|
|
129
129
|
const studioManifests = this.parseEntryData(configs, batch_export_import_constants_1.BatchExportImportConstants.STUDIO_FILE_NAME);
|
|
@@ -35,11 +35,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35
35
|
profile.name = yield questions.ask("Name of the Git profile to create: ");
|
|
36
36
|
profile.username = yield questions.ask("Your Git username: ");
|
|
37
37
|
profile.repository = yield questions.ask("Your repository (format: repoOwner/repoName): ");
|
|
38
|
-
const type = yield questions.ask("Authentication type:
|
|
38
|
+
const type = yield questions.ask("Authentication type: HTTPS (1), SSH token (2): ");
|
|
39
39
|
switch (type) {
|
|
40
40
|
case "1":
|
|
41
|
-
profile.authenticationType = git_profile_interface_1.AuthenticationType.
|
|
42
|
-
profile.token = yield questions.ask("Your Personal Access Token (PAT): ");
|
|
41
|
+
profile.authenticationType = git_profile_interface_1.AuthenticationType.HTTPS;
|
|
43
42
|
break;
|
|
44
43
|
case "2":
|
|
45
44
|
profile.authenticationType = git_profile_interface_1.AuthenticationType.SSH;
|
package/content-cli.js
CHANGED
|
@@ -47,6 +47,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
47
47
|
program.version(version_1.VersionUtils.getCurrentCliVersion());
|
|
48
48
|
program.option("-q, --quietmode", "Reduce output to a minimum", false);
|
|
49
49
|
program.option("-p, --profile [profile]");
|
|
50
|
+
program.option("--gitProfile [gitProfile]", "Git profile to use");
|
|
50
51
|
program.option("--debug", "Print debug messages", false);
|
|
51
52
|
program.option("--dev", "Development Mode", false);
|
|
52
53
|
program.parseOptions(process.argv);
|
|
@@ -55,7 +55,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
55
55
|
const repoUrl = this.getRepoUrl();
|
|
56
56
|
const git = (0, simple_git_1.default)();
|
|
57
57
|
try {
|
|
58
|
-
yield git.clone(repoUrl, workingDir
|
|
58
|
+
yield git.clone(repoUrl, workingDir);
|
|
59
59
|
const repoGit = (0, simple_git_1.default)({ baseDir: workingDir });
|
|
60
60
|
yield repoGit.addConfig("user.name", (_a = this.gitProfile.username) !== null && _a !== void 0 ? _a : "content-cli");
|
|
61
61
|
yield repoGit.addConfig("user.email", `${(_b = this.gitProfile.username) !== null && _b !== void 0 ? _b : "cli"}@users.noreply.github.com`);
|
|
@@ -92,12 +92,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
92
92
|
checkoutOrCreateLocalBranch(git, branch) {
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
94
|
const branches = yield git.branch();
|
|
95
|
-
if (
|
|
96
|
-
|
|
95
|
+
if (branches.current === branch) {
|
|
96
|
+
return;
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
yield git.checkout(
|
|
98
|
+
if (branches.all.includes(branch)) {
|
|
99
|
+
yield git.checkout(branch);
|
|
100
|
+
return;
|
|
100
101
|
}
|
|
102
|
+
if (branches.all.includes(`remotes/origin/${branch}`)) {
|
|
103
|
+
yield git.checkout(["--track", `origin/${branch}`]);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
yield git.checkoutLocalBranch(branch);
|
|
101
107
|
});
|
|
102
108
|
}
|
|
103
109
|
getRepoUrl() {
|
|
@@ -105,9 +111,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
105
111
|
if (authenticationType === "SSH") {
|
|
106
112
|
return `git@github.com:${repository}.git`;
|
|
107
113
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
if (token) {
|
|
115
|
+
const safeUsername = encodeURIComponent(username !== null && username !== void 0 ? username : "git");
|
|
116
|
+
const safeToken = encodeURIComponent(token);
|
|
117
|
+
return `https://${safeUsername}:${safeToken}@github.com/${repository}.git`;
|
|
118
|
+
}
|
|
119
|
+
return `https://github.com/${repository}.git`;
|
|
111
120
|
}
|
|
112
121
|
cleanupGitDirectory(repoDirectory) {
|
|
113
122
|
const gitPath = path.join(repoDirectory, ".git");
|
|
@@ -34,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
findProfile(profileName) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
36
|
return new Promise((resolve, reject) => {
|
|
37
|
-
if (process.env.
|
|
37
|
+
if (process.env.GIT_USERNAME && process.env.GIT_TOKEN && process.env.GIT_REPOSITORY) {
|
|
38
38
|
resolve(this.buildProfileFromEnvVariables());
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
@@ -59,7 +59,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
59
59
|
resolve(profile);
|
|
60
60
|
})
|
|
61
61
|
.catch(err => {
|
|
62
|
-
logger_1.logger.error(new logger_1.FatalError("Git Profile does not
|
|
62
|
+
logger_1.logger.error(new logger_1.FatalError("Git Profile does not exist."));
|
|
63
63
|
reject(err);
|
|
64
64
|
});
|
|
65
65
|
});
|
|
@@ -85,10 +85,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
86
|
const profileVariables = this.getProfileEnvVariables();
|
|
87
87
|
const profile = {
|
|
88
|
-
name:
|
|
88
|
+
name: "env-profile",
|
|
89
|
+
username: profileVariables.username,
|
|
89
90
|
repository: profileVariables.repository,
|
|
90
|
-
token: profileVariables.
|
|
91
|
-
authenticationType: git_profile_interface_1.AuthenticationType.
|
|
91
|
+
token: profileVariables.token,
|
|
92
|
+
authenticationType: git_profile_interface_1.AuthenticationType.HTTPS,
|
|
92
93
|
};
|
|
93
94
|
profile.authenticationType = yield git_profile_validator_1.GitProfileValidator.validateProfile(profile);
|
|
94
95
|
return profile;
|
|
@@ -123,9 +124,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
123
124
|
}
|
|
124
125
|
getProfileEnvVariables() {
|
|
125
126
|
return {
|
|
126
|
-
username: process.env.
|
|
127
|
+
username: process.env.GIT_USERNAME,
|
|
127
128
|
token: process.env.GIT_TOKEN,
|
|
128
|
-
repository: process.env.
|
|
129
|
+
repository: process.env.GIT_REPOSITORY,
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
}
|
|
@@ -13,14 +13,13 @@ 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", "../utils/logger"
|
|
16
|
+
define(["require", "exports", "../utils/logger"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.GitProfileValidator = void 0;
|
|
22
22
|
const logger_1 = require("../utils/logger");
|
|
23
|
-
const git_profile_interface_1 = require("./git-profile.interface");
|
|
24
23
|
class GitProfileValidator {
|
|
25
24
|
static validateProfile(gitProfile) {
|
|
26
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -36,9 +35,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
36
35
|
if (gitProfile.authenticationType == null) {
|
|
37
36
|
logger_1.logger.error(new logger_1.FatalError("The authentication type can not be empty"));
|
|
38
37
|
}
|
|
39
|
-
if (gitProfile.authenticationType === git_profile_interface_1.AuthenticationType.PAT && gitProfile.token == null) {
|
|
40
|
-
logger_1.logger.error(new logger_1.FatalError("The token can not be empty for authentication with PAT"));
|
|
41
|
-
}
|
|
42
38
|
});
|
|
43
39
|
}
|
|
44
40
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export interface GitProfile {
|
|
2
2
|
name: string;
|
|
3
3
|
username?: string;
|
|
4
|
-
repository: string;
|
|
5
4
|
token?: string;
|
|
5
|
+
repository: string;
|
|
6
6
|
authenticationType: AuthenticationType;
|
|
7
7
|
}
|
|
8
|
-
export type AuthenticationType = "SSH" | "
|
|
8
|
+
export type AuthenticationType = "SSH" | "HTTPS";
|
|
9
9
|
export declare const AuthenticationType: {
|
|
10
10
|
[key: string]: AuthenticationType;
|
|
11
11
|
};
|