mirror of
https://github.com/swc-project/swc.git
synced 2024-10-26 17:13:09 +03:00
feat(swc-info): Add a CLI to help issue reporting (#7871)
This commit is contained in:
parent
7911973020
commit
d6952ea687
5
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
5
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -30,6 +30,11 @@ body:
|
||||
attributes:
|
||||
label: Playground link
|
||||
description: You can use [swc playground](https://play.swc.rs/) to create a reproduction link, then paste the link here.
|
||||
- type: input
|
||||
id: swc-info
|
||||
attributes:
|
||||
label: SWC Info output
|
||||
description: Please run `npx -y swc-info@latest` and paste the output here.
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
|
8
packages/swc-info/.gitignore
vendored
Normal file
8
packages/swc-info/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
yarn.lock
|
||||
node_modules
|
||||
_/
|
||||
*.tgz
|
||||
lib/*.js
|
||||
tests/*.js
|
||||
*.d.ts
|
||||
*.map
|
10
packages/swc-info/.npmignore
Normal file
10
packages/swc-info/.npmignore
Normal file
@ -0,0 +1,10 @@
|
||||
examples/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
*.log
|
||||
.swcrc
|
||||
.yarn
|
||||
*.tgz
|
||||
.dprint.json
|
||||
out/
|
||||
tests/
|
9
packages/swc-info/README.md
Normal file
9
packages/swc-info/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# swc-info
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
npx -y swc-info@latest
|
||||
```
|
||||
|
||||
then copy the output to the issue;.
|
2
packages/swc-info/bin/swc-info.js
Executable file
2
packages/swc-info/bin/swc-info.js
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require("../lib/index.js");
|
71
packages/swc-info/lib/index.ts
Normal file
71
packages/swc-info/lib/index.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import os from "node:os";
|
||||
import process from "node:process";
|
||||
import childProcess from "child_process";
|
||||
|
||||
function getUniqueCpuNames(): string {
|
||||
return os
|
||||
.cpus()
|
||||
.map((cpu) => cpu.model)
|
||||
.filter((model, index, models) => models.indexOf(model) === index)
|
||||
.join(", ");
|
||||
}
|
||||
|
||||
function getBinaryVersion(binaryName: string): string {
|
||||
try {
|
||||
return childProcess
|
||||
.execFileSync(binaryName, ["--version"])
|
||||
.toString()
|
||||
.trim();
|
||||
} catch {
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
function getPackageVersion(packageName: string) {
|
||||
try {
|
||||
return require(`${packageName}/package.json`).version;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function interestingPackage(name: string): string | null {
|
||||
const version = getPackageVersion(name);
|
||||
if (version) {
|
||||
return `${name}: ${version}`;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function interestingPackages(names: string[]): string {
|
||||
return names.map(interestingPackage).filter(Boolean).join("\n ");
|
||||
}
|
||||
|
||||
console.log(`
|
||||
Operating System:
|
||||
Platform: ${os.platform()}
|
||||
Arch: ${os.arch()}
|
||||
Machine Type: ${os.machine()}
|
||||
Version: ${os.version()}
|
||||
CPU: (${os.cpus().length} cores)
|
||||
Models: ${getUniqueCpuNames()}
|
||||
|
||||
Binaries:
|
||||
Node: ${process.versions.node}
|
||||
npm: ${getBinaryVersion("npm")}
|
||||
Yarn: ${getBinaryVersion("yarn")}
|
||||
pnpm: ${getBinaryVersion("pnpm")}
|
||||
|
||||
Relevant Packages:
|
||||
@swc/core: ${getPackageVersion("@swc/core") ?? "N/A"}
|
||||
@swc/helpers: ${getPackageVersion("@swc/helpers") ?? "N/A"}
|
||||
@swc/types: ${getPackageVersion("@swc/types") ?? "N/A"}
|
||||
${interestingPackages(["typescript", "next"])}
|
||||
|
||||
SWC Config:
|
||||
output: N/A
|
||||
.swcrc path: N/A
|
||||
|
||||
Next.js info:
|
||||
output: N/A
|
||||
`);
|
37
packages/swc-info/package.json
Normal file
37
packages/swc-info/package.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "swc-info",
|
||||
"packageManager": "yarn@3.2.3",
|
||||
"version": "0.1.11",
|
||||
"description": "CLI tool to help issue reporting for swc",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "yarn build",
|
||||
"prepack": "yarn build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/swc-project/swc.git"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
},
|
||||
"keywords": [
|
||||
"swc",
|
||||
"info",
|
||||
"cli"
|
||||
],
|
||||
"author": "강동윤 <kdy1997.dev@gmail.com>",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/swc-project/swc/issues"
|
||||
},
|
||||
"homepage": "https://swc.rs",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"bin": {
|
||||
"swc-info": "bin/swc-info.js"
|
||||
}
|
||||
}
|
25
packages/swc-info/tsconfig.json
Normal file
25
packages/swc-info/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2019",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "commonjs",
|
||||
"baseUrl": "./",
|
||||
"paths": {},
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"downlevelIteration": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": [
|
||||
"lib",
|
||||
"tests"
|
||||
],
|
||||
"exclude": [
|
||||
"examples"
|
||||
]
|
||||
}
|
@ -28,6 +28,6 @@
|
||||
"homepage": "https://swc.rs",
|
||||
"packageManager": "yarn@3.2.3",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@swc/types@workspace:types"
|
||||
dependencies:
|
||||
typescript: ^5.1.6
|
||||
typescript: ^5.2.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@ -611,6 +611,14 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"swc-info@workspace:swc-info":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "swc-info@workspace:swc-info"
|
||||
dependencies:
|
||||
typescript: ^5.2.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"through@npm:2, through@npm:~2.3, through@npm:~2.3.1":
|
||||
version: 2.3.8
|
||||
resolution: "through@npm:2.3.8"
|
||||
@ -634,23 +642,23 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@npm:^5.1.6":
|
||||
version: 5.1.6
|
||||
resolution: "typescript@npm:5.1.6"
|
||||
"typescript@npm:^5.2.2":
|
||||
version: 5.2.2
|
||||
resolution: "typescript@npm:5.2.2"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: b2f2c35096035fe1f5facd1e38922ccb8558996331405eb00a5111cc948b2e733163cc22fab5db46992aba7dd520fff637f2c1df4996ff0e134e77d3249a7350
|
||||
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@^5.1.6#~builtin<compat/typescript>":
|
||||
version: 5.1.6
|
||||
resolution: "typescript@patch:typescript@npm%3A5.1.6#~builtin<compat/typescript>::version=5.1.6&hash=a1c5e5"
|
||||
"typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
|
||||
version: 5.2.2
|
||||
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=a1c5e5"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 21e88b0a0c0226f9cb9fd25b9626fb05b4c0f3fddac521844a13e1f30beb8f14e90bd409a9ac43c812c5946d714d6e0dee12d5d02dfc1c562c5aacfa1f49b606
|
||||
checksum: 07106822b4305de3f22835cbba949a2b35451cad50888759b6818421290ff95d522b38ef7919e70fb381c5fe9c1c643d7dea22c8b31652a717ddbd57b7f4d554
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user