swytchcode 2.20.15 → 2.20.16
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 +4 -0
- package/package.json +11 -7
- package/scripts/postinstall.js +43 -0
package/README.md
CHANGED
|
@@ -40,6 +40,10 @@ npm install -g swytchcode
|
|
|
40
40
|
|
|
41
41
|
The correct binary for your platform (macOS, Linux, Windows - x64 and arm64) is selected automatically.
|
|
42
42
|
|
|
43
|
+
> **Security & Execution Policy Note (Windows):** The npm package uses a `postinstall` script to delete the `.ps1` wrapper files generated by npm. This forces PowerShell to fall back to the `.cmd` wrapper, bypassing the default `Restricted` execution policy so the CLI runs out of the box.
|
|
44
|
+
> - **Scanners:** Automated supply-chain scanners (e.g. Socket.dev) may flag this postinstall script because it deletes files outside the package directory. This is benign and limited only to removing the npm-generated shims.
|
|
45
|
+
> - **--ignore-scripts:** If you install with `npm install -g swytchcode --ignore-scripts` (or have it set in your config), the postinstall cleanup won't run. You can run the CLI by explicitly invoking `swytchcode.cmd` (or `swy.cmd`). To use the unqualified `swytchcode` command in PowerShell, you must explicitly opt in by running `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`.
|
|
46
|
+
|
|
43
47
|
## Usage
|
|
44
48
|
|
|
45
49
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swytchcode",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.16",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://gitlab.com/swytchcode/cli.git"
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"bin/swytchcode.js",
|
|
28
|
+
"scripts/postinstall.js",
|
|
28
29
|
"README.md"
|
|
29
30
|
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"postinstall": "node ./scripts/postinstall.js"
|
|
33
|
+
},
|
|
30
34
|
"optionalDependencies": {
|
|
31
|
-
"swytchcode-cli-darwin-arm64": "2.20.
|
|
32
|
-
"swytchcode-cli-darwin-x64": "2.20.
|
|
33
|
-
"swytchcode-cli-linux-arm64": "2.20.
|
|
34
|
-
"swytchcode-cli-linux-x64": "2.20.
|
|
35
|
-
"swytchcode-cli-win32-arm64": "2.20.
|
|
36
|
-
"swytchcode-cli-win32-x64": "2.20.
|
|
35
|
+
"swytchcode-cli-darwin-arm64": "2.20.16",
|
|
36
|
+
"swytchcode-cli-darwin-x64": "2.20.16",
|
|
37
|
+
"swytchcode-cli-linux-arm64": "2.20.16",
|
|
38
|
+
"swytchcode-cli-linux-x64": "2.20.16",
|
|
39
|
+
"swytchcode-cli-win32-arm64": "2.20.16",
|
|
40
|
+
"swytchcode-cli-win32-x64": "2.20.16"
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
function cleanPs1Shims() {
|
|
6
|
+
// Only run on Windows
|
|
7
|
+
if (process.platform !== 'win32') {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Only run for global installs
|
|
12
|
+
if (process.env.npm_config_global !== 'true') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Get the global npm prefix (which is where the shim files are placed on Windows)
|
|
17
|
+
let prefix = process.env.npm_config_prefix;
|
|
18
|
+
if (!prefix) {
|
|
19
|
+
try {
|
|
20
|
+
prefix = execSync('npm prefix -g', { encoding: 'utf8' }).trim();
|
|
21
|
+
} catch (_) {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!prefix) return;
|
|
25
|
+
|
|
26
|
+
const shims = ['swytchcode.ps1', 'swy.ps1'];
|
|
27
|
+
|
|
28
|
+
for (const shim of shims) {
|
|
29
|
+
try {
|
|
30
|
+
const shimPath = path.join(prefix, shim);
|
|
31
|
+
if (fs.existsSync(shimPath)) {
|
|
32
|
+
fs.unlinkSync(shimPath);
|
|
33
|
+
// We delete the .ps1 files so that PowerShell falls back to executing
|
|
34
|
+
// the .cmd files instead. The .cmd files are not subject to PowerShell's
|
|
35
|
+
// Execution Policy (which defaults to Restricted and blocks .ps1 files).
|
|
36
|
+
}
|
|
37
|
+
} catch (_) {
|
|
38
|
+
// Best-effort removal. Silently continue if something goes wrong (e.g. file lock, permissions)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
cleanPs1Shims();
|