package-json-scripts-portability 0.0.1 → 0.0.3
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/README.md +59 -20
- package/dist/analyze-script.d.mts +34 -0
- package/dist/analyze-script.mjs +53 -0
- package/dist/command-checker.mjs +527 -0
- package/dist/command-usage.mjs +413 -0
- package/dist/commands.mjs +639 -0
- package/dist/context.mjs +25 -0
- package/dist/fixes.d.mts +9 -0
- package/dist/fixes.mjs +354 -0
- package/dist/index.d.mts +6 -118
- package/dist/index.mjs +4 -3787
- package/dist/line-break-checker.mjs +104 -0
- package/dist/messages.mjs +38 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-difference.mjs +11 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-includes.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-is-subset.mjs +16 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/arrayify.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index-with.mjs +33 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/sorted-array-insertion-index.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs +30 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert-computed.mjs +42 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs +40 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/path/to-forward-slashes.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/predicate/is-array.mjs +39 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/is-semver-in-range.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/semver/parse-semver.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs +8 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after-last.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-before.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs +46 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/ts/all-union-members.mjs +45 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/types/maybe-readonly-array.d.mts +17 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/value/is-equal.mjs +37 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/@antfu/utils/dist/index.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/globalThis.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/isUnsafeProperty.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/setOwnValue.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/toPropertyKey.mjs +16 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceBy.mjs +40 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceWith.mjs +37 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/intersectionWith.mjs +43 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/isSubsetWith.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/bigint/clamp.mjs +15 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/baseToString.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getSymbols.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getTag.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/hasOwn.mjs +13 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isDeepKey.mjs +39 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/isIndex.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/regexMultiByte.mjs +10 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/tags.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/toKey.mjs +15 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndex.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedIndexBy.mjs +54 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndex.mjs +34 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/array/sortedLastIndexBy.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/function/identity.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeep.mjs +52 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/cloneDeepWith.mjs +179 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/get.mjs +67 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/has.mjs +53 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/object/property.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isArguments.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isBuffer.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatch.mjs +34 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isMatchWith.mjs +163 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNaN.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNil.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isNumber.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObject.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObjectLike.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isSymbol.mjs +19 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isTypedArray.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matches.mjs +36 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/matchesProperty.mjs +47 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/string/truncate.mjs +78 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/eq.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/iteratee.mjs +46 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toPath.mjs +75 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/toString.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/identity.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/noop.mjs +12 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/math/clamp.mjs +23 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isBuffer.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqual.mjs +21 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqualWith.mjs +150 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNil.mjs +24 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isNull.mjs +25 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPlainObject.mjs +50 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPrimitive.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isSymbol.mjs +28 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isTypedArray.mjs +20 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isUndefined.mjs +25 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/binarySearchCutoffIndex-Bu-OMJ0Z.mjs +26 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/isArray.mjs +18 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/sortedIndexWith.mjs +7 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/array-includes.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/set-has.mjs +5 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/comparison-CmVirWIW.mjs +108 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/range-C5wjdo9a.mjs +164 -0
- package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/verkit/dist/set-BGFWKKE8.mjs +38 -0
- package/dist/platforms.d.mts +8 -0
- package/dist/platforms.mjs +26 -0
- package/dist/redirection-checker.mjs +169 -0
- package/dist/reporter.d.mts +32 -0
- package/dist/reporter.mjs +143 -0
- package/dist/runners.d.mts +21 -0
- package/dist/runners.mjs +199 -0
- package/dist/script-analyzer.mjs +853 -0
- package/dist/word-checker.mjs +573 -0
- package/dist/words.mjs +70 -0
- package/package.json +36 -30
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { BASH_4_SUGGESTION, BASH_SUGGESTION, CROSS_ENV_SUGGESTION, DEFAULT_SUGGESTION, RIMRAF_SUGGESTION, SHELL_SCRIPT_SUGGESTION } from "./messages.mjs";
|
|
2
|
+
import { LINUX_PLATFORMS, MACOS_PLATFORMS, NOT_LINUX_OR_WINDOWS, NOT_MACOS_OR_WINDOWS, PLATFORMS, POSIX_PLATFORMS, WINDOWS_PLATFORMS } from "./platforms.mjs";
|
|
3
|
+
// src/commands.ts
|
|
4
|
+
/** POSIX shells, which don't exist on Windows */
|
|
5
|
+
const SHELLS = [
|
|
6
|
+
"bash",
|
|
7
|
+
"csh",
|
|
8
|
+
"dash",
|
|
9
|
+
"fish",
|
|
10
|
+
"ksh",
|
|
11
|
+
"sh",
|
|
12
|
+
"tcsh",
|
|
13
|
+
"zsh"
|
|
14
|
+
];
|
|
15
|
+
const COMMAND_GROUPS = [
|
|
16
|
+
[
|
|
17
|
+
["rm"],
|
|
18
|
+
WINDOWS_PLATFORMS,
|
|
19
|
+
RIMRAF_SUGGESTION
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
["env", "export"],
|
|
23
|
+
WINDOWS_PLATFORMS,
|
|
24
|
+
CROSS_ENV_SUGGESTION
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
["true", ":"],
|
|
28
|
+
WINDOWS_PLATFORMS,
|
|
29
|
+
"Use `exit 0` instead (e.g. `command || exit 0`)."
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
["false"],
|
|
33
|
+
WINDOWS_PLATFORMS,
|
|
34
|
+
"Use `exit 1` instead."
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
["find"],
|
|
38
|
+
WINDOWS_PLATFORMS,
|
|
39
|
+
"Windows ships an unrelated `find` command; use a Node.js script instead."
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
["date"],
|
|
43
|
+
WINDOWS_PLATFORMS,
|
|
44
|
+
"cmd.exe's `date` sets the system date; use a Node.js script instead."
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
SHELLS,
|
|
48
|
+
WINDOWS_PLATFORMS,
|
|
49
|
+
SHELL_SCRIPT_SUGGESTION
|
|
50
|
+
],
|
|
51
|
+
[[
|
|
52
|
+
".",
|
|
53
|
+
"[",
|
|
54
|
+
"alias",
|
|
55
|
+
"awk",
|
|
56
|
+
"base64",
|
|
57
|
+
"basename",
|
|
58
|
+
"bg",
|
|
59
|
+
"bzip2",
|
|
60
|
+
"cat",
|
|
61
|
+
"chgrp",
|
|
62
|
+
"chmod",
|
|
63
|
+
"chown",
|
|
64
|
+
"clear",
|
|
65
|
+
"cmp",
|
|
66
|
+
"column",
|
|
67
|
+
"comm",
|
|
68
|
+
"command",
|
|
69
|
+
"cp",
|
|
70
|
+
"crontab",
|
|
71
|
+
"cut",
|
|
72
|
+
"df",
|
|
73
|
+
"diff",
|
|
74
|
+
"dirname",
|
|
75
|
+
"du",
|
|
76
|
+
"egrep",
|
|
77
|
+
"eval",
|
|
78
|
+
"exec",
|
|
79
|
+
"expr",
|
|
80
|
+
"fg",
|
|
81
|
+
"fgrep",
|
|
82
|
+
"file",
|
|
83
|
+
"fmt",
|
|
84
|
+
"fold",
|
|
85
|
+
"fuser",
|
|
86
|
+
"getopts",
|
|
87
|
+
"grep",
|
|
88
|
+
"gunzip",
|
|
89
|
+
"gzip",
|
|
90
|
+
"hash",
|
|
91
|
+
"head",
|
|
92
|
+
"hexdump",
|
|
93
|
+
"iconv",
|
|
94
|
+
"id",
|
|
95
|
+
"install",
|
|
96
|
+
"jobs",
|
|
97
|
+
"join",
|
|
98
|
+
"kill",
|
|
99
|
+
"killall",
|
|
100
|
+
"less",
|
|
101
|
+
"ln",
|
|
102
|
+
"local",
|
|
103
|
+
"ls",
|
|
104
|
+
"lsof",
|
|
105
|
+
"md5sum",
|
|
106
|
+
"mktemp",
|
|
107
|
+
"mv",
|
|
108
|
+
"nice",
|
|
109
|
+
"nl",
|
|
110
|
+
"nohup",
|
|
111
|
+
"od",
|
|
112
|
+
"paste",
|
|
113
|
+
"patch",
|
|
114
|
+
"pgrep",
|
|
115
|
+
"pkill",
|
|
116
|
+
"printenv",
|
|
117
|
+
"printf",
|
|
118
|
+
"ps",
|
|
119
|
+
"pwd",
|
|
120
|
+
"read",
|
|
121
|
+
"readlink",
|
|
122
|
+
"readonly",
|
|
123
|
+
"realpath",
|
|
124
|
+
"return",
|
|
125
|
+
"rev",
|
|
126
|
+
"rsync",
|
|
127
|
+
"sed",
|
|
128
|
+
"seq",
|
|
129
|
+
"sha1sum",
|
|
130
|
+
"sha224sum",
|
|
131
|
+
"sha256sum",
|
|
132
|
+
"sha384sum",
|
|
133
|
+
"sha512sum",
|
|
134
|
+
"shasum",
|
|
135
|
+
"shift",
|
|
136
|
+
"sleep",
|
|
137
|
+
"split",
|
|
138
|
+
"stat",
|
|
139
|
+
"stdbuf",
|
|
140
|
+
"strings",
|
|
141
|
+
"su",
|
|
142
|
+
"sudo",
|
|
143
|
+
"tail",
|
|
144
|
+
"tee",
|
|
145
|
+
"test",
|
|
146
|
+
"time",
|
|
147
|
+
"touch",
|
|
148
|
+
"tput",
|
|
149
|
+
"tr",
|
|
150
|
+
"trap",
|
|
151
|
+
"truncate",
|
|
152
|
+
"ulimit",
|
|
153
|
+
"umask",
|
|
154
|
+
"uname",
|
|
155
|
+
"uniq",
|
|
156
|
+
"unset",
|
|
157
|
+
"unzip",
|
|
158
|
+
"wait",
|
|
159
|
+
"wc",
|
|
160
|
+
"which",
|
|
161
|
+
"xargs",
|
|
162
|
+
"xxd",
|
|
163
|
+
"yes",
|
|
164
|
+
"zcat",
|
|
165
|
+
"zip"
|
|
166
|
+
], WINDOWS_PLATFORMS],
|
|
167
|
+
[[
|
|
168
|
+
"apk",
|
|
169
|
+
"apt",
|
|
170
|
+
"apt-get",
|
|
171
|
+
"b2sum",
|
|
172
|
+
"dnf",
|
|
173
|
+
"dpkg",
|
|
174
|
+
"free",
|
|
175
|
+
"gawk",
|
|
176
|
+
"inotifywait",
|
|
177
|
+
"ip",
|
|
178
|
+
"journalctl",
|
|
179
|
+
"ldconfig",
|
|
180
|
+
"ldd",
|
|
181
|
+
"lsblk",
|
|
182
|
+
"notify-send",
|
|
183
|
+
"nproc",
|
|
184
|
+
"pacman",
|
|
185
|
+
"rpm",
|
|
186
|
+
"sensible-browser",
|
|
187
|
+
"service",
|
|
188
|
+
"setsid",
|
|
189
|
+
"shred",
|
|
190
|
+
"snap",
|
|
191
|
+
"ss",
|
|
192
|
+
"strace",
|
|
193
|
+
"systemctl",
|
|
194
|
+
"tac",
|
|
195
|
+
"taskset",
|
|
196
|
+
"unxz",
|
|
197
|
+
"wget",
|
|
198
|
+
"wl-copy",
|
|
199
|
+
"wl-paste",
|
|
200
|
+
"xclip",
|
|
201
|
+
"xdg-open",
|
|
202
|
+
"xdotool",
|
|
203
|
+
"xsel",
|
|
204
|
+
"xz",
|
|
205
|
+
"yum",
|
|
206
|
+
"zypper"
|
|
207
|
+
], NOT_MACOS_OR_WINDOWS],
|
|
208
|
+
[[
|
|
209
|
+
"afplay",
|
|
210
|
+
"agvtool",
|
|
211
|
+
"caffeinate",
|
|
212
|
+
"codesign",
|
|
213
|
+
"defaults",
|
|
214
|
+
"diskutil",
|
|
215
|
+
"ditto",
|
|
216
|
+
"hdiutil",
|
|
217
|
+
"install_name_tool",
|
|
218
|
+
"launchctl",
|
|
219
|
+
"lipo",
|
|
220
|
+
"md5",
|
|
221
|
+
"mdfind",
|
|
222
|
+
"networksetup",
|
|
223
|
+
"open",
|
|
224
|
+
"osacompile",
|
|
225
|
+
"osascript",
|
|
226
|
+
"pbcopy",
|
|
227
|
+
"pbpaste",
|
|
228
|
+
"pkgutil",
|
|
229
|
+
"plutil",
|
|
230
|
+
"pmset",
|
|
231
|
+
"qlmanage",
|
|
232
|
+
"say",
|
|
233
|
+
"scutil",
|
|
234
|
+
"security",
|
|
235
|
+
"sw_vers",
|
|
236
|
+
"tccutil",
|
|
237
|
+
"xcodebuild",
|
|
238
|
+
"xcrun",
|
|
239
|
+
"xed"
|
|
240
|
+
], NOT_LINUX_OR_WINDOWS],
|
|
241
|
+
[
|
|
242
|
+
["del"],
|
|
243
|
+
POSIX_PLATFORMS,
|
|
244
|
+
"Use `rimraf` instead (del-cli's `del` alias is shadowed by cmd.exe's builtin on Windows)."
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
["erase", "rd"],
|
|
248
|
+
POSIX_PLATFORMS,
|
|
249
|
+
RIMRAF_SUGGESTION
|
|
250
|
+
],
|
|
251
|
+
[
|
|
252
|
+
["setx"],
|
|
253
|
+
POSIX_PLATFORMS,
|
|
254
|
+
CROSS_ENV_SUGGESTION
|
|
255
|
+
],
|
|
256
|
+
[
|
|
257
|
+
["rem"],
|
|
258
|
+
POSIX_PLATFORMS,
|
|
259
|
+
"Remove the comment instead."
|
|
260
|
+
],
|
|
261
|
+
[["dir"], MACOS_PLATFORMS],
|
|
262
|
+
[[
|
|
263
|
+
"assoc",
|
|
264
|
+
"attrib",
|
|
265
|
+
"call",
|
|
266
|
+
"certutil",
|
|
267
|
+
"chcp",
|
|
268
|
+
"chdir",
|
|
269
|
+
"choice",
|
|
270
|
+
"clip",
|
|
271
|
+
"cls",
|
|
272
|
+
"cmd",
|
|
273
|
+
"copy",
|
|
274
|
+
"cscript",
|
|
275
|
+
"endlocal",
|
|
276
|
+
"explorer",
|
|
277
|
+
"findstr",
|
|
278
|
+
"ftype",
|
|
279
|
+
"goto",
|
|
280
|
+
"icacls",
|
|
281
|
+
"md",
|
|
282
|
+
"mklink",
|
|
283
|
+
"move",
|
|
284
|
+
"msiexec",
|
|
285
|
+
"netsh",
|
|
286
|
+
"pause",
|
|
287
|
+
"powershell",
|
|
288
|
+
"reg",
|
|
289
|
+
"ren",
|
|
290
|
+
"rename",
|
|
291
|
+
"robocopy",
|
|
292
|
+
"rundll32",
|
|
293
|
+
"schtasks",
|
|
294
|
+
"setlocal",
|
|
295
|
+
"start",
|
|
296
|
+
"systeminfo",
|
|
297
|
+
"taskkill",
|
|
298
|
+
"tasklist",
|
|
299
|
+
"title",
|
|
300
|
+
"ver",
|
|
301
|
+
"where",
|
|
302
|
+
"wmic",
|
|
303
|
+
"wscript",
|
|
304
|
+
"wsl",
|
|
305
|
+
"xcopy"
|
|
306
|
+
], POSIX_PLATFORMS]
|
|
307
|
+
];
|
|
308
|
+
/** Bash builtins that POSIX `sh` (e.g. dash on Debian/Ubuntu) and cmd.exe don't have */
|
|
309
|
+
const BASH_BUILTINS = [
|
|
310
|
+
[[
|
|
311
|
+
"bind",
|
|
312
|
+
"builtin",
|
|
313
|
+
"caller",
|
|
314
|
+
"compgen",
|
|
315
|
+
"complete",
|
|
316
|
+
"declare",
|
|
317
|
+
"dirs",
|
|
318
|
+
"disown",
|
|
319
|
+
"enable",
|
|
320
|
+
"help",
|
|
321
|
+
"history",
|
|
322
|
+
"let",
|
|
323
|
+
"logout",
|
|
324
|
+
"shopt",
|
|
325
|
+
"source",
|
|
326
|
+
"suspend",
|
|
327
|
+
"typeset"
|
|
328
|
+
], NOT_LINUX_OR_WINDOWS],
|
|
329
|
+
[["popd", "pushd"], LINUX_PLATFORMS],
|
|
330
|
+
[
|
|
331
|
+
["mapfile", "readarray"],
|
|
332
|
+
PLATFORMS,
|
|
333
|
+
BASH_4_SUGGESTION
|
|
334
|
+
]
|
|
335
|
+
];
|
|
336
|
+
const COMMANDS = new Map([...COMMAND_GROUPS.flatMap(([names, platforms, suggestion = DEFAULT_SUGGESTION]) => names.map((name) => [name, {
|
|
337
|
+
platforms,
|
|
338
|
+
suggestion
|
|
339
|
+
}])), ...BASH_BUILTINS.flatMap(([names, platforms, suggestion = BASH_SUGGESTION]) => names.map((name) => [name, {
|
|
340
|
+
bashBuiltin: true,
|
|
341
|
+
platforms,
|
|
342
|
+
suggestion
|
|
343
|
+
}]))]);
|
|
344
|
+
/** Shell builtins that macOS' `sh` only finds by their exact name, unlike executables */
|
|
345
|
+
const EXACT_NAME_BUILTINS = /* @__PURE__ */ new Set([
|
|
346
|
+
...BASH_BUILTINS.flatMap(([names]) => names),
|
|
347
|
+
"alias",
|
|
348
|
+
"bg",
|
|
349
|
+
"cd",
|
|
350
|
+
"eval",
|
|
351
|
+
"exec",
|
|
352
|
+
"exit",
|
|
353
|
+
"export",
|
|
354
|
+
"fg",
|
|
355
|
+
"getopts",
|
|
356
|
+
"jobs",
|
|
357
|
+
"local",
|
|
358
|
+
"read",
|
|
359
|
+
"readonly",
|
|
360
|
+
"return",
|
|
361
|
+
"shift",
|
|
362
|
+
"trap",
|
|
363
|
+
"ulimit",
|
|
364
|
+
"umask",
|
|
365
|
+
"unset",
|
|
366
|
+
"wait"
|
|
367
|
+
]);
|
|
368
|
+
/** Builtins of both dash and Bash, i.e. of `sh` on Linux and macOS */
|
|
369
|
+
const POSIX_SHELL_BUILTINS = /* @__PURE__ */ new Set([
|
|
370
|
+
".",
|
|
371
|
+
":",
|
|
372
|
+
"[",
|
|
373
|
+
"alias",
|
|
374
|
+
"bg",
|
|
375
|
+
"command",
|
|
376
|
+
"eval",
|
|
377
|
+
"exec",
|
|
378
|
+
"export",
|
|
379
|
+
"false",
|
|
380
|
+
"fg",
|
|
381
|
+
"getopts",
|
|
382
|
+
"hash",
|
|
383
|
+
"jobs",
|
|
384
|
+
"kill",
|
|
385
|
+
"local",
|
|
386
|
+
"printf",
|
|
387
|
+
"pwd",
|
|
388
|
+
"read",
|
|
389
|
+
"readonly",
|
|
390
|
+
"return",
|
|
391
|
+
"shift",
|
|
392
|
+
"test",
|
|
393
|
+
"trap",
|
|
394
|
+
"true",
|
|
395
|
+
"ulimit",
|
|
396
|
+
"umask",
|
|
397
|
+
"unset",
|
|
398
|
+
"wait"
|
|
399
|
+
]);
|
|
400
|
+
/** cmd.exe builtins (rather than executables), which Yarn's portable shell can't run on Windows */
|
|
401
|
+
const CMD_BUILTINS = /* @__PURE__ */ new Set([
|
|
402
|
+
"assoc",
|
|
403
|
+
"call",
|
|
404
|
+
"chdir",
|
|
405
|
+
"cls",
|
|
406
|
+
"copy",
|
|
407
|
+
"del",
|
|
408
|
+
"dir",
|
|
409
|
+
"endlocal",
|
|
410
|
+
"erase",
|
|
411
|
+
"ftype",
|
|
412
|
+
"goto",
|
|
413
|
+
"md",
|
|
414
|
+
"mklink",
|
|
415
|
+
"move",
|
|
416
|
+
"pause",
|
|
417
|
+
"rd",
|
|
418
|
+
"rem",
|
|
419
|
+
"ren",
|
|
420
|
+
"rename",
|
|
421
|
+
"set",
|
|
422
|
+
"setlocal",
|
|
423
|
+
"start",
|
|
424
|
+
"title",
|
|
425
|
+
"type",
|
|
426
|
+
"ver"
|
|
427
|
+
]);
|
|
428
|
+
/** Builtins of Yarn's portable shell, which work on all platforms */
|
|
429
|
+
const PORTABLE_SHELL_BUILTINS = /* @__PURE__ */ new Set([
|
|
430
|
+
":",
|
|
431
|
+
"cd",
|
|
432
|
+
"echo",
|
|
433
|
+
"exit",
|
|
434
|
+
"false",
|
|
435
|
+
"pwd",
|
|
436
|
+
"sleep",
|
|
437
|
+
"true",
|
|
438
|
+
"unset"
|
|
439
|
+
]);
|
|
440
|
+
/** BSD utilities on macOS that don't support GNU-style long options */
|
|
441
|
+
const NO_LONG_OPTIONS_ON_MACOS = /* @__PURE__ */ new Set([
|
|
442
|
+
"basename",
|
|
443
|
+
"cat",
|
|
444
|
+
"chmod",
|
|
445
|
+
"chown",
|
|
446
|
+
"cp",
|
|
447
|
+
"cut",
|
|
448
|
+
"date",
|
|
449
|
+
"df",
|
|
450
|
+
"dirname",
|
|
451
|
+
"du",
|
|
452
|
+
"install",
|
|
453
|
+
"ln",
|
|
454
|
+
"mkdir",
|
|
455
|
+
"mv",
|
|
456
|
+
"readlink",
|
|
457
|
+
"realpath",
|
|
458
|
+
"rm",
|
|
459
|
+
"rmdir",
|
|
460
|
+
"sed",
|
|
461
|
+
"stat",
|
|
462
|
+
"tee",
|
|
463
|
+
"touch",
|
|
464
|
+
"tr",
|
|
465
|
+
"truncate",
|
|
466
|
+
"uname",
|
|
467
|
+
"wc"
|
|
468
|
+
]);
|
|
469
|
+
/** OS commands rather than npm packages, including those that exist everywhere */
|
|
470
|
+
const OS_COMMANDS = /* @__PURE__ */ new Set([
|
|
471
|
+
...COMMANDS.keys(),
|
|
472
|
+
"cd",
|
|
473
|
+
"echo",
|
|
474
|
+
"exit",
|
|
475
|
+
"mkdir",
|
|
476
|
+
"more",
|
|
477
|
+
"rmdir",
|
|
478
|
+
"sort",
|
|
479
|
+
"timeout"
|
|
480
|
+
]);
|
|
481
|
+
/**
|
|
482
|
+
* Well-known programs that aren't npm packages or OS commands, and don't expand globs in their
|
|
483
|
+
* arguments themselves, e.g. `tar`
|
|
484
|
+
*/
|
|
485
|
+
const NON_GLOB_PROGRAMS = /* @__PURE__ */ new Set([
|
|
486
|
+
"bun",
|
|
487
|
+
"cargo",
|
|
488
|
+
"curl",
|
|
489
|
+
"deno",
|
|
490
|
+
"docker",
|
|
491
|
+
"git",
|
|
492
|
+
"go",
|
|
493
|
+
"java",
|
|
494
|
+
"kubectl",
|
|
495
|
+
"make",
|
|
496
|
+
"node",
|
|
497
|
+
"perl",
|
|
498
|
+
"php",
|
|
499
|
+
"podman",
|
|
500
|
+
"python",
|
|
501
|
+
"python3",
|
|
502
|
+
"ruby",
|
|
503
|
+
"scp",
|
|
504
|
+
"ssh",
|
|
505
|
+
"tar"
|
|
506
|
+
]);
|
|
507
|
+
/** Package manager subcommands that run the command given as their arguments */
|
|
508
|
+
const EXEC_SUBCOMMANDS = {
|
|
509
|
+
aube: ["dlx", "exec"],
|
|
510
|
+
bun: ["x"],
|
|
511
|
+
npm: ["exec", "x"],
|
|
512
|
+
pnpm: ["dlx", "exec"],
|
|
513
|
+
upm: ["exec"],
|
|
514
|
+
yarn: ["dlx", "exec"]
|
|
515
|
+
};
|
|
516
|
+
/** Options of package managers (before the subcommand) that take a value */
|
|
517
|
+
const PACKAGE_MANAGER_VALUE_OPTIONS = [
|
|
518
|
+
"--cd",
|
|
519
|
+
"--cwd",
|
|
520
|
+
"--dir",
|
|
521
|
+
"--filter",
|
|
522
|
+
"--filter-prod",
|
|
523
|
+
"--prefix",
|
|
524
|
+
"--workspace",
|
|
525
|
+
"-C",
|
|
526
|
+
"-F"
|
|
527
|
+
];
|
|
528
|
+
/** Options of npm (before its subcommand) that take a value, unlike pnpm's `-w` */
|
|
529
|
+
const NPM_VALUE_OPTIONS = [...PACKAGE_MANAGER_VALUE_OPTIONS, "-w"];
|
|
530
|
+
/** Options of package managers' exec subcommands that take a value */
|
|
531
|
+
const EXEC_VALUE_OPTIONS = ["--package", "-p"];
|
|
532
|
+
/** Options of `npm exec` and `npx` that take a value */
|
|
533
|
+
const NPM_EXEC_VALUE_OPTIONS = [
|
|
534
|
+
...EXEC_VALUE_OPTIONS,
|
|
535
|
+
"--workspace",
|
|
536
|
+
"-w"
|
|
537
|
+
];
|
|
538
|
+
/** Options of GNU `timeout` that take a value */
|
|
539
|
+
const TIMEOUT_VALUE_OPTIONS = [
|
|
540
|
+
"--kill-after",
|
|
541
|
+
"--signal",
|
|
542
|
+
"-k",
|
|
543
|
+
"-s"
|
|
544
|
+
];
|
|
545
|
+
/** Commands whose arguments are often patterns rather than paths */
|
|
546
|
+
const PATTERN_COMMANDS = /* @__PURE__ */ new Set([
|
|
547
|
+
"awk",
|
|
548
|
+
"echo",
|
|
549
|
+
"egrep",
|
|
550
|
+
"findstr",
|
|
551
|
+
"grep",
|
|
552
|
+
"printf",
|
|
553
|
+
"sed"
|
|
554
|
+
]);
|
|
555
|
+
/** Commands that run the command given as their arguments, with their options that take a value */
|
|
556
|
+
const WRAPPER_VALUE_OPTIONS = /* @__PURE__ */ new Map([
|
|
557
|
+
["aubx", EXEC_VALUE_OPTIONS],
|
|
558
|
+
["bunx", EXEC_VALUE_OPTIONS],
|
|
559
|
+
["command", []],
|
|
560
|
+
["env", [
|
|
561
|
+
"--chdir",
|
|
562
|
+
"--split-string",
|
|
563
|
+
"--unset",
|
|
564
|
+
"-C",
|
|
565
|
+
"-S",
|
|
566
|
+
"-u"
|
|
567
|
+
]],
|
|
568
|
+
["exec", ["-a"]],
|
|
569
|
+
["nice", ["--adjustment", "-n"]],
|
|
570
|
+
["nohup", []],
|
|
571
|
+
["npx", NPM_EXEC_VALUE_OPTIONS],
|
|
572
|
+
["pnpx", EXEC_VALUE_OPTIONS],
|
|
573
|
+
["sudo", [
|
|
574
|
+
"-C",
|
|
575
|
+
"-D",
|
|
576
|
+
"-g",
|
|
577
|
+
"-h",
|
|
578
|
+
"-p",
|
|
579
|
+
"-r",
|
|
580
|
+
"-t",
|
|
581
|
+
"-U",
|
|
582
|
+
"-u"
|
|
583
|
+
]],
|
|
584
|
+
["time", ["-f", "-o"]],
|
|
585
|
+
["upx", EXEC_VALUE_OPTIONS],
|
|
586
|
+
["xargs", [
|
|
587
|
+
"-a",
|
|
588
|
+
"-d",
|
|
589
|
+
"-E",
|
|
590
|
+
"-I",
|
|
591
|
+
"-L",
|
|
592
|
+
"-n",
|
|
593
|
+
"-P",
|
|
594
|
+
"-s"
|
|
595
|
+
]]
|
|
596
|
+
]);
|
|
597
|
+
/**
|
|
598
|
+
* Builtins that change or use the state of the shell that runs them.
|
|
599
|
+
* They don't work the same in a subshell, or when another command runs them, e.g. `cross-env`
|
|
600
|
+
*/
|
|
601
|
+
const SHELL_STATE_COMMANDS = /* @__PURE__ */ new Set([
|
|
602
|
+
".",
|
|
603
|
+
"alias",
|
|
604
|
+
"builtin",
|
|
605
|
+
"cd",
|
|
606
|
+
"command",
|
|
607
|
+
"declare",
|
|
608
|
+
"eval",
|
|
609
|
+
"exec",
|
|
610
|
+
"exit",
|
|
611
|
+
"export",
|
|
612
|
+
"getopts",
|
|
613
|
+
"let",
|
|
614
|
+
"local",
|
|
615
|
+
"mapfile",
|
|
616
|
+
"popd",
|
|
617
|
+
"pushd",
|
|
618
|
+
"read",
|
|
619
|
+
"readarray",
|
|
620
|
+
"readonly",
|
|
621
|
+
"return",
|
|
622
|
+
"set",
|
|
623
|
+
"shift",
|
|
624
|
+
"shopt",
|
|
625
|
+
"source",
|
|
626
|
+
"trap",
|
|
627
|
+
"typeset",
|
|
628
|
+
"ulimit",
|
|
629
|
+
"umask",
|
|
630
|
+
"unalias",
|
|
631
|
+
"unset",
|
|
632
|
+
"wait"
|
|
633
|
+
]);
|
|
634
|
+
/**
|
|
635
|
+
* Shell builtins that Yarn's portable shell doesn't have, and that have no executables that work
|
|
636
|
+
* the same, e.g. `export`
|
|
637
|
+
*/
|
|
638
|
+
const NON_PORTABLE_BUILTINS = new Set([...SHELL_STATE_COMMANDS, ...EXACT_NAME_BUILTINS].filter((name) => !PORTABLE_SHELL_BUILTINS.has(name) && name !== "command" && name !== "set"));
|
|
639
|
+
export { CMD_BUILTINS, COMMANDS, EXACT_NAME_BUILTINS, EXEC_SUBCOMMANDS, EXEC_VALUE_OPTIONS, NON_GLOB_PROGRAMS, NON_PORTABLE_BUILTINS, NO_LONG_OPTIONS_ON_MACOS, NPM_EXEC_VALUE_OPTIONS, NPM_VALUE_OPTIONS, OS_COMMANDS, PACKAGE_MANAGER_VALUE_OPTIONS, PATTERN_COMMANDS, PORTABLE_SHELL_BUILTINS, POSIX_SHELL_BUILTINS, SHELLS, SHELL_STATE_COMMANDS, TIMEOUT_VALUE_OPTIONS, WRAPPER_VALUE_OPTIONS };
|
package/dist/context.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/context.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets where a node of a piece of the script is in the analyzed script.
|
|
4
|
+
* @param context The piece that the node is in
|
|
5
|
+
* @param node The node, with positions relative to the piece's source
|
|
6
|
+
* @returns The range in the analyzed script, or the piece's fixed range
|
|
7
|
+
*/
|
|
8
|
+
const rangeInScript = (context, node) => context.fixedRange || {
|
|
9
|
+
end: context.offset + node.end,
|
|
10
|
+
pos: context.offset + node.pos
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Gets the text of a node as the script has it, e.g. with `$OUT` instead of its placeholder.
|
|
14
|
+
* @param context The piece of the script that the node is in
|
|
15
|
+
* @param node The node, with positions relative to the piece's source
|
|
16
|
+
* @returns The text
|
|
17
|
+
*/
|
|
18
|
+
const originalText = (context, node) => context.originalSource.slice(node.pos, node.end);
|
|
19
|
+
const withCovered = (context, platforms) => platforms.every((platform) => context.covered.has(platform)) ? context : {
|
|
20
|
+
...context,
|
|
21
|
+
covered: /* @__PURE__ */ new Set([...context.covered, ...platforms])
|
|
22
|
+
};
|
|
23
|
+
/** Gets how reports name Bash syntax of a kind, e.g. "Bash 4" for Bash 4 syntax */
|
|
24
|
+
const bashLabel = (kind) => kind === "bash4" ? "Bash 4" : "Bash-specific";
|
|
25
|
+
export { bashLabel, originalText, rangeInScript, withCovered };
|
package/dist/fixes.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "unbash";
|
|
2
|
+
import { ScriptFix } from "./reporter.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Applies a fix to the script that it was found in.
|
|
5
|
+
* @param script Text of the script to change
|
|
6
|
+
* @param fix A fix from `analyzeScript`
|
|
7
|
+
* @returns The fixed script
|
|
8
|
+
*/
|
|
9
|
+
export declare const applyFix: (script: string, fix: ScriptFix) => string;
|