create-h3ravel 0.3.2 → 0.4.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/bin/run.cjs CHANGED
@@ -153,12 +153,11 @@ var actions_default = class {
153
153
  });
154
154
  }
155
155
  async complete() {
156
- const packageManager = await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm";
157
156
  console.log("");
158
157
  __h3ravel_shared.Logger.success("Your h3ravel project has been created successfully");
159
158
  __h3ravel_shared.Logger.parse([["cd " + (0, node_path.relative)(process.cwd(), this.location), "cyan"]]);
160
- __h3ravel_shared.Logger.parse([[`${packageManager} run dev`, "cyan"]]);
161
- __h3ravel_shared.Logger.parse([["Open http://localhost:4444", "cyan"]]);
159
+ __h3ravel_shared.Logger.parse([[`npx musket fire`, "cyan"]]);
160
+ __h3ravel_shared.Logger.parse([["Open http://localhost:3000", "cyan"]]);
162
161
  console.log("");
163
162
  __h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
164
163
  __h3ravel_shared.Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
package/bin/run.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.cjs","names":["location?: string","appName?: string","description?: string","Command","Argument","AbortPromptError","ExitPromptError","Actions","Logger"],"sources":["../src/templates.ts","../src/scripts.ts","../src/actions.ts","../src/logo.ts","../src/run.ts"],"sourcesContent":["/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","export const mainTsconfig = {\n extends: \"@h3ravel/shared/tsconfig.json\",\n compilerOptions: {\n baseUrl: \".\",\n outDir: \"dist\",\n paths: {\n \"src/*\": [\"./../src/*\"],\n \"App/*\": [\"./../src/app/*\"],\n \"root/*\": [\"./../*\"],\n \"routes/*\": [\"./../src/routes/*\"],\n \"config/*\": [\"./../src/config/*\"],\n \"resources/*\": [\"./../src/resources/*\"]\n },\n target: \"es2022\",\n module: \"es2022\",\n moduleResolution: \"Node\",\n esModuleInterop: true,\n strict: true,\n allowJs: true,\n skipLibCheck: true,\n resolveJsonModule: true,\n noEmit: true,\n experimentalDecorators: true,\n emitDecoratorMetadata: true\n },\n include: [\"./**/*.d.ts\", \"./../**/*\"],\n exclude: [\"./dist\", \"./node_modules\"]\n}\n\nexport const baseTsconfig = {\n extends: \"./.h3ravel/tsconfig.json\"\n}\n\nexport const packageJsonScript = {\n build: \"NODE_ENV=production tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n dev: \"NODE_ENV=development pnpm tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n start: \"DIST_DIR=dist node -r source-map-support/register dist/server.js\",\n lint: \"eslint . --ext .ts\",\n test: \"NODE_NO_WARNINGS=1 NODE_ENV=testing jest --passWithNoTests\",\n}\n","import { baseTsconfig, mainTsconfig, packageJsonScript } from \"./scripts\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Logger } from \"@h3ravel/shared\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { slugify } from \"@h3ravel/support\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string) {\n if (this.location?.includes('.temp')) {\n await rm(this.location!, { force: true, recursive: true })\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete () {\n const packageManager = (await detectPackageManager()) ?? 'npm'\n\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd ' + relative(process.cwd(), this.location!), 'cyan']])\n Logger.parse([[`${packageManager} run dev`, 'cyan']])\n Logger.parse([['Open http://localhost:4444', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport inquirer from \"inquirer\";\nimport { templates } from './templates';\nimport ora from 'ora';\nimport Actions from './actions';\nimport { basename, join } from 'node:path';\nimport { slugify } from '@h3ravel/support';\nimport { AbortPromptError, ExitPromptError } from '@inquirer/core';\nimport { Logger } from '@h3ravel/shared';\nimport { altLogo } from './logo';\n\nasync function main () {\n const program = new Command();\n\n program\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\n program\n .option(\"-n, --name <string>\", \"The name of your project.\")\n .option('-i, --install', 'Install node_modules right away.')\n .option('-t, --token <string>', 'Kit repo authentication token.')\n .option('-d, --desc <string>', 'Project Description.')\n .option('-k, --kit <string>\", \"Starter template kit')\n .addArgument(new Argument('[location]', 'The location where this project should be created relative to the current dir.'))\n .action(async (pathName, options) => {\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n Logger.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete()\n });\n\n program.parse();\n\n process.on('SIGINT', () => {\n })\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,YAAY;CACrB;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACJ;;;;AC3CD,MAAa,eAAe;CAC1B,SAAS;CACT,iBAAiB;EACf,SAAS;EACT,QAAQ;EACR,OAAO;GACL,SAAS,CAAC,aAAa;GACvB,SAAS,CAAC,iBAAiB;GAC3B,UAAU,CAAC,SAAS;GACpB,YAAY,CAAC,oBAAoB;GACjC,YAAY,CAAC,oBAAoB;GACjC,eAAe,CAAC,uBAAuB;GACxC;EACD,QAAQ;EAC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SAAS;AAEvB,UAAQ,KAAKA,wBAAO,MAAM,CAAC,CAAC,2BAA2B,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AACrF,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,QAAQ,gBAAgB;AAE9B,UAAQ,QAAQA,wBAAO,MAAM,CAAC,CAAC,oCAAoC,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC;AAEzF,QAAM,QAAQ,UAAU;GAC1B;AAEN,SAAQ,OAAO;AAEf,SAAQ,GAAG,gBAAgB,GACzB;;AAGN,MAAM"}
1
+ {"version":3,"file":"run.cjs","names":["location?: string","appName?: string","description?: string","Command","Argument","AbortPromptError","ExitPromptError","Actions","Logger"],"sources":["../src/templates.ts","../src/scripts.ts","../src/actions.ts","../src/logo.ts","../src/run.ts"],"sourcesContent":["/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","export const mainTsconfig = {\n extends: \"@h3ravel/shared/tsconfig.json\",\n compilerOptions: {\n baseUrl: \".\",\n outDir: \"dist\",\n paths: {\n \"src/*\": [\"./../src/*\"],\n \"App/*\": [\"./../src/app/*\"],\n \"root/*\": [\"./../*\"],\n \"routes/*\": [\"./../src/routes/*\"],\n \"config/*\": [\"./../src/config/*\"],\n \"resources/*\": [\"./../src/resources/*\"]\n },\n target: \"es2022\",\n module: \"es2022\",\n moduleResolution: \"Node\",\n esModuleInterop: true,\n strict: true,\n allowJs: true,\n skipLibCheck: true,\n resolveJsonModule: true,\n noEmit: true,\n experimentalDecorators: true,\n emitDecoratorMetadata: true\n },\n include: [\"./**/*.d.ts\", \"./../**/*\"],\n exclude: [\"./dist\", \"./node_modules\"]\n}\n\nexport const baseTsconfig = {\n extends: \"./.h3ravel/tsconfig.json\"\n}\n\nexport const packageJsonScript = {\n build: \"NODE_ENV=production tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n dev: \"NODE_ENV=development pnpm tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n start: \"DIST_DIR=dist node -r source-map-support/register dist/server.js\",\n lint: \"eslint . --ext .ts\",\n test: \"NODE_NO_WARNINGS=1 NODE_ENV=testing jest --passWithNoTests\",\n}\n","import { baseTsconfig, mainTsconfig, packageJsonScript } from \"./scripts\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Logger } from \"@h3ravel/shared\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { slugify } from \"@h3ravel/support\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string) {\n if (this.location?.includes('.temp')) {\n await rm(this.location!, { force: true, recursive: true })\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete () {\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd ' + relative(process.cwd(), this.location!), 'cyan']])\n Logger.parse([[`npx musket fire`, 'cyan']])\n Logger.parse([['Open http://localhost:3000', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport inquirer from \"inquirer\";\nimport { templates } from './templates';\nimport ora from 'ora';\nimport Actions from './actions';\nimport { basename, join } from 'node:path';\nimport { slugify } from '@h3ravel/support';\nimport { AbortPromptError, ExitPromptError } from '@inquirer/core';\nimport { Logger } from '@h3ravel/shared';\nimport { altLogo } from './logo';\n\nasync function main () {\n const program = new Command();\n\n program\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\n program\n .option(\"-n, --name <string>\", \"The name of your project.\")\n .option('-i, --install', 'Install node_modules right away.')\n .option('-t, --token <string>', 'Kit repo authentication token.')\n .option('-d, --desc <string>', 'Project Description.')\n .option('-k, --kit <string>\", \"Starter template kit')\n .addArgument(new Argument('[location]', 'The location where this project should be created relative to the current dir.'))\n .action(async (pathName, options) => {\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n Logger.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete()\n });\n\n program.parse();\n\n process.on('SIGINT', () => {\n })\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,YAAY;CACrB;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACJ;;;;AC3CD,MAAa,eAAe;CAC1B,SAAS;CACT,iBAAiB;EACf,SAAS;EACT,QAAQ;EACR,OAAO;GACL,SAAS,CAAC,aAAa;GACvB,SAAS,CAAC,iBAAiB;GAC3B,UAAU,CAAC,SAAS;GACpB,YAAY,CAAC,oBAAoB;GACjC,YAAY,CAAC,oBAAoB;GACjC,eAAe,CAAC,uBAAuB;GACxC;EACD,QAAQ;EACR,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;EACjB,QAAQ;EACR,SAAS;EACT,cAAc;EACd,mBAAmB;EACnB,QAAQ;EACR,wBAAwB;EACxB,uBAAuB;EACxB;CACD,SAAS,CAAC,eAAe,YAAY;CACrC,SAAS,CAAC,UAAU,iBAAiB;CACtC;AAED,MAAa,eAAe,EAC1B,SAAS,4BACV;AAED,MAAa,oBAAoB;CAC/B,OAAO;CACP,KAAK;CACL,OAAO;CACP,MAAM;CACN,MAAM;CACP;;;;AC5BD,4BAAqB;CACjB;CAEA,YAAY,AAAQA,UAAmB,AAAQC,SAAkB,AAAQC,aAAsB;EAA3E;EAA2B;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ageManager() ?? "npm";
123
122
  console.log("");
124
123
  Logger.success("Your h3ravel project has been created successfully");
125
124
  Logger.parse([["cd " + relative(process.cwd(), this.location), "cyan"]]);
126
- Logger.parse([[`${packageManager} run dev`, "cyan"]]);
127
- Logger.parse([["Open http://localhost:4444", "cyan"]]);
125
+ Logger.parse([[`npx musket fire`, "cyan"]]);
126
+ Logger.parse([["Open http://localhost:3000", "cyan"]]);
128
127
  console.log("");
129
128
  Logger.parse([["Have any questions", "white"]]);
130
129
  Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
package/bin/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","names":["location?: string","appName?: string","description?: string","Actions"],"sources":["../src/templates.ts","../src/scripts.ts","../src/actions.ts","../src/logo.ts","../src/run.ts"],"sourcesContent":["/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","export const mainTsconfig = {\n extends: \"@h3ravel/shared/tsconfig.json\",\n compilerOptions: {\n baseUrl: \".\",\n outDir: \"dist\",\n paths: {\n \"src/*\": [\"./../src/*\"],\n \"App/*\": [\"./../src/app/*\"],\n \"root/*\": [\"./../*\"],\n \"routes/*\": [\"./../src/routes/*\"],\n \"config/*\": [\"./../src/config/*\"],\n \"resources/*\": [\"./../src/resources/*\"]\n },\n target: \"es2022\",\n module: \"es2022\",\n moduleResolution: \"Node\",\n esModuleInterop: true,\n strict: true,\n allowJs: true,\n skipLibCheck: true,\n resolveJsonModule: true,\n noEmit: true,\n experimentalDecorators: true,\n emitDecoratorMetadata: true\n },\n include: [\"./**/*.d.ts\", \"./../**/*\"],\n exclude: [\"./dist\", \"./node_modules\"]\n}\n\nexport const baseTsconfig = {\n extends: \"./.h3ravel/tsconfig.json\"\n}\n\nexport const packageJsonScript = {\n build: \"NODE_ENV=production tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n dev: \"NODE_ENV=development pnpm tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n start: \"DIST_DIR=dist node -r source-map-support/register dist/server.js\",\n lint: \"eslint . --ext .ts\",\n test: \"NODE_NO_WARNINGS=1 NODE_ENV=testing jest --passWithNoTests\",\n}\n","import { baseTsconfig, mainTsconfig, packageJsonScript } from \"./scripts\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Logger } from \"@h3ravel/shared\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { slugify } from \"@h3ravel/support\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string) {\n if (this.location?.includes('.temp')) {\n await rm(this.location!, { force: true, recursive: true })\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete () {\n const packageManager = (await detectPackageManager()) ?? 'npm'\n\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd ' + relative(process.cwd(), this.location!), 'cyan']])\n Logger.parse([[`${packageManager} run dev`, 'cyan']])\n Logger.parse([['Open http://localhost:4444', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport inquirer from \"inquirer\";\nimport { templates } from './templates';\nimport ora from 'ora';\nimport Actions from './actions';\nimport { basename, join } from 'node:path';\nimport { slugify } from '@h3ravel/support';\nimport { AbortPromptError, ExitPromptError } from '@inquirer/core';\nimport { Logger } from '@h3ravel/shared';\nimport { altLogo } from './logo';\n\nasync function main () {\n const program = new Command();\n\n program\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\n program\n .option(\"-n, --name <string>\", \"The name of your project.\")\n .option('-i, --install', 'Install node_modules right away.')\n .option('-t, --token <string>', 'Kit repo authentication token.')\n .option('-d, --desc <string>', 'Project Description.')\n .option('-k, --kit <string>\", \"Starter template kit')\n .addArgument(new Argument('[location]', 'The location where this project should be created relative to the current dir.'))\n .action(async (pathName, options) => {\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n Logger.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete()\n });\n\n program.parse();\n\n process.on('SIGINT', () => {\n })\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAa,YAAY;CACrB;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACJ;;;;AC3CD,MAAa,eAAe;CAC1B,SAAS;CACT,iBAAiB;EACf,SAAS;EACT,QAAQ;EACR,OAAO;GACL,SAAS,CAAC,aAAa;GACvB,SAAS,CAAC,iBAAiB;GAC3B,UAAU,CAAC,SAAS;GACpB,YAAY,CAAC,oBAAoB;GACjC,YAAY,CAAC,oBAAoB;GACjC,eAAe,CAAC,uBAAuB;GACxC;EACD,QAAQ;EACR,QAAQ;EACR,kBAAkB;EAClB,iBAAiB;EACjB,QAAQ;EACR,SAAS;EACT,cAAc;EACd,mBAAmB;EACnB,QAAQ;EACR,wBAAwB;EACxB,uBAAuB;EACxB;CACD,SAAS,CAAC,eAAe,YAAY;CACrC,SAAS,CAAC,UAAU,iBAAiB;CACtC;AAED,MAAa,eAAe,EAC1B,SAAS,4BACV;AAED,MAAa,oBAAoB;CAC/B,OAAO;CACP,KAAK;CACL,OAAO;CACP,MAAM;CACN,MAAM;CACP;;;;AC5BD,4BAAqB;CACjB;CAEA,YAAY,AAAQA,UAAmB,AAAQC,SAAkB,AAAQC,aAAsB;EAA3E;EAA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oCAAoC,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC;AAEzF,QAAM,QAAQ,UAAU;GAC1B;AAEN,SAAQ,OAAO;AAEf,SAAQ,GAAG,gBAAgB,GACzB;;AAGN,MAAM"}
1
+ {"version":3,"file":"run.js","names":["location?: string","appName?: string","description?: string","Actions"],"sources":["../src/templates.ts","../src/scripts.ts","../src/actions.ts","../src/logo.ts","../src/run.ts"],"sourcesContent":["/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","export const mainTsconfig = {\n extends: \"@h3ravel/shared/tsconfig.json\",\n compilerOptions: {\n baseUrl: \".\",\n outDir: \"dist\",\n paths: {\n \"src/*\": [\"./../src/*\"],\n \"App/*\": [\"./../src/app/*\"],\n \"root/*\": [\"./../*\"],\n \"routes/*\": [\"./../src/routes/*\"],\n \"config/*\": [\"./../src/config/*\"],\n \"resources/*\": [\"./../src/resources/*\"]\n },\n target: \"es2022\",\n module: \"es2022\",\n moduleResolution: \"Node\",\n esModuleInterop: true,\n strict: true,\n allowJs: true,\n skipLibCheck: true,\n resolveJsonModule: true,\n noEmit: true,\n experimentalDecorators: true,\n emitDecoratorMetadata: true\n },\n include: [\"./**/*.d.ts\", \"./../**/*\"],\n exclude: [\"./dist\", \"./node_modules\"]\n}\n\nexport const baseTsconfig = {\n extends: \"./.h3ravel/tsconfig.json\"\n}\n\nexport const packageJsonScript = {\n build: \"NODE_ENV=production tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n dev: \"NODE_ENV=development pnpm tsdown --config-loader unconfig -c tsdown.default.config.ts\",\n start: \"DIST_DIR=dist node -r source-map-support/register dist/server.js\",\n lint: \"eslint . --ext .ts\",\n test: \"NODE_NO_WARNINGS=1 NODE_ENV=testing jest --passWithNoTests\",\n}\n","import { baseTsconfig, mainTsconfig, packageJsonScript } from \"./scripts\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Logger } from \"@h3ravel/shared\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { slugify } from \"@h3ravel/support\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string) {\n if (this.location?.includes('.temp')) {\n await rm(this.location!, { force: true, recursive: true })\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete () {\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd ' + relative(process.cwd(), this.location!), 'cyan']])\n Logger.parse([[`npx musket fire`, 'cyan']])\n Logger.parse([['Open http://localhost:3000', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport inquirer from \"inquirer\";\nimport { templates } from './templates';\nimport ora from 'ora';\nimport Actions from './actions';\nimport { basename, join } from 'node:path';\nimport { slugify } from '@h3ravel/support';\nimport { AbortPromptError, ExitPromptError } from '@inquirer/core';\nimport { Logger } from '@h3ravel/shared';\nimport { altLogo } from './logo';\n\nasync function main () {\n const program = new Command();\n\n program\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\n program\n .option(\"-n, --name <string>\", \"The name of your project.\")\n .option('-i, --install', 'Install node_modules right away.')\n .option('-t, --token <string>', 'Kit repo authentication token.')\n .option('-d, --desc <string>', 'Project Description.')\n .option('-k, --kit <string>\", \"Starter template kit')\n .addArgument(new Argument('[location]', 'The location where this project should be created relative to the current dir.'))\n .action(async (pathName, options) => {\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n Logger.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n Logger.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete()\n });\n\n program.parse();\n\n process.on('SIGINT', () => {\n })\n}\n\nmain()\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAa,YAAY;CACrB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,KAAK,iCAAiC;AAC7C,YAAQ,KAAK,EAAE;;AAEnB,UAAO;IACT;AAEF,UAAQ,QAAQ,SAAS;AACzB,YAAU,QAAQ,QAAQ;AAC1B,YAAU,QAAQ,WAAW;AAC7B,aAAW,QAAQ,OAAO;AAC1B,aAAW,YAAY;AACvB,gBAAc,QAAQ,eAAe;EAErC,MAAM,MAAM,UAAU,MAAK,MAAK,EAAE,UAAU,SAAS;AAErD,MAAI,OAAO,CAAC,IAAI,QAAQ;AACpB,UAAO,MAAM,cAAc,IAAI,KAAK,iCAAiC;AACrE,WAAQ,KAAK,EAAE;;EAGnB,MAAM,UAAU,IAAIC,gBAAQ,KAAK,QAAQ,KAAK,EAAE,SAAS,EAAE,SAAS,YAAY;EAEhF,MAAM,UAAU,IAAI,sBAAsB,CAAC,OAAO;AAClD,QAAM,QAAQ,SAAS,KAAK,UAAU,UAAU,QAAQ;AAExD,UAAQ,KAAK,OAAO,MAAM,CAAC,CAAC,kBAAkB,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AAC5E,QAAM,QAAQ,SAAS;AAEvB,UAAQ,KAAK,OAAO,MAAM,CAAC,CAAC,2BAA2B,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AACrF,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,QAAQ,gBAAgB;AAE9B,UAAQ,QAAQ,OAAO,MAAM,CAAC,CAAC,oCAAoC,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC;AAEzF,QAAM,QAAQ,UAAU;GAC1B;AAEN,SAAQ,OAAO;AAEf,SAAQ,GAAG,gBAAgB,GACzB;;AAGN,MAAM"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-h3ravel",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.4.0",
5
5
  "description": "Scaffold a new H3ravel applications using templates and starter kits",
6
6
  "main": "build/index.js",
7
7
  "private": false,