This commit is contained in:
Jarred Sumner
2021-10-16 23:49:39 -07:00
parent dcc29d3db6
commit e63fbcefe9
4 changed files with 22 additions and 8 deletions

View File

@@ -421,8 +421,6 @@ At the time of writing, `bun create react app` runs ~11x faster on my local comp
#### Usage
By default, templates are downloaded from folders inside `examples/` in Bun's GitHub repo. Running `bun create react ./local-path` downloads the `react` folder from `examples/react`.
Create a new Next.js project:
```bash
@@ -447,6 +445,16 @@ To see a list of examples, run:
bun create
```
Format:
```bash
bun create github-user/repo-name destination
bun create local-example-or-remote-example destination
bun create /absolute/path/to-template-folder destination
bun create https://github.com/github-user/repo-name destination
bun create github.com/github-user/repo-name destination
```
Note: you don't need `bun create` to use Bun. You don't need any configuration at all. This command exists to make it a little easier.
##### Local templates
@@ -569,6 +577,9 @@ ELSE IF local template
3. Copy files recursively using the fastest system calls available (on macOS `fcopyfile` and Linux, `copy_file_range`). Do not copy or traverse into `node_modules` folder if exists (this alone makes it faster than `cp`)
4. Parse the `package.json` (again!), update `name` to be `${basename(destination)}`, remove the `bun-create` section from the `package.json` and save the updated `package.json` to disk.
- IF Next.js is detected, add `bun-framework-next` to the list of imports
- IF Create React App is detected, add the entry point in /src/index.{js,jsx,ts,tsx} to `public/index.html`
- IF Relay is detected, add `bun-macro-relay` so that Relay works
5. Auto-detect the npm client, preferring `pnpm`, `yarn` (v1), and lastly `npm`
6. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
7. Run `${npmClient} install` unless `--no-install` is passed OR no dependencies are in package.json

View File

@@ -4,5 +4,5 @@
},
"name": "bun-cli-darwin-x64",
"repository": "https://github.com/jarred-sumner/bun",
"version": "0.0.35"
"version": "0.0.36"
}

View File

@@ -9,5 +9,5 @@
"postinstall": "node postinstall.js",
"prepublishOnly": "rm -rf ./bin/bun; chmod +x ./reset-bin.js; cp ./reset-bin.js ./bin/bun"
},
"version": "0.0.35"
"version": "0.0.36"
}

View File

@@ -1467,10 +1467,12 @@ pub const CreateCommand = struct {
std.os.ftruncate(package_json_file.?.handle, written + 1) catch {};
if (needs.bun_bun_for_nextjs) {
try postinstall_tasks.append(ctx.allocator, InjectionPrefill.bun_bun_for_nextjs_task);
} else if (bun_bun_for_react_scripts) {
try postinstall_tasks.append(ctx.allocator, try std.fmt.allocPrint(ctx.allocator, "bun bun {s}", .{create_react_app_entry_point_path}));
if (!create_options.skip_install) {
if (needs.bun_bun_for_nextjs) {
try postinstall_tasks.append(ctx.allocator, InjectionPrefill.bun_bun_for_nextjs_task);
} else if (bun_bun_for_react_scripts) {
try postinstall_tasks.append(ctx.allocator, try std.fmt.allocPrint(ctx.allocator, "bun bun {s}", .{create_react_app_entry_point_path}));
}
}
}
}
@@ -1669,6 +1671,7 @@ pub const CreateCommand = struct {
\\ <b><cyan>cd {s}<r>
\\ <b><cyan>bun<r>
\\
\\
, .{
filesystem.relativeTo(destination),
});