From a08029033f6ca080d02c380fc8ca5baa7cc402ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Fri, 23 Feb 2024 11:16:19 +0100 Subject: [PATCH] Revert "feat: Support for yarn workspaces (#493)" (#936) This reverts commit 3e8410bbfea45fca9d70c41122ab2327b55d9ccc. --- package-lock.json | 52 ++--- package.json | 1 - src/npm.ts | 150 +++++++------- src/package.ts | 62 +++--- .../node_modules/.yarn-integrity | 26 --- .../node_modules/filter-obj/index.js | 14 -- .../node_modules/filter-obj/license | 9 - .../node_modules/filter-obj/package.json | 37 ---- .../node_modules/filter-obj/readme.md | 57 ------ .../node_modules/in-array/LICENSE | 21 -- .../node_modules/in-array/README.md | 76 ------- .../node_modules/in-array/index.js | 21 -- .../node_modules/in-array/package.json | 61 ------ .../node_modules/is-number/LICENSE | 21 -- .../node_modules/is-number/README.md | 187 ------------------ .../node_modules/is-number/index.js | 18 -- .../node_modules/is-number/package.json | 82 -------- .../node_modules/map-obj/index.js | 54 ----- .../node_modules/map-obj/license | 9 - .../node_modules/map-obj/package.json | 42 ---- .../node_modules/map-obj/readme.md | 76 ------- .../yarnWorkspaces/node_modules/package-a | 1 - .../yarnWorkspaces/node_modules/package-b | 1 - src/test/fixtures/yarnWorkspaces/package.json | 15 -- .../packageA/important/prod.log | 1 - .../yarnWorkspaces/packageA/logger.log | 1 - .../fixtures/yarnWorkspaces/packageA/main.js | 1 - .../yarnWorkspaces/packageA/package.json | 14 -- .../yarnWorkspaces/packageB/.vscodeignore | 5 - .../fixtures/yarnWorkspaces/packageB/main.js | 1 - .../yarnWorkspaces/packageB/package.json | 15 -- src/test/fixtures/yarnWorkspaces/yarn.lock | 23 --- src/test/package.test.ts | 86 -------- 33 files changed, 101 insertions(+), 1139 deletions(-) delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/.yarn-integrity delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/index.js delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/license delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/readme.md delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/in-array/LICENSE delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/in-array/README.md delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/in-array/index.js delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/in-array/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/is-number/LICENSE delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/is-number/README.md delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/is-number/index.js delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/is-number/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/map-obj/index.js delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/map-obj/license delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/map-obj/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/node_modules/map-obj/readme.md delete mode 120000 src/test/fixtures/yarnWorkspaces/node_modules/package-a delete mode 120000 src/test/fixtures/yarnWorkspaces/node_modules/package-b delete mode 100644 src/test/fixtures/yarnWorkspaces/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/packageA/important/prod.log delete mode 100644 src/test/fixtures/yarnWorkspaces/packageA/logger.log delete mode 100644 src/test/fixtures/yarnWorkspaces/packageA/main.js delete mode 100644 src/test/fixtures/yarnWorkspaces/packageA/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/packageB/.vscodeignore delete mode 100644 src/test/fixtures/yarnWorkspaces/packageB/main.js delete mode 100644 src/test/fixtures/yarnWorkspaces/packageB/package.json delete mode 100644 src/test/fixtures/yarnWorkspaces/yarn.lock diff --git a/package-lock.json b/package-lock.json index 5c7c25c7..b0bf32f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.9", "commander": "^6.2.1", - "find-yarn-workspace-root": "^2.0.0", "glob": "^7.0.6", "hosted-git-info": "^4.0.2", "jsonc-parser": "^3.2.0", @@ -610,6 +609,7 @@ "version": "3.0.2", "resolved": "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz", "integrity": "sha1-NFThpGLujVmeI23zNs2epPiv4Qc= sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, "dependencies": { "fill-range": "^7.0.1" }, @@ -1053,6 +1053,7 @@ "version": "7.0.1", "resolved": "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha1-GRmmp8df44ssfHflGYU12prN2kA= sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -1085,14 +1086,6 @@ "node": ">=8" } }, - "node_modules/find-yarn-workspace-root": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", - "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", - "dependencies": { - "micromatch": "^4.0.2" - } - }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -1455,6 +1448,7 @@ "version": "7.0.0", "resolved": "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz", "integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss= sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, "engines": { "node": ">=0.12.0" } @@ -1691,18 +1685,6 @@ "resolved": "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=" }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz", @@ -2062,6 +2044,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, "engines": { "node": ">=8.6" }, @@ -2516,6 +2499,7 @@ "version": "5.0.1", "resolved": "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ= sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -3405,6 +3389,7 @@ "version": "3.0.2", "resolved": "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz", "integrity": "sha1-NFThpGLujVmeI23zNs2epPiv4Qc= sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, "requires": { "fill-range": "^7.0.1" } @@ -3732,6 +3717,7 @@ "version": "7.0.1", "resolved": "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha1-GRmmp8df44ssfHflGYU12prN2kA= sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, "requires": { "to-regex-range": "^5.0.1" } @@ -3754,14 +3740,6 @@ } } }, - "find-yarn-workspace-root": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", - "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", - "requires": { - "micromatch": "^4.0.2" - } - }, "flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -4028,7 +4006,8 @@ "is-number": { "version": "7.0.0", "resolved": "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss= sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + "integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss= sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true }, "is-unicode-supported": { "version": "0.1.0", @@ -4217,15 +4196,6 @@ "resolved": "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=" }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, "mime": { "version": "1.6.0", "resolved": "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz", @@ -4492,7 +4462,8 @@ "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true }, "prebuild-install": { "version": "7.0.1", @@ -4816,6 +4787,7 @@ "version": "5.0.1", "resolved": "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ= sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, "requires": { "is-number": "^7.0.0" } diff --git a/package.json b/package.json index 7ae47728..b16cf251 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.9", "commander": "^6.2.1", - "find-yarn-workspace-root": "^2.0.0", "glob": "^7.0.6", "hosted-git-info": "^4.0.2", "jsonc-parser": "^3.2.0", diff --git a/src/npm.ts b/src/npm.ts index 8dafc357..c355cbef 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -1,10 +1,8 @@ import * as path from 'path'; import * as fs from 'fs'; import * as cp from 'child_process'; -import findWorkspaceRoot from 'find-yarn-workspace-root'; -import { Manifest } from './manifest'; -import { readNodeManifest } from './package'; -import { CancellationToken, log } from './util'; +import parseSemver from 'parse-semver'; +import { CancellationToken, log, nonnull } from './util'; const exists = (file: string) => fs.promises.stat(file).then( @@ -64,67 +62,51 @@ async function checkNPM(cancellationToken?: CancellationToken): Promise { } } -function getNpmDependencies(cwd: string): Promise { +function getNpmDependencies(cwd: string): Promise { return checkNPM() .then(() => exec('npm list --production --parseable --depth=99999 --loglevel=error', { cwd, maxBuffer: 5000 * 1024 }) ) - .then(({ stdout }) => stdout.split(/[\r\n]/).filter(dir => path.isAbsolute(dir)) - .map(dir => { - return { - src: dir, - dest: path.relative(cwd, dir) - } - })); + .then(({ stdout }) => stdout.split(/[\r\n]/).filter(dir => path.isAbsolute(dir))); +} + +interface YarnTreeNode { + name: string; + children: YarnTreeNode[]; } export interface YarnDependency { name: string; - path: SourceAndDestination; + path: string; children: YarnDependency[]; } -export interface SourceAndDestination { - src: string; - dest: string; -} +function asYarnDependency(prefix: string, tree: YarnTreeNode, prune: boolean): YarnDependency | null { + if (prune && /@[\^~]/.test(tree.name)) { + return null; + } -async function asYarnDependencies(root: string, rootDependencies: string[]): Promise { - const resolve = async (prefix: string, dependencies: string[], collected: Map = new Map()): Promise => await Promise.all(dependencies - .map(async (name: string) => { - let newPrefix = prefix, depPath = null, depManifest = null; - while (!depManifest && root.length <= newPrefix.length) { - depPath = path.join(newPrefix, 'node_modules', name); - try { - depManifest = await readNodeManifest(depPath); - } catch (err) { - newPrefix = path.join(newPrefix, '..'); - if (newPrefix.length < root.length) { - throw err; - } - } - } + let name: string; - if (!depPath || !depManifest) { - throw new Error(`Error finding dependencies`); - } + try { + const parseResult = parseSemver(tree.name); + name = parseResult.name; + } catch (err) { + name = tree.name.replace(/^([^@+])@.*$/, '$1'); + } - const result: YarnDependency = { - name, - path: { - src: depPath, - dest: path.relative(root, depPath), - }, - children: [], - }; - const shouldResolveChildren = !collected.has(depPath); - collected.set(depPath, result); - if (shouldResolveChildren) { - result.children = await resolve(depPath, Object.keys(depManifest.dependencies || {}), collected); - } - return result; - })); - return resolve(root, rootDependencies); + const dependencyPath = path.join(prefix, name); + const children: YarnDependency[] = []; + + for (const child of tree.children || []) { + const dep = asYarnDependency(path.join(prefix, name, 'node_modules'), child, prune); + + if (dep) { + children.push(dep); + } + } + + return { name, path: dependencyPath, children }; } function selectYarnDependencies(deps: YarnDependency[], packagedDependencies: string[]): YarnDependency[] { @@ -172,10 +154,26 @@ function selectYarnDependencies(deps: YarnDependency[], packagedDependencies: st return reached.values; } -async function getYarnProductionDependencies(root: string, manifest: Manifest, packagedDependencies?: string[]): Promise { +async function getYarnProductionDependencies(cwd: string, packagedDependencies?: string[]): Promise { + const raw = await new Promise((c, e) => + cp.exec( + 'yarn list --prod --json', + { cwd, encoding: 'utf8', env: { ...process.env }, maxBuffer: 5000 * 1024 }, + (err, stdout) => (err ? e(err) : c(stdout)) + ) + ); + const match = /^{"type":"tree".*$/m.exec(raw); + + if (!match || match.length !== 1) { + throw new Error('Could not parse result of `yarn list --json`'); + } + const usingPackagedDependencies = Array.isArray(packagedDependencies); + const trees = JSON.parse(match[0]).data.trees as YarnTreeNode[]; - let result = await asYarnDependencies(root, Object.keys(manifest.dependencies || {})); + let result = trees + .map(tree => asYarnDependency(path.join(cwd, 'node_modules'), tree, !usingPackagedDependencies)) + .filter(nonnull); if (usingPackagedDependencies) { result = selectYarnDependencies(result, packagedDependencies!); @@ -184,35 +182,22 @@ async function getYarnProductionDependencies(root: string, manifest: Manifest, p return result; } -async function getYarnDependencies(cwd: string, root: string, manifest: Manifest, packagedDependencies?: string[]): Promise { - const result: SourceAndDestination[] = [{ - src: cwd, - dest: '' - }]; - - if (await exists(path.join(root, 'yarn.lock'))) { - const deps = await getYarnProductionDependencies(root, manifest, packagedDependencies); - const flatten = (dep: YarnDependency) => { - result.push(dep.path); - dep.children.forEach(flatten); - }; - deps.forEach(flatten); - } - - const dedup = new Map(); +async function getYarnDependencies(cwd: string, packagedDependencies?: string[]): Promise { + const result = new Set([cwd]); - for (const item of result) { - if (!dedup.has(item.src)) { - dedup.set(item.src, item); - } - } + const deps = await getYarnProductionDependencies(cwd, packagedDependencies); + const flatten = (dep: YarnDependency) => { + result.add(dep.path); + dep.children.forEach(flatten); + }; + deps.forEach(flatten); - return [...dedup.values()]; + return [...result]; } -export async function detectYarn(root: string) { +export async function detectYarn(cwd: string): Promise { for (const name of ['yarn.lock', '.yarnrc', '.yarnrc.yaml', '.pnp.cjs', '.yarn']) { - if (await exists(path.join(root, name))) { + if (await exists(path.join(cwd, name))) { if (!process.env['VSCE_TESTS']) { log.info( `Detected presence of ${name}. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).` @@ -226,16 +211,13 @@ export async function detectYarn(root: string) { export async function getDependencies( cwd: string, - manifest: Manifest, dependencies: 'npm' | 'yarn' | 'none' | undefined, packagedDependencies?: string[] -): Promise { - const root = findWorkspaceRoot(cwd) || cwd; - +): Promise { if (dependencies === 'none') { - return [{ src: root, dest: '' }]; - } else if (dependencies === 'yarn' || (dependencies === undefined && (await detectYarn(root)))) { - return await getYarnDependencies(cwd, root, manifest, packagedDependencies); + return [cwd]; + } else if (dependencies === 'yarn' || (dependencies === undefined && (await detectYarn(cwd)))) { + return await getYarnDependencies(cwd, packagedDependencies); } else { return await getNpmDependencies(cwd); } diff --git a/src/package.ts b/src/package.ts index 00780266..e1a4e34c 100644 --- a/src/package.ts +++ b/src/package.ts @@ -20,7 +20,7 @@ import { validateEngineCompatibility, validateVSCodeTypesCompatibility, } from './validation'; -import { detectYarn, getDependencies, SourceAndDestination } from './npm'; +import { detectYarn, getDependencies } from './npm'; import * as GitHost from 'hosted-git-info'; import parseSemver from 'parse-semver'; import * as jsonc from 'jsonc-parser'; @@ -1351,8 +1351,10 @@ export function validateManifest(manifest: Manifest): Manifest { return manifest; } -export function readNodeManifest(cwd = process.cwd()): Promise { +export function readManifest(cwd = process.cwd(), nls = true): Promise { const manifestPath = path.join(cwd, 'package.json'); + const manifestNLSPath = path.join(cwd, 'package.nls.json'); + const manifest = fs.promises .readFile(manifestPath, 'utf8') .catch(() => Promise.reject(`Extension manifest not found: ${manifestPath}`)) @@ -1363,19 +1365,13 @@ export function readNodeManifest(cwd = process.cwd()): Promise { console.error(`Error parsing 'package.json' manifest file: not a valid JSON file.`); throw e; } - }); - return manifest; -} - -export function readManifest(cwd = process.cwd(), nls = true): Promise { - const manifest = readNodeManifest(cwd) + }) .then(validateManifest); if (!nls) { return manifest; } - const manifestNLSPath = path.join(cwd, 'package.nls.json'); const manifestNLS = fs.promises .readFile(manifestNLSPath, 'utf8') .catch(err => (err.code !== 'ENOENT' ? Promise.reject(err) : Promise.resolve('{}'))) @@ -1566,17 +1562,13 @@ const notIgnored = ['!package.json', '!README.md']; async function collectAllFiles( cwd: string, - manifest: Manifest, dependencies: 'npm' | 'yarn' | 'none' | undefined, dependencyEntryPoints?: string[] -): Promise { - const deps = await getDependencies(cwd, manifest, dependencies, dependencyEntryPoints); +): Promise { + const deps = await getDependencies(cwd, dependencies, dependencyEntryPoints); const promises = deps.map(dep => - promisify(glob)('**', { cwd: dep.src, nodir: true, dot: true, ignore: 'node_modules/**' }).then(files => - files.map(f => ({ - src: path.relative(cwd, path.join(dep.src, f)).replace(/\\/g, '/'), - dest: path.join(dep.dest, f).replace(/\\/g, '/') - })) + promisify(glob)('**', { cwd: dep, nodir: true, dot: true, ignore: 'node_modules/**' }).then(files => + files.map(f => path.relative(cwd, path.join(dep, f))).map(f => f.replace(/\\/g, '/')) ) ); @@ -1600,21 +1592,12 @@ function getDependenciesOption(options: IPackageOptions): 'npm' | 'yarn' | 'none function collectFiles( cwd: string, - manifest: Manifest, - options: IPackageOptions -): Promise { - const packagedDependencies = options.dependencyEntryPoints || undefined; - const ignoreFile = options.ignoreFile || undefined; - const target = options.target || undefined; - - return collectAllFiles(cwd, manifest, getDependenciesOption(options), packagedDependencies).then(files => { - files = files.filter(f => !/\r$/m.test(f.src)); - - // Filter data from other platforms - if (target && options.ignoreOtherTargetFolders) { - const regex = new RegExp(`(^|/)(${Array.from(Targets, v => v).filter(v => v !== target).join('|')})/`); - files = files.filter(f => !regex.test(f.src)) - } + dependencies: 'npm' | 'yarn' | 'none' | undefined, + dependencyEntryPoints?: string[], + ignoreFile?: string +): Promise { + return collectAllFiles(cwd, dependencies, dependencyEntryPoints).then(files => { + files = files.filter(f => !/\r$/m.test(f)); return ( fs.promises @@ -1654,8 +1637,8 @@ function collectFiles( .then(({ ignore, negate }) => files.filter( f => - !ignore.some(i => minimatch(f.src, i, MinimatchOptions)) || - negate.some(i => minimatch(f.src, i.substr(1), MinimatchOptions)) + !ignore.some(i => minimatch(f, i, MinimatchOptions)) || + negate.some(i => minimatch(f, i.substr(1), MinimatchOptions)) ) ) ); @@ -1707,10 +1690,12 @@ export function createDefaultProcessors(manifest: Manifest, options: IPackageOpt export function collect(manifest: Manifest, options: IPackageOptions = {}): Promise { const cwd = options.cwd || process.cwd(); + const packagedDependencies = options.dependencyEntryPoints || undefined; + const ignoreFile = options.ignoreFile || undefined; const processors = createDefaultProcessors(manifest, options); - return collectFiles(cwd, manifest, options).then(fileNames => { - const files = fileNames.map(f => ({ path: `extension/${f.dest}`, localPath: path.join(cwd, f.src) })); + return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile).then(fileNames => { + const files = fileNames.map(f => ({ path: `extension/${f}`, localPath: path.join(cwd, f) })); return processFiles(processors, files); }); @@ -1861,8 +1846,7 @@ export async function listFiles(options: IListFilesOptions = {}): Promise f.src); + return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile); } /** @@ -1874,4 +1858,4 @@ export async function ls(options: IListFilesOptions = {}): Promise { for (const file of files) { console.log(`${file}`); } -} \ No newline at end of file +} diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/.yarn-integrity b/src/test/fixtures/yarnWorkspaces/node_modules/.yarn-integrity deleted file mode 100644 index a40e555f..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/.yarn-integrity +++ /dev/null @@ -1,26 +0,0 @@ -{ - "systemParams": "darwin-arm64-108", - "modulesFolders": [ - "node_modules", - "node_modules" - ], - "flags": [], - "linkedModules": [], - "topLevelPatterns": [ - "filter-obj@2.0.1", - "in-array@0.1.2", - "is-number@7.0.0", - "map-obj@4.1.0", - "package-a@*", - "package-a@1.0.0", - "package-b@1.0.0" - ], - "lockfileEntries": { - "filter-obj@2.0.1": "https://registry.yarnpkg.com/filter-obj/-/filter-obj-2.0.1.tgz#34d9f0536786f072df7aeac3a8bda1c6e767aec6", - "in-array@0.1.2": "https://registry.yarnpkg.com/in-array/-/in-array-0.1.2.tgz#1a2683009177ab914ade0620a35c5039851f3715", - "is-number@7.0.0": "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b", - "map-obj@4.1.0": "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5" - }, - "files": [], - "artifacts": {} -} \ No newline at end of file diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/index.js b/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/index.js deleted file mode 100644 index b05ed67c..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/index.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = (object, predicate) => { - const result = {}; - const isArray = Array.isArray(predicate); - - for (const [key, value] of Object.entries(object)) { - if (isArray ? predicate.includes(key) : predicate(key, value, object)) { - result[key] = value; - } - } - - return result; -}; diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/license b/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/license deleted file mode 100644 index e7af2f77..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/package.json b/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/package.json deleted file mode 100644 index 3da71cc4..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "filter-obj", - "version": "2.0.1", - "description": "Filter object keys and values into a new object", - "license": "MIT", - "repository": "sindresorhus/filter-obj", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "filter", - "object", - "key", - "keys", - "value", - "values", - "iterate", - "iterator" - ], - "devDependencies": { - "ava": "^2.4.0", - "tsd": "^0.9.0", - "xo": "^0.25.3" - } -} diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/readme.md b/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/readme.md deleted file mode 100644 index 57c84ccd..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/filter-obj/readme.md +++ /dev/null @@ -1,57 +0,0 @@ -# filter-obj [![Build Status](https://travis-ci.org/sindresorhus/filter-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/filter-obj) - -> Filter object keys and values into a new object - - -## Install - -``` -$ npm install filter-obj -``` - - -## Usage - -```js -const filterObject = require('filter-obj'); - -const object = { - foo: true, - bar: false -}; - -const newObject = filterObject(object, (key, value) => value === true); -//=> {foo: true} - -const newObject2 = filterObject(object, ['bar']); -//=> {bar: false} -``` - - -## API - -### filterObject(source, filter) -### filterObject(source, includeKeys) - -#### source - -Type: `object` - -Source object to filter properties from. - -#### filter - -Type: `Function` - -A predicate function that detemines whether a property should be assigned to the new object. The function has the signature `filterFunction(sourceKey, sourceValue, source)`. - -#### includeKeys - -Type: `string[]` - -Array of property names that should be assigned to the new object. - - -## Related - -- [map-obj](https://github.com/sindresorhus/map-obj) - Map object keys and values into a new object diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/LICENSE b/src/test/fixtures/yarnWorkspaces/node_modules/in-array/LICENSE deleted file mode 100644 index ce0a70f2..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2016. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/README.md b/src/test/fixtures/yarnWorkspaces/node_modules/in-array/README.md deleted file mode 100644 index 1e0219f0..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# in-array [![NPM version](https://img.shields.io/npm/v/in-array.svg?style=flat)](https://www.npmjs.com/package/in-array) [![NPM downloads](https://img.shields.io/npm/dm/in-array.svg?style=flat)](https://npmjs.org/package/in-array) [![Build Status](https://img.shields.io/travis/jonschlinkert/in-array.svg?style=flat)](https://travis-ci.org/jonschlinkert/in-array) - -> Return true if a value exists in an array. Faster than using indexOf and won't blow up on null values. - -## Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm install in-array --save -``` - -## Usage - -```js -var inArray = require('in-array'); -console.log(inArray(['a', 'b', 'c'], 'a')); -//=> true - -console.log(inArray(null, 'a')); -//=> false - -console.log(inArray(null)); -//=> false -``` - -## Related projects - -You might also be interested in these projects: - -* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten) -* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://www.npmjs.com/package/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union) -* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object) -* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject) - -## Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/in-array/issues/new). - -## Building docs - -Generate readme and API documentation with [verb](https://github.com/verbose/verb): - -```sh -$ npm install verb && npm run docs -``` - -Or, if [verb](https://github.com/verbose/verb) is installed globally: - -```sh -$ verb -``` - -## Running tests - -Install dev dependencies: - -```sh -$ npm install -d && npm test -``` - -## Author - -**Jon Schlinkert** - -* [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) - -## License - -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](https://github.com/jonschlinkert/in-array/blob/master/LICENSE). - -*** - -_This file was generated by [verb](https://github.com/verbose/verb), v, on March 27, 2016._ \ No newline at end of file diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/index.js b/src/test/fixtures/yarnWorkspaces/node_modules/in-array/index.js deleted file mode 100644 index 388c4faa..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/index.js +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * in-array - * - * Copyright (c) 2014 Jon Schlinkert, contributors. - * Licensed under the MIT License - */ - -'use strict'; - -module.exports = function inArray (arr, val) { - arr = arr || []; - var len = arr.length; - var i; - - for (i = 0; i < len; i++) { - if (arr[i] === val) { - return true; - } - } - return false; -}; diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/package.json b/src/test/fixtures/yarnWorkspaces/node_modules/in-array/package.json deleted file mode 100644 index 8c5da4eb..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/in-array/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "in-array", - "description": "Return true if a value exists in an array. Faster than using indexOf and won't blow up on null values.", - "version": "0.1.2", - "homepage": "https://github.com/jonschlinkert/in-array", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "repository": "jonschlinkert/in-array", - "bugs": { - "url": "https://github.com/jonschlinkert/in-array/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "lint": "jshint *.js test/*.js", - "test": "npm run lint && mocha" - }, - "devDependencies": { - "benchmark": "^2.1.0", - "gulp-format-md": "^0.1.7" - }, - "keywords": [ - "array", - "check", - "element", - "find", - "index", - "index-of", - "of" - ], - "verb": { - "run": true, - "toc": false, - "layout": "default", - "tasks": [ - "readme" - ], - "plugins": [ - "gulp-format-md" - ], - "related": { - "list": [ - "isobject", - "is-plain-object", - "arr-flatten", - "arr-union" - ] - }, - "reflinks": [ - "verb" - ], - "lint": { - "reflinks": true - } - } -} diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/LICENSE b/src/test/fixtures/yarnWorkspaces/node_modules/is-number/LICENSE deleted file mode 100644 index 9af4a67d..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-present, Jon Schlinkert. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/README.md b/src/test/fixtures/yarnWorkspaces/node_modules/is-number/README.md deleted file mode 100644 index eb8149e8..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/README.md +++ /dev/null @@ -1,187 +0,0 @@ -# is-number [![NPM version](https://img.shields.io/npm/v/is-number.svg?style=flat)](https://www.npmjs.com/package/is-number) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![NPM total downloads](https://img.shields.io/npm/dt/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-number.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-number) - -> Returns true if the value is a finite number. - -Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. - -## Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm install --save is-number -``` - -## Why is this needed? - -In JavaScript, it's not always as straightforward as it should be to reliably check if a value is a number. It's common for devs to use `+`, `-`, or `Number()` to cast a string value to a number (for example, when values are returned from user input, regex matches, parsers, etc). But there are many non-intuitive edge cases that yield unexpected results: - -```js -console.log(+[]); //=> 0 -console.log(+''); //=> 0 -console.log(+' '); //=> 0 -console.log(typeof NaN); //=> 'number' -``` - -This library offers a performant way to smooth out edge cases like these. - -## Usage - -```js -const isNumber = require('is-number'); -``` - -See the [tests](./test.js) for more examples. - -### true - -```js -isNumber(5e3); // true -isNumber(0xff); // true -isNumber(-1.1); // true -isNumber(0); // true -isNumber(1); // true -isNumber(1.1); // true -isNumber(10); // true -isNumber(10.10); // true -isNumber(100); // true -isNumber('-1.1'); // true -isNumber('0'); // true -isNumber('012'); // true -isNumber('0xff'); // true -isNumber('1'); // true -isNumber('1.1'); // true -isNumber('10'); // true -isNumber('10.10'); // true -isNumber('100'); // true -isNumber('5e3'); // true -isNumber(parseInt('012')); // true -isNumber(parseFloat('012')); // true -``` - -### False - -Everything else is false, as you would expect: - -```js -isNumber(Infinity); // false -isNumber(NaN); // false -isNumber(null); // false -isNumber(undefined); // false -isNumber(''); // false -isNumber(' '); // false -isNumber('foo'); // false -isNumber([1]); // false -isNumber([]); // false -isNumber(function () {}); // false -isNumber({}); // false -``` - -## Release history - -### 7.0.0 - -* Refactor. Now uses `.isFinite` if it exists. -* Performance is about the same as v6.0 when the value is a string or number. But it's now 3x-4x faster when the value is not a string or number. - -### 6.0.0 - -* Optimizations, thanks to @benaadams. - -### 5.0.0 - -**Breaking changes** - -* removed support for `instanceof Number` and `instanceof String` - -## Benchmarks - -As with all benchmarks, take these with a grain of salt. See the [benchmarks](./benchmark/index.js) for more detail. - -``` -# all -v7.0 x 413,222 ops/sec ±2.02% (86 runs sampled) -v6.0 x 111,061 ops/sec ±1.29% (85 runs sampled) -parseFloat x 317,596 ops/sec ±1.36% (86 runs sampled) -fastest is 'v7.0' - -# string -v7.0 x 3,054,496 ops/sec ±1.05% (89 runs sampled) -v6.0 x 2,957,781 ops/sec ±0.98% (88 runs sampled) -parseFloat x 3,071,060 ops/sec ±1.13% (88 runs sampled) -fastest is 'parseFloat,v7.0' - -# number -v7.0 x 3,146,895 ops/sec ±0.89% (89 runs sampled) -v6.0 x 3,214,038 ops/sec ±1.07% (89 runs sampled) -parseFloat x 3,077,588 ops/sec ±1.07% (87 runs sampled) -fastest is 'v6.0' -``` - -## About - -
-Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). - -
- -
-Running Tests - -Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: - -```sh -$ npm install && npm test -``` - -
- -
-Building docs - -_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ - -To generate the readme, run the following command: - -```sh -$ npm install -g verbose/verb#dev verb-generate-readme && verb -``` - -
- -### Related projects - -You might also be interested in these projects: - -* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.") -* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ") -* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.") -* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.") - -### Contributors - -| **Commits** | **Contributor** | -| --- | --- | -| 49 | [jonschlinkert](https://github.com/jonschlinkert) | -| 5 | [charlike-old](https://github.com/charlike-old) | -| 1 | [benaadams](https://github.com/benaadams) | -| 1 | [realityking](https://github.com/realityking) | - -### Author - -**Jon Schlinkert** - -* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) -* [GitHub Profile](https://github.com/jonschlinkert) -* [Twitter Profile](https://twitter.com/jonschlinkert) - -### License - -Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT License](LICENSE). - -*** - -_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 15, 2018._ \ No newline at end of file diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/index.js b/src/test/fixtures/yarnWorkspaces/node_modules/is-number/index.js deleted file mode 100644 index 27f19b75..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/index.js +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * is-number - * - * Copyright (c) 2014-present, Jon Schlinkert. - * Released under the MIT License. - */ - -'use strict'; - -module.exports = function(num) { - if (typeof num === 'number') { - return num - num === 0; - } - if (typeof num === 'string' && num.trim() !== '') { - return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); - } - return false; -}; diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/package.json b/src/test/fixtures/yarnWorkspaces/node_modules/is-number/package.json deleted file mode 100644 index 37150726..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/is-number/package.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "is-number", - "description": "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.", - "version": "7.0.0", - "homepage": "https://github.com/jonschlinkert/is-number", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "contributors": [ - "Jon Schlinkert (http://twitter.com/jonschlinkert)", - "Olsten Larck (https://i.am.charlike.online)", - "Rouven Weßling (www.rouvenwessling.de)" - ], - "repository": "jonschlinkert/is-number", - "bugs": { - "url": "https://github.com/jonschlinkert/is-number/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.12.0" - }, - "scripts": { - "test": "mocha" - }, - "devDependencies": { - "ansi": "^0.3.1", - "benchmark": "^2.1.4", - "gulp-format-md": "^1.0.0", - "mocha": "^3.5.3" - }, - "keywords": [ - "cast", - "check", - "coerce", - "coercion", - "finite", - "integer", - "is", - "isnan", - "is-nan", - "is-num", - "is-number", - "isnumber", - "isfinite", - "istype", - "kind", - "math", - "nan", - "num", - "number", - "numeric", - "parseFloat", - "parseInt", - "test", - "type", - "typeof", - "value" - ], - "verb": { - "toc": false, - "layout": "default", - "tasks": [ - "readme" - ], - "related": { - "list": [ - "is-plain-object", - "is-primitive", - "isobject", - "kind-of" - ] - }, - "plugins": [ - "gulp-format-md" - ], - "lint": { - "reflinks": true - } - } -} diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/index.js b/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/index.js deleted file mode 100644 index 4f1e4be9..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/index.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -const isObject = value => typeof value === 'object' && value !== null; - -// Customized for this use-case -const isObjectCustom = value => - isObject(value) && - !(value instanceof RegExp) && - !(value instanceof Error) && - !(value instanceof Date); - -const mapObject = (object, mapper, options, isSeen = new WeakMap()) => { - options = { - deep: false, - target: {}, - ...options - }; - - if (isSeen.has(object)) { - return isSeen.get(object); - } - - isSeen.set(object, options.target); - - const {target} = options; - delete options.target; - - const mapArray = array => array.map(element => isObjectCustom(element) ? mapObject(element, mapper, options, isSeen) : element); - if (Array.isArray(object)) { - return mapArray(object); - } - - for (const [key, value] of Object.entries(object)) { - let [newKey, newValue] = mapper(key, value, object); - - if (options.deep && isObjectCustom(newValue)) { - newValue = Array.isArray(newValue) ? - mapArray(newValue) : - mapObject(newValue, mapper, options, isSeen); - } - - target[newKey] = newValue; - } - - return target; -}; - -module.exports = (object, mapper, options) => { - if (!isObject(object)) { - throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`); - } - - return mapObject(object, mapper, options); -}; diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/license b/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/license deleted file mode 100644 index e7af2f77..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/package.json b/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/package.json deleted file mode 100644 index 18cf63c3..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "map-obj", - "version": "4.1.0", - "description": "Map object keys and values into a new object", - "license": "MIT", - "repository": "sindresorhus/map-obj", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "map", - "object", - "key", - "keys", - "value", - "values", - "iterate", - "iterator", - "rename", - "modify", - "deep", - "recurse", - "recursive" - ], - "devDependencies": { - "ava": "^2.0.0", - "tsd": "^0.7.3", - "xo": "^0.24.0" - } -} diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/readme.md b/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/readme.md deleted file mode 100644 index cd405f56..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/map-obj/readme.md +++ /dev/null @@ -1,76 +0,0 @@ -# map-obj [![Build Status](https://travis-ci.org/sindresorhus/map-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/map-obj) - -> Map object keys and values into a new object - - -## Install - -``` -$ npm install map-obj -``` - - -## Usage - -```js -const mapObject = require('map-obj'); - -const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]); -//=> {bar: 'foo'} -``` - - -## API - -### mapObject(source, mapper, options?) - -#### source - -Type: `object` - -Source object to copy properties from. - -#### mapper - -Type: `Function` - -Mapping function. - -- It has signature `mapper(sourceKey, sourceValue, source)`. -- It must return a two item array: `[targetKey, targetValue]`. - -#### options - -Type: `object` - -##### deep - -Type: `boolean`
-Default: `false` - -Recurse nested objects and objects in arrays. - -##### target - -Type: `object`
-Default: `{}` - -Target object to map properties on to. - - -## Related - -- [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object - - ---- - -
- - Get professional support for this package with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/package-a b/src/test/fixtures/yarnWorkspaces/node_modules/package-a deleted file mode 120000 index ea7528af..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/package-a +++ /dev/null @@ -1 +0,0 @@ -../packageA \ No newline at end of file diff --git a/src/test/fixtures/yarnWorkspaces/node_modules/package-b b/src/test/fixtures/yarnWorkspaces/node_modules/package-b deleted file mode 120000 index b9b0c8fc..00000000 --- a/src/test/fixtures/yarnWorkspaces/node_modules/package-b +++ /dev/null @@ -1 +0,0 @@ -../packageB \ No newline at end of file diff --git a/src/test/fixtures/yarnWorkspaces/package.json b/src/test/fixtures/yarnWorkspaces/package.json deleted file mode 100644 index 899beedb..00000000 --- a/src/test/fixtures/yarnWorkspaces/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "yarn-workspaces-monorepo", - "publisher": "mocha", - "version": "1.0.0", - "private": true, - "engines": { "vscode": "*" }, - "workspaces": [ - "packageA", - "packageB" - ], - "dependencies": { - }, - "devDependencies": { - } -} diff --git a/src/test/fixtures/yarnWorkspaces/packageA/important/prod.log b/src/test/fixtures/yarnWorkspaces/packageA/important/prod.log deleted file mode 100644 index 6bfe6b19..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageA/important/prod.log +++ /dev/null @@ -1 +0,0 @@ -log diff --git a/src/test/fixtures/yarnWorkspaces/packageA/logger.log b/src/test/fixtures/yarnWorkspaces/packageA/logger.log deleted file mode 100644 index 6bfe6b19..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageA/logger.log +++ /dev/null @@ -1 +0,0 @@ -log diff --git a/src/test/fixtures/yarnWorkspaces/packageA/main.js b/src/test/fixtures/yarnWorkspaces/packageA/main.js deleted file mode 100644 index 90d2a58e..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageA/main.js +++ /dev/null @@ -1 +0,0 @@ -// Package A diff --git a/src/test/fixtures/yarnWorkspaces/packageA/package.json b/src/test/fixtures/yarnWorkspaces/packageA/package.json deleted file mode 100644 index fd1302f5..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageA/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "package-a", - "publisher": "mocha", - "version": "1.0.0", - "engines": { - "vscode": "*" - }, - "dependencies": { - "filter-obj": "2.0.1" - }, - "devDependencies": { - "is-number": "7.0.0" - } -} diff --git a/src/test/fixtures/yarnWorkspaces/packageB/.vscodeignore b/src/test/fixtures/yarnWorkspaces/packageB/.vscodeignore deleted file mode 100644 index 20e9ce5b..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageB/.vscodeignore +++ /dev/null @@ -1,5 +0,0 @@ -# pattern of file name -../node_modules/package-a/*.log - -# include files using negate -!../node_modules/package-a/important diff --git a/src/test/fixtures/yarnWorkspaces/packageB/main.js b/src/test/fixtures/yarnWorkspaces/packageB/main.js deleted file mode 100644 index 7fc1d307..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageB/main.js +++ /dev/null @@ -1 +0,0 @@ -// Package B diff --git a/src/test/fixtures/yarnWorkspaces/packageB/package.json b/src/test/fixtures/yarnWorkspaces/packageB/package.json deleted file mode 100644 index 4c5c6fa2..00000000 --- a/src/test/fixtures/yarnWorkspaces/packageB/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "package-b", - "publisher": "mocha", - "version": "1.0.0", - "engines": { - "vscode": "*" - }, - "dependencies": { - "map-obj": "4.1.0", - "package-a": "*" - }, - "devDependencies": { - "in-array": "0.1.2" - } -} diff --git a/src/test/fixtures/yarnWorkspaces/yarn.lock b/src/test/fixtures/yarnWorkspaces/yarn.lock deleted file mode 100644 index d14b6866..00000000 --- a/src/test/fixtures/yarnWorkspaces/yarn.lock +++ /dev/null @@ -1,23 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -filter-obj@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-2.0.1.tgz#34d9f0536786f072df7aeac3a8bda1c6e767aec6" - integrity sha512-yDEp513p7+iLdFHWBVdZFnRiOYwg8ZqmpaAiZCMjzqsbo7tCS4Qm4ulXOht337NGzkukKa9u3W4wqQ9tQPm3Ug== - -in-array@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/in-array/-/in-array-0.1.2.tgz#1a2683009177ab914ade0620a35c5039851f3715" - integrity sha1-GiaDAJF3q5FK3gYgo1xQOYUfNxU= - -is-number@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -map-obj@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5" - integrity sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g== diff --git a/src/test/package.test.ts b/src/test/package.test.ts index d32ab8c3..4c1fb6aa 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -11,7 +11,6 @@ import { validateManifest, IPackageOptions, ManifestProcessor, - ILocalFile, versionBump, VSIX, LicenseProcessor, @@ -244,91 +243,6 @@ describe('collect', function () { const manifest = await readManifest(cwd); await collect(manifest, { cwd }); }); - - it('should collect the right files when using yarn workspaces', async () => { - // PackageB will act as the extension here - const root = fixture('yarnWorkspaces'); - const cwd = path.join(root, 'packageB'); - const manifest = await readManifest(cwd); - - assert.strictEqual(manifest.name, 'package-b'); - - const files = await collect(manifest, { cwd }) as ILocalFile[]; - - [ - { - path: 'extension/main.js', - localPath: path.resolve(cwd, 'main.js') - }, - { - path: 'extension/package.json', - localPath: path.resolve(cwd, 'package.json') - }, - { - path: 'extension/node_modules/package-a/main.js', - localPath: path.resolve(root, 'node_modules/package-a/main.js') - }, - { - path: 'extension/node_modules/package-a/package.json', - localPath: path.resolve(root, 'node_modules/package-a/package.json') - }, - { - path: 'extension/node_modules/package-a/important/prod.log', - localPath: path.resolve(root, 'node_modules/package-a/important/prod.log') - } - ].forEach(expected => { - const found = files.find(f => f.path === expected.path || f.localPath === expected.localPath); - if (found) { - assert.strictEqual(found.path, expected.path, 'path'); - assert.strictEqual(found.localPath, expected.localPath, 'localPath'); - } - }) - const ignoreFilename = 'extension/node_modules/package-a/logger.log'; - const ignore = files.find(f => f.path === ignoreFilename); - assert.ok(!ignore, 'should ignore ' + ignoreFilename) - }); - - it('should handle target and ignoreOtherTargetFolders', async function () { - const cwd = fixture('target'); - const manifest = await readManifest(cwd); - let files = await collect(manifest, { cwd }); - - assert.strictEqual(files.length, 13); - assert.ok(files.some(f => f.path === 'extension/file.txt')); - assert.ok(files.some(f => f.path === 'extension/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/linux-x64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/linux-x64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/web/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/web/file.txt')); - assert.ok(files.some(f => f.path === 'extension/darwin-arm64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/darwin-arm64/file.txt')); - - files = await collect(manifest, { cwd, target: 'linux-x64' }); - - assert.strictEqual(files.length, 13); - assert.ok(files.some(f => f.path === 'extension/file.txt')); - assert.ok(files.some(f => f.path === 'extension/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/linux-x64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/linux-x64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/web/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/web/file.txt')); - assert.ok(files.some(f => f.path === 'extension/darwin-arm64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/darwin-arm64/file.txt')); - - files = await collect(manifest, { cwd, target: 'linux-x64', ignoreOtherTargetFolders: true }); - - assert.strictEqual(files.length, 9); - assert.ok(files.some(f => f.path === 'extension/file.txt')); - assert.ok(files.some(f => f.path === 'extension/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/random/file.txt')); - assert.ok(files.some(f => f.path === 'extension/linux-x64/file.txt')); - assert.ok(files.some(f => f.path === 'extension/deep/linux-x64/file.txt')); - }); }); describe('readManifest', () => {