@emohk/bun-generator 1.0.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright 2026 Ronald Mak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @emohk/bun-generator
2
+
3
+ A generator for creating Bun projects.
4
+
5
+ It does the following things:
6
+
7
+ - Create a project by `bun init`.
8
+ - Install `prettier`.
9
+ - Add a `prettier` configuration file.
10
+ - Add a build script.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install -g @emohk/bun-generator
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```bash
21
+ create-bun-app <project-name>
22
+ ```
23
+
24
+ <project-name> is optional. You can enter it later.
25
+
26
+ ## Development
27
+
28
+ To install dependencies:
29
+
30
+ ```bash
31
+ bun install
32
+ ```
33
+
34
+ To run:
35
+
36
+ ```bash
37
+ bun run index.ts
38
+ ```
39
+
40
+ Written by Ronald Mak on 4th March 2026.
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var E=(A)=>typeof A==="string"&&A.trim().length>0;var V=async(A,y=[],O={})=>{let h=Bun.spawn([A,...y],O),v=await h.stdout.text();console.log(v),await h.exited},D=async()=>{let y=Bun.argv.slice(2)[0]??"";if(!E(y)){process.stdout.write("Enter project name: ");for await(let H of console){if(E(H)){y=H;break}process.stdout.write("Enter project name: ")}}console.log(`
4
+ Creating project: ${y}`),await V("bun",["init",y,"-y"]),console.log(`Installing prettier
5
+ `),await V("bun",["add","-d","prettier"],{cwd:y}),console.log("Downloading prettier config");let O=".prettierrc.json",h=`https://raw.githubusercontent.com/emocreation/common-resources/refs/heads/main/${O}`,v=await fetch(h);if(v.ok)console.log("Saving prettier config"),await Bun.write(`${y}/${O}`,v);else console.error("Failed to download prettier config from URL:",h);console.log("Creating build configuration file");let w="build.ts",z=`await Bun.build({
6
+ entrypoints: ['./index.ts'],
7
+ outdir: './dist',
8
+ target: 'bun',
9
+ minify: true
10
+ })`;await Bun.write(`${y}/${w}`,z);let G=`${y}/package.json`,x=await Bun.file(G).json();x.scripts={...x.scripts,test:"bun run index.ts",build:"bun run build.ts"},await Bun.write(G,JSON.stringify(x,null,2)),console.log("Done")};D();
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@emohk/bun-generator",
3
+ "version": "1.0.0",
4
+ "description": "A generator for creating Bun projects",
5
+ "type": "module",
6
+ "scripts": {
7
+ "test": "bun run index.ts",
8
+ "build": "bun run build.ts",
9
+ "prepublishOnly": "bun run build"
10
+ },
11
+ "bin": {
12
+ "create-bun-app": "./dist/index.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/emocreation/bun-generator.git"
22
+ },
23
+ "devDependencies": {
24
+ "@types/bun": "latest",
25
+ "prettier": "^3.8.1"
26
+ },
27
+ "peerDependencies": {
28
+ "typescript": "^5"
29
+ },
30
+ "dependencies": {
31
+ "@emohk/utils": "^1.0.0"
32
+ },
33
+ "author": "Ronald Mak",
34
+ "license": "MIT"
35
+ }