@magnolia/cli-jumpstart-plugin 1.0.0-preview.9 → 1.0.1
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 +7 -0
- package/dist/jumpstart-plugin.d.ts +0 -2
- package/dist/jumpstart-plugin.js +8 -17
- package/dist/lib/config-helper.d.ts +1 -1
- package/dist/lib/config-helper.js +2 -10
- package/dist/lib/download.js +7 -6
- package/dist/lib/extract.js +2 -1
- package/dist/lib/handleMicroprofileConfig.d.ts +1 -1
- package/dist/lib/helper.d.ts +0 -2
- package/dist/lib/helper.js +3 -38
- package/dist/lib/locales/en/translation.json +0 -2
- package/dist/package.json +3 -4
- package/package.json +3 -4
package/CHANGELOG.md
ADDED
|
@@ -21,8 +21,6 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
21
21
|
promptTemplateSelection(templates: Array<Template>, names?: string[]): Promise<TemplateWithoutChildren | undefined>;
|
|
22
22
|
findTemplateByIdentifier(identifier: string): TemplateWithoutChildren | undefined;
|
|
23
23
|
chooseTemplate(options: PluginOptions): Promise<void>;
|
|
24
|
-
private isFlag;
|
|
25
|
-
private checkFlagsArguments;
|
|
26
24
|
init(winstonLogger: Logger): Promise<void>;
|
|
27
25
|
start(options: PluginOptions): Promise<void>;
|
|
28
26
|
stop(): Promise<void>;
|
package/dist/jumpstart-plugin.js
CHANGED
|
@@ -19,10 +19,14 @@ import { downloadBundle } from "./lib/download.js";
|
|
|
19
19
|
import { PostCommands } from "./types/types.js";
|
|
20
20
|
import { installDependencies } from "./lib/install.js";
|
|
21
21
|
import path from "path";
|
|
22
|
-
import { askForCredentials, handleLightModulesFolder,
|
|
22
|
+
import { askForCredentials, handleLightModulesFolder, initializeNodeProject } from "./lib/helper.js";
|
|
23
23
|
import { compileCustomPrompts, evaluateCustomPrompts } from "./lib/extensions.js";
|
|
24
24
|
import { addConfigProps } from "./lib/config-helper.js";
|
|
25
25
|
import { installAdditionalPlugins } from "./lib/config-helper.js";
|
|
26
|
+
import { checkFlagsValue, CreateError } from "@magnolia/cli-helper/general-utils";
|
|
27
|
+
import { initI18n } from "@magnolia/cli-helper/i18n";
|
|
28
|
+
import { fileURLToPath } from "url";
|
|
29
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
30
|
const extensionsPath = path.resolve("./extensions/extension.yaml");
|
|
27
31
|
export let logger;
|
|
28
32
|
export let i18nInstance = {
|
|
@@ -34,7 +38,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
34
38
|
this.name = "jumpstart";
|
|
35
39
|
this.version = pkg.version;
|
|
36
40
|
this.usage = "[options]";
|
|
37
|
-
i18nInstance = initI18n(this.name);
|
|
41
|
+
i18nInstance = initI18n(this.name, "translation", path.join(__dirname, "lib/locales"));
|
|
38
42
|
this.description = i18nInstance.t('description');
|
|
39
43
|
this.options = [
|
|
40
44
|
new Option('-m, --magnolia <version>', i18nInstance.t('option-magnolia-description')),
|
|
@@ -124,7 +128,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
124
128
|
}
|
|
125
129
|
catch (e) {
|
|
126
130
|
if (errorMsg) {
|
|
127
|
-
throw new
|
|
131
|
+
throw new CreateError(errorMsg);
|
|
128
132
|
}
|
|
129
133
|
else {
|
|
130
134
|
console.error(i18nInstance.t("error-while-getting-projectTemplates"));
|
|
@@ -198,19 +202,6 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
198
202
|
}
|
|
199
203
|
});
|
|
200
204
|
}
|
|
201
|
-
isFlag(value) {
|
|
202
|
-
return this.options.some(it => it.long === value || it.short === value);
|
|
203
|
-
}
|
|
204
|
-
checkFlagsArguments(options) {
|
|
205
|
-
Object.keys(options).forEach(key => {
|
|
206
|
-
const value = options[key];
|
|
207
|
-
if (this.isFlag(value)) {
|
|
208
|
-
const optionLong = "--" + key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
209
|
-
const option = this.options.find(it => it.long === optionLong);
|
|
210
|
-
throw new Error(i18nInstance.t('error-option-param-is-flag', { option: option === null || option === void 0 ? void 0 : option.flags, value: value }));
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
205
|
init(winstonLogger) {
|
|
215
206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
207
|
logger = winstonLogger;
|
|
@@ -218,7 +209,7 @@ export default class JumpstartPlugin extends PluginTemplate {
|
|
|
218
209
|
}
|
|
219
210
|
start(options) {
|
|
220
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
this.
|
|
212
|
+
checkFlagsValue(this.options, options);
|
|
222
213
|
yield this.setProjectTemplates(options);
|
|
223
214
|
yield this.chooseTemplate(options);
|
|
224
215
|
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-downloaded'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginRequirement } from "../types/types";
|
|
1
|
+
import { PluginRequirement } from "../types/types.js";
|
|
2
2
|
export declare const installAdditionalPlugins: (plugins: Array<PluginRequirement>) => Promise<void>;
|
|
3
3
|
export declare const handleMGNLConfigFile: () => Promise<void>;
|
|
4
4
|
export declare const addConfigProps: (vars: any) => Promise<void>;
|
|
@@ -21,15 +21,8 @@ import _generate from "@babel/generator";
|
|
|
21
21
|
import _traverse from "@babel/traverse";
|
|
22
22
|
import { execa } from "execa";
|
|
23
23
|
import JSON5 from "json5";
|
|
24
|
+
import { BEAUTIFY_OPTIONS } from "@magnolia/cli-helper/general-utils";
|
|
24
25
|
const { js_beautify } = beautifyModule;
|
|
25
|
-
const BEAUTIFY_OPTIONS = {
|
|
26
|
-
indent_size: 2,
|
|
27
|
-
end_with_newline: true,
|
|
28
|
-
max_preserve_newlines: 2,
|
|
29
|
-
keep_array_indentation: false,
|
|
30
|
-
preserve_newlines: true,
|
|
31
|
-
wrap_line_length: 1
|
|
32
|
-
};
|
|
33
26
|
const getLocalConfigPath = () => path.join(process.cwd(), 'mgnl.config.js');
|
|
34
27
|
const getPackageConfigPath = () => path.join(process.cwd(), 'node_modules/@magnolia/cli/mgnl.config.js');
|
|
35
28
|
export const installAdditionalPlugins = (plugins) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -78,7 +71,6 @@ export const installAdditionalPlugins = (plugins) => __awaiter(void 0, void 0, v
|
|
|
78
71
|
if (argsMsg) {
|
|
79
72
|
logger === null || logger === void 0 ? void 0 : logger.warn(argsMsg);
|
|
80
73
|
}
|
|
81
|
-
logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-plugin-installed', { plugin: plugin.plugin }));
|
|
82
74
|
}
|
|
83
75
|
catch (e) {
|
|
84
76
|
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-add-plugin', { plugin: plugin.plugin, errorMsg: e.message }));
|
|
@@ -135,7 +127,7 @@ function getLoggerContent(logger) {
|
|
|
135
127
|
${logger},`;
|
|
136
128
|
}
|
|
137
129
|
const extractLoggerConfig = (content) => {
|
|
138
|
-
const loggerRegex = /(logger\s*:\s*{[^}]*})
|
|
130
|
+
const loggerRegex = /(logger\s*:\s*{[^}]*})/;
|
|
139
131
|
return loggerRegex.exec(content);
|
|
140
132
|
};
|
|
141
133
|
const writeConfigContent = (content, creating) => {
|
package/dist/lib/download.js
CHANGED
|
@@ -14,6 +14,7 @@ import inquirer from "inquirer";
|
|
|
14
14
|
import { i18nInstance, logger } from "../jumpstart-plugin.js";
|
|
15
15
|
import { askForCredentials } from "./helper.js";
|
|
16
16
|
import axios from "axios";
|
|
17
|
+
import { CreateError } from "@magnolia/cli-helper/general-utils";
|
|
17
18
|
export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
try {
|
|
19
20
|
let url = bundle.url;
|
|
@@ -82,7 +83,7 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
|
|
|
82
83
|
}
|
|
83
84
|
catch (error) {
|
|
84
85
|
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-downloading-bundle', { url: bundle.url }));
|
|
85
|
-
throw new
|
|
86
|
+
throw new CreateError(error.message);
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -104,7 +105,7 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
104
105
|
if (options.snapshot || bundle.version.toLowerCase().includes("snapshot")) {
|
|
105
106
|
url.searchParams.set('prerelease', "true");
|
|
106
107
|
if (options.magnolia === undefined && !bundle.version.match(/^\d/)) {
|
|
107
|
-
options.magnolia = "6.
|
|
108
|
+
options.magnolia = "6.3";
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
if (options.magnolia) {
|
|
@@ -165,11 +166,11 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
|
|
|
165
166
|
}));
|
|
166
167
|
logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-unable-to-get-local-issuer-certificate"));
|
|
167
168
|
}
|
|
168
|
-
throw new
|
|
169
|
+
throw new CreateError(error.message);
|
|
169
170
|
}
|
|
170
171
|
});
|
|
171
172
|
export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
var
|
|
173
|
+
var _a;
|
|
173
174
|
const opts = {
|
|
174
175
|
method: 'get',
|
|
175
176
|
headers: {
|
|
@@ -180,8 +181,8 @@ export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0,
|
|
|
180
181
|
opts.auth = credentials;
|
|
181
182
|
}
|
|
182
183
|
const res = yield get(url, opts, credentials);
|
|
183
|
-
if (!((
|
|
184
|
-
throw new
|
|
184
|
+
if (!((_a = res.data) === null || _a === void 0 ? void 0 : _a.values) || res.data.values.length <= 0) {
|
|
185
|
+
throw new CreateError(i18nInstance.t("error-no-tags"));
|
|
185
186
|
}
|
|
186
187
|
const { tag } = yield inquirer
|
|
187
188
|
.prompt([
|
package/dist/lib/extract.js
CHANGED
|
@@ -16,6 +16,7 @@ import url from "url";
|
|
|
16
16
|
import { i18nInstance } from "../jumpstart-plugin.js";
|
|
17
17
|
import { handleMicroprofileConfig } from "./handleMicroprofileConfig.js";
|
|
18
18
|
import ora from "ora";
|
|
19
|
+
import { CreateError } from "@magnolia/cli-helper/general-utils";
|
|
19
20
|
export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
var _a;
|
|
21
22
|
const spinner = ora().start(i18nInstance.t("ora-start-extracting"));
|
|
@@ -62,7 +63,7 @@ export const findExtractedApacheTomcatDir = (p) => {
|
|
|
62
63
|
next();
|
|
63
64
|
});
|
|
64
65
|
walker.on('end', function () {
|
|
65
|
-
return reject(new
|
|
66
|
+
return reject(new CreateError(i18nInstance.t("error-apache-tomcat-not-found")));
|
|
66
67
|
});
|
|
67
68
|
});
|
|
68
69
|
};
|
package/dist/lib/helper.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Credentials } from "../types/types.js";
|
|
2
|
-
import { i18n } from "i18next";
|
|
3
|
-
export declare function initI18n(pluginName: string, namespace?: string): i18n;
|
|
4
2
|
export declare const handleLightModulesFolder: () => Promise<void>;
|
|
5
3
|
export declare const findLightModulesFolder: (p: string) => Promise<unknown>;
|
|
6
4
|
export declare const findWebAppsList: (apacheTomcatPath: string) => string[];
|
package/dist/lib/helper.js
CHANGED
|
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { handleMGNLConfigFile } from "./config-helper.js";
|
|
11
11
|
import { handlePackageJSON } from "./pj-helper.js";
|
|
12
|
-
import i18next from "i18next";
|
|
13
|
-
import Backend from 'i18next-fs-backend';
|
|
14
12
|
import ora from "ora";
|
|
15
13
|
import { execa } from "execa";
|
|
16
14
|
import path from "path";
|
|
@@ -18,41 +16,8 @@ import fs from "fs-extra";
|
|
|
18
16
|
import { findExtractedApacheTomcatDir } from "./extract.js";
|
|
19
17
|
import walk from "walk";
|
|
20
18
|
import { i18nInstance, logger } from "../jumpstart-plugin.js";
|
|
21
|
-
import { fileURLToPath } from "url";
|
|
22
19
|
import inquirer from "inquirer";
|
|
23
|
-
|
|
24
|
-
export function initI18n(pluginName, namespace = "translation") {
|
|
25
|
-
const lng = 'en';
|
|
26
|
-
const localesPath = path.join(__dirname, `locales/${lng}`);
|
|
27
|
-
const namespaces = fs.readdirSync(localesPath)
|
|
28
|
-
.filter(file => file.endsWith('.json'))
|
|
29
|
-
.map(file => file.replace('.json', ''));
|
|
30
|
-
if (!namespaces.includes(namespace)) {
|
|
31
|
-
console.warn(`${pluginName}: Requested translation file "${namespace}" not found at "${localesPath}".\n`);
|
|
32
|
-
if (namespaces.length > 0) {
|
|
33
|
-
console.warn(`Using "${namespaces[0]}" instead.\n`);
|
|
34
|
-
}
|
|
35
|
-
namespace = namespaces[0];
|
|
36
|
-
}
|
|
37
|
-
const newI18nInstance = i18next.createInstance();
|
|
38
|
-
newI18nInstance
|
|
39
|
-
.use(Backend)
|
|
40
|
-
.init({
|
|
41
|
-
joinArrays: '\n',
|
|
42
|
-
lng: lng,
|
|
43
|
-
fallbackLng: 'en',
|
|
44
|
-
ns: namespaces,
|
|
45
|
-
defaultNS: namespace,
|
|
46
|
-
initImmediate: false,
|
|
47
|
-
interpolation: {
|
|
48
|
-
escapeValue: false,
|
|
49
|
-
},
|
|
50
|
-
backend: {
|
|
51
|
-
loadPath: path.join(__dirname, 'locales/{{lng}}/{{ns}}.json')
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return newI18nInstance;
|
|
55
|
-
}
|
|
20
|
+
import { CreateError } from "@magnolia/cli-helper/general-utils";
|
|
56
21
|
export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
22
|
let lightModulesPath;
|
|
58
23
|
try {
|
|
@@ -143,7 +108,7 @@ export const findLightModulesFolder = (p) => {
|
|
|
143
108
|
next();
|
|
144
109
|
});
|
|
145
110
|
walker.on('end', function () {
|
|
146
|
-
return reject(new
|
|
111
|
+
return reject(new CreateError(i18nInstance.t("error-lm-not-found")));
|
|
147
112
|
});
|
|
148
113
|
});
|
|
149
114
|
};
|
|
@@ -164,7 +129,7 @@ export const initializeNodeProject = () => __awaiter(void 0, void 0, void 0, fun
|
|
|
164
129
|
yield handleMGNLConfigFile();
|
|
165
130
|
});
|
|
166
131
|
export const installCLI = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
167
|
-
return yield installPackage(determinePackageManager(), "@magnolia/cli@
|
|
132
|
+
return yield installPackage(determinePackageManager(), "@magnolia/cli@5", "mgnl-cli");
|
|
168
133
|
});
|
|
169
134
|
export const installPackage = (packageManager, packageReference, packageName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
135
|
if (!packageName) {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"info-microprofile-exists": "File \"microprofile-config.properties\" already exists",
|
|
19
19
|
"info-created-microprofile": "Created \"microprofile-config.properties\" at: {{file}}",
|
|
20
20
|
"info-no-node_modules": "Didn't find \"node_modules\" directory",
|
|
21
|
-
"info-plugin-installed": "\"{{plugin}}\" successfully installed",
|
|
22
21
|
"info-registered-commands": "Run \"npm run mgnl\" to see the list of registered commands",
|
|
23
22
|
"info-start-project": "Start the project using: \"npm run mgnl -- start\"",
|
|
24
23
|
"info-add-plugin-plugin": "If the \"StartPlugin\" is not available, install it using: \"npm run mgnl -- add-plugin @magnolia/cli-start-plugin\"",
|
|
@@ -47,7 +46,6 @@
|
|
|
47
46
|
"error-webapp-props-update-error": "An error occurred while updating \"magnolia.properties\" in {{path}} file:\n{{errorMsg}}",
|
|
48
47
|
"error-while-adding-vars": "An error occurred while adding variables to \"mgnl.config.js\":\n{{errorMsg}}",
|
|
49
48
|
"error-while-add-plugin": "An error occurred while installing plugin \"{{plugin}}\":\n{{errorMsg}}",
|
|
50
|
-
"error-option-param-is-flag": "Option \"{{option}}\" argument missing; provided value: \"{{value}}\" is a flag",
|
|
51
49
|
"error-mgnl-cli-not-installed": "The \"@magnolia/cli\" package is not installed; try installing it manually: 'npm install @magnolia/cli'",
|
|
52
50
|
"error-download-fail-status": "Download failed from: {{downloadUrl}}; expected status \"200\"; received: \"{{status}}\"",
|
|
53
51
|
"error-while-downloading-bundle": "An error occurred while downloading bundle from: {{url}}",
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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": {
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@babel/parser": "^7.23.6",
|
|
32
32
|
"@babel/traverse": "^7.24.1",
|
|
33
33
|
"@babel/types": "^7.23.6",
|
|
34
|
-
"@magnolia/cli-
|
|
34
|
+
"@magnolia/cli-helper": "^1.0.0",
|
|
35
|
+
"@magnolia/cli-plugin-template": "^1.1.2",
|
|
35
36
|
"axios": "^1.4.0",
|
|
36
37
|
"commander": "^11.0.0",
|
|
37
38
|
"decompress": "^4.2.1",
|
|
@@ -39,8 +40,6 @@
|
|
|
39
40
|
"execa": "^7.2.0",
|
|
40
41
|
"fs-extra": "^11.1.1",
|
|
41
42
|
"glob": "^10.3.10",
|
|
42
|
-
"i18next": "^23.8.2",
|
|
43
|
-
"i18next-fs-backend": "^2.3.1",
|
|
44
43
|
"inquirer": "^9.2.8",
|
|
45
44
|
"js-beautify": "^1.14.9",
|
|
46
45
|
"json5": "^2.2.3",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnolia/cli-jumpstart-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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": {
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@babel/parser": "^7.23.6",
|
|
32
32
|
"@babel/traverse": "^7.24.1",
|
|
33
33
|
"@babel/types": "^7.23.6",
|
|
34
|
-
"@magnolia/cli-
|
|
34
|
+
"@magnolia/cli-helper": "^1.0.0",
|
|
35
|
+
"@magnolia/cli-plugin-template": "^1.1.2",
|
|
35
36
|
"axios": "^1.4.0",
|
|
36
37
|
"commander": "^11.0.0",
|
|
37
38
|
"decompress": "^4.2.1",
|
|
@@ -39,8 +40,6 @@
|
|
|
39
40
|
"execa": "^7.2.0",
|
|
40
41
|
"fs-extra": "^11.1.1",
|
|
41
42
|
"glob": "^10.3.10",
|
|
42
|
-
"i18next": "^23.8.2",
|
|
43
|
-
"i18next-fs-backend": "^2.3.1",
|
|
44
43
|
"inquirer": "^9.2.8",
|
|
45
44
|
"js-beautify": "^1.14.9",
|
|
46
45
|
"json5": "^2.2.3",
|