workspace-tools 0.25.3 → 0.26.1

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 CHANGED
@@ -2,7 +2,102 @@
2
2
  "name": "workspace-tools",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 03 Aug 2022 08:01:26 GMT",
5
+ "date": "Mon, 08 Aug 2022 22:43:58 GMT",
6
+ "tag": "workspace-tools_v0.26.1",
7
+ "version": "0.26.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "elcraig@microsoft.com",
12
+ "package": "workspace-tools",
13
+ "commit": "fa0d932a0a0ae63ebf16357b9a5ca42412405e95",
14
+ "comment": "Add missing type exports"
15
+ }
16
+ ],
17
+ "none": [
18
+ {
19
+ "author": "email not defined",
20
+ "package": "workspace-tools",
21
+ "commit": "05c206e967548245798da2f8b41ded7415e757e9",
22
+ "comment": "Update devDependency beachball to v2.26.1"
23
+ },
24
+ {
25
+ "author": "email not defined",
26
+ "package": "workspace-tools",
27
+ "commit": "9349737ca68eb1a10bc56c19911a08027fce9f48",
28
+ "comment": "Update devDependency gh-pages to v4"
29
+ },
30
+ {
31
+ "author": "email not defined",
32
+ "package": "workspace-tools",
33
+ "commit": "dbd019cf7c1cafb1b9a503461cc49acce936278f",
34
+ "comment": "Lock file maintenance"
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ {
40
+ "date": "Thu, 04 Aug 2022 21:47:46 GMT",
41
+ "tag": "workspace-tools_v0.26.0",
42
+ "version": "0.26.0",
43
+ "comments": {
44
+ "minor": [
45
+ {
46
+ "author": "elcraig@microsoft.com",
47
+ "package": "workspace-tools",
48
+ "commit": "e74753a50e613d41f62c1e917ceafc2185791e2a",
49
+ "comment": "Use ES2019 output (compatible with Node 14)"
50
+ }
51
+ ],
52
+ "none": [
53
+ {
54
+ "author": "elcraig@microsoft.com",
55
+ "package": "workspace-tools",
56
+ "commit": "286b02b981a5bc532560ee17433ef0501f9414ea",
57
+ "comment": "Use Node 14 in repo and types"
58
+ },
59
+ {
60
+ "author": "renovate@whitesourcesoftware.com",
61
+ "package": "workspace-tools",
62
+ "commit": "5cba374fac27ef530d5f80530d3b925577f7e193",
63
+ "comment": "Lock file maintenance"
64
+ }
65
+ ],
66
+ "patch": [
67
+ {
68
+ "author": "boabdelm@microsoft.com",
69
+ "package": "workspace-tools",
70
+ "commit": "5577a58d537fe41ca2dd8f74ea243da700ca0840",
71
+ "comment": "Gracefully handle not having a package.json at git root"
72
+ }
73
+ ]
74
+ }
75
+ },
76
+ {
77
+ "date": "Thu, 04 Aug 2022 08:01:48 GMT",
78
+ "tag": "workspace-tools_v0.25.4",
79
+ "version": "0.25.4",
80
+ "comments": {
81
+ "none": [
82
+ {
83
+ "author": "email not defined",
84
+ "package": "workspace-tools",
85
+ "commit": "32e204ebc47d7e619b6b16e6b34873e6b1c7a96f",
86
+ "comment": "Pin devDependency @types/micromatch to 4.0.2"
87
+ }
88
+ ],
89
+ "patch": [
90
+ {
91
+ "author": "elcraig@microsoft.com",
92
+ "package": "workspace-tools",
93
+ "commit": "95ad5f346a1ce0c6e4c1b2d5bb173ceeac136aa2",
94
+ "comment": "Switch from multimatch to micromatch"
95
+ }
96
+ ]
97
+ }
98
+ },
99
+ {
100
+ "date": "Wed, 03 Aug 2022 08:01:34 GMT",
6
101
  "tag": "workspace-tools_v0.25.3",
7
102
  "version": "0.25.3",
8
103
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,40 @@
1
1
  # Change Log - workspace-tools
2
2
 
3
- This log was last generated on Wed, 03 Aug 2022 08:01:26 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 08 Aug 2022 22:43:58 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.26.1
8
+
9
+ Mon, 08 Aug 2022 22:43:58 GMT
10
+
11
+ ### Patches
12
+
13
+ - Add missing type exports (elcraig@microsoft.com)
14
+
15
+ ## 0.26.0
16
+
17
+ Thu, 04 Aug 2022 21:47:46 GMT
18
+
19
+ ### Minor changes
20
+
21
+ - Use ES2019 output (compatible with Node 14) (elcraig@microsoft.com)
22
+
23
+ ### Patches
24
+
25
+ - Gracefully handle not having a package.json at git root (boabdelm@microsoft.com)
26
+
27
+ ## 0.25.4
28
+
29
+ Thu, 04 Aug 2022 08:01:48 GMT
30
+
31
+ ### Patches
32
+
33
+ - Switch from multimatch to micromatch (elcraig@microsoft.com)
34
+
7
35
  ## 0.25.3
8
36
 
9
- Wed, 03 Aug 2022 08:01:26 GMT
37
+ Wed, 03 Aug 2022 08:01:34 GMT
10
38
 
11
39
  ### Patches
12
40
 
@@ -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
- throw new Error(`Could not read "${packageJsonPath}"`);
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.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare type GitProcessOutput = {
10
10
  success: boolean;
11
11
  };
12
12
  /** Observes the git operations called from `git()` or `gitFailFast()` */
13
- declare type GitObserver = (args: string[], output: GitProcessOutput) => void;
13
+ export declare type GitObserver = (args: string[], output: GitProcessOutput) => void;
14
14
  /**
15
15
  * Adds an observer for the git operations, e.g. for testing
16
16
  * @param observer
@@ -26,4 +26,3 @@ export declare function git(args: string[], options?: SpawnSyncOptions): GitProc
26
26
  export declare function gitFailFast(args: string[], options?: SpawnSyncOptions & {
27
27
  noExitCode?: boolean;
28
28
  }): void;
29
- export {};
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, Object.assign({ maxBuffer: defaultMaxBuffer }, options));
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 multimatch_1 = __importDefault(require("multimatch"));
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, multimatch_1.default)(packageNames, filter.namePatterns) : packageNames;
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 = Object.assign(Object.assign(Object.assign({}, info.dependencies), (options.withDevDependencies && info.devDependencies)), (options.withPeerDependencies && info.peerDependencies));
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(Object.assign(Object.assign({}, oldPackageJson), packageJson), null, 2));
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) {
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./graph/index";
5
5
  export * from "./lockfile";
6
6
  export * from "./paths";
7
7
  export * from "./scope";
8
+ export * from "./types/PackageGraph";
8
9
  export * from "./types/PackageInfo";
9
10
  export * from "./types/WorkspaceInfo";
10
11
  export * from "./workspaces/findWorkspacePath";
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ __exportStar(require("./graph/index"), exports);
17
17
  __exportStar(require("./lockfile"), exports);
18
18
  __exportStar(require("./paths"), exports);
19
19
  __exportStar(require("./scope"), exports);
20
+ __exportStar(require("./types/PackageGraph"), exports);
20
21
  __exportStar(require("./types/PackageInfo"), exports);
21
22
  __exportStar(require("./types/WorkspaceInfo"), exports);
22
23
  __exportStar(require("./workspaces/findWorkspacePath"), exports);
@@ -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 Object.assign({ packageJsonPath }, packageJson);
5
+ return {
6
+ packageJsonPath,
7
+ ...packageJson,
8
+ };
6
9
  }
7
10
  exports.infoFromPackageJson = infoFromPackageJson;
@@ -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 (_a) {
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 const parseNpmLock: (lock: NpmLockFile) => ParsedLock;
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
- const dependencies = Object.entries((_a = lock.dependencies) !== null && _a !== void 0 ? _a : {}).reduce(formatNpmLock, {});
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.js CHANGED
@@ -55,7 +55,7 @@ function findProjectRoot(cwd) {
55
55
  try {
56
56
  workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
57
57
  }
58
- catch (_a) { }
58
+ catch { }
59
59
  return workspaceRoot || findGitRoot(cwd);
60
60
  }
61
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: scoping is different than package scopes (@scope/package)
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 multimatch_1 = __importDefault(require("multimatch"));
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: scoping is different than package scopes (@scope/package)
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, multimatch_1.default)(packageNames, scopedSearch);
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, multimatch_1.default)(Object.keys(barePackageMap), unscopedSearch);
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);
@@ -8,7 +8,3 @@ export interface PackageGraph {
8
8
  packages: string[];
9
9
  dependencies: PackageDependency[];
10
10
  }
11
- /** Package graph visitor is called as it visits every package in dependency order */
12
- export interface PackageGraphVisitor {
13
- (pkg: string, dependencies: string[], dependents: string[]): void;
14
- }
@@ -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 multimatch_1 = __importDefault(require("multimatch"));
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, multimatch_1.default)(files, ignoreGlobs));
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 (_a) {
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: Object.assign(Object.assign({}, packageJson), { packageJsonPath }),
27
+ packageJson: {
28
+ ...packageJson,
29
+ packageJsonPath,
30
+ },
28
31
  },
29
32
  ];
30
33
  }, []);
@@ -27,7 +27,7 @@ function getLernaWorkspaces(cwd) {
27
27
  const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
28
28
  return workspaceInfo;
29
29
  }
30
- catch (_a) {
30
+ catch {
31
31
  return [];
32
32
  }
33
33
  }
@@ -44,7 +44,7 @@ function getWorkspaceInfoFromWorkspaceRoot(packageJsonWorkspacesRoot) {
44
44
  const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
45
45
  return workspaceInfo;
46
46
  }
47
- catch (_a) {
47
+ catch {
48
48
  return [];
49
49
  }
50
50
  }
@@ -26,7 +26,7 @@ function getPnpmWorkspaces(cwd) {
26
26
  const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths);
27
27
  return workspaceInfo;
28
28
  }
29
- catch (_a) {
29
+ catch {
30
30
  return [];
31
31
  }
32
32
  }
@@ -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 (_a) {
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.25.3",
3
+ "version": "0.26.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "scripts": {
15
15
  "build": "tsc",
16
16
  "build:docs": "typedoc src/index.ts",
17
- "release:docs": "typedoc src/index.ts && gh-pages -d docs",
17
+ "release:docs": "yarn build:docs && gh-pages -d docs",
18
18
  "change": "beachball change",
19
19
  "checkchange": "beachball check",
20
20
  "format": "prettier --write .",
@@ -28,25 +28,26 @@
28
28
  "git-url-parse": "^12.0.0",
29
29
  "globby": "^11.0.0",
30
30
  "jju": "^1.4.0",
31
- "multimatch": "^4.0.0",
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/multimatch": "4.0.0",
39
- "@types/node": "13.13.5",
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
- "beachball": "2.26.0",
43
+ "beachball": "2.26.1",
43
44
  "fs-extra": "10.1.0",
45
+ "gh-pages": "4.0.0",
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": "4.0.0"
51
+ "typescript": "4.5.4"
51
52
  }
52
53
  }