generator-jhipster-sentry-module 1.0.5 → 1.0.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.
@@ -2,7 +2,7 @@ const path = require('path');
2
2
  const fs = require('fs');
3
3
  const chalk = require('chalk');
4
4
  const semver = require('semver');
5
- const Generator = require('yeoman-generator'); // Use Yeoman directly
5
+ const Generator = require('yeoman-generator');
6
6
  const packageJson = require('../../package.json');
7
7
 
8
8
  // JHipster constants
@@ -14,7 +14,7 @@ const jhipsterConstants = {
14
14
 
15
15
  module.exports = class extends Generator {
16
16
  async initializing() {
17
- // Read config
17
+ // Read JHipster config
18
18
  this.jhipsterAppConfig = this.fs.readJSON(this.destinationPath('.yo-rc.json'), {})['generator-jhipster'];
19
19
  if (!this.jhipsterAppConfig) {
20
20
  this.log(chalk.red('Cannot read .yo-rc.json or JHipster config missing'));
@@ -72,6 +72,7 @@ module.exports = class extends Generator {
72
72
  config['generator-jhipster'].sentry = this.jhipsterAppConfig.sentry;
73
73
  this.fs.writeJSON(configPath, config, null, 2);
74
74
 
75
+ // Logging
75
76
  this.log('\n--- JHipster Config ---');
76
77
  this.log(`baseName=${this.baseName}`);
77
78
  this.log(`packageName=${this.packageName}`);
@@ -86,7 +87,7 @@ module.exports = class extends Generator {
86
87
  return;
87
88
  }
88
89
 
89
- // Backend: add dependencies manually
90
+ // Backend dependencies
90
91
  if (this.buildTool === 'maven') {
91
92
  const pomPath = this.destinationPath('pom.xml');
92
93
  if (fs.existsSync(pomPath)) {
@@ -117,28 +118,28 @@ module.exports = class extends Generator {
117
118
  }
118
119
  }
119
120
 
120
- // Frontend
121
+ // Frontend templates
121
122
  if (this.clientFramework === 'react') {
122
- this.npmInstall(['@sentry/react@^7.3.0'], { 'save': true });
123
123
  this.fs.copyTpl(this.templatePath('client/react/sentry.ts.ejs'), `${webappDir}app/sentry.ts`);
124
- }
125
- if (this.clientFramework === 'angularX') {
126
- this.npmInstall(['@sentry/angular@^7.3.0'], { 'save': true });
124
+ } else if (this.clientFramework === 'angularX') {
127
125
  this.fs.copyTpl(this.templatePath('client/angular/sentry.ts.ejs'), `${webappDir}app/sentry.ts`);
128
126
  }
129
127
  }
130
128
 
131
129
  install() {
132
- const logMsg = `To install dependencies manually, run: ${chalk.yellow.bold(`${this.clientPackageManager} install`)}`;
133
- if (this.options['skip-install']) {
134
- this.log(logMsg);
135
- return;
130
+ if (!this.promptAnswers.enableSentry) return;
131
+
132
+ const packages = [];
133
+ if (this.clientFramework === 'react') {
134
+ packages.push('@sentry/react@^7.3.0');
135
+ } else if (this.clientFramework === 'angularX') {
136
+ packages.push('@sentry/angular@^7.3.0');
137
+ }
138
+
139
+ if (packages.length > 0) {
140
+ const cmd = this.clientPackageManager === 'yarn' ? 'add' : 'install';
141
+ this.spawnCommandSync(this.clientPackageManager, [...(this.clientPackageManager === 'yarn' ? ['add'] : ['install']), ...packages]);
136
142
  }
137
- this.installDependencies({
138
- npm: this.clientPackageManager === 'npm',
139
- yarn: this.clientPackageManager === 'yarn',
140
- bower: false
141
- });
142
143
  }
143
144
 
144
145
  end() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-jhipster-sentry-module",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Adding Sentry integration to JHipster projects",
5
5
  "keywords": [
6
6
  "yeoman-generator",