workspace-tools
Advanced tools
Comparing version 0.18.0 to 0.18.1
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Fri, 07 Jan 2022 00:04:25 GMT", | ||
"date": "Fri, 07 Jan 2022 17:07:14 GMT", | ||
"tag": "workspace-tools_v0.18.1", | ||
"version": "0.18.1", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"author": "kchau@microsoft.com", | ||
"package": "workspace-tools", | ||
"comment": "bump ts to 4.5 and fixed typing issues with caught errors as unknown", | ||
"commit": "253384a2c94b5bf41189c6a2b4e5d4478daeaa5e" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Fri, 07 Jan 2022 00:04:32 GMT", | ||
"tag": "workspace-tools_v0.18.0", | ||
@@ -8,0 +23,0 @@ "version": "0.18.0", |
# Change Log - workspace-tools | ||
This log was last generated on Fri, 07 Jan 2022 00:04:25 GMT and should not be manually modified. | ||
This log was last generated on Fri, 07 Jan 2022 17:07:14 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.18.1 | ||
Fri, 07 Jan 2022 17:07:14 GMT | ||
### Patches | ||
- bump ts to 4.5 and fixed typing issues with caught errors as unknown (kchau@microsoft.com) | ||
## 0.18.0 | ||
Fri, 07 Jan 2022 00:04:25 GMT | ||
Fri, 07 Jan 2022 00:04:32 GMT | ||
@@ -11,0 +19,0 @@ ### Minor changes |
@@ -11,3 +11,3 @@ "use strict"; | ||
}; | ||
const actual = dependencies_1.getTransitiveConsumers(["c"], allPackages); | ||
const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages); | ||
expect(actual).toContain("a"); | ||
@@ -25,3 +25,3 @@ expect(actual).toContain("b"); | ||
}; | ||
const actual = dependencies_1.getTransitiveConsumers(["core"], allPackages, [ | ||
const actual = (0, dependencies_1.getTransitiveConsumers)(["core"], allPackages, [ | ||
"grid", | ||
@@ -56,3 +56,3 @@ "word", | ||
}; | ||
const actual = dependencies_1.getTransitiveConsumers(["c"], allPackages); | ||
const actual = (0, dependencies_1.getTransitiveConsumers)(["c"], allPackages); | ||
expect(actual).toContain("a"); | ||
@@ -74,3 +74,3 @@ expect(actual).toContain("b"); | ||
}; | ||
const actual = dependencies_1.getTransitiveProviders(["a"], allPackages); | ||
const actual = (0, dependencies_1.getTransitiveProviders)(["a"], allPackages); | ||
expect(actual).toContain("b"); | ||
@@ -99,3 +99,3 @@ expect(actual).toContain("c"); | ||
}; | ||
const actual = dependencies_1.getTransitiveProviders(["c"], allPackages); | ||
const actual = (0, dependencies_1.getTransitiveProviders)(["c"], allPackages); | ||
expect(actual).toContain("e"); | ||
@@ -131,3 +131,3 @@ expect(actual).toContain("f"); | ||
}; | ||
const actual = dependencies_1.getTransitiveConsumers(["f"], allPackages, ["b"]); | ||
const actual = (0, dependencies_1.getTransitiveConsumers)(["f"], allPackages, ["b"]); | ||
expect(actual).toContain("e"); | ||
@@ -134,0 +134,0 @@ expect(actual).toContain("c"); |
@@ -13,11 +13,11 @@ "use strict"; | ||
afterAll(() => { | ||
setupFixture_1.cleanupFixtures(); | ||
(0, setupFixture_1.cleanupFixtures)(); | ||
}); | ||
it("can detect changes inside an untracked file", () => { | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -28,7 +28,7 @@ expect(changedPkgs).toContain("package-a"); | ||
// arrange | ||
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo"); | ||
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -39,7 +39,7 @@ expect(changedPkgs).toEqual(["package-a"]); | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/src/index.ts"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -50,7 +50,7 @@ expect(changedPkgs).toContain("package-a"); | ||
// arrange | ||
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo"); | ||
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/src/index.ts"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -61,8 +61,8 @@ expect(changedPkgs).toEqual(["package-a"]); | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["add", newFile], { cwd: root }); | ||
(0, git_1.git)(["add", newFile], { cwd: root }); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -73,8 +73,8 @@ expect(changedPkgs).toContain("package-a"); | ||
// arrange | ||
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo"); | ||
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["add", newFile], { cwd: root }); | ||
(0, git_1.git)(["add", newFile], { cwd: root }); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -85,9 +85,9 @@ expect(changedPkgs).toEqual(["package-a"]); | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["checkout", "-b", "newbranch"], { cwd: root }); | ||
git_1.stageAndCommit(["add", newFile], "test commit", root); | ||
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root }); | ||
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -98,9 +98,9 @@ expect(changedPkgs).toContain("package-a"); | ||
// arrange | ||
const root = path_1.default.join(setupFixture_1.setupFixture("monorepo-nested"), "monorepo"); | ||
const root = path_1.default.join((0, setupFixture_1.setupFixture)("monorepo-nested"), "monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["checkout", "-b", "newbranch"], { cwd: root }); | ||
git_1.stageAndCommit(["add", newFile], "test commit", root); | ||
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root }); | ||
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main"); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main"); | ||
// assert | ||
@@ -111,10 +111,10 @@ expect(changedPkgs).toEqual(["package-a"]); | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
setupFixture_1.setupLocalRemote(root, "origin", "basic"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
(0, setupFixture_1.setupLocalRemote)(root, "origin", "basic"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["checkout", "-b", "newbranch"], { cwd: root }); | ||
git_1.stageAndCommit(["add", newFile], "test commit", root); | ||
(0, git_1.git)(["checkout", "-b", "newbranch"], { cwd: root }); | ||
(0, git_1.stageAndCommit)(["add", newFile], "test commit", root); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, undefined); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, undefined); | ||
// assert | ||
@@ -125,8 +125,8 @@ expect(changedPkgs).toContain("package-a"); | ||
// arrange | ||
const root = setupFixture_1.setupFixture("monorepo"); | ||
const root = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const newFile = path_1.default.join(root, "packages/package-a/footest.txt"); | ||
fs_1.default.writeFileSync(newFile, "hello foo test"); | ||
git_1.git(["add", newFile], { cwd: root }); | ||
(0, git_1.git)(["add", newFile], { cwd: root }); | ||
// act | ||
const changedPkgs = getChangedPackages_1.getChangedPackages(root, "main", ["packages/package-a/*"]); | ||
const changedPkgs = (0, getChangedPackages_1.getChangedPackages)(root, "main", ["packages/package-a/*"]); | ||
// assert | ||
@@ -133,0 +133,0 @@ expect(changedPkgs).toEqual([]); |
@@ -7,9 +7,9 @@ "use strict"; | ||
afterAll(() => { | ||
setupFixture_1.cleanupFixtures(); | ||
(0, setupFixture_1.cleanupFixtures)(); | ||
}); | ||
it("is origin in the default test repo", () => { | ||
// arrange | ||
const cwd = setupFixture_1.setupFixture("basic"); | ||
const cwd = (0, setupFixture_1.setupFixture)("basic"); | ||
// act | ||
const remote = git_1.getDefaultRemote(cwd); | ||
const remote = (0, git_1.getDefaultRemote)(cwd); | ||
// assert | ||
@@ -20,6 +20,6 @@ expect(remote).toBe("origin"); | ||
// arrange | ||
const cwd = setupFixture_1.setupFixture("basic"); | ||
setupFixture_1.setupLocalRemote(cwd, "myRemote", "basic"); | ||
const cwd = (0, setupFixture_1.setupFixture)("basic"); | ||
(0, setupFixture_1.setupLocalRemote)(cwd, "myRemote", "basic"); | ||
// act | ||
const remote = git_1.getDefaultRemote(cwd); | ||
const remote = (0, git_1.getDefaultRemote)(cwd); | ||
// assert | ||
@@ -26,0 +26,0 @@ expect(remote).toBe("myRemote"); |
@@ -7,9 +7,9 @@ "use strict"; | ||
afterAll(() => { | ||
setupFixture_1.cleanupFixtures(); | ||
(0, setupFixture_1.cleanupFixtures)(); | ||
}); | ||
it("is main in the default test repo", () => { | ||
// arrange | ||
const cwd = setupFixture_1.setupFixture("basic"); | ||
const cwd = (0, setupFixture_1.setupFixture)("basic"); | ||
// act | ||
const branch = git_1.getDefaultBranch(cwd); | ||
const branch = (0, git_1.getDefaultBranch)(cwd); | ||
// assert | ||
@@ -20,6 +20,6 @@ expect(branch).toBe("main"); | ||
// arrange | ||
const cwd = setupFixture_1.setupFixture("basic"); | ||
git_1.git(['config', 'init.defaultBranch', 'myMain'], { cwd }); | ||
const cwd = (0, setupFixture_1.setupFixture)("basic"); | ||
(0, git_1.git)(['config', 'init.defaultBranch', 'myMain'], { cwd }); | ||
// act | ||
const branch = git_1.getDefaultBranch(cwd); | ||
const branch = (0, git_1.getDefaultBranch)(cwd); | ||
// assert | ||
@@ -26,0 +26,0 @@ expect(branch).toBe("myMain"); |
@@ -6,3 +6,3 @@ "use strict"; | ||
it("can match scopes for full matches for an array", () => { | ||
const results = scope_1.getScopedPackages(["foo", "bar"], ["foo", "bar", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], ["foo", "bar", "baz"]); | ||
expect(results).toContain("foo"); | ||
@@ -13,3 +13,3 @@ expect(results).toContain("bar"); | ||
it("can match scopes for full matches for a map", () => { | ||
const results = scope_1.getScopedPackages(["foo", "bar"], { | ||
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], { | ||
foo: {}, | ||
@@ -24,3 +24,3 @@ bar: {}, | ||
it("can match scopes for full matches for a map of PackageInfos", () => { | ||
const results = scope_1.getScopedPackages(["foo", "bar"], { | ||
const results = (0, scope_1.getScopedPackages)(["foo", "bar"], { | ||
foo: { name: "foo", packageJsonPath: "nowhere", version: "1.0.0" }, | ||
@@ -35,3 +35,3 @@ bar: { name: "bar", packageJsonPath: "nowhere", version: "1.0.0" }, | ||
it("can match with wildcards", () => { | ||
const results = scope_1.getScopedPackages(["foo*"], ["foo1", "foo2", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["foo*"], ["foo1", "foo2", "baz"]); | ||
expect(results).toContain("foo1"); | ||
@@ -42,3 +42,3 @@ expect(results).toContain("foo2"); | ||
it("can match with npm package scopes", () => { | ||
const results = scope_1.getScopedPackages(["foo"], ["@yay/foo", "@yay1/foo", "foo", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["foo"], ["@yay/foo", "@yay1/foo", "foo", "baz"]); | ||
expect(results).toContain("@yay/foo"); | ||
@@ -50,3 +50,3 @@ expect(results).toContain("@yay1/foo"); | ||
it("can match with npm package scopes with wildcards", () => { | ||
const results = scope_1.getScopedPackages(["foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]); | ||
expect(results).toContain("@yay/foo1"); | ||
@@ -58,3 +58,3 @@ expect(results).toContain("@yay1/foo2"); | ||
it("uses the correct package scope when the search pattern starts a @ character", () => { | ||
const results = scope_1.getScopedPackages(["@yay/foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["@yay/foo*"], ["@yay/foo1", "@yay1/foo2", "foo", "baz"]); | ||
expect(results).toContain("@yay/foo1"); | ||
@@ -66,3 +66,3 @@ expect(results).not.toContain("@yay1/foo2"); | ||
it("can deal with brace expansion with scopes", () => { | ||
const results = scope_1.getScopedPackages(["@yay/foo{1,2}"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["@yay/foo{1,2}"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]); | ||
expect(results).toContain("@yay/foo1"); | ||
@@ -75,3 +75,3 @@ expect(results).toContain("@yay/foo2"); | ||
it("can deal with negated search", () => { | ||
const results = scope_1.getScopedPackages(["@yay/foo*", "!@yay/foo3"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]); | ||
const results = (0, scope_1.getScopedPackages)(["@yay/foo*", "!@yay/foo3"], ["@yay/foo1", "@yay/foo2", "@yay/foo3", "foo", "baz"]); | ||
expect(results).toContain("@yay/foo1"); | ||
@@ -78,0 +78,0 @@ expect(results).toContain("@yay/foo2"); |
@@ -11,22 +11,22 @@ "use strict"; | ||
afterAll(() => { | ||
setupFixture_1.cleanupFixtures(); | ||
(0, setupFixture_1.cleanupFixtures)(); | ||
}); | ||
it("handles yarn workspace", () => { | ||
const repoRoot = setupFixture_1.setupFixture("monorepo"); | ||
const workspaceRoot = yarn_1.getYarnWorkspaceRoot(repoRoot); | ||
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const workspaceRoot = (0, yarn_1.getYarnWorkspaceRoot)(repoRoot); | ||
expect(workspaceRoot).toBe(repoRoot); | ||
}); | ||
it("handles pnpm workspace", () => { | ||
const repoRoot = setupFixture_1.setupFixture("monorepo-pnpm"); | ||
const workspaceRoot = pnpm_1.getPnpmWorkspaceRoot(repoRoot); | ||
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm"); | ||
const workspaceRoot = (0, pnpm_1.getPnpmWorkspaceRoot)(repoRoot); | ||
expect(workspaceRoot).toBe(repoRoot); | ||
}); | ||
it("handles rush workspace", () => { | ||
const repoRoot = setupFixture_1.setupFixture("monorepo-rush-pnpm"); | ||
const workspaceRoot = rush_1.getRushWorkspaceRoot(repoRoot); | ||
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm"); | ||
const workspaceRoot = (0, rush_1.getRushWorkspaceRoot)(repoRoot); | ||
expect(workspaceRoot).toBe(repoRoot); | ||
}); | ||
it("handles npm workspace", () => { | ||
const repoRoot = setupFixture_1.setupFixture("monorepo-npm"); | ||
const workspaceRoot = npm_1.getNpmWorkspaceRoot(repoRoot); | ||
const repoRoot = (0, setupFixture_1.setupFixture)("monorepo-npm"); | ||
const workspaceRoot = (0, npm_1.getNpmWorkspaceRoot)(repoRoot); | ||
expect(workspaceRoot).toBe(repoRoot); | ||
@@ -37,6 +37,6 @@ }); | ||
it("gets the root of the workspace", async () => { | ||
const repoRoot = await setupFixture_1.setupFixture("monorepo-lerna-npm"); | ||
const workspaceRoot = lerna_1.getLernaWorkspaceRoot(repoRoot); | ||
const repoRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm"); | ||
const workspaceRoot = (0, lerna_1.getLernaWorkspaceRoot)(repoRoot); | ||
expect(workspaceRoot).toBe(repoRoot); | ||
}); | ||
}); |
@@ -15,8 +15,8 @@ "use strict"; | ||
afterAll(() => { | ||
setupFixture_1.cleanupFixtures(); | ||
(0, setupFixture_1.cleanupFixtures)(); | ||
}); | ||
describe("yarn", () => { | ||
it("gets the name and path of the workspaces", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo"); | ||
const workspacesPackageInfo = yarn_1.getYarnWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo"); | ||
const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -30,4 +30,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces against a packages spec of an individual package", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo-globby"); | ||
const workspacesPackageInfo = yarn_1.getYarnWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-globby"); | ||
const workspacesPackageInfo = (0, yarn_1.getYarnWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -45,4 +45,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo-pnpm"); | ||
const workspacesPackageInfo = pnpm_1.getPnpmWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-pnpm"); | ||
const workspacesPackageInfo = (0, pnpm_1.getPnpmWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -58,4 +58,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo-rush-pnpm"); | ||
const workspacesPackageInfo = rush_1.getRushWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-rush-pnpm"); | ||
const workspacesPackageInfo = (0, rush_1.getRushWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -71,4 +71,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo-npm"); | ||
const workspacesPackageInfo = npm_1.getNpmWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-npm"); | ||
const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -82,4 +82,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces using the shorthand configuration", () => { | ||
const packageRoot = setupFixture_1.setupFixture("monorepo-shorthand"); | ||
const workspacesPackageInfo = npm_1.getNpmWorkspaces(packageRoot); | ||
const packageRoot = (0, setupFixture_1.setupFixture)("monorepo-shorthand"); | ||
const workspacesPackageInfo = (0, npm_1.getNpmWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -97,4 +97,4 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); | ||
it("gets the name and path of the workspaces", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("monorepo-lerna-npm"); | ||
const workspacesPackageInfo = lerna_1.getLernaWorkspaces(packageRoot); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-lerna-npm"); | ||
const workspacesPackageInfo = (0, lerna_1.getLernaWorkspaces)(packageRoot); | ||
const packageAPath = path_1.default.join(packageRoot, "packages", "package-a"); | ||
@@ -101,0 +101,0 @@ const packageBPath = path_1.default.join(packageRoot, "packages", "package-b"); |
@@ -12,24 +12,24 @@ "use strict"; | ||
it("throws if it cannot find lock file", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("basic-without-lock-file"); | ||
await expect(lockfile_1.parseLockFile(packageRoot)).rejects.toThrow(ERROR_MESSAGES.NO_LOCK); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-without-lock-file"); | ||
await expect((0, lockfile_1.parseLockFile)(packageRoot)).rejects.toThrow(ERROR_MESSAGES.NO_LOCK); | ||
}); | ||
// NPM | ||
it("parses package-lock.json file when it is found", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("monorepo-npm"); | ||
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-npm"); | ||
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot); | ||
expect(parsedLockeFile).toHaveProperty("type", "success"); | ||
}); | ||
it("throws if npm version is unsupported", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("monorepo-npm-unsupported"); | ||
await expect(lockfile_1.parseLockFile(packageRoot)).rejects.toThrow(ERROR_MESSAGES.UNSUPPORTED); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("monorepo-npm-unsupported"); | ||
await expect((0, lockfile_1.parseLockFile)(packageRoot)).rejects.toThrow(ERROR_MESSAGES.UNSUPPORTED); | ||
}); | ||
// Yarn | ||
it("parses yarn.lock file when it is found", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("basic"); | ||
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("basic"); | ||
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot); | ||
expect(parsedLockeFile).toHaveProperty("type", "success"); | ||
}); | ||
it("parses combined ranges in yarn.lock", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("basic-yarn"); | ||
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-yarn"); | ||
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot); | ||
expect(parsedLockeFile.object["@babel/code-frame@^7.0.0"].version).toBe(parsedLockeFile.object["@babel/code-frame@^7.8.3"].version); | ||
@@ -39,6 +39,6 @@ }); | ||
it("parses pnpm-lock.yaml file when it is found", async () => { | ||
const packageRoot = await setupFixture_1.setupFixture("basic-pnpm"); | ||
const parsedLockeFile = await lockfile_1.parseLockFile(packageRoot); | ||
const packageRoot = await (0, setupFixture_1.setupFixture)("basic-pnpm"); | ||
const parsedLockeFile = await (0, lockfile_1.parseLockFile)(packageRoot); | ||
expect(Object.keys(parsedLockeFile.object["yargs@16.2.0"].dependencies)).toContain("cliui"); | ||
}); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getInternalDeps = exports.getTransitiveDependents = exports.getTransitiveDependencies = exports.getTransitiveProviders = exports.getTransitiveConsumers = exports.getDependentMap = void 0; | ||
const graphCache = new Map(); | ||
@@ -4,0 +5,0 @@ function memoizedKey(packages, scope = []) { |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPackageInfos = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -11,3 +12,3 @@ const infoFromPackageJson_1 = require("./infoFromPackageJson"); | ||
function getPackageInfos(cwd) { | ||
const packageJsonFiles = workspaces_1.getAllPackageJsonFiles(cwd); | ||
const packageJsonFiles = (0, workspaces_1.getAllPackageJsonFiles)(cwd); | ||
const packageInfos = {}; | ||
@@ -18,7 +19,12 @@ if (packageJsonFiles && packageJsonFiles.length > 0) { | ||
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8")); | ||
packageInfos[packageJson.name] = infoFromPackageJson_1.infoFromPackageJson(packageJson, packageJsonPath); | ||
packageInfos[packageJson.name] = (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath); | ||
} | ||
catch (e) { | ||
// Pass, the package.json is invalid | ||
throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${e.message}`); | ||
if (e instanceof Error) { | ||
// Pass, the package.json is invalid | ||
throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${e.message}`); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
@@ -25,0 +31,0 @@ }); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPackagePaths = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -8,0 +9,0 @@ const globby_1 = __importDefault(require("globby")); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listAllTrackedFiles = exports.getDefaultRemote = exports.getDefaultBranch = exports.getDefaultRemoteBranch = exports.parseRemoteBranch = exports.getRemoteBranch = exports.getParentBranch = exports.revertLocalChanges = exports.stageAndCommit = exports.commit = exports.stage = exports.init = exports.getFileAddedHash = exports.getCurrentHash = exports.getShortBranchName = exports.getFullBranchRef = exports.getBranchName = exports.getUserEmail = exports.getRecentCommitMessages = exports.getStagedChanges = exports.getChangesBetweenRefs = exports.getBranchChanges = exports.getChanges = exports.getUnstagedChanges = exports.fetchRemoteBranch = exports.fetchRemote = exports.getUntrackedChanges = exports.gitFailFast = exports.git = exports.addGitObserver = void 0; | ||
const child_process_1 = require("child_process"); | ||
@@ -12,2 +13,8 @@ const fs_1 = __importDefault(require("fs")); | ||
const git_url_parse_1 = __importDefault(require("git-url-parse")); | ||
function gitError(message, e) { | ||
if (e && e instanceof Error) { | ||
return new Error(`${message}: ${e.message}`); | ||
} | ||
return new Error(message); | ||
} | ||
/** | ||
@@ -33,3 +40,3 @@ * A maxBuffer override globally for all git operations | ||
function git(args, options) { | ||
const results = child_process_1.spawnSync("git", args, Object.assign({ maxBuffer: MaxBufferOption }, options)); | ||
const results = (0, child_process_1.spawnSync)("git", args, Object.assign({ maxBuffer: MaxBufferOption }, options)); | ||
let output; | ||
@@ -68,5 +75,5 @@ if (results.status === 0) { | ||
process.exitCode = 1; | ||
throw new Error(`CRITICAL ERROR: running git command: git ${args.join(" ")}! | ||
${gitResult.stdout && gitResult.stdout.toString().trimRight()} | ||
${gitResult.stderr && gitResult.stderr.toString().trimRight()}`); | ||
throw gitError(`CRITICAL ERROR: running git command: git ${args.join(" ")}! | ||
${gitResult.stdout && gitResult.stdout.toString().trimRight()} | ||
${gitResult.stderr && gitResult.stderr.toString().trimRight()}`); | ||
} | ||
@@ -99,3 +106,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about untracked changes: ${e.message}`); | ||
throw gitError(`Cannot gather information about untracked changes`, e); | ||
} | ||
@@ -107,3 +114,3 @@ } | ||
if (!results.success) { | ||
throw new Error(`Cannot fetch remote: ${remote}`); | ||
throw gitError(`Cannot fetch remote: ${remote}`); | ||
} | ||
@@ -115,3 +122,3 @@ } | ||
if (!results.success) { | ||
throw new Error(`Cannot fetch remote: ${remote} ${remoteBranch}`); | ||
throw gitError(`Cannot fetch remote: ${remote} ${remoteBranch}`); | ||
} | ||
@@ -129,3 +136,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about unstaged changes: ${e.message}`); | ||
throw gitError(`Cannot gather information about unstaged changes`, e); | ||
} | ||
@@ -139,3 +146,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about changes: ${e.message}`); | ||
throw gitError(`Cannot gather information about changes`, e); | ||
} | ||
@@ -154,3 +161,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about branch changes: ${e.message}`); | ||
throw gitError(`Cannot gather information about branch changes`, e); | ||
} | ||
@@ -166,3 +173,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about change between refs changes (${fromRef} to ${toRef}): ${e.message}`); | ||
throw gitError(`Cannot gather information about change between refs changes (${fromRef} to ${toRef})`, e); | ||
} | ||
@@ -176,3 +183,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about staged changes: ${e.message}`); | ||
throw gitError(`Cannot gather information about staged changes`, e); | ||
} | ||
@@ -192,3 +199,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about recent commits: ${e.message}`); | ||
throw gitError(`Cannot gather information about recent commits`, e); | ||
} | ||
@@ -206,3 +213,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot gather information about user.email: ${e.message}`); | ||
throw gitError(`Cannot gather information about user.email`, e); | ||
} | ||
@@ -219,3 +226,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot get branch name: ${e.message}`); | ||
throw gitError(`Cannot get branch name`, e); | ||
} | ||
@@ -251,3 +258,3 @@ return null; | ||
catch (e) { | ||
throw new Error(`Cannot get current git hash: ${e.message}`); | ||
throw gitError(`Cannot get current git hash`, e); | ||
} | ||
@@ -273,3 +280,3 @@ return null; | ||
if (!username) { | ||
throw new Error("must include a username when initializing git repo"); | ||
throw gitError("must include a username when initializing git repo"); | ||
} | ||
@@ -293,3 +300,3 @@ git(["config", "user.name", username], { cwd }); | ||
catch (e) { | ||
throw new Error(`Cannot stage changes: ${e.message}`); | ||
throw gitError(`Cannot stage changes`, e); | ||
} | ||
@@ -306,3 +313,3 @@ } | ||
catch (e) { | ||
throw new Error(`Cannot commit changes: ${e.message}`); | ||
throw gitError(`Cannot commit changes`, e); | ||
} | ||
@@ -375,3 +382,3 @@ } | ||
try { | ||
const parsed = git_url_parse_1.default(repositoryUrl); | ||
const parsed = (0, git_url_parse_1.default)(repositoryUrl); | ||
return parsed | ||
@@ -398,6 +405,6 @@ .toString("https") | ||
*/ | ||
const headBranchLine = showRemote.stdout.split(/\n/).find(line => line.includes('HEAD branch')); | ||
const headBranchLine = showRemote.stdout.split(/\n/).find((line) => line.includes("HEAD branch")); | ||
let remoteDefaultBranch; | ||
if (headBranchLine) { | ||
remoteDefaultBranch = headBranchLine.replace(/^\s*HEAD branch:\s+/, ''); | ||
remoteDefaultBranch = headBranchLine.replace(/^\s*HEAD branch:\s+/, ""); | ||
} | ||
@@ -420,3 +427,3 @@ branch = branch || remoteDefaultBranch || getDefaultBranch(cwd); | ||
try { | ||
packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(paths_1.findGitRoot(cwd), "package.json")).toString()); | ||
packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join((0, paths_1.findGitRoot)(cwd), "package.json")).toString()); | ||
} | ||
@@ -423,0 +430,0 @@ catch (e) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._resetGraphCache = exports.getPackageGraph = void 0; | ||
const dependencies_1 = require("./dependencies"); | ||
@@ -11,3 +12,3 @@ const graphCache = new Map(); | ||
for (const [pkg, info] of Object.entries(packages)) { | ||
const deps = dependencies_1.getInternalDeps(info, packages); | ||
const deps = (0, dependencies_1.getInternalDeps)(info, packages); | ||
for (const dep of deps) { | ||
@@ -14,0 +15,0 @@ edges.push([dep, pkg]); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setupLocalRemote = exports.cleanupFixtures = exports.setupFixture = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -37,3 +38,3 @@ const find_up_1 = __importDefault(require("find-up")); | ||
fs_extra_1.default.copySync(fixturePath, cwd); | ||
git_1.init(cwd, "test@test.email", "test user"); | ||
(0, git_1.init)(cwd, "test@test.email", "test user"); | ||
// Make the 'main' branch the default in the test repo | ||
@@ -43,5 +44,5 @@ // ensure that the configuration for this repo does not collide | ||
// a 'fixed' value for our tests, regardless of user configuration | ||
git_1.gitFailFast(["symbolic-ref", "HEAD", "refs/heads/main"], { cwd }); | ||
git_1.gitFailFast(["config", "init.defaultBranch", "main"], { cwd }); | ||
git_1.stageAndCommit(["."], "test", cwd); | ||
(0, git_1.gitFailFast)(["symbolic-ref", "HEAD", "refs/heads/main"], { cwd }); | ||
(0, git_1.gitFailFast)(["config", "init.defaultBranch", "main"], { cwd }); | ||
(0, git_1.stageAndCommit)(["."], "test", cwd); | ||
return cwd; | ||
@@ -61,3 +62,3 @@ } | ||
const remoteUrl = remoteCwd.replace(/\\/g, "/"); | ||
git_1.gitFailFast(["remote", "add", remoteName, remoteUrl], { cwd }); | ||
(0, git_1.gitFailFast)(["remote", "add", remoteName, remoteUrl], { cwd }); | ||
// Configure url in package.json | ||
@@ -64,0 +65,0 @@ const pkgJsonPath = path_1.default.join(cwd, "package.json"); |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./dependencies")); | ||
__export(require("./getPackageInfos")); | ||
__export(require("./git")); | ||
__export(require("./graph")); | ||
__export(require("./lockfile")); | ||
__export(require("./paths")); | ||
__export(require("./scope")); | ||
__export(require("./workspaces/findWorkspacePath")); | ||
__export(require("./workspaces/getWorkspaces")); | ||
__export(require("./workspaces/getWorkspaceRoot")); | ||
__export(require("./workspaces/implementations/pnpm")); | ||
__export(require("./workspaces/implementations/rush")); | ||
__export(require("./workspaces/implementations/yarn")); | ||
__export(require("./workspaces/getChangedPackages")); | ||
__export(require("./workspaces/listOfWorkspacePackageNames")); | ||
__export(require("./workspaces/workspaces")); | ||
__exportStar(require("./dependencies"), exports); | ||
__exportStar(require("./getPackageInfos"), exports); | ||
__exportStar(require("./git"), exports); | ||
__exportStar(require("./graph"), exports); | ||
__exportStar(require("./lockfile"), exports); | ||
__exportStar(require("./paths"), exports); | ||
__exportStar(require("./scope"), exports); | ||
__exportStar(require("./types/PackageInfo"), exports); | ||
__exportStar(require("./types/WorkspaceInfo"), exports); | ||
__exportStar(require("./workspaces/findWorkspacePath"), exports); | ||
__exportStar(require("./workspaces/getWorkspaces"), exports); | ||
__exportStar(require("./workspaces/getWorkspaceRoot"), exports); | ||
__exportStar(require("./workspaces/implementations/pnpm"), exports); | ||
__exportStar(require("./workspaces/implementations/rush"), exports); | ||
__exportStar(require("./workspaces/implementations/yarn"), exports); | ||
__exportStar(require("./workspaces/getChangedPackages"), exports); | ||
__exportStar(require("./workspaces/listOfWorkspacePackageNames"), exports); | ||
__exportStar(require("./workspaces/workspaces"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.infoFromPackageJson = void 0; | ||
function infoFromPackageJson(packageJson, packageJsonPath) { | ||
@@ -4,0 +5,0 @@ return Object.assign({ packageJsonPath }, packageJson); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryLockFile = exports.nameAtVersion = exports.parseLockFile = void 0; | ||
// NOTE: never place the import of lockfile implementation here, as it slows down the library as a whole | ||
@@ -17,3 +33,3 @@ const find_up_1 = __importDefault(require("find-up")); | ||
const nameAtVersion_1 = require("./nameAtVersion"); | ||
exports.nameAtVersion = nameAtVersion_1.nameAtVersion; | ||
Object.defineProperty(exports, "nameAtVersion", { enumerable: true, get: function () { return nameAtVersion_1.nameAtVersion; } }); | ||
const parsePnpmLock_1 = require("./parsePnpmLock"); | ||
@@ -23,3 +39,3 @@ const parseNpmLock_1 = require("./parseNpmLock"); | ||
async function parseLockFile(packageRoot) { | ||
const yarnLockPath = await find_up_1.default(["yarn.lock", "common/config/rush/yarn.lock"], { cwd: packageRoot }); | ||
const yarnLockPath = await (0, find_up_1.default)(["yarn.lock", "common/config/rush/yarn.lock"], { cwd: packageRoot }); | ||
// First, test out whether this works for yarn | ||
@@ -37,3 +53,3 @@ if (yarnLockPath) { | ||
// Second, test out whether this works for pnpm | ||
let pnpmLockPath = await find_up_1.default(["pnpm-lock.yaml", "common/config/rush/pnpm-lock.yaml"], { cwd: packageRoot }); | ||
let pnpmLockPath = await (0, find_up_1.default)(["pnpm-lock.yaml", "common/config/rush/pnpm-lock.yaml"], { cwd: packageRoot }); | ||
if (pnpmLockPath) { | ||
@@ -45,3 +61,3 @@ if (memoization[pnpmLockPath]) { | ||
const yaml = (await readYamlFile(pnpmLockPath)); | ||
const parsed = parsePnpmLock_1.parsePnpmLock(yaml); | ||
const parsed = (0, parsePnpmLock_1.parsePnpmLock)(yaml); | ||
memoization[pnpmLockPath] = parsed; | ||
@@ -51,3 +67,3 @@ return memoization[pnpmLockPath]; | ||
// Third, try for npm workspaces | ||
let npmLockPath = await find_up_1.default(["package-lock.json"], { cwd: packageRoot }); | ||
let npmLockPath = await (0, find_up_1.default)(["package-lock.json"], { cwd: packageRoot }); | ||
if (npmLockPath) { | ||
@@ -68,3 +84,3 @@ if (memoization[npmLockPath]) { | ||
} | ||
memoization[npmLockPath] = parseNpmLock_1.parseNpmLock(npmLock); | ||
memoization[npmLockPath] = (0, parseNpmLock_1.parseNpmLock)(npmLock); | ||
return memoization[npmLockPath]; | ||
@@ -76,2 +92,3 @@ } | ||
var queryLockFile_1 = require("./queryLockFile"); | ||
exports.queryLockFile = queryLockFile_1.queryLockFile; | ||
Object.defineProperty(exports, "queryLockFile", { enumerable: true, get: function () { return queryLockFile_1.queryLockFile; } }); | ||
__exportStar(require("./types"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameAtVersion = void 0; | ||
function nameAtVersion(name, version) { | ||
@@ -4,0 +5,0 @@ return `${name}@${version}`; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseNpmLock = (lock) => { | ||
exports.parseNpmLock = void 0; | ||
const parseNpmLock = (lock) => { | ||
var _a; | ||
@@ -10,1 +11,2 @@ return ({ | ||
}; | ||
exports.parseNpmLock = parseNpmLock; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parsePnpmLock = void 0; | ||
const nameAtVersion_1 = require("./nameAtVersion"); | ||
@@ -12,3 +13,3 @@ function parsePnpmLock(yaml) { | ||
const version = specParts.length > 3 ? specParts[3] : specParts[2]; | ||
object[nameAtVersion_1.nameAtVersion(name, version)] = { | ||
object[(0, nameAtVersion_1.nameAtVersion)(name, version)] = { | ||
version, | ||
@@ -15,0 +16,0 @@ dependencies: snapshot.dependencies, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryLockFile = void 0; | ||
const nameAtVersion_1 = require("./nameAtVersion"); | ||
function queryLockFile(name, versionRange, lock) { | ||
const versionRangeSignature = nameAtVersion_1.nameAtVersion(name, versionRange); | ||
const versionRangeSignature = (0, nameAtVersion_1.nameAtVersion)(name, versionRange); | ||
return lock.object[versionRangeSignature]; | ||
} | ||
exports.queryLockFile = queryLockFile; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isChildOf = exports.getChangePath = exports.findPackageRoot = exports.findGitRoot = exports.searchUp = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -8,0 +9,0 @@ const fs_1 = __importDefault(require("fs")); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getScopedPackages = void 0; | ||
const multimatch_1 = __importDefault(require("multimatch")); | ||
@@ -22,3 +23,3 @@ /** | ||
if (scopedSearch.length > 0) { | ||
const matched = multimatch_1.default(packageNames, scopedSearch); | ||
const matched = (0, multimatch_1.default)(packageNames, scopedSearch); | ||
for (const pkg of matched) { | ||
@@ -33,3 +34,3 @@ results.add(pkg); | ||
const barePackageMap = generateBarePackageMap(packageNames); | ||
let matched = multimatch_1.default(Object.keys(barePackageMap), unscopedSearch); | ||
let matched = (0, multimatch_1.default)(Object.keys(barePackageMap), unscopedSearch); | ||
for (const bare of matched) { | ||
@@ -36,0 +37,0 @@ for (const pkg of barePackageMap[bare]) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findWorkspacePath = void 0; | ||
function findWorkspacePath(workspaces, packageName) { | ||
@@ -4,0 +5,0 @@ const workspace = workspaces.find(({ name }) => name === packageName); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getChangedPackages = void 0; | ||
const git_1 = require("../git"); | ||
@@ -29,13 +30,13 @@ const getWorkspaces_1 = require("./getWorkspaces"); | ||
function getChangedPackages(cwd, target, ignoreGlobs = []) { | ||
const workspaceInfo = getWorkspaces_1.getWorkspaces(cwd); | ||
target = target || git_1.getDefaultRemoteBranch(undefined, cwd); | ||
const workspaceInfo = (0, getWorkspaces_1.getWorkspaces)(cwd); | ||
target = target || (0, git_1.getDefaultRemoteBranch)(undefined, cwd); | ||
let changes = [ | ||
...new Set([ | ||
...(git_1.getUntrackedChanges(cwd) || []), | ||
...(git_1.getUnstagedChanges(cwd) || []), | ||
...(git_1.getBranchChanges(target, cwd) || []), | ||
...(git_1.getStagedChanges(cwd) || []), | ||
...((0, git_1.getUntrackedChanges)(cwd) || []), | ||
...((0, git_1.getUnstagedChanges)(cwd) || []), | ||
...((0, git_1.getBranchChanges)(target, cwd) || []), | ||
...((0, git_1.getStagedChanges)(cwd) || []), | ||
]), | ||
]; | ||
const ignoreSet = new Set(multimatch_1.default(changes, ignoreGlobs)); | ||
const ignoreSet = new Set((0, multimatch_1.default)(changes, ignoreGlobs)); | ||
changes = changes.filter((change) => !ignoreSet.has(change)); | ||
@@ -42,0 +43,0 @@ const changeSet = new Set(); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWorkspacePackageInfo = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -8,0 +9,0 @@ const fs_1 = __importDefault(require("fs")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWorkspaceRoot = void 0; | ||
const implementations_1 = require("./implementations"); | ||
const preferred = process.env.PREFERRED_WORKSPACE_MANAGER; | ||
function getWorkspaceRoot(cwd) { | ||
const workspaceImplementation = preferred || implementations_1.getWorkspaceImplementation(cwd); | ||
const workspaceImplementation = preferred || (0, implementations_1.getWorkspaceImplementation)(cwd); | ||
if (!workspaceImplementation) { | ||
@@ -8,0 +9,0 @@ return; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWorkspaces = void 0; | ||
const implementations_1 = require("./implementations"); | ||
const preferred = process.env.PREFERRED_WORKSPACE_MANAGER; | ||
function getWorkspaces(cwd) { | ||
const workspaceImplementation = preferred || implementations_1.getWorkspaceImplementation(cwd); | ||
const workspaceImplementation = preferred || (0, implementations_1.getWorkspaceImplementation)(cwd); | ||
if (!workspaceImplementation) { | ||
@@ -8,0 +9,0 @@ return []; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWorkspaceImplementation = exports.getWorkspaceImplementationAndLockFile = void 0; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
@@ -8,0 +9,0 @@ const path_1 = __importDefault(require("path")); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLernaWorkspaces = exports.getLernaWorkspaceRoot = void 0; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
@@ -26,4 +27,4 @@ const fs_1 = __importDefault(require("fs")); | ||
const lernaConfig = jju_1.default.parse(fs_1.default.readFileSync(lernaJsonPath, "utf-8")); | ||
const packagePaths = getPackagePaths_1.getPackagePaths(lernaWorkspaceRoot, lernaConfig.packages); | ||
const workspaceInfo = getWorkspacePackageInfo_1.getWorkspacePackageInfo(packagePaths); | ||
const packagePaths = (0, getPackagePaths_1.getPackagePaths)(lernaWorkspaceRoot, lernaConfig.packages); | ||
const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths); | ||
return workspaceInfo; | ||
@@ -30,0 +31,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNpmWorkspaces = exports.getNpmWorkspaceRoot = void 0; | ||
const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces"); | ||
function getNpmWorkspaceRoot(cwd) { | ||
const npmWorkspacesRoot = packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot(cwd); | ||
const npmWorkspacesRoot = (0, packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot)(cwd); | ||
if (!npmWorkspacesRoot) { | ||
@@ -14,4 +15,4 @@ throw new Error("Could not find NPM workspaces root"); | ||
const npmWorkspacesRoot = getNpmWorkspaceRoot(cwd); | ||
return packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot(npmWorkspacesRoot); | ||
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(npmWorkspacesRoot); | ||
} | ||
exports.getNpmWorkspaces = getNpmWorkspaces; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWorkspaceInfoFromWorkspaceRoot = exports.getPackageJsonWorkspaceRoot = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -14,3 +15,3 @@ const path_1 = __importDefault(require("path")); | ||
var _a; | ||
const lockFile = (_a = _1.getWorkspaceImplementationAndLockFile(cwd)) === null || _a === void 0 ? void 0 : _a.lockFile; | ||
const lockFile = (_a = (0, _1.getWorkspaceImplementationAndLockFile)(cwd)) === null || _a === void 0 ? void 0 : _a.lockFile; | ||
const packageJsonWorkspacesRoot = lockFile ? path_1.default.dirname(lockFile) : cwd; | ||
@@ -44,4 +45,4 @@ return packageJsonWorkspacesRoot; | ||
const packages = getPackages(rootPackageJson); | ||
const packagePaths = getPackagePaths_1.getPackagePaths(packageJsonWorkspacesRoot, packages); | ||
const workspaceInfo = getWorkspacePackageInfo_1.getWorkspacePackageInfo(packagePaths); | ||
const packagePaths = (0, getPackagePaths_1.getPackagePaths)(packageJsonWorkspacesRoot, packages); | ||
const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths); | ||
return workspaceInfo; | ||
@@ -48,0 +49,0 @@ } |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPnpmWorkspaces = exports.getPnpmWorkspaceRoot = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -25,4 +26,4 @@ const find_up_1 = __importDefault(require("find-up")); | ||
const pnpmWorkspaces = readYaml(pnpmWorkspacesFile); | ||
const packagePaths = getPackagePaths_1.getPackagePaths(pnpmWorkspacesRoot, pnpmWorkspaces.packages); | ||
const workspaceInfo = getWorkspacePackageInfo_1.getWorkspacePackageInfo(packagePaths); | ||
const packagePaths = (0, getPackagePaths_1.getPackagePaths)(pnpmWorkspacesRoot, pnpmWorkspaces.packages); | ||
const workspaceInfo = (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(packagePaths); | ||
return workspaceInfo; | ||
@@ -29,0 +30,0 @@ } |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRushWorkspaces = exports.getRushWorkspaceRoot = void 0; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
@@ -26,3 +27,3 @@ const path_1 = __importDefault(require("path")); | ||
const root = path_1.default.dirname(rushJsonPath); | ||
return getWorkspacePackageInfo_1.getWorkspacePackageInfo(rushConfig.projects.map((project) => path_1.default.join(root, project.projectFolder))); | ||
return (0, getWorkspacePackageInfo_1.getWorkspacePackageInfo)(rushConfig.projects.map((project) => path_1.default.join(root, project.projectFolder))); | ||
} | ||
@@ -29,0 +30,0 @@ catch (_a) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getYarnWorkspaces = exports.getYarnWorkspaceRoot = void 0; | ||
const packageJsonWorkspaces_1 = require("./packageJsonWorkspaces"); | ||
function getYarnWorkspaceRoot(cwd) { | ||
const yarnWorkspacesRoot = packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot(cwd); | ||
const yarnWorkspacesRoot = (0, packageJsonWorkspaces_1.getPackageJsonWorkspaceRoot)(cwd); | ||
if (!yarnWorkspacesRoot) { | ||
@@ -14,4 +15,4 @@ throw new Error("Could not find yarn workspaces root"); | ||
const yarnWorkspacesRoot = getYarnWorkspaceRoot(cwd); | ||
return packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot(yarnWorkspacesRoot); | ||
return (0, packageJsonWorkspaces_1.getWorkspaceInfoFromWorkspaceRoot)(yarnWorkspacesRoot); | ||
} | ||
exports.getYarnWorkspaces = getYarnWorkspaces; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listOfWorkspacePackageNames = void 0; | ||
function listOfWorkspacePackageNames(workspaces) { | ||
@@ -4,0 +5,0 @@ return workspaces.map(({ name }) => name); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._resetCache = exports.getAllPackageJsonFiles = void 0; | ||
const getWorkspaces_1 = require("./getWorkspaces"); | ||
@@ -13,3 +14,3 @@ const cache = new Map(); | ||
} | ||
const workspaces = getWorkspaces_1.getWorkspaces(cwd); | ||
const workspaces = (0, getWorkspaces_1.getWorkspaces)(cwd); | ||
const packageJsonFiles = workspaces.map((workspace) => workspace.packageJson.packageJsonPath); | ||
@@ -16,0 +17,0 @@ cache.set(cwd, packageJsonFiles); |
{ | ||
"name": "workspace-tools", | ||
"version": "0.18.0", | ||
"version": "0.18.1", | ||
"license": "MIT", | ||
@@ -41,4 +41,4 @@ "repository": { | ||
"ts-jest": "^25.5.1", | ||
"typescript": "3.8.3" | ||
"typescript": "^4.5.4" | ||
} | ||
} |
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
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
129828
3008