@metamask/action-utils
Advanced tools
Comparing version 0.0.2 to 1.0.0
@@ -90,4 +90,5 @@ export declare enum ManifestDependencyFieldNames { | ||
* @param rootDir - The monorepo root directory. | ||
* @param recursive - Whether to search recursively. | ||
* @returns The location of each workspace directory relative to the root directory | ||
*/ | ||
export declare function getWorkspaceLocations(workspaces: string[], rootDir: string): Promise<string[]>; | ||
export declare function getWorkspaceLocations(workspaces: string[], rootDir: string, recursive?: boolean, prefix?: string): Promise<string[]>; |
@@ -170,9 +170,32 @@ "use strict"; | ||
* @param rootDir - The monorepo root directory. | ||
* @param recursive - Whether to search recursively. | ||
* @returns The location of each workspace directory relative to the root directory | ||
*/ | ||
async function getWorkspaceLocations(workspaces, rootDir) { | ||
const resolvedWorkspaces = await Promise.all(workspaces.map((pattern) => glob(pattern, { cwd: rootDir }))); | ||
return resolvedWorkspaces.flat(); | ||
async function getWorkspaceLocations(workspaces, rootDir, recursive = false, prefix = '') { | ||
const resolvedWorkspaces = await workspaces.reduce(async (promise, pattern) => { | ||
const array = await promise; | ||
const matches = (await glob(pattern, { cwd: rootDir })).map((match) => path_1.default.join(prefix, match)); | ||
return [...array, ...matches]; | ||
}, Promise.resolve([])); | ||
if (recursive) { | ||
// This reads all the package JSON files in each workspace, checks if they are a monorepo, and | ||
// recursively calls `getWorkspaceLocations` if they are. | ||
const resolvedSubWorkspaces = await resolvedWorkspaces.reduce(async (promise, workspacePath) => { | ||
const array = await promise; | ||
const rawManifest = await getPackageManifest(workspacePath); | ||
if (ManifestFieldNames.Workspaces in rawManifest) { | ||
const manifest = validatePackageManifestVersion(rawManifest, workspacePath); | ||
const monorepoManifest = validateMonorepoPackageManifest(manifest, workspacePath); | ||
return [ | ||
...array, | ||
...(await getWorkspaceLocations(monorepoManifest[ManifestFieldNames.Workspaces], workspacePath, recursive, workspacePath)), | ||
]; | ||
} | ||
return array; | ||
}, Promise.resolve(resolvedWorkspaces)); | ||
return resolvedSubWorkspaces; | ||
} | ||
return resolvedWorkspaces; | ||
} | ||
exports.getWorkspaceLocations = getWorkspaceLocations; | ||
//# sourceMappingURL=package-utils.js.map |
{ | ||
"name": "@metamask/action-utils", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"description": "Utilities for MetaMask's GitHub Actions.", | ||
@@ -18,2 +18,6 @@ "publishConfig": { | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MetaMask/action-utils.git" | ||
}, | ||
"scripts": { | ||
@@ -38,6 +42,6 @@ "setup": "yarn install && yarn allow-scripts", | ||
"@lavamoat/allow-scripts": "^1.0.5", | ||
"@metamask/eslint-config": "^6.0.0", | ||
"@metamask/eslint-config-jest": "^6.0.0", | ||
"@metamask/eslint-config-nodejs": "^6.0.0", | ||
"@metamask/eslint-config-typescript": "^6.0.0", | ||
"@metamask/eslint-config": "^7.0.1", | ||
"@metamask/eslint-config-jest": "^7.0.0", | ||
"@metamask/eslint-config-nodejs": "^7.0.1", | ||
"@metamask/eslint-config-typescript": "^7.0.1", | ||
"@types/glob": "^7.1.3", | ||
@@ -44,0 +48,0 @@ "@types/jest": "^26.0.13", |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
49660
19
513
1
1
1