@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.
package/README.md CHANGED
@@ -1,153 +1,42 @@
1
- # CLI Jumpstart Plugin
2
-
3
- **NOTE:** *This version of the Jumpstart plugin is still under development. The README will be updated continuosly as we refine the plugin.*
4
-
5
- The Jumpstart Plugin is a part of the Magnolia CLI's plugin system. This plugin is designed to facilitate the process of starting new projects using predefined templates and bundles. It allows users to choose a template and download associated bundles while performing necessary tasks such as authentication, bundle downloading, extraction, and post-command execution.
1
+ # JumpstartPlugin
2
+ A plugin for [Magnolia CLI](https://docs.magnolia-cms.com/magnolia-cli) to download and set up a new headless or freemarker-based project with Magnolia webapp
6
3
 
7
4
  ## Installation
8
-
9
- The Jumpstart plugin is by default installed in the MGNL plugin-system and ready to be used.
5
+ Within the Magnolia CLI plugin system, this plugin is pre-installed and ready to be used.
10
6
 
11
7
  ## Usage
12
- The Jumpstart Plugin enhances the Magnolia CLI by providing a streamlined way to start new projects using predefined templates and bundles. Users can select templates, which are collections of bundles, and have the plugin handle the download, extraction, and execution of post-commands.
13
-
14
- **Jumpstart command:**
15
-
8
+ ### Options
9
+
10
+ | Short | Long | Description |
11
+ |----------------|--------------------------------|-------------------------------------------------------------------------------|
12
+ | `-m <version>` | `--magnolia <version>` | set the Magnolia version; defaults to the latest stable version |
13
+ | `-s` | `--snapshot` | download the latest snapshot version of the specified or latest stable webapp |
14
+ | `-t <name>` | `--template <name>` | choose a template from available project templates |
15
+ | `-p <source>` | `--project-templates <source>` | specify the source to load project templates from |
16
+ | `-v` | `--version` | output the version number |
17
+ | `-h` | `--help` | display help for command |
18
+
19
+ ### Examples
20
+ #### Jumpstart a project
16
21
  ```bash
17
- magnolia-cli jumpstart
22
+ npx @magnolia/cli jumpstart
18
23
  ```
24
+ This command will prompt you with a list of available templates to choose from. Once you select a template, the CLI will download and configure the project with the latest Magnolia version (or with version associated with that template)
19
25
 
20
- This command initiates the **jumpstart** plugin.
21
- When run, the plugin will prompt the user to select a template. It will then proceed to download and extract the required bundles, executing post-commands if specified, install required plugins, initialize package.json project and create mgnl.config.js.
22
-
23
-
24
- ![select-template.png](images/select-template.png)
25
-
26
-
27
- ### **command-line options**
28
-
29
- You can customize the **jumpstart** plugin's actions using these command-line options:
30
- - `-t, --template <name>`, choose a template from available project templates
31
- - `-p, --project-templates-path <path>`, specify the path to load project templates from
32
- - `-m, --magnolia-version <version>`, set the Magnolia version; defaults to the latest stable version
33
- - `-s, --snapshot`, download the latest snapshot version of the specified or latest stable webapp
34
-
35
- **Template option:**
36
-
37
- With this option, you can specify which template to use:
38
-
26
+ #### Jumpstart a project with specific template
39
27
  ```bash
40
- magnolia-cli jumpstart --template "headless/minimal-headless-spa-demos/dx-core"
28
+ npx @magnolia/cli jumpstart --template "standard-webapps/magnolia-community-webapp"
41
29
  ```
30
+ This command will start downloading and configuring project based on "standard-webapps/magnolia-community-webapp" template with latest Magnolia version.
42
31
 
43
-
44
- **Project templates list:**
45
-
46
- The **jumpstart** plugin relies on a list of predefined project templates stored in an external [repository](https://bitbucket.org/magnolia-cms/cli-project-templates/raw/HEAD/projectTemplates.json).
47
- You can specify your own project templates list with the *--project-templates-path* command:
48
-
32
+ #### Jumpstart a project with specific template and specific magnolia version
49
33
  ```bash
50
- magnolia-cli jumpstart -p "<project-templates-path>"
34
+ npx @magnolia/cli jumpstart --template "standard-webapps/magnolia-community-webapp" --magnolia "6.2.11"
51
35
  ```
36
+ This command will start downloading and configuring project based on "standard-webapps/magnolia-community-webapp" template with 6.2.11 Magnolia version.
52
37
 
38
+ ## Plugin Documentation
39
+ For detailed documentation of the plugin, please refer to [Plugin Documentation](https://docs.magnolia-cms.com/magnolia-cli)
53
40
 
54
- ## Extensions
55
-
56
- The extensions functionality allows for greater flexibility and customizability during the setup process of a new Magnolia project.
57
-
58
- ### Extension YAML Configuration
59
-
60
- The plugin searches for extension YAML files in the following path within your project directory:
61
- `<rootdir>/extensions/extension.yaml`
62
-
63
- This YAML file defines additional prompts and post-command functions, which can be helpful for tailoring the plugin's functionality to specific project requirements.
64
-
65
- ### Structure of the YAML File
66
-
67
- An extension YAML file typically contains the following key sections:
68
-
69
- - `extend`: Specifies a JavaScript file that the extension will tie into for additional logic or configuration.
70
- - `prompts`: A series of input prompts to gather necessary information from the user. Each prompt can specify:
71
- - `type`: The type of prompt, such as `input` for user text input.
72
- - `name`: The internal name used to reference the collected data.
73
- - `message`: The message displayed to the user during the prompt.
74
- - `default`: The default value for the prompt, used if the user provides no input.
75
- - `commands`: Defines actions to be taken after the prompts have been completed, such as:
76
- - `post`: Commands to be executed after the setup process. This could involve downloading dependencies, setting up environment variables, etc.
77
-
78
- ### Example
79
-
80
- ```yaml
81
- extend: ./example.js
82
- prompts:
83
- - type: input
84
- name: clientId
85
- message: Client ID
86
- default: clientId_001
87
-
88
- - type: input
89
- name: organizationId
90
- message: Organization Id
91
- default: organizationId_001
92
-
93
- - type: input
94
- name: siteId
95
- message: Site Id
96
- default: siteId_001
97
-
98
- commands:
99
- post:
100
- - function: example
101
- retry: 3
102
- delay: 1000
103
- ```
104
-
105
- ### Execution Flow
106
-
107
- Upon project initialization, if an extension file is detected, the **Jumpstart** Plugin performs the following steps:
108
-
109
- 1. **Input Gathering**: It prompts the user for input based on the `prompts` defined within the extension's YAML file.
110
-
111
- 2. **Configuration Integration**: The plugin retrieves the main **package.json** file. The responses gathered from the prompts are then added to this configuration object under an `answers` property. This augmented **package.json** object is subsequently used to automatically populate the corresponding placeholders within your project files.
112
-
113
- 3. **Post-Command Execution**: Each `post-command` function specified in the YAML file is executed. These functions have access to the `prompts` object, which contains the user's responses, allowing the functions to perform tasks that are tailored to the user's input.
114
-
115
- ### Customization Example
116
-
117
- After gathering inputs, a file containing placeholders like below:
118
- ```js
119
- // config.js
120
-
121
- export default {
122
- clientId: <%=answers.siteId%>,
123
- organizationId: <%=answers.organizationId%>,
124
- siteId: <%=answers.siteId%>
125
- };
126
- ```
127
- will be transformed into:
128
- ```js
129
- // config.js
130
-
131
- export default {
132
- clientId: clientId_001,
133
- organizationId: organizationId_001,
134
- siteId: siteId_001
135
- };
136
- ```
137
-
138
- By using the **Jumpstart** Plugin's extensions functionality, developers can create a more interactive and automated project setup process, making it easier to get started with a new Magnolia project.
139
-
140
- ## Light-modules folder:
141
-
142
- The Jumpstart Plugin initiates a recursive search throughout the project's directory structure for an existing `light-modules` directory. Upon detection, the plugin avoids creating a new one, instead utilizing the existing directory to maintain the pre-configured modules. On the other hand, if a `light-modules` directory is not found, the system will generate one.
143
-
144
- **magnolia.properties file:**
145
-
146
- The Jumpstart Plugin automatically applies specific modifications to the 'magnolia.properties' files of magnoliaAuthor and magnoliaPublic webapps.
147
-
148
- Following properties are modified:
149
- - 'magnolia.resources.dir' is adjusted to reference the `light-modules` directory.
150
- - 'magnolia.update.auto' is set to true
151
-
152
- ## Conclusion
153
- The Jumpstart Plugin demonstrates an effective way to streamline the process of setting up new projects by providing template-based automation for downloading, extracting, and handling bundles. With its intuitive command-line interface and detailed documentation, users can quickly get started with the Magnolia CLI's powerful plugin system.
41
+ ## Magnolia CMS
42
+ This plugin is created to work with Magnolia CMS. For more information, please refer to [Magnolia CMS Documentation](https://docs.magnolia-cms.com/home/)
@@ -9,6 +9,7 @@ export declare let i18nInstance: {
9
9
  export default class JumpstartPlugin extends PluginTemplate {
10
10
  name: string;
11
11
  version: any;
12
+ usage: string;
12
13
  projectTemplates?: Array<Template>;
13
14
  options: Option[];
14
15
  credentials?: Credentials;
@@ -33,13 +33,14 @@ export default class JumpstartPlugin extends PluginTemplate {
33
33
  super();
34
34
  this.name = "jumpstart";
35
35
  this.version = pkg.version;
36
+ this.usage = "[options]";
36
37
  i18nInstance = initI18n(this.name);
37
- this.description = i18nInstance.t('cmd-option-description');
38
+ this.description = i18nInstance.t('description');
38
39
  this.options = [
39
- new Option('-t, --template <name>', i18nInstance.t("cmd-option-template")),
40
- new Option('-p, --project-templates-path <path>', i18nInstance.t("cmd-option-project-templates-path")),
41
- new Option('-m, --magnolia-version <version>', i18nInstance.t('cmd-option-magnolia-version')),
42
- new Option('-s, --snapshot', i18nInstance.t('cmd-option-snapshot'))
40
+ new Option('-m, --magnolia <version>', i18nInstance.t('option-magnolia-description')),
41
+ new Option('-s, --snapshot', i18nInstance.t('option-snapshot-description')),
42
+ new Option('-t, --template <name>', i18nInstance.t("option-template-description")),
43
+ new Option('-pt, --project-templates <source>', i18nInstance.t("option-projectTemplates-description"))
43
44
  ];
44
45
  }
45
46
  executePostCommands(bundle, file) {
@@ -64,19 +65,13 @@ export default class JumpstartPlugin extends PluginTemplate {
64
65
  handleTemplate(template, options) {
65
66
  return __awaiter(this, void 0, void 0, function* () {
66
67
  if (template.auth) {
67
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("prompt-enter-credentials", {
68
- bundle: template.name
69
- }));
70
- this.credentials = yield askForCredentials();
68
+ this.credentials = yield askForCredentials(template.name);
71
69
  }
72
70
  for (const bundle of template.bundles || []) {
73
71
  let file;
74
72
  try {
75
73
  if (bundle.auth === true) {
76
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('prompt-enter-credentials', {
77
- bundle: bundle.name ? bundle.name : bundle.url
78
- }));
79
- const bundleCredentials = yield askForCredentials();
74
+ const bundleCredentials = yield askForCredentials(bundle.name ? bundle.name : bundle.url);
80
75
  file = yield downloadBundle(bundle, bundleCredentials, undefined, options);
81
76
  }
82
77
  else {
@@ -87,7 +82,7 @@ export default class JumpstartPlugin extends PluginTemplate {
87
82
  }
88
83
  }
89
84
  catch (e) {
90
- logger.error(e.message);
85
+ logger === null || logger === void 0 ? void 0 : logger.error(e.message);
91
86
  }
92
87
  }
93
88
  yield handleLightModulesFolder();
@@ -110,21 +105,31 @@ export default class JumpstartPlugin extends PluginTemplate {
110
105
  setProjectTemplates(options) {
111
106
  return __awaiter(this, void 0, void 0, function* () {
112
107
  var _a;
108
+ let errorMsg;
113
109
  try {
114
- if ((_a = options.projectTemplatesPath) === null || _a === void 0 ? void 0 : _a.startsWith("http", 0)) {
115
- const res = yield axios.get(options.projectTemplatesPath);
110
+ if ((_a = options.projectTemplates) === null || _a === void 0 ? void 0 : _a.startsWith("http", 0)) {
111
+ errorMsg = i18nInstance.t("error-no-projectTemplates-from-url", { url: options.projectTemplates });
112
+ const res = yield axios.get(options.projectTemplates);
116
113
  this.projectTemplates = res.data.projectTemplates;
117
114
  }
118
- else if (options.projectTemplatesPath) {
119
- this.projectTemplates = requireFn(path.resolve(options.projectTemplatesPath)).projectTemplates;
115
+ else if (options.projectTemplates) {
116
+ errorMsg = i18nInstance.t("error-no-projectTemplates-from-path", { path: options.projectTemplates });
117
+ this.projectTemplates = requireFn(path.resolve(options.projectTemplates)).projectTemplates;
120
118
  }
121
119
  else {
120
+ errorMsg = i18nInstance.t("error-no-projectTemplates-from-default");
122
121
  const res = yield axios.get("https://bitbucket.org/magnolia-cms/cli-project-templates/raw/HEAD/projectTemplates.json");
123
122
  this.projectTemplates = res.data.projectTemplates;
124
123
  }
125
124
  }
126
125
  catch (e) {
127
- logger.error(e.message);
126
+ if (errorMsg) {
127
+ throw new Error(errorMsg);
128
+ }
129
+ else {
130
+ console.error(i18nInstance.t("error-while-getting-projectTemplates"));
131
+ throw e;
132
+ }
128
133
  }
129
134
  });
130
135
  }
@@ -143,7 +148,7 @@ export default class JumpstartPlugin extends PluginTemplate {
143
148
  {
144
149
  type: 'rawlist',
145
150
  name: 'template',
146
- message: 'Please choose a template?',
151
+ message: i18nInstance.t('inquirer-prompt-choose-template'),
147
152
  choices: choices
148
153
  }
149
154
  ]);
@@ -182,7 +187,7 @@ export default class JumpstartPlugin extends PluginTemplate {
182
187
  return;
183
188
  }
184
189
  else {
185
- logger.info(i18nInstance.t("info-template_not_found", {
190
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-template-not-found", {
186
191
  template: options.template
187
192
  }));
188
193
  }
@@ -213,15 +218,13 @@ export default class JumpstartPlugin extends PluginTemplate {
213
218
  }
214
219
  start(options) {
215
220
  return __awaiter(this, void 0, void 0, function* () {
216
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-jumpstart_started"));
217
221
  this.checkFlagsArguments(options);
218
222
  yield this.setProjectTemplates(options);
219
223
  yield this.chooseTemplate(options);
224
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-project-downloaded'));
220
225
  });
221
226
  }
222
227
  stop() {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-jumpstart_stopped"));
225
- });
228
+ return __awaiter(this, void 0, void 0, function* () { });
226
229
  }
227
230
  }
@@ -14,7 +14,7 @@ const generate = _generate.default;
14
14
  const traverse = _traverse.default;
15
15
  import beautifyModule from "js-beautify";
16
16
  import path from "path";
17
- import { determinePackageManager, installPackage } from "./helper.js";
17
+ import { determinePackageManager, installCLI } from "./helper.js";
18
18
  import ora from "ora";
19
19
  import { i18nInstance, logger } from "../jumpstart-plugin.js";
20
20
  import _generate from "@babel/generator";
@@ -33,22 +33,35 @@ const BEAUTIFY_OPTIONS = {
33
33
  const getLocalConfigPath = () => path.join(process.cwd(), 'mgnl.config.js');
34
34
  const getPackageConfigPath = () => path.join(process.cwd(), 'node_modules/@magnolia/cli/mgnl.config.js');
35
35
  export const installAdditionalPlugins = (plugins) => __awaiter(void 0, void 0, void 0, function* () {
36
+ let spinner = ora().start(i18nInstance.t("ora-start-checking-add-plugin"));
37
+ let showManualInstallMsg = false;
36
38
  const pm = determinePackageManager();
37
- const addPluginExists = yield execa(pm, 'run mgnl -s -- add-plugin -v'.split(' '), { cwd: process.cwd() });
38
- if (addPluginExists.exitCode !== 0 || !addPluginExists.stdout.match(/(\d.)+(\d).*/)) {
39
- logger.warn(i18nInstance.t("warn-config-h-no-add-plugin"));
39
+ try {
40
+ const addPluginExists = yield execa(pm, 'run mgnl -s -- add-plugin -v'.split(' '), { cwd: process.cwd() });
41
+ if (addPluginExists.exitCode !== 0 || !addPluginExists.stdout.match(/(\d.)+(\d).*/)) {
42
+ spinner.warn(i18nInstance.t("ora-warn-no-add-plugin"));
43
+ showManualInstallMsg = true;
44
+ }
45
+ spinner.stop();
46
+ }
47
+ catch (e) {
48
+ showManualInstallMsg = true;
49
+ spinner.fail(i18nInstance.t("ora-fail-while-add-plugin-check", { errorMsg: e.message }));
50
+ }
51
+ if (showManualInstallMsg) {
40
52
  let installPluginsText = "";
41
53
  plugins.forEach(plugin => {
42
54
  installPluginsText = `${installPluginsText} - ${plugin.plugin}\n`;
43
55
  if (plugin.pluginArgs) {
44
- installPluginsText = `${installPluginsText}${i18nInstance.t("install-plugin-with-args-text", { pluginArgs: JSON5.stringify(plugin.pluginArgs) })}`;
56
+ installPluginsText = `${installPluginsText}${i18nInstance.t("text-install-plugin-with-args", { pluginArgs: JSON5.stringify(plugin.pluginArgs) })}`;
45
57
  }
46
58
  });
47
- logger.warn(i18nInstance.t("warn-config-h-install-plugins-manually", { installPluginsText: installPluginsText }));
59
+ logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t("warn-install-plugins-manually", { installPluginsText: installPluginsText }));
48
60
  return;
49
61
  }
50
62
  for (const plugin of plugins) {
51
63
  try {
64
+ let argsMsg;
52
65
  const addPluginArgs = `run mgnl -s -- add-plugin ${plugin.plugin}`.split(' ');
53
66
  try {
54
67
  if (plugin.pluginArgs !== undefined && plugin.pluginArgs !== 'undefined' && plugin.pluginArgs !== '') {
@@ -56,35 +69,37 @@ export const installAdditionalPlugins = (plugins) => __awaiter(void 0, void 0, v
56
69
  }
57
70
  }
58
71
  catch (e) {
59
- logger.warn(i18nInstance.t('warn-config-h-error-cannot-parse-plugin-args', { pluginArgs: plugin.pluginArgs }));
72
+ argsMsg = i18nInstance.t('warn-cannot-parse-plugin-args', { pluginArgs: plugin.pluginArgs, plugin: plugin.plugin });
60
73
  }
61
74
  yield execa(pm, addPluginArgs, {
62
75
  stdio: 'inherit',
63
76
  cwd: process.cwd()
64
77
  });
78
+ if (argsMsg) {
79
+ logger === null || logger === void 0 ? void 0 : logger.warn(argsMsg);
80
+ }
81
+ logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t('info-plugin-installed', { plugin: plugin.plugin }));
65
82
  }
66
83
  catch (e) {
67
- logger.error(i18nInstance.t('error-config-h-while-add-plugin', { plugin: plugin }));
84
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t('error-while-add-plugin', { plugin: plugin.plugin, errorMsg: e.message }));
68
85
  }
69
86
  }
70
87
  });
71
88
  export const handleMGNLConfigFile = () => __awaiter(void 0, void 0, void 0, function* () {
72
89
  let isMgnlCliInstalled = true;
73
90
  if (!fs.existsSync(getPackageConfigPath())) {
74
- isMgnlCliInstalled = yield installPackage(determinePackageManager(), "@magnolia/cli@preview");
75
- logger === null || logger === void 0 ? void 0 : logger.warn(i18nInstance.t('warn-config-h-could-not-install-cli'));
76
- }
77
- if (isMgnlCliInstalled && fs.existsSync(getLocalConfigPath())) {
78
- handleExistingConfigFile();
79
- }
80
- else if (isMgnlCliInstalled && !fs.existsSync(getLocalConfigPath())) {
81
- createMgnlConfigFile();
91
+ isMgnlCliInstalled = yield installCLI();
82
92
  }
83
- else if (!isMgnlCliInstalled && !fs.existsSync(getLocalConfigPath())) {
84
- createSimpleMgnlConfigFile();
93
+ if (isMgnlCliInstalled) {
94
+ if (fs.existsSync(getLocalConfigPath())) {
95
+ handleExistingConfigFile();
96
+ }
97
+ else {
98
+ createMgnlConfigFile();
99
+ }
85
100
  }
86
101
  else {
87
- // the mgnl.config.js exist, do not do anything
102
+ logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-mgnl-cli-not-installed"));
88
103
  }
89
104
  });
90
105
  const handleExistingConfigFile = () => {
@@ -94,8 +109,8 @@ const handleExistingConfigFile = () => {
94
109
  const globalLoggerConfig = extractLoggerConfig(packageConfigContent);
95
110
  if (!localLoggerConfig && (globalLoggerConfig && globalLoggerConfig[1])) {
96
111
  const loggerContent = getLoggerContent(globalLoggerConfig[1]);
97
- const newLocalConfigContent = localConfigContent.replace(/(export default \{)/, `$1${loggerContent}`);
98
- writeConfigContent(newLocalConfigContent);
112
+ const newLocalConfigContent = localConfigContent.replace(/(export\s+default\s+\{)/, `$1${loggerContent}`);
113
+ writeConfigContent(newLocalConfigContent, false);
99
114
  }
100
115
  };
101
116
  function createMgnlConfigFile() {
@@ -111,15 +126,7 @@ function createMgnlConfigFile() {
111
126
  plugins: []
112
127
  };`;
113
128
  const mgnlConfigContent = mgnlConfigPrefix + logger + mgnlConfigSufix;
114
- writeConfigContent(mgnlConfigContent);
115
- }
116
- function createSimpleMgnlConfigFile() {
117
- const mgnlConfigContent = `
118
- export default {
119
- // Here you can add plugins you want to use with MGNL CLI
120
- plugins: []
121
- };`;
122
- writeConfigContent(mgnlConfigContent);
129
+ writeConfigContent(mgnlConfigContent, true);
123
130
  }
124
131
  function getLoggerContent(logger) {
125
132
  return `
@@ -131,21 +138,18 @@ const extractLoggerConfig = (content) => {
131
138
  const loggerRegex = /(logger\s*:\s*{[^}]*})/s;
132
139
  return loggerRegex.exec(content);
133
140
  };
134
- const writeConfigContent = (content) => {
135
- const spinner = ora().start(i18nInstance.t("ora-updating-mgnl-config"));
141
+ const writeConfigContent = (content, creating) => {
142
+ const spinner = ora().start(i18nInstance.t(creating ? "ora-start-creating-config" : "ora-start-updating-config"));
136
143
  try {
137
144
  fs.writeFileSync(getLocalConfigPath(), js_beautify(content.trim(), BEAUTIFY_OPTIONS), 'utf-8');
145
+ spinner.succeed(i18nInstance.t(creating ? "ora-succeed-config-created" : "ora-succeed-config-updated"));
138
146
  }
139
147
  catch (e) {
140
- spinner.stop();
141
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-config-h-while-updating-mgnl-config"));
142
- console.error(e);
148
+ spinner.fail(i18nInstance.t(creating ? "ora-fail-creating-config" : "ora-fail-updating-config", { errorMsg: e.message }));
143
149
  }
144
- spinner.stop();
145
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-config-h-mgnl-config-updated"));
146
150
  };
147
151
  export const addConfigProps = (vars) => __awaiter(void 0, void 0, void 0, function* () {
148
- const spinner = ora().start(i18nInstance.t("ora-adding-shared-vars"));
152
+ const spinner = ora().start(i18nInstance.t("ora-start-adding-shared-vars"));
149
153
  try {
150
154
  const filePath = getLocalConfigPath();
151
155
  let content = fs.readFileSync(filePath, 'utf-8');
@@ -198,13 +202,10 @@ export const addConfigProps = (vars) => __awaiter(void 0, void 0, void 0, functi
198
202
  if (modificationsMade) {
199
203
  const output = generate(ast, {}, content);
200
204
  fs.writeFileSync(getLocalConfigPath(), js_beautify(output.code.trim(), BEAUTIFY_OPTIONS), 'utf-8');
201
- spinner.stop();
202
- logger === null || logger === void 0 ? void 0 : logger.info(i18nInstance.t("info-config-h-mgnl-vars-added"));
205
+ spinner.succeed(i18nInstance.t("ora-succeed-shared-vars-added"));
203
206
  }
204
207
  }
205
208
  catch (e) {
206
- spinner.stop();
207
- logger === null || logger === void 0 ? void 0 : logger.error(i18nInstance.t("error-config-h-while-adding-vars"));
208
- console.error(e);
209
+ spinner.fail(i18nInstance.t("error-while-adding-vars", { errorMsg: e.message }));
209
210
  }
210
211
  });