@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.
@@ -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 "./config-helper.js";
11
- import { handlePackageJSON } from "./pj-helper.js";
12
- import ora from "ora";
13
- import { execa } from "execa";
14
- import path from "path";
15
- import fs from "fs-extra";
16
- import { findExtractedApacheTomcatDir } from "./extract.js";
17
- import walk from "walk";
18
- import { i18nInstance, logger } from "../jumpstart-plugin.js";
19
- import inquirer from "inquirer";
20
- import { CreateError } from "@magnolia/cli-helper/general-utils";
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("info-found-lm", {
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 (e) {
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("info-lm-created", {
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("error-lm-create-fail", {
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("warn-cannot-modify-webapp", {
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' ? path.relative(webApp, lightModulesPath).replace(/\\/g, '/') : path.relative(webApp, lightModulesPath);
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': "true"
64
+ 'magnolia.update.auto': 'true',
60
65
  };
61
- if (webApp.endsWith("magnoliaAuthor")) {
62
- props['magnolia.develop'] = "true";
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("warn-webapp-props-not-exist", {
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("info-webapp-prop-setting", {
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("error-webapp-props-update-error", {
89
- errorMsg: error.message, path: filePath
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("error-lm-not-found")));
128
+ return reject(new CreateError(i18nInstance.t('error-lm-not-found')));
112
129
  });
113
130
  });
114
131
  };
115
132
  export const findWebAppsList = (apacheTomcatPath) => {
116
- let webApps = [];
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(), "@magnolia/cli@5", "mgnl-cli");
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("ora-start-installing-package", {
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("ora-succeed-package-installed", {
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("ora-fail-installing-package", {
153
- packageName: packageName, errorMsg: error.message
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("info-enter-credentials", {
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
+ }
@@ -1,2 +1,2 @@
1
- import { Bundle } from "../types/types.js";
1
+ import { Bundle } from '../types/types.js';
2
2
  export declare const installDependencies: (bundle: Bundle, command: string) => Promise<void>;
@@ -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 "../types/types.js";
11
- import path from "path";
12
- import { execa } from "execa";
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 "../jumpstart-plugin.js";
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("ora-start-running-pm-install", { packageManager: pm }));
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("ora-fail-pm-install", { packageManager: pm, errorMsg: e.message }));
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
- "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",
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
- "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",
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
- "warn-install-plugins-manually": "Please install following plugins:\n{{installPluginsText}}and register them in \"mgnl.config.js\" file",
27
- "warn-changed-type": "Changed 'type' property to \"module\" in \"package.json\"",
28
- "warn-webapp-props-not-exist": "File \"{{filePath}}\" not found; skipping configuration",
29
- "warn-cannot-modify-webapp": "An error occurred while modifying webapps:\n{{errorMsg}}",
30
- "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}}\"",
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
- "error-no-tags": "No available tags found",
33
- "error-problem-accessing-url": "A problem occurred while accessing: {{url}}",
34
- "error-unable-to-get-local-issuer-certificate": ["The \"unable to get local issuer certificate\" error indicates that something in your infrastructure is preventing the CLI from downloading the Magnolia artifacts", "This is not a bug in the CLI", "For example, you may be behind a proxy that requires certain certificates", "You might be able to ask your infrastructure team to allow requests to the Magnolia artifact repository: https://nexus.magnolia-cms.com/", "Please search the web on \"unable to get local issuer certificate\" for more information"],
35
- "error-no-artifact-available": "No Magnolia bundle with version \"{{version}}\" is available",
36
- "error-while-getting-projectTemplates": "An error occurred while getting \"projectTemplates\":",
37
- "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?",
38
- "error-no-projectTemplates-from-path": "Cannot read projectTemplates from a local file located at: \"{{path}}\"; is it a JSON file?",
39
- "error-no-projectTemplates-from-default": "Cannot fetch default projectTemplates; are you connected to the internet?",
40
- "error-extensions-calling-fn-retry": "Error calling function: \"{{name}}\"; {{retry}}/{{maxRetry}}; waiting {{delay}}ms before retry",
41
- "error-extensions-fn-not-found": "\"{{function}}\" function not found",
42
- "error-apache-tomcat-not-found": "\"apache-tomcat\" was not found",
43
- "error-lm-not-found": "\"light-modules\" was not found",
44
- "error-pj-mod-fail": "An error occurred while modifying \"package.json\":\n{{errorMsg}}",
45
- "error-lm-create-fail": "An error occurred while creating \"light-modules\" directory:\n{{errorMsg}}",
46
- "error-webapp-props-update-error": "An error occurred while updating \"magnolia.properties\" in {{path}} file:\n{{errorMsg}}",
47
- "error-while-adding-vars": "An error occurred while adding variables to \"mgnl.config.js\":\n{{errorMsg}}",
48
- "error-while-add-plugin": "An error occurred while installing plugin \"{{plugin}}\":\n{{errorMsg}}",
49
- "error-mgnl-cli-not-installed": "The \"@magnolia/cli\" package is not installed; try installing it manually: 'npm install @magnolia/cli'",
50
- "error-download-fail-status": "Download failed from: {{downloadUrl}}; expected status \"200\"; received: \"{{status}}\"",
51
- "error-while-downloading-bundle": "An error occurred while downloading bundle from: {{url}}",
52
- "error-auth-fail": "Authentication failed for {{url}}; received 401 status; verify your credentials and try again",
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
- "inquirer-prompt-select-tag": "Choose a tag",
55
- "inquirer-prompt-choose-template": "Choose a template",
63
+ "inquirer-prompt-select-tag": "Choose a tag",
64
+ "inquirer-prompt-choose-template": "Choose a template",
56
65
 
57
- "ora-start-checking-add-plugin": "Looking for \"@magnolia/cli add-plugin\" command...",
58
- "ora-start-extracting": "Extracting...",
59
- "ora-start-creating-config": "Creating \"mgnl.config.js\"...",
60
- "ora-start-updating-config": "Updating \"mgnl.config.js\"...",
61
- "ora-start-adding-shared-vars": "Adding variables to \"mgnl.config.js\"...",
62
- "ora-start-installing-ext-dep": "Installing extension dependencies...",
63
- "ora-start-running-pm-install": "Running '{{packageManager}} install'...",
64
- "ora-start-creating-pj": "Creating package.json...",
65
- "ora-start-installing-package": "Installing \"{{packageName}}\"...",
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
- "ora-succeed-pj-created": "\"package.json\" created",
68
- "ora-succeed-extracted-to": "Extracted to {{path}}",
69
- "ora-succeed-shared-vars-added": "Added shared variables to \"mgnl.config.js\"",
70
- "ora-succeed-extensions-install-done": "Extension dependencies installed",
71
- "ora-succeed-pm-install": "Completed running '{{packageManager}} install'",
72
- "ora-succeed-config-created": "Created \"mgnl.config.js\" with logger and plugins properties",
73
- "ora-succeed-config-updated": "Updated \"mgnl.config.js\" with logger property",
74
- "ora-succeed-package-installed": "\"{{packageName}}\" installed",
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
- "ora-warn-no-add-plugin": "Cannot find \"@magnolia/cli add-plugin\" command; you may need to update \"@magnolia/cli\" package",
85
+ "ora-warn-no-add-plugin": "Cannot find \"@magnolia/cli add-plugin\" command; you may need to update \"@magnolia/cli\" package",
77
86
 
78
- "ora-fail-pm-install": "An error occurred while running '{{packageManager}} install':\n{{errorMsg}}",
79
- "ora-fail-creating-config": "An error occurred while creating \"mgnl.config.js\":\n{{errorMsg}}",
80
- "ora-fail-updating-config": "An error occurred while updating \"mgnl.config.js\":\n{{errorMsg}}",
81
- "ora-fail-creating-pj": "An error occurred while creating \"package.json\":\n{{errorMsg}}",
82
- "ora-fail-installing-package": "An error occurred while installing \"{{packageName}}\":\n{{errorMsg}}",
83
- "ora-fail-while-add-plugin-check": "An error occurred while looking for \"@magnolia/cli add-plugin\" command:\n{{errorMsg}}",
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
- "progress-bar-downloading": "Downloading",
94
+ "progress-bar-downloading": "Downloading",
86
95
 
87
- "text-install-plugin-with-args": "\twith following arguments: {{pluginArgs}}\n"
96
+ "text-install-plugin-with-args": "\twith following arguments: {{pluginArgs}}\n"
88
97
  }
@@ -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 "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";
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(), "node_modules");
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("ora-start-running-pm-install", { packageManager: pm }));
36
+ const npmISpinner = ora().start(i18nInstance.t('ora-start-running-pm-install', {
37
+ packageManager: pm,
38
+ }));
37
39
  try {
38
- yield execa(pm, ["install"], {
40
+ yield execa(pm, ['install'], {
39
41
  buffer: true,
40
- cwd: process.cwd()
42
+ cwd: process.cwd(),
41
43
  });
42
- npmISpinner.succeed(i18nInstance.t("ora-succeed-pm-install", { packageManager: pm }));
44
+ npmISpinner.succeed(i18nInstance.t('ora-succeed-pm-install', {
45
+ packageManager: pm,
46
+ }));
43
47
  }
44
48
  catch (e) {
45
- npmISpinner.fail(i18nInstance.t("ora-fail-pm-install", { packageManager: pm, errorMsg: e.message }));
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 = { "mgnl": "node node_modules/@magnolia/cli" };
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] || pj.scripts[scriptKey] !== mgnlScript[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 = "module";
71
+ pj.type = 'module';
62
72
  }
63
- else if (pj.type !== "module") {
64
- changedTypeMsg = "warn-changed-type";
65
- pj.type = "module";
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("info-add-mgnl-to-pj"));
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("error-pj-mod-fail", { errorMsg: e.message }));
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("ora-start-creating-pj"));
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("ora-succeed-pj-created"));
96
+ pjSpinner.succeed(i18nInstance.t('ora-succeed-pj-created'));
87
97
  }
88
98
  catch (e) {
89
- pjSpinner.fail(i18nInstance.t("ora-fail-creating-pj", { errorMsg: e.message }));
99
+ pjSpinner.fail(i18nInstance.t('ora-fail-creating-pj', { errorMsg: e.message }));
90
100
  return;
91
101
  }
92
102
  });