diff --git a/packages/init/deno.json b/packages/init/deno.json index 9aa0e8a9..983b0517 100644 --- a/packages/init/deno.json +++ b/packages/init/deno.json @@ -2,7 +2,10 @@ "name": "@fresh/init", "version": "2.3.0", "license": "MIT", - "exports": "./src/mod.ts", + "exports": { + ".": "./src/mod.ts", + "./create": "./src/create.ts" + }, "exclude": ["**/tmp/*"], "publish": { "include": [ diff --git a/packages/init/src/create.ts b/packages/init/src/create.ts new file mode 100644 index 00000000..ce6cc9f4 --- /dev/null +++ b/packages/init/src/create.ts @@ -0,0 +1,26 @@ +import { parseArgs } from "@std/cli/parse-args"; +import { initProject } from "./init.ts"; +import { InitError } from "./init.ts"; + +const flags = parseArgs(Deno.args, { + boolean: ["force", "tailwind", "vscode", "docker", "help", "builder"], + default: { + force: null, + tailwind: null, + vscode: null, + docker: null, + builder: null, + }, + alias: { + help: "h", + }, +}); + +try { + await initProject(Deno.cwd(), flags._, flags); +} catch (err) { + if (err instanceof InitError) { + Deno.exit(1); + } + throw err; +} diff --git a/packages/init/src/mod.ts b/packages/init/src/mod.ts index ce6cc9f4..ecba5561 100644 --- a/packages/init/src/mod.ts +++ b/packages/init/src/mod.ts @@ -2,6 +2,12 @@ import { parseArgs } from "@std/cli/parse-args"; import { initProject } from "./init.ts"; import { InitError } from "./init.ts"; +// deno-lint-ignore no-console +console.warn( + "\x1b[33m%s\x1b[0m", + `Warning: "deno run -Ar jsr:@fresh/init" is deprecated. Use "deno create @fresh/init" instead.`, +); + const flags = parseArgs(Deno.args, { boolean: ["force", "tailwind", "vscode", "docker", "help", "builder"], default: {