@magnolia/cli-jumpstart-plugin 1.0.2 → 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 +12 -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 +101 -68
- 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/helper.js
CHANGED
|
@@ -7,36 +7,39 @@ 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 { handleMGNLConfigFile } from
|
|
11
|
-
import { handlePackageJSON } from
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
10
|
+
import { handleMGNLConfigFile } from './config-helper.js';
|
|
11
|
+
import { handlePackageJSON } from './pj-helper.js';
|
|
12
|
+
import { PostCommands } from '../types/types.js';
|
|
13
|
+
import ora from 'ora';
|
|
14
|
+
import { execa } from 'execa';
|
|
15
|
+
import path from 'path';
|
|
16
|
+
import fs from 'fs-extra';
|
|
17
|
+
import { findExtractedApacheTomcatDir } from './extract.js';
|
|
18
|
+
import walk from 'walk';
|
|
19
|
+
import { i18nInstance, logger } from '../jumpstart-plugin.js';
|
|
20
|
+
import inquirer from 'inquirer';
|
|
21
|
+
import { CreateError } from '@magnolia/cli-helper/general-utils';
|
|
22
|
+
import { getRelativePathToMGNLConfig } from '@magnolia/cli-helper';
|
|
23
|
+
import chalk from 'chalk';
|
|
21
24
|
export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.log(chalk.cyanBright('==========================================='));
|
|
22
27
|
let lightModulesPath;
|
|
23
28
|
try {
|
|
24
29
|
lightModulesPath = (yield findLightModulesFolder(process.cwd()));
|
|
25
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
26
|
-
lightModulesPath: lightModulesPath
|
|
27
|
-
}));
|
|
30
|
+
logger === null || logger === void 0 ? void 0 : logger.info(chalk.green.bold('✅ ' + i18nInstance.t('info-found-lm', { lightModulesPath })));
|
|
28
31
|
}
|
|
29
|
-
catch (
|
|
32
|
+
catch (_a) {
|
|
30
33
|
lightModulesPath = path.join(process.cwd(), 'light-modules');
|
|
31
34
|
try {
|
|
32
35
|
fs.mkdirSync(lightModulesPath, { recursive: true });
|
|
33
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
34
|
-
lightModulesPath: lightModulesPath
|
|
36
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-lm-created', {
|
|
37
|
+
lightModulesPath: lightModulesPath,
|
|
35
38
|
}));
|
|
36
39
|
}
|
|
37
40
|
catch (error) {
|
|
38
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
39
|
-
errorMsg: error.message
|
|
41
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-lm-create-fail', {
|
|
42
|
+
errorMsg: error.message,
|
|
40
43
|
}));
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
@@ -46,29 +49,33 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
|
|
|
46
49
|
apacheTomcatPath = yield findExtractedApacheTomcatDir(process.cwd());
|
|
47
50
|
}
|
|
48
51
|
catch (error) {
|
|
49
|
-
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t(
|
|
50
|
-
errorMsg: error.message
|
|
52
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t('warn-cannot-modify-webapp', {
|
|
53
|
+
errorMsg: error.message,
|
|
51
54
|
}));
|
|
52
55
|
return;
|
|
53
56
|
}
|
|
54
57
|
const webApps = findWebAppsList(apacheTomcatPath);
|
|
55
58
|
for (const webApp of webApps) {
|
|
56
|
-
const lightModulesPathToMagnoliaHomeRelPath = process.platform === 'win32'
|
|
59
|
+
const lightModulesPathToMagnoliaHomeRelPath = process.platform === 'win32'
|
|
60
|
+
? path.relative(webApp, lightModulesPath).replace(/\\/g, '/')
|
|
61
|
+
: path.relative(webApp, lightModulesPath);
|
|
57
62
|
const props = {
|
|
58
63
|
'magnolia.resources.dir': '${magnolia.home}/' + lightModulesPathToMagnoliaHomeRelPath,
|
|
59
|
-
'magnolia.update.auto':
|
|
64
|
+
'magnolia.update.auto': 'true',
|
|
60
65
|
};
|
|
61
|
-
if (webApp.endsWith(
|
|
62
|
-
props['magnolia.develop'] =
|
|
66
|
+
if (webApp.endsWith('magnoliaAuthor')) {
|
|
67
|
+
props['magnolia.develop'] = 'true';
|
|
63
68
|
}
|
|
64
69
|
const webAppPropertiesFilePath = path.join(webApp, 'WEB-INF', 'config', 'default', 'magnolia.properties');
|
|
65
70
|
editProperties(webAppPropertiesFilePath, props);
|
|
66
71
|
}
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log(chalk.cyanBright('==========================================='));
|
|
67
74
|
});
|
|
68
75
|
const editProperties = (filePath, props) => {
|
|
69
76
|
if (!fs.existsSync(filePath)) {
|
|
70
|
-
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t(
|
|
71
|
-
filePath: filePath
|
|
77
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t('warn-webapp-props-not-exist', {
|
|
78
|
+
filePath: filePath,
|
|
72
79
|
}));
|
|
73
80
|
return;
|
|
74
81
|
}
|
|
@@ -77,16 +84,17 @@ const editProperties = (filePath, props) => {
|
|
|
77
84
|
try {
|
|
78
85
|
fs.writeFileSync(filePath, replacedContent);
|
|
79
86
|
Object.keys(props).forEach((key) => {
|
|
80
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
87
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-webapp-prop-setting', {
|
|
81
88
|
key: key,
|
|
82
89
|
propsKey: props[key],
|
|
83
|
-
filePath: filePath
|
|
90
|
+
filePath: filePath,
|
|
84
91
|
}));
|
|
85
92
|
});
|
|
86
93
|
}
|
|
87
94
|
catch (error) {
|
|
88
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
89
|
-
errorMsg: error.message,
|
|
95
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-webapp-props-update-error', {
|
|
96
|
+
errorMsg: error.message,
|
|
97
|
+
path: filePath,
|
|
90
98
|
}));
|
|
91
99
|
}
|
|
92
100
|
};
|
|
@@ -98,6 +106,15 @@ const replaceInConfig = (config, props) => {
|
|
|
98
106
|
});
|
|
99
107
|
return config;
|
|
100
108
|
};
|
|
109
|
+
export const handleLightModulesPathInTemplate = (template) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
var _a;
|
|
111
|
+
const lightModulesPath = yield findLightModulesFolder(process.cwd()).catch(() => undefined);
|
|
112
|
+
if (typeof lightModulesPath === 'string' &&
|
|
113
|
+
lightModulesPath !== '' &&
|
|
114
|
+
((_a = template.configVars) === null || _a === void 0 ? void 0 : _a.lightModulesPath) === undefined) {
|
|
115
|
+
template.configVars = Object.assign(Object.assign({}, template.configVars), { lightModulesPath: getRelativePathToMGNLConfig(lightModulesPath) });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
101
118
|
export const findLightModulesFolder = (p) => {
|
|
102
119
|
return new Promise((resolve, reject) => {
|
|
103
120
|
const walker = walk.walk(p, { followLinks: false });
|
|
@@ -108,12 +125,12 @@ export const findLightModulesFolder = (p) => {
|
|
|
108
125
|
next();
|
|
109
126
|
});
|
|
110
127
|
walker.on('end', function () {
|
|
111
|
-
return reject(new CreateError(i18nInstance.t(
|
|
128
|
+
return reject(new CreateError(i18nInstance.t('error-lm-not-found')));
|
|
112
129
|
});
|
|
113
130
|
});
|
|
114
131
|
};
|
|
115
132
|
export const findWebAppsList = (apacheTomcatPath) => {
|
|
116
|
-
|
|
133
|
+
const webApps = [];
|
|
117
134
|
const webAppsFolder = path.join(apacheTomcatPath, 'webapps');
|
|
118
135
|
const files = fs.readdirSync(webAppsFolder);
|
|
119
136
|
for (const file of files) {
|
|
@@ -129,28 +146,29 @@ export const initializeNodeProject = () => __awaiter(void 0, void 0, void 0, fun
|
|
|
129
146
|
yield handleMGNLConfigFile();
|
|
130
147
|
});
|
|
131
148
|
export const installCLI = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
return yield installPackage(determinePackageManager(),
|
|
149
|
+
return yield installPackage(determinePackageManager(), '@magnolia/cli@5', 'mgnl-cli');
|
|
133
150
|
});
|
|
134
151
|
export const installPackage = (packageManager, packageReference, packageName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
152
|
if (!packageName) {
|
|
136
153
|
packageName = packageReference;
|
|
137
154
|
}
|
|
138
|
-
const spinner = ora().start(i18nInstance.t(
|
|
139
|
-
packageName: packageName
|
|
155
|
+
const spinner = ora().start(i18nInstance.t('ora-start-installing-package', {
|
|
156
|
+
packageName: packageName,
|
|
140
157
|
}));
|
|
141
158
|
try {
|
|
142
159
|
yield execa(packageManager, [packageManager === 'npm' ? 'install' : 'add', packageReference], {
|
|
143
160
|
buffer: true,
|
|
144
|
-
cwd: process.cwd()
|
|
161
|
+
cwd: process.cwd(),
|
|
145
162
|
});
|
|
146
|
-
spinner.succeed(i18nInstance.t(
|
|
147
|
-
packageName: packageName
|
|
163
|
+
spinner.succeed(i18nInstance.t('ora-succeed-package-installed', {
|
|
164
|
+
packageName: packageName,
|
|
148
165
|
}));
|
|
149
166
|
return true;
|
|
150
167
|
}
|
|
151
168
|
catch (error) {
|
|
152
|
-
spinner.fail(i18nInstance.t(
|
|
153
|
-
packageName: packageName,
|
|
169
|
+
spinner.fail(i18nInstance.t('ora-fail-installing-package', {
|
|
170
|
+
packageName: packageName,
|
|
171
|
+
errorMsg: error.message,
|
|
154
172
|
}));
|
|
155
173
|
return false;
|
|
156
174
|
}
|
|
@@ -168,20 +186,20 @@ export const determinePackageManager = (baseDirectory = process.cwd()) => {
|
|
|
168
186
|
return 'npm';
|
|
169
187
|
};
|
|
170
188
|
export const askForCredentials = (bundle) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
172
|
-
bundle: bundle
|
|
189
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-enter-credentials', {
|
|
190
|
+
bundle: bundle,
|
|
173
191
|
}));
|
|
174
192
|
return inquirer.prompt([
|
|
175
193
|
{
|
|
176
194
|
type: 'input',
|
|
177
195
|
name: 'username',
|
|
178
|
-
message: 'Username'
|
|
196
|
+
message: 'Username',
|
|
179
197
|
},
|
|
180
198
|
{
|
|
181
199
|
type: 'password',
|
|
182
200
|
name: 'password',
|
|
183
|
-
message: 'Password'
|
|
184
|
-
}
|
|
201
|
+
message: 'Password',
|
|
202
|
+
},
|
|
185
203
|
]);
|
|
186
204
|
});
|
|
187
205
|
export function getWebAppConfigDefaultFolderLocation(tomcatFolder, instance) {
|
|
@@ -190,3 +208,19 @@ export function getWebAppConfigDefaultFolderLocation(tomcatFolder, instance) {
|
|
|
190
208
|
export function getMicroprofileConfigLocation(tomcatFolder, instance) {
|
|
191
209
|
return path.join(getWebAppConfigDefaultFolderLocation(tomcatFolder, instance), 'microprofile-config.properties');
|
|
192
210
|
}
|
|
211
|
+
export function copyDownloadedFile(bundle, file) {
|
|
212
|
+
if (!(bundle.postCommand || []).some((command) => command === PostCommands.Extract ||
|
|
213
|
+
command === PostCommands.ExtractAndOverride ||
|
|
214
|
+
command === PostCommands.ExtractAndUnfold)) {
|
|
215
|
+
const { dest = './' } = bundle;
|
|
216
|
+
const destinationWithFileName = path.join(dest, path.normalize(file).split(path.sep).pop() ||
|
|
217
|
+
'file' + new Date().getTime());
|
|
218
|
+
fs.copySync(file, destinationWithFileName, { overwrite: true });
|
|
219
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-file-downloaded-to', {
|
|
220
|
+
path: path.resolve(destinationWithFileName),
|
|
221
|
+
}));
|
|
222
|
+
fs.rmSync(path.dirname(file), { recursive: true, force: true });
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
}
|
package/dist/lib/install.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bundle } from
|
|
1
|
+
import { Bundle } from '../types/types.js';
|
|
2
2
|
export declare const installDependencies: (bundle: Bundle, command: string) => Promise<void>;
|
package/dist/lib/install.js
CHANGED
|
@@ -7,22 +7,25 @@ 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 { PostCommands } from
|
|
11
|
-
import path from
|
|
12
|
-
import { execa } from
|
|
10
|
+
import { PostCommands } from '../types/types.js';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { execa } from 'execa';
|
|
13
13
|
import ora from 'ora';
|
|
14
|
-
import { i18nInstance } from
|
|
14
|
+
import { i18nInstance } from '../jumpstart-plugin.js';
|
|
15
15
|
export const installDependencies = (bundle, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
const pm = command === PostCommands.YarnInstall ? 'yarn' : 'npm';
|
|
17
|
-
const spinner = ora().start(i18nInstance.t(
|
|
17
|
+
const spinner = ora().start(i18nInstance.t('ora-start-running-pm-install', { packageManager: pm }));
|
|
18
18
|
try {
|
|
19
19
|
yield execa(pm, ['install'], {
|
|
20
20
|
buffer: true,
|
|
21
|
-
cwd: path.join(process.cwd(), bundle.dest ? bundle.dest :
|
|
21
|
+
cwd: path.join(process.cwd(), bundle.dest ? bundle.dest : './'),
|
|
22
22
|
});
|
|
23
23
|
spinner.succeed(i18nInstance.t('ora-succeed-pm-install', { packageManager: pm }));
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
spinner.fail(i18nInstance.t(
|
|
26
|
+
spinner.fail(i18nInstance.t('ora-fail-pm-install', {
|
|
27
|
+
packageManager: pm,
|
|
28
|
+
errorMsg: e.message,
|
|
29
|
+
}));
|
|
27
30
|
}
|
|
28
31
|
});
|
|
@@ -1,88 +1,97 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"description": "download and set up a new headless or freemarker-based project with Magnolia webapp",
|
|
3
|
+
"option-template-description": "choose a template from available project templates",
|
|
4
|
+
"option-projectTemplates-description": "specify the source to load project templates from",
|
|
5
|
+
"option-magnolia-description": "set the Magnolia version; defaults to the latest stable version",
|
|
6
|
+
"option-snapshot-description": "download the latest snapshot version of the specified or latest stable webapp",
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
"info-enter-credentials": "Enter the credentials for \"{{bundle}}\"",
|
|
9
|
+
"info-template-not-found": "Template \"{{template}}\" not found",
|
|
10
|
+
"info-download-preparing": "Retrieving download URL from: {{url}}",
|
|
11
|
+
"info-download-starting": "Starting download from: {{downloadUrl}}",
|
|
12
|
+
"info-extensions-calling-fn": "Calling function \"{{name}}\"",
|
|
13
|
+
"info-add-mgnl-to-pj": "Added \"mgnl\" script to package.json",
|
|
14
|
+
"info-found-lm": "Found existing \"light-modules\" directory at: \"{{lightModulesPath}}\"",
|
|
15
|
+
"info-lm-created": "New \"light-modules\" directory created at: \"{{lightModulesPath}}\"",
|
|
16
|
+
"info-webapp-prop-setting": "Set \"{{key}}\" to: \"{{propsKey}}\" in \"{{filePath}}\"",
|
|
17
|
+
"info-project-downloaded": "Project successfully downloaded",
|
|
18
|
+
"info-microprofile-exists": "File \"microprofile-config.properties\" already exists",
|
|
19
|
+
"info-created-microprofile": "Created \"microprofile-config.properties\" at: {{file}}",
|
|
20
|
+
"info-no-node_modules": "Didn't find \"node_modules\" directory",
|
|
21
|
+
"info-registered-commands": "Run \"npm run mgnl\" to see the list of registered commands",
|
|
22
|
+
"info-start-project": "Start the project using: \"npm run mgnl -- start\"",
|
|
23
|
+
"info-add-plugin-plugin": "If the \"StartPlugin\" is not available, install it using: \"npm run mgnl -- add-plugin @magnolia/cli-start-plugin\"",
|
|
24
|
+
"info-refer-to-documentation": "For additional plugins and features, refer to the Magnolia CLI documentation: https://docs.magnolia-cms.com/magnolia-cli",
|
|
25
|
+
"info-file-downloaded-to": "Downloaded to {{path}}",
|
|
26
|
+
"info-will-be-in-cwd": "The project will be created in the current working directory",
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
"warn-install-plugins-manually": "Please install following plugins:\n{{installPluginsText}}and register them in \"mgnl.config.js\" file",
|
|
29
|
+
"warn-changed-type": "Changed 'type' property to \"module\" in \"package.json\"",
|
|
30
|
+
"warn-webapp-props-not-exist": "File \"{{filePath}}\" not found; skipping configuration",
|
|
31
|
+
"warn-cannot-modify-webapp": "An error occurred while modifying webapps:\n{{errorMsg}}",
|
|
32
|
+
"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}}\"",
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
"error-no-tags": "No available tags found",
|
|
35
|
+
"error-problem-accessing-url": "A problem occurred while accessing: {{url}}",
|
|
36
|
+
"error-unable-to-get-local-issuer-certificate": [
|
|
37
|
+
"The \"unable to get local issuer certificate\" error indicates that something in your infrastructure is preventing the CLI from downloading the Magnolia artifacts",
|
|
38
|
+
"This is not a bug in the CLI",
|
|
39
|
+
"For example, you may be behind a proxy that requires certain certificates",
|
|
40
|
+
"You might be able to ask your infrastructure team to allow requests to the Magnolia artifact repository: https://nexus.magnolia-cms.com/",
|
|
41
|
+
"Please search the web on \"unable to get local issuer certificate\" for more information"
|
|
42
|
+
],
|
|
43
|
+
"error-no-artifact-available": "No Magnolia bundle with version \"{{version}}\" is available",
|
|
44
|
+
"error-while-getting-projectTemplates": "An error occurred while getting \"projectTemplates\":",
|
|
45
|
+
"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?",
|
|
46
|
+
"error-no-projectTemplates-from-path": "Cannot read projectTemplates from a local file located at: \"{{path}}\"; is it a JSON file?",
|
|
47
|
+
"error-no-projectTemplates-from-default": "Cannot fetch default projectTemplates; are you connected to the internet?",
|
|
48
|
+
"error-extensions-calling-fn-retry": "Error calling function: \"{{name}}\"; {{retry}}/{{maxRetry}}; waiting {{delay}}ms before retry",
|
|
49
|
+
"error-extensions-fn-not-found": "\"{{function}}\" function not found",
|
|
50
|
+
"error-apache-tomcat-not-found": "\"apache-tomcat\" was not found",
|
|
51
|
+
"error-extraction-fail": "Extraction failed; {{error}}",
|
|
52
|
+
"error-lm-not-found": "\"light-modules\" was not found",
|
|
53
|
+
"error-pj-mod-fail": "An error occurred while modifying \"package.json\":\n{{errorMsg}}",
|
|
54
|
+
"error-lm-create-fail": "An error occurred while creating \"light-modules\" directory:\n{{errorMsg}}",
|
|
55
|
+
"error-webapp-props-update-error": "An error occurred while updating \"magnolia.properties\" in {{path}} file:\n{{errorMsg}}",
|
|
56
|
+
"error-while-adding-vars": "An error occurred while adding variables to \"mgnl.config.js\":\n{{errorMsg}}",
|
|
57
|
+
"error-while-add-plugin": "An error occurred while installing plugin \"{{plugin}}\":\n{{errorMsg}}",
|
|
58
|
+
"error-mgnl-cli-not-installed": "The \"@magnolia/cli\" package is not installed; try installing it manually: 'npm install @magnolia/cli'",
|
|
59
|
+
"error-download-fail-status": "Download failed from: {{downloadUrl}}; expected status \"200\"; received: \"{{status}}\"",
|
|
60
|
+
"error-while-downloading-bundle": "An error occurred while downloading bundle from: {{url}}",
|
|
61
|
+
"error-auth-fail": "Authentication failed for {{url}}; received 401 status; verify your credentials and try again",
|
|
53
62
|
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
"inquirer-prompt-select-tag": "Choose a tag",
|
|
64
|
+
"inquirer-prompt-choose-template": "Choose a template",
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
"ora-start-checking-add-plugin": "Looking for \"@magnolia/cli add-plugin\" command...",
|
|
67
|
+
"ora-start-extracting": "Extracting...",
|
|
68
|
+
"ora-start-creating-config": "Creating \"mgnl.config.js\"...",
|
|
69
|
+
"ora-start-updating-config": "Updating \"mgnl.config.js\"...",
|
|
70
|
+
"ora-start-adding-shared-vars": "Adding variables to \"mgnl.config.js\"...",
|
|
71
|
+
"ora-start-installing-ext-dep": "Installing extension dependencies...",
|
|
72
|
+
"ora-start-running-pm-install": "Running '{{packageManager}} install'...",
|
|
73
|
+
"ora-start-creating-pj": "Creating package.json...",
|
|
74
|
+
"ora-start-installing-package": "Installing \"{{packageName}}\"...",
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
"ora-succeed-pj-created": "\"package.json\" created",
|
|
77
|
+
"ora-succeed-extracted-to": "Extracted to {{path}}",
|
|
78
|
+
"ora-succeed-shared-vars-added": "Added shared variables to \"mgnl.config.js\"",
|
|
79
|
+
"ora-succeed-extensions-install-done": "Extension dependencies installed",
|
|
80
|
+
"ora-succeed-pm-install": "Completed running '{{packageManager}} install'",
|
|
81
|
+
"ora-succeed-config-created": "Created \"mgnl.config.js\" with logger and plugins properties",
|
|
82
|
+
"ora-succeed-config-updated": "Updated \"mgnl.config.js\" with logger property",
|
|
83
|
+
"ora-succeed-package-installed": "\"{{packageName}}\" installed",
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
"ora-warn-no-add-plugin": "Cannot find \"@magnolia/cli add-plugin\" command; you may need to update \"@magnolia/cli\" package",
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
"ora-fail-pm-install": "An error occurred while running '{{packageManager}} install':\n{{errorMsg}}",
|
|
88
|
+
"ora-fail-creating-config": "An error occurred while creating \"mgnl.config.js\":\n{{errorMsg}}",
|
|
89
|
+
"ora-fail-updating-config": "An error occurred while updating \"mgnl.config.js\":\n{{errorMsg}}",
|
|
90
|
+
"ora-fail-creating-pj": "An error occurred while creating \"package.json\":\n{{errorMsg}}",
|
|
91
|
+
"ora-fail-installing-package": "An error occurred while installing \"{{packageName}}\":\n{{errorMsg}}",
|
|
92
|
+
"ora-fail-while-add-plugin-check": "An error occurred while looking for \"@magnolia/cli add-plugin\" command:\n{{errorMsg}}",
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
"progress-bar-downloading": "Downloading",
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
"text-install-plugin-with-args": "\twith following arguments: {{pluginArgs}}\n"
|
|
88
97
|
}
|
package/dist/lib/pj-helper.js
CHANGED
|
@@ -7,12 +7,12 @@ 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 ora from
|
|
12
|
-
import fs from
|
|
13
|
-
import { execa } from
|
|
14
|
-
import { determinePackageManager, installCLI } from
|
|
15
|
-
import { i18nInstance, logger } from
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import ora from 'ora';
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import { execa } from 'execa';
|
|
14
|
+
import { determinePackageManager, installCLI } from './helper.js';
|
|
15
|
+
import { i18nInstance, logger } from '../jumpstart-plugin.js';
|
|
16
16
|
export const handlePackageJSON = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const pjPath = path.join(process.cwd(), 'package.json');
|
|
18
18
|
if (!fs.existsSync(pjPath)) {
|
|
@@ -29,64 +29,74 @@ export const modifyPackageJSON = (pjPath) => __awaiter(void 0, void 0, void 0, f
|
|
|
29
29
|
pj = JSON.parse(fs.readFileSync(pjPath, 'utf8'));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const nodeModulesPath = path.join(process.cwd(),
|
|
32
|
+
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
|
|
33
33
|
if (!fs.existsSync(nodeModulesPath)) {
|
|
34
34
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-no-node_modules'));
|
|
35
35
|
const pm = determinePackageManager();
|
|
36
|
-
const npmISpinner = ora().start(i18nInstance.t(
|
|
36
|
+
const npmISpinner = ora().start(i18nInstance.t('ora-start-running-pm-install', {
|
|
37
|
+
packageManager: pm,
|
|
38
|
+
}));
|
|
37
39
|
try {
|
|
38
|
-
yield execa(pm, [
|
|
40
|
+
yield execa(pm, ['install'], {
|
|
39
41
|
buffer: true,
|
|
40
|
-
cwd: process.cwd()
|
|
42
|
+
cwd: process.cwd(),
|
|
41
43
|
});
|
|
42
|
-
npmISpinner.succeed(i18nInstance.t(
|
|
44
|
+
npmISpinner.succeed(i18nInstance.t('ora-succeed-pm-install', {
|
|
45
|
+
packageManager: pm,
|
|
46
|
+
}));
|
|
43
47
|
}
|
|
44
48
|
catch (e) {
|
|
45
|
-
npmISpinner.fail(i18nInstance.t(
|
|
49
|
+
npmISpinner.fail(i18nInstance.t('ora-fail-pm-install', {
|
|
50
|
+
packageManager: pm,
|
|
51
|
+
errorMsg: e.message,
|
|
52
|
+
}));
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
if (isMgnlCliInstalled) {
|
|
50
|
-
const mgnlScript = {
|
|
57
|
+
const mgnlScript = {
|
|
58
|
+
mgnl: 'node node_modules/@magnolia/cli',
|
|
59
|
+
};
|
|
51
60
|
const scriptKey = Object.keys(mgnlScript)[0];
|
|
52
61
|
if (!pj.scripts) {
|
|
53
62
|
pj.scripts = {};
|
|
54
63
|
}
|
|
55
|
-
if (!pj.scripts[scriptKey] ||
|
|
64
|
+
if (!pj.scripts[scriptKey] ||
|
|
65
|
+
pj.scripts[scriptKey] !== mgnlScript[scriptKey]) {
|
|
56
66
|
pj.scripts[scriptKey] = mgnlScript[scriptKey];
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
let changedTypeMsg;
|
|
60
70
|
if (!pj.type) {
|
|
61
|
-
pj.type =
|
|
71
|
+
pj.type = 'module';
|
|
62
72
|
}
|
|
63
|
-
else if (pj.type !==
|
|
64
|
-
changedTypeMsg =
|
|
65
|
-
pj.type =
|
|
73
|
+
else if (pj.type !== 'module') {
|
|
74
|
+
changedTypeMsg = 'warn-changed-type';
|
|
75
|
+
pj.type = 'module';
|
|
66
76
|
}
|
|
67
77
|
try {
|
|
68
78
|
fs.writeFileSync(pjPath, JSON.stringify(pj, null, '\t'), 'utf8');
|
|
69
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t(
|
|
79
|
+
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-add-mgnl-to-pj'));
|
|
70
80
|
if (changedTypeMsg) {
|
|
71
81
|
logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t(changedTypeMsg));
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
catch (e) {
|
|
75
|
-
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t(
|
|
85
|
+
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-pj-mod-fail', { errorMsg: e.message }));
|
|
76
86
|
return;
|
|
77
87
|
}
|
|
78
88
|
});
|
|
79
89
|
export const initPackageJSON = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
const pjSpinner = ora().start(i18nInstance.t(
|
|
90
|
+
const pjSpinner = ora().start(i18nInstance.t('ora-start-creating-pj'));
|
|
81
91
|
try {
|
|
82
92
|
yield execa(determinePackageManager(), ['init', '-y'], {
|
|
83
93
|
buffer: true,
|
|
84
|
-
cwd: process.cwd()
|
|
94
|
+
cwd: process.cwd(),
|
|
85
95
|
});
|
|
86
|
-
pjSpinner.succeed(i18nInstance.t(
|
|
96
|
+
pjSpinner.succeed(i18nInstance.t('ora-succeed-pj-created'));
|
|
87
97
|
}
|
|
88
98
|
catch (e) {
|
|
89
|
-
pjSpinner.fail(i18nInstance.t(
|
|
99
|
+
pjSpinner.fail(i18nInstance.t('ora-fail-creating-pj', { errorMsg: e.message }));
|
|
90
100
|
return;
|
|
91
101
|
}
|
|
92
102
|
});
|