package-json-scripts-portability 0.0.0 → 0.0.1

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2026 andreww2012
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,235 @@
1
- # package-json-scripts-portability
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `package-json-scripts-portability`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
1
+ # package-json-scripts-portability [![npm](https://img.shields.io/npm/v/package-json-scripts-portability)](https://npmx.dev/package-json-scripts-portability)
2
+
3
+ Finds package.json scripts that don't work the same on Windows, macOS and Linux, and suggests fixes.
4
+ Package managers run scripts with cmd.exe on Windows and with `sh` elsewhere, and `sh` differs too: it's dash on Debian/Ubuntu and Bash 3.2 on macOS.
5
+
6
+ - 🖥️ **Every platform**: cmd.exe on Windows, Bash 3.2 and BSD tools on macOS, dash and GNU tools on Linux.
7
+ - 🔍 **Commands, syntax and options**: `rm`, `open`, `FOO=1 cmd`, `$VAR`, single quotes, `;`, `&`, `[[ ... ]]`, `sed -i`, `mkdir -p`, `%VAR%`, backslash paths and many more.
8
+ - 🪆 **Nested scripts**: also checks what `sh -c`, [cross-env], [concurrently], `npx` and the like run.
9
+ - 🔀 **Fallbacks**: `rm -rf dist || rmdir /s /q dist` works everywhere, so it's not reported.
10
+ - 🔧 **Safe fixes**: only when the script keeps working the same way, e.g. `rimraf dist` for `rm -rf dist`.
11
+ - 📦 **Package managers**: npm, pnpm, Yarn, aube, upm and `node --run`, including the quirks of Yarn v1 and the portable shell of Yarn v2+.
12
+ - 🔒 **Static**: parses the scripts with [unbash] and never runs them.
13
+
14
+ ## Examples
15
+
16
+ | Script | Breaks on | Why | Fix |
17
+ | ------------------------------ | -------------- | ----------------------------------------------------------- | --------------------------------------- |
18
+ | `rm -rf dist` | Windows | There's no `rm` | `rimraf dist` |
19
+ | `NODE_ENV=production webpack` | Windows | cmd.exe doesn't support inline environment variables | `cross-env NODE_ENV=production webpack` |
20
+ | `eslint 'src/**/*.ts'` | Windows | cmd.exe passes the single quotes on to the command | `eslint "src/**/*.ts"` |
21
+ | `tsc; vite build` | Windows | cmd.exe doesn't support `;` | `tsc && vite build` |
22
+ | `npm run a & npm run b` | Windows | cmd.exe runs the commands one by one | |
23
+ | `node x.js > /dev/null` | Windows | There's no `/dev/null` | `node x.js` |
24
+ | `mkdir -p dist/assets` | Windows | cmd.exe's `mkdir` doesn't support `-p` | |
25
+ | `open http://localhost:3000` | Linux, Windows | `open` only exists on macOS | |
26
+ | `sed -i 's/a/b/' file.txt` | macOS, Windows | BSD `sed -i` requires a backup suffix, Windows has no `sed` | |
27
+ | `sh -c "[[ -f x ]] && node x"` | Linux, Windows | dash doesn't support `[[ ... ]]`, Windows has no `sh` | |
28
+ | `node scripts\build.js` | macOS, Linux | POSIX shells treat backslashes as escape characters | `node scripts/build.js` |
29
+ | `if exist dist rd /s /q dist` | macOS, Linux | It's cmd.exe syntax | |
30
+
31
+ The scripts are shown as they are after JSON decoding: in package.json, `node scripts\build.js` is written as `"node scripts\\build.js"`.
32
+
33
+ ## Usage
34
+
35
+ ```sh
36
+ pnpm i package-json-scripts-portability
37
+ ```
38
+
39
+ Replace `pnpm i` with the installation command of your package manager.
40
+
41
+ Node.js 22.23.1+, 24.18.0+ or 26.4.0+ is required.
42
+
43
+ ```ts
44
+ import {analyzeScript, applyFix, formatPlatforms} from 'package-json-scripts-portability';
45
+
46
+ const script = 'rm -rf dist';
47
+
48
+ analyzeScript(script).forEach((issue) => {
49
+ // {
50
+ // messageId: 'unsupportedCommand',
51
+ // data: {command: 'rm', suggestion: 'Use `rimraf` instead.'},
52
+ // platforms: ['win32'],
53
+ // pos: 0,
54
+ // end: 2,
55
+ // fix: {description: 'Replace `rm -rf` with `rimraf`.', edits: [{pos: 0, end: 6, text: 'rimraf'}]},
56
+ // runners: ['npm'],
57
+ // }
58
+
59
+ script.slice(issue.pos, issue.end); // 'rm'
60
+ formatPlatforms(issue.platforms); // 'Windows'
61
+
62
+ if (issue.fix) {
63
+ applyFix(script, issue.fix); // 'rimraf dist'
64
+ }
65
+ });
66
+ ```
67
+
68
+ ### Checking a package.json
69
+
70
+ Pass the dependencies and tell what runs the scripts:
71
+
72
+ ```ts
73
+ import {readFile} from 'node:fs/promises';
74
+ import {
75
+ type AnalyzeScriptOptions,
76
+ analyzeScript,
77
+ formatPlatforms,
78
+ getRunner,
79
+ } from 'package-json-scripts-portability';
80
+
81
+ const packageJson = JSON.parse(await readFile('package.json', 'utf8'));
82
+ // e.g. `pnpm@10.0.0`, or `yarn@1.22.22` for Yarn v1
83
+ const packageManager: string = packageJson.packageManager || '';
84
+ const [name = '', version] = packageManager.split('@', 2);
85
+ const options: AnalyzeScriptOptions = {
86
+ dependencies: Object.keys({...packageJson.dependencies, ...packageJson.devDependencies}),
87
+ runner: getRunner(name, version),
88
+ };
89
+
90
+ Object.entries<string>(packageJson.scripts || {}).forEach(([scriptName, script]) => {
91
+ analyzeScript(script, options).forEach((issue) => {
92
+ const text = script.slice(issue.pos, issue.end);
93
+ console.log(`${scriptName}: \`${text}\` breaks on ${formatPlatforms(issue.platforms)}`);
94
+ });
95
+ });
96
+ ```
97
+
98
+ ### Messages
99
+
100
+ Issues don't contain ready-made messages: `messageId` tells the kind of the issue, and `data` has the parts of the message.
101
+ `platforms` and `runners` aren't in `data`, so that you can format them yourself, for example with `formatPlatforms` and `formatRunners`.
102
+
103
+ | `messageId` | `data` | Example message |
104
+ | ---------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
105
+ | `unsupportedCommand` | `command`, `suggestion` | `rm` is not available on Windows. Use `rimraf` instead. |
106
+ | `unsupportedSyntax` | `syntax`, `suggestion` | The `;` command separator is not supported on Windows. Use `&&` instead. |
107
+ | `unsupportedUsage` | `usage`, `reason`, `suggestion` | `mkdir -p` is not supported on Windows: cmd.exe's `mkdir` doesn't support POSIX options. Use a Node.js script instead. |
108
+ | `inconsistentBehavior` | `syntax`, `reason`, `suggestion` | The `&` operator works differently on Windows: cmd.exe runs the commands sequentially instead of in the background. Use `concurrently` instead. |
109
+
110
+ These messages come from the following templates.
111
+ They use ESLint's placeholder syntax, so in an ESLint rule you can pass them as `meta.messages` and the `data` below to `context.report()`.
112
+
113
+ ```ts
114
+ import {
115
+ type ScriptIssue,
116
+ type ScriptIssueMessageId,
117
+ formatPlatforms,
118
+ } from 'package-json-scripts-portability';
119
+
120
+ const MESSAGES: Readonly<Record<ScriptIssueMessageId, string>> = {
121
+ inconsistentBehavior: '{{syntax}} works differently on {{platforms}}: {{reason}}. {{suggestion}}',
122
+ unsupportedCommand: '`{{command}}` is not available on {{platforms}}. {{suggestion}}',
123
+ unsupportedSyntax: '{{syntax}} is not supported on {{platforms}}. {{suggestion}}',
124
+ unsupportedUsage: '`{{usage}}` is not supported on {{platforms}}: {{reason}}. {{suggestion}}',
125
+ };
126
+ const PLACEHOLDER = /\{\{(\w+)\}\}/g;
127
+
128
+ const formatIssue = (issue: ScriptIssue) => {
129
+ const data: Record<string, string> = {...issue.data, platforms: formatPlatforms(issue.platforms)};
130
+ return MESSAGES[issue.messageId].replaceAll(PLACEHOLDER, (_, key: string) => data[key] || '');
131
+ };
132
+ ```
133
+
134
+ ## Package managers
135
+
136
+ By default, the scripts are checked as npm runs them: with `sh` on macOS and Linux, and with cmd.exe on Windows.
137
+ If something else runs them, set `runner`, e.g. with [`getRunner`](#api) from the `packageManager` field.
138
+ It decides which shell runs the scripts and which environment variables they get.
139
+ For example, unlike npm and pnpm v10, pnpm v11+ doesn't set `HOME`, which Windows doesn't set either, and `node --run` doesn't set `npm_*` variables.
140
+
141
+ | Scripts are run by | Options |
142
+ | ------------------ | ------------------------------------------------------------------------------------ |
143
+ | npm | None, or `runner: 'npm'` |
144
+ | pnpm v11+ | `runner: 'pnpm'`, and `shellEmulator: true` if its `shell-emulator` setting is on |
145
+ | pnpm v10 and older | `runner: 'pnpm-10'`, and `shellEmulator: true` if its `shell-emulator` setting is on |
146
+ | [aube] | `runner: 'aube'` |
147
+ | [upm] | `runner: 'upm'` |
148
+ | Yarn v2+ | `runner: 'yarn'` |
149
+ | Yarn v1 | `runner: 'yarn-classic'` |
150
+ | `node --run` | `runner: 'node'` |
151
+ | Bun | None, but the results for Windows only apply to `bun run --shell=system` |
152
+ | Deno or Nub | Not supported yet, as they run the scripts with their own shells |
153
+
154
+ Whatever runs the scripts, the commands that package managers run are checked too, e.g. in `pnpm exec`, `aubx` or `upx`.
155
+
156
+ ### Several runners
157
+
158
+ Pass several runners to report what breaks with any of them, e.g. `runner: ['npm', 'pnpm']`.
159
+ Each issue lists the runners that have it in `runners`, and is on the platforms where any of them has it.
160
+
161
+ ### Runner-agnostic scripts
162
+
163
+ Some scripts can run with any package manager.
164
+ For example, the install scripts of a published package run with the package manager of whoever installs it.
165
+ Pass the script's name in `scriptName`, and such scripts are checked with all package managers instead of `runner`:
166
+
167
+ ```ts
168
+ import {analyzeScript, formatRunners} from 'package-json-scripts-portability';
169
+
170
+ const script = 'cross-env CONFIG=${HOME}/.config node install.js';
171
+
172
+ analyzeScript(script, {runner: 'npm', scriptName: 'postinstall'}).forEach((issue) => {
173
+ formatRunners(issue.runners); // 'aube, pnpm, upm, and Yarn v1', since only npm and pnpm v10 set `HOME`
174
+ });
175
+ ```
176
+
177
+ By default, `preinstall`, `install`, `postinstall` and `prepare` (which runs when the package is installed from git) are runner-agnostic.
178
+ `runnerAgnosticScripts` changes that: `true` makes all scripts runner-agnostic, `false` none, and an object sets it for each script on top of the defaults, e.g. `{prepare: false, release: true}`.
179
+ Install scripts of a private package only run with its own package manager, so pass `runnerAgnosticScripts: false` for one.
180
+
181
+ Runner-agnostic scripts aren't checked with `node --run`, since it doesn't install packages.
182
+
183
+ ## Options
184
+
185
+ | Option | Default | Description |
186
+ | ----------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
187
+ | `dependencies` | `[]` | Names of the package's dependencies. With [del-cli], `del` is reported as cmd.exe's builtin, which takes precedence on Windows. |
188
+ | `ignoreCommands` | `[]` | Commands not to report, e.g. ones that you install on every platform. The commands that they run are still checked. |
189
+ | `runner` | `'npm'` | What runs the scripts, or a list of runners, see [Package managers](#package-managers). |
190
+ | `runnerAgnosticScripts` | Install scripts and `prepare` | Scripts that are checked with all package managers, see [Runner-agnostic scripts](#runner-agnostic-scripts). |
191
+ | `scriptName` | None | The script's name in package.json, e.g. `postinstall`, to tell whether it's runner-agnostic. |
192
+ | `shellEmulator` | `false` | Whether pnpm's `shell-emulator` setting is on, so that it runs the scripts with Yarn's shell. |
193
+
194
+ ## API
195
+
196
+ - `analyzeScript(script, options?)` returns the issues of a script, which are not necessarily sorted by position.
197
+ Each issue has:
198
+ - `messageId` and `data`: see [Messages](#messages).
199
+ - `platforms`: where the script doesn't work as intended, as `process.platform` values: `'darwin'`, `'linux'` or `'win32'`.
200
+ - `pos` and `end`: the offsets of the reported text in the script, `end` excluded.
201
+ - `fix`: a `description` and non-overlapping `edits` (`pos`, `end`, `text`), if the issue has a fix that keeps the script working the same way.
202
+ - `runners`: the runners that have the issue, e.g. `['pnpm', 'yarn-classic']`.
203
+ - `applyFix(script, fix)` returns the script with all edits of a fix applied.
204
+ - `formatPlatforms(platforms)` formats platforms for people, e.g. `'macOS, Linux, and Windows'`.
205
+ - `formatRunners(runners)` formats runners for people, e.g. `'pnpm and Yarn v1'`.
206
+ - `getRunner(name, version?)` gets the `runner` value for a package manager, e.g. from the `packageManager` or `devEngines.packageManager` field: `getRunner('yarn', '1.22.22')` is `'yarn-classic'`.
207
+ It returns `undefined` for other package managers, like Bun, and for Yarn without a version, since Yarn v1 and v2+ run scripts differently.
208
+ For pnpm, it returns `'pnpm-10'` for v10 and older, and `'pnpm'` otherwise, including for no version and for ranges like `>=10`, which allow v11+.
209
+ - `PLATFORMS` is the list of all platforms: `['darwin', 'linux', 'win32']`.
210
+ - `RUNNER_AGNOSTIC_SCRIPTS` is the set of the scripts that are runner-agnostic by default: `preinstall`, `install`, `postinstall` and `prepare`.
211
+ - `RUNNERS` is the list of all `runner` values: `['aube', 'node', 'npm', 'pnpm', 'pnpm-10', 'upm', 'yarn', 'yarn-classic']`.
212
+
213
+ The types `AnalyzeScriptOptions`, `Platform`, `Runner`, `ScriptEdit`, `ScriptFix`, `ScriptIssue` and `ScriptIssueMessageId` are exported too.
214
+
215
+ ## Limitations
216
+
217
+ - Scripts are only parsed, so it doesn't know which commands are installed or which files exist.
218
+ Commands from npm packages, like `rimraf`, are assumed to work everywhere.
219
+ - The scripts of shells (`sh -c`), cross-env, concurrently, `npx`, `npm exec`, `pnpm dlx` and the like, and of commands like `env` and `xargs` are checked.
220
+ Other tools that run commands, like `nodemon --exec`, are not, since each of them takes different options.
221
+ - Unquoted globs are only reported if they contain `**/`: many tools expand simpler globs themselves when the shell doesn't.
222
+ - A script that isn't valid shell syntax is only checked for cmd.exe syntax like `if exist`.
223
+ - `node --run` and upm don't run `pre` and `post` scripts, which isn't checked.
224
+ - Whether the package is private isn't known, so its install scripts are runner-agnostic, unless you tell otherwise.
225
+
226
+ ## License
227
+
228
+ [MIT](./LICENSE.md)
229
+
230
+ [aube]: https://aube.sh
231
+ [concurrently]: https://npmx.dev/concurrently
232
+ [cross-env]: https://npmx.dev/cross-env
233
+ [del-cli]: https://npmx.dev/del-cli
234
+ [unbash]: https://npmx.dev/unbash
235
+ [upm]: https://npmx.dev/upm
@@ -0,0 +1,118 @@
1
+ import "unbash";
2
+ type Platform = 'darwin' | 'linux' | 'win32';
3
+ export declare const PLATFORMS: readonly Platform[];
4
+ /**
5
+ * Formats platforms as a list for people, e.g. "macOS, Linux, and Windows".
6
+ * @param platforms The platforms to format
7
+ * @returns The formatted list
8
+ */
9
+ export declare const formatPlatforms: (platforms: readonly Platform[]) => string;
10
+ /** What can run the scripts: a package manager, or `node` for `node --run` */
11
+ type Runner = 'aube' | 'node' | 'npm' | 'pnpm' | 'pnpm-10' | 'upm' | 'yarn' | 'yarn-classic';
12
+ export declare const RUNNERS: readonly Runner[];
13
+ /**
14
+ * Scripts that run with any package manager by default, as they run on the machine of whoever
15
+ * installs the package: install scripts, and `prepare`, which runs when it's installed from git
16
+ */
17
+ export declare const RUNNER_AGNOSTIC_SCRIPTS: ReadonlySet<string>;
18
+ /**
19
+ * Gets the runner for a package manager, e.g. the one in the `packageManager` or
20
+ * `devEngines.packageManager` field of package.json.
21
+ * @param name Name of the package manager, e.g. `yarn`
22
+ * @param version Its version or version range, which tells Yarn v1 from Yarn v2+, and pnpm v10
23
+ * from later versions, e.g. `1.22.22`
24
+ * @returns The runner, or `undefined` if it's an unknown package manager or Yarn of an unknown
25
+ * version
26
+ */
27
+ export declare const getRunner: (name: string, version?: string) => "aube" | "node" | "npm" | "pnpm" | "pnpm-10" | "upm" | "yarn" | "yarn-classic" | undefined;
28
+ /**
29
+ * Formats runners as a list for people, e.g. "pnpm and Yarn v1".
30
+ * @param runners The runners to format
31
+ * @returns The formatted list
32
+ */
33
+ export declare const formatRunners: (runners: readonly Runner[]) => string;
34
+ /**
35
+ * A value or a readonly array of such values: `T | readonly T[]`.
36
+ *
37
+ * Unlike `MaybeArray`, it also accepts readonly arrays and tuples (like `as const` literals), so
38
+ * it fits parameters and options that only read the array.
39
+ * To tell the two cases apart, use `isArray`: unlike `Array.isArray`, it narrows this type in
40
+ * both branches.
41
+ * @example
42
+ * const watch = (paths: MaybeReadonlyArray<string>) => {
43
+ * const list = isArray(paths) ? paths : [paths]; // readonly string[]
44
+ * // ...
45
+ * };
46
+ *
47
+ * watch('src');
48
+ * watch(['src', 'test'] as const); // an error with `MaybeArray<string>`
49
+ */
50
+ type MaybeReadonlyArray<T> = T | readonly T[];
51
+ type ScriptIssueMessageId = 'inconsistentBehavior' | 'unsupportedCommand' | 'unsupportedSyntax' | 'unsupportedUsage';
52
+ interface ScriptEdit {
53
+ /** End offset (exclusive) of the replaced text in the script */
54
+ end: number;
55
+ /** Start offset of the replaced text in the script */
56
+ pos: number;
57
+ /** The replacement */
58
+ text: string;
59
+ }
60
+ interface ScriptFix {
61
+ /** Describes the fix for people, e.g. "Prefix the command with `cross-env`." */
62
+ description: string;
63
+ /** Replacements that don't overlap */
64
+ edits: ScriptEdit[];
65
+ }
66
+ interface ScriptIssue {
67
+ /** Message data, apart from `platforms` */
68
+ data: Record<string, string>;
69
+ /** End offset (exclusive) of the issue in the script */
70
+ end: number;
71
+ /** A fix that the rule suggests, if the issue has an obvious one */
72
+ fix?: ScriptFix;
73
+ messageId: ScriptIssueMessageId;
74
+ /** Platforms on which the script doesn't work as intended */
75
+ platforms: Platform[];
76
+ /** Start offset of the issue in the script */
77
+ pos: number;
78
+ /** Runners with which the script has the issue */
79
+ runners: Runner[];
80
+ }
81
+ interface AnalyzeScriptOptions {
82
+ /** Names of the package's dependencies, e.g. to detect del-cli's `del` alias */
83
+ dependencies?: readonly string[];
84
+ /** Commands that shouldn't be reported */
85
+ ignoreCommands?: readonly string[];
86
+ /**
87
+ * What runs the script: a package manager, or `node` for `node --run`.
88
+ * It decides e.g. which shell runs the script and which environment variables it gets.
89
+ * Several runners report what breaks with any of them.
90
+ * Defaults to `npm`
91
+ */
92
+ runner?: MaybeReadonlyArray<Runner>;
93
+ /**
94
+ * Scripts that any package manager may run, which are checked with all of them instead of
95
+ * `runner`: `true` for all scripts, `false` for none, or whether each script is, by name, on
96
+ * top of the defaults (`preinstall`, `install`, `postinstall` and `prepare`)
97
+ */
98
+ runnerAgnosticScripts?: boolean | Readonly<Record<string, boolean>>;
99
+ /** The script's name in package.json, e.g. `postinstall`, to tell if it's runner-agnostic */
100
+ scriptName?: string;
101
+ /** Whether pnpm's `shell-emulator` setting is on, so that it runs the script with Yarn's shell */
102
+ shellEmulator?: boolean;
103
+ }
104
+ /**
105
+ * Analyzes a package.json script for constructs that don't work (the same) on all platforms.
106
+ * @param script The script's source
107
+ * @param options Analysis options
108
+ * @returns The issues found, with offsets relative to the script
109
+ */
110
+ export declare const analyzeScript: (script: string, options?: AnalyzeScriptOptions) => ScriptIssue[];
111
+ /**
112
+ * Applies a fix to the script that it was found in.
113
+ * @param script Text of the script to change
114
+ * @param fix A fix from `analyzeScript`
115
+ * @returns The fixed script
116
+ */
117
+ export declare const applyFix: (script: string, fix: ScriptFix) => string;
118
+ export type { AnalyzeScriptOptions, Platform, Runner, ScriptEdit, ScriptFix, ScriptIssue, ScriptIssueMessageId };