Skip to content

Commit 0331eae

Browse files
committed
feat: setup cli
1 parent 2a7c609 commit 0331eae

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# what-the-dep
22

33
compile time async dependency injection plugin
4+
5+
## Installation
6+
7+
```
8+
bun install @softnetics/what-the-dep
9+
```

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"types": "dist/index.d.ts",
66
"module": "dist/index.js",
77
"license": "MIT",
8+
"bin": {
9+
"what-the-dep": "dist/create.js"
10+
},
811
"homepage": "https://github.com/softnetics/what-the-dep",
912
"bugs": {
1013
"url": "https://github.com/softnetics/what-the-dep"

src/create.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import fs from "fs";
2+
import path from "path";
3+
4+
const rootPath = path.resolve(import.meta.dir, "..", "..");
5+
const configPath = path.join(rootPath, "bunfig.toml");
6+
7+
const pluginPreloadConfig = `
8+
preload = ['./what-the-dep.ts']
9+
`;
10+
11+
if (!fs.existsSync(configPath)) {
12+
fs.writeFileSync(configPath, pluginPreloadConfig);
13+
} else {
14+
fs.appendFileSync(configPath, pluginPreloadConfig);
15+
}
16+
17+
fs.writeFileSync(
18+
path.join(rootPath, "what-the-dep.ts"),
19+
`
20+
import { whatTheDep } from "@softnetics/what-the-dep";
21+
import { plugin } from "bun";
22+
23+
plugin(whatTheDep())
24+
`
25+
);
26+
27+
fs.writeFileSync(
28+
path.join(rootPath, "build.ts"),
29+
`
30+
import { whatTheDep } from "@softnetics/what-the-dep";
31+
32+
await Bun.build({
33+
// edit to your entrypoints
34+
entrypoints: ["src/index.ts"],
35+
// edit to your outdir
36+
outdir: "dist/out",
37+
target: "bun",
38+
plugins: [whatTheDep()],
39+
})
40+
`
41+
);
42+
43+
console.info(
44+
'what-the-dep is initialized! 🎉 \n Don\'t for get to add script \n \n "build":"bun run build.ts" \n \n In your package.json'
45+
);

tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from "tsup";
22

33
export default defineConfig({
4-
entry: ["src/index.ts"],
4+
entry: ["src/index.ts", "src/create.ts"],
55
splitting: true,
66
minify: true,
77
clean: true,

0 commit comments

Comments
 (0)