@magnolia/cli-jumpstart-plugin 1.0.0-preview.6 → 1.0.0-preview.7

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.
@@ -9,22 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import path from "path";
11
11
  import fs from "fs-extra";
12
- import axios from "axios";
13
12
  import ProgressBar from "progress";
14
13
  import inquirer from "inquirer";
15
14
  import { i18nInstance, logger } from "../jumpstart-plugin.js";
15
+ import { askForCredentials } from "./helper.js";
16
+ import axios from "axios";
16
17
  export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(void 0, void 0, void 0, function* () {
17
18
  try {
18
19
  let url = bundle.url;
19
20
  const downloadDest = dest ? dest : "./download-" + new Date().getTime();
20
21
  let downloadUrl;
21
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-preparing", {
22
- url
23
- }));
24
22
  if (path.parse(url).name === "tags") {
25
23
  downloadUrl = yield selectTag(url, credentials);
26
24
  }
27
25
  else if (url.includes('https://nexus.magnolia-cms.com/service/rest/v1/search')) {
26
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-preparing", {
27
+ url
28
+ }));
28
29
  downloadUrl = yield getDownloadUrl(bundle, credentials, options);
29
30
  }
30
31
  else {
@@ -45,16 +46,16 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
45
46
  logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-starting", {
46
47
  downloadUrl: downloadUrl
47
48
  }));
48
- const res = yield axios.get(downloadUrl, opts);
49
+ const res = yield get(downloadUrl, opts, credentials, bundle.name || bundle.url);
49
50
  if (res.status !== 200) {
50
- throw new Error(i18nInstance.t("info-download-status-error", {
51
+ throw new Error(i18nInstance.t("error-download-fail-status", {
51
52
  downloadUrl: downloadUrl,
52
53
  status: res.status
53
54
  }));
54
55
  }
55
56
  if (res.headers['content-length']) {
56
57
  const len = parseInt(res.headers['content-length'], 10);
57
- const bar = new ProgressBar('Downloading [:bar] :percent :etas', {
58
+ const bar = new ProgressBar(`${i18nInstance.t('progress-bar-downloading')} [:bar] :percent :etas`, {
58
59
  complete: '=',
59
60
  incomplete: ' ',
60
61
  width: 20,
@@ -67,7 +68,6 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
67
68
  res.data.pipe(target);
68
69
  return new Promise((resolve) => {
69
70
  target.on('finish', () => {
70
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-download-finished"));
71
71
  resolve(path.join('.', tempDownload));
72
72
  });
73
73
  target.on('error', (error) => {
@@ -81,11 +81,12 @@ export const downloadBundle = (bundle, credentials, dest, options) => __awaiter(
81
81
  });
82
82
  }
83
83
  catch (error) {
84
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-downloading-bundle', { url: bundle.url }));
84
85
  throw new Error(error);
85
86
  }
86
87
  });
87
88
  export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0, void 0, void 0, function* () {
88
- var _a, _b, _c, _d, _e;
89
+ var _a, _b, _c, _d, _e, _f;
89
90
  const opts = {
90
91
  method: 'get',
91
92
  responseType: 'json',
@@ -102,26 +103,29 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
102
103
  if (bundle.version) {
103
104
  if (options.snapshot || bundle.version.toLowerCase().includes("snapshot")) {
104
105
  url.searchParams.set('prerelease', "true");
106
+ if (options.magnolia === undefined && !bundle.version.match(/^\d/)) {
107
+ options.magnolia = "6.2";
108
+ }
105
109
  }
106
- if (options.magnoliaVersion) {
107
- bundle.version = options.magnoliaVersion;
108
- if (bundle.version.startsWith('6.3') && bundle.alternative) {
110
+ if (options.magnolia) {
111
+ bundle.version = options.magnolia;
112
+ if ((bundle.version.startsWith('6.3') || bundle.version.includes('alpha') || bundle.version.includes('beta') || bundle.version.includes('rc')) && bundle.alternative) {
109
113
  url.searchParams.set('maven.groupId', bundle.alternative.groupId);
110
114
  url.searchParams.set('maven.artifactId', bundle.alternative.artifactId);
111
115
  }
112
116
  }
113
- if (bundle.version.toLowerCase() !== "latest" && bundle.version.toLowerCase() !== "alpha" && bundle.version.toLowerCase() !== "beta") {
117
+ if (bundle.version.toLowerCase() !== "latest" && bundle.version.toLowerCase() !== "alpha" && bundle.version.toLowerCase() !== "beta" && bundle.version.toLowerCase() !== "rc") {
114
118
  url.searchParams.set('maven.baseVersion', options.snapshot ? bundle.version + "-SNAPSHOT" : bundle.version);
115
119
  }
116
120
  }
117
- const response = yield axios.get(url.toString(), opts);
121
+ let response = yield get(url.toString(), opts, credentials, bundle.name || bundle.url);
118
122
  const params = new URLSearchParams(bundle.url.split("?")[1]);
119
123
  let item = response.data.items[0];
120
124
  if (((_a = bundle.version) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "latest") {
121
125
  item = response.data.items.find((item) => {
122
126
  var _a;
123
127
  const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
124
- return !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-alpha")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta"));
128
+ return !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-alpha")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta")) && !(itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-rc"));
125
129
  });
126
130
  }
127
131
  else if (((_b = bundle.version) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "alpha") {
@@ -138,10 +142,17 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
138
142
  return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-beta");
139
143
  });
140
144
  }
145
+ else if (((_d = bundle.version) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === "rc") {
146
+ item = response.data.items.find((item) => {
147
+ var _a;
148
+ const itemVersion = (_a = item === null || item === void 0 ? void 0 : item.maven2) === null || _a === void 0 ? void 0 : _a.version;
149
+ return itemVersion === null || itemVersion === void 0 ? void 0 : itemVersion.includes("-rc");
150
+ });
151
+ }
141
152
  if (!item) {
142
- throw new Error(i18nInstance.t('error-download-no-artifact-available', { version: bundle.version, interpolation: { escapeValue: false } }));
153
+ throw new Error(i18nInstance.t('error-no-artifact-available', { version: bundle.version }));
143
154
  }
144
- bundle.version = (_e = (_d = item === null || item === void 0 ? void 0 : item.maven2) === null || _d === void 0 ? void 0 : _d.version) !== null && _e !== void 0 ? _e : bundle.version;
155
+ bundle.version = (_f = (_e = item === null || item === void 0 ? void 0 : item.maven2) === null || _e === void 0 ? void 0 : _e.version) !== null && _f !== void 0 ? _f : bundle.version;
145
156
  let downloadUrl = item.downloadUrl;
146
157
  downloadUrl = downloadUrl === null || downloadUrl === void 0 ? void 0 : downloadUrl.split('/magnolia.');
147
158
  downloadUrl = downloadUrl && `${downloadUrl[0]}/${params.get('repository')}${item.path}`;
@@ -149,16 +160,16 @@ export const getDownloadUrl = (bundle, credentials, options) => __awaiter(void 0
149
160
  }
150
161
  catch (error) {
151
162
  if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
152
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-download-problem-accessing-url", {
163
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-problem-accessing-url", {
153
164
  url: bundle.url
154
165
  }));
155
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-download-unable-to-get-local-issuer-certificate"));
166
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-unable-to-get-local-issuer-certificate"));
156
167
  }
157
168
  throw new Error(error.message);
158
169
  }
159
170
  });
160
171
  export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0, function* () {
161
- var _f;
172
+ var _g;
162
173
  const opts = {
163
174
  method: 'get',
164
175
  headers: {
@@ -168,18 +179,54 @@ export const selectTag = (url, credentials) => __awaiter(void 0, void 0, void 0,
168
179
  if (credentials && credentials.username && credentials.password) {
169
180
  opts.auth = credentials;
170
181
  }
171
- const res = yield axios.get(url, opts);
172
- if (!((_f = res.data) === null || _f === void 0 ? void 0 : _f.values) || res.data.values.length <= 0) {
173
- throw new Error(i18nInstance.t("error-download-no-tags"));
182
+ const res = yield get(url, opts, credentials);
183
+ if (!((_g = res.data) === null || _g === void 0 ? void 0 : _g.values) || res.data.values.length <= 0) {
184
+ throw new Error(i18nInstance.t("error-no-tags"));
174
185
  }
175
186
  const { tag } = yield inquirer
176
187
  .prompt([
177
188
  {
178
189
  type: 'rawlist',
179
190
  name: 'tag',
180
- message: 'Please select a tag',
191
+ message: i18nInstance.t('inquirer-prompt-select-tag'),
181
192
  choices: res.data.values.map((tag) => ({ name: tag.displayId, value: "archive?at=" + tag.id }))
182
193
  }
183
194
  ]);
184
195
  return url.slice(0, url.length - 4) + tag;
185
196
  });
197
+ function get(url, opts, credentials, bundleName) {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ let res;
200
+ if (bundleName === undefined) {
201
+ bundleName = url;
202
+ }
203
+ const handleAuthFail = () => __awaiter(this, void 0, void 0, function* () {
204
+ if (credentials) {
205
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-auth-fail", { url }));
206
+ const newCredentials = yield askForCredentials(bundleName);
207
+ credentials.username = (newCredentials === null || newCredentials === void 0 ? void 0 : newCredentials.username) || "";
208
+ credentials.password = (newCredentials === null || newCredentials === void 0 ? void 0 : newCredentials.password) || "";
209
+ }
210
+ });
211
+ while (true) {
212
+ try {
213
+ res = yield axios.get(url, opts);
214
+ if (res.status === 401 && credentials) {
215
+ yield handleAuthFail();
216
+ }
217
+ else {
218
+ break;
219
+ }
220
+ }
221
+ catch (e) {
222
+ if (e.response.status === 401 && credentials) {
223
+ yield handleAuthFail();
224
+ }
225
+ else {
226
+ throw Error(e);
227
+ }
228
+ }
229
+ }
230
+ return res;
231
+ });
232
+ }
@@ -79,23 +79,21 @@ export const evaluateCustomPrompts = (extensionsPath) => __awaiter(void 0, void
79
79
  const baseDir = path.parse(extensionsPath).dir;
80
80
  const packageJson = path.join(baseDir, 'package.json');
81
81
  if (fs.existsSync(packageJson)) {
82
- const npmISpinner = ora().start(i18nInstance.t("ora-installing-ext-dep"));
82
+ const npmISpinner = ora().start(i18nInstance.t("ora-start-installing-ext-dep"));
83
83
  const packageManager = determinePackageManager(baseDir);
84
84
  try {
85
85
  yield execa(packageManager, ["install"], {
86
86
  buffer: true,
87
87
  cwd: baseDir
88
88
  });
89
+ npmISpinner.succeed(i18nInstance.t("ora-succeed-extensions-install-done"));
89
90
  }
90
91
  catch (e) {
91
- npmISpinner.stop();
92
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-extensions-install-fail", {
93
- packageManager: packageManager
92
+ npmISpinner.fail(i18nInstance.t("ora-fail-pm-install", {
93
+ packageManager: packageManager, errorMsg: e.message
94
94
  }));
95
95
  return;
96
96
  }
97
- npmISpinner.stop();
98
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-extensions-install-done"));
99
97
  }
100
98
  try {
101
99
  const extensions = doc.extend ? yield import(pathToFileURL(path.join(baseDir, doc.extend)).href) : null;
@@ -13,12 +13,13 @@ import walk from "walk";
13
13
  import fs from "fs-extra";
14
14
  import { PostCommands } from "../types/types.js";
15
15
  import url from "url";
16
- import { i18nInstance, logger } from "../jumpstart-plugin.js";
16
+ import { i18nInstance } from "../jumpstart-plugin.js";
17
17
  import { handleMicroprofileConfig } from "./handleMicroprofileConfig.js";
18
+ import ora from "ora";
18
19
  export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void 0, function* () {
19
20
  var _a;
20
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-extract-extracting"));
21
- const { dest = "./", type } = bundle;
21
+ const spinner = ora().start(i18nInstance.t("ora-start-extracting"));
22
+ let { dest = "./" } = bundle;
22
23
  const unzipFolder = "temp-" + new Date().getTime();
23
24
  yield decompress(file, unzipFolder);
24
25
  if (command === PostCommands.ExtractAndOverride) {
@@ -26,7 +27,9 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
26
27
  }
27
28
  const artifactId = (_a = url.parse(bundle.url, true)) === null || _a === void 0 ? void 0 : _a.query['maven.artifactId'];
28
29
  if (artifactId === 'magnolia-tomcat-barebone') {
30
+ dest = path.join(dest, 'apache-tomcat');
29
31
  yield extractApacheTomcat(dest, unzipFolder);
32
+ spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', { path: path.resolve(dest) }));
30
33
  }
31
34
  else {
32
35
  let sourceFolder = unzipFolder;
@@ -38,6 +41,7 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
38
41
  sourceFolder = firstDir ? path.join(unzipFolder, firstDir) : unzipFolder;
39
42
  }
40
43
  fs.copySync(sourceFolder, dest, { overwrite: true });
44
+ spinner.succeed(i18nInstance.t('ora-succeed-extracted-to', { path: path.resolve(dest) }));
41
45
  yield handleMicroprofileConfig(bundle, dest);
42
46
  }
43
47
  fs.rmSync(unzipFolder, { recursive: true, force: true });
@@ -46,7 +50,7 @@ export const extract = (bundle, file, command) => __awaiter(void 0, void 0, void
46
50
  export const extractApacheTomcat = (dest, unzipFolder) => __awaiter(void 0, void 0, void 0, function* () {
47
51
  const apacheTomcatDir = yield findExtractedApacheTomcatDir(unzipFolder);
48
52
  fs.rmSync(path.join(apacheTomcatDir, 'webapps', 'magnoliaAuthor'), { recursive: true, force: true });
49
- fs.copySync(apacheTomcatDir, path.join(dest, "apache-tomcat"), { overwrite: false });
53
+ fs.copySync(apacheTomcatDir, dest, { overwrite: false });
50
54
  });
51
55
  export const findExtractedApacheTomcatDir = (p) => {
52
56
  return new Promise((resolve, reject) => {
@@ -58,7 +62,7 @@ export const findExtractedApacheTomcatDir = (p) => {
58
62
  next();
59
63
  });
60
64
  walker.on('end', function () {
61
- return reject(new Error(i18nInstance.t("error-extract-apache-tomcat-not-found")));
65
+ return reject(new Error(i18nInstance.t("error-apache-tomcat-not-found")));
62
66
  });
63
67
  });
64
68
  };
@@ -48,12 +48,12 @@ function createMicroprofileConfigFile(file) {
48
48
  }
49
49
  }
50
50
  };
51
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('create-microprofile--info-creating-file', { file }));
52
- return fs.writeFileSync(file, convertObjectToProperties(microprofileConfig).join('\n'), 'utf8');
51
+ fs.writeFileSync(file, convertObjectToProperties(microprofileConfig).join('\n'), 'utf8');
52
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-created-microprofile', { file }));
53
53
  }
54
54
  function processMicroprofileConfigFile(file) {
55
55
  if (fs.existsSync(file)) {
56
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('create-microprofile--info-file-exists-skipping'));
56
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-microprofile-exists'));
57
57
  }
58
58
  else {
59
59
  createMicroprofileConfigFile(file);
@@ -5,10 +5,9 @@ export declare const handleLightModulesFolder: () => Promise<void>;
5
5
  export declare const findLightModulesFolder: (p: string) => Promise<unknown>;
6
6
  export declare const findWebAppsList: (apacheTomcatPath: string) => string[];
7
7
  export declare const initializeNodeProject: () => Promise<void>;
8
- export declare const installPackage: (packageManager: string, packageReference: string, packageName?: string, credentials?: Credentials) => Promise<boolean>;
9
- export declare const isValidURL: (str: string) => boolean;
10
- export declare const extractRepoName: (gitUrl: string) => string | null;
8
+ export declare const installCLI: () => Promise<boolean>;
9
+ export declare const installPackage: (packageManager: string, packageReference: string, packageName?: string) => Promise<boolean>;
11
10
  export declare const determinePackageManager: (baseDirectory?: string) => "yarn" | "npm";
12
- export declare const askForCredentials: () => Promise<Credentials>;
11
+ export declare const askForCredentials: (bundle: string) => Promise<Credentials>;
13
12
  export declare function getWebAppConfigDefaultFolderLocation(tomcatFolder: string, instance: string): string;
14
13
  export declare function getMicroprofileConfigLocation(tomcatFolder: string, instance: string): string;
@@ -57,22 +57,21 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
57
57
  let lightModulesPath;
58
58
  try {
59
59
  lightModulesPath = (yield findLightModulesFolder(process.cwd()));
60
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-found-lm", {
60
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-found-lm", {
61
61
  lightModulesPath: lightModulesPath
62
62
  }));
63
63
  }
64
64
  catch (e) {
65
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-no-lm-found"));
66
65
  lightModulesPath = path.join(process.cwd(), 'light-modules');
67
66
  try {
68
67
  fs.mkdirSync(lightModulesPath, { recursive: true });
69
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-lm-created", {
68
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-lm-created", {
70
69
  lightModulesPath: lightModulesPath
71
70
  }));
72
71
  }
73
72
  catch (error) {
74
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-helper-lm-create-fail", {
75
- errorMsg: error instanceof Error ? error.message : ""
73
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-lm-create-fail", {
74
+ errorMsg: error.message
76
75
  }));
77
76
  return;
78
77
  }
@@ -82,8 +81,8 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
82
81
  apacheTomcatPath = yield findExtractedApacheTomcatDir(process.cwd());
83
82
  }
84
83
  catch (error) {
85
- logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-helper-cannot-modify-webapp", {
86
- errorMsg: error instanceof Error ? error.message : ""
84
+ logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-cannot-modify-webapp", {
85
+ errorMsg: error.message
87
86
  }));
88
87
  return;
89
88
  }
@@ -103,7 +102,7 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
103
102
  });
104
103
  const editProperties = (filePath, props) => {
105
104
  if (!fs.existsSync(filePath)) {
106
- logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-helper-webapp-props-not-exist", {
105
+ logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-webapp-props-not-exist", {
107
106
  filePath: filePath
108
107
  }));
109
108
  return;
@@ -113,7 +112,7 @@ const editProperties = (filePath, props) => {
113
112
  try {
114
113
  fs.writeFileSync(filePath, replacedContent);
115
114
  Object.keys(props).forEach((key) => {
116
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-webapp-prop-setting", {
115
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-webapp-prop-setting", {
117
116
  key: key,
118
117
  propsKey: props[key],
119
118
  filePath: filePath
@@ -121,8 +120,8 @@ const editProperties = (filePath, props) => {
121
120
  });
122
121
  }
123
122
  catch (error) {
124
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-helper-webapp-props-update-error", {
125
- errorMsg: error instanceof Error ? error.message : ""
123
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-webapp-props-update-error", {
124
+ errorMsg: error.message, path: filePath
126
125
  }));
127
126
  }
128
127
  };
@@ -144,7 +143,7 @@ export const findLightModulesFolder = (p) => {
144
143
  next();
145
144
  });
146
145
  walker.on('end', function () {
147
- return reject(new Error(i18nInstance.t("error-helper-lm-not-found")));
146
+ return reject(new Error(i18nInstance.t("error-lm-not-found")));
148
147
  });
149
148
  });
150
149
  };
@@ -164,17 +163,14 @@ export const initializeNodeProject = () => __awaiter(void 0, void 0, void 0, fun
164
163
  yield handlePackageJSON();
165
164
  yield handleMGNLConfigFile();
166
165
  });
167
- export const installPackage = (packageManager, packageReference, packageName, credentials) => __awaiter(void 0, void 0, void 0, function* () {
166
+ export const installCLI = () => __awaiter(void 0, void 0, void 0, function* () {
167
+ return yield installPackage(determinePackageManager(), "@magnolia/cli@preview", "mgnl-cli");
168
+ });
169
+ export const installPackage = (packageManager, packageReference, packageName) => __awaiter(void 0, void 0, void 0, function* () {
168
170
  if (!packageName) {
169
171
  packageName = packageReference;
170
172
  }
171
- if (packageReference.startsWith("git+https://git.magnolia-cms.com")) {
172
- if (credentials === undefined) {
173
- credentials = yield askForCredentials();
174
- }
175
- packageReference = packageReference.replace("git+https://git.magnolia-cms.com", `git+https://${credentials.username}:${credentials.password}@git.magnolia-cms.com`);
176
- }
177
- const spinner = ora().start(i18nInstance.t("ora-installing-package", {
173
+ const spinner = ora().start(i18nInstance.t("ora-start-installing-package", {
178
174
  packageName: packageName
179
175
  }));
180
176
  try {
@@ -182,33 +178,18 @@ export const installPackage = (packageManager, packageReference, packageName, cr
182
178
  buffer: true,
183
179
  cwd: process.cwd()
184
180
  });
185
- spinner.stop();
186
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-package-installed", {
181
+ spinner.succeed(i18nInstance.t("ora-succeed-package-installed", {
187
182
  packageName: packageName
188
183
  }));
189
184
  return true;
190
185
  }
191
186
  catch (error) {
192
- spinner.stop();
193
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-helper-fail-to-install-package", {
194
- packageName: packageName
187
+ spinner.fail(i18nInstance.t("ora-fail-installing-package", {
188
+ packageName: packageName, errorMsg: error.message
195
189
  }));
196
190
  return false;
197
191
  }
198
192
  });
199
- export const isValidURL = (str) => {
200
- try {
201
- new URL(str);
202
- return true;
203
- }
204
- catch (_) {
205
- return false;
206
- }
207
- };
208
- export const extractRepoName = (gitUrl) => {
209
- const match = gitUrl.match(/\/([^/]+?)(?:\.git)?$/);
210
- return match ? match[1] : null;
211
- };
212
193
  export const determinePackageManager = (baseDirectory = process.cwd()) => {
213
194
  const yarnLockPath = path.join(baseDirectory, 'yarn.lock');
214
195
  const packageLockPath = path.join(baseDirectory, 'package-lock.json');
@@ -221,7 +202,10 @@ export const determinePackageManager = (baseDirectory = process.cwd()) => {
221
202
  // Default to npm
222
203
  return 'npm';
223
204
  };
224
- export const askForCredentials = () => __awaiter(void 0, void 0, void 0, function* () {
205
+ export const askForCredentials = (bundle) => __awaiter(void 0, void 0, void 0, function* () {
206
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-enter-credentials", {
207
+ bundle: bundle
208
+ }));
225
209
  return inquirer.prompt([
226
210
  {
227
211
  type: 'input',
@@ -11,19 +11,18 @@ import { PostCommands } from "../types/types.js";
11
11
  import path from "path";
12
12
  import { execa } from "execa";
13
13
  import ora from 'ora';
14
- import { i18nInstance, logger } 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
- const spinner = ora(i18nInstance.t("ora-installing-dep")).start();
16
+ const pm = command === PostCommands.YarnInstall ? 'yarn' : 'npm';
17
+ const spinner = ora().start(i18nInstance.t("ora-start-running-pm-install", { packageManager: pm }));
17
18
  try {
18
- yield execa(command === PostCommands.YarnInstall ? 'yarn' : 'npm', ['install'], {
19
+ yield execa(pm, ['install'], {
19
20
  buffer: true,
20
21
  cwd: path.join(process.cwd(), bundle.dest ? bundle.dest : "./")
21
22
  });
22
- spinner.stop();
23
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-install-dep"));
23
+ spinner.succeed(i18nInstance.t('ora-succeed-pm-install', { packageManager: pm }));
24
24
  }
25
25
  catch (e) {
26
- spinner.stop();
27
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-install-dep-fail"));
26
+ spinner.fail(i18nInstance.t("ora-fail-pm-install", { packageManager: pm, errorMsg: e.message }));
28
27
  }
29
28
  });