Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove updater #83

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@
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 @@
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 @@

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 @@
}, {});
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 @@
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 @@
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