@magnolia/cli-jumpstart-plugin 1.0.1 → 1.0.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/CHANGELOG.md +15 -0
- package/README.md +3 -3
- package/dist/jumpstart-plugin.d.ts +2 -2
- package/dist/jumpstart-plugin.js +49 -39
- package/dist/lib/config-helper.d.ts +1 -1
- package/dist/lib/config-helper.js +71 -48
- package/dist/lib/download.d.ts +1 -1
- package/dist/lib/download.js +104 -71
- package/dist/lib/extensions.d.ts +3 -1
- package/dist/lib/extensions.js +36 -48
- package/dist/lib/extract.d.ts +1 -1
- package/dist/lib/extract.js +54 -38
- package/dist/lib/handleMicroprofileConfig.d.ts +1 -1
- package/dist/lib/handleMicroprofileConfig.js +9 -9
- package/dist/lib/helper.d.ts +3 -1
- package/dist/lib/helper.js +80 -46
- package/dist/lib/install.d.ts +1 -1
- package/dist/lib/install.js +10 -7
- package/dist/lib/locales/en/translation.json +85 -76
- package/dist/lib/pj-helper.js +34 -24
- package/dist/package.json +75 -57
- package/package.json +75 -57
package/dist/lib/download.js
CHANGED
|
@@ -7,25 +7,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import path from
|
|
11
|
-
import fs from
|
|
12
|
-
import ProgressBar from
|
|
13
|
-
import inquirer from
|
|
14
|
-
import { i18nInstance, logger } from
|
|
15
|
-
import { askForCredentials } from
|
|
16
|
-
import axios from
|
|
17
|
-
import { CreateError } from
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import fs from 'fs-extra';
|
|
12
|
+
import ProgressBar from 'progress';
|
|
13
|
+
import inquirer from 'inquirer';
|
|
14
|
+
import { i18nInstance, logger } from '../jumpstart-plugin.js';
|
|
15
|
+
import { askForCredentials } from './helper.js';
|
|
16
|
+
import axios from 'axios';
|
|
17
|
+
import { CreateError, prependNumbersToChoices, } from '@magnolia/cli-helper/general-utils';
|
|
18
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
19
|
+
import { HttpProxyAgent } from 'http-proxy-agent';
|
|
18
20
|
export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
21
|
try {
|
|
20
|
-
|
|
21
|
-
const downloadDest = dest ? dest :
|
|
22
|
+
const url = bundle.url;
|
|
23
|
+
const downloadDest = dest ? dest : './download-' + new Date().getTime();
|
|
22
24
|
let downloadUrl;
|
|
23
|
-
if (path.parse(url).name ===
|
|
25
|
+
if (path.parse(url).name === 'tags') {
|
|
24
26
|
downloadUrl = yield selectTag(url, credentials);
|
|
25
27
|
}
|
|
26
|
-
else if (url.includes('https://nexus.magnolia-cms.com/service/rest/v1/search')
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
else if (url.includes('https://nexus.magnolia-cms.com/service/rest/v1/search') ||
|
|
29
|
+
url.includes('https://nexus.magnolia-cms.cn/service/rest/v1/search')) {
|
|
30
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-download-preparing', {
|
|
31
|
+
url,
|
|
29
32
|
}));
|
|
30
33
|
downloadUrl = yield getDownloadUrl(bundle, credentials, options);
|
|
31
34
|
}
|
|
@@ -36,22 +39,21 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
36
39
|
method: 'get',
|
|
37
40
|
responseType: 'stream',
|
|
38
41
|
};
|
|
39
|
-
if (credentials && credentials.username && credentials.password) {
|
|
40
|
-
opts.auth = credentials;
|
|
41
|
-
}
|
|
42
42
|
if (downloadDest) {
|
|
43
43
|
yield fs.ensureDir(downloadDest);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const parsedUrl = new URL(downloadUrl);
|
|
46
|
+
const filename = path.basename(parsedUrl.pathname);
|
|
47
|
+
const tempDownload = path.join(downloadDest, bundle.name || filename || 'temp-' + new Date().getTime());
|
|
46
48
|
const target = fs.createWriteStream(tempDownload);
|
|
47
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
48
|
-
downloadUrl: downloadUrl
|
|
49
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-download-starting', {
|
|
50
|
+
downloadUrl: downloadUrl,
|
|
49
51
|
}));
|
|
50
52
|
const res = yield get(downloadUrl, opts, credentials, bundle.name || bundle.url);
|
|
51
53
|
if (res.status !== 200) {
|
|
52
|
-
throw new Error(i18nInstance.t(
|
|
54
|
+
throw new Error(i18nInstance.t('error-download-fail-status', {
|
|
53
55
|
downloadUrl: downloadUrl,
|
|
54
|
-
status: res.status
|
|
56
|
+
status: res.status,
|
|
55
57
|
}));
|
|
56
58
|
}
|
|
57
59
|
if (res.headers['content-length']) {
|
|
@@ -60,7 +62,7 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
60
62
|
complete: '=',
|
|
61
63
|
incomplete: ' ',
|
|
62
64
|
width: 20,
|
|
63
|
-
total: len
|
|
65
|
+
total: len,
|
|
64
66
|
});
|
|
65
67
|
res.data.on('data', (chunk) => {
|
|
66
68
|
bar.tick(chunk.length);
|
|
@@ -82,7 +84,9 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
catch (error) {
|
|
85
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-downloading-bundle', {
|
|
87
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-downloading-bundle', {
|
|
88
|
+
url: bundle.url,
|
|
89
|
+
}));
|
|
86
90
|
throw new CreateError(error.message);
|
|
87
91
|
}
|
|
88
92
|
});
|
|
@@ -92,79 +96,94 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
92
96
|
method: 'get',
|
|
93
97
|
responseType: 'json',
|
|
94
98
|
headers: {
|
|
95
|
-
Accept: 'application/json'
|
|
96
|
-
}
|
|
99
|
+
Accept: 'application/json',
|
|
100
|
+
},
|
|
97
101
|
};
|
|
98
|
-
if (credentials && credentials.username && credentials.password) {
|
|
99
|
-
opts.auth = credentials;
|
|
100
|
-
}
|
|
101
102
|
try {
|
|
102
103
|
const url = new URL(bundle.url);
|
|
103
|
-
url.searchParams.set('prerelease',
|
|
104
|
+
url.searchParams.set('prerelease', 'false');
|
|
104
105
|
if (bundle.version) {
|
|
105
|
-
if (options.snapshot ||
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
if (options.snapshot ||
|
|
107
|
+
bundle.version.toLowerCase().includes('snapshot')) {
|
|
108
|
+
url.searchParams.set('prerelease', 'true');
|
|
109
|
+
if (options.magnolia === undefined &&
|
|
110
|
+
!bundle.version.match(/^\d/)) {
|
|
111
|
+
options.magnolia = '6.3';
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
if (options.magnolia) {
|
|
112
115
|
bundle.version = options.magnolia;
|
|
113
|
-
if ((bundle.version.startsWith('6.3') || bundle.version.includes('alpha') || bundle.version.includes('beta') || bundle.version.includes('rc')) && bundle.alternative) {
|
|
114
|
-
url.searchParams.set('maven.groupId', bundle.alternative.groupId);
|
|
115
|
-
url.searchParams.set('maven.artifactId', bundle.alternative.artifactId);
|
|
116
|
-
}
|
|
117
116
|
}
|
|
118
|
-
if (bundle.version.
|
|
119
|
-
|
|
117
|
+
if ((bundle.version.startsWith('latest') ||
|
|
118
|
+
bundle.version.startsWith('6.3') ||
|
|
119
|
+
bundle.version.includes('alpha') ||
|
|
120
|
+
bundle.version.includes('beta') ||
|
|
121
|
+
bundle.version.includes('rc')) &&
|
|
122
|
+
bundle.alternative) {
|
|
123
|
+
url.searchParams.set('maven.groupId', bundle.alternative.groupId);
|
|
124
|
+
url.searchParams.set('maven.artifactId', bundle.alternative.artifactId);
|
|
125
|
+
}
|
|
126
|
+
if (bundle.version.toLowerCase() !== 'latest' &&
|
|
127
|
+
bundle.version.toLowerCase() !== 'alpha' &&
|
|
128
|
+
bundle.version.toLowerCase() !== 'beta' &&
|
|
129
|
+
bundle.version.toLowerCase() !== 'rc') {
|
|
130
|
+
url.searchParams.set('maven.baseVersion', options.snapshot
|
|
131
|
+
? bundle.version + '-SNAPSHOT'
|
|
132
|
+
: bundle.version);
|
|
120
133
|
}
|
|
121
134
|
}
|
|
122
|
-
|
|
123
|
-
const params = new URLSearchParams(bundle.url.split(
|
|
135
|
+
const response = (yield get(url.toString(), opts, credentials, bundle.name || bundle.url));
|
|
136
|
+
const params = new URLSearchParams(bundle.url.split('?')[1]);
|
|
124
137
|
let item = response.data.items[0];
|
|
125
|
-
if (((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
|
|
138
|
+
if (((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'latest') {
|
|
126
139
|
item = response.data.items.find((item) => {
|
|
127
140
|
var _a;
|
|
128
141
|
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
129
|
-
return !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes(
|
|
142
|
+
return (!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha')) &&
|
|
143
|
+
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta')) &&
|
|
144
|
+
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc')));
|
|
130
145
|
});
|
|
131
146
|
}
|
|
132
|
-
else if (((_b = bundle.version) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
|
|
147
|
+
else if (((_b = bundle.version) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'alpha') {
|
|
133
148
|
item = response.data.items.find((item) => {
|
|
134
149
|
var _a;
|
|
135
150
|
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
136
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes(
|
|
151
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha');
|
|
137
152
|
});
|
|
138
153
|
}
|
|
139
|
-
else if (((_c = bundle.version) === null || _c === void 0 ? void 0 : _c.toLowerCase()) ===
|
|
154
|
+
else if (((_c = bundle.version) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'beta') {
|
|
140
155
|
item = response.data.items.find((item) => {
|
|
141
156
|
var _a;
|
|
142
157
|
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
143
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes(
|
|
158
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta');
|
|
144
159
|
});
|
|
145
160
|
}
|
|
146
|
-
else if (((_d = bundle.version) === null || _d === void 0 ? void 0 : _d.toLowerCase()) ===
|
|
161
|
+
else if (((_d = bundle.version) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === 'rc') {
|
|
147
162
|
item = response.data.items.find((item) => {
|
|
148
163
|
var _a;
|
|
149
164
|
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
150
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes(
|
|
165
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc');
|
|
151
166
|
});
|
|
152
167
|
}
|
|
153
168
|
if (!item) {
|
|
154
|
-
throw new Error(i18nInstance.t('error-no-artifact-available', {
|
|
169
|
+
throw new Error(i18nInstance.t('error-no-artifact-available', {
|
|
170
|
+
version: bundle.version,
|
|
171
|
+
}));
|
|
155
172
|
}
|
|
156
173
|
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;
|
|
157
174
|
let downloadUrl = item.downloadUrl;
|
|
158
175
|
downloadUrl = downloadUrl === null || downloadUrl === void 0 ? void 0 : downloadUrl.split('/magnolia.');
|
|
159
|
-
downloadUrl =
|
|
176
|
+
downloadUrl =
|
|
177
|
+
downloadUrl &&
|
|
178
|
+
`${downloadUrl[0]}/${params.get('repository')}${item.path}`;
|
|
160
179
|
return downloadUrl;
|
|
161
180
|
}
|
|
162
181
|
catch (error) {
|
|
163
182
|
if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
|
|
164
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
165
|
-
url: bundle.url
|
|
183
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-problem-accessing-url', {
|
|
184
|
+
url: bundle.url,
|
|
166
185
|
}));
|
|
167
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
186
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-unable-to-get-local-issuer-certificate'));
|
|
168
187
|
}
|
|
169
188
|
throw new CreateError(error.message);
|
|
170
189
|
}
|
|
@@ -174,24 +193,23 @@ export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0,
|
|
|
174
193
|
const opts = {
|
|
175
194
|
method: 'get',
|
|
176
195
|
headers: {
|
|
177
|
-
Accept: 'application/json'
|
|
178
|
-
}
|
|
196
|
+
Accept: 'application/json',
|
|
197
|
+
},
|
|
179
198
|
};
|
|
180
|
-
|
|
181
|
-
opts.auth = credentials;
|
|
182
|
-
}
|
|
183
|
-
const res = yield get(url, opts, credentials);
|
|
199
|
+
const res = (yield get(url, opts, credentials));
|
|
184
200
|
if (!((_a = res.data) === null || _a === void 0 ? void 0 : _a.values) || res.data.values.length <= 0) {
|
|
185
|
-
throw new CreateError(i18nInstance.t(
|
|
201
|
+
throw new CreateError(i18nInstance.t('error-no-tags'));
|
|
186
202
|
}
|
|
187
|
-
const { tag } = yield inquirer
|
|
188
|
-
.prompt([
|
|
203
|
+
const { tag } = yield inquirer.prompt([
|
|
189
204
|
{
|
|
190
|
-
type: '
|
|
205
|
+
type: 'list',
|
|
191
206
|
name: 'tag',
|
|
192
207
|
message: i18nInstance.t('inquirer-prompt-select-tag'),
|
|
193
|
-
choices: res.data.values.map((tag) => ({
|
|
194
|
-
|
|
208
|
+
choices: prependNumbersToChoices(res.data.values.map((tag) => ({
|
|
209
|
+
name: tag.displayId,
|
|
210
|
+
value: 'archive?at=' + tag.id,
|
|
211
|
+
}))),
|
|
212
|
+
},
|
|
195
213
|
]);
|
|
196
214
|
return url.slice(0, url.length - 4) + tag;
|
|
197
215
|
});
|
|
@@ -201,12 +219,16 @@ function get(url, opts, credentials, bundleName) {
|
|
|
201
219
|
if (bundleName === undefined) {
|
|
202
220
|
bundleName = url;
|
|
203
221
|
}
|
|
222
|
+
if (credentials) {
|
|
223
|
+
opts.auth = credentials;
|
|
224
|
+
}
|
|
225
|
+
opts = setProxyOpts(opts);
|
|
204
226
|
const handleAuthFail = () => __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-auth-fail', { url }));
|
|
205
228
|
if (credentials) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
credentials.
|
|
209
|
-
credentials.password = (newCredentials === null || newCredentials === void 0 ? void 0 : newCredentials.password) || "";
|
|
229
|
+
opts.auth = yield askForCredentials(bundleName);
|
|
230
|
+
credentials.username = opts.auth.username;
|
|
231
|
+
credentials.password = opts.auth.password;
|
|
210
232
|
}
|
|
211
233
|
});
|
|
212
234
|
while (true) {
|
|
@@ -231,3 +253,14 @@ function get(url, opts, credentials, bundleName) {
|
|
|
231
253
|
return res;
|
|
232
254
|
});
|
|
233
255
|
}
|
|
256
|
+
const setProxyOpts = (opts) => {
|
|
257
|
+
const httpsproxy = process.env.https_proxy || process.env.HTTPS_PROXY;
|
|
258
|
+
const httpproxy = process.env.http_proxy || process.env.HTTP_PROXY;
|
|
259
|
+
if (httpsproxy) {
|
|
260
|
+
return Object.assign(Object.assign({}, opts), { httpsAgent: new HttpsProxyAgent(httpsproxy), proxy: false });
|
|
261
|
+
}
|
|
262
|
+
else if (httpproxy) {
|
|
263
|
+
return Object.assign(Object.assign({}, opts), { httpAgent: new HttpProxyAgent(httpproxy), proxy: false });
|
|
264
|
+
}
|
|
265
|
+
return opts;
|
|
266
|
+
};
|
package/dist/lib/extensions.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const evaluateCustomPrompts: (extensionsPath: string) => Promise<{
|
|
2
|
-
answers:
|
|
2
|
+
answers: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
};
|
|
3
5
|
executePostCommands: (context: any) => Promise<void>;
|
|
4
6
|
} | undefined>;
|
|
5
7
|
export declare const compileCustomPrompts: (answers: any, pattern?: string) => Promise<void>;
|
package/dist/lib/extensions.js
CHANGED
|
@@ -7,17 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import fs from
|
|
11
|
-
import path from
|
|
12
|
-
import inquirer from
|
|
13
|
-
import { execa } from
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import inquirer from 'inquirer';
|
|
13
|
+
import { execa } from 'execa';
|
|
14
14
|
import { parse } from 'yaml';
|
|
15
|
-
import { i18nInstance, logger } from
|
|
16
|
-
import ora from
|
|
17
|
-
import { determinePackageManager } from
|
|
18
|
-
import { pathToFileURL } from
|
|
19
|
-
import { globSync } from
|
|
20
|
-
import _ from
|
|
15
|
+
import { i18nInstance, logger } from '../jumpstart-plugin.js';
|
|
16
|
+
import ora from 'ora';
|
|
17
|
+
import { determinePackageManager } from './helper.js';
|
|
18
|
+
import { pathToFileURL } from 'url';
|
|
19
|
+
import { globSync } from 'glob';
|
|
20
|
+
import _ from 'underscore';
|
|
21
21
|
function pause(milliSeconds) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
return new Promise((resolve) => {
|
|
@@ -29,8 +29,8 @@ function pause(milliSeconds) {
|
|
|
29
29
|
}
|
|
30
30
|
function callExtensionFunction(func_1, context_1, name_1) {
|
|
31
31
|
return __awaiter(this, arguments, void 0, function* (func, context, name, delay = 200, retry = 0, maxRetry = 0) {
|
|
32
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
33
|
-
name: name
|
|
32
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-extensions-calling-fn', {
|
|
33
|
+
name: name,
|
|
34
34
|
}));
|
|
35
35
|
try {
|
|
36
36
|
yield func(context);
|
|
@@ -39,11 +39,11 @@ function callExtensionFunction(func_1, context_1, name_1) {
|
|
|
39
39
|
if (retry === maxRetry) {
|
|
40
40
|
throw error;
|
|
41
41
|
}
|
|
42
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
42
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-extensions-calling-fn-retry', {
|
|
43
43
|
name: name,
|
|
44
44
|
retry: retry,
|
|
45
45
|
maxRetry: maxRetry,
|
|
46
|
-
delay: delay
|
|
46
|
+
delay: delay,
|
|
47
47
|
}));
|
|
48
48
|
yield pause(delay);
|
|
49
49
|
yield callExtensionFunction(func, context, name, delay, retry + 1, maxRetry);
|
|
@@ -52,19 +52,14 @@ function callExtensionFunction(func_1, context_1, name_1) {
|
|
|
52
52
|
}
|
|
53
53
|
function executePostCommands() {
|
|
54
54
|
return __awaiter(this, arguments, void 0, function* (cmds = [], extensions, context) {
|
|
55
|
-
for (
|
|
55
|
+
for (const cmd of cmds) {
|
|
56
56
|
const func = extensions[cmd.function];
|
|
57
57
|
if (func) {
|
|
58
|
-
|
|
59
|
-
yield callExtensionFunction(func, context, cmd.function, cmd.delay, 0, cmd.retry);
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
throw e;
|
|
63
|
-
}
|
|
58
|
+
yield callExtensionFunction(func, context, cmd.function, cmd.delay, 0, cmd.retry);
|
|
64
59
|
}
|
|
65
60
|
else {
|
|
66
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
67
|
-
function: cmd.function
|
|
61
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-extensions-fn-not-found', {
|
|
62
|
+
function: cmd.function,
|
|
68
63
|
}));
|
|
69
64
|
}
|
|
70
65
|
}
|
|
@@ -79,45 +74,38 @@ export const evaluateCustomPrompts = (extensionsPath) => __awaiter(void 0, void
|
|
|
79
74
|
const baseDir = path.parse(extensionsPath).dir;
|
|
80
75
|
const packageJson = path.join(baseDir, 'package.json');
|
|
81
76
|
if (fs.existsSync(packageJson)) {
|
|
82
|
-
const npmISpinner = ora().start(i18nInstance.t(
|
|
77
|
+
const npmISpinner = ora().start(i18nInstance.t('ora-start-installing-ext-dep'));
|
|
83
78
|
const packageManager = determinePackageManager(baseDir);
|
|
84
79
|
try {
|
|
85
|
-
yield execa(packageManager, [
|
|
80
|
+
yield execa(packageManager, ['install'], {
|
|
86
81
|
buffer: true,
|
|
87
|
-
cwd: baseDir
|
|
82
|
+
cwd: baseDir,
|
|
88
83
|
});
|
|
89
|
-
npmISpinner.succeed(i18nInstance.t(
|
|
84
|
+
npmISpinner.succeed(i18nInstance.t('ora-succeed-extensions-install-done'));
|
|
90
85
|
}
|
|
91
86
|
catch (e) {
|
|
92
|
-
npmISpinner.fail(i18nInstance.t(
|
|
93
|
-
packageManager: packageManager,
|
|
87
|
+
npmISpinner.fail(i18nInstance.t('ora-fail-pm-install', {
|
|
88
|
+
packageManager: packageManager,
|
|
89
|
+
errorMsg: e.message,
|
|
94
90
|
}));
|
|
95
91
|
return;
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
94
|
+
const extensions = doc.extend
|
|
95
|
+
? yield import(pathToFileURL(path.join(baseDir, doc.extend)).href)
|
|
96
|
+
: null;
|
|
97
|
+
return {
|
|
98
|
+
answers: doc.prompts ? yield inquirer.prompt(doc.prompts) : {},
|
|
99
|
+
executePostCommands: (context) => __awaiter(void 0, void 0, void 0, function* () { var _a; return yield executePostCommands((_a = doc === null || doc === void 0 ? void 0 : doc.commands) === null || _a === void 0 ? void 0 : _a.post, extensions, context); }),
|
|
100
|
+
};
|
|
108
101
|
});
|
|
109
102
|
export const compileCustomPrompts = (answers_1, ...args_1) => __awaiter(void 0, [answers_1, ...args_1], void 0, function* (answers, pattern = '**/**/**/*.{yaml,tsx,ts,js,jsx,vue,md,json}') {
|
|
110
|
-
const init = globSync(pattern, { ignore: 'node_modules/**' }).map(itm => path.join(process.cwd(), itm));
|
|
103
|
+
const init = globSync(pattern, { ignore: 'node_modules/**' }).map((itm) => path.join(process.cwd(), itm));
|
|
111
104
|
const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), './package.json'), 'utf8'));
|
|
112
105
|
pkg.answers = answers;
|
|
113
106
|
for (const item of init) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
fs.outputFileSync(item, doc, 'utf8');
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
120
|
-
throw e;
|
|
121
|
-
}
|
|
107
|
+
const file = fs.readFileSync(item, 'utf8');
|
|
108
|
+
const doc = _.template(file)(pkg);
|
|
109
|
+
fs.outputFileSync(item, doc, 'utf8');
|
|
122
110
|
}
|
|
123
111
|
});
|
package/dist/lib/extract.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bundle } from
|
|
1
|
+
import { Bundle } from '../types/types.js';
|
|
2
2
|
export declare const extract: (bundle: Bundle, file: string, command: string) => Promise<void>;
|
|
3
3
|
export declare const extractApacheTomcat: (dest: string, unzipFolder: string) => Promise<void>;
|
|
4
4
|
export declare const findExtractedApacheTomcatDir: (p: string) => Promise<unknown>;
|
package/dist/lib/extract.js
CHANGED
|
@@ -7,50 +7,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import decompress from
|
|
11
|
-
import path from
|
|
12
|
-
import walk from
|
|
13
|
-
import fs from
|
|
14
|
-
import { PostCommands } from
|
|
15
|
-
import url from
|
|
16
|
-
import { i18nInstance } from
|
|
17
|
-
import { handleMicroprofileConfig } from
|
|
18
|
-
import ora from
|
|
19
|
-
import { CreateError } from
|
|
10
|
+
import decompress from 'decompress';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import walk from 'walk';
|
|
13
|
+
import fs from 'fs-extra';
|
|
14
|
+
import { PostCommands } from '../types/types.js';
|
|
15
|
+
import url from 'url';
|
|
16
|
+
import { i18nInstance, logger } from '../jumpstart-plugin.js';
|
|
17
|
+
import { handleMicroprofileConfig } from './handleMicroprofileConfig.js';
|
|
18
|
+
import ora from 'ora';
|
|
19
|
+
import { CreateError } from '@magnolia/cli-helper/general-utils';
|
|
20
20
|
export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
var _a;
|
|
22
|
-
const spinner = ora().start(i18nInstance.t(
|
|
23
|
-
let { dest =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const artifactId = (_a = url.parse(bundle.url, true)) === null || _a === void 0 ? void 0 : _a.query['maven.artifactId'];
|
|
30
|
-
if (artifactId === 'magnolia-tomcat-barebone') {
|
|
31
|
-
dest = path.join(dest, 'apache-tomcat');
|
|
32
|
-
yield extractApacheTomcat(dest, unzipFolder);
|
|
33
|
-
spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', { path: path.resolve(dest) }));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
let sourceFolder = unzipFolder;
|
|
37
|
-
if (command === PostCommands.ExtractAndUnfold) {
|
|
38
|
-
const firstDir = fs.readdirSync(unzipFolder).find(item => {
|
|
39
|
-
const itemPath = path.join(unzipFolder, item);
|
|
40
|
-
return fs.statSync(itemPath).isDirectory();
|
|
41
|
-
});
|
|
42
|
-
sourceFolder = firstDir ? path.join(unzipFolder, firstDir) : unzipFolder;
|
|
22
|
+
const spinner = ora().start(i18nInstance.t('ora-start-extracting'));
|
|
23
|
+
let { dest = './' } = bundle;
|
|
24
|
+
try {
|
|
25
|
+
const unzipFolder = 'temp-' + new Date().getTime();
|
|
26
|
+
yield decompress(file, unzipFolder);
|
|
27
|
+
if (command === PostCommands.ExtractAndOverride) {
|
|
28
|
+
fs.rmSync(dest, { recursive: true, force: true });
|
|
43
29
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
const artifactId = (_a = url.parse(bundle.url, true)) === null || _a === void 0 ? void 0 : _a.query['maven.artifactId'];
|
|
31
|
+
if (artifactId === 'magnolia-tomcat-barebone') {
|
|
32
|
+
dest = path.join(dest, 'apache-tomcat');
|
|
33
|
+
yield extractApacheTomcat(dest, unzipFolder);
|
|
34
|
+
spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', {
|
|
35
|
+
path: path.resolve(dest),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
let sourceFolder = unzipFolder;
|
|
40
|
+
if (command === PostCommands.ExtractAndUnfold) {
|
|
41
|
+
const firstDir = fs.readdirSync(unzipFolder).find((item) => {
|
|
42
|
+
const itemPath = path.join(unzipFolder, item);
|
|
43
|
+
return fs.statSync(itemPath).isDirectory();
|
|
44
|
+
});
|
|
45
|
+
sourceFolder = firstDir
|
|
46
|
+
? path.join(unzipFolder, firstDir)
|
|
47
|
+
: unzipFolder;
|
|
48
|
+
}
|
|
49
|
+
fs.copySync(sourceFolder, dest, { overwrite: true });
|
|
50
|
+
spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', {
|
|
51
|
+
path: path.resolve(dest),
|
|
52
|
+
}));
|
|
53
|
+
yield handleMicroprofileConfig(bundle, dest);
|
|
54
|
+
}
|
|
55
|
+
fs.rmSync(unzipFolder, { recursive: true, force: true });
|
|
56
|
+
fs.rmSync(path.dirname(file), { recursive: true, force: true });
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
spinner.stop();
|
|
60
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-extraction-fail', { error: e.message }));
|
|
61
|
+
process.exit(1);
|
|
47
62
|
}
|
|
48
|
-
fs.rmSync(unzipFolder, { recursive: true, force: true });
|
|
49
|
-
fs.rmSync(path.dirname(file), { recursive: true, force: true });
|
|
50
63
|
});
|
|
51
64
|
export const extractApacheTomcat = (dest, unzipFolder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
65
|
const apacheTomcatDir = yield findExtractedApacheTomcatDir(unzipFolder);
|
|
53
|
-
fs.rmSync(path.join(apacheTomcatDir, 'webapps', 'magnoliaAuthor'), {
|
|
66
|
+
fs.rmSync(path.join(apacheTomcatDir, 'webapps', 'magnoliaAuthor'), {
|
|
67
|
+
recursive: true,
|
|
68
|
+
force: true,
|
|
69
|
+
});
|
|
54
70
|
fs.copySync(apacheTomcatDir, dest, { overwrite: false });
|
|
55
71
|
});
|
|
56
72
|
export const findExtractedApacheTomcatDir = (p) => {
|
|
@@ -63,7 +79,7 @@ export const findExtractedApacheTomcatDir = (p) => {
|
|
|
63
79
|
next();
|
|
64
80
|
});
|
|
65
81
|
walker.on('end', function () {
|
|
66
|
-
return reject(new CreateError(i18nInstance.t(
|
|
82
|
+
return reject(new CreateError(i18nInstance.t('error-apache-tomcat-not-found')));
|
|
67
83
|
});
|
|
68
84
|
});
|
|
69
85
|
};
|
|
@@ -7,13 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import fs from
|
|
11
|
-
import path from
|
|
12
|
-
import { getMicroprofileConfigLocation } from
|
|
13
|
-
import { i18nInstance, logger } from
|
|
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
14
|
export const handleMicroprofileConfig = (bundle, dest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
var _a;
|
|
16
|
-
if (!((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.startsWith(
|
|
16
|
+
if (!((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.startsWith('6.3')))
|
|
17
17
|
return;
|
|
18
18
|
const tomcatPath = path.join(path.resolve(dest), '../../');
|
|
19
19
|
const webappName = path.basename(dest);
|
|
@@ -43,10 +43,10 @@ function createMicroprofileConfigFile(file) {
|
|
|
43
43
|
'receivers[0]': {
|
|
44
44
|
name: 'magnoliaPublic8080',
|
|
45
45
|
url: 'http://localhost:8080/magnoliaPublic',
|
|
46
|
-
enabled: true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
46
|
+
enabled: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
50
|
};
|
|
51
51
|
fs.writeFileSync(file, convertObjectToProperties(microprofileConfig).join('\n'), 'utf8');
|
|
52
52
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-created-microprofile', { file }));
|
package/dist/lib/helper.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Credentials } from
|
|
1
|
+
import { Bundle, Credentials } from '../types/types.js';
|
|
2
2
|
export declare const handleLightModulesFolder: () => Promise<void>;
|
|
3
|
+
export declare const handleLightModulesPathInTemplate: (template: any) => Promise<void>;
|
|
3
4
|
export declare const findLightModulesFolder: (p: string) => Promise<unknown>;
|
|
4
5
|
export declare const findWebAppsList: (apacheTomcatPath: string) => string[];
|
|
5
6
|
export declare const initializeNodeProject: () => Promise<void>;
|
|
@@ -9,3 +10,4 @@ export declare const determinePackageManager: (baseDirectory?: string) => "yarn"
|
|
|
9
10
|
export declare const askForCredentials: (bundle: string) => Promise<Credentials>;
|
|
10
11
|
export declare function getWebAppConfigDefaultFolderLocation(tomcatFolder: string, instance: string): string;
|
|
11
12
|
export declare function getMicroprofileConfigLocation(tomcatFolder: string, instance: string): string;
|
|
13
|
+
export declare function copyDownloadedFile(bundle: Bundle, file: string): boolean;
|