generated from hamlim/template-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
334 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
packages/one-version/__fixtures__/bun-configured-pinned/libs/pkg-a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "pkg-a", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
}, | ||
"peerDependencies": { | ||
"next": "14.3.0-canary.61" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/one-version/__fixtures__/bun-configured-pinned/libs/pkg-b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "pkg-b", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
}, | ||
"peerDependencies": { | ||
"next": "14.3.0-canary.61" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.4" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/one-version/__fixtures__/bun-configured-pinned/libs/pkg-c/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "pkg-c", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
}, | ||
"peerDependencies": { | ||
"next": "14.3.0-canary.61" | ||
}, | ||
"devDependencies": { | ||
"typescript": "5.4.5" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/one-version/__fixtures__/bun-configured-pinned/one-version.config.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "../../../../apps/docs/public/schema.json", | ||
"packageManager": "bun", | ||
"versionStrategy": "pin" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/one-version/__fixtures__/bun-configured-pinned/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"private": true, | ||
"workspaces": [ | ||
"libs/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ import assert from "node:assert"; | |
import path from "node:path"; | ||
import { describe, test } from "node:test"; | ||
import { fileURLToPath } from "node:url"; | ||
import { start } from "../one-version.mjs"; | ||
import { getUnpinnedDependencies, start } from "../one-version.mjs"; | ||
|
||
describe("one-version", () => { | ||
describe("one-version unit tests", () => { | ||
test("supports help command", async () => { | ||
let logs = []; | ||
const logger = { | ||
|
@@ -32,6 +32,104 @@ describe("one-version", () => { | |
|
||
assert.match(logs[0], /Unknown command:/); | ||
}); | ||
|
||
describe("getUnpinnedDependencies", () => { | ||
test("returns empty array when no dependencies are found", () => { | ||
const workspaceDependencies = [{ | ||
name: "testing", | ||
dependencies: {}, | ||
devDependencies: {}, | ||
peerDependencies: {}, | ||
}]; | ||
const result = getUnpinnedDependencies({ workspaceDependencies, overrides: undefined }); | ||
|
||
assert.deepEqual(result, {}); | ||
}); | ||
|
||
test("Covers the core edge cases", () => { | ||
const workspaceDependencies = [{ | ||
name: "testing", | ||
dependencies: { | ||
foo: "^1.0.0", | ||
}, | ||
devDependencies: { | ||
bar: "2.0.x", | ||
baz: "3.X", | ||
react: "17.0.0 - 18.0.0", | ||
"react-dom": "17.0.0 || 18.0.0", | ||
"react-native": ">=0.64.0", | ||
"react-native-web": "<0.17.0", | ||
"one-version": "workspace:^*", | ||
turbo: "workspace:~*", | ||
next: "canary", | ||
abc: "next", | ||
def: "beta", | ||
ghi: "alpha", | ||
jkl: "rc", | ||
mno: "dev", | ||
// All below shouldn't show up! | ||
hohoro: "workspace:*", | ||
"react-router": "file:../react-router", | ||
"left-pad": "git://github.com/jonschlinkert/left-pad.git#1.2.0", | ||
"right-pad": "link:../right-pad", | ||
"top-pad": "url:../top-pad", | ||
}, | ||
peerDependencies: { | ||
"peer-dep": "*", | ||
}, | ||
}]; | ||
const result = getUnpinnedDependencies({ workspaceDependencies, overrides: undefined }); | ||
|
||
// peer-dep is omitted because it's a peer dependency | ||
assert.deepEqual(result, { | ||
testing: [ | ||
"foo@^1.0.0", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected] - 18.0.0", | ||
"[email protected] || 18.0.0", | ||
"react-native@>=0.64.0", | ||
"react-native-web@<0.17.0", | ||
"one-version@workspace:^*", | ||
"turbo@workspace:~*", | ||
"next@canary", | ||
"abc@next", | ||
"def@beta", | ||
"ghi@alpha", | ||
"jkl@rc", | ||
"mno@dev", | ||
], | ||
}); | ||
}); | ||
|
||
test("Allows overriding dependencies", () => { | ||
const workspaceDependencies = [{ | ||
name: "testing", | ||
dependencies: { | ||
foo: "^1.0.0", | ||
}, | ||
devDependencies: {}, | ||
peerDependencies: { | ||
next: "canary", | ||
}, | ||
}]; | ||
const result = getUnpinnedDependencies({ | ||
workspaceDependencies, | ||
overrides: { | ||
next: { | ||
canary: ["*"], | ||
}, | ||
}, | ||
}); | ||
|
||
// Next not included because it's overridden | ||
assert.deepEqual(result, { | ||
testing: [ | ||
"foo@^1.0.0", | ||
], | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
let __filename = fileURLToPath(import.meta.url); | ||
|
@@ -54,7 +152,6 @@ describe("one-version integration tests", () => { | |
|
||
// should fail - mismatch of typescript dependencies | ||
assert.equal(statusCode, 1); | ||
assert.match(errors[0], /More than one version of dependencies found. See above output/); | ||
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
assert.match(logs[0], /typescript/); | ||
|
@@ -76,7 +173,6 @@ describe("one-version integration tests", () => { | |
|
||
// should fail - mismatch of typescript dependencies | ||
assert.equal(statusCode, 1); | ||
assert.match(errors[0], /More than one version of dependencies found. See above output/); | ||
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
assert.match(logs[0], /typescript/); | ||
|
@@ -98,7 +194,6 @@ describe("one-version integration tests", () => { | |
|
||
// should fail - mismatch of typescript dependencies | ||
assert.equal(statusCode, 1); | ||
assert.match(errors[0], /More than one version of dependencies found. See above output/); | ||
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
assert.match(logs[0], /typescript/); | ||
|
@@ -120,7 +215,6 @@ describe("one-version integration tests", () => { | |
|
||
// should fail - mismatch of typescript dependencies | ||
assert.equal(statusCode, 1); | ||
assert.match(errors[0], /More than one version of dependencies found. See above output/); | ||
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
assert.match(logs[0], /typescript/); | ||
|
@@ -142,7 +236,6 @@ describe("one-version integration tests", () => { | |
|
||
// should fail - mismatch of typescript dependencies | ||
assert.equal(statusCode, 1); | ||
assert.match(errors[0], /More than one version of dependencies found. See above output/); | ||
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
assert.match(logs[0], /typescript/); | ||
|
@@ -188,4 +281,25 @@ describe("one-version integration tests", () => { | |
// single log line with multiple new-lines | ||
assert.match(logs[0], /One Version Rule Success/); | ||
}); | ||
|
||
test("bun - configured and pinned versions", async () => { | ||
const targetDir = path.join(__dirname, "..", "__fixtures__", "bun-configured-pinned"); | ||
let logs = []; | ||
let errors = []; | ||
let logger = { | ||
log(...args) { | ||
logs.push(args.join(" ")); | ||
}, | ||
error(...args) { | ||
errors.push(args.join(" ")); | ||
}, | ||
}; | ||
let { statusCode } = await start({ rootDirectory: targetDir, logger, args: ["check"] }); | ||
|
||
// should fail because of loose deps | ||
assert.equal(statusCode, 1); | ||
|
||
assert.equal(logs.length, 2); | ||
assert.match(logs[0], /One Version Rule Failure/); | ||
}); | ||
}); |
Oops, something went wrong.