j4k0xb / webcrack

Deobfuscate obfuscator.io, unminify and unpack bundled javascript
https://webcrack.netlify.app
MIT License
1.07k stars 129 forks source link

pnpm install: warning: Failed to create bin at apps/playground/node_modules/.bin/webcrack #58

Closed milahu closed 9 months ago

milahu commented 9 months ago

Describe the bug

when running pnpm install in the repo root pnpm is trying to install packages/webcrack to apps/playground but packages/webcrack is not-yet built at this point

pnpm version 8.15.2 webcrack version e6b584f300886b36b2bb3f5b7044f1aa8f97616c

git clone --depth=1 https://github.com/j4k0xb/webcrack
cd webcrack
pnpm install

WARN  Failed to create bin at apps/playground/node_modules/.bin/webcrack. ENOENT: no such file or directory, open 'packages/webcrack/dist/cli.js'

WARN  Failed to create bin at apps/playground/node_modules/.bin/webcrack. ENOENT: no such file or directory, open 'apps/playground/node_modules/webcrack/dist/cli.js'

workaround

pnpm install --ignore-scripts
npm run build

possible solution

create a wrapper packages/webcrack/src/cli-wrapper.js for packages/webcrack/dist/cli.js

commit 70500eb14a9c9f1660caad0596cff288ce102ff3
Author: Milan Hauth <milahu@gmail.com>
Date:   Tue Feb 13 14:41:48 2024 +0100

    use bin wrapper

diff --git a/packages/webcrack/package.json b/packages/webcrack/package.json
index f5816c0..6db5072 100644
--- a/packages/webcrack/package.json
+++ b/packages/webcrack/package.json
@@ -7,7 +7,7 @@
   "type": "module",
   "main": "dist/index.js",
   "types": "dist/index.d.ts",
-  "bin": "dist/cli.js",
+  "bin": "src/cli-wrapper.js",
   "files": [
     "dist"
   ],
diff --git a/packages/webcrack/src/cli-wrapper.js b/packages/webcrack/src/cli-wrapper.js
new file mode 100755
index 0000000..dc4b410
--- /dev/null
+++ b/packages/webcrack/src/cli-wrapper.js
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+import "../dist/cli.js"

Expected Behaviour

no warnings

Code

no

Logs

No response

j4k0xb commented 9 months ago

the cli isn't needed for the playground but would be nice to get rid of the warning either way wanna create a PR with that wrapper? have to include it in https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files because src isn't published or use https://pnpm.io/package_json#publishconfig with "bin": "dist/cli.js"

pionxzh commented 9 months ago

publishconfig should be the right tool for this unless you want to bind webcrack as an executable in the dev environment.