Skip to content

Commit b790c80

Browse files
bartlomiejuclaude
andauthored
feat: support deno create for project initialization (#3706)
## Summary - Add a `./create` export to `@fresh/init` so users can scaffold projects with `deno create @fresh/init` (Deno 2.7+) - The old `deno run -Ar jsr:@fresh/init` continues to work but now shows a deprecation warning **New way (Deno 2.7+):** ```sh deno create @fresh/init ``` **Old way (still works, with warning):** ```sh deno run -Ar jsr:@fresh/init ``` Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 214975d commit b790c80

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

packages/init/deno.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"name": "@fresh/init",
33
"version": "2.3.0",
44
"license": "MIT",
5-
"exports": "./src/mod.ts",
5+
"exports": {
6+
".": "./src/mod.ts",
7+
"./create": "./src/create.ts"
8+
},
69
"exclude": ["**/tmp/*"],
710
"publish": {
811
"include": [

packages/init/src/create.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { parseArgs } from "@std/cli/parse-args";
2+
import { initProject } from "./init.ts";
3+
import { InitError } from "./init.ts";
4+
5+
const flags = parseArgs(Deno.args, {
6+
boolean: ["force", "tailwind", "vscode", "docker", "help", "builder"],
7+
default: {
8+
force: null,
9+
tailwind: null,
10+
vscode: null,
11+
docker: null,
12+
builder: null,
13+
},
14+
alias: {
15+
help: "h",
16+
},
17+
});
18+
19+
try {
20+
await initProject(Deno.cwd(), flags._, flags);
21+
} catch (err) {
22+
if (err instanceof InitError) {
23+
Deno.exit(1);
24+
}
25+
throw err;
26+
}

packages/init/src/mod.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { parseArgs } from "@std/cli/parse-args";
22
import { initProject } from "./init.ts";
33
import { InitError } from "./init.ts";
44

5+
// deno-lint-ignore no-console
6+
console.warn(
7+
"\x1b[33m%s\x1b[0m",
8+
`Warning: "deno run -Ar jsr:@fresh/init" is deprecated. Use "deno create @fresh/init" instead.`,
9+
);
10+
511
const flags = parseArgs(Deno.args, {
612
boolean: ["force", "tailwind", "vscode", "docker", "help", "builder"],
713
default: {

0 commit comments

Comments
 (0)