workspace-tools 0.25.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +90 -1
- package/CHANGELOG.md +31 -2
- package/lib/dependencies/index.d.ts +0 -2
- package/lib/dependencies/transitiveDeps.d.ts +0 -5
- package/lib/dependencies/transitiveDeps.js +0 -5
- package/lib/git/getDefaultRemote.js +1 -1
- package/lib/git/git.js +1 -1
- package/lib/graph/createPackageGraph.js +2 -2
- package/lib/graph/getPackageDependencies.js +5 -1
- package/lib/helpers/setupFixture.js +2 -2
- package/lib/infoFromPackageJson.js +4 -1
- package/lib/lockfile/index.js +1 -1
- package/lib/lockfile/parseNpmLock.d.ts +1 -1
- package/lib/lockfile/parseNpmLock.js +5 -12
- package/lib/paths.d.ts +1 -4
- package/lib/paths.js +5 -12
- package/lib/scope.d.ts +2 -4
- package/lib/scope.js +5 -7
- package/lib/workspaces/getPackagesByFiles.js +2 -2
- package/lib/workspaces/getWorkspacePackageInfo.js +5 -2
- package/lib/workspaces/implementations/lerna.js +1 -1
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +1 -1
- package/lib/workspaces/implementations/pnpm.js +1 -1
- package/lib/workspaces/implementations/rush.js +1 -1
- package/package.json +8 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,96 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 04 Aug 2022 21:47:41 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.26.0",
|
|
7
|
+
"version": "0.26.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"commit": "e74753a50e613d41f62c1e917ceafc2185791e2a",
|
|
14
|
+
"comment": "Use ES2019 output (compatible with Node 14)"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"none": [
|
|
18
|
+
{
|
|
19
|
+
"author": "elcraig@microsoft.com",
|
|
20
|
+
"package": "workspace-tools",
|
|
21
|
+
"commit": "286b02b981a5bc532560ee17433ef0501f9414ea",
|
|
22
|
+
"comment": "Use Node 14 in repo and types"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"author": "renovate@whitesourcesoftware.com",
|
|
26
|
+
"package": "workspace-tools",
|
|
27
|
+
"commit": "5cba374fac27ef530d5f80530d3b925577f7e193",
|
|
28
|
+
"comment": "Lock file maintenance"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"patch": [
|
|
32
|
+
{
|
|
33
|
+
"author": "boabdelm@microsoft.com",
|
|
34
|
+
"package": "workspace-tools",
|
|
35
|
+
"commit": "5577a58d537fe41ca2dd8f74ea243da700ca0840",
|
|
36
|
+
"comment": "Gracefully handle not having a package.json at git root"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"date": "Thu, 04 Aug 2022 08:01:48 GMT",
|
|
43
|
+
"tag": "workspace-tools_v0.25.4",
|
|
44
|
+
"version": "0.25.4",
|
|
45
|
+
"comments": {
|
|
46
|
+
"none": [
|
|
47
|
+
{
|
|
48
|
+
"author": "email not defined",
|
|
49
|
+
"package": "workspace-tools",
|
|
50
|
+
"commit": "32e204ebc47d7e619b6b16e6b34873e6b1c7a96f",
|
|
51
|
+
"comment": "Pin devDependency @types/micromatch to 4.0.2"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"patch": [
|
|
55
|
+
{
|
|
56
|
+
"author": "elcraig@microsoft.com",
|
|
57
|
+
"package": "workspace-tools",
|
|
58
|
+
"commit": "95ad5f346a1ce0c6e4c1b2d5bb173ceeac136aa2",
|
|
59
|
+
"comment": "Switch from multimatch to micromatch"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"date": "Wed, 03 Aug 2022 08:01:34 GMT",
|
|
66
|
+
"tag": "workspace-tools_v0.25.3",
|
|
67
|
+
"version": "0.25.3",
|
|
68
|
+
"comments": {
|
|
69
|
+
"none": [
|
|
70
|
+
{
|
|
71
|
+
"author": "renovate@whitesourcesoftware.com",
|
|
72
|
+
"package": "workspace-tools",
|
|
73
|
+
"commit": "c51bca9b331ae106b22ed260b5c045936dd3b723",
|
|
74
|
+
"comment": "Update devDependency gh-pages to v4"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"patch": [
|
|
78
|
+
{
|
|
79
|
+
"author": "elcraig@microsoft.com",
|
|
80
|
+
"package": "workspace-tools",
|
|
81
|
+
"commit": "ae076192e9010c32fc90a7cb2a6d1488d382cec6",
|
|
82
|
+
"comment": "Simplify createPackageGraph and getPackageDependencies"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"author": "elcraig@microsoft.com",
|
|
86
|
+
"package": "workspace-tools",
|
|
87
|
+
"commit": "f81a7c1f61ec402febbc1cc1927343dadefbcdd5",
|
|
88
|
+
"comment": "Update find-up to v5"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"date": "Tue, 02 Aug 2022 23:03:14 GMT",
|
|
6
95
|
"tag": "workspace-tools_v0.25.2",
|
|
7
96
|
"version": "0.25.2",
|
|
8
97
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 04 Aug 2022 21:47:41 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.26.0
|
|
8
|
+
|
|
9
|
+
Thu, 04 Aug 2022 21:47:41 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Use ES2019 output (compatible with Node 14) (elcraig@microsoft.com)
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Gracefully handle not having a package.json at git root (boabdelm@microsoft.com)
|
|
18
|
+
|
|
19
|
+
## 0.25.4
|
|
20
|
+
|
|
21
|
+
Thu, 04 Aug 2022 08:01:48 GMT
|
|
22
|
+
|
|
23
|
+
### Patches
|
|
24
|
+
|
|
25
|
+
- Switch from multimatch to micromatch (elcraig@microsoft.com)
|
|
26
|
+
|
|
27
|
+
## 0.25.3
|
|
28
|
+
|
|
29
|
+
Wed, 03 Aug 2022 08:01:34 GMT
|
|
30
|
+
|
|
31
|
+
### Patches
|
|
32
|
+
|
|
33
|
+
- Simplify createPackageGraph and getPackageDependencies (elcraig@microsoft.com)
|
|
34
|
+
- Update find-up to v5 (elcraig@microsoft.com)
|
|
35
|
+
|
|
7
36
|
## 0.25.2
|
|
8
37
|
|
|
9
|
-
Tue, 02 Aug 2022 23:03:
|
|
38
|
+
Tue, 02 Aug 2022 23:03:14 GMT
|
|
10
39
|
|
|
11
40
|
### Patches
|
|
12
41
|
|
|
@@ -2,11 +2,9 @@ import { getTransitiveConsumers, getTransitiveProviders } from "./transitiveDeps
|
|
|
2
2
|
import { getPackageDependencies } from "../graph/getPackageDependencies";
|
|
3
3
|
/** @deprecated Do not use */
|
|
4
4
|
export declare const getTransitiveDependencies: typeof getTransitiveProviders;
|
|
5
|
-
/** @deprecated Do not use */
|
|
6
5
|
export { getTransitiveProviders };
|
|
7
6
|
/** @deprecated Do not use */
|
|
8
7
|
export declare const getTransitiveDependents: typeof getTransitiveConsumers;
|
|
9
|
-
/** @deprecated Do not use */
|
|
10
8
|
export { getTransitiveConsumers };
|
|
11
9
|
/** @deprecated Do not use */
|
|
12
10
|
export declare const getInternalDeps: typeof getPackageDependencies;
|
|
@@ -4,16 +4,11 @@ export declare function getDependentMap(packages: PackageInfos): Map<string, Set
|
|
|
4
4
|
* @deprecated Do not use
|
|
5
5
|
*
|
|
6
6
|
* for a package graph of a->b->c (where b depends on a), transitive consumers of a are b & c and their consumers (or what are the consequences of a)
|
|
7
|
-
* @param targets
|
|
8
|
-
* @param packages
|
|
9
|
-
* @param scope
|
|
10
7
|
*/
|
|
11
8
|
export declare function getTransitiveConsumers(targets: string[], packages: PackageInfos, scope?: string[]): string[];
|
|
12
9
|
/**
|
|
13
10
|
* @deprecated Do not use
|
|
14
11
|
*
|
|
15
12
|
* for a package graph of a->b->c (where b depends on a), transitive providers of c are a & b and their providers (or what is needed to satisfy c)
|
|
16
|
-
* @param targets
|
|
17
|
-
* @param packages
|
|
18
13
|
*/
|
|
19
14
|
export declare function getTransitiveProviders(targets: string[], packages: PackageInfos): string[];
|
|
@@ -53,9 +53,6 @@ exports.getDependentMap = getDependentMap;
|
|
|
53
53
|
* @deprecated Do not use
|
|
54
54
|
*
|
|
55
55
|
* for a package graph of a->b->c (where b depends on a), transitive consumers of a are b & c and their consumers (or what are the consequences of a)
|
|
56
|
-
* @param targets
|
|
57
|
-
* @param packages
|
|
58
|
-
* @param scope
|
|
59
56
|
*/
|
|
60
57
|
function getTransitiveConsumers(targets, packages, scope = []) {
|
|
61
58
|
const graph = getPackageGraph(packages, scope);
|
|
@@ -79,8 +76,6 @@ exports.getTransitiveConsumers = getTransitiveConsumers;
|
|
|
79
76
|
* @deprecated Do not use
|
|
80
77
|
*
|
|
81
78
|
* for a package graph of a->b->c (where b depends on a), transitive providers of c are a & b and their providers (or what is needed to satisfy c)
|
|
82
|
-
* @param targets
|
|
83
|
-
* @param packages
|
|
84
79
|
*/
|
|
85
80
|
function getTransitiveProviders(targets, packages) {
|
|
86
81
|
const graph = getPackageGraph(packages);
|
|
@@ -26,7 +26,7 @@ function getDefaultRemote(cwdOrOptions) {
|
|
|
26
26
|
packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8").trim());
|
|
27
27
|
}
|
|
28
28
|
catch (e) {
|
|
29
|
-
|
|
29
|
+
logOrThrow(`Could not read "${packageJsonPath}"`);
|
|
30
30
|
}
|
|
31
31
|
const { repository } = packageJson;
|
|
32
32
|
const repositoryUrl = typeof repository === "string" ? repository : (repository && repository.url) || "";
|
package/lib/git/git.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.addGitObserver = addGitObserver;
|
|
|
37
37
|
* Runs git command - use this for read-only commands
|
|
38
38
|
*/
|
|
39
39
|
function git(args, options) {
|
|
40
|
-
const results = (0, child_process_1.spawnSync)("git", args,
|
|
40
|
+
const results = (0, child_process_1.spawnSync)("git", args, { maxBuffer: defaultMaxBuffer, ...options });
|
|
41
41
|
const output = {
|
|
42
42
|
stderr: results.stderr.toString().trimRight(),
|
|
43
43
|
stdout: results.stdout.toString().trimRight(),
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createPackageGraph = void 0;
|
|
7
7
|
const createDependencyMap_1 = require("./createDependencyMap");
|
|
8
|
-
const
|
|
8
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
9
9
|
function createPackageGraph(packages, filters) {
|
|
10
10
|
/** set of packages being accumulated as the graph is filtered */
|
|
11
11
|
const packageSet = new Set();
|
|
@@ -83,7 +83,7 @@ function visitPackageGraph(packages, dependencyMap, visitor, filter) {
|
|
|
83
83
|
var _a, _b;
|
|
84
84
|
const visited = new Set();
|
|
85
85
|
const packageNames = Object.keys(packages);
|
|
86
|
-
const stack = filter ? (0,
|
|
86
|
+
const stack = filter ? (0, micromatch_1.default)(packageNames, filter.namePatterns) : packageNames;
|
|
87
87
|
while (stack.length > 0) {
|
|
88
88
|
const pkg = stack.pop();
|
|
89
89
|
if (visited.has(pkg)) {
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPackageDependencies = void 0;
|
|
4
4
|
function getPackageDependencies(info, packages, options = { withDevDependencies: true }) {
|
|
5
|
-
const deps =
|
|
5
|
+
const deps = {
|
|
6
|
+
...info.dependencies,
|
|
7
|
+
...(options.withDevDependencies && info.devDependencies),
|
|
8
|
+
...(options.withPeerDependencies && info.peerDependencies),
|
|
9
|
+
};
|
|
6
10
|
return Object.keys(packages).filter((pkg) => !!deps[pkg]);
|
|
7
11
|
}
|
|
8
12
|
exports.getPackageDependencies = getPackageDependencies;
|
|
@@ -49,7 +49,7 @@ function setupFixture(fixtureName) {
|
|
|
49
49
|
(0, git_1.gitFailFast)(["config", "init.defaultBranch", "main"], { cwd });
|
|
50
50
|
// Copy and commit the fixture if requested
|
|
51
51
|
if (fixturePath) {
|
|
52
|
-
fs_extra_1.default.copySync(fixturePath, cwd);
|
|
52
|
+
fs_extra_1.default.copySync(fixturePath, cwd, { filter: (src) => !/[/\\](node_modules|temp|.rush)([/\\]|$)/.test(src) });
|
|
53
53
|
(0, git_1.stageAndCommit)(["."], "test", cwd);
|
|
54
54
|
}
|
|
55
55
|
return cwd;
|
|
@@ -72,7 +72,7 @@ function setupPackageJson(cwd, packageJson = {}) {
|
|
|
72
72
|
if (fs_extra_1.default.existsSync(pkgJsonPath)) {
|
|
73
73
|
oldPackageJson = JSON.parse(fs_extra_1.default.readFileSync(pkgJsonPath, "utf-8"));
|
|
74
74
|
}
|
|
75
|
-
fs_extra_1.default.writeFileSync(pkgJsonPath, JSON.stringify(
|
|
75
|
+
fs_extra_1.default.writeFileSync(pkgJsonPath, JSON.stringify({ ...oldPackageJson, ...packageJson }, null, 2));
|
|
76
76
|
}
|
|
77
77
|
exports.setupPackageJson = setupPackageJson;
|
|
78
78
|
function setupLocalRemote(cwd, remoteName, fixtureName) {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.infoFromPackageJson = void 0;
|
|
4
4
|
function infoFromPackageJson(packageJson, packageJsonPath) {
|
|
5
|
-
return
|
|
5
|
+
return {
|
|
6
|
+
packageJsonPath,
|
|
7
|
+
...packageJson,
|
|
8
|
+
};
|
|
6
9
|
}
|
|
7
10
|
exports.infoFromPackageJson = infoFromPackageJson;
|
package/lib/lockfile/index.js
CHANGED
|
@@ -69,7 +69,7 @@ async function parseLockFile(packageRoot) {
|
|
|
69
69
|
try {
|
|
70
70
|
npmLockJson = fs_1.default.readFileSync(npmLockPath, "utf-8");
|
|
71
71
|
}
|
|
72
|
-
catch
|
|
72
|
+
catch {
|
|
73
73
|
throw new Error("Couldn’t parse package-lock.json.");
|
|
74
74
|
}
|
|
75
75
|
const npmLock = JSON.parse(npmLockJson.toString());
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ParsedLock, NpmLockFile } from "./types";
|
|
2
|
-
export declare
|
|
2
|
+
export declare function parseNpmLock(lock: NpmLockFile): ParsedLock;
|
|
@@ -2,21 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseNpmLock = void 0;
|
|
4
4
|
const nameAtVersion_1 = require("./nameAtVersion");
|
|
5
|
-
|
|
6
|
-
* formatNpmLock reformats the dependencies object, so the key includes the version, similarly to yarn.lock. For
|
|
7
|
-
* example, `"@microsoft/task-scheduler": { }` will become `"@microsoft/task-scheduler@2.7.1": { }`.
|
|
8
|
-
*/
|
|
9
|
-
const formatNpmLock = (previousValue, currentValue) => {
|
|
10
|
-
const [key, dependency] = currentValue;
|
|
11
|
-
previousValue[(0, nameAtVersion_1.nameAtVersion)(key, dependency.version)] = dependency;
|
|
12
|
-
return previousValue;
|
|
13
|
-
};
|
|
14
|
-
const parseNpmLock = (lock) => {
|
|
5
|
+
function parseNpmLock(lock) {
|
|
15
6
|
var _a;
|
|
16
|
-
|
|
7
|
+
// Re-format the dependencies object so that the key includes the version, similarly to yarn.lock.
|
|
8
|
+
// For example, `"@microsoft/task-scheduler": { }` will become `"@microsoft/task-scheduler@2.7.1": { }`.
|
|
9
|
+
const dependencies = Object.fromEntries(Object.entries((_a = lock.dependencies) !== null && _a !== void 0 ? _a : {}).map(([key, dep]) => [(0, nameAtVersion_1.nameAtVersion)(key, dep.version), dep]));
|
|
17
10
|
return {
|
|
18
11
|
object: dependencies,
|
|
19
12
|
type: "success",
|
|
20
13
|
};
|
|
21
|
-
}
|
|
14
|
+
}
|
|
22
15
|
exports.parseNpmLock = parseNpmLock;
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
3
|
-
* @param pathName Path to look for
|
|
4
|
-
* @param cwd Directory to start from
|
|
5
|
-
* @param type If specified, look for only files or only directories. Otherwise accept either.
|
|
6
3
|
*/
|
|
7
|
-
export declare function searchUp(pathName: string, cwd: string
|
|
4
|
+
export declare function searchUp(pathName: string, cwd: string): string | null;
|
|
8
5
|
/**
|
|
9
6
|
* Starting from `cwd`, uses `git rev-parse --show-toplevel` to find the root of the git repo.
|
|
10
7
|
* Throws if `cwd` is not in a Git repository.
|
package/lib/paths.js
CHANGED
|
@@ -10,21 +10,14 @@ const getWorkspaceRoot_1 = require("./workspaces/getWorkspaceRoot");
|
|
|
10
10
|
const git_1 = require("./git");
|
|
11
11
|
/**
|
|
12
12
|
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
13
|
-
* @param pathName Path to look for
|
|
14
|
-
* @param cwd Directory to start from
|
|
15
|
-
* @param type If specified, look for only files or only directories. Otherwise accept either.
|
|
16
13
|
*/
|
|
17
|
-
function searchUp(pathName, cwd
|
|
14
|
+
function searchUp(pathName, cwd) {
|
|
18
15
|
const root = path_1.default.parse(cwd).root;
|
|
19
16
|
let found = false;
|
|
20
17
|
while (!found && cwd !== root) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!((type === "file" && isDir) || (type === "directory" && !isDir))) {
|
|
25
|
-
found = true;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
18
|
+
if (fs_1.default.existsSync(path_1.default.join(cwd, pathName))) {
|
|
19
|
+
found = true;
|
|
20
|
+
break;
|
|
28
21
|
}
|
|
29
22
|
cwd = path_1.default.dirname(cwd);
|
|
30
23
|
}
|
|
@@ -62,7 +55,7 @@ function findProjectRoot(cwd) {
|
|
|
62
55
|
try {
|
|
63
56
|
workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
|
|
64
57
|
}
|
|
65
|
-
catch
|
|
58
|
+
catch { }
|
|
66
59
|
return workspaceRoot || findGitRoot(cwd);
|
|
67
60
|
}
|
|
68
61
|
exports.findProjectRoot = findProjectRoot;
|
package/lib/scope.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Searches all package names based on "scoping" (i.e. "scope" in the sense of inclusion)
|
|
3
|
-
* NOTE:
|
|
4
|
-
* @param search
|
|
5
|
-
* @param packages
|
|
2
|
+
* Searches all package names based on "scoping" (i.e. "scope" in the sense of inclusion).
|
|
3
|
+
* NOTE: this is not the same as package scopes (`@scope/package`).
|
|
6
4
|
*/
|
|
7
5
|
export declare function getScopedPackages(search: string[], packages: {
|
|
8
6
|
[pkg: string]: unknown;
|
package/lib/scope.js
CHANGED
|
@@ -4,12 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getScopedPackages = void 0;
|
|
7
|
-
const
|
|
7
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
8
8
|
/**
|
|
9
|
-
* Searches all package names based on "scoping" (i.e. "scope" in the sense of inclusion)
|
|
10
|
-
* NOTE:
|
|
11
|
-
* @param search
|
|
12
|
-
* @param packages
|
|
9
|
+
* Searches all package names based on "scoping" (i.e. "scope" in the sense of inclusion).
|
|
10
|
+
* NOTE: this is not the same as package scopes (`@scope/package`).
|
|
13
11
|
*/
|
|
14
12
|
function getScopedPackages(search, packages) {
|
|
15
13
|
const packageNames = Array.isArray(packages) ? packages : Object.keys(packages);
|
|
@@ -17,7 +15,7 @@ function getScopedPackages(search, packages) {
|
|
|
17
15
|
// perform a package-scoped search (e.g. search is @scope/foo*)
|
|
18
16
|
const scopedSearch = search.filter((needle) => needle.startsWith("@") || needle.startsWith("!@"));
|
|
19
17
|
if (scopedSearch.length > 0) {
|
|
20
|
-
const matched = (0,
|
|
18
|
+
const matched = (0, micromatch_1.default)(packageNames, scopedSearch);
|
|
21
19
|
for (const pkg of matched) {
|
|
22
20
|
results.add(pkg);
|
|
23
21
|
}
|
|
@@ -27,7 +25,7 @@ function getScopedPackages(search, packages) {
|
|
|
27
25
|
if (unscopedSearch.length > 0) {
|
|
28
26
|
// only generate the bare package map if there ARE unscoped searches
|
|
29
27
|
const barePackageMap = generateBarePackageMap(packageNames);
|
|
30
|
-
let matched = (0,
|
|
28
|
+
let matched = (0, micromatch_1.default)(Object.keys(barePackageMap), unscopedSearch);
|
|
31
29
|
for (const bare of matched) {
|
|
32
30
|
for (const pkg of barePackageMap[bare]) {
|
|
33
31
|
results.add(pkg);
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPackagesByFiles = void 0;
|
|
7
|
-
const
|
|
7
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const getWorkspaces_1 = require("./getWorkspaces");
|
|
10
10
|
/**
|
|
@@ -18,7 +18,7 @@ const getWorkspaces_1 = require("./getWorkspaces");
|
|
|
18
18
|
*/
|
|
19
19
|
function getPackagesByFiles(workspaceRoot, files, ignoreGlobs = [], returnAllPackagesOnNoMatch = false) {
|
|
20
20
|
const workspaceInfo = (0, getWorkspaces_1.getWorkspaces)(workspaceRoot);
|
|
21
|
-
const ignoreSet = new Set((0,
|
|
21
|
+
const ignoreSet = new Set((0, micromatch_1.default)(files, ignoreGlobs));
|
|
22
22
|
files = files.filter((change) => !ignoreSet.has(change));
|
|
23
23
|
const packages = new Set();
|
|
24
24
|
for (const file of files) {
|
|
@@ -16,7 +16,7 @@ function getWorkspacePackageInfo(workspacePaths) {
|
|
|
16
16
|
try {
|
|
17
17
|
packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
|
|
18
18
|
}
|
|
19
|
-
catch
|
|
19
|
+
catch {
|
|
20
20
|
return returnValue;
|
|
21
21
|
}
|
|
22
22
|
return [
|
|
@@ -24,7 +24,10 @@ function getWorkspacePackageInfo(workspacePaths) {
|
|
|
24
24
|
{
|
|
25
25
|
name: packageJson.name,
|
|
26
26
|
path: workspacePath,
|
|
27
|
-
packageJson:
|
|
27
|
+
packageJson: {
|
|
28
|
+
...packageJson,
|
|
29
|
+
packageJsonPath,
|
|
30
|
+
},
|
|
28
31
|
},
|
|
29
32
|
];
|
|
30
33
|
}, []);
|
|
@@ -25,7 +25,7 @@ function getRushWorkspaces(cwd) {
|
|
|
25
25
|
const root = path_1.default.dirname(rushJsonPath);
|
|
26
26
|
return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(rushConfig.projects.map((project) => path_1.default.join(root, project.projectFolder)));
|
|
27
27
|
}
|
|
28
|
-
catch
|
|
28
|
+
catch {
|
|
29
29
|
return [];
|
|
30
30
|
}
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,29 +24,30 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
27
|
-
"find-up": "^
|
|
27
|
+
"find-up": "^5.0.0",
|
|
28
28
|
"git-url-parse": "^12.0.0",
|
|
29
29
|
"globby": "^11.0.0",
|
|
30
30
|
"jju": "^1.4.0",
|
|
31
|
-
"
|
|
31
|
+
"micromatch": "^4.0.0",
|
|
32
32
|
"read-yaml-file": "^2.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@types/fs-extra": "9.0.13",
|
|
35
36
|
"@types/git-url-parse": "9.0.1",
|
|
36
37
|
"@types/jest": "28.1.6",
|
|
37
38
|
"@types/jju": "1.4.2",
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/node": "
|
|
39
|
+
"@types/micromatch": "4.0.2",
|
|
40
|
+
"@types/node": "14.18.23",
|
|
40
41
|
"@types/tmp": "0.2.3",
|
|
41
42
|
"@types/yarnpkg__lockfile": "1.1.5",
|
|
42
43
|
"beachball": "2.26.0",
|
|
43
44
|
"fs-extra": "10.1.0",
|
|
45
|
+
"gh-pages": "3.2.3",
|
|
44
46
|
"jest": "28.1.3",
|
|
45
47
|
"prettier": "2.7.1",
|
|
46
48
|
"tmp": "0.2.1",
|
|
47
49
|
"ts-jest": "28.0.7",
|
|
48
50
|
"typedoc": "0.22.15",
|
|
49
|
-
"typescript": "4.5.4"
|
|
50
|
-
"gh-pages": "3.2.3"
|
|
51
|
+
"typescript": "4.5.4"
|
|
51
52
|
}
|
|
52
53
|
}
|