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

Updates (particularly for spdx-correct and spdx-satisfies) #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
language: node_js
node_js:
- "node"
- "8"
- "8.3"
- "10"
- "12"
before_script: >
node_version=$(node -v);
if [ ${node_version:3:1} = "." ]; then
echo "Node 10+"
else
echo "Node 8"
npm install --no-save "eslint@5"
fi
script:
- npm run test
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/

const program = require('commander');
const packageJson = require('./package.json');
const moment = require('moment');
const inquirer = require('inquirer');
const colors = require('colors/safe');
const packageJson = require('./package.json');
const getPackageDetails = require('./lib/getPackageDetails');
const walkDependencies = require('./lib/walkDependencies');
const showImpact = require('./lib/showImpact');
const showDetails = require('./lib/showDetails');
const showQuickStats = require('./lib/showQuickStats');
const colors = require('colors/safe');
const install = require('./lib/install');
const exec = require('./lib/exec');
const getInstallCommand = require(
Expand Down
2 changes: 1 addition & 1 deletion lib/calculateImpactPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function flatingPackages(packages) {
let duplicated = false;
for (let i = 0; i < flatPackages.length; i += 1) {
const key = flatPackages[i];
const name = packages[key].name;
const { name } = packages[key];
if (name === newName) {
duplicated = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file exec command with args
*/

const spawn = require('child_process').spawn;
const { spawn } = require('child_process');

/**
* @param {string} command
Expand Down
2 changes: 1 addition & 1 deletion lib/getInstallCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file get install command considering package manager and arguments
*/

const testYarn = require('./testYarn');
const program = require('commander');
const testYarn = require('./testYarn');
const isProduction = require('./isProduction');

/**
Expand Down
6 changes: 4 additions & 2 deletions lib/getLicenseStr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
module.exports = function getLicenseStr(licenseObj) {
if (typeof licenseObj === 'string') {
return licenseObj;
} else if (Array.isArray(licenseObj)) {
}
if (Array.isArray(licenseObj)) {
return `(${licenseObj.map(getLicenseStr).join(` OR `)})`;
} else if (typeof licenseObj === 'object') {
}
if (typeof licenseObj === 'object') {
return licenseObj.type || `Unknown`;
}
return `Unknown`;
Expand Down
2 changes: 1 addition & 1 deletion lib/getLocalPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @file get local package.json
*/

const findPrefixPromise = require('./findPrefixPromise');
const fs = require('fs');
const path = require('path');
const findPrefixPromise = require('./findPrefixPromise');

/**
* @return {Promise.<Object>} package.json
Expand Down
11 changes: 7 additions & 4 deletions lib/getPackageDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

const fetch = require('node-fetch');
const semver = require('semver');
const url = require('url');
const readline = require('readline');
const rc = require('rc');
const getLicenseStr = require('./getLicenseStr');
const getLicenseType = require('./getLicenseType');
const url = require('url');
const printError = require('./printError');
const readline = require('readline');

const packageDetailsCache = {};
const npmConfig = require('rc')('npm', {
const npmConfig = rc('npm', {
registry: `https://registry.npmjs.org/`
});

Expand Down Expand Up @@ -108,7 +109,9 @@ function getPackageJsonFromGitHub(owner, repo, ref) {
* @param {string} versionLoose
* @returns {object} details like dependencies, version, size, license, modified
*/
function getPackageDetailsFromGitHub({ host, path, hash, protocol }, versionLoose) {
function getPackageDetailsFromGitHub({
host, path, hash, protocol
}, versionLoose) {
let owner;
let repo;
if (protocol === 'github:') {
Expand Down
4 changes: 3 additions & 1 deletion lib/getPackagesStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ module.exports = function getPackagesStats(packages) {
}
licenseTypes[type] += licenses[license];
});
return { count, size, licenses, licenseTypes };
return {
count, size, licenses, licenseTypes
};
};
10 changes: 5 additions & 5 deletions lib/install.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* @file install action
*/
const getLocalPackage = require('./getLocalPackage');
const colors = require('colors/safe');
const inquirer = require('inquirer');
const filesize = require('filesize');
const program = require('commander');
const readline = require('readline');
const getLocalPackage = require('./getLocalPackage');
const walkDependencies = require('./walkDependencies');
const getInstallCommand = require('./getInstallCommand');
const inquirer = require('inquirer');
const exec = require('./exec');
const showDetails = require('./showDetails');
const isProduction = require('./isProduction');
const getPackagesStats = require('./getPackagesStats');
const formatLicenseType = require('./formatLicenseType');
const filesize = require('filesize');
const getSimpleTable = require('./getSimpleTable');
const program = require('commander');
const readline = require('readline');
const printError = require('./printError');

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/showImpact.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
*/

const program = require('commander');
const filesize = require('filesize');
const readline = require('readline');
const getLocalPackage = require('./getLocalPackage');
const calculateImpactPackages = require('./calculateImpactPackages');
const satisfies = require('./satisfies');
const walkDependencies = require('./walkDependencies');
const getPackagesStats = require('./getPackagesStats');
const filesize = require('filesize');
const getSimpleTable = require('./getSimpleTable');
const readline = require('readline');

/**
* @param {Object} impactLicenses license -> count
Expand Down Expand Up @@ -67,9 +67,9 @@ module.exports = function showImpact(
const devDependencies = localPackage.devDependencies || {};
let allDependencies;
if (program.args[1].saveDev) {
allDependencies = Object.assign({}, dependencies, devDependencies);
allDependencies = { ...dependencies, ...devDependencies };
} else {
allDependencies = Object.assign({}, dependencies);
allDependencies = { ...dependencies };
}
if (Object.keys(allDependencies).length === 0) {
console.log('Local package has no dependencies');
Expand Down
4 changes: 2 additions & 2 deletions lib/showQuickStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* @file print quick stats
*/

const filesize = require('filesize');
const readline = require('readline');
const getPackagesStats = require('./getPackagesStats');
const formatLicenseType = require('./formatLicenseType');
const filesize = require('filesize');
const getSimpleTable = require('./getSimpleTable');
const readline = require('readline');

/**
* @param {Object} packages
Expand Down
2 changes: 1 addition & 1 deletion lib/testYarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @file detects if package initialised with yarn
*/

const findPrefixPromise = require('./findPrefixPromise');
const fs = require('fs');
const path = require('path');
const findPrefixPromise = require('./findPrefixPromise');

module.exports = function testYarn() {
return findPrefixPromise().then((packagePath) => {
Expand Down