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

Refactor CLI to use npm and yarn instead of third party packages #3275

Merged
merged 2 commits into from
Mar 24, 2018
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
2 changes: 1 addition & 1 deletion lib/cli/lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import latestVersion from 'latest-version';
import { sync as spawnSync } from 'cross-spawn';
import { gt } from 'semver';
import latestVersion from './latest_version';

import { version, devDependencies } from '../package.json';

Expand Down
17 changes: 17 additions & 0 deletions lib/cli/lib/latest_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { sync as spawnSync } from 'cross-spawn';
import hasYarn from './has_yarn';

const packageManager = hasYarn() ? 'yarn' : 'npm';

export default async function latestVersion(packageName) {
const result = spawnSync(packageManager, ['info', packageName, '--json'], {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason not to use ${packageManager} info ${packageName} version?

cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
silent: true,
});

const info = JSON.parse(result.output[1].toString());
return info.data.version;
}
1 change: 0 additions & 1 deletion lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"cross-spawn": "^6.0.5",
"jscodeshift": "^0.5.0",
"json5": "^0.5.1",
"latest-version": "^3.1.0",
"merge-dirs": "^0.2.1",
"semver": "^5.5.0",
"shelljs": "^0.8.1",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9304,7 +9304,7 @@ latest-version@^2.0.0:
dependencies:
package-json "^2.0.0"

latest-version@^3.0.0, latest-version@^3.1.0:
latest-version@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15"
dependencies:
Expand Down