@monorepo-utils/package-utils
Advanced tools
+17
-11
@@ -38,14 +38,4 @@ "use strict"; | ||
| var getPackages = function (rootDirectory) { | ||
| var lernaJsonPath = path.join(rootDirectory, "lerna.json"); | ||
| // prefer to use yarn workspace instead of lerna.json | ||
| if (fs.existsSync(lernaJsonPath)) { | ||
| var lernaJson = loadJsonFile.sync(lernaJsonPath); | ||
| var hasNotWorkspacesInLernaJson = function (v) { | ||
| return !("useWorkspaces" in v); | ||
| }; | ||
| if (hasNotWorkspacesInLernaJson(lernaJson)) { | ||
| return (0, exports.findPackages)(lernaJson.packages, rootDirectory); | ||
| } | ||
| } | ||
| var pkgJsonPath = path.join(rootDirectory, "package.json"); | ||
| // npm 7+/yarn workspaces support | ||
| if (fs.existsSync(pkgJsonPath)) { | ||
@@ -67,2 +57,3 @@ var pkgJson = loadJsonFile.sync(pkgJsonPath); | ||
| } | ||
| // pnpm workspaces support | ||
| var pnpmYamlPath = path.join(rootDirectory, "pnpm-workspace.yaml"); | ||
@@ -76,2 +67,17 @@ if (fs.existsSync(pnpmYamlPath)) { | ||
| } | ||
| // legacy lerna(pre workspaces) support | ||
| // leran 7+ does not have "useWorkspaces" option | ||
| // if non-useWorkspaces and packages is defined, use it | ||
| var lernaJsonPath = path.join(rootDirectory, "lerna.json"); | ||
| // prefer to use yarn workspace instead of lerna.json | ||
| if (fs.existsSync(lernaJsonPath)) { | ||
| var lernaJson = loadJsonFile.sync(lernaJsonPath); | ||
| // useWorkspaces is removed in lerna 7 | ||
| var hasNotWorkspacesInLernaJson = function (v) { | ||
| return !("useWorkspaces" in v); | ||
| }; | ||
| if (hasNotWorkspacesInLernaJson(lernaJson) && lernaJson.packages) { | ||
| return (0, exports.findPackages)(lernaJson.packages, rootDirectory); | ||
| } | ||
| } | ||
| // Bail if we don't find any packages | ||
@@ -78,0 +84,0 @@ return []; |
+10
-10
| { | ||
| "name": "@monorepo-utils/package-utils", | ||
| "version": "2.9.0", | ||
| "version": "2.10.2", | ||
| "description": "Package utility for monorepo.", | ||
@@ -70,11 +70,11 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@types/jest": "^26.0.10", | ||
| "@types/jest": "^29.5.2", | ||
| "@types/load-json-file": "^5.1.0", | ||
| "@types/node": "^14.6.2", | ||
| "cross-env": "^7.0.2", | ||
| "jest": "^26.4.2", | ||
| "prettier": "^2.1.1", | ||
| "rimraf": "^3.0.2", | ||
| "ts-jest": "^26.3.0", | ||
| "typescript": "^4.4.4" | ||
| "@types/node": "^20.4.0", | ||
| "cross-env": "^7.0.3", | ||
| "jest": "^29.6.1", | ||
| "prettier": "^2.8.8", | ||
| "rimraf": "^5.0.1", | ||
| "ts-jest": "^29.1.1", | ||
| "typescript": "^5.1.6" | ||
| }, | ||
@@ -84,3 +84,3 @@ "publishConfig": { | ||
| }, | ||
| "gitHead": "77d7d3a5daf5a67dbc8de45017b8898100945b16" | ||
| "gitHead": "103ae872df1b4ce67e3819e29b43d0b4dfc2c101" | ||
| } |
+19
-13
@@ -45,19 +45,8 @@ "use strict"; | ||
| export const getPackages = (rootDirectory: string): PackageResult[] => { | ||
| const lernaJsonPath = path.join(rootDirectory, "lerna.json"); | ||
| // prefer to use yarn workspace instead of lerna.json | ||
| if (fs.existsSync(lernaJsonPath)) { | ||
| const lernaJson = loadJsonFile.sync(lernaJsonPath); | ||
| const hasNotWorkspacesInLernaJson = (v: any): v is { packages: string[] } => { | ||
| return !("useWorkspaces" in v); | ||
| }; | ||
| if (hasNotWorkspacesInLernaJson(lernaJson)) { | ||
| return findPackages(lernaJson.packages, rootDirectory); | ||
| } | ||
| } | ||
| const pkgJsonPath = path.join(rootDirectory, "package.json"); | ||
| // npm 7+/yarn workspaces support | ||
| if (fs.existsSync(pkgJsonPath)) { | ||
| const pkgJson = loadJsonFile.sync(pkgJsonPath); | ||
| const hasWorkspacesInPackageJson = ( | ||
| v: any | ||
| v: any, | ||
| ): v is { | ||
@@ -79,2 +68,3 @@ workspaces: { packages: string[] } | string[]; | ||
| // pnpm workspaces support | ||
| const pnpmYamlPath = path.join(rootDirectory, "pnpm-workspace.yaml"); | ||
@@ -90,4 +80,20 @@ if (fs.existsSync(pnpmYamlPath)) { | ||
| // legacy lerna(pre workspaces) support | ||
| // leran 7+ does not have "useWorkspaces" option | ||
| // if non-useWorkspaces and packages is defined, use it | ||
| const lernaJsonPath = path.join(rootDirectory, "lerna.json"); | ||
| // prefer to use yarn workspace instead of lerna.json | ||
| if (fs.existsSync(lernaJsonPath)) { | ||
| const lernaJson = loadJsonFile.sync(lernaJsonPath); | ||
| // useWorkspaces is removed in lerna 7 | ||
| const hasNotWorkspacesInLernaJson = (v: any): v is { packages: string[] } => { | ||
| return !("useWorkspaces" in v); | ||
| }; | ||
| if (hasNotWorkspacesInLernaJson(lernaJson) && lernaJson.packages) { | ||
| return findPackages(lernaJson.packages, rootDirectory); | ||
| } | ||
| } | ||
| // Bail if we don't find any packages | ||
| return []; | ||
| }; |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
226056
0.31%271
4.63%