@magnolia/cli-jumpstart-plugin 1.0.0-preview.5 → 1.0.0-preview.7
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/README.md +28 -139
- package/dist/jumpstart-plugin.d.ts +3 -0
- package/dist/jumpstart-plugin.js +43 -26
- package/dist/lib/config-helper.js +45 -44
- package/dist/lib/download.js +75 -23
- package/dist/lib/extensions.js +4 -6
- package/dist/lib/extract.js +11 -5
- package/dist/lib/handleMicroprofileConfig.d.ts +3 -0
- package/dist/lib/handleMicroprofileConfig.js +61 -0
- package/dist/lib/helper.d.ts +5 -4
- package/dist/lib/helper.js +29 -39
- package/dist/lib/install.js +6 -7
- package/dist/lib/locales/en/translation.json +78 -65
- package/dist/lib/pj-helper.js +18 -17
- package/dist/package.json +2 -4
- package/dist/types/types.d.ts +6 -2
- package/package.json +2 -4
package/dist/lib/download.js
CHANGED
|
@@ -9,22 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import path from "path";
|
|
11
11
|
import fs from "fs-extra";
|
|
12
|
-
import axios from "axios";
|
|
13
12
|
import ProgressBar from "progress";
|
|
14
13
|
import inquirer from "inquirer";
|
|
15
14
|
import { i18nInstance, logger } from "../jumpstart-plugin.js";
|
|
15
|
+
import { askForCredentials } from "./helper.js";
|
|
16
|
+
import axios from "axios";
|
|
16
17
|
export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
try {
|
|
18
19
|
let url = bundle.url;
|
|
19
20
|
const downloadDest = dest ? dest : "./download-" + new Date().getTime();
|
|
20
21
|
let downloadUrl;
|
|
21
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-preparing", {
|
|
22
|
-
url
|
|
23
|
-
}));
|
|
24
22
|
if (path.parse(url).name === "tags") {
|
|
25
23
|
downloadUrl = yield selectTag(url, credentials);
|
|
26
24
|
}
|
|
27
25
|
else if (url.includes('https://nexus.magnolia-cms.com/service/rest/v1/search')) {
|
|
26
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-preparing", {
|
|
27
|
+
url
|
|
28
|
+
}));
|
|
28
29
|
downloadUrl = yield getDownloadUrl(bundle, credentials, options);
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
@@ -45,16 +46,16 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
45
46
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-starting", {
|
|
46
47
|
downloadUrl: downloadUrl
|
|
47
48
|
}));
|
|
48
|
-
const res = yield
|
|
49
|
+
const res = yield get(downloadUrl, opts, credentials, bundle.name || bundle.url);
|
|
49
50
|
if (res.status !== 200) {
|
|
50
|
-
throw new Error(i18nInstance.t("
|
|
51
|
+
throw new Error(i18nInstance.t("error-download-fail-status", {
|
|
51
52
|
downloadUrl: downloadUrl,
|
|
52
53
|
status: res.status
|
|
53
54
|
}));
|
|
54
55
|
}
|
|
55
56
|
if (res.headers['content-length']) {
|
|
56
57
|
const len = parseInt(res.headers['content-length'], 10);
|
|
57
|
-
const bar = new ProgressBar('
|
|
58
|
+
const bar = new ProgressBar(`${i18nInstance.t('progress-bar-downloading')} [:bar] :percent :etas`, {
|
|
58
59
|
complete: '=',
|
|
59
60
|
incomplete: ' ',
|
|
60
61
|
width: 20,
|
|
@@ -67,7 +68,6 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
67
68
|
res.data.pipe(target);
|
|
68
69
|
return new Promise((resolve) => {
|
|
69
70
|
target.on('finish', () => {
|
|
70
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-finished"));
|
|
71
71
|
resolve(path.join('.', tempDownload));
|
|
72
72
|
});
|
|
73
73
|
target.on('error', (error) => {
|
|
@@ -81,11 +81,12 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
84
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-downloading-bundle', { url: bundle.url }));
|
|
84
85
|
throw new Error(error);
|
|
85
86
|
}
|
|
86
87
|
});
|
|
87
88
|
export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
-
var _a, _b, _c;
|
|
89
|
+
var _a, _b, _c, _d, _e, _f;
|
|
89
90
|
const opts = {
|
|
90
91
|
method: 'get',
|
|
91
92
|
responseType: 'json',
|
|
@@ -102,22 +103,29 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
102
103
|
if (bundle.version) {
|
|
103
104
|
if (options.snapshot || bundle.version.toLowerCase().includes("snapshot")) {
|
|
104
105
|
url.searchParams.set('prerelease', "true");
|
|
106
|
+
if (options.magnolia === undefined && !bundle.version.match(/^\d/)) {
|
|
107
|
+
options.magnolia = "6.2";
|
|
108
|
+
}
|
|
105
109
|
}
|
|
106
|
-
if (options.
|
|
107
|
-
bundle.version = options.
|
|
110
|
+
if (options.magnolia) {
|
|
111
|
+
bundle.version = options.magnolia;
|
|
112
|
+
if ((bundle.version.startsWith('6.3') || bundle.version.includes('alpha') || bundle.version.includes('beta') || bundle.version.includes('rc')) && bundle.alternative) {
|
|
113
|
+
url.searchParams.set('maven.groupId', bundle.alternative.groupId);
|
|
114
|
+
url.searchParams.set('maven.artifactId', bundle.alternative.artifactId);
|
|
115
|
+
}
|
|
108
116
|
}
|
|
109
|
-
if (bundle.version.toLowerCase() !== "latest" && bundle.version.toLowerCase() !== "alpha" && bundle.version.toLowerCase() !== "beta") {
|
|
110
|
-
url.searchParams.set('maven.baseVersion', bundle.version);
|
|
117
|
+
if (bundle.version.toLowerCase() !== "latest" && bundle.version.toLowerCase() !== "alpha" && bundle.version.toLowerCase() !== "beta" && bundle.version.toLowerCase() !== "rc") {
|
|
118
|
+
url.searchParams.set('maven.baseVersion', options.snapshot ? bundle.version + "-SNAPSHOT" : bundle.version);
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
|
-
|
|
121
|
+
let response = yield get(url.toString(), opts, credentials, bundle.name || bundle.url);
|
|
114
122
|
const params = new URLSearchParams(bundle.url.split("?")[1]);
|
|
115
123
|
let item = response.data.items[0];
|
|
116
124
|
if (((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "latest") {
|
|
117
125
|
item = response.data.items.find((item) => {
|
|
118
126
|
var _a;
|
|
119
127
|
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
120
|
-
return !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-alpha")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta"));
|
|
128
|
+
return !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-alpha")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-rc"));
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
else if (((_b = bundle.version) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "alpha") {
|
|
@@ -134,9 +142,17 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
134
142
|
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta");
|
|
135
143
|
});
|
|
136
144
|
}
|
|
145
|
+
else if (((_d = bundle.version) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === "rc") {
|
|
146
|
+
item = response.data.items.find((item) => {
|
|
147
|
+
var _a;
|
|
148
|
+
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
149
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-rc");
|
|
150
|
+
});
|
|
151
|
+
}
|
|
137
152
|
if (!item) {
|
|
138
|
-
throw new Error(i18nInstance.t('error-
|
|
153
|
+
throw new Error(i18nInstance.t('error-no-artifact-available', { version: bundle.version }));
|
|
139
154
|
}
|
|
155
|
+
bundle.version = (_f = (_e = item === null || item === void 0 ? void 0 : item.maven2) === null || _e === void 0 ? void 0 : _e.version) !== null && _f !== void 0 ? _f : bundle.version;
|
|
140
156
|
let downloadUrl = item.downloadUrl;
|
|
141
157
|
downloadUrl = downloadUrl === null || downloadUrl === void 0 ? void 0 : downloadUrl.split('/magnolia.');
|
|
142
158
|
downloadUrl = downloadUrl && `${downloadUrl[0]}/${params.get('repository')}${item.path}`;
|
|
@@ -144,16 +160,16 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
144
160
|
}
|
|
145
161
|
catch (error) {
|
|
146
162
|
if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
|
|
147
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-
|
|
163
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-problem-accessing-url", {
|
|
148
164
|
url: bundle.url
|
|
149
165
|
}));
|
|
150
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-
|
|
166
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-unable-to-get-local-issuer-certificate"));
|
|
151
167
|
}
|
|
152
168
|
throw new Error(error.message);
|
|
153
169
|
}
|
|
154
170
|
});
|
|
155
171
|
export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
var
|
|
172
|
+
var _g;
|
|
157
173
|
const opts = {
|
|
158
174
|
method: 'get',
|
|
159
175
|
headers: {
|
|
@@ -163,18 +179,54 @@ export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0,
|
|
|
163
179
|
if (credentials && credentials.username && credentials.password) {
|
|
164
180
|
opts.auth = credentials;
|
|
165
181
|
}
|
|
166
|
-
const res = yield
|
|
167
|
-
if (!((
|
|
168
|
-
throw new Error(i18nInstance.t("error-
|
|
182
|
+
const res = yield get(url, opts, credentials);
|
|
183
|
+
if (!((_g = res.data) === null || _g === void 0 ? void 0 : _g.values) || res.data.values.length <= 0) {
|
|
184
|
+
throw new Error(i18nInstance.t("error-no-tags"));
|
|
169
185
|
}
|
|
170
186
|
const { tag } = yield inquirer
|
|
171
187
|
.prompt([
|
|
172
188
|
{
|
|
173
189
|
type: 'rawlist',
|
|
174
190
|
name: 'tag',
|
|
175
|
-
message: '
|
|
191
|
+
message: i18nInstance.t('inquirer-prompt-select-tag'),
|
|
176
192
|
choices: res.data.values.map((tag) => ({ name: tag.displayId, value: "archive?at=" + tag.id }))
|
|
177
193
|
}
|
|
178
194
|
]);
|
|
179
195
|
return url.slice(0, url.length - 4) + tag;
|
|
180
196
|
});
|
|
197
|
+
function get(url, opts, credentials, bundleName) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
let res;
|
|
200
|
+
if (bundleName === undefined) {
|
|
201
|
+
bundleName = url;
|
|
202
|
+
}
|
|
203
|
+
const handleAuthFail = () => __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
if (credentials) {
|
|
205
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-auth-fail", { url }));
|
|
206
|
+
const newCredentials = yield askForCredentials(bundleName);
|
|
207
|
+
credentials.username = (newCredentials === null || newCredentials === void 0 ? void 0 : newCredentials.username) || "";
|
|
208
|
+
credentials.password = (newCredentials === null || newCredentials === void 0 ? void 0 : newCredentials.password) || "";
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
while (true) {
|
|
212
|
+
try {
|
|
213
|
+
res = yield axios.get(url, opts);
|
|
214
|
+
if (res.status === 401 && credentials) {
|
|
215
|
+
yield handleAuthFail();
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
if (e.response.status === 401 && credentials) {
|
|
223
|
+
yield handleAuthFail();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
throw Error(e);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return res;
|
|
231
|
+
});
|
|
232
|
+
}
|
package/dist/lib/extensions.js
CHANGED
|
@@ -79,23 +79,21 @@ export const evaluateCustomPrompts = (extensionsPath) => __awaiter(void 0, void
|
|
|
79
79
|
const baseDir = path.parse(extensionsPath).dir;
|
|
80
80
|
const packageJson = path.join(baseDir, 'package.json');
|
|
81
81
|
if (fs.existsSync(packageJson)) {
|
|
82
|
-
const npmISpinner = ora().start(i18nInstance.t("ora-installing-ext-dep"));
|
|
82
|
+
const npmISpinner = ora().start(i18nInstance.t("ora-start-installing-ext-dep"));
|
|
83
83
|
const packageManager = determinePackageManager(baseDir);
|
|
84
84
|
try {
|
|
85
85
|
yield execa(packageManager, ["install"], {
|
|
86
86
|
buffer: true,
|
|
87
87
|
cwd: baseDir
|
|
88
88
|
});
|
|
89
|
+
npmISpinner.succeed(i18nInstance.t("ora-succeed-extensions-install-done"));
|
|
89
90
|
}
|
|
90
91
|
catch (e) {
|
|
91
|
-
npmISpinner.
|
|
92
|
-
|
|
93
|
-
packageManager: packageManager
|
|
92
|
+
npmISpinner.fail(i18nInstance.t("ora-fail-pm-install", {
|
|
93
|
+
packageManager: packageManager, errorMsg: e.message
|
|
94
94
|
}));
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
npmISpinner.stop();
|
|
98
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-extensions-install-done"));
|
|
99
97
|
}
|
|
100
98
|
try {
|
|
101
99
|
const extensions = doc.extend ? yield import(pathToFileURL(path.join(baseDir, doc.extend)).href) : null;
|
package/dist/lib/extract.js
CHANGED
|
@@ -13,11 +13,13 @@ import walk from "walk";
|
|
|
13
13
|
import fs from "fs-extra";
|
|
14
14
|
import { PostCommands } from "../types/types.js";
|
|
15
15
|
import url from "url";
|
|
16
|
-
import { i18nInstance
|
|
16
|
+
import { i18nInstance } from "../jumpstart-plugin.js";
|
|
17
|
+
import { handleMicroprofileConfig } from "./handleMicroprofileConfig.js";
|
|
18
|
+
import ora from "ora";
|
|
17
19
|
export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
20
|
var _a;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const spinner = ora().start(i18nInstance.t("ora-start-extracting"));
|
|
22
|
+
let { dest = "./" } = bundle;
|
|
21
23
|
const unzipFolder = "temp-" + new Date().getTime();
|
|
22
24
|
yield decompress(file, unzipFolder);
|
|
23
25
|
if (command === PostCommands.ExtractAndOverride) {
|
|
@@ -25,7 +27,9 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
|
|
|
25
27
|
}
|
|
26
28
|
const artifactId = (_a = url.parse(bundle.url, true)) === null || _a === void 0 ? void 0 : _a.query['maven.artifactId'];
|
|
27
29
|
if (artifactId === 'magnolia-tomcat-barebone') {
|
|
30
|
+
dest = path.join(dest, 'apache-tomcat');
|
|
28
31
|
yield extractApacheTomcat(dest, unzipFolder);
|
|
32
|
+
spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', { path: path.resolve(dest) }));
|
|
29
33
|
}
|
|
30
34
|
else {
|
|
31
35
|
let sourceFolder = unzipFolder;
|
|
@@ -37,6 +41,8 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
|
|
|
37
41
|
sourceFolder = firstDir ? path.join(unzipFolder, firstDir) : unzipFolder;
|
|
38
42
|
}
|
|
39
43
|
fs.copySync(sourceFolder, dest, { overwrite: true });
|
|
44
|
+
spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', { path: path.resolve(dest) }));
|
|
45
|
+
yield handleMicroprofileConfig(bundle, dest);
|
|
40
46
|
}
|
|
41
47
|
fs.rmSync(unzipFolder, { recursive: true, force: true });
|
|
42
48
|
fs.rmSync(path.dirname(file), { recursive: true, force: true });
|
|
@@ -44,7 +50,7 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
|
|
|
44
50
|
export const extractApacheTomcat = (dest, unzipFolder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
51
|
const apacheTomcatDir = yield findExtractedApacheTomcatDir(unzipFolder);
|
|
46
52
|
fs.rmSync(path.join(apacheTomcatDir, 'webapps', 'magnoliaAuthor'), { recursive: true, force: true });
|
|
47
|
-
fs.copySync(apacheTomcatDir,
|
|
53
|
+
fs.copySync(apacheTomcatDir, dest, { overwrite: false });
|
|
48
54
|
});
|
|
49
55
|
export const findExtractedApacheTomcatDir = (p) => {
|
|
50
56
|
return new Promise((resolve, reject) => {
|
|
@@ -56,7 +62,7 @@ export const findExtractedApacheTomcatDir = (p) => {
|
|
|
56
62
|
next();
|
|
57
63
|
});
|
|
58
64
|
walker.on('end', function () {
|
|
59
|
-
return reject(new Error(i18nInstance.t("error-
|
|
65
|
+
return reject(new Error(i18nInstance.t("error-apache-tomcat-not-found")));
|
|
60
66
|
});
|
|
61
67
|
});
|
|
62
68
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
import fs from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { getMicroprofileConfigLocation } from "./helper.js";
|
|
13
|
+
import { i18nInstance, logger } from "../jumpstart-plugin.js";
|
|
14
|
+
export const handleMicroprofileConfig = (bundle, dest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.startsWith("6.3")))
|
|
17
|
+
return;
|
|
18
|
+
const tomcatPath = path.join(path.resolve(dest), '../../');
|
|
19
|
+
const webappName = path.basename(dest);
|
|
20
|
+
const pathToMicroprofileConfig = getMicroprofileConfigLocation(tomcatPath, webappName);
|
|
21
|
+
processMicroprofileConfigFile(pathToMicroprofileConfig);
|
|
22
|
+
});
|
|
23
|
+
export function convertObjectToProperties(obj) {
|
|
24
|
+
const props = [];
|
|
25
|
+
Object.keys(obj).forEach((key) => {
|
|
26
|
+
const val = obj[key];
|
|
27
|
+
if (val && typeof val === 'object' && !Array.isArray(val)) {
|
|
28
|
+
const children = convertObjectToProperties(val);
|
|
29
|
+
for (const child of children) {
|
|
30
|
+
props.push(key + '.' + child);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
props.push(key + '=' + val);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return props;
|
|
38
|
+
}
|
|
39
|
+
function createMicroprofileConfigFile(file) {
|
|
40
|
+
const microprofileConfig = {
|
|
41
|
+
magnolia: {
|
|
42
|
+
publishing: {
|
|
43
|
+
'receivers[0]': {
|
|
44
|
+
name: 'magnoliaPublic8080',
|
|
45
|
+
url: 'http://localhost:8080/magnoliaPublic',
|
|
46
|
+
enabled: true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
fs.writeFileSync(file, convertObjectToProperties(microprofileConfig).join('\n'), 'utf8');
|
|
52
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-created-microprofile', { file }));
|
|
53
|
+
}
|
|
54
|
+
function processMicroprofileConfigFile(file) {
|
|
55
|
+
if (fs.existsSync(file)) {
|
|
56
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-microprofile-exists'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
createMicroprofileConfigFile(file);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/lib/helper.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ export declare const handleLightModulesFolder: () => Promise<void>;
|
|
|
5
5
|
export declare const findLightModulesFolder: (p: string) => Promise<unknown>;
|
|
6
6
|
export declare const findWebAppsList: (apacheTomcatPath: string) => string[];
|
|
7
7
|
export declare const initializeNodeProject: () => Promise<void>;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const extractRepoName: (gitUrl: string) => string | null;
|
|
8
|
+
export declare const installCLI: () => Promise<boolean>;
|
|
9
|
+
export declare const installPackage: (packageManager: string, packageReference: string, packageName?: string) => Promise<boolean>;
|
|
11
10
|
export declare const determinePackageManager: (baseDirectory?: string) => "yarn" | "npm";
|
|
12
|
-
export declare const askForCredentials: () => Promise<Credentials>;
|
|
11
|
+
export declare const askForCredentials: (bundle: string) => Promise<Credentials>;
|
|
12
|
+
export declare function getWebAppConfigDefaultFolderLocation(tomcatFolder: string, instance: string): string;
|
|
13
|
+
export declare function getMicroprofileConfigLocation(tomcatFolder: string, instance: string): string;
|
package/dist/lib/helper.js
CHANGED
|
@@ -57,22 +57,21 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
|
|
|
57
57
|
let lightModulesPath;
|
|
58
58
|
try {
|
|
59
59
|
lightModulesPath = (yield findLightModulesFolder(process.cwd()));
|
|
60
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-
|
|
60
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-found-lm", {
|
|
61
61
|
lightModulesPath: lightModulesPath
|
|
62
62
|
}));
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-no-lm-found"));
|
|
66
65
|
lightModulesPath = path.join(process.cwd(), 'light-modules');
|
|
67
66
|
try {
|
|
68
67
|
fs.mkdirSync(lightModulesPath, { recursive: true });
|
|
69
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-
|
|
68
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-lm-created", {
|
|
70
69
|
lightModulesPath: lightModulesPath
|
|
71
70
|
}));
|
|
72
71
|
}
|
|
73
72
|
catch (error) {
|
|
74
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-
|
|
75
|
-
errorMsg: error
|
|
73
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-lm-create-fail", {
|
|
74
|
+
errorMsg: error.message
|
|
76
75
|
}));
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
@@ -82,8 +81,8 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
|
|
|
82
81
|
apacheTomcatPath = yield findExtractedApacheTomcatDir(process.cwd());
|
|
83
82
|
}
|
|
84
83
|
catch (error) {
|
|
85
|
-
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-
|
|
86
|
-
errorMsg: error
|
|
84
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-cannot-modify-webapp", {
|
|
85
|
+
errorMsg: error.message
|
|
87
86
|
}));
|
|
88
87
|
return;
|
|
89
88
|
}
|
|
@@ -103,7 +102,7 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
|
|
|
103
102
|
});
|
|
104
103
|
const editProperties = (filePath, props) => {
|
|
105
104
|
if (!fs.existsSync(filePath)) {
|
|
106
|
-
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-
|
|
105
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-webapp-props-not-exist", {
|
|
107
106
|
filePath: filePath
|
|
108
107
|
}));
|
|
109
108
|
return;
|
|
@@ -113,7 +112,7 @@ const editProperties = (filePath, props) => {
|
|
|
113
112
|
try {
|
|
114
113
|
fs.writeFileSync(filePath, replacedContent);
|
|
115
114
|
Object.keys(props).forEach((key) => {
|
|
116
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-
|
|
115
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-webapp-prop-setting", {
|
|
117
116
|
key: key,
|
|
118
117
|
propsKey: props[key],
|
|
119
118
|
filePath: filePath
|
|
@@ -121,8 +120,8 @@ const editProperties = (filePath, props) => {
|
|
|
121
120
|
});
|
|
122
121
|
}
|
|
123
122
|
catch (error) {
|
|
124
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-
|
|
125
|
-
errorMsg: error
|
|
123
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-webapp-props-update-error", {
|
|
124
|
+
errorMsg: error.message, path: filePath
|
|
126
125
|
}));
|
|
127
126
|
}
|
|
128
127
|
};
|
|
@@ -144,7 +143,7 @@ export const findLightModulesFolder = (p) => {
|
|
|
144
143
|
next();
|
|
145
144
|
});
|
|
146
145
|
walker.on('end', function () {
|
|
147
|
-
return reject(new Error(i18nInstance.t("error-
|
|
146
|
+
return reject(new Error(i18nInstance.t("error-lm-not-found")));
|
|
148
147
|
});
|
|
149
148
|
});
|
|
150
149
|
};
|
|
@@ -164,17 +163,14 @@ export const initializeNodeProject = () => __awaiter(void 0, void 0, void 0, fun
|
|
|
164
163
|
yield handlePackageJSON();
|
|
165
164
|
yield handleMGNLConfigFile();
|
|
166
165
|
});
|
|
167
|
-
export const
|
|
166
|
+
export const installCLI = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
|
+
return yield installPackage(determinePackageManager(), "@magnolia/cli@preview", "mgnl-cli");
|
|
168
|
+
});
|
|
169
|
+
export const installPackage = (packageManager, packageReference, packageName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
170
|
if (!packageName) {
|
|
169
171
|
packageName = packageReference;
|
|
170
172
|
}
|
|
171
|
-
|
|
172
|
-
if (credentials === undefined) {
|
|
173
|
-
credentials = yield askForCredentials();
|
|
174
|
-
}
|
|
175
|
-
packageReference = packageReference.replace("git+https://git.magnolia-cms.com", `git+https://${credentials.username}:${credentials.password}@git.magnolia-cms.com`);
|
|
176
|
-
}
|
|
177
|
-
const spinner = ora().start(i18nInstance.t("ora-installing-package", {
|
|
173
|
+
const spinner = ora().start(i18nInstance.t("ora-start-installing-package", {
|
|
178
174
|
packageName: packageName
|
|
179
175
|
}));
|
|
180
176
|
try {
|
|
@@ -182,33 +178,18 @@ export const installPackage = (packageManager, packageReference, packageName, cr
|
|
|
182
178
|
buffer: true,
|
|
183
179
|
cwd: process.cwd()
|
|
184
180
|
});
|
|
185
|
-
spinner.
|
|
186
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-package-installed", {
|
|
181
|
+
spinner.succeed(i18nInstance.t("ora-succeed-package-installed", {
|
|
187
182
|
packageName: packageName
|
|
188
183
|
}));
|
|
189
184
|
return true;
|
|
190
185
|
}
|
|
191
186
|
catch (error) {
|
|
192
|
-
spinner.
|
|
193
|
-
|
|
194
|
-
packageName: packageName
|
|
187
|
+
spinner.fail(i18nInstance.t("ora-fail-installing-package", {
|
|
188
|
+
packageName: packageName, errorMsg: error.message
|
|
195
189
|
}));
|
|
196
190
|
return false;
|
|
197
191
|
}
|
|
198
192
|
});
|
|
199
|
-
export const isValidURL = (str) => {
|
|
200
|
-
try {
|
|
201
|
-
new URL(str);
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
catch (_) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
export const extractRepoName = (gitUrl) => {
|
|
209
|
-
const match = gitUrl.match(/\/([^/]+?)(?:\.git)?$/);
|
|
210
|
-
return match ? match[1] : null;
|
|
211
|
-
};
|
|
212
193
|
export const determinePackageManager = (baseDirectory = process.cwd()) => {
|
|
213
194
|
const yarnLockPath = path.join(baseDirectory, 'yarn.lock');
|
|
214
195
|
const packageLockPath = path.join(baseDirectory, 'package-lock.json');
|
|
@@ -221,7 +202,10 @@ export const determinePackageManager = (baseDirectory = process.cwd()) => {
|
|
|
221
202
|
// Default to npm
|
|
222
203
|
return 'npm';
|
|
223
204
|
};
|
|
224
|
-
export const askForCredentials = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
205
|
+
export const askForCredentials = (bundle) => __awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-enter-credentials", {
|
|
207
|
+
bundle: bundle
|
|
208
|
+
}));
|
|
225
209
|
return inquirer.prompt([
|
|
226
210
|
{
|
|
227
211
|
type: 'input',
|
|
@@ -235,3 +219,9 @@ export const askForCredentials = () => __awaiter(void 0, void 0, void 0, functio
|
|
|
235
219
|
}
|
|
236
220
|
]);
|
|
237
221
|
});
|
|
222
|
+
export function getWebAppConfigDefaultFolderLocation(tomcatFolder, instance) {
|
|
223
|
+
return path.join(tomcatFolder, 'webapps', instance, 'WEB-INF', 'config', 'default');
|
|
224
|
+
}
|
|
225
|
+
export function getMicroprofileConfigLocation(tomcatFolder, instance) {
|
|
226
|
+
return path.join(getWebAppConfigDefaultFolderLocation(tomcatFolder, instance), 'microprofile-config.properties');
|
|
227
|
+
}
|
package/dist/lib/install.js
CHANGED
|
@@ -11,19 +11,18 @@ import { PostCommands } from "../types/types.js";
|
|
|
11
11
|
import path from "path";
|
|
12
12
|
import { execa } from "execa";
|
|
13
13
|
import ora from 'ora';
|
|
14
|
-
import { i18nInstance
|
|
14
|
+
import { i18nInstance } from "../jumpstart-plugin.js";
|
|
15
15
|
export const installDependencies = (bundle, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const
|
|
16
|
+
const pm = command === PostCommands.YarnInstall ? 'yarn' : 'npm';
|
|
17
|
+
const spinner = ora().start(i18nInstance.t("ora-start-running-pm-install", { packageManager: pm }));
|
|
17
18
|
try {
|
|
18
|
-
yield execa(
|
|
19
|
+
yield execa(pm, ['install'], {
|
|
19
20
|
buffer: true,
|
|
20
21
|
cwd: path.join(process.cwd(), bundle.dest ? bundle.dest : "./")
|
|
21
22
|
});
|
|
22
|
-
spinner.
|
|
23
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-install-dep"));
|
|
23
|
+
spinner.succeed(i18nInstance.t('ora-succeed-pm-install', { packageManager: pm }));
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
spinner.
|
|
27
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-install-dep-fail"));
|
|
26
|
+
spinner.fail(i18nInstance.t("ora-fail-pm-install", { packageManager: pm, errorMsg: e.message }));
|
|
28
27
|
}
|
|
29
28
|
});
|