create-mushi-mushi 0.4.0 → 0.5.0
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 +36 -8
- package/dist/index.js +67 -24
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -10,9 +10,17 @@ yarn create mushi-mushi
|
|
|
10
10
|
bun create mushi-mushi
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## What it does
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
1. **Detects your framework** — Next.js, Nuxt, SvelteKit, Angular, Expo, Capacitor, plain React/Vue/Svelte, or vanilla JS.
|
|
16
|
+
2. **Picks the right SDK** — `@mushi-mushi/react`, `@mushi-mushi/vue`, `@mushi-mushi/svelte`, `@mushi-mushi/angular`, `@mushi-mushi/react-native`, `@mushi-mushi/capacitor`, or `@mushi-mushi/web`.
|
|
17
|
+
3. **Detects your package manager** — uses `npm`, `pnpm`, `yarn`, or `bun` based on your lockfile.
|
|
18
|
+
4. **Writes env vars** — `MUSHI_PROJECT_ID` and `MUSHI_API_KEY` land in `.env.local` with the right framework prefix (`NEXT_PUBLIC_`, `NUXT_PUBLIC_`, `VITE_`).
|
|
19
|
+
5. **Warns about `.gitignore`** — won't ship secrets if your env file isn't ignored.
|
|
20
|
+
6. **Prints the provider snippet** — framework-specific code to paste in.
|
|
21
|
+
7. **Sends a test report** (opt-in) — closes the loop so you see your first classified bug immediately.
|
|
22
|
+
|
|
23
|
+
This is a **scaffold for existing projects** — it does not generate a new app from scratch. Run it from the project root of an existing app.
|
|
16
24
|
|
|
17
25
|
## Flags
|
|
18
26
|
|
|
@@ -20,22 +28,42 @@ This is a **scaffold for existing projects** — it does not generate a new app
|
|
|
20
28
|
npm create mushi-mushi -- --framework next
|
|
21
29
|
npm create mushi-mushi -- --project-id proj_xxx --api-key mushi_xxx
|
|
22
30
|
npm create mushi-mushi -- --skip-install
|
|
31
|
+
npm create mushi-mushi -- --skip-test-report
|
|
32
|
+
npm create mushi-mushi -- --cwd apps/web
|
|
33
|
+
npm create mushi-mushi -- --endpoint https://mushi.your-company.com
|
|
23
34
|
npm create mushi-mushi -- -y
|
|
24
35
|
npm create mushi-mushi -- --help
|
|
25
36
|
```
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
> `npm create` and `pnpm create` need the `--` separator before flags. Yarn 1 and Bun do not.
|
|
39
|
+
|
|
40
|
+
## Equivalent commands
|
|
28
41
|
|
|
29
42
|
```bash
|
|
30
|
-
npx mushi-mushi #
|
|
31
|
-
npx @mushi-mushi/cli init #
|
|
43
|
+
npx mushi-mushi # shorter
|
|
44
|
+
npx @mushi-mushi/cli init # scoped name
|
|
32
45
|
```
|
|
33
46
|
|
|
47
|
+
## Troubleshooting
|
|
48
|
+
|
|
49
|
+
- **Wrong framework detected?** Pass `--framework <id>` explicitly. Valid IDs: `next, react, vue, nuxt, svelte, sveltekit, angular, expo, react-native, capacitor, vanilla`.
|
|
50
|
+
- **Running in a monorepo?** `cd` into the package you want Mushi in first, or pass `--cwd apps/web`.
|
|
51
|
+
- **`npx` cache serving an old version?** Run `npm cache clean --force` or `npx mushi-mushi@latest`.
|
|
52
|
+
- **Non-interactive (CI)?** Pass all of `--yes`, `--project-id`, and `--api-key`. The wizard exits with a clear error otherwise.
|
|
53
|
+
- **Key pasted with quotes/whitespace?** The wizard strips them, but still validates against `mushi_[A-Za-z0-9_-]{10,}` / `proj_[A-Za-z0-9_-]{10,}`.
|
|
54
|
+
|
|
55
|
+
## Security
|
|
56
|
+
|
|
57
|
+
- Credentials accepted via `--api-key` flag leak into `ps -ef`. Prefer the interactive prompt on dev machines; on CI, pass them via the environment and an explicit `--api-key "$MUSHI_API_KEY"` at the boundary.
|
|
58
|
+
- The `~/.mushirc` credentials cache is written with mode `0o600` (owner read/write only) on Unix.
|
|
59
|
+
- All env-file writes strip CR/LF/NUL from secrets to prevent accidental `.env` injection.
|
|
60
|
+
|
|
34
61
|
## Links
|
|
35
62
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
63
|
+
- [Console](https://kensaur.us/mushi-mushi/)
|
|
64
|
+
- [GitHub](https://github.com/kensaurus/mushi-mushi)
|
|
65
|
+
- [Docs](https://github.com/kensaurus/mushi-mushi#readme)
|
|
66
|
+
- [Report a bug](https://github.com/kensaurus/mushi-mushi/issues)
|
|
39
67
|
|
|
40
68
|
## License
|
|
41
69
|
|
package/dist/index.js
CHANGED
|
@@ -2,44 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { runInit } from "@mushi-mushi/cli/init";
|
|
5
|
+
import { FRAMEWORK_IDS, isFrameworkId } from "@mushi-mushi/cli/detect";
|
|
6
|
+
var VERSION = true ? "0.5.0" : "0.0.0-dev";
|
|
7
|
+
var MIN_NODE_MAJOR = 18;
|
|
8
|
+
var ISSUES_URL = "https://github.com/kensaurus/mushi-mushi/issues";
|
|
5
9
|
var HELP = `create-mushi-mushi \u2014 add Mushi Mushi to your existing project
|
|
6
10
|
|
|
7
11
|
Usage:
|
|
8
12
|
npm create mushi-mushi run the setup wizard
|
|
9
13
|
npm create mushi-mushi -- --help show all flags
|
|
10
14
|
|
|
15
|
+
Note: \`npm create\` requires the \`--\` separator before flags.
|
|
16
|
+
\`yarn create mushi-mushi --help\` works without it on Yarn 1.
|
|
17
|
+
\`pnpm create mushi-mushi -- --help\` mirrors npm.
|
|
18
|
+
\`bun create mushi-mushi --help\` works without it.
|
|
19
|
+
|
|
11
20
|
Flags (forwarded to the wizard):
|
|
12
21
|
--project-id <id> skip the project ID prompt
|
|
13
|
-
--api-key <key> skip the API key prompt
|
|
14
|
-
--framework <id> force a framework (
|
|
15
|
-
svelte, sveltekit, angular, expo,
|
|
16
|
-
react-native, capacitor, vanilla)
|
|
22
|
+
--api-key <key> skip the API key prompt (CI only)
|
|
23
|
+
--framework <id> force a framework (${FRAMEWORK_IDS.join(", ")})
|
|
17
24
|
--skip-install print the install command instead of running it
|
|
25
|
+
--skip-test-report don't offer to send a test report at the end
|
|
26
|
+
--cwd <path> run in a different directory
|
|
27
|
+
--endpoint <url> override the Mushi API endpoint (self-hosted)
|
|
18
28
|
-y, --yes accept the detected framework without prompting
|
|
29
|
+
-v, --version print the version and exit
|
|
19
30
|
|
|
20
31
|
Docs: https://github.com/kensaurus/mushi-mushi
|
|
21
32
|
Console: https://kensaur.us/mushi-mushi/`;
|
|
22
|
-
var VALID_FRAMEWORKS = [
|
|
23
|
-
"next",
|
|
24
|
-
"react",
|
|
25
|
-
"vue",
|
|
26
|
-
"nuxt",
|
|
27
|
-
"svelte",
|
|
28
|
-
"sveltekit",
|
|
29
|
-
"angular",
|
|
30
|
-
"expo",
|
|
31
|
-
"react-native",
|
|
32
|
-
"capacitor",
|
|
33
|
-
"vanilla"
|
|
34
|
-
];
|
|
35
33
|
function parseArgs(args) {
|
|
36
|
-
const out = { showHelp: false };
|
|
34
|
+
const out = { showHelp: false, showVersion: false };
|
|
37
35
|
for (let i = 0; i < args.length; i++) {
|
|
38
36
|
const a = args[i];
|
|
39
37
|
if (a === "-h" || a === "--help") {
|
|
40
38
|
out.showHelp = true;
|
|
41
39
|
continue;
|
|
42
40
|
}
|
|
41
|
+
if (a === "-v" || a === "--version") {
|
|
42
|
+
out.showVersion = true;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
43
45
|
if (a === "-y" || a === "--yes") {
|
|
44
46
|
out.yes = true;
|
|
45
47
|
continue;
|
|
@@ -48,6 +50,10 @@ function parseArgs(args) {
|
|
|
48
50
|
out.skipInstall = true;
|
|
49
51
|
continue;
|
|
50
52
|
}
|
|
53
|
+
if (a === "--skip-test-report") {
|
|
54
|
+
out.skipTestReport = true;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
51
57
|
if (a === "--project-id") {
|
|
52
58
|
out.projectId = args[++i];
|
|
53
59
|
continue;
|
|
@@ -56,10 +62,18 @@ function parseArgs(args) {
|
|
|
56
62
|
out.apiKey = args[++i];
|
|
57
63
|
continue;
|
|
58
64
|
}
|
|
65
|
+
if (a === "--cwd") {
|
|
66
|
+
out.cwd = args[++i];
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (a === "--endpoint") {
|
|
70
|
+
out.endpoint = args[++i];
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
59
73
|
if (a === "--framework") {
|
|
60
74
|
const fw = args[++i];
|
|
61
|
-
if (!
|
|
62
|
-
throw new Error(`Unknown framework: ${fw}. Valid: ${
|
|
75
|
+
if (!isFrameworkId(fw)) {
|
|
76
|
+
throw new Error(`Unknown framework: ${fw}. Valid: ${FRAMEWORK_IDS.join(", ")}`);
|
|
63
77
|
}
|
|
64
78
|
out.framework = fw;
|
|
65
79
|
continue;
|
|
@@ -70,16 +84,33 @@ function parseArgs(args) {
|
|
|
70
84
|
}
|
|
71
85
|
return out;
|
|
72
86
|
}
|
|
87
|
+
function assertNodeVersion() {
|
|
88
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
89
|
+
if (!Number.isFinite(major) || major < MIN_NODE_MAJOR) {
|
|
90
|
+
process.stderr.write(
|
|
91
|
+
`create-mushi-mushi requires Node.js ${MIN_NODE_MAJOR} or newer. You are on ${process.versions.node}.
|
|
92
|
+
Upgrade Node (https://nodejs.org/) and try again.
|
|
93
|
+
`
|
|
94
|
+
);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
73
98
|
async function main() {
|
|
99
|
+
assertNodeVersion();
|
|
74
100
|
let parsed;
|
|
75
101
|
try {
|
|
76
102
|
parsed = parseArgs(process.argv.slice(2));
|
|
77
103
|
} catch (err) {
|
|
78
|
-
|
|
104
|
+
process.stderr.write(`${err instanceof Error ? err.message : String(err)}
|
|
105
|
+
`);
|
|
79
106
|
process.exit(1);
|
|
80
107
|
}
|
|
81
108
|
if (parsed.showHelp) {
|
|
82
|
-
|
|
109
|
+
process.stdout.write(HELP + "\n");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (parsed.showVersion) {
|
|
113
|
+
process.stdout.write(VERSION + "\n");
|
|
83
114
|
return;
|
|
84
115
|
}
|
|
85
116
|
await runInit({
|
|
@@ -87,10 +118,22 @@ async function main() {
|
|
|
87
118
|
apiKey: parsed.apiKey,
|
|
88
119
|
framework: parsed.framework,
|
|
89
120
|
skipInstall: parsed.skipInstall,
|
|
90
|
-
yes: parsed.yes
|
|
121
|
+
yes: parsed.yes,
|
|
122
|
+
cwd: parsed.cwd,
|
|
123
|
+
endpoint: parsed.endpoint,
|
|
124
|
+
sendTestReport: parsed.skipTestReport ? false : void 0
|
|
91
125
|
});
|
|
92
126
|
}
|
|
93
127
|
main().catch((err) => {
|
|
94
|
-
|
|
128
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
129
|
+
process.stderr.write(`
|
|
130
|
+
create-mushi-mushi: ${message}
|
|
131
|
+
`);
|
|
132
|
+
if (process.env.DEBUG?.includes("mushi") && err instanceof Error && err.stack) {
|
|
133
|
+
process.stderr.write(err.stack + "\n");
|
|
134
|
+
}
|
|
135
|
+
process.stderr.write(`
|
|
136
|
+
If this is a bug, please report it at ${ISSUES_URL}
|
|
137
|
+
`);
|
|
95
138
|
process.exit(1);
|
|
96
139
|
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mushi-mushi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Run `npm create mushi-mushi` to add the Mushi Mushi bug-reporting SDK to your existing project — the wizard auto-detects your framework (React, Vue, Svelte, Angular, React Native, Expo, Capacitor) and installs the right package.",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-mushi-mushi": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@mushi-mushi/cli": "^0.
|
|
10
|
+
"@mushi-mushi/cli": "^0.5.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/node": "^22.15.3",
|
|
14
14
|
"eslint": "^10.2.0",
|
|
15
15
|
"tsup": "^8.5.1",
|
|
16
16
|
"typescript": "^6.0.2",
|
|
17
|
+
"vitest": "^4.1.4",
|
|
17
18
|
"@mushi-mushi/eslint-config": "0.0.0"
|
|
18
19
|
},
|
|
19
20
|
"author": "Kenji Sakuramoto",
|
|
@@ -26,8 +27,13 @@
|
|
|
26
27
|
"bugs": {
|
|
27
28
|
"url": "https://github.com/kensaurus/mushi-mushi/issues"
|
|
28
29
|
},
|
|
30
|
+
"funding": {
|
|
31
|
+
"type": "github",
|
|
32
|
+
"url": "https://github.com/sponsors/kensaurus"
|
|
33
|
+
},
|
|
29
34
|
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
31
37
|
},
|
|
32
38
|
"files": [
|
|
33
39
|
"dist",
|
|
@@ -66,6 +72,7 @@
|
|
|
66
72
|
"scripts": {
|
|
67
73
|
"build": "tsup",
|
|
68
74
|
"lint": "eslint src/",
|
|
75
|
+
"test": "vitest run",
|
|
69
76
|
"typecheck": "tsc --noEmit"
|
|
70
77
|
}
|
|
71
78
|
}
|