workspace-tools 0.25.4 → 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 CHANGED
@@ -2,7 +2,44 @@
2
2
  "name": "workspace-tools",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 04 Aug 2022 08:01:45 GMT",
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",
6
43
  "tag": "workspace-tools_v0.25.4",
7
44
  "version": "0.25.4",
8
45
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,24 @@
1
1
  # Change Log - workspace-tools
2
2
 
3
- This log was last generated on Thu, 04 Aug 2022 08:01:45 GMT and should not be manually modified.
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
+
7
19
  ## 0.25.4
8
20
 
9
- Thu, 04 Aug 2022 08:01:45 GMT
21
+ Thu, 04 Aug 2022 08:01:48 GMT
10
22
 
11
23
  ### Patches
12
24
 
@@ -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.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(),
@@ -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;
@@ -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) {
@@ -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;
@@ -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.4",
3
+ "version": "0.26.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "@types/jest": "28.1.6",
38
38
  "@types/jju": "1.4.2",
39
39
  "@types/micromatch": "4.0.2",
40
- "@types/node": "13.13.5",
40
+ "@types/node": "14.18.23",
41
41
  "@types/tmp": "0.2.3",
42
42
  "@types/yarnpkg__lockfile": "1.1.5",
43
43
  "beachball": "2.26.0",