@magnolia/cli-jumpstart-plugin 1.0.0-preview.3 → 1.0.0-preview.5

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,34 +7,86 @@ 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, installAndConfigPlugins } from "./config-helper.js";
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';
12
14
  import ora from "ora";
13
15
  import { execa } from "execa";
14
16
  import path from "path";
15
17
  import fs from "fs-extra";
16
18
  import { findExtractedApacheTomcatDir } from "./extract.js";
17
19
  import walk from "walk";
18
- import { logger } from "../jumpstart-plugin.js";
20
+ import { i18nInstance, logger } from "../jumpstart-plugin.js";
21
+ import { fileURLToPath } from "url";
22
+ import inquirer from "inquirer";
23
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
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
+ }
19
56
  export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0, function* () {
20
57
  let lightModulesPath;
21
58
  try {
22
59
  lightModulesPath = (yield findLightModulesFolder(process.cwd()));
23
- logger === null || logger === void 0 ? void 0 : logger.info(`Found existing light-modules path at '${lightModulesPath}'`);
60
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-found-lm", {
61
+ lightModulesPath: lightModulesPath
62
+ }));
24
63
  }
25
64
  catch (e) {
26
- logger === null || logger === void 0 ? void 0 : logger.info(`No light-modules folder found. Attempting to create one.`);
65
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-no-lm-found"));
27
66
  lightModulesPath = path.join(process.cwd(), 'light-modules');
28
67
  try {
29
68
  fs.mkdirSync(lightModulesPath, { recursive: true });
30
- logger === null || logger === void 0 ? void 0 : logger.info(`'light-modules' folder created at '${lightModulesPath}'.`);
69
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-lm-created", {
70
+ lightModulesPath: lightModulesPath
71
+ }));
31
72
  }
32
73
  catch (error) {
33
- logger === null || logger === void 0 ? void 0 : logger.error(`Failed to create 'light-modules' folder: ${error instanceof Error ? error.message : ""}`);
74
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-helper-lm-create-fail", {
75
+ errorMsg: error instanceof Error ? error.message : ""
76
+ }));
34
77
  return;
35
78
  }
36
79
  }
37
- const apacheTomcatPath = yield findExtractedApacheTomcatDir(process.cwd());
80
+ let apacheTomcatPath;
81
+ try {
82
+ apacheTomcatPath = yield findExtractedApacheTomcatDir(process.cwd());
83
+ }
84
+ 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 : ""
87
+ }));
88
+ return;
89
+ }
38
90
  const webApps = findWebAppsList(apacheTomcatPath);
39
91
  for (const webApp of webApps) {
40
92
  const lightModulesPathToMagnoliaHomeRelPath = process.platform === 'win32' ? path.relative(webApp, lightModulesPath).replace(/\\/g, '/') : path.relative(webApp, lightModulesPath);
@@ -51,7 +103,9 @@ export const handleLightModulesFolder = () => __awaiter(void 0, void 0, void 0,
51
103
  });
52
104
  const editProperties = (filePath, props) => {
53
105
  if (!fs.existsSync(filePath)) {
54
- logger === null || logger === void 0 ? void 0 : logger.warn(`File ${filePath} doesn't exists, skipping configuration.`);
106
+ logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-helper-webapp-props-not-exist", {
107
+ filePath: filePath
108
+ }));
55
109
  return;
56
110
  }
57
111
  const propertiesFileContent = fs.readFileSync(filePath, 'utf-8');
@@ -59,11 +113,17 @@ const editProperties = (filePath, props) => {
59
113
  try {
60
114
  fs.writeFileSync(filePath, replacedContent);
61
115
  Object.keys(props).forEach((key) => {
62
- logger === null || logger === void 0 ? void 0 : logger.info(`Setting ${key} to: ${props[key]} in ${filePath}`);
116
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-webapp-prop-setting", {
117
+ key: key,
118
+ propsKey: props[key],
119
+ filePath: filePath
120
+ }));
63
121
  });
64
122
  }
65
123
  catch (error) {
66
- logger === null || logger === void 0 ? void 0 : logger.error(`An error occurred while updating 'magnolia.properties': ${error instanceof Error ? error.message : ""}`);
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 : ""
126
+ }));
67
127
  }
68
128
  };
69
129
  const replaceInConfig = (config, props) => {
@@ -84,7 +144,7 @@ export const findLightModulesFolder = (p) => {
84
144
  next();
85
145
  });
86
146
  walker.on('end', function () {
87
- return reject(new Error("light-modules was not found."));
147
+ return reject(new Error(i18nInstance.t("error-helper-lm-not-found")));
88
148
  });
89
149
  });
90
150
  };
@@ -100,30 +160,39 @@ export const findWebAppsList = (apacheTomcatPath) => {
100
160
  }
101
161
  return webApps;
102
162
  };
103
- export const installAdditionalPlugins = (plugins) => __awaiter(void 0, void 0, void 0, function* () {
104
- yield installAndConfigPlugins(plugins);
105
- });
106
163
  export const initializeNodeProject = () => __awaiter(void 0, void 0, void 0, function* () {
107
164
  yield handlePackageJSON();
108
165
  yield handleMGNLConfigFile();
109
166
  });
110
- export const installPackage = (packageManager, packageReference, packageName) => __awaiter(void 0, void 0, void 0, function* () {
167
+ export const installPackage = (packageManager, packageReference, packageName, credentials) => __awaiter(void 0, void 0, void 0, function* () {
111
168
  if (!packageName) {
112
169
  packageName = packageReference;
113
170
  }
114
- const spinner = ora().start(`Installing ${packageName}`);
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", {
178
+ packageName: packageName
179
+ }));
115
180
  try {
116
181
  yield execa(packageManager, [packageManager === 'npm' ? 'install' : 'add', packageReference], {
117
182
  buffer: true,
118
183
  cwd: process.cwd()
119
184
  });
120
185
  spinner.stop();
121
- logger === null || logger === void 0 ? void 0 : logger.info(`${packageName} installed`);
186
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-helper-package-installed", {
187
+ packageName: packageName
188
+ }));
122
189
  return true;
123
190
  }
124
191
  catch (error) {
125
192
  spinner.stop();
126
- logger === null || logger === void 0 ? void 0 : logger.error(`Failed to install ${packageName}`);
193
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-helper-fail-to-install-package", {
194
+ packageName: packageName
195
+ }));
127
196
  return false;
128
197
  }
129
198
  });
@@ -152,3 +221,17 @@ export const determinePackageManager = (baseDirectory = process.cwd()) => {
152
221
  // Default to npm
153
222
  return 'npm';
154
223
  };
224
+ export const askForCredentials = () => __awaiter(void 0, void 0, void 0, function* () {
225
+ return inquirer.prompt([
226
+ {
227
+ type: 'input',
228
+ name: 'username',
229
+ message: 'Username'
230
+ },
231
+ {
232
+ type: 'password',
233
+ name: 'password',
234
+ message: 'Password'
235
+ }
236
+ ]);
237
+ });
@@ -11,19 +11,19 @@ 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 { logger } from "../jumpstart-plugin.js";
14
+ import { i18nInstance, logger } from "../jumpstart-plugin.js";
15
15
  export const installDependencies = (bundle, command) => __awaiter(void 0, void 0, void 0, function* () {
16
- const spinner = ora('Installing dependencies').start();
16
+ const spinner = ora(i18nInstance.t("ora-installing-dep")).start();
17
17
  try {
18
18
  yield execa(command === PostCommands.YarnInstall ? 'yarn' : 'npm', ['install'], {
19
19
  buffer: true,
20
20
  cwd: path.join(process.cwd(), bundle.dest ? bundle.dest : "./")
21
21
  });
22
22
  spinner.stop();
23
- logger === null || logger === void 0 ? void 0 : logger.info('Dependencies installed');
23
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-install-dep"));
24
24
  }
25
25
  catch (e) {
26
26
  spinner.stop();
27
- logger === null || logger === void 0 ? void 0 : logger.error('Failed to install dependencies');
27
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-install-dep-fail"));
28
28
  }
29
29
  });
@@ -0,0 +1,73 @@
1
+ {
2
+ "cmd-option-description": "download and set up a new headless or freemarker-based project with Magnolia webapp",
3
+ "cmd-option-template": "choose a template from available project templates",
4
+ "cmd-option-project-templates-path": "specify the path to load project templates from",
5
+ "cmd-option-magnolia-version": "set the Magnolia version; defaults to the latest stable version",
6
+ "cmd-option-snapshot": "download the latest snapshot version of the specified or latest stable webapp",
7
+
8
+ "prompt-enter-credentials": "Please enter credentials for {{bundle}}",
9
+
10
+ "info-template_not_found": "The '{{template}}' template was not found.",
11
+ "info-jumpstart_started": "'JumpstartPlugin' plugin started successfully.",
12
+ "info-jumpstart_stopped": "'JumpstartPlugin' stopped",
13
+ "info-config-h-will-install-missing-plugins": "Will attempt to install missing plugins",
14
+ "info-config-h-mgnl-config-updated": "mgnl.config.js updated",
15
+ "info-config-h-mgnl-vars-added": "Shared variables added to mgnl.config.js",
16
+ "info-download-preparing": "Preparing to download {{url}}",
17
+ "info-download-starting": "Starting download from: {{downloadUrl}}",
18
+ "info-download-finished": "Download finished",
19
+ "info-download-status-error": "Failed to download from: {{downloadUrl}}. Expected 200, but received: {{status}}.",
20
+ "info-extensions-calling-fn": "Calling Function {{name}}.",
21
+ "info-extensions-install-done": "Installing Extension Dependencies. Done.",
22
+ "info-extract-extracting": "Extracting...",
23
+ "info-install-dep": "Dependencies installed",
24
+ "info-pj-helper-npm-done": "Running 'npm install' done",
25
+ "info-pj-helper-pj-created": "package.json created",
26
+ "info-pj-helper-add-mgnl-to-pj": "Adding \"mgnl\" script to package.json",
27
+ "info-helper-found-lm": "Found existing light-modules path at '{{lightModulesPath}}'",
28
+ "info-helper-no-lm-found": "No light-modules folder found. Attempting to create one.",
29
+ "info-helper-lm-created": "light-modules folder created at '{{lightModulesPath}}'.",
30
+ "info-helper-webapp-prop-setting": "Setting {{key}} to: {{propsKey}} in {{filePath}}",
31
+ "info-helper-package-installed": "{{packageName}} installed",
32
+
33
+ "warn-config-h-could-not-install-cli": "Couldn't install @magnolia/cli",
34
+ "warn-config-h-no-add-plugin": "Cannot find add-plugin command. Please update @magnolia/cli package.",
35
+ "warn-config-h-install-plugins-manually": "Please install following plugins:\n{{installPluginsText}}and add them to mgnl.config.js manually.",
36
+ "warn-pj-helper-changing-type": "Changing 'type' to \"module\"",
37
+ "warn-helper-webapp-props-not-exist": "File {{filePath}} doesn't exists, skipping configuration.",
38
+ "warn-helper-cannot-modify-webapp": "Cannot modify webapps: {{errorMsg}}",
39
+ "warn-config-h-error-cannot-parse-plugin-args": "Provided plugin argument:\n{{pluginArgs}}\nis not a valid JSON5 object.",
40
+
41
+ "error-config-h-could-not-read-mgnl-config": "Couldn't read {{configPath}}",
42
+ "error-config-h-could-not-parse-mgnl-config": "Couldn't parse {{configPath}}, please check the file for issues",
43
+ "error-config-h-while-updating-mgnl-config": "Error occurred while updating mgnl.config.js",
44
+ "error-config-h-while-adding-vars": "Error occurred while adding variables to mgnl.config.js",
45
+ "error-config-h-while-add-plugin": "An error occurred while installing following plugin: {{plugin}}",
46
+ "error-download-no-tags": "There are no available tags",
47
+ "error-download-problem-accessing-url": "A problem was detected while accessing: {{url}}.",
48
+ "error-download-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.",
49
+ "error-download-no-artifact-available": "No Magnolia bundle with \"{{version}}\" version is available.",
50
+ "error-extensions-calling-fn-retry": "Error Calling Function {{name}}. {{retry}}/{{maxRetry}}. Waiting {{delay}}ms before retry.",
51
+ "error-extensions-fn-not-found": "{{function}} Function not found",
52
+ "error-extensions-path-not-found": "{{extensionsPath}} not found. Could not evaluate custom prompts.",
53
+ "error-extensions-install-fail": "'{{packageManager}} install' has failed",
54
+ "error-extract-apache-tomcat-not-found": "apache-tomcat was not found.",
55
+ "error-install-dep-fail": "Failed to install dependencies",
56
+ "error-pj-helper-npm-fail": "'npm install' has failed",
57
+ "error-pj-helper-pj-mod-fail": "Failed to modify package.json",
58
+ "error-pj-helper-pj-create-fail": "Failed to create package.json",
59
+ "error-helper-lm-create-fail": "Failed to create 'light-modules' folder: {{errorMsg}}",
60
+ "error-helper-webapp-props-update-error": "An error occurred while updating 'magnolia.properties': {{errorMsg}}",
61
+ "error-helper-lm-not-found": "light-modules was not found",
62
+ "error-helper-fail-to-install-package": "Failed to install {{packageName}}",
63
+
64
+ "ora-updating-mgnl-config": "Updating mgnl.config.js",
65
+ "ora-adding-shared-vars": "Adding variables to mgnl.config.js",
66
+ "ora-installing-ext-dep": "Installing Extension Dependencies",
67
+ "ora-installing-dep": "Installing dependencies",
68
+ "ora-running-npm-install": "Didn't find 'node_modules' folder. Running 'npm install'",
69
+ "ora-creating-pj": "Creating package.json",
70
+ "ora-installing-package": "Installing {{packageName}}",
71
+
72
+ "install-plugin-with-args-text": "\twith following args: {{pluginArgs}}\n"
73
+ }
@@ -12,7 +12,7 @@ import ora from "ora";
12
12
  import fs from "fs-extra";
13
13
  import { execa } from "execa";
14
14
  import { determinePackageManager, installPackage } from "./helper.js";
15
- import { logger } from "../jumpstart-plugin.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)) {
@@ -31,7 +31,7 @@ export const modifyPackageJSON = (pjPath) => __awaiter(void 0, void 0, void 0, f
31
31
  }
32
32
  const nodeModulesPath = path.join(process.cwd(), "node_modules");
33
33
  if (!fs.existsSync(nodeModulesPath)) {
34
- const npmISpinner = ora().start("Didn't find 'node_modules' folder. Running 'npm install'");
34
+ const npmISpinner = ora().start(i18nInstance.t("ora-running-npm-install"));
35
35
  try {
36
36
  yield execa(determinePackageManager(), ["install"], {
37
37
  buffer: true,
@@ -40,11 +40,11 @@ export const modifyPackageJSON = (pjPath) => __awaiter(void 0, void 0, void 0, f
40
40
  }
41
41
  catch (e) {
42
42
  npmISpinner.stop();
43
- logger === null || logger === void 0 ? void 0 : logger.error("'npm install' has failed");
43
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-pj-helper-npm-fail"));
44
44
  return;
45
45
  }
46
46
  npmISpinner.stop();
47
- logger === null || logger === void 0 ? void 0 : logger.info("Running 'npm install' done");
47
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-pj-helper-npm-done"));
48
48
  }
49
49
  if (isMgnlCliInstalled) {
50
50
  const mgnlScript = { "mgnl": "node node_modules/@magnolia/cli" };
@@ -53,7 +53,7 @@ export const modifyPackageJSON = (pjPath) => __awaiter(void 0, void 0, void 0, f
53
53
  pj.scripts = {};
54
54
  }
55
55
  if (!pj.scripts[scriptKey] || pj.scripts[scriptKey] !== mgnlScript[scriptKey]) {
56
- logger === null || logger === void 0 ? void 0 : logger.info('Add "mgnl" script to package.json');
56
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-pj-helper-add-mgnl-to-pj"));
57
57
  pj.scripts[scriptKey] = mgnlScript[scriptKey];
58
58
  }
59
59
  }
@@ -61,19 +61,19 @@ export const modifyPackageJSON = (pjPath) => __awaiter(void 0, void 0, void 0, f
61
61
  pj.type = "module";
62
62
  }
63
63
  else if (pj.type !== "module") {
64
- logger === null || logger === void 0 ? void 0 : logger.warn(`Changing 'type' to "module"`);
64
+ logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-pj-helper-changing-type"));
65
65
  pj.type = "module";
66
66
  }
67
67
  try {
68
68
  fs.writeFileSync(pjPath, JSON.stringify(pj, null, '\t'), 'utf8');
69
69
  }
70
70
  catch (e) {
71
- logger === null || logger === void 0 ? void 0 : logger.error('Failed to modify package.json');
71
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-pj-helper-pj-mod-fail"));
72
72
  return;
73
73
  }
74
74
  });
75
75
  export const initPackageJSON = () => __awaiter(void 0, void 0, void 0, function* () {
76
- const pjSpinner = ora().start('Creating package.json');
76
+ const pjSpinner = ora().start(i18nInstance.t("ora-creating-pj"));
77
77
  try {
78
78
  yield execa(determinePackageManager(), ['init', '-y'], {
79
79
  buffer: true,
@@ -82,10 +82,10 @@ export const initPackageJSON = () => __awaiter(void 0, void 0, void 0, function*
82
82
  }
83
83
  catch (e) {
84
84
  pjSpinner.stop();
85
- logger === null || logger === void 0 ? void 0 : logger.info('Failed to create package.json');
85
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-pj-helper-pj-create-fail"));
86
86
  console.error(e);
87
87
  return;
88
88
  }
89
89
  pjSpinner.stop();
90
- logger === null || logger === void 0 ? void 0 : logger.info('package.json created');
90
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-pj-helper-pj-created"));
91
91
  });
package/dist/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@magnolia/cli-jumpstart-plugin",
3
- "version": "1.0.0-preview.3",
3
+ "version": "1.0.0-preview.5",
4
4
  "description": "Plugin to set up new projects using predefined templates and bundles. Easily select and configure project templates, and let the plugin handle bundle downloads, extraction, and post-command execution.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
8
- "build": "standard && tsc && cpy package.json dist",
7
+ "test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
8
+ "build": "standard --fix && tsc && cpy package.json dist && cpy lib/locales dist",
9
9
  "standard": "npx standard"
10
10
  },
11
11
  "keywords": [],
12
- "author": "",
13
- "license": "ISC",
12
+ "author": "Magnolia International Ltd.",
13
+ "license": "SEE LICENSE IN LICENSE.txt",
14
14
  "devDependencies": {
15
15
  "@jest/globals": "^29.6.3",
16
16
  "@types/decompress": "^4.2.4",
@@ -19,6 +19,7 @@
19
19
  "@types/js-beautify": "^1.14.0",
20
20
  "@types/node": "^20.3.3",
21
21
  "@types/progress": "^2.0.5",
22
+ "@types/underscore": "^1.11.14",
22
23
  "@types/walk": "^2.3.1",
23
24
  "@types/yauzl": "^2.10.1",
24
25
  "cpy-cli": "^5.0.0",
@@ -27,7 +28,9 @@
27
28
  "typescript": "^5.1.6"
28
29
  },
29
30
  "dependencies": {
31
+ "@babel/generator": "^7.24.4",
30
32
  "@babel/parser": "^7.23.6",
33
+ "@babel/traverse": "^7.24.1",
31
34
  "@babel/types": "^7.23.6",
32
35
  "@magnolia/cli-plugin-template": "^1.1.0",
33
36
  "axios": "^1.4.0",
@@ -37,12 +40,18 @@
37
40
  "dotenv": "^16.3.1",
38
41
  "execa": "^7.2.0",
39
42
  "fs-extra": "^11.1.1",
43
+ "glob": "^10.3.10",
44
+ "i18next": "^23.8.2",
45
+ "i18next-fs-backend": "^2.3.1",
40
46
  "inquirer": "^9.2.8",
41
47
  "js-beautify": "^1.14.9",
48
+ "json5": "^2.2.3",
42
49
  "ora": "^7.0.1",
43
50
  "progress": "^2.0.3",
51
+ "underscore": "^1.13.6",
44
52
  "walk": "^2.3.15",
45
- "winston": "^3.10.0"
53
+ "winston": "^3.10.0",
54
+ "yaml": "^2.3.4"
46
55
  },
47
56
  "type": "module",
48
57
  "standard": {
@@ -1,6 +1,8 @@
1
1
  export interface PluginOptions {
2
2
  template: string | boolean;
3
3
  projectTemplatesPath: string;
4
+ magnoliaVersion?: string;
5
+ snapshot?: boolean;
4
6
  }
5
7
  export interface Bundle {
6
8
  url: string;
@@ -10,6 +12,7 @@ export interface Bundle {
10
12
  dest?: string;
11
13
  downloadDest?: string;
12
14
  name?: string;
15
+ version?: string;
13
16
  }
14
17
  export interface TemplateBase {
15
18
  name: string;
@@ -19,51 +22,47 @@ export interface TemplateWithChildren extends TemplateBase {
19
22
  children: Array<Template>;
20
23
  bundles?: never;
21
24
  plugins?: never;
25
+ configVars?: never;
22
26
  }
23
27
  export interface TemplateWithBundles extends TemplateBase {
24
28
  bundles: Array<Bundle>;
25
29
  children?: never;
26
30
  plugins?: never;
31
+ configVars?: never;
27
32
  }
28
33
  export interface TemplateWithPlugins extends TemplateBase {
29
34
  plugins: Array<PluginRequirement>;
30
35
  bundles?: never;
31
36
  children?: never;
37
+ configVars?: never;
32
38
  }
33
39
  export interface TemplateWithBundlesAndPlugins extends TemplateBase {
34
40
  bundles: Array<Bundle>;
35
41
  plugins: Array<PluginRequirement>;
36
42
  children?: never;
43
+ configVars?: {
44
+ [key: string]: any;
45
+ };
37
46
  }
38
47
  export type TemplateWithoutChildren = TemplateWithBundles | TemplateWithPlugins | TemplateWithBundlesAndPlugins;
39
48
  export type Template = TemplateWithChildren | TemplateWithoutChildren;
40
49
  export interface PluginRequirement {
41
- name: string;
42
- installReference: string;
50
+ plugin: string;
51
+ pluginArgs?: any;
43
52
  }
44
53
  export type Credentials = {
45
54
  username: string;
46
55
  password: string;
47
- } | null;
56
+ } | undefined;
48
57
  export declare enum PostCommands {
49
58
  Extract = "extract",
50
59
  ExtractAndOverride = "extract and override",
60
+ ExtractAndUnfold = "extract and unfold",
51
61
  NpmInstall = "npm install",
52
62
  YarnInstall = "yarn install"
53
63
  }
54
- export interface PluginRequirement {
55
- name: string;
56
- installReference: string;
57
- }
58
- export type ImportItem = {
59
- importedNames: string;
60
- importSource: string;
61
- };
62
- export interface CommandItem {
63
- commandName: string;
64
+ export interface PostCommandFunction {
65
+ function: string;
66
+ delay: number;
67
+ retry: number;
64
68
  }
65
- export type ParsedConfigData = {
66
- configContent: string;
67
- imports: ImportItem[];
68
- commands: CommandItem[];
69
- };
@@ -2,6 +2,7 @@ export var PostCommands;
2
2
  (function (PostCommands) {
3
3
  PostCommands["Extract"] = "extract";
4
4
  PostCommands["ExtractAndOverride"] = "extract and override";
5
+ PostCommands["ExtractAndUnfold"] = "extract and unfold";
5
6
  PostCommands["NpmInstall"] = "npm install";
6
7
  PostCommands["YarnInstall"] = "yarn install";
7
8
  })(PostCommands || (PostCommands = {}));
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@magnolia/cli-jumpstart-plugin",
3
- "version": "1.0.0-preview.3",
3
+ "version": "1.0.0-preview.5",
4
4
  "description": "Plugin to set up new projects using predefined templates and bundles. Easily select and configure project templates, and let the plugin handle bundle downloads, extraction, and post-command execution.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
8
- "build": "standard && tsc && cpy package.json dist",
7
+ "test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
8
+ "build": "standard --fix && tsc && cpy package.json dist && cpy lib/locales dist",
9
9
  "standard": "npx standard"
10
10
  },
11
11
  "keywords": [],
12
- "author": "",
13
- "license": "ISC",
12
+ "author": "Magnolia International Ltd.",
13
+ "license": "SEE LICENSE IN LICENSE.txt",
14
14
  "devDependencies": {
15
15
  "@jest/globals": "^29.6.3",
16
16
  "@types/decompress": "^4.2.4",
@@ -19,6 +19,7 @@
19
19
  "@types/js-beautify": "^1.14.0",
20
20
  "@types/node": "^20.3.3",
21
21
  "@types/progress": "^2.0.5",
22
+ "@types/underscore": "^1.11.14",
22
23
  "@types/walk": "^2.3.1",
23
24
  "@types/yauzl": "^2.10.1",
24
25
  "cpy-cli": "^5.0.0",
@@ -27,7 +28,9 @@
27
28
  "typescript": "^5.1.6"
28
29
  },
29
30
  "dependencies": {
31
+ "@babel/generator": "^7.24.4",
30
32
  "@babel/parser": "^7.23.6",
33
+ "@babel/traverse": "^7.24.1",
31
34
  "@babel/types": "^7.23.6",
32
35
  "@magnolia/cli-plugin-template": "^1.1.0",
33
36
  "axios": "^1.4.0",
@@ -37,12 +40,18 @@
37
40
  "dotenv": "^16.3.1",
38
41
  "execa": "^7.2.0",
39
42
  "fs-extra": "^11.1.1",
43
+ "glob": "^10.3.10",
44
+ "i18next": "^23.8.2",
45
+ "i18next-fs-backend": "^2.3.1",
40
46
  "inquirer": "^9.2.8",
41
47
  "js-beautify": "^1.14.9",
48
+ "json5": "^2.2.3",
42
49
  "ora": "^7.0.1",
43
50
  "progress": "^2.0.3",
51
+ "underscore": "^1.13.6",
44
52
  "walk": "^2.3.15",
45
- "winston": "^3.10.0"
53
+ "winston": "^3.10.0",
54
+ "yaml": "^2.3.4"
46
55
  },
47
56
  "type": "module",
48
57
  "standard": {