-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle pnpx & pnpm dlx in package.json scripts (#16187)
Co-authored-by: Jarred Sumner <[email protected]>
- Loading branch information
1 parent
f299ef8
commit 1923509
Showing
3 changed files
with
134 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,77 @@ | ||
const std = @import("std"); | ||
const bun = @import("root").bun; | ||
|
||
// yarn v2.3 commands | ||
const yarn_v2 = [_][]const u8{ | ||
"add", | ||
"bin", | ||
"cache", | ||
"config", | ||
"dedupe", | ||
"dlx", | ||
"exec", | ||
"explain", | ||
"info", | ||
"init", | ||
"install", | ||
"link", | ||
"node", | ||
"npm", | ||
"pack", | ||
"patch", | ||
"plugin", | ||
"rebuild", | ||
"remove", | ||
"run", | ||
"set", | ||
"unplug", | ||
"up", | ||
"why", | ||
"workspace", | ||
"workspaces", | ||
}; | ||
pub const all_yarn_commands = bun.ComptimeStringMap(void, .{ | ||
// yarn v2.3 commands | ||
.{"add"}, | ||
.{"bin"}, | ||
.{"cache"}, | ||
.{"config"}, | ||
.{"dedupe"}, | ||
.{"dlx"}, | ||
.{"exec"}, | ||
.{"explain"}, | ||
.{"info"}, | ||
.{"init"}, | ||
.{"install"}, | ||
.{"link"}, | ||
.{"node"}, | ||
.{"npm"}, | ||
.{"pack"}, | ||
.{"patch"}, | ||
.{"plugin"}, | ||
.{"rebuild"}, | ||
.{"remove"}, | ||
.{"run"}, | ||
.{"set"}, | ||
.{"unplug"}, | ||
.{"up"}, | ||
.{"why"}, | ||
.{"workspace"}, | ||
.{"workspaces"}, | ||
|
||
// yarn v1 commands | ||
const yarn_v1 = [_][]const u8{ | ||
"access", | ||
"add", | ||
"audit", | ||
"autoclean", | ||
"bin", | ||
"cache", | ||
"check", | ||
"config", | ||
"create", | ||
"exec", | ||
"generate-lock-entry", | ||
"generateLockEntry", | ||
"global", | ||
"help", | ||
"import", | ||
"info", | ||
"init", | ||
"install", | ||
"licenses", | ||
"link", | ||
"list", | ||
"login", | ||
"logout", | ||
"node", | ||
"outdated", | ||
"owner", | ||
"pack", | ||
"policies", | ||
"publish", | ||
"remove", | ||
"run", | ||
"tag", | ||
"team", | ||
"unlink", | ||
"unplug", | ||
"upgrade", | ||
"upgrade-interactive", | ||
"upgradeInteractive", | ||
"version", | ||
"versions", | ||
"why", | ||
"workspace", | ||
"workspaces", | ||
}; | ||
|
||
pub const all_yarn_commands = brk: { | ||
@setEvalBranchQuota(9999); | ||
var array: [yarn_v2.len + yarn_v1.len]u64 = undefined; | ||
var array_i: usize = 0; | ||
for (yarn_v2) |yarn| { | ||
const hash = bun.hash(yarn); | ||
@setEvalBranchQuota(9999); | ||
if (std.mem.indexOfScalar(u64, array[0..array_i], hash) == null) { | ||
@setEvalBranchQuota(9999); | ||
array[array_i] = hash; | ||
array_i += 1; | ||
} | ||
} | ||
|
||
for (yarn_v1) |yarn| { | ||
@setEvalBranchQuota(9999); | ||
|
||
const hash = bun.hash(yarn); | ||
if (std.mem.indexOfScalar(u64, array[0..array_i], hash) == null) { | ||
@setEvalBranchQuota(9999); | ||
|
||
array[array_i] = hash; | ||
array_i += 1; | ||
} | ||
} | ||
|
||
const final = array[0..array_i].*; | ||
break :brk &final; | ||
}; | ||
// yarn v1 commands | ||
.{"access"}, | ||
.{"add"}, | ||
.{"audit"}, | ||
.{"autoclean"}, | ||
.{"bin"}, | ||
.{"cache"}, | ||
.{"check"}, | ||
.{"config"}, | ||
.{"create"}, | ||
.{"exec"}, | ||
.{"generate-lock-entry"}, | ||
.{"generateLockEntry"}, | ||
.{"global"}, | ||
.{"help"}, | ||
.{"import"}, | ||
.{"info"}, | ||
.{"init"}, | ||
.{"install"}, | ||
.{"licenses"}, | ||
.{"link"}, | ||
.{"list"}, | ||
.{"login"}, | ||
.{"logout"}, | ||
.{"node"}, | ||
.{"outdated"}, | ||
.{"owner"}, | ||
.{"pack"}, | ||
.{"policies"}, | ||
.{"publish"}, | ||
.{"remove"}, | ||
.{"run"}, | ||
.{"tag"}, | ||
.{"team"}, | ||
.{"unlink"}, | ||
.{"unplug"}, | ||
.{"upgrade"}, | ||
.{"upgrade-interactive"}, | ||
.{"upgradeInteractive"}, | ||
.{"version"}, | ||
.{"versions"}, | ||
.{"why"}, | ||
.{"workspace"}, | ||
.{"workspaces"}, | ||
}); |
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