diff --git a/.eslintrc b/.eslintrc index 78c98eb..c799fe5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,3 @@ { - "extends": "eslint-config-egg", - "rules": { - "no-console": "off", - "no-else-return": "off", - "linebreak-style": "off" - } + "extends": "eslint-config-egg" } diff --git a/README.md b/README.md index 5171f27..3e0fea8 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,12 @@ [![NPM version][npm-image]][npm-url] [![Node.js CI](https://github.com/eggjs/egg-init/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-init/actions/workflows/nodejs.yml) [![Test coverage][codecov-image]][codecov-url] -[![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] [npm-image]: https://img.shields.io/npm/v/egg-init.svg?style=flat-square [npm-url]: https://npmjs.org/package/egg-init [codecov-image]: https://codecov.io/gh/eggjs/egg-init/branch/master/graph/badge.svg [codecov-url]: https://codecov.io/gh/eggjs/egg-init -[snyk-image]: https://snyk.io/test/npm/egg-init/badge.svg?style=flat-square -[snyk-url]: https://snyk.io/test/npm/egg-init [download-image]: https://img.shields.io/npm/dm/egg-init.svg?style=flat-square [download-url]: https://npmjs.org/package/egg-init diff --git a/README.zh-CN.md b/README.zh-CN.md index 48ab9d0..272c671 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -3,15 +3,12 @@ [![NPM version][npm-image]][npm-url] [![Node.js CI](https://github.com/eggjs/egg-init/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-init/actions/workflows/nodejs.yml) [![Test coverage][codecov-image]][codecov-url] -[![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][download-url] [npm-image]: https://img.shields.io/npm/v/egg-init.svg?style=flat-square [npm-url]: https://npmjs.org/package/egg-init [codecov-image]: https://codecov.io/gh/eggjs/egg-init/branch/master/graph/badge.svg [codecov-url]: https://codecov.io/gh/eggjs/egg-init -[snyk-image]: https://snyk.io/test/npm/egg-init/badge.svg?style=flat-square -[snyk-url]: https://snyk.io/test/npm/egg-init [download-image]: https://img.shields.io/npm/dm/egg-init.svg?style=flat-square [download-url]: https://npmjs.org/package/egg-init @@ -85,6 +82,7 @@ module.exports = { ## License [MIT](LICENSE) + ## Contributors @@ -96,4 +94,4 @@ module.exports = { This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Nov 25 2023 23:06:04 GMT+0800`. - \ No newline at end of file + diff --git a/lib/init_command.js b/lib/init_command.js index 6da17d1..8ee368e 100644 --- a/lib/init_command.js +++ b/lib/init_command.js @@ -3,7 +3,6 @@ const assert = require('node:assert'); const fs = require('node:fs'); const path = require('node:path'); const urllib = require('urllib'); -const updater = require('npm-updater'); const mkdirp = require('mkdirp'); const inquirer = require('inquirer'); const yargs = require('yargs'); @@ -21,7 +20,6 @@ module.exports = class Command { this.name = options.name || 'egg-init'; this.configName = options.configName || 'egg-init-config'; this.pkgInfo = options.pkgInfo || require('../package.json'); - this.needUpdate = options.needUpdate !== false; this.httpClient = urllib; this.inquirer = inquirer; @@ -44,15 +42,6 @@ module.exports = class Command { this.registryUrl = this.getRegistryByType(argv.registry); this.log(`use registry: ${this.registryUrl}`); - if (this.needUpdate) { - // check update - await updater({ - package: this.pkgInfo, - registry: this.registryUrl, - level: 'major', - }); - } - // ask for target dir this.targetDir = await this.getTargetDirectory(); @@ -182,10 +171,10 @@ module.exports = class Command { if (shouldInstall) { return boilerplateInfo; - } else { - console.log(`Exit due to: ${boilerplateInfo.deprecate}`); - return; } + console.log(`Exit due to: ${boilerplateInfo.deprecate}`); + return; + } /** @@ -232,19 +221,19 @@ module.exports = class Command { }, {}); this.log('use default due to --silent, %j', result); return result; - } else { - return await inquirer.prompt(keys.map(key => { - const question = questions[key]; - return { - type: question.type || 'input', - name: key, - message: question.description || question.desc, - default: question.default, - filter: question.filter, - choices: question.choices, - }; - })); } + return await inquirer.prompt(keys.map(key => { + const question = questions[key]; + return { + type: question.type || 'input', + name: key, + message: question.description || question.desc, + default: question.default, + filter: question.filter, + choices: question.choices, + }; + })); + } /** @@ -357,16 +346,16 @@ module.exports = class Command { default: { if (/^https?:/.test(key)) { return key.replace(/\/$/, ''); - } else { - // support .npmrc - const home = homedir(); - let url = process.env.npm_registry || process.env.npm_config_registry || 'https://registry.npmjs.org'; - if (fs.existsSync(path.join(home, '.cnpmrc')) || fs.existsSync(path.join(home, '.tnpmrc'))) { - url = 'https://registry.npmmirror.com'; - } - url = url.replace(/\/$/, ''); - return url; } + // support .npmrc + const home = homedir(); + let url = process.env.npm_registry || process.env.npm_config_registry || 'https://registry.npmjs.org'; + if (fs.existsSync(path.join(home, '.cnpmrc')) || fs.existsSync(path.join(home, '.tnpmrc'))) { + url = 'https://registry.npmmirror.com'; + } + url = url.replace(/\/$/, ''); + return url; + } } } @@ -539,9 +528,9 @@ module.exports = class Command { if (withFallback) { this.log(`use fallback from ${pkgName}`); return require(`${pkgName}/package.json`); - } else { - throw err; } + throw err; + } } diff --git a/package.json b/package.json index 85bcb00..c692669 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "mkdirp": "^0.5.1", "mz-modules": "^2.1.0", "node-homedir": "^2.0.0", - "npm-updater": "^3.0.3", "urllib": "^3.19.3", "yargs": "^11.1.0" },