Skip to content

Commit

Permalink
fix: remove updater
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Nov 26, 2023
1 parent f38c469 commit 15386dd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 51 deletions.
7 changes: 1 addition & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"extends": "eslint-config-egg",
"rules": {
"no-console": "off",
"no-else-return": "off",
"linebreak-style": "off"
}
"extends": "eslint-config-egg"
}
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -85,6 +82,7 @@ module.exports = {
## License
[MIT](LICENSE)
<!-- GITCONTRIBUTOR_START -->
## Contributors
Expand All @@ -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`.
<!-- GITCONTRIBUTOR_END -->
<!-- GITCONTRIBUTOR_END -->
63 changes: 26 additions & 37 deletions lib/init_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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;

Check warning on line 177 in lib/init_command.js

View check run for this annotation

Codecov / codecov/patch

lib/init_command.js#L175-L177

Added lines #L175 - L177 were not covered by tests
}

/**
Expand Down Expand Up @@ -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,
};
}));

Check warning on line 236 in lib/init_command.js

View check run for this annotation

Codecov / codecov/patch

lib/init_command.js#L226-L236

Added lines #L226 - L236 were not covered by tests
}

/**
Expand Down Expand Up @@ -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';
}

Check warning on line 355 in lib/init_command.js

View check run for this annotation

Codecov / codecov/patch

lib/init_command.js#L354-L355

Added lines #L354 - L355 were not covered by tests
url = url.replace(/\/$/, '');
return url;

}
}
}
Expand Down Expand Up @@ -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;

Check warning on line 533 in lib/init_command.js

View check run for this annotation

Codecov / codecov/patch

lib/init_command.js#L532-L533

Added lines #L532 - L533 were not covered by tests
}
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 15386dd

Please sign in to comment.