@magnolia/cli-jumpstart-plugin 1.1.1 → 1.1.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 +6 -0
- package/dist/jumpstart-plugin.d.ts +1 -1
- package/dist/jumpstart-plugin.js +35 -12
- package/dist/lib/download.d.ts +2 -2
- package/dist/lib/download.js +39 -11
- package/dist/lib/locales/en/translation.json +1 -0
- package/dist/package.json +4 -3
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.3 (2025-09-16)
|
|
4
|
+
* Jumpstart should resolve template path before switching CWD ([MGNLCLI-421](https://magnolia-cms.atlassian.net/browse/MGNLCLI-421))
|
|
5
|
+
|
|
6
|
+
## 1.1.2 (2025-08-08)
|
|
7
|
+
* Ask for credentials before checking for tomcat ([MGNLCLI-417](https://magnolia-cms.atlassian.net/browse/MGNLCLI-417))
|
|
8
|
+
|
|
3
9
|
## 1.1.1 (2025-08-07)
|
|
4
10
|
* Set allowVariants property for the magnoliaAuthor ([MGNLCLI-407](https://magnolia-cms.atlassian.net/browse/MGNLCLI-407))
|
|
5
11
|
* Add optional [name] argument to jumpstart command ([MGNLCLI-408](https://magnolia-cms.atlassian.net/browse/MGNLCLI-408))
|
|
@@ -18,7 +18,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
18
18
|
constructor();
|
|
19
19
|
executePostCommands(bundle: Bundle, file: string): Promise<void>;
|
|
20
20
|
handleTemplate(template: TemplateWithoutChildren, options: PluginOptions): Promise<void>;
|
|
21
|
-
setProjectTemplates(options: PluginOptions): Promise<void>;
|
|
21
|
+
setProjectTemplates(options: PluginOptions, originalCwd: string): Promise<void>;
|
|
22
22
|
promptTemplateSelection(templates: Array<Template>, names?: string[]): Promise<TemplateWithoutChildren | undefined>;
|
|
23
23
|
findTemplateByIdentifier(identifier: string): TemplateWithoutChildren | undefined;
|
|
24
24
|
chooseTemplate(options: PluginOptions): Promise<void>;
|
package/dist/jumpstart-plugin.js
CHANGED
|
@@ -95,13 +95,28 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
95
95
|
}
|
|
96
96
|
for (const bundle of template.bundles || []) {
|
|
97
97
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
let credentials = this.credentials;
|
|
99
|
+
if (bundle.auth === true) {
|
|
100
|
+
const key = bundle.url;
|
|
101
|
+
if (this.authProfiles[key]) {
|
|
102
|
+
credentials = this.authProfiles[key];
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
credentials = yield askForCredentials(key);
|
|
106
|
+
this.authProfiles[key] = credentials;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (typeof bundle.auth === 'string') {
|
|
110
|
+
const key = bundle.auth;
|
|
111
|
+
if (this.authProfiles[key]) {
|
|
112
|
+
credentials = this.authProfiles[key];
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
credentials = yield askForCredentials(key);
|
|
116
|
+
this.authProfiles[key] = credentials;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const file = yield downloadBundle(bundle, credentials, undefined, options, template.bundles || [], this.authProfiles);
|
|
105
120
|
if (file) {
|
|
106
121
|
yield this.executePostCommands(bundle, file);
|
|
107
122
|
}
|
|
@@ -128,7 +143,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
128
143
|
}
|
|
129
144
|
});
|
|
130
145
|
}
|
|
131
|
-
setProjectTemplates(options) {
|
|
146
|
+
setProjectTemplates(options, originalCwd) {
|
|
132
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
148
|
var _a;
|
|
134
149
|
let errorMsg;
|
|
@@ -139,8 +154,13 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
139
154
|
this.projectTemplates = res.data.projectTemplates;
|
|
140
155
|
}
|
|
141
156
|
else if (options.projectTemplates) {
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
const projectTemplatesPath = path.resolve(originalCwd, options.projectTemplates);
|
|
158
|
+
if (!fs.existsSync(projectTemplatesPath)) {
|
|
159
|
+
throw new CreateError(i18nInstance.t('error-projectTemplates-file-not-found', { path: projectTemplatesPath }));
|
|
160
|
+
}
|
|
161
|
+
errorMsg = i18nInstance.t('error-no-projectTemplates-from-path', { path: projectTemplatesPath });
|
|
162
|
+
this.projectTemplates =
|
|
163
|
+
requireFn(projectTemplatesPath).projectTemplates;
|
|
144
164
|
}
|
|
145
165
|
else {
|
|
146
166
|
errorMsg = i18nInstance.t('error-no-projectTemplates-from-default');
|
|
@@ -149,7 +169,10 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
149
169
|
}
|
|
150
170
|
}
|
|
151
171
|
catch (e) {
|
|
152
|
-
if (
|
|
172
|
+
if (e instanceof CreateError) {
|
|
173
|
+
throw e;
|
|
174
|
+
}
|
|
175
|
+
else if (errorMsg) {
|
|
153
176
|
throw new CreateError(errorMsg + `\n${e.message}`);
|
|
154
177
|
}
|
|
155
178
|
else {
|
|
@@ -332,7 +355,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
332
355
|
process.chdir(targetDir);
|
|
333
356
|
}
|
|
334
357
|
try {
|
|
335
|
-
yield this.setProjectTemplates(options);
|
|
358
|
+
yield this.setProjectTemplates(options, originalCwd);
|
|
336
359
|
yield this.chooseTemplate(options);
|
|
337
360
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-downloaded'));
|
|
338
361
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-registered-commands'));
|
package/dist/lib/download.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Bundle, Credentials, PluginOptions } from '../types/types.js';
|
|
2
|
-
export declare const downloadBundle: (bundle: Bundle, credentials: Credentials, dest: string | undefined, options: PluginOptions, allBundles?: Bundle[]) => Promise<string>;
|
|
3
|
-
export declare const getDownloadUrl: (bundle: Bundle, credentials: Credentials, options: PluginOptions) => Promise<string>;
|
|
2
|
+
export declare const downloadBundle: (bundle: Bundle, credentials: Credentials, dest: string | undefined, options: PluginOptions, allBundles?: Bundle[], authProfiles?: Record<string, Credentials>) => Promise<string>;
|
|
3
|
+
export declare const getDownloadUrl: (bundle: Bundle, credentials: Credentials, options: PluginOptions, authProfiles?: Record<string, Credentials>) => Promise<string>;
|
|
4
4
|
export declare const selectTag: (url: string, credentials: Credentials) => Promise<string>;
|
package/dist/lib/download.js
CHANGED
|
@@ -92,7 +92,7 @@ const findItemFromResponse = (response, version) => {
|
|
|
92
92
|
}
|
|
93
93
|
return item;
|
|
94
94
|
};
|
|
95
|
-
const fetchMavenArtifact = (bundle_1, options_1, credentials_1, ...args_1) => __awaiter(void 0, [bundle_1, options_1, credentials_1, ...args_1], void 0, function* (bundle, options, credentials, isTomcatExcluded = false) {
|
|
95
|
+
const fetchMavenArtifact = (bundle_1, options_1, credentials_1, ...args_1) => __awaiter(void 0, [bundle_1, options_1, credentials_1, ...args_1], void 0, function* (bundle, options, credentials, isTomcatExcluded = false, authProfiles) {
|
|
96
96
|
const opts = {
|
|
97
97
|
method: 'get',
|
|
98
98
|
responseType: 'json',
|
|
@@ -101,14 +101,42 @@ const fetchMavenArtifact = (bundle_1, options_1, credentials_1, ...args_1) => __
|
|
|
101
101
|
},
|
|
102
102
|
};
|
|
103
103
|
const { url, modifiedBundle } = constructMavenSearchUrl(bundle, options, isTomcatExcluded);
|
|
104
|
-
|
|
104
|
+
let resolvedCredentials = credentials;
|
|
105
|
+
let profileKey;
|
|
106
|
+
if (bundle.auth === true) {
|
|
107
|
+
profileKey = modifiedBundle.url;
|
|
108
|
+
if (authProfiles && profileKey && authProfiles[profileKey]) {
|
|
109
|
+
resolvedCredentials = authProfiles[profileKey];
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const promptKey = profileKey || modifiedBundle.url;
|
|
113
|
+
resolvedCredentials = yield askForCredentials(promptKey);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (typeof bundle.auth === 'string') {
|
|
117
|
+
profileKey = bundle.auth;
|
|
118
|
+
if (authProfiles && authProfiles[profileKey]) {
|
|
119
|
+
resolvedCredentials = authProfiles[profileKey];
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
resolvedCredentials = yield askForCredentials(profileKey);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const response = (yield get(url.toString(), opts, resolvedCredentials, modifiedBundle.name || modifiedBundle.url));
|
|
126
|
+
if (authProfiles &&
|
|
127
|
+
profileKey &&
|
|
128
|
+
resolvedCredentials &&
|
|
129
|
+
resolvedCredentials.username &&
|
|
130
|
+
resolvedCredentials.password) {
|
|
131
|
+
authProfiles[profileKey] = resolvedCredentials;
|
|
132
|
+
}
|
|
105
133
|
const item = findItemFromResponse(response, modifiedBundle.version);
|
|
106
134
|
return { item, modifiedBundle };
|
|
107
135
|
});
|
|
108
|
-
const getMagnoliaVersionFromBundle = (bundle, options, credentials) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
const getMagnoliaVersionFromBundle = (bundle, options, credentials, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
137
|
var _a;
|
|
110
138
|
try {
|
|
111
|
-
const { item } = yield fetchMavenArtifact(bundle, options, credentials);
|
|
139
|
+
const { item } = yield fetchMavenArtifact(bundle, options, credentials, false, authProfiles);
|
|
112
140
|
if ((_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version) {
|
|
113
141
|
return item.maven2.version;
|
|
114
142
|
}
|
|
@@ -118,7 +146,7 @@ const getMagnoliaVersionFromBundle = (bundle, options, credentials) => __awaiter
|
|
|
118
146
|
return null;
|
|
119
147
|
}
|
|
120
148
|
});
|
|
121
|
-
const modifyTomcatBundleUrl = (bundle, allBundles, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
+
const modifyTomcatBundleUrl = (bundle, allBundles, credentials, options, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
150
|
if (!bundle.url.includes('magnolia-tomcat-barebone')) {
|
|
123
151
|
return bundle;
|
|
124
152
|
}
|
|
@@ -128,7 +156,7 @@ const modifyTomcatBundleUrl = (bundle, allBundles, credentials, options) => __aw
|
|
|
128
156
|
if (allBundles && options) {
|
|
129
157
|
for (const otherBundle of allBundles) {
|
|
130
158
|
if (isMagnoliaBundle(otherBundle)) {
|
|
131
|
-
const magnoliaVersion = yield getMagnoliaVersionFromBundle(otherBundle, options, credentials);
|
|
159
|
+
const magnoliaVersion = yield getMagnoliaVersionFromBundle(otherBundle, options, credentials, authProfiles);
|
|
132
160
|
if (magnoliaVersion === null) {
|
|
133
161
|
throw new Error(i18nInstance.t('error-no-artifact-available', {
|
|
134
162
|
version: options.magnolia || otherBundle.version,
|
|
@@ -161,7 +189,7 @@ const updateTomcatBundleUrl = (bundle, magnoliaVersion) => {
|
|
|
161
189
|
}
|
|
162
190
|
return bundle;
|
|
163
191
|
};
|
|
164
|
-
export const downloadBundle = (bundle, credentials, dest, options, allBundles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
|
+
export const downloadBundle = (bundle, credentials, dest, options, allBundles, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
193
|
try {
|
|
166
194
|
const url = bundle.url;
|
|
167
195
|
const downloadDest = dest ? dest : './download-' + new Date().getTime();
|
|
@@ -174,8 +202,8 @@ export const downloadBundle = (bundle, credentials, dest, options, allBundles) =
|
|
|
174
202
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-download-preparing', {
|
|
175
203
|
url,
|
|
176
204
|
}));
|
|
177
|
-
const modifiedBundle = yield modifyTomcatBundleUrl(bundle, allBundles, credentials, options);
|
|
178
|
-
downloadUrl = yield getDownloadUrl(modifiedBundle, credentials, options);
|
|
205
|
+
const modifiedBundle = yield modifyTomcatBundleUrl(bundle, allBundles, credentials, options, authProfiles);
|
|
206
|
+
downloadUrl = yield getDownloadUrl(modifiedBundle, credentials, options, authProfiles);
|
|
179
207
|
}
|
|
180
208
|
else {
|
|
181
209
|
downloadUrl = url;
|
|
@@ -235,10 +263,10 @@ export const downloadBundle = (bundle, credentials, dest, options, allBundles) =
|
|
|
235
263
|
throw new CreateError(error.message);
|
|
236
264
|
}
|
|
237
265
|
});
|
|
238
|
-
export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
266
|
+
export const getDownloadUrl = (bundle, credentials, options, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
239
267
|
var _a, _b, _c;
|
|
240
268
|
try {
|
|
241
|
-
const { item, modifiedBundle } = yield fetchMavenArtifact(bundle, options, credentials, true);
|
|
269
|
+
const { item, modifiedBundle } = yield fetchMavenArtifact(bundle, options, credentials, true, authProfiles);
|
|
242
270
|
const params = new URLSearchParams(bundle.url.split('?')[1]);
|
|
243
271
|
bundle.version = modifiedBundle.version;
|
|
244
272
|
if (!item) {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"error-while-getting-projectTemplates": "An error occurred while getting \"projectTemplates\":",
|
|
54
54
|
"error-no-projectTemplates-from-url": "Cannot fetch remote projectTemplates file located at: \"{{url}}\"; are you connected to the internet? does it point to a JSON file?",
|
|
55
55
|
"error-no-projectTemplates-from-path": "Cannot read projectTemplates from a local file located at: \"{{path}}\"; is it a JSON file?",
|
|
56
|
+
"error-projectTemplates-file-not-found": "ProjectTemplates file not found at: \"{{path}}\"; please check the file path and ensure the file exists",
|
|
56
57
|
"error-no-projectTemplates-from-default": "Cannot fetch default projectTemplates; are you connected to the internet?",
|
|
57
58
|
"error-extensions-calling-fn-retry": "Error calling function: \"{{name}}\"; {{retry}}/{{maxRetry}}; waiting {{delay}}ms before retry",
|
|
58
59
|
"error-extensions-fn-not-found": "\"{{function}}\" function not found",
|
package/dist/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A plugin for Magnolia CLI to download and set up a new headless or freemarker-based project with Magnolia webapp",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepare": "husky || true",
|
|
8
|
-
"test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
9
|
-
"build": "
|
|
8
|
+
"test": "npm run lint && npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
9
|
+
"build": "tsc && cpy package.json dist && cpy lib/locales dist",
|
|
10
10
|
"depcheck": "depcheck",
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/globals": "^29.7.0",
|
|
27
27
|
"@types/decompress": "^4.2.7",
|
|
28
|
+
"@types/filenamify": "^2.0.1",
|
|
28
29
|
"@types/fs-extra": "^11.0.4",
|
|
29
30
|
"@types/inquirer": "^9.0.7",
|
|
30
31
|
"@types/js-beautify": "^1.14.3",
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A plugin for Magnolia CLI to download and set up a new headless or freemarker-based project with Magnolia webapp",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepare": "husky || true",
|
|
8
|
-
"test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
9
|
-
"build": "
|
|
8
|
+
"test": "npm run lint && npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
9
|
+
"build": "tsc && cpy package.json dist && cpy lib/locales dist",
|
|
10
10
|
"depcheck": "depcheck",
|
|
11
11
|
"lint": "eslint .",
|
|
12
12
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/globals": "^29.7.0",
|
|
27
27
|
"@types/decompress": "^4.2.7",
|
|
28
|
+
"@types/filenamify": "^2.0.1",
|
|
28
29
|
"@types/fs-extra": "^11.0.4",
|
|
29
30
|
"@types/inquirer": "^9.0.7",
|
|
30
31
|
"@types/js-beautify": "^1.14.3",
|