@magnolia/cli-jumpstart-plugin 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.3 (2025-09-16)
4
+ * Jumpstart should resolve template path before switching CWD ([MGNLCLI-421](https://magnolia-cms.atlassian.net/browse/MGNLCLI-421))
5
+
3
6
  ## 1.1.2 (2025-08-08)
4
7
  * Ask for credentials before checking for tomcat ([MGNLCLI-417](https://magnolia-cms.atlassian.net/browse/MGNLCLI-417))
5
8
 
@@ -18,7 +18,7 @@ export default class JumpstartPlugin extends PluginTemplate {
18
18
  constructor();
19
19
  executePostCommands(bundle: Bundle, file: string): Promise<void>;
20
20
  handleTemplate(template: TemplateWithoutChildren, options: PluginOptions): Promise<void>;
21
- setProjectTemplates(options: PluginOptions): Promise<void>;
21
+ setProjectTemplates(options: PluginOptions, originalCwd: string): Promise<void>;
22
22
  promptTemplateSelection(templates: Array<Template>, names?: string[]): Promise<TemplateWithoutChildren | undefined>;
23
23
  findTemplateByIdentifier(identifier: string): TemplateWithoutChildren | undefined;
24
24
  chooseTemplate(options: PluginOptions): Promise<void>;
@@ -143,7 +143,7 @@ export default class JumpstartPlugin extends PluginTemplate {
143
143
  }
144
144
  });
145
145
  }
146
- setProjectTemplates(options) {
146
+ setProjectTemplates(options, originalCwd) {
147
147
  return __awaiter(this, void 0, void 0, function* () {
148
148
  var _a;
149
149
  let errorMsg;
@@ -154,8 +154,13 @@ export default class JumpstartPlugin extends PluginTemplate {
154
154
  this.projectTemplates = res.data.projectTemplates;
155
155
  }
156
156
  else if (options.projectTemplates) {
157
- errorMsg = i18nInstance.t('error-no-projectTemplates-from-path', { path: options.projectTemplates });
158
- this.projectTemplates = requireFn(path.resolve(options.projectTemplates)).projectTemplates;
157
+ const projectTemplatesPath = path.resolve(originalCwd, options.projectTemplates);
158
+ if (!fs.existsSync(projectTemplatesPath)) {
159
+ throw new CreateError(i18nInstance.t('error-projectTemplates-file-not-found', { path: projectTemplatesPath }));
160
+ }
161
+ errorMsg = i18nInstance.t('error-no-projectTemplates-from-path', { path: projectTemplatesPath });
162
+ this.projectTemplates =
163
+ requireFn(projectTemplatesPath).projectTemplates;
159
164
  }
160
165
  else {
161
166
  errorMsg = i18nInstance.t('error-no-projectTemplates-from-default');
@@ -164,7 +169,10 @@ export default class JumpstartPlugin extends PluginTemplate {
164
169
  }
165
170
  }
166
171
  catch (e) {
167
- if (errorMsg) {
172
+ if (e instanceof CreateError) {
173
+ throw e;
174
+ }
175
+ else if (errorMsg) {
168
176
  throw new CreateError(errorMsg + `\n${e.message}`);
169
177
  }
170
178
  else {
@@ -347,7 +355,7 @@ export default class JumpstartPlugin extends PluginTemplate {
347
355
  process.chdir(targetDir);
348
356
  }
349
357
  try {
350
- yield this.setProjectTemplates(options);
358
+ yield this.setProjectTemplates(options, originalCwd);
351
359
  yield this.chooseTemplate(options);
352
360
  logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-downloaded'));
353
361
  logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-registered-commands'));
@@ -53,6 +53,7 @@
53
53
  "error-while-getting-projectTemplates": "An error occurred while getting \"projectTemplates\":",
54
54
  "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?",
55
55
  "error-no-projectTemplates-from-path": "Cannot read projectTemplates from a local file located at: \"{{path}}\"; is it a JSON file?",
56
+ "error-projectTemplates-file-not-found": "ProjectTemplates file not found at: \"{{path}}\"; please check the file path and ensure the file exists",
56
57
  "error-no-projectTemplates-from-default": "Cannot fetch default projectTemplates; are you connected to the internet?",
57
58
  "error-extensions-calling-fn-retry": "Error calling function: \"{{name}}\"; {{retry}}/{{maxRetry}}; waiting {{delay}}ms before retry",
58
59
  "error-extensions-fn-not-found": "\"{{function}}\" function not found",
package/dist/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@magnolia/cli-jumpstart-plugin",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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": {
7
7
  "prepare": "husky || true",
8
- "test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
9
- "build": "npm run lint && tsc && cpy package.json dist && cpy lib/locales dist",
8
+ "test": "npm run lint && npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
9
+ "build": "tsc && cpy package.json dist && cpy lib/locales dist",
10
10
  "depcheck": "depcheck",
11
11
  "lint": "eslint .",
12
12
  "lint:fix": "npm run lint -- --fix",
@@ -25,6 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@jest/globals": "^29.7.0",
27
27
  "@types/decompress": "^4.2.7",
28
+ "@types/filenamify": "^2.0.1",
28
29
  "@types/fs-extra": "^11.0.4",
29
30
  "@types/inquirer": "^9.0.7",
30
31
  "@types/js-beautify": "^1.14.3",
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@magnolia/cli-jumpstart-plugin",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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": {
7
7
  "prepare": "husky || true",
8
- "test": "npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
9
- "build": "npm run lint && tsc && cpy package.json dist && cpy lib/locales dist",
8
+ "test": "npm run lint && npm run build && node --experimental-vm-modules node_modules/jest/bin/jest.js",
9
+ "build": "tsc && cpy package.json dist && cpy lib/locales dist",
10
10
  "depcheck": "depcheck",
11
11
  "lint": "eslint .",
12
12
  "lint:fix": "npm run lint -- --fix",
@@ -25,6 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@jest/globals": "^29.7.0",
27
27
  "@types/decompress": "^4.2.7",
28
+ "@types/filenamify": "^2.0.1",
28
29
  "@types/fs-extra": "^11.0.4",
29
30
  "@types/inquirer": "^9.0.7",
30
31
  "@types/js-beautify": "^1.14.3",