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

flow-typed

Package Overview
Dependencies
Maintainers
7
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-typed - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

4

dist/cli.js

@@ -29,5 +29,5 @@ #!/usr/bin/env node

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -34,0 +34,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -6,5 +6,5 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -11,0 +11,0 @@ var _path = _interopRequireDefault(require("path"));

@@ -6,5 +6,5 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -88,3 +88,3 @@ var _stubUtils = require("../lib/stubUtils.js");

const pnpResolver = await (0, _npmProjectUtils.loadPnpResolver)((await (0, _npmProjectUtils.getPackageJsonData)(projectRoot)));
const pnpResolver = await (0, _npmProjectUtils.loadPnpResolver)(await (0, _npmProjectUtils.getPackageJsonData)(projectRoot));
const plural = packages.length > 1 ? 'stubs' : 'stub';

@@ -91,0 +91,0 @@ console.log(`• Creating ${packages.length} ${plural}...`);

@@ -6,8 +6,8 @@ "use strict";

});
exports.setup = setup;
exports.run = run;
exports._determineFlowVersion = determineFlowVersion;
exports._installNpmLibDef = installNpmLibDef;
exports._installNpmLibDefs = installNpmLibDefs;
exports._installNpmLibDef = installNpmLibDef;
exports.description = exports.name = void 0;
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;

@@ -66,2 +66,7 @@ var _codeSign = require("../lib/codeSign");

},
skipCache: {
describe: 'Do not update cache prior to installing libdefs',
type: 'boolean',
demandOption: false
},
libdefDir: {

@@ -159,2 +164,3 @@ alias: 'l',

skip: Boolean(args.skip),
skipCache: Boolean(args.skipCache),
ignoreDeps: ignoreDeps,

@@ -207,2 +213,3 @@ useCacheUntil: Number(args.useCacheUntil) || _cacheRepoUtils.CACHE_REPO_EXPIRY

skip,
skipCache,
ignoreDeps,

@@ -218,5 +225,18 @@ useCacheUntil

const libdefsToSearchFor = new Map(); // If a specific pkg/version was specified, only add those packages.
const libdefsToSearchFor = new Map();
let ignoreDefs;
try {
ignoreDefs = _node.fs.readFileSync(_node.path.join(cwd, libdefDir, '.ignore'), 'utf-8').replace(/"/g, '').split('\n');
} catch (err) {
// If the error is unrelated to file not existing we should continue throwing
if (err.code !== 'ENOENT') {
throw err;
}
ignoreDefs = [];
} // If a specific pkg/version was specified, only add those packages.
// Otherwise, extract dependencies from the package.json
if (explicitLibDefs.length > 0) {

@@ -229,3 +249,6 @@ for (var i = 0; i < explicitLibDefs.length; i++) {

const pkgJsonData = await (0, _npmProjectUtils.getPackageJsonData)(cwd);
const pkgJsonDeps = (0, _npmProjectUtils.getPackageJsonDependencies)(pkgJsonData, [], []);
const workspacesPkgJsonData = await (0, _npmProjectUtils.findWorkspacesPackages)(pkgJsonData);
const pkgJsonDeps = workspacesPkgJsonData.reduce((acc, pckData) => {
return (0, _npmProjectUtils.mergePackageJsonDependencies)(acc, (0, _npmProjectUtils.getPackageJsonDependencies)(pckData, [], []));
}, (0, _npmProjectUtils.getPackageJsonDependencies)(pkgJsonData, [], []));
const packageVersion = pkgJsonDeps[term];

@@ -248,17 +271,7 @@

} else {
let ignoreDefs;
try {
ignoreDefs = _node.fs.readFileSync(_node.path.join(cwd, libdefDir, '.ignore'), 'utf-8').replace(/"/g, '').split('\n');
} catch (err) {
// If the error is unrelated to file not existing we should continue throwing
if (err.code !== 'ENOENT') {
throw err;
}
ignoreDefs = [];
}
const pkgJsonData = await (0, _npmProjectUtils.getPackageJsonData)(cwd);
const pkgJsonDeps = (0, _npmProjectUtils.getPackageJsonDependencies)(pkgJsonData, ignoreDeps, ignoreDefs);
const workspacesPkgJsonData = await (0, _npmProjectUtils.findWorkspacesPackages)(pkgJsonData);
const pkgJsonDeps = workspacesPkgJsonData.reduce((acc, pckData) => {
return (0, _npmProjectUtils.mergePackageJsonDependencies)(acc, (0, _npmProjectUtils.getPackageJsonDependencies)(pckData, ignoreDeps, ignoreDefs));
}, (0, _npmProjectUtils.getPackageJsonDependencies)(pkgJsonData, ignoreDeps, ignoreDefs));

@@ -288,28 +301,76 @@ for (const pkgName in pkgJsonDeps) {

const unavailableLibDefs = [];
await Promise.all(libDefsToSearchForEntries.map(async ([name, ver]) => {
if (FLOW_BUILT_IN_NPM_LIBS.indexOf(name) !== -1) {
return;
}
const libDef = await (0, _npmLibDefs.findNpmLibDef)(name, ver, flowVersion, useCacheUntil);
const getLibDefsToInstall = async entries => {
await Promise.all(entries.map(async ([name, ver]) => {
// To comment in json files a work around is to give a key value pair
// of `"//": "comment"` we should exclude these so the install doesn't crash
// Ref: https://stackoverflow.com/a/14221781/430128
if (name === '//') {
return;
}
if (libDef === null) {
unavailableLibDefs.push({
name,
ver
});
} else {
libDefsToInstall.set(name, libDef);
const libDefLower = (0, _semver.getRangeLowerBound)(libDef.version);
const depLower = (0, _semver.getRangeLowerBound)(ver);
if (FLOW_BUILT_IN_NPM_LIBS.indexOf(name) !== -1) {
return;
}
if (_semver2.default.lt(libDefLower, depLower)) {
outdatedLibDefsToInstall.push([libDef, {
const libDef = await (0, _npmLibDefs.findNpmLibDef)(name, ver, flowVersion, useCacheUntil, skipCache);
if (libDef === null) {
unavailableLibDefs.push({
name,
ver
}]);
});
} else {
libDefsToInstall.set(name, libDef);
const libDefLower = (0, _semver.getRangeLowerBound)(libDef.version);
const depLower = (0, _semver.getRangeLowerBound)(ver);
if (_semver2.default.lt(libDefLower, depLower)) {
outdatedLibDefsToInstall.push([libDef, {
name,
ver
}]);
}
}
}));
};
await getLibDefsToInstall(libDefsToSearchForEntries);
const pnpResolver = await (0, _npmProjectUtils.loadPnpResolver)(await (0, _npmProjectUtils.getPackageJsonData)(cwd)); // If a package that's missing a flow-typed libdef has any .flow files,
// we'll skip generating a stub for it.
const untypedMissingLibDefs = [];
const typedMissingLibDefs = [];
await Promise.all(unavailableLibDefs.map(async ({
name: pkgName,
ver: pkgVer
}) => {
const hasFlowFiles = await (0, _stubUtils.pkgHasFlowFiles)(cwd, pkgName, pnpResolver);
if (hasFlowFiles.flowTyped && hasFlowFiles.path) {
typedMissingLibDefs.push([pkgName, pkgVer, hasFlowFiles.path]);
} else {
untypedMissingLibDefs.push([pkgName, pkgVer]);
}
})); // Scan libdefs that are already installed
})); // If there are any typed packages we should try install any missing
// lib defs for that package.
// Scanning through all typed dependencies then checking their immediate deps
// but do not overwrite the lib def that the project itself wants
if (typedMissingLibDefs.length > 0) {
const typedDepsLibDefsToSearchFor = [];
await Promise.all(typedMissingLibDefs.map(async typedLibDef => {
const pkgJsonData = await (0, _npmProjectUtils.getPackageJsonData)(`${typedLibDef[2]}/package.json`);
const pkgJsonDeps = (0, _npmProjectUtils.getPackageJsonDependencies)(pkgJsonData, ignoreDeps, ignoreDefs);
for (const pkgName in pkgJsonDeps) {
if (!libDefsToInstall.has(pkgName)) {
typedDepsLibDefsToSearchFor.push([pkgName, pkgJsonDeps[pkgName]]);
}
}
}));
await getLibDefsToInstall(typedDepsLibDefsToSearchFor);
} // Scan libdefs that are already installed
const libDefsToUninstall = new Map();

@@ -380,20 +441,2 @@ const alreadyInstalledLibDefs = await (0, _npmLibDefs.getInstalledNpmLibDefs)(_node.path.join(flowProjectRoot), libdefDir);

} else {
const pnpResolver = await (0, _npmProjectUtils.loadPnpResolver)((await (0, _npmProjectUtils.getPackageJsonData)(cwd))); // If a package that's missing a flow-typed libdef has any .flow files,
// we'll skip generating a stub for it.
const untypedMissingLibDefs = [];
const typedMissingLibDefs = [];
await Promise.all(unavailableLibDefs.map(async ({
name: pkgName,
ver: pkgVer
}) => {
const hasFlowFiles = await (0, _stubUtils.pkgHasFlowFiles)(cwd, pkgName, pnpResolver);
if (hasFlowFiles) {
typedMissingLibDefs.push([pkgName, pkgVer]);
} else {
untypedMissingLibDefs.push([pkgName, pkgVer]);
}
}));
if (untypedMissingLibDefs.length > 0 && !skip) {

@@ -400,0 +443,0 @@ console.log('• Generating stubs for untyped dependencies...');

@@ -6,5 +6,5 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -33,5 +33,5 @@ var _node = require("../lib/node.js");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -77,3 +77,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const diff = await (0, _git.getDiff)();
let changedDefs;
const baseDiff = diff.map(d => {

@@ -88,4 +87,18 @@ const match = d.match(basePathRegex);

}).filter(d => d !== '');
changedDefs = baseDiff.map(d => (0, _libDefs.parseRepoDirItem)(d).pkgName);
libDefs = libDefs.filter(def => changedDefs.includes(def.pkgName));
const changedDefs = baseDiff.map(d => {
const {
pkgName,
pkgVersion
} = (0, _libDefs.parseRepoDirItem)(d);
const {
major,
minor,
patch
} = pkgVersion;
return {
name: pkgName,
version: `v${major}.${minor}.${patch}`
};
});
libDefs = libDefs.filter(def => changedDefs.some(d => d.name === def.pkgName && d.version === def.pkgVersionStr));
}

@@ -92,0 +105,0 @@

@@ -7,5 +7,5 @@ "use strict";

exports._formatDefTable = _formatDefTable;
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -12,0 +12,0 @@ var _libDefs = require("../lib/libDefs.js");

@@ -6,5 +6,5 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -11,0 +11,0 @@ var _cacheRepoUtils = require("../lib/cacheRepoUtils");

@@ -6,10 +6,11 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = exports.description = exports.name = void 0;
exports.setup = void 0;
var Install = _interopRequireWildcard(require("./install"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -16,0 +17,0 @@ const name = 'update';

@@ -6,5 +6,5 @@ "use strict";

});
exports.name = exports.description = void 0;
exports.run = run;
exports.setup = setup;
exports.run = run;
exports.description = exports.name = void 0;

@@ -11,0 +11,0 @@ var _node = require("../lib/node");

@@ -6,5 +6,3 @@ "use strict";

});
exports.ensureCacheRepo = ensureCacheRepo;
exports.getCacheRepoDir = getCacheRepoDir;
exports.verifyCLIVersion = verifyCLIVersion;
exports._cacheRepoEnsureToken = exports._REMOTE_REPO_URL = exports._CACHE_REPO_EXPIRY = exports.CACHE_REPO_EXPIRY = void 0;
exports._clearCustomCacheDir = clearCustomCacheDir;

@@ -14,3 +12,5 @@ exports._getCacheRepoGitDir = getCacheRepoGitDir;

exports._setCustomCacheDir = setCustomCacheDir;
exports._REMOTE_REPO_URL = exports._cacheRepoEnsureToken = exports._CACHE_REPO_EXPIRY = exports.CACHE_REPO_EXPIRY = void 0;
exports.ensureCacheRepo = ensureCacheRepo;
exports.getCacheRepoDir = getCacheRepoDir;
exports.verifyCLIVersion = verifyCLIVersion;

@@ -17,0 +17,0 @@ var _fileUtils = require("./fileUtils");

@@ -6,9 +6,9 @@ "use strict";

});
exports.__parseVersion = _parseVersion;
exports.compareFlowVersionAsc = compareFlowVersionAsc;
exports.disjointVersionsAll = disjointVersionsAll;
exports.parseDirString = parseDirString;
exports.parseFlowSpecificVer = parseFlowSpecificVer;
exports.disjointVersionsAll = disjointVersionsAll;
exports.toDirString = toDirString;
exports.toSemverString = toSemverString;
exports.compareFlowVersionAsc = compareFlowVersionAsc;
exports.__parseVersion = _parseVersion;

@@ -15,0 +15,0 @@ var _ValidationError = require("./ValidationError");

@@ -7,9 +7,9 @@ "use strict";

exports.add = add;
exports.cloneInto = cloneInto;
exports.commit = commit;
exports.setLocalConfig = setLocalConfig;
exports.findLatestFileCommitHash = findLatestFileCommitHash;
exports.getDiff = getDiff;
exports.cloneInto = cloneInto;
exports.init = init;
exports.findLatestFileCommitHash = findLatestFileCommitHash;
exports.rebaseRepoMaster = rebaseRepoMaster;
exports.setLocalConfig = setLocalConfig;

@@ -16,0 +16,0 @@ var _which = _interopRequireDefault(require("which"));

@@ -10,5 +10,5 @@ "use strict";

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -15,0 +15,0 @@ function isInFlowTypedRepo() {

@@ -6,9 +6,9 @@ "use strict";

});
exports._cacheRepoAssure = exports._REMOTE_REPO_URL = exports._LAST_UPDATED_FILE = exports._CACHE_REPO_GIT_DIR = exports._CACHE_REPO_EXPIRY = exports._CACHE_REPO_DIR = exports.TEST_FILE_NAME_RE = void 0;
exports._ensureCacheRepo = ensureCacheRepo;
exports.updateCacheRepo = updateCacheRepo;
exports.filterLibDefs = filterLibDefs;
exports.getCacheLibDefs = getCacheLibDefs;
exports.getLibDefs = getLibDefs;
exports.parseRepoDirItem = parseRepoDirItem;
exports.getCacheLibDefs = getCacheLibDefs;
exports.filterLibDefs = filterLibDefs;
exports._REMOTE_REPO_URL = exports._LAST_UPDATED_FILE = exports._CACHE_REPO_GIT_DIR = exports._CACHE_REPO_EXPIRY = exports._CACHE_REPO_DIR = exports._cacheRepoAssure = exports.TEST_FILE_NAME_RE = void 0;
exports.updateCacheRepo = updateCacheRepo;

@@ -15,0 +15,0 @@ var _semver = _interopRequireDefault(require("semver"));

@@ -22,5 +22,5 @@ "use strict";

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -27,0 +27,0 @@ const child_process = {

@@ -6,13 +6,13 @@ "use strict";

});
exports._extractLibDefsFromNpmPkgDir = extractLibDefsFromNpmPkgDir;
exports._parsePkgNameVer = parsePkgNameVer;
exports._validateVersionNumPart = validateVersionNumPart;
exports._validateVersionPart = validateVersionPart;
exports.findNpmLibDef = findNpmLibDef;
exports.parseSignedCodeVersion = parseSignedCodeVersion;
exports.getInstalledNpmLibDef = getInstalledNpmLibDef;
exports.getInstalledNpmLibDefs = getInstalledNpmLibDefs;
exports.getNpmLibDefVersionHash = getNpmLibDefVersionHash;
exports.getNpmLibDefs = getNpmLibDefs;
exports.getNpmLibDefVersionHash = getNpmLibDefVersionHash;
exports.getScopedPackageName = getScopedPackageName;
exports._extractLibDefsFromNpmPkgDir = extractLibDefsFromNpmPkgDir;
exports._parsePkgNameVer = parsePkgNameVer;
exports._validateVersionNumPart = validateVersionNumPart;
exports._validateVersionPart = validateVersionPart;
exports.parseSignedCodeVersion = parseSignedCodeVersion;

@@ -156,4 +156,7 @@ var _cacheRepoUtils = require("../cacheRepoUtils");

async function getCacheNpmLibDefs(cacheExpiry) {
await (0, _cacheRepoUtils.ensureCacheRepo)(cacheExpiry);
async function getCacheNpmLibDefs(cacheExpiry, skipCache = false) {
if (!skipCache) {
await (0, _cacheRepoUtils.ensureCacheRepo)(cacheExpiry);
}
await (0, _cacheRepoUtils.verifyCLIVersion)();

@@ -234,3 +237,3 @@ return getNpmLibDefs(_node.path.join((0, _cacheRepoUtils.getCacheRepoDir)(), 'definitions'));

function pkgVersionMatch(pkgSemver, libDefSemverRaw) {
function pkgVersionMatch(pkgSemverRaw, libDefSemverRaw) {
// The package version should be treated as a semver implicitly prefixed by

@@ -255,2 +258,17 @@ // `^` or `~`. Depending on whether or not the minor value is defined.

const pkgSemver = (() => {
// If pkg version is prefixed with `>=` we should be treated as `^`
// Normally `>=` would mean anything greater than a particular version so
// ">=2.1.0" would match 2.1.0 up to anything such as 3.4.5
// But in the case of flow types, an import of a lib should probably match
// the lowest version that matches the range to assume backwards compatibility usage
const gtEq = '>=';
if (pkgSemverRaw.startsWith(gtEq)) {
return pkgSemverRaw.replace(gtEq, '^');
}
return pkgSemverRaw;
})();
if (_semver2.default.valid(pkgSemver)) {

@@ -345,4 +363,4 @@ // Test the single package version against the LibDef range

async function findNpmLibDef(pkgName, pkgVersion, flowVersion, useCacheUntil = _cacheRepoUtils.CACHE_REPO_EXPIRY) {
const libDefs = await getCacheNpmLibDefs(useCacheUntil);
async function findNpmLibDef(pkgName, pkgVersion, flowVersion, useCacheUntil = _cacheRepoUtils.CACHE_REPO_EXPIRY, skipCache = false) {
const libDefs = await getCacheNpmLibDefs(useCacheUntil, skipCache);
const filteredLibDefs = filterLibDefs(libDefs, {

@@ -349,0 +367,0 @@ type: 'exact',

@@ -6,9 +6,12 @@ "use strict";

});
exports.determineFlowVersion = determineFlowVersion;
exports.findFlowSpecificVer = findFlowSpecificVer;
exports.findPackageJsonDepVersionStr = findPackageJsonDepVersionStr;
exports.findPackageJsonPath = findPackageJsonPath;
exports.findWorkspacesPackagePaths = findWorkspacesPackagePaths;
exports.findWorkspacesPackages = findWorkspacesPackages;
exports.getPackageJsonData = getPackageJsonData;
exports.getPackageJsonDependencies = getPackageJsonDependencies;
exports.getPackageJsonData = getPackageJsonData;
exports.determineFlowVersion = determineFlowVersion;
exports.loadPnpResolver = loadPnpResolver;
exports.findFlowSpecificVer = findFlowSpecificVer;
exports.mergePackageJsonDependencies = mergePackageJsonDependencies;

@@ -21,6 +24,14 @@ var _fileUtils = require("../fileUtils.js");

var _semver2 = _interopRequireDefault(require("semver"));
var _semver2 = _interopRequireWildcard(require("semver"));
var _safe = _interopRequireDefault(require("colors/safe"));
var _glob = _interopRequireDefault(require("glob"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const PKG_JSON_DEP_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'bundledDependencies'];

@@ -58,2 +69,42 @@

return _node.path.join(pkgJsonPathStr, 'package.json');
}
function getWorkspacePatterns(pkgJson) {
if (Array.isArray(pkgJson.content.workspaces)) {
return pkgJson.content.workspaces;
}
if (pkgJson.content.workspaces && Array.isArray(pkgJson.content.workspaces.packages)) {
return pkgJson.content.workspaces.packages;
}
return [];
}
async function findWorkspacesPackagePaths(pkgJson) {
const tasks = await Promise.all(getWorkspacePatterns(pkgJson).map(pattern => {
return new Promise((resolve, reject) => {
(0, _glob.default)(`${_node.path.dirname(pkgJson.pathStr)}/${pattern}/package.json`, {
absolute: true
}, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
}
});
});
}));
return tasks.flat();
}
async function findWorkspacesPackages(pkgJson) {
const paths = await findWorkspacesPackagePaths(pkgJson);
return Promise.all(paths.map(async pathStr => {
const pkgJsonContent = await _node.fs.readJson(pathStr);
return {
pathStr,
content: pkgJsonContent
};
}));
} // TODO: Write tests for this

@@ -102,2 +153,19 @@

function mergePackageJsonDependencies(a, b) {
const result = { ...a
};
for (const dep of Object.keys(b)) {
const version = b[dep];
if (a[dep] != null && !(0, _semver2.intersects)(result[dep], version)) {
console.log(_safe.default.yellow("\t Conflicting versions for '%s' between '%s' and '%s'"), dep, a[dep], version);
} else {
result[dep] = version;
}
}
return result;
}
async function getPackageJsonData(pathStr) {

@@ -148,3 +216,3 @@ const pkgJsonPath = await findPackageJsonPath(pathStr);

if (await _node.fs.exists(pnpJsFile)) {
// $FlowFixMe
// $FlowFixMe[unsupported-syntax]
return require(pnpJsFile);

@@ -151,0 +219,0 @@ }

@@ -14,5 +14,5 @@ "use strict";

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -19,0 +19,0 @@ function emptyVersion() {

@@ -6,5 +6,5 @@ "use strict";

});
exports.createStub = createStub;
exports.glob = glob;
exports.pkgHasFlowFiles = pkgHasFlowFiles;
exports.createStub = createStub;

@@ -301,5 +301,10 @@ var _safe = _interopRequireDefault(require("colors/safe"));

});
return files.length > 0;
return {
flowTyped: files.length > 0,
path: pathToPackage
};
} catch (e) {
return false;
return {
flowTyped: false
};
}

@@ -306,0 +311,0 @@ }

@@ -13,3 +13,3 @@ {

},
"version": "3.4.0",
"version": "3.5.0",
"main": "dist/cli.js",

@@ -27,3 +27,3 @@ "bin": "dist/cli.js",

"test": "yarn clean && yarn build && yarn test-quick",
"test-quick": "jest && yarn lint",
"test-quick": "jest && yarn lint && yarn flow",
"watch": "mkdirp dist && babel --source-maps --watch=./src --out-dir=./dist"

@@ -43,3 +43,3 @@ },

"semver": "7.3.2",
"table": "^5.4.6",
"table": "^6.7.3",
"unzipper": "^0.10.8",

@@ -50,15 +50,16 @@ "which": "^2.0.2",

"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-flow": "^7.8.3",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-fb-flow": "^0.0.1",
"eslint-plugin-flowtype": "^4.6.0",
"eslint-plugin-prettier": "^3.1.2",
"flow-bin": "^0.144.0",
"jest": "^25.1.0"
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/plugin-syntax-flow": "^7.16.0",
"@babel/plugin-transform-react-jsx": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@babel/preset-flow": "^7.16.0",
"eslint": "^8.3.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-fb-flow": "^0.0.4",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-prettier": "^4.0.0",
"flow-bin": "^0.165.1",
"jest": "^27.3.1"
},

@@ -65,0 +66,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

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