@magnolia/cli-jumpstart-plugin 1.1.0 → 1.1.2
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 +8 -0
- package/README.md +23 -2
- package/dist/jumpstart-plugin.d.ts +4 -1
- package/dist/jumpstart-plugin.js +138 -17
- package/dist/lib/download.d.ts +2 -2
- package/dist/lib/download.js +183 -78
- package/dist/lib/helper.js +1 -0
- package/dist/lib/locales/en/translation.json +8 -0
- package/dist/package.json +2 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.2 (2025-08-08)
|
|
4
|
+
* Ask for credentials before checking for tomcat ([MGNLCLI-417](https://magnolia-cms.atlassian.net/browse/MGNLCLI-417))
|
|
5
|
+
|
|
6
|
+
## 1.1.1 (2025-08-07)
|
|
7
|
+
* Set allowVariants property for the magnoliaAuthor ([MGNLCLI-407](https://magnolia-cms.atlassian.net/browse/MGNLCLI-407))
|
|
8
|
+
* Add optional [name] argument to jumpstart command ([MGNLCLI-408](https://magnolia-cms.atlassian.net/browse/MGNLCLI-408))
|
|
9
|
+
* Download correct tomcat version ([MGNLCLI-413](https://magnolia-cms.atlassian.net/browse/MGNLCLI-413))
|
|
10
|
+
|
|
3
11
|
## 1.1.0 (2025-06-06)
|
|
4
12
|
* Add support for named auth profiles in project templates for reusing credentials across bundles ([MGNLCLI-387](https://magnolia-cms.atlassian.net/browse/MGNLCLI-387))
|
|
5
13
|
* Add support for 6.4 version ([MGNLCLI-389](https://magnolia-cms.atlassian.net/browse/MGNLCLI-389))
|
package/README.md
CHANGED
|
@@ -5,6 +5,15 @@ A plugin for [Magnolia CLI](https://docs.magnolia-cms.com/magnolia-cli) to downl
|
|
|
5
5
|
Within the Magnolia CLI plugin system, this plugin is pre-installed and ready to be used.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
|
+
```
|
|
9
|
+
jumpstart [name] [options]
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Arguments
|
|
13
|
+
| Argument | Description |
|
|
14
|
+
|----------|-------------------------------------------------------------------------------------------------|
|
|
15
|
+
| `name` | Optional project directory name. If provided, the project will be created in this directory. |
|
|
16
|
+
|
|
8
17
|
### Options
|
|
9
18
|
|
|
10
19
|
| Short | Long | Description |
|
|
@@ -17,11 +26,17 @@ Within the Magnolia CLI plugin system, this plugin is pre-installed and ready to
|
|
|
17
26
|
| `-h` | `--help` | display help for command |
|
|
18
27
|
|
|
19
28
|
### Examples
|
|
20
|
-
#### Jumpstart a project
|
|
29
|
+
#### Jumpstart a project in current directory
|
|
21
30
|
```bash
|
|
22
31
|
npx @magnolia/cli@latest jumpstart
|
|
23
32
|
```
|
|
24
|
-
This command will prompt you with a list of available templates to choose from. Once you select a template, the CLI will download and configure the project with the latest Magnolia version (or with version associated with that template)
|
|
33
|
+
This command will prompt you with a list of available templates to choose from. Once you select a template, the CLI will download and configure the project in the current working directory with the latest Magnolia version (or with version associated with that template).
|
|
34
|
+
|
|
35
|
+
#### Jumpstart a project in a new directory
|
|
36
|
+
```bash
|
|
37
|
+
npx @magnolia/cli@latest jumpstart my-project
|
|
38
|
+
```
|
|
39
|
+
This command will create a new directory called `my-project` (if it doesn't exist) and set up the project inside it.
|
|
25
40
|
|
|
26
41
|
#### Jumpstart a project with specific template
|
|
27
42
|
```bash
|
|
@@ -35,6 +50,12 @@ npx @magnolia/cli@latest jumpstart --template "standard-webapps/magnolia-communi
|
|
|
35
50
|
```
|
|
36
51
|
This command will start downloading and configuring project based on "standard-webapps/magnolia-community-webapp" template with 6.2.11 Magnolia version.
|
|
37
52
|
|
|
53
|
+
#### Jumpstart a project in a specific directory with template and version
|
|
54
|
+
```bash
|
|
55
|
+
npx @magnolia/cli@latest jumpstart my-magnolia-app --template "standard-webapps/magnolia-community-webapp" --magnolia "6.2.11"
|
|
56
|
+
```
|
|
57
|
+
This command will create the `my-magnolia-app` directory (if needed) and set up the project with the specified template and Magnolia version.
|
|
58
|
+
|
|
38
59
|
## Plugin Documentation
|
|
39
60
|
For detailed documentation of the plugin, please refer to [Plugin Documentation](https://docs.magnolia-cms.com/magnolia-cli)
|
|
40
61
|
|
|
@@ -22,7 +22,10 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
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>;
|
|
25
|
+
private extractProjectName;
|
|
26
|
+
validateAndGetDirectoryName(projectName?: string): Promise<string | undefined>;
|
|
27
|
+
handleProjectDirectory(projectName?: string): string;
|
|
25
28
|
init(winstonLogger: Logger): Promise<void>;
|
|
26
|
-
start(options: PluginOptions): Promise<void>;
|
|
29
|
+
start(options: PluginOptions, args?: string[]): Promise<void>;
|
|
27
30
|
stop(): Promise<void>;
|
|
28
31
|
}
|
package/dist/jumpstart-plugin.js
CHANGED
|
@@ -13,12 +13,15 @@ import { createRequire } from 'module';
|
|
|
13
13
|
const requireFn = createRequire(import.meta.url);
|
|
14
14
|
const pkg = requireFn('./package.json');
|
|
15
15
|
import inquirer from 'inquirer';
|
|
16
|
+
import filenamify from 'filenamify';
|
|
16
17
|
import axios from 'axios';
|
|
17
18
|
import { extract } from './lib/extract.js';
|
|
18
19
|
import { downloadBundle } from './lib/download.js';
|
|
19
20
|
import { PostCommands, } from './types/types.js';
|
|
20
21
|
import { installDependencies } from './lib/install.js';
|
|
21
22
|
import path from 'path';
|
|
23
|
+
import fs from 'fs-extra';
|
|
24
|
+
import process from 'process';
|
|
22
25
|
import { askForCredentials, copyDownloadedFile, handleLightModulesFolder, handleLightModulesPathInTemplate, initializeNodeProject, } from './lib/helper.js';
|
|
23
26
|
import { compileCustomPrompts, evaluateCustomPrompts, } from './lib/extensions.js';
|
|
24
27
|
import { addConfigProps } from './lib/config-helper.js';
|
|
@@ -40,7 +43,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
40
43
|
super();
|
|
41
44
|
this.name = 'jumpstart';
|
|
42
45
|
this.version = pkg.version;
|
|
43
|
-
this.usage = '[options]';
|
|
46
|
+
this.usage = '[name] [options]';
|
|
44
47
|
this.authProfiles = {};
|
|
45
48
|
i18nInstance = initI18n(this.name, 'translation', path.join(__dirname, 'lib/locales'));
|
|
46
49
|
this.description = i18nInstance.t('description');
|
|
@@ -92,13 +95,28 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
92
95
|
}
|
|
93
96
|
for (const bundle of template.bundles || []) {
|
|
94
97
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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);
|
|
102
120
|
if (file) {
|
|
103
121
|
yield this.executePostCommands(bundle, file);
|
|
104
122
|
}
|
|
@@ -223,22 +241,125 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
223
241
|
}
|
|
224
242
|
});
|
|
225
243
|
}
|
|
244
|
+
extractProjectName(args) {
|
|
245
|
+
if (!Array.isArray(args)) {
|
|
246
|
+
const argv = process.argv;
|
|
247
|
+
if (argv.length > 3) {
|
|
248
|
+
const jumpstartIndex = argv.findIndex((arg) => arg === 'jumpstart');
|
|
249
|
+
if (jumpstartIndex !== -1 && argv.length > jumpstartIndex + 1) {
|
|
250
|
+
const nextArg = argv[jumpstartIndex + 1];
|
|
251
|
+
if (nextArg && !nextArg.startsWith('-')) {
|
|
252
|
+
return nextArg;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else if (Array.isArray(args) && args.length > 0) {
|
|
258
|
+
return args[0];
|
|
259
|
+
}
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
validateAndGetDirectoryName(projectName) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
+
if (!projectName) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const sanitizedName = filenamify(projectName, { replacement: '' });
|
|
268
|
+
if (sanitizedName !== projectName || sanitizedName.trim() === '') {
|
|
269
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t('warn-invalid-directory-name', {
|
|
270
|
+
name: projectName,
|
|
271
|
+
}));
|
|
272
|
+
const { validDirectoryName } = yield inquirer.prompt([
|
|
273
|
+
{
|
|
274
|
+
type: 'input',
|
|
275
|
+
name: 'validDirectoryName',
|
|
276
|
+
message: i18nInstance.t('prompt-enter-valid-directory-name'),
|
|
277
|
+
validate: (input) => {
|
|
278
|
+
if (!input || input.trim() === '') {
|
|
279
|
+
return i18nInstance.t('error-directory-name-required');
|
|
280
|
+
}
|
|
281
|
+
const sanitized = filenamify(input, {
|
|
282
|
+
replacement: '',
|
|
283
|
+
});
|
|
284
|
+
if (sanitized !== input || sanitized.trim() === '') {
|
|
285
|
+
return i18nInstance.t('error-directory-name-invalid');
|
|
286
|
+
}
|
|
287
|
+
return true;
|
|
288
|
+
},
|
|
289
|
+
default: sanitizedName || 'my-magnolia-project',
|
|
290
|
+
},
|
|
291
|
+
]);
|
|
292
|
+
return validDirectoryName;
|
|
293
|
+
}
|
|
294
|
+
return projectName;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
handleProjectDirectory(projectName) {
|
|
298
|
+
if (!projectName) {
|
|
299
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-will-be-in-cwd'));
|
|
300
|
+
return process.cwd();
|
|
301
|
+
}
|
|
302
|
+
const targetDir = path.resolve(projectName);
|
|
303
|
+
const dirExists = fs.existsSync(targetDir);
|
|
304
|
+
if (!dirExists) {
|
|
305
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
306
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-directory-created', {
|
|
307
|
+
directory: projectName,
|
|
308
|
+
}));
|
|
309
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-will-be-in-directory', {
|
|
310
|
+
directory: projectName,
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
const files = fs.readdirSync(targetDir);
|
|
315
|
+
if (files.length === 0) {
|
|
316
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-directory-exists-empty', {
|
|
317
|
+
directory: projectName,
|
|
318
|
+
}));
|
|
319
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-will-be-in-directory', {
|
|
320
|
+
directory: projectName,
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-directory-exists-contains-files', {
|
|
325
|
+
directory: projectName,
|
|
326
|
+
}));
|
|
327
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-will-be-in-directory', {
|
|
328
|
+
directory: projectName,
|
|
329
|
+
}));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return targetDir;
|
|
333
|
+
}
|
|
226
334
|
init(winstonLogger) {
|
|
227
335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
336
|
logger = winstonLogger;
|
|
229
337
|
});
|
|
230
338
|
}
|
|
231
|
-
start(options) {
|
|
339
|
+
start(options, args) {
|
|
232
340
|
return __awaiter(this, void 0, void 0, function* () {
|
|
233
341
|
checkFlagsValue(this.options, options);
|
|
234
|
-
|
|
235
|
-
yield this.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
342
|
+
const projectName = this.extractProjectName(args);
|
|
343
|
+
const validatedProjectName = yield this.validateAndGetDirectoryName(projectName);
|
|
344
|
+
const targetDir = this.handleProjectDirectory(validatedProjectName);
|
|
345
|
+
const originalCwd = process.cwd();
|
|
346
|
+
if (targetDir !== originalCwd) {
|
|
347
|
+
process.chdir(targetDir);
|
|
348
|
+
}
|
|
349
|
+
try {
|
|
350
|
+
yield this.setProjectTemplates(options);
|
|
351
|
+
yield this.chooseTemplate(options);
|
|
352
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-downloaded'));
|
|
353
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-registered-commands'));
|
|
354
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-start-project'));
|
|
355
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-add-plugin-plugin'));
|
|
356
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-refer-to-documentation'));
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
if (targetDir !== originalCwd) {
|
|
360
|
+
process.chdir(originalCwd);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
242
363
|
});
|
|
243
364
|
}
|
|
244
365
|
stop() {
|
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) => 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
|
@@ -17,7 +17,179 @@ import axios from 'axios';
|
|
|
17
17
|
import { CreateError, prependNumbersToChoices, } from '@magnolia/cli-helper/general-utils';
|
|
18
18
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
19
19
|
import { HttpProxyAgent } from 'http-proxy-agent';
|
|
20
|
-
|
|
20
|
+
let discoveredMagnoliaVersion = null;
|
|
21
|
+
const constructMavenSearchUrl = (bundle, options, isTomcatExcluded = false) => {
|
|
22
|
+
const bundleCopy = Object.assign({}, bundle);
|
|
23
|
+
const url = new URL(bundleCopy.url);
|
|
24
|
+
url.searchParams.set('prerelease', 'false');
|
|
25
|
+
url.searchParams.set('maven.classifier', '');
|
|
26
|
+
if (bundleCopy.version) {
|
|
27
|
+
if (options.snapshot ||
|
|
28
|
+
bundleCopy.version.toLowerCase().includes('snapshot')) {
|
|
29
|
+
url.searchParams.set('prerelease', 'true');
|
|
30
|
+
if (options.magnolia === undefined &&
|
|
31
|
+
!bundleCopy.version.match(/^\d/)) {
|
|
32
|
+
options.magnolia = '6.3';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (options.magnolia &&
|
|
36
|
+
(!isTomcatExcluded ||
|
|
37
|
+
!bundle.url.includes('magnolia-tomcat-barebone'))) {
|
|
38
|
+
bundleCopy.version = options.magnolia;
|
|
39
|
+
}
|
|
40
|
+
if ((bundleCopy.version.startsWith('latest') ||
|
|
41
|
+
bundleCopy.version.startsWith('6.3') ||
|
|
42
|
+
bundleCopy.version.startsWith('6.4') ||
|
|
43
|
+
bundleCopy.version.includes('alpha') ||
|
|
44
|
+
bundleCopy.version.includes('beta') ||
|
|
45
|
+
bundleCopy.version.includes('rc')) &&
|
|
46
|
+
bundleCopy.alternative) {
|
|
47
|
+
url.searchParams.set('maven.groupId', bundleCopy.alternative.groupId);
|
|
48
|
+
url.searchParams.set('maven.artifactId', bundleCopy.alternative.artifactId);
|
|
49
|
+
}
|
|
50
|
+
if (bundleCopy.version.toLowerCase() !== 'latest' &&
|
|
51
|
+
bundleCopy.version.toLowerCase() !== 'alpha' &&
|
|
52
|
+
bundleCopy.version.toLowerCase() !== 'beta' &&
|
|
53
|
+
bundleCopy.version.toLowerCase() !== 'rc') {
|
|
54
|
+
url.searchParams.set('maven.baseVersion', options.snapshot
|
|
55
|
+
? bundleCopy.version + '-SNAPSHOT'
|
|
56
|
+
: bundleCopy.version);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { url, modifiedBundle: bundleCopy };
|
|
60
|
+
};
|
|
61
|
+
const findItemFromResponse = (response, version) => {
|
|
62
|
+
let item = response.data.items[0];
|
|
63
|
+
if ((version === null || version === void 0 ? void 0 : version.toLowerCase()) === 'latest') {
|
|
64
|
+
item = response.data.items.find((item) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
67
|
+
return (!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha')) &&
|
|
68
|
+
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta')) &&
|
|
69
|
+
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc')));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else if ((version === null || version === void 0 ? void 0 : version.toLowerCase()) === 'alpha') {
|
|
73
|
+
item = response.data.items.find((item) => {
|
|
74
|
+
var _a;
|
|
75
|
+
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
76
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha');
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else if ((version === null || version === void 0 ? void 0 : version.toLowerCase()) === 'beta') {
|
|
80
|
+
item = response.data.items.find((item) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
83
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta');
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else if ((version === null || version === void 0 ? void 0 : version.toLowerCase()) === 'rc') {
|
|
87
|
+
item = response.data.items.find((item) => {
|
|
88
|
+
var _a;
|
|
89
|
+
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
90
|
+
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc');
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return item;
|
|
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, authProfiles) {
|
|
96
|
+
const opts = {
|
|
97
|
+
method: 'get',
|
|
98
|
+
responseType: 'json',
|
|
99
|
+
headers: {
|
|
100
|
+
Accept: 'application/json',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const { url, modifiedBundle } = constructMavenSearchUrl(bundle, options, isTomcatExcluded);
|
|
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
|
+
}
|
|
133
|
+
const item = findItemFromResponse(response, modifiedBundle.version);
|
|
134
|
+
return { item, modifiedBundle };
|
|
135
|
+
});
|
|
136
|
+
const getMagnoliaVersionFromBundle = (bundle, options, credentials, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
var _a;
|
|
138
|
+
try {
|
|
139
|
+
const { item } = yield fetchMavenArtifact(bundle, options, credentials, false, authProfiles);
|
|
140
|
+
if ((_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version) {
|
|
141
|
+
return item.maven2.version;
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
catch (_b) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const modifyTomcatBundleUrl = (bundle, allBundles, credentials, options, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
if (!bundle.url.includes('magnolia-tomcat-barebone')) {
|
|
151
|
+
return bundle;
|
|
152
|
+
}
|
|
153
|
+
if (discoveredMagnoliaVersion) {
|
|
154
|
+
return updateTomcatBundleUrl(bundle, discoveredMagnoliaVersion);
|
|
155
|
+
}
|
|
156
|
+
if (allBundles && options) {
|
|
157
|
+
for (const otherBundle of allBundles) {
|
|
158
|
+
if (isMagnoliaBundle(otherBundle)) {
|
|
159
|
+
const magnoliaVersion = yield getMagnoliaVersionFromBundle(otherBundle, options, credentials, authProfiles);
|
|
160
|
+
if (magnoliaVersion === null) {
|
|
161
|
+
throw new Error(i18nInstance.t('error-no-artifact-available', {
|
|
162
|
+
version: options.magnolia || otherBundle.version,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
if (magnoliaVersion) {
|
|
166
|
+
discoveredMagnoliaVersion = magnoliaVersion;
|
|
167
|
+
return updateTomcatBundleUrl(bundle, magnoliaVersion);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return bundle;
|
|
173
|
+
});
|
|
174
|
+
const isMagnoliaBundle = (bundle) => {
|
|
175
|
+
return (bundle.url.includes('maven.groupId=info.magnolia') &&
|
|
176
|
+
!bundle.url.includes('magnolia-tomcat-barebone'));
|
|
177
|
+
};
|
|
178
|
+
const updateTomcatBundleUrl = (bundle, magnoliaVersion) => {
|
|
179
|
+
const versionParts = magnoliaVersion.split('.');
|
|
180
|
+
const majorVersion = parseInt(versionParts[0]);
|
|
181
|
+
const minorVersion = parseInt(versionParts[1]);
|
|
182
|
+
let baseVersion = '1.*'; // Default for 6.3 and below
|
|
183
|
+
if (majorVersion > 6 || (majorVersion === 6 && minorVersion >= 4)) {
|
|
184
|
+
baseVersion = '2.*';
|
|
185
|
+
}
|
|
186
|
+
// Change the version only if the version isn't set in projectTemplates
|
|
187
|
+
if (!bundle.url.includes('maven.baseVersion=') || bundle.version) {
|
|
188
|
+
bundle.url = `${bundle.url}&maven.baseVersion=${baseVersion}`;
|
|
189
|
+
}
|
|
190
|
+
return bundle;
|
|
191
|
+
};
|
|
192
|
+
export const downloadBundle = (bundle, credentials, dest, options, allBundles, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
193
|
try {
|
|
22
194
|
const url = bundle.url;
|
|
23
195
|
const downloadDest = dest ? dest : './download-' + new Date().getTime();
|
|
@@ -30,7 +202,8 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
30
202
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-download-preparing', {
|
|
31
203
|
url,
|
|
32
204
|
}));
|
|
33
|
-
|
|
205
|
+
const modifiedBundle = yield modifyTomcatBundleUrl(bundle, allBundles, credentials, options, authProfiles);
|
|
206
|
+
downloadUrl = yield getDownloadUrl(modifiedBundle, credentials, options, authProfiles);
|
|
34
207
|
}
|
|
35
208
|
else {
|
|
36
209
|
downloadUrl = url;
|
|
@@ -90,89 +263,21 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
90
263
|
throw new CreateError(error.message);
|
|
91
264
|
}
|
|
92
265
|
});
|
|
93
|
-
export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
-
var _a, _b, _c
|
|
95
|
-
const opts = {
|
|
96
|
-
method: 'get',
|
|
97
|
-
responseType: 'json',
|
|
98
|
-
headers: {
|
|
99
|
-
Accept: 'application/json',
|
|
100
|
-
},
|
|
101
|
-
};
|
|
266
|
+
export const getDownloadUrl = (bundle, credentials, options, authProfiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
267
|
+
var _a, _b, _c;
|
|
102
268
|
try {
|
|
103
|
-
const
|
|
104
|
-
url.searchParams.set('prerelease', 'false');
|
|
105
|
-
url.searchParams.set('maven.classifier', '');
|
|
106
|
-
if (bundle.version) {
|
|
107
|
-
if (options.snapshot ||
|
|
108
|
-
bundle.version.toLowerCase().includes('snapshot')) {
|
|
109
|
-
url.searchParams.set('prerelease', 'true');
|
|
110
|
-
if (options.magnolia === undefined &&
|
|
111
|
-
!bundle.version.match(/^\d/)) {
|
|
112
|
-
options.magnolia = '6.3';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (options.magnolia) {
|
|
116
|
-
bundle.version = options.magnolia;
|
|
117
|
-
}
|
|
118
|
-
if ((bundle.version.startsWith('latest') ||
|
|
119
|
-
bundle.version.startsWith('6.3') ||
|
|
120
|
-
bundle.version.startsWith('6.4') ||
|
|
121
|
-
bundle.version.includes('alpha') ||
|
|
122
|
-
bundle.version.includes('beta') ||
|
|
123
|
-
bundle.version.includes('rc')) &&
|
|
124
|
-
bundle.alternative) {
|
|
125
|
-
url.searchParams.set('maven.groupId', bundle.alternative.groupId);
|
|
126
|
-
url.searchParams.set('maven.artifactId', bundle.alternative.artifactId);
|
|
127
|
-
}
|
|
128
|
-
if (bundle.version.toLowerCase() !== 'latest' &&
|
|
129
|
-
bundle.version.toLowerCase() !== 'alpha' &&
|
|
130
|
-
bundle.version.toLowerCase() !== 'beta' &&
|
|
131
|
-
bundle.version.toLowerCase() !== 'rc') {
|
|
132
|
-
url.searchParams.set('maven.baseVersion', options.snapshot
|
|
133
|
-
? bundle.version + '-SNAPSHOT'
|
|
134
|
-
: bundle.version);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const response = (yield get(url.toString(), opts, credentials, bundle.name || bundle.url));
|
|
269
|
+
const { item, modifiedBundle } = yield fetchMavenArtifact(bundle, options, credentials, true, authProfiles);
|
|
138
270
|
const params = new URLSearchParams(bundle.url.split('?')[1]);
|
|
139
|
-
|
|
140
|
-
if (((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'latest') {
|
|
141
|
-
item = response.data.items.find((item) => {
|
|
142
|
-
var _a;
|
|
143
|
-
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
144
|
-
return (!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha')) &&
|
|
145
|
-
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta')) &&
|
|
146
|
-
!(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc')));
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
else if (((_b = bundle.version) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'alpha') {
|
|
150
|
-
item = response.data.items.find((item) => {
|
|
151
|
-
var _a;
|
|
152
|
-
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
153
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-alpha');
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else if (((_c = bundle.version) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'beta') {
|
|
157
|
-
item = response.data.items.find((item) => {
|
|
158
|
-
var _a;
|
|
159
|
-
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
160
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-beta');
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
else if (((_d = bundle.version) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === 'rc') {
|
|
164
|
-
item = response.data.items.find((item) => {
|
|
165
|
-
var _a;
|
|
166
|
-
const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
|
|
167
|
-
return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes('-rc');
|
|
168
|
-
});
|
|
169
|
-
}
|
|
271
|
+
bundle.version = modifiedBundle.version;
|
|
170
272
|
if (!item) {
|
|
171
273
|
throw new Error(i18nInstance.t('error-no-artifact-available', {
|
|
172
274
|
version: bundle.version,
|
|
173
275
|
}));
|
|
174
276
|
}
|
|
175
|
-
bundle.version = (
|
|
277
|
+
bundle.version = (_b = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : bundle.version;
|
|
278
|
+
if (isMagnoliaBundle(bundle) && ((_c = item === null || item === void 0 ? void 0 : item.maven2) === null || _c === void 0 ? void 0 : _c.version)) {
|
|
279
|
+
discoveredMagnoliaVersion = item.maven2.version;
|
|
280
|
+
}
|
|
176
281
|
let downloadUrl = item.downloadUrl;
|
|
177
282
|
downloadUrl = downloadUrl === null || downloadUrl === void 0 ? void 0 : downloadUrl.split('/magnolia.');
|
|
178
283
|
downloadUrl =
|
package/dist/lib/helper.js
CHANGED
|
@@ -66,6 +66,7 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
|
|
|
66
66
|
if (webApp.endsWith('magnoliaAuthor')) {
|
|
67
67
|
props['magnolia.develop'] = 'true';
|
|
68
68
|
props['magnolia.graphql.introspection.enabled'] = 'true';
|
|
69
|
+
props['magnolia.personalization.rest.allowVariants'] = 'true';
|
|
69
70
|
}
|
|
70
71
|
const webAppPropertiesFilePath = path.join(webApp, 'WEB-INF', 'config', 'default', 'magnolia.properties');
|
|
71
72
|
editProperties(webAppPropertiesFilePath, props);
|
|
@@ -28,12 +28,17 @@
|
|
|
28
28
|
"info-refer-to-documentation": "For additional plugins and features, refer to the Magnolia CLI documentation: https://docs.magnolia-cms.com/magnolia-cli",
|
|
29
29
|
"info-file-downloaded-to": "Downloaded to {{path}}",
|
|
30
30
|
"info-will-be-in-cwd": "The project will be created in the current working directory",
|
|
31
|
+
"info-directory-created": "Directory '{{directory}}' was created",
|
|
32
|
+
"info-directory-exists-empty": "Directory '{{directory}}' exists and is empty",
|
|
33
|
+
"info-directory-exists-contains-files": "Directory '{{directory}}' exists and contains files",
|
|
34
|
+
"info-project-will-be-in-directory": "The project will be set up inside the '{{directory}}' directory",
|
|
31
35
|
|
|
32
36
|
"warn-install-plugins-manually": "Please install following plugins:\n{{installPluginsText}}and register them in \"mgnl.config.js\" file",
|
|
33
37
|
"warn-changed-type": "Changed 'type' property to \"module\" in \"package.json\"",
|
|
34
38
|
"warn-webapp-props-not-exist": "File \"{{filePath}}\" not found; skipping configuration",
|
|
35
39
|
"warn-cannot-modify-webapp": "An error occurred while modifying webapps:\n{{errorMsg}}",
|
|
36
40
|
"warn-cannot-parse-plugin-args": "The provided object:\n{{pluginArgs}}\nis not a valid JSON5 object; arguments will not be added to the plugin: \"{{plugin}}\"",
|
|
41
|
+
"warn-invalid-directory-name": "The directory name '{{name}}' contains invalid characters and cannot be used",
|
|
37
42
|
|
|
38
43
|
"error-no-tags": "No available tags found",
|
|
39
44
|
"error-problem-accessing-url": "A problem occurred while accessing: {{url}}",
|
|
@@ -63,9 +68,12 @@
|
|
|
63
68
|
"error-download-fail-status": "Download failed from: {{downloadUrl}}; expected status \"200\"; received: \"{{status}}\"",
|
|
64
69
|
"error-while-downloading-bundle": "An error occurred while downloading bundle from: {{url}}",
|
|
65
70
|
"error-auth-fail": "Authentication failed for {{url}}; received 401 status; verify your credentials and try again",
|
|
71
|
+
"error-directory-name-required": "Directory name is required",
|
|
72
|
+
"error-directory-name-invalid": "Directory name contains invalid characters. Please use only letters, numbers, hyphens, and underscores",
|
|
66
73
|
|
|
67
74
|
"inquirer-prompt-select-tag": "Choose a tag",
|
|
68
75
|
"inquirer-prompt-choose-template": "Choose a template",
|
|
76
|
+
"prompt-enter-valid-directory-name": "Please enter a valid directory name",
|
|
69
77
|
|
|
70
78
|
"ora-start-checking-add-plugin": "Looking for \"@magnolia/cli add-plugin\" command...",
|
|
71
79
|
"ora-start-extracting": "Extracting...",
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"decompress": "^4.2.1",
|
|
55
55
|
"dotenv": "^16.4.7",
|
|
56
56
|
"execa": "^9.5.2",
|
|
57
|
+
"filenamify": "^6.0.0",
|
|
57
58
|
"fs-extra": "^11.3.0",
|
|
58
59
|
"glob": "^11.0.1",
|
|
59
60
|
"http-proxy-agent": "^7.0.2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"decompress": "^4.2.1",
|
|
55
55
|
"dotenv": "^16.4.7",
|
|
56
56
|
"execa": "^9.5.2",
|
|
57
|
+
"filenamify": "^6.0.0",
|
|
57
58
|
"fs-extra": "^11.3.0",
|
|
58
59
|
"glob": "^11.0.1",
|
|
59
60
|
"http-proxy-agent": "^7.0.2",
|