Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-core-utils

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-core-utils - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.eslintignore

10

bin/metadata.js

@@ -28,3 +28,3 @@ #!/usr/bin/env node

const PR_ID = parseInt(process.argv[2]); // example
const PR_ID = parsePRId(process.argv[2]);

@@ -72,1 +72,9 @@ async function main(prid, owner, repo) {

});
function parsePRId(id) {
// Fast path: numeric string
if (`${+id}` === id) { return +id; }
const match = id.match(/^https:.*\/pull\/([0-9]+)(?:\/(?:files)?)?$/);
if (match !== null) { return +match[1]; }
throw new Error(`Could not understand PR id format: ${id}`);
}
'use strict';
const assert = require('assert');
const fs = require('fs');
const os = require('os');
const path = require('path');
const util = require('util');
const readline = require('readline');
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
const authFile = path.join(os.homedir(), '.ncurc');
// TODO: try-catch, validate properties
const { username, token } = JSON.parse(fs.readFileSync(authFile, 'utf8'));
const auth = Buffer.from(`${username}:${token}`).toString('base64');
module.exports = auth;
module.exports = lazy(auth);
function check(username, token) {
assert(typeof username === 'string' && /^[a-zA-Z0-9]*/.test(username));
assert(typeof token === 'string' && /^[0-9a-f]*/.test(token));
}
async function auth() {
let username, token;
// Try reading from ~/.ncurc
try {
({ username, token } = JSON.parse(await readFile(authFile, 'utf8')));
} catch (e) {
process.stdout.write('Reading configuration for node-core-utils failed:\n' +
e.message + '\n');
}
// If that worked, yay
if (username && token) {
check(username, token);
return Buffer.from(`${username}:${token}`).toString('base64');
}
// Ask the user for input and write to ~/.ncurc, then try again
process.stdout.write('Please enter your Github user information:\n' +
'[Github tokens can be created as described in ' +
'https://help.github.com/articles/' +
'creating-a-personal-access-token-for-the-command-line/]\n');
username = await prompt('Github user name');
token = await prompt('Github token');
check(username, token);
const json = JSON.stringify({ username, token }, null, ' ');
await writeFile(authFile, json, { mode:
0o600 /* owner read/write */
});
return auth();
}
async function prompt(question) {
return new Promise((resolve, reject) => {
process.stdout.write(`${question}: `);
const rl = readline.createInterface({
input: process.stdin
});
rl.on('line', (line) => {
rl.close();
process.stdin.removeListener('error', reject);
process.stdin.removeListener('end', reject);
resolve(line.trim());
});
process.stdin.on('error', reject);
process.stdin.on('end', reject);
});
}
function lazy(fn) {
let cachedValue;
return function() {
if (cachedValue !== undefined) {
return cachedValue;
}
cachedValue = fn();
return cachedValue;
};
}

@@ -8,2 +8,3 @@ 'use strict';

const CL_TITLE = '### Collaborators';
const CLE_TITLE = '### Collaborator Emeriti';
const CONTACT_RE = /\* \[(.+?)\]\(.+?\) -\s\*\*(.+?)\*\* <(.+?)>/mg;

@@ -61,2 +62,3 @@

const clIndex = readme.indexOf(CL_TITLE);
const cleIndex = readme.indexOf(CLE_TITLE);

@@ -72,4 +74,9 @@ if (tscIndex === -1) {

}
if (cleIndex === -1) {
throw new Error(`Couldn't find ${CLE_TITLE} in the README`);
}
if (!(tscIndex < tsceIndex && tsceIndex < clIndex)) {
if (!(tscIndex < tsceIndex &&
tsceIndex < clIndex &&
clIndex < cleIndex)) {
logger.warn('Order of different types of contacts needs update. ' +

@@ -89,3 +96,4 @@ 'Analysis could get wrong.');

// eslint-disable-next-line no-cond-assign
while (m = CONTACT_RE.exec(readme)) {
while ((m = CONTACT_RE.exec(readme)) &&
CONTACT_RE.lastIndex < cleIndex) {
const login = m[1].toLowerCase();

@@ -92,0 +100,0 @@ if (!members.get(login)) {

2

lib/metadata_gen.js

@@ -30,3 +30,3 @@ 'use strict';

meta = meta.concat(output.reviewedBy.map((r) => {
return `Reviewed-By: ${r.reviewer.getContact()}>`;
return `Reviewed-By: ${r.reviewer.getContact()}`;
}));

@@ -33,0 +33,0 @@ meta = meta.concat(output.fixes.map((fix) => `Fixes: ${fix}`));

@@ -11,3 +11,3 @@ 'use strict';

headers: {
'Authorization': `Basic ${auth}`,
'Authorization': `Basic ${await auth()}`,
'User-Agent': 'node-check-pr'

@@ -39,3 +39,2 @@ },

let all = [];
let totalCount;
// first page

@@ -56,3 +55,2 @@ do {

all = all.concat(current.nodes);
totalCount = current.totalCount;
if (current.pageInfo.hasNextPage) {

@@ -59,0 +57,0 @@ after = current.pageInfo.endCursor;

{
"name": "node-core-utils",
"version": "1.2.0",
"version": "1.3.0",
"description": "",

@@ -10,3 +10,8 @@ "main": "./bin/metadata.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npm run test-unit && npm run lint",
"test-unit": "mocha --require intelli-espower-loader test/unit/*.test.js",
"test-all": "mocha --require intelli-espower-loader test/**/*.test.js",
"coverage": "nyc npm test",
"coverage-all": "nyc npm run test-all",
"lint": "eslint ."
},

@@ -21,3 +26,17 @@ "author": "Joyee Cheung <joyeec9h3@gmail.com>",

"request-promise-native": "^1.0.5"
},
"devDependencies": {
"eslint": "^4.9.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"intelli-espower-loader": "^1.0.1",
"mocha": "^4.0.1",
"nyc": "^11.2.1",
"power-assert": "^1.4.4",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.2"
}
}
# Node.js Core Utilities
[![npm](https://img.shields.io/npm/v/node-core-utils.svg?style=flat-square)](https://npmjs.org/package/node-core-utils)
[![Build Status](https://travis-ci.org/joyeecheung/node-core-utils.svg?branch=master)](https://travis-ci.org/joyeecheung/node-core-utils)

@@ -22,2 +24,3 @@ CLI tools for Node.js Core collaborators

If you install via npm, that's it.
If you are using it from source, install and link:

@@ -45,2 +48,3 @@

- [ ] Check if commiters match authors
- Only when `"authorAssociation": "FIRST_TIME_CONTRIBUTOR"`
- [x] Check 48-hour wait

@@ -47,0 +51,0 @@ - [x] Check two TSC approval for semver-major

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc