You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/01/09 23:55:13 UTC

[GitHub] brodybits closed pull request #225: npm audit fixes, eslint config updates

brodybits closed pull request #225: npm audit fixes, eslint config updates
URL: https://github.com/apache/cordova-coho/pull/225
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/package.json b/package.json
index 968b4a5c8..5d5a6bbc2 100644
--- a/package.json
+++ b/package.json
@@ -17,24 +17,24 @@
     "jasmine-co": "^1.2.2",
     "jira-client": "4.2.0",
     "jira-linkify": "^2.3.0",
-    "nlf": "^1.4.3",
+    "nlf": "^2.0.1",
     "opener": "^1.4.1",
     "optimist": "0.4",
     "q": "1.4.1",
-    "request": "^2.69.0",
+    "request": "^2.88.0",
     "semver": "^4.2.0",
     "shelljs": "0.1.4",
     "treeify": "^1.0.1",
     "xml2js": "0.4.17"
   },
   "devDependencies": {
-    "eslint": "^3.19.0",
-    "eslint-config-semistandard": "^11.0.0",
-    "eslint-config-standard": "^10.2.1",
-    "eslint-plugin-import": "^2.3.0",
-    "eslint-plugin-node": "^5.0.0",
-    "eslint-plugin-promise": "^3.5.0",
-    "eslint-plugin-standard": "^3.0.1",
+    "eslint": "^5.12.0",
+    "eslint-config-semistandard": "^13.0.0",
+    "eslint-config-standard": "^12.0.0",
+    "eslint-plugin-import": "^2.13.0",
+    "eslint-plugin-node": "^7.0.1",
+    "eslint-plugin-promise": "^4.0.0",
+    "eslint-plugin-standard": "^4.0.0",
     "tap-dot": "^1.0.0",
     "tap-spec": "^5.0.0",
     "tape": "^4.0.0",
diff --git a/src/audit-license-headers.js b/src/audit-license-headers.js
index e4bd2d95c..aa2af1743 100644
--- a/src/audit-license-headers.js
+++ b/src/audit-license-headers.js
@@ -79,7 +79,7 @@ module.exports = function * () {
         process.exit(1);
     }
 
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
     yield module.exports.scrubRepos(repos);
 };
 
diff --git a/src/check-license.js b/src/check-license.js
index 7ac55d3a2..4d5c4732b 100644
--- a/src/check-license.js
+++ b/src/check-license.js
@@ -45,7 +45,7 @@ module.exports = function * () {
         optimist.showHelp();
         process.exit(1);
     }
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
     checkLicense(repos);
 };
 
diff --git a/src/create-pr.js b/src/create-pr.js
index 62f423d58..154297196 100644
--- a/src/create-pr.js
+++ b/src/create-pr.js
@@ -61,7 +61,7 @@ function * getRemoteForkName (remoteName) {
     var remotes = (yield executil.execHelper(executil.ARGS('git remote -v'), /* silent */ true)).split('\n');
     var remoteUrl;
     for (var i = 0; i < remotes.length; i++) {
-       // fork    https://github.com/forkName/cordova-coho.git (push)
+        // fork    https://github.com/forkName/cordova-coho.git (push)
         var tokens = remotes[i].split(/\s+/);
         if (tokens[2] === '(push)' && tokens[0] === remoteName) {
             remoteUrl = tokens[1];
diff --git a/src/create-verify-archive.js b/src/create-verify-archive.js
index 31fe7d3db..5456cf99f 100644
--- a/src/create-verify-archive.js
+++ b/src/create-verify-archive.js
@@ -68,7 +68,7 @@ exports.createCommand = function * (argv) {
         optimist.showHelp();
         process.exit(1);
     }
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
 
     if (argv.sign && !shelljs.which('gpg')) {
         apputil.fatal('gpg command not found on your PATH. Refer to ' + settingUpGpg);
diff --git a/src/executil.js b/src/executil.js
index e461d0dd8..b67db2231 100644
--- a/src/executil.js
+++ b/src/executil.js
@@ -52,7 +52,7 @@ function execHelper (cmdAndArgs, silent, allowError, win, fail) {
     if (!silent || silent === 3 || exports.verbose) {
         apputil.print('Executing:', cmdAndArgs.join(' '));
     }
-    var result = superspawn.spawn(cmdAndArgs[0], cmdAndArgs.slice(1), {stdio: (silent && (silent !== 2)) ? 'default' : 'inherit'});
+    var result = superspawn.spawn(cmdAndArgs[0], cmdAndArgs.slice(1), { stdio: (silent && (silent !== 2)) ? 'default' : 'inherit' });
     return result.then(win || null, fail || function (e) {
         if (allowError) {
             throw e;
diff --git a/src/last-week.js b/src/last-week.js
index ed577ad90..e24924a84 100644
--- a/src/last-week.js
+++ b/src/last-week.js
@@ -54,7 +54,7 @@ module.exports = function * () {
         optimist.showHelp();
         process.exit(1);
     }
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
     var filterByEmail = !!argv.me || !!argv.user;
     var days = argv.days || 7;
     var userEmail = filterByEmail && (argv.user || meEmail);
diff --git a/src/list-pulls.js b/src/list-pulls.js
index 3a111d945..a1a068148 100644
--- a/src/list-pulls.js
+++ b/src/list-pulls.js
@@ -87,7 +87,7 @@ function getPullRequestComments (url, existingComments, callback) {
 
     request.get({
         url: url,
-        headers: {'User-Agent': 'Cordova Coho'}
+        headers: { 'User-Agent': 'Cordova Coho' }
     }, function (err, res, payload) {
         if (err) {
             if (!commentFailed) {
@@ -129,7 +129,7 @@ function listGitHubPullRequests (repo, maxAge, hideUser, short, statsOnly, callb
 
         if (pullRequests.message === 'Bad credentials') {
             apputil.fatal('Error: GitHub Bad credentials. Check your CORDOVA_GIT_ACCOUNT environment variable which should be set with your Github API token: https://github.com/settings/tokens.',
-            'CORDOVA_GIT_ACCOUNT used: ' + process.env['CORDOVA_GIT_ACCOUNT']);
+                'CORDOVA_GIT_ACCOUNT used: ' + process.env['CORDOVA_GIT_ACCOUNT']);
         }
 
         pullRequests = pullRequests.filter(function (p) {
@@ -245,10 +245,10 @@ function * listPullRequestsCommand () {
             desc: 'Used in conjunction with --stats-only. Output the report in JSON format.',
             type: 'bool'
         })
-         .options('short', {
-             desc: 'Truncates PR body description',
-             type: 'bool'
-         });
+        .options('short', {
+            desc: 'Truncates PR body description',
+            type: 'bool'
+        });
     opt.usage('Reports what GitHub pull requests are open for the given repositories.\n' +
                '\n' +
                'Example usage: $0 list-pulls --hide-user="agrieve" | tee pulls.list | less -R\n' +
@@ -257,7 +257,7 @@ function * listPullRequestsCommand () {
                '\n' +
                'Please note that GitHub rate limiting applies. See http://developer.github.com/v3/#rate-limiting for details.\n' +
                'You can also set the CORDOVA_GIT_ACCOUNT environment variable with your Github API key: https://github.com/settings/tokens\n'
-               );
+    );
     var argv = opt.argv;
 
     if (argv.h) {
diff --git a/src/npm-link.js b/src/npm-link.js
index d56f0e93c..be8a93dd2 100644
--- a/src/npm-link.js
+++ b/src/npm-link.js
@@ -32,7 +32,7 @@ function * createLink (argv) {
                '\n' +
                'Usage: $0 npm-link' +
                'Example usage: $0 npm-link --use-yarn\n'
-               )
+        )
         .options('use-yarn', {
             desc: 'Use the yarn package manager instead of npm',
             type: 'bool',
@@ -54,8 +54,8 @@ function * createLink (argv) {
 
     function npmLinkIn (linkedModule, installingModule) {
         cdInto(installingModule);
-       // 'npm link' will automatically unbuild a non-linked module if it is present,
-       // so don't need to explicitly 'rm -r' it first.
+        // 'npm link' will automatically unbuild a non-linked module if it is present,
+        // so don't need to explicitly 'rm -r' it first.
         shelljs.exec(packman + ' link ' + linkedModule);
         cdOutOf();
     }
diff --git a/src/plugin-release.js b/src/plugin-release.js
index 6c8208bb2..0cabe9275 100644
--- a/src/plugin-release.js
+++ b/src/plugin-release.js
@@ -313,9 +313,9 @@ function * interactive_plugins_release () {
                 plugin_base = path.resolve(path.normalize(answers.cwd));
                 shelljs.mkdir('-p', plugin_base);
                 process.chdir(plugin_base);
-                plugin_repos = flagutil.computeReposFromFlag('active-plugins', {includeSvn: true});
-                dist_svn = flagutil.computeReposFromFlag('dist', {includeSvn: true});
-                dist_dev_svn = flagutil.computeReposFromFlag('dist/dev', {includeSvn: true});
+                plugin_repos = flagutil.computeReposFromFlag('active-plugins', { includeSvn: true });
+                dist_svn = flagutil.computeReposFromFlag('dist', { includeSvn: true });
+                dist_dev_svn = flagutil.computeReposFromFlag('dist/dev', { includeSvn: true });
                 svn_repos = dist_svn.concat(dist_dev_svn);
                 dist_svn = dist_svn[0];
                 dist_dev_svn = dist_dev_svn[0];
@@ -367,7 +367,7 @@ function * interactive_plugins_release () {
                     })[0];
                     if (unknown[0] !== '0') {
                         // There are some unknown licenses!
-                        unknown_licenses.push({repo: repo.repoName, unknown: unknown});
+                        unknown_licenses.push({ repo: repo.repoName, unknown: unknown });
                     }
                 });
                 return yield Promise.resolve(unknown_licenses);
@@ -414,7 +414,7 @@ function * interactive_plugins_release () {
                     console.log(repo.repoName, '\'s current version is', current_version);
                     var devless_version = versionutil.removeDev(current_version);
                     plugin_data[repo.repoName].current_release = devless_version;
-                    yield versionutil.updateRepoVersion(repo, devless_version, {commitChanges: false});
+                    yield versionutil.updateRepoVersion(repo, devless_version, { commitChanges: false });
                 });
             })();
         }).then(function () {
@@ -469,13 +469,13 @@ function * interactive_plugins_release () {
                         // Overwrite plugin version
                         var previous_assumed_version = plugin_data[plugin_name].current_release;
                         plugin_data[plugin_name].current_release = release_notes[plugin_name + '-version'];
-                        yield versionutil.updateRepoVersion(repo, plugin_data[plugin_name].current_release, {commitChanges: false});
+                        yield versionutil.updateRepoVersion(repo, plugin_data[plugin_name].current_release, { commitChanges: false });
                         // also overwrite the version originally specified in the release notes file, since we changed it now!
                         var rn = release_notes[plugin_name];
                         var new_rn = rn.replace(new RegExp('### ' + previous_assumed_version, 'g'), '### ' + plugin_data[plugin_name].current_release);
                         release_notes[plugin_name] = new_rn;
                     }
-                    fs.writeFileSync(update_release_notes.FILE, release_notes[plugin_name], {encoding: 'utf8'});
+                    fs.writeFileSync(update_release_notes.FILE, release_notes[plugin_name], { encoding: 'utf8' });
                     /* - commit changes to versions and release notes together with description '$JIRA Updated version and release notes for release $v'
                      * - tag each plugin repo with $v */
                     if (yield gitutil.pendingChangesExist()) {
@@ -568,7 +568,7 @@ function * interactive_plugins_release () {
                     yield gitutil.gitCheckout('master');
                     // store previous master HEAD, for later comparison/showing of diff
                     plugin_data[plugin_name].previous_master_head = gitutil.hashForRef('master');
-                    yield versionutil.updateRepoVersion(repo, newest_version, {commitChanges: true});
+                    yield versionutil.updateRepoVersion(repo, newest_version, { commitChanges: true });
                 });
             })();
         }).then(function () {
@@ -761,7 +761,7 @@ function * interactive_plugins_release () {
         console.error('ERROR! There was a problem connecting to JIRA, received a', auth_err.statusCode, 'status code.');
         process.exit(1);
     });
-     /* 16. Bonus: separate script to 'approve' a plugins release, which would:
+    /* 16. Bonus: separate script to 'approve' a plugins release, which would:
      *   - publish the artifacts to dist/ in apache
      *   - "tell apache about the release" which has a TODO to write a helper to POST the request appropriately.
      *   - publish to npm
diff --git a/src/print-tags.js b/src/print-tags.js
index ec08b3479..723bf050d 100644
--- a/src/print-tags.js
+++ b/src/print-tags.js
@@ -30,14 +30,14 @@ module.exports = function * (argv) {
         .usage('Prints out tags & hashes for the given repos. Used in VOTE emails.\n' +
                '\n' +
                'Usage: $0 print-tags -r plugman -r cli [--tag 3.6.0]')
-        .options('tag', {desc: 'Print a specific tag instead of the "most recent" tag'})
+        .options('tag', { desc: 'Print a specific tag instead of the "most recent" tag' })
         .argv;
 
     if (argv.h) {
         optimist.showHelp();
         process.exit(1);
     }
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
 
     var tag;
     yield repoutil.forEachRepo(repos, function * (repo) {
diff --git a/src/repo-clone.js b/src/repo-clone.js
index d04d909b8..248af1bb1 100644
--- a/src/repo-clone.js
+++ b/src/repo-clone.js
@@ -40,7 +40,7 @@ module.exports = function * (_argv) {
 
     var depth = argv.depth ? argv.depth : null;
 
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeSvn: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeSvn: true });
     yield cloneRepos(repos, false, depth);
 };
 
diff --git a/src/repo-update.js b/src/repo-update.js
index 7facef52b..9e678b11c 100644
--- a/src/repo-update.js
+++ b/src/repo-update.js
@@ -67,7 +67,7 @@ module.exports = function * (_argv) {
     apputil.prefixLength = Math.max.apply(null,
         [apputil.prefixLength].concat(
             repos.map(function (r) { return r.repoName.length + 2; }))
-        );
+    );
 
     // ensure that any missing repos are cloned
     yield require('./repo-clone').cloneRepos(repos, true, depth);
@@ -116,7 +116,7 @@ function * updateRepos (repos, branches, noFetch) {
                     yield executil.execHelper(executil.ARGS('svn up'), /* silent */ false, /* allowError */ true);
                 } catch (e) {
                     errors += '(' + repo.repoName + '): ' + e + '\n';
-                     // Log failure and continue updating other repos
+                    // Log failure and continue updating other repos
                     console.log(e);
                 }
                 return;
@@ -132,7 +132,7 @@ function * updateRepos (repos, branches, noFetch) {
                     }
                 } else {
                     yield executil.execHelper(executil.ARGS('git checkout -b ' + branchName + ' remotes/' + repo.remoteName + '/' + branchName),
-                            /* silent */ true, /* allowError */ false);
+                        /* silent */ true, /* allowError */ false);
                 }
             }
             staleBranches = branches.filter(function (branchName) {
diff --git a/src/repoutil.js b/src/repoutil.js
index 2520132eb..393745748 100644
--- a/src/repoutil.js
+++ b/src/repoutil.js
@@ -429,9 +429,9 @@ var otherRepos = [
 ];
 
 var allRepos = platformRepos.concat(nonPlatformRepos,
-                                    pluginRepos,
-                                    toolRepos,
-                                    otherRepos);
+    pluginRepos,
+    toolRepos,
+    otherRepos);
 
 var repoGroups = {
     'all': allRepos,
diff --git a/src/shortlog.js b/src/shortlog.js
index 62fad8c93..7cd9e20b8 100644
--- a/src/shortlog.js
+++ b/src/shortlog.js
@@ -62,7 +62,7 @@ module.exports = function * () {
         if (emailFilter && emailFilter.exec(author)) {
             filterTotal += count;
         }
-        return {author: author, count: count};
+        return { author: author, count: count };
     });
     records.sort(function (a, b) {
         return b.count - a.count;
diff --git a/src/update-release-notes.js b/src/update-release-notes.js
index bca5ce3ee..28365fc1c 100644
--- a/src/update-release-notes.js
+++ b/src/update-release-notes.js
@@ -37,10 +37,10 @@ module.exports = function * () {
         '\n' +
         'Usage: $0 update-release-notes [--repo=ios]'
         )
-        .options('from-tag', {desc: 'Update since a specific tag instead of the "most recent" tag'})
-        .options('to-tag', {desc: 'Update to a specific tag instead of "master"'})
-        .options('override-date', {desc: 'Update to a specific date instead of today.'})
-        .options('last-two-tags', {desc: 'Update with the latest and previous tagged commits'});
+        .options('from-tag', { desc: 'Update since a specific tag instead of the "most recent" tag' })
+        .options('to-tag', { desc: 'Update to a specific tag instead of "master"' })
+        .options('override-date', { desc: 'Update to a specific date instead of today.' })
+        .options('last-two-tags', { desc: 'Update with the latest and previous tagged commits' });
     let argv = opt.argv;
 
     if (argv.h) {
@@ -48,7 +48,7 @@ module.exports = function * () {
         process.exit(1);
     }
 
-    var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+    var repos = flagutil.computeReposFromFlag(argv.r, { includeModules: true });
 
     yield repoutil.forEachRepo(repos, function * (repo) {
         // TODO: we should use gitutil.summaryOfChanges here.
@@ -104,7 +104,7 @@ module.exports = function * () {
                 newVersion = toTag;
             }
             var final_notes = yield createNotes(repo, newVersion, output, argv['override-date']);
-            fs.writeFileSync(relNotesFile, final_notes, {encoding: 'utf8'});
+            fs.writeFileSync(relNotesFile, final_notes, { encoding: 'utf8' });
             return linkify.file(relNotesFile);
         }
     });
@@ -140,7 +140,7 @@ function * createNotes (repo, newVersion, changes, overrideDate) {
     var lines = data.split('\n');
     data = lines.filter(function (line) {
         return !(
-           line.match(GITHUB_CLOSE_COMMIT_MSG) ||
+            line.match(GITHUB_CLOSE_COMMIT_MSG) ||
            line.match(VIA_COHO_COMMIT_MSG)
         );
     }).join('\n');
@@ -173,10 +173,10 @@ function * createNotes (repo, newVersion, changes, overrideDate) {
     var relNotesData;
     // if being run in cordova directy, cd into repo
     if (path.basename(process.cwd()) === 'cordova') {
-        relNotesData = fs.readFileSync(path.join(process.cwd(), repo, relNotesFile), {encoding: 'utf8'});
+        relNotesData = fs.readFileSync(path.join(process.cwd(), repo, relNotesFile), { encoding: 'utf8' });
     } else {
         // being run in repo directory (Eg cordova/cordova-plugin-device)
-        relNotesData = fs.readFileSync(path.join(process.cwd(), relNotesFile), {encoding: 'utf8'});
+        relNotesData = fs.readFileSync(path.join(process.cwd(), relNotesFile), { encoding: 'utf8' });
     }
     var headerPos = relNotesData.indexOf('### ');
     var date;
diff --git a/src/verify-tags.js b/src/verify-tags.js
index a158c06e8..003aa2d0e 100644
--- a/src/verify-tags.js
+++ b/src/verify-tags.js
@@ -71,7 +71,7 @@ exports.createCommand = function * (argv) {
     var m;
     var results = [];
     while (m = pattern.exec(input)) { // eslint-disable-line no-cond-assign
-        results.push({repoId: m[1], tagName: m[2], hash: m[3]});
+        results.push({ repoId: m[1], tagName: m[2], hash: m[3] });
     }
     if (results.length === 0) {
         apputil.fatal('Error processing input.');
diff --git a/src/versionutil.js b/src/versionutil.js
index 9dedbcd89..1a14fa669 100644
--- a/src/versionutil.js
+++ b/src/versionutil.js
@@ -55,13 +55,13 @@ function updatePlatformsConfig (newValues) {
     var platformsJS = require(platformsConfig);
 
     flagutil.computeReposFromFlag('active-platform')
-    .forEach(function (repo) {
-        if (newValues[repo.id]) {
+        .forEach(function (repo) {
+            if (newValues[repo.id]) {
             // For blackberry platformsConfig.json uses 'blackberry10' key
-            var correctRepoId = (repo.id === 'blackberry') ? 'blackberry10' : repo.id;
-            platformsJS[correctRepoId].version = newValues[repo.id];
-        }
-    });
+                var correctRepoId = (repo.id === 'blackberry') ? 'blackberry10' : repo.id;
+                platformsJS[correctRepoId].version = newValues[repo.id];
+            }
+        });
 
     fs.writeFileSync(platformsConfig, JSON.stringify(platformsJS, null, 4) + '\n', 'utf8', function (err) {
         if (err) return console.log(err);
@@ -131,7 +131,7 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) {
     // Update the package.json VERSION.
     var packageFilePaths = repo.packageFilePaths || ['package.json'];
     if (fs.existsSync(packageFilePaths[0])) {
-        var data = fs.readFileSync(packageFilePaths[0], {encoding: 'utf-8'});
+        var data = fs.readFileSync(packageFilePaths[0], { encoding: 'utf-8' });
         var packageJSON = JSON.parse(data);
         packageJSON.version = version;
         // use 2 spaces indent similar to npm
@@ -149,8 +149,8 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) {
         var xmlFilePaths = repo.xmlFilePaths || ['plugin.xml', 'tests/plugin.xml'];
         xmlFilePaths.forEach(function (xmlFile) {
             if (fs.existsSync(xmlFile)) {
-                var data = fs.readFileSync(xmlFile, {encoding: 'utf-8'});
-                xml2js.parseString(data, {async: false}, function (err, xml) {
+                var data = fs.readFileSync(xmlFile, { encoding: 'utf-8' });
+                xml2js.parseString(data, { async: false }, function (err, xml) {
                     if (err) throw err;
                     var prev_version = xml.plugin['$'].version;
                     shelljs.sed('-i', new RegExp('version="' + prev_version + '"', 'i'), 'version="' + version + '"', xmlFile);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org