@loopback/cli 4.1.1 → 4.1.2

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.
@@ -8,7 +8,6 @@ const BaseGenerator = require('../../lib/base-generator');
8
8
  const {updateFileHeaders} = require('./header');
9
9
  const {spdxLicenseList, updateLicense} = require('./license');
10
10
  const g = require('../../lib/globalize');
11
- const _ = require('lodash');
12
11
  const chalk = require('chalk');
13
12
  const autocomplete = require('inquirer-autocomplete-prompt');
14
13
 
@@ -77,19 +76,19 @@ module.exports = class CopyrightGenerator extends BaseGenerator {
77
76
 
78
77
  async promptOwnerAndLicense() {
79
78
  const pkgFile = this.destinationPath('package.json');
80
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
81
- if (pkg == null) {
79
+ if (!this.existsDestination('package.json')) {
82
80
  this.exit(`${pkgFile} does not exist.`);
83
81
  return;
84
82
  }
85
- this.packageJson = pkg;
86
- let author = _.get(pkg, 'author');
83
+ let author = this.packageJson.get('author');
87
84
  if (typeof author === 'object') {
88
85
  author = author.name;
89
86
  }
90
87
  const owner =
91
- this.options.copyrightOwner || _.get(pkg, 'copyright.owner', author);
92
- let license = this.options.license || _.get(pkg, 'license');
88
+ this.options.copyrightOwner ||
89
+ this.packageJson.get('copyright.owner') ||
90
+ author;
91
+ let license = this.options.license || this.packageJson.get('license');
93
92
  const licenses = [...this.licenseList];
94
93
  if (license != null) {
95
94
  // find the matching license by id and move it to the front of the list
@@ -86,13 +86,12 @@ async function updateLicense(projectRoot, pkg, options) {
86
86
  if (typeof licenseId === 'object') {
87
87
  licenseId = licenseId.id;
88
88
  }
89
- pkg.license = licenseId;
90
- pkg['copyright.owner'] = options.copyrightOwner;
91
- await fs.writeJSON(path.join(projectRoot, 'package.json'), pkg);
89
+ pkg.set('license', licenseId);
90
+ pkg.set('copyright.owner', options.copyrightOwner);
92
91
  await fs.write(
93
92
  path.join(projectRoot, 'LICENSE'),
94
93
  renderLicense({
95
- name: pkg.name,
94
+ name: pkg.get('name'),
96
95
  owner: options.copyrightOwner,
97
96
  license: options.license,
98
97
  years: await getYears(projectRoot),
@@ -5,6 +5,7 @@
5
5
 
6
6
  'use strict';
7
7
 
8
+ const _ = require('lodash');
8
9
  const Generator = require('yeoman-generator');
9
10
  const chalk = require('chalk');
10
11
  const {StatusConflicter, readTextFromStdin} = require('./utils');
@@ -15,6 +16,8 @@ const updateIndex = require('./update-index');
15
16
  const {checkLoopBackProject} = require('./version-helper');
16
17
  const g = require('./globalize');
17
18
 
19
+ _.extend(Generator.prototype, require('yeoman-generator/lib/actions/install'));
20
+
18
21
  const supportedPackageManagers = ['npm', 'yarn'];
19
22
 
20
23
  debug('Is stdin interactive (isTTY)?', process.stdin.isTTY);
@@ -47,10 +50,9 @@ module.exports = class BaseGenerator extends Generator {
47
50
  constructor(args, opts) {
48
51
  super(args, opts);
49
52
  debug('Initializing generator', this.constructor.name);
50
- this.conflicter = new StatusConflicter(
51
- this.env.adapter,
52
- this.options.force,
53
- );
53
+ this.conflicter = new StatusConflicter(this.env.adapter, {
54
+ force: this.options.force,
55
+ });
54
56
  this._setupGenerator();
55
57
  }
56
58
 
@@ -479,14 +481,15 @@ module.exports = class BaseGenerator extends Generator {
479
481
 
480
482
  // Check all files being generated to ensure they succeeded
481
483
  _isGenerationSuccessful() {
482
- const generationStatus = !!Object.entries(
483
- this.conflicter.generationStatus,
484
- ).find(([key, val]) => {
485
- // If a file was modified, update the indexes and say stuff about it
486
- return val !== 'skip' && val !== 'identical';
487
- });
488
- debug(`Generation status: ${generationStatus}`);
489
- return generationStatus;
484
+ // const generationStatus = !!Object.entries(
485
+ // this.conflicter.generationStatus,
486
+ // ).find(([key, val]) => {
487
+ // // If a file was modified, update the indexes and say stuff about it
488
+ // return val !== 'skip' && val !== 'identical';
489
+ // });
490
+ // debug(`Generation status: ${generationStatus}`);
491
+ // return generationStatus;
492
+ return true; // FixMe: Conflicter does not work
490
493
  }
491
494
 
492
495
  async _updateIndexFile(dir, file) {
package/lib/debug.js CHANGED
@@ -12,5 +12,5 @@ const debug = require('debug');
12
12
  * @param {String=} scope The scope to use for the debug statement.
13
13
  */
14
14
  module.exports = function (scope) {
15
- return debug(`loopback:cli${scope ? `:${scope}` : ''}`);
15
+ return debug('loopback:cli').extend(scope);
16
16
  };
@@ -96,7 +96,7 @@ module.exports = class ProjectGenerator extends BaseGenerator {
96
96
  * from files that have it during project generation.
97
97
  */
98
98
  _setupRenameTransformer() {
99
- this.registerTransformStream(utils.renameEJS());
99
+ this.queueTransformStream(utils.renameEJS());
100
100
  }
101
101
 
102
102
  async setOptions() {
package/lib/utils.js CHANGED
@@ -23,7 +23,7 @@ const toVarName = require('change-case').camelCase;
23
23
  const pluralize = require('pluralize');
24
24
  const urlSlug = require('url-slug');
25
25
  const validate = require('validate-npm-package-name');
26
- const Conflicter = require('yeoman-generator/lib/util/conflicter');
26
+ const Conflicter = require('yeoman-environment/conflicter');
27
27
  const connectors = require('./connectors.json');
28
28
  const tsquery = require('./ast-helper');
29
29
  const stringifyObject = require('stringify-object');
@@ -300,8 +300,8 @@ exports.validateUrlSlug = function (name) {
300
300
  * Extends conflicter so that it keeps track of conflict status
301
301
  */
302
302
  exports.StatusConflicter = class StatusConflicter extends Conflicter {
303
- constructor(adapter, force) {
304
- super(adapter, force);
303
+ constructor(adapter, opts) {
304
+ super(adapter, opts);
305
305
  this.generationStatus = {}; // keeps track of file conflict history
306
306
  }
307
307
 
@@ -35,7 +35,6 @@ function printVersions(log = console.log) {
35
35
  */
36
36
  async function checkDependencies(generator) {
37
37
  const pkg = generator.fs.readJSON(generator.destinationPath('package.json'));
38
- generator.packageJson = pkg;
39
38
 
40
39
  const isUpdate = generator.command === 'update';
41
40
  const pkgDeps = pkg
@@ -131,7 +130,7 @@ async function checkDependencies(generator) {
131
130
  return;
132
131
  }
133
132
 
134
- const originalCliVersion = generator.config.get('update') || '<unknown>';
133
+ const originalCliVersion = generator.config.get('version') || '<unknown>';
135
134
  generator.log(
136
135
  chalk.red(
137
136
  g.f(
@@ -169,7 +168,7 @@ async function checkDependencies(generator) {
169
168
  */
170
169
  function updateDependencies(generator) {
171
170
  const pkg =
172
- generator.packageJson ||
171
+ generator.packageJson.getAll() ||
173
172
  generator.fs.readJSON(generator.destinationPath('package.json'));
174
173
  const depUpdates = [];
175
174
  for (const d in templateDeps) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loopback/cli",
3
3
  "description": "Yeoman generator for LoopBack 4",
4
- "version": "4.1.1",
4
+ "version": "4.1.2",
5
5
  "keywords": [
6
6
  "LoopBack",
7
7
  "CLI",
@@ -39,7 +39,7 @@
39
39
  ".yo-rc.json"
40
40
  ],
41
41
  "dependencies": {
42
- "@lerna/project": "^5.1.6",
42
+ "@lerna/project": "^5.4.0",
43
43
  "@openapi-contrib/openapi-schema-to-json-schema": "^3.2.0",
44
44
  "@phenomnomnominal/tsquery": "^4.2.0",
45
45
  "camelcase-keys": "^7.0.2",
@@ -77,8 +77,8 @@
77
77
  "url-slug": "^3.0.4",
78
78
  "validate-npm-package-name": "^4.0.0",
79
79
  "write-file-atomic": "^4.0.1",
80
- "yeoman-environment": "^2.10.3",
81
- "yeoman-generator": "^4.13.0"
80
+ "yeoman-environment": "^3.10.0",
81
+ "yeoman-generator": "^5.7.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@loopback/build": "^9.0.2",
@@ -87,17 +87,19 @@
87
87
  "@types/ejs": "^3.1.1",
88
88
  "@types/fs-extra": "^9.0.13",
89
89
  "@types/minimatch": "^3.0.5",
90
- "@types/node": "^14.18.21",
90
+ "@types/node": "^14.18.23",
91
+ "@types/yeoman-environment": "^2.10.7",
92
+ "@types/yeoman-generator": "^5.2.10",
91
93
  "loopback": "^3.28.0",
92
94
  "loopback-datasource-juggler": "^4.27.1",
93
95
  "mem-fs": "^2.2.1",
94
- "mem-fs-editor": "^9.4.0",
96
+ "mem-fs-editor": "^9.5.0",
95
97
  "mock-stdin": "^1.0.0",
96
98
  "rimraf": "^3.0.2",
97
99
  "sinon": "^11.1.2",
98
100
  "strong-globalize-cli": "7.1.0",
99
101
  "yeoman-assert": "^3.1.1",
100
- "yeoman-test": "^4.0.2"
102
+ "yeoman-test": "^6.3.0"
101
103
  },
102
104
  "config": {
103
105
  "templateDependencies": {
@@ -194,5 +196,5 @@
194
196
  "@loopback/example-references-many": "^6.0.2"
195
197
  }
196
198
  },
197
- "gitHead": "d2eddfc1319810f4c0126e613c24499b5685f7e4"
199
+ "gitHead": "cc63323e20cf39c62402f1dee108bf9e9d23e133"
198
200
  }