workspace-tools
Advanced tools
Comparing version 0.17.0 to 0.18.0
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Thu, 02 Dec 2021 17:11:04 GMT", | ||
"date": "Fri, 07 Jan 2022 00:04:25 GMT", | ||
"tag": "workspace-tools_v0.18.0", | ||
"version": "0.18.0", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"author": "kchau@microsoft.com", | ||
"package": "workspace-tools", | ||
"comment": "speed up workspace-tools - reducing weight and adding caches - lazy load pkg mgr helpers", | ||
"commit": "6105a8eb81e4972b9ffbdd18669a137f0f5d9400" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Thu, 02 Dec 2021 17:11:12 GMT", | ||
"tag": "workspace-tools_v0.17.0", | ||
@@ -8,0 +23,0 @@ "version": "0.17.0", |
# Change Log - workspace-tools | ||
This log was last generated on Thu, 02 Dec 2021 17:11:04 GMT and should not be manually modified. | ||
This log was last generated on Fri, 07 Jan 2022 00:04:25 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.18.0 | ||
Fri, 07 Jan 2022 00:04:25 GMT | ||
### Minor changes | ||
- speed up workspace-tools - reducing weight and adding caches - lazy load pkg mgr helpers (kchau@microsoft.com) | ||
## 0.17.0 | ||
Thu, 02 Dec 2021 17:11:04 GMT | ||
Thu, 02 Dec 2021 17:11:12 GMT | ||
@@ -11,0 +19,0 @@ ### Minor changes |
@@ -8,23 +8,23 @@ "use strict"; | ||
const globby_1 = __importDefault(require("globby")); | ||
const packagePathsCache = {}; | ||
function getPackagePaths(workspacesRoot, packages) { | ||
const packagePaths = packages.map((glob) => { | ||
const globbed = globby_1.default | ||
.sync(path_1.default.join(glob, "package.json").replace(/\\/g, "/"), { | ||
cwd: workspacesRoot, | ||
absolute: true, | ||
ignore: ["**/node_modules/**"], | ||
}) | ||
.map((p) => path_1.default.dirname(p)); | ||
return globbed; | ||
}); | ||
/* | ||
* fast-glob returns unix style path, | ||
* so we use path.join to align the path with the platform. | ||
*/ | ||
return packagePaths | ||
.reduce((acc, cur) => { | ||
return [...acc, ...cur]; | ||
if (packagePathsCache[workspacesRoot]) { | ||
return packagePathsCache[workspacesRoot]; | ||
} | ||
const packagePaths = globby_1.default | ||
.sync(packages.map((glob) => path_1.default.join(glob, "package.json").replace(/\\/g, "/")), { | ||
cwd: workspacesRoot, | ||
absolute: true, | ||
ignore: ["**/node_modules/**"], | ||
stats: false, | ||
}) | ||
.map((p) => path_1.default.join(p)); | ||
.map((p) => path_1.default.dirname(p)); | ||
if (path_1.default.sep === "/") { | ||
packagePathsCache[workspacesRoot] = packagePaths; | ||
} | ||
else { | ||
packagePathsCache[workspacesRoot] = packagePaths.map((p) => p.replace(/\//g, path_1.default.sep)); | ||
} | ||
return packagePathsCache[workspacesRoot]; | ||
} | ||
exports.getPackagePaths = getPackagePaths; |
@@ -9,3 +9,2 @@ "use strict"; | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const fs_extra_2 = __importDefault(require("fs-extra")); | ||
const tmp_1 = __importDefault(require("tmp")); | ||
@@ -43,4 +42,4 @@ const git_1 = require("../git"); | ||
// a 'fixed' value for our tests, regardless of user configuration | ||
git_1.gitFailFast(['symbolic-ref', 'HEAD', 'refs/heads/main'], { cwd }); | ||
git_1.gitFailFast(['config', 'init.defaultBranch', 'main'], { cwd }); | ||
git_1.gitFailFast(["symbolic-ref", "HEAD", "refs/heads/main"], { cwd }); | ||
git_1.gitFailFast(["config", "init.defaultBranch", "main"], { cwd }); | ||
git_1.stageAndCommit(["."], "test", cwd); | ||
@@ -64,7 +63,7 @@ return cwd; | ||
const pkgJsonPath = path_1.default.join(cwd, "package.json"); | ||
const pkgJson = fs_extra_2.default.readJSONSync(pkgJsonPath); | ||
fs_extra_2.default.writeJSONSync(pkgJsonPath, Object.assign(Object.assign({}, pkgJson), { repository: { | ||
url: remoteUrl | ||
} })); | ||
const pkgJson = JSON.parse(fs_extra_1.default.readFileSync(pkgJsonPath, "utf-8")); | ||
fs_extra_1.default.writeFileSync(pkgJsonPath, JSON.stringify(Object.assign(Object.assign({}, pkgJson), { repository: { | ||
url: remoteUrl, | ||
} }), null, 2)); | ||
} | ||
exports.setupLocalRemote = setupLocalRemote; |
@@ -15,4 +15,3 @@ "use strict"; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const read_yaml_file_1 = __importDefault(require("read-yaml-file")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const nameAtVersion_1 = require("./nameAtVersion"); | ||
@@ -31,3 +30,3 @@ exports.nameAtVersion = nameAtVersion_1.nameAtVersion; | ||
const parseYarnLock = (await Promise.resolve().then(() => __importStar(require("@yarnpkg/lockfile")))).parse; | ||
const yarnLock = fs_extra_1.default.readFileSync(yarnLockPath).toString(); | ||
const yarnLock = fs_1.default.readFileSync(yarnLockPath, 'utf-8'); | ||
const parsed = parseYarnLock(yarnLock); | ||
@@ -43,3 +42,4 @@ memoization[yarnLockPath] = parsed; | ||
} | ||
const yaml = await read_yaml_file_1.default(pnpmLockPath); | ||
const readYamlFile = require("read-yaml-file"); | ||
const yaml = (await readYamlFile(pnpmLockPath)); | ||
const parsed = parsePnpmLock_1.parsePnpmLock(yaml); | ||
@@ -57,3 +57,3 @@ memoization[pnpmLockPath] = parsed; | ||
try { | ||
npmLockJson = fs_extra_1.default.readFileSync(npmLockPath); | ||
npmLockJson = fs_1.default.readFileSync(npmLockPath, 'utf-8'); | ||
} | ||
@@ -60,0 +60,0 @@ catch (_a) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const implementations_1 = require("./implementations"); | ||
const pnpm_1 = require("./implementations/pnpm"); | ||
const yarn_1 = require("./implementations/yarn"); | ||
const rush_1 = require("./implementations/rush"); | ||
const npm_1 = require("./implementations/npm"); | ||
const lerna_1 = require("./implementations/lerna"); | ||
const workspaceGetter = { | ||
yarn: yarn_1.getYarnWorkspaceRoot, | ||
pnpm: pnpm_1.getPnpmWorkspaceRoot, | ||
rush: rush_1.getRushWorkspaceRoot, | ||
npm: npm_1.getNpmWorkspaceRoot, | ||
lerna: lerna_1.getLernaWorkspaceRoot, | ||
}; | ||
const preferred = process.env | ||
.PREFERRED_WORKSPACE_MANAGER; | ||
const preferred = process.env.PREFERRED_WORKSPACE_MANAGER; | ||
function getWorkspaceRoot(cwd) { | ||
const workspaceImplementation = preferred || implementations_1.getWorkspaceImplementation(cwd); | ||
if (!workspaceImplementation || !workspaceGetter[workspaceImplementation]) { | ||
if (!workspaceImplementation) { | ||
return; | ||
} | ||
return workspaceGetter[workspaceImplementation](cwd); | ||
switch (workspaceImplementation) { | ||
case "yarn": | ||
return require(`./implementations/yarn`).getYarnWorkspaceRoot(cwd); | ||
case "pnpm": | ||
return require(`./implementations/pnpm`).getPnpmWorkspaceRoot(cwd); | ||
case "rush": | ||
return require(`./implementations/rush`).getRushWorkspaceRoot(cwd); | ||
case "npm": | ||
return require(`./implementations/npm`).getNpmWorkspaceRoot(cwd); | ||
case "lerna": | ||
return require(`./implementations/lerna`).getLernaWorkspaceRoot(cwd); | ||
} | ||
} | ||
exports.getWorkspaceRoot = getWorkspaceRoot; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const implementations_1 = require("./implementations"); | ||
const lerna_1 = require("./implementations/lerna"); | ||
const npm_1 = require("./implementations/npm"); | ||
const pnpm_1 = require("./implementations/pnpm"); | ||
const rush_1 = require("./implementations/rush"); | ||
const yarn_1 = require("./implementations/yarn"); | ||
const workspaceGetter = { | ||
yarn: yarn_1.getYarnWorkspaces, | ||
pnpm: pnpm_1.getPnpmWorkspaces, | ||
rush: rush_1.getRushWorkspaces, | ||
npm: npm_1.getNpmWorkspaces, | ||
lerna: lerna_1.getLernaWorkspaces, | ||
}; | ||
const preferred = process.env | ||
.PREFERRED_WORKSPACE_MANAGER; | ||
const preferred = process.env.PREFERRED_WORKSPACE_MANAGER; | ||
function getWorkspaces(cwd) { | ||
const workspaceImplementation = preferred || implementations_1.getWorkspaceImplementation(cwd); | ||
if (!workspaceImplementation || !workspaceGetter[workspaceImplementation]) { | ||
if (!workspaceImplementation) { | ||
return []; | ||
} | ||
return workspaceGetter[workspaceImplementation](cwd); | ||
switch (workspaceImplementation) { | ||
case "yarn": | ||
return require(`./implementations/yarn`).getYarnWorkspaces(cwd); | ||
case "pnpm": | ||
return require(`./implementations/pnpm`).getPnpmWorkspaces(cwd); | ||
case "rush": | ||
return require(`./implementations/rush`).getRushWorkspaces(cwd); | ||
case "npm": | ||
return require(`./implementations/npm`).getNpmWorkspaces(cwd); | ||
case "lerna": | ||
return require(`./implementations/lerna`).getLernaWorkspaces(cwd); | ||
} | ||
} | ||
exports.getWorkspaces = getWorkspaces; |
@@ -1,2 +0,10 @@ | ||
export declare type WorkspaceImplementations = "yarn" | "pnpm" | "rush" | "npm" | 'lerna'; | ||
export declare type WorkspaceImplementations = "yarn" | "pnpm" | "rush" | "npm" | "lerna"; | ||
export interface ImplementationAndLockFile { | ||
implementation: WorkspaceImplementations | undefined; | ||
lockFile: string; | ||
} | ||
export declare function getWorkspaceImplementationAndLockFile(cwd: string): { | ||
implementation: WorkspaceImplementations | undefined; | ||
lockFile: string; | ||
} | undefined; | ||
export declare function getWorkspaceImplementation(cwd: string): WorkspaceImplementations | undefined; |
@@ -7,26 +7,53 @@ "use strict"; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
function getWorkspaceImplementation(cwd) { | ||
// This needs to come before Yarn and NPM because | ||
// lerna can be used with either package manager | ||
const lernaJsonPath = find_up_1.default.sync("lerna.json", { cwd }); | ||
if (lernaJsonPath) { | ||
return "lerna"; | ||
const path_1 = __importDefault(require("path")); | ||
const cache = {}; | ||
function getWorkspaceImplementationAndLockFile(cwd) { | ||
if (cache[cwd]) { | ||
return cache[cwd]; | ||
} | ||
const yarnLockPath = find_up_1.default.sync("yarn.lock", { cwd }); | ||
if (yarnLockPath) { | ||
return "yarn"; | ||
const lockFile = find_up_1.default.sync(["lerna.json", "yarn.lock", "pnpm-workspace.yaml", "rush.json", "package-lock.json"], { | ||
cwd, | ||
}); | ||
if (!lockFile) { | ||
return; | ||
} | ||
const pnpmLockPath = find_up_1.default.sync("pnpm-workspace.yaml", { cwd }); | ||
if (pnpmLockPath) { | ||
return "pnpm"; | ||
switch (path_1.default.basename(lockFile)) { | ||
case "lerna.json": | ||
cache[cwd] = { | ||
implementation: "lerna", | ||
lockFile, | ||
}; | ||
break; | ||
case "yarn.lock": | ||
cache[cwd] = { | ||
implementation: "yarn", | ||
lockFile, | ||
}; | ||
break; | ||
case "pnpm-workspace.yaml": | ||
cache[cwd] = { | ||
implementation: "pnpm", | ||
lockFile, | ||
}; | ||
break; | ||
case "rush.json": | ||
cache[cwd] = { | ||
implementation: "rush", | ||
lockFile, | ||
}; | ||
break; | ||
case "package-lock.json": | ||
cache[cwd] = { | ||
implementation: "npm", | ||
lockFile, | ||
}; | ||
break; | ||
} | ||
const rushJsonPath = find_up_1.default.sync("rush.json", { cwd }); | ||
if (rushJsonPath) { | ||
return "rush"; | ||
} | ||
const npmLockPath = find_up_1.default.sync("package-lock.json", { cwd }); | ||
if (npmLockPath) { | ||
return "npm"; | ||
} | ||
return cache[cwd]; | ||
} | ||
exports.getWorkspaceImplementationAndLockFile = getWorkspaceImplementationAndLockFile; | ||
function getWorkspaceImplementation(cwd) { | ||
var _a; | ||
return (_a = getWorkspaceImplementationAndLockFile(cwd)) === null || _a === void 0 ? void 0 : _a.implementation; | ||
} | ||
exports.getWorkspaceImplementation = getWorkspaceImplementation; |
@@ -6,9 +6,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const _1 = require("."); | ||
const getPackagePaths_1 = require("../../getPackagePaths"); | ||
const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo"); | ||
function getPackageJsonWorkspaceRoot(cwd) { | ||
const packageJsonWorkspacesRoot = find_yarn_workspace_root_1.default(cwd); | ||
var _a; | ||
const lockFile = (_a = _1.getWorkspaceImplementationAndLockFile(cwd)) === null || _a === void 0 ? void 0 : _a.lockFile; | ||
const packageJsonWorkspacesRoot = lockFile ? path_1.default.dirname(lockFile) : cwd; | ||
return packageJsonWorkspacesRoot; | ||
@@ -15,0 +17,0 @@ } |
@@ -8,3 +8,2 @@ "use strict"; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
const read_yaml_file_1 = require("read-yaml-file"); | ||
const getPackagePaths_1 = require("../../getPackagePaths"); | ||
@@ -24,3 +23,4 @@ const getWorkspacePackageInfo_1 = require("../getWorkspacePackageInfo"); | ||
const pnpmWorkspacesFile = path_1.default.join(pnpmWorkspacesRoot, "pnpm-workspace.yaml"); | ||
const pnpmWorkspaces = read_yaml_file_1.sync(pnpmWorkspacesFile); | ||
const readYaml = require("read-yaml-file").sync; | ||
const pnpmWorkspaces = readYaml(pnpmWorkspacesFile); | ||
const packagePaths = getPackagePaths_1.getPackagePaths(pnpmWorkspacesRoot, pnpmWorkspaces.packages); | ||
@@ -27,0 +27,0 @@ const workspaceInfo = getWorkspacePackageInfo_1.getWorkspacePackageInfo(packagePaths); |
{ | ||
"name": "workspace-tools", | ||
"version": "0.17.0", | ||
"version": "0.18.0", | ||
"license": "MIT", | ||
@@ -22,4 +22,2 @@ "repository": { | ||
"find-up": "^4.1.0", | ||
"find-yarn-workspace-root": "^1.2.1", | ||
"fs-extra": "^9.0.0", | ||
"git-url-parse": "^11.1.2", | ||
@@ -32,3 +30,2 @@ "globby": "^11.0.0", | ||
"devDependencies": { | ||
"@types/fs-extra": "^8.1.0", | ||
"@types/git-url-parse": "^9.0.0", | ||
@@ -35,0 +32,0 @@ "@types/glob": "^7.1.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
124237
7
13
2926
24
- Removedfind-yarn-workspace-root@^1.2.1
- Removedfs-extra@^9.0.0
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedat-least-node@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfind-yarn-workspace-root@1.2.1(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfs-extra@4.0.39.1.0(transitive)
- Removedget-value@2.0.6(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjsonfile@4.0.06.1.0(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removeduniversalify@0.1.22.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)