create-h3ravel 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Framework][ix]][lx]
4
4
  [![Create H3ravel][i1]][l1]
5
+ [![Downloads][d1]][d1]
5
6
 
6
7
  # About Create H3ravel
7
8
 
@@ -88,7 +89,7 @@ npm init h3ravel -- --kit="github:github_user/repo" --token="github_token"
88
89
 
89
90
  ## Contributing
90
91
 
91
- Thank you for considering contributing to the H3ravel framework! The contribution guide can be found in the [H3ravel documentation](#!).
92
+ Thank you for considering contributing to the H3ravel framework! The [Contribution Guide](https://h3ravel.toneflix.net/contributing) can be found in the H3ravel documentation and will provide you with all the information you need to get started.
92
93
 
93
94
  ## Code of Conduct
94
95
 
@@ -105,4 +106,5 @@ The H3ravel framework and all it's base packages are open-sourced software licen
105
106
  [ix]: https://img.shields.io/npm/v/%40h3ravel%2Fcore?style=flat-square&label=Framework&color=%230970ce
106
107
  [lx]: https://www.npmjs.com/package/@h3ravel/core
107
108
  [i1]: https://img.shields.io/npm/v/create-h3ravel?style=flat-square&label=create-h3ravel&color=%230970ce
108
- [l1]: https://www.npmjs.com/package/@h3ravel/create-h3ravel
109
+ [l1]: https://www.npmjs.com/package/create-h3ravel
110
+ [d1]: https://img.shields.io/npm/dt/create-h3ravel?style=flat-square&label=Downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fcreate-h3ravel
package/bin/run.cjs CHANGED
@@ -66,6 +66,57 @@ var templates = [
66
66
  // src/run.ts
67
67
  var import_ora = __toESM(require("ora"), 1);
68
68
 
69
+ // src/tsconfig.ts
70
+ var mainTsconfig = {
71
+ extends: "@h3ravel/shared/tsconfig.json",
72
+ compilerOptions: {
73
+ baseUrl: ".",
74
+ outDir: "dist",
75
+ paths: {
76
+ "src/*": [
77
+ "./../src/*"
78
+ ],
79
+ "App/*": [
80
+ "./../src/app/*"
81
+ ],
82
+ "root/*": [
83
+ "./../*"
84
+ ],
85
+ "routes/*": [
86
+ "./../src/routes/*"
87
+ ],
88
+ "config/*": [
89
+ "./../src/config/*"
90
+ ],
91
+ "resources/*": [
92
+ "./../src/resources/*"
93
+ ]
94
+ },
95
+ target: "es2022",
96
+ module: "es2022",
97
+ moduleResolution: "Node",
98
+ esModuleInterop: true,
99
+ strict: true,
100
+ allowJs: true,
101
+ skipLibCheck: true,
102
+ resolveJsonModule: true,
103
+ noEmit: true,
104
+ experimentalDecorators: true,
105
+ emitDecoratorMetadata: true
106
+ },
107
+ include: [
108
+ "./**/*.d.ts",
109
+ "./../**/*"
110
+ ],
111
+ exclude: [
112
+ "./dist",
113
+ "./node_modules"
114
+ ]
115
+ };
116
+ var baseTsconfig = {
117
+ extends: "./.h3ravel/tsconfig.json"
118
+ };
119
+
69
120
  // src/actions.ts
70
121
  var import_node_path = require("path");
71
122
  var import_promises = require("fs/promises");
@@ -124,6 +175,7 @@ var actions_default = class {
124
175
  console.log("");
125
176
  console.log(`Have any questions?`);
126
177
  console.log(`Join our Discord server - ${import_chalk.default.yellow("https://discord.gg/hsG2A8PuGb")}`);
178
+ console.log(`Checkout the documentation - ${import_chalk.default.yellow("https://h3ravel.toneflix.net")}`);
127
179
  }
128
180
  async cleanup() {
129
181
  const pkgPath = (0, import_node_path.join)(this.location, "package.json");
@@ -168,6 +220,14 @@ var actions_default = class {
168
220
  await (0, import_promises.copyFile)(exampleEnvPath, envPath);
169
221
  }
170
222
  }
223
+ async createTsConfig() {
224
+ const tscPath = (0, import_node_path.join)(this.location, ".h3ravel");
225
+ await (0, import_promises.mkdir)(tscPath, {
226
+ recursive: true
227
+ });
228
+ await (0, import_promises.writeFile)((0, import_node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(mainTsconfig, null, 2));
229
+ await (0, import_promises.writeFile)((0, import_node_path.join)(this.location, "tsconfig.json"), JSON.stringify(baseTsconfig, null, 2));
230
+ }
171
231
  };
172
232
 
173
233
  // src/run.ts
@@ -241,9 +301,10 @@ program.option("-n, --name <string>", "The name of your project.").option("-i, -
241
301
  await actions.download(kit?.source ?? template, install);
242
302
  spinner.info(import_chalk2.default.green("Cleaning Up...")).start();
243
303
  await actions.cleanup();
244
- spinner.info(import_chalk2.default.green("Creating .env...")).start();
304
+ spinner.info(import_chalk2.default.green("Initializing Project...")).start();
245
305
  await actions.copyExampleEnv();
246
- spinner.succeed(import_chalk2.default.green("Template Downloaded!"));
306
+ await actions.createTsConfig();
307
+ spinner.succeed(import_chalk2.default.green("Project initialized successfully!"));
247
308
  await actions.complete();
248
309
  });
249
310
  program.parse();
package/bin/run.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/run.ts","../src/templates.ts","../src/actions.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport chalk from 'chalk';\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';\n\nconst program = new Command();\n\nprogram\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\nprogram\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 let { appName, description } = await inquirer\n .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 when: () => !options.desc,\n }]\n )\n\n let { template, install, location, token } = await inquirer\n .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 },\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 console.log(chalk.bgRed(' Error: '), chalk.red(`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(chalk.green(\"Cleaning Up...\")).start();\n await actions.cleanup()\n\n spinner.info(chalk.green(\"Creating .env...\")).start();\n await actions.copyExampleEnv()\n\n spinner.succeed(chalk.green('Template Downloaded!'))\n\n await actions.complete()\n });\n\nprogram.parse();\n","/*\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","import { basename, join, relative } from \"node:path\";\nimport { copyFile, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport chalk from \"chalk\";\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 console.log('')\n console.log('Your h3ravel project has been created successfully!')\n console.log(chalk.cyan('cd ' + relative(process.cwd(), this.location!)))\n console.log(chalk.cyan(`${packageManager} run dev`))\n console.log(chalk.cyan('Open http://localhost:4444'))\n console.log('')\n console.log(`Have any questions?`)\n console.log(`Join our Discord server - ${chalk.yellow('https://discord.gg/hsG2A8PuGb')}`)\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uBAAkC;AAClC,IAAAA,gBAAkB;AAClB,sBAAqB;;;ACQd,IAAMC,YAAY;EACrB;IACIC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;;;;ADpCJ,iBAAgB;;;AENhB,uBAAyC;AACzC,sBAAkD;AAClD,yBAAqD;AAErD,mBAAkB;AAClB,mBAAiC;AACjC,qBAA2B;AAC3B,qBAAwB;AACxB,IAAAC,mBAAuB;AAEvB,IAAA,kBAAA,MAAe;EAVf,OAUe;;;;;;EACXC;EAEA,YAAoBC,UAA2BC,SAA0BC,aAAsB;SAA3EF,WAAAA;SAA2BC,UAAAA;SAA0BC,cAAAA;AACrE,QAAI,CAAC,KAAKF,UAAU;AAChB,WAAKA,eAAWG,uBAAKC,QAAQC,IAAG,GAAI,OAAA;IACxC;EACJ;EAEA,MAAMC,SAAUC,UAAkBC,UAAU,OAAOC,MAAe;AAC9D,QAAI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KN,CAAAA,MAAKA,EAAEE,UAAUb,QAAAA;AAE5C,MAAIgB,OAAO,CAACA,IAAID,QAAQ;AACpBG,YAAQC,IAAIC,cAAAA,QAAMC,MAAM,UAAA,GAAaD,cAAAA,QAAME,IAAI,OAAON,IAAIjC,IAAI,iCAAiC,CAAA;AAC/FuB,YAAQiB,KAAK,CAAA;EACjB;AAEA,QAAMC,UAAU,IAAIC,oBAAQC,wBAAKpB,QAAQC,IAAG,GAAIL,QAAAA,GAAWV,SAASR,WAAAA;AAEpE,QAAM2C,cAAUC,WAAAA,SAAI,qBAAqB,EAAEC,MAAK;AAChD,QAAML,QAAQM,SAASd,KAAKD,UAAUf,UAAUC,OAAAA;AAEhD0B,UAAQI,KAAKX,cAAAA,QAAMY,MAAM,gBAAA,CAAA,EAAmBH,MAAK;AACjD,QAAML,QAAQS,QAAO;AAErBN,UAAQI,KAAKX,cAAAA,QAAMY,MAAM,kBAAA,CAAA,EAAqBH,MAAK;AACnD,QAAML,QAAQU,eAAc;AAE5BP,UAAQQ,QAAQf,cAAAA,QAAMY,MAAM,sBAAA,CAAA;AAE5B,QAAMR,QAAQY,SAAQ;AAC1B,CAAA;AAEJvD,QAAQwD,MAAK;","names":["import_chalk","templates","name","alias","hint","source","import_promises","skipInstallation","location","appName","description","join","process","cwd","download","template","install","auth","includes","rm","force","recursive","removeLockFile","downloadTemplate","dir","registry","detectPackageManager","forceClean","installPackage","name","silent","complete","packageManager","console","log","chalk","cyan","relative","yellow","cleanup","pkgPath","pkg","readFile","then","JSON","parse","slugify","basename","replace","Promise","allSettled","writeFile","stringify","unlink","getBanner","copyExampleEnv","envPath","exampleEnvPath","existsSync","copyFile","import_node_path","import_support","program","Command","name","description","version","option","addArgument","Argument","action","pathName","options","appName","inquirer","prompt","type","message","default","when","desc","template","install","location","token","slugify","basename","process","cwd","choices","templates","map","e","value","alias","disabled","source","kit","find","console","log","chalk","bgRed","red","exit","actions","Actions","join","spinner","ora","start","download","info","green","cleanup","copyExampleEnv","succeed","complete","parse"]}
1
+ {"version":3,"sources":["../src/run.ts","../src/templates.ts","../src/tsconfig.ts","../src/actions.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport chalk from 'chalk';\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';\n\nconst program = new Command();\n\nprogram\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\nprogram\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 let { appName, description } = await inquirer\n .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 when: () => !options.desc,\n }]\n )\n\n let { template, install, location, token } = await inquirer\n .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 },\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 console.log(chalk.bgRed(' Error: '), chalk.red(`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(chalk.green(\"Cleaning Up...\")).start();\n await actions.cleanup()\n\n spinner.info(chalk.green(\"Initializing Project...\")).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(chalk.green('Project initialized successfully!'))\n\n await actions.complete()\n });\n\nprogram.parse();\n","/*\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","import { baseTsconfig, mainTsconfig } from \"./tsconfig\";\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 chalk from \"chalk\";\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 console.log('')\n console.log('Your h3ravel project has been created successfully!')\n console.log(chalk.cyan('cd ' + relative(process.cwd(), this.location!)))\n console.log(chalk.cyan(`${packageManager} run dev`))\n console.log(chalk.cyan('Open http://localhost:4444'))\n console.log('')\n console.log(`Have any questions?`)\n console.log(`Join our Discord server - ${chalk.yellow('https://discord.gg/hsG2A8PuGb')}`)\n console.log(`Checkout the documentation - ${chalk.yellow('https://h3ravel.toneflix.net')}`)\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 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 }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uBAAkC;AAClC,IAAAA,gBAAkB;AAClB,sBAAqB;;;ACQd,IAAMC,YAAY;EACrB;IACIC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;;;;ADpCJ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gBAAcO,QAAQP,eAAeA;AAErC,QAAMgC,MAAMP,UAAUQ,KAAKN,CAAAA,MAAKA,EAAEE,UAAUb,QAAAA;AAE5C,MAAIgB,OAAO,CAACA,IAAID,QAAQ;AACpBG,YAAQC,IAAIC,cAAAA,QAAMC,MAAM,UAAA,GAAaD,cAAAA,QAAME,IAAI,OAAON,IAAIjC,IAAI,iCAAiC,CAAA;AAC/FuB,YAAQiB,KAAK,CAAA;EACjB;AAEA,QAAMC,UAAU,IAAIC,oBAAQC,wBAAKpB,QAAQC,IAAG,GAAIL,QAAAA,GAAWV,SAASR,WAAAA;AAEpE,QAAM2C,cAAUC,WAAAA,SAAI,qBAAqB,EAAEC,MAAK;AAChD,QAAML,QAAQM,SAASd,KAAKD,UAAUf,UAAUC,OAAAA;AAEhD0B,UAAQI,KAAKX,cAAAA,QAAMY,MAAM,gBAAA,CAAA,EAAmBH,MAAK;AACjD,QAAML,QAAQS,QAAO;AAErBN,UAAQI,KAAKX,cAAAA,QAAMY,MAAM,yBAAA,CAAA,EAA4BH,MAAK;AAC1D,QAAML,QAAQU,eAAc;AAC5B,QAAMV,QAAQW,eAAc;AAE5BR,UAAQS,QAAQhB,cAAAA,QAAMY,MAAM,mCAAA,CAAA;AAE5B,QAAMR,QAAQa,SAAQ;AAC1B,CAAA;AAEJxD,QAAQyD,MAAK;","names":["import_chalk","templates","name","alias","hint","source","mainTsconfig","extends","compilerOptions","baseUrl","outDir","paths","target","module","moduleResolution","esModuleInterop","strict","allowJs","skipLibCheck","resolveJsonModule","noEmit","experimentalDecorators","emitDecoratorMetadata","include","exclude","baseTsconfig","import_promises","skipInstallation","location","appName","description","join","process","cwd","download","template","install","auth","includes","rm","force","recursive","removeLockFile","downloadTemplate","dir","registry","detectPackageManager","forceClean","installPackage","name","silent","complete","packageManager","console","log","chalk","cyan","relative","yellow","cleanup","pkgPath","pkg","readFile","then","JSON","parse","slugify","basename","replace","Promise","allSettled","writeFile","stringify","unlink","getBanner","copyExampleEnv","envPath","exampleEnvPath","existsSync","copyFile","createTsConfig","tscPath","mkdir","mainTsconfig","baseTsconfig","import_node_path","import_support","program","Command","name","description","version","option","addArgument","Argument","action","pathName","options","appName","inquirer","prompt","type","message","default","when","desc","template","install","location","token","slugify","basename","process","cwd","choices","templates","map","e","value","alias","disabled","source","kit","find","console","log","chalk","bgRed","red","exit","actions","Actions","join","spinner","ora","start","download","info","green","cleanup","copyExampleEnv","createTsConfig","succeed","complete","parse"]}
package/bin/run.js CHANGED
@@ -44,9 +44,60 @@ var templates = [
44
44
  // src/run.ts
45
45
  import ora from "ora";
46
46
 
47
+ // src/tsconfig.ts
48
+ var mainTsconfig = {
49
+ extends: "@h3ravel/shared/tsconfig.json",
50
+ compilerOptions: {
51
+ baseUrl: ".",
52
+ outDir: "dist",
53
+ paths: {
54
+ "src/*": [
55
+ "./../src/*"
56
+ ],
57
+ "App/*": [
58
+ "./../src/app/*"
59
+ ],
60
+ "root/*": [
61
+ "./../*"
62
+ ],
63
+ "routes/*": [
64
+ "./../src/routes/*"
65
+ ],
66
+ "config/*": [
67
+ "./../src/config/*"
68
+ ],
69
+ "resources/*": [
70
+ "./../src/resources/*"
71
+ ]
72
+ },
73
+ target: "es2022",
74
+ module: "es2022",
75
+ moduleResolution: "Node",
76
+ esModuleInterop: true,
77
+ strict: true,
78
+ allowJs: true,
79
+ skipLibCheck: true,
80
+ resolveJsonModule: true,
81
+ noEmit: true,
82
+ experimentalDecorators: true,
83
+ emitDecoratorMetadata: true
84
+ },
85
+ include: [
86
+ "./**/*.d.ts",
87
+ "./../**/*"
88
+ ],
89
+ exclude: [
90
+ "./dist",
91
+ "./node_modules"
92
+ ]
93
+ };
94
+ var baseTsconfig = {
95
+ extends: "./.h3ravel/tsconfig.json"
96
+ };
97
+
47
98
  // src/actions.ts
48
99
  import { basename, join, relative } from "path";
49
- import { copyFile, readFile, rm, writeFile } from "fs/promises";
100
+ import { copyFile, mkdir, readFile, rm, writeFile } from "fs/promises";
50
101
  import { detectPackageManager, installPackage } from "@antfu/install-pkg";
51
102
  import chalk from "chalk";
52
103
  import { downloadTemplate } from "giget";
@@ -102,6 +153,7 @@ var actions_default = class {
102
153
  console.log("");
103
154
  console.log(`Have any questions?`);
104
155
  console.log(`Join our Discord server - ${chalk.yellow("https://discord.gg/hsG2A8PuGb")}`);
156
+ console.log(`Checkout the documentation - ${chalk.yellow("https://h3ravel.toneflix.net")}`);
105
157
  }
106
158
  async cleanup() {
107
159
  const pkgPath = join(this.location, "package.json");
@@ -146,6 +198,14 @@ var actions_default = class {
146
198
  await copyFile(exampleEnvPath, envPath);
147
199
  }
148
200
  }
201
+ async createTsConfig() {
202
+ const tscPath = join(this.location, ".h3ravel");
203
+ await mkdir(tscPath, {
204
+ recursive: true
205
+ });
206
+ await writeFile(join(tscPath, "tsconfig.json"), JSON.stringify(mainTsconfig, null, 2));
207
+ await writeFile(join(this.location, "tsconfig.json"), JSON.stringify(baseTsconfig, null, 2));
208
+ }
149
209
  };
150
210
 
151
211
  // src/run.ts
@@ -219,9 +279,10 @@ program.option("-n, --name <string>", "The name of your project.").option("-i, -
219
279
  await actions.download(kit?.source ?? template, install);
220
280
  spinner.info(chalk2.green("Cleaning Up...")).start();
221
281
  await actions.cleanup();
222
- spinner.info(chalk2.green("Creating .env...")).start();
282
+ spinner.info(chalk2.green("Initializing Project...")).start();
223
283
  await actions.copyExampleEnv();
224
- spinner.succeed(chalk2.green("Template Downloaded!"));
284
+ await actions.createTsConfig();
285
+ spinner.succeed(chalk2.green("Project initialized successfully!"));
225
286
  await actions.complete();
226
287
  });
227
288
  program.parse();
package/bin/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/run.ts","../src/templates.ts","../src/actions.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport chalk from 'chalk';\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';\n\nconst program = new Command();\n\nprogram\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\nprogram\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 let { appName, description } = await inquirer\n .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 when: () => !options.desc,\n }]\n )\n\n let { template, install, location, token } = await inquirer\n .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 },\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 console.log(chalk.bgRed(' Error: '), chalk.red(`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(chalk.green(\"Cleaning Up...\")).start();\n await actions.cleanup()\n\n spinner.info(chalk.green(\"Creating .env...\")).start();\n await actions.copyExampleEnv()\n\n spinner.succeed(chalk.green('Template Downloaded!'))\n\n await actions.complete()\n });\n\nprogram.parse();\n","/*\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","import { basename, join, relative } from \"node:path\";\nimport { copyFile, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport chalk from \"chalk\";\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 console.log('')\n console.log('Your h3ravel project has been created successfully!')\n console.log(chalk.cyan('cd ' + relative(process.cwd(), this.location!)))\n console.log(chalk.cyan(`${packageManager} run dev`))\n console.log(chalk.cyan('Open http://localhost:4444'))\n console.log('')\n console.log(`Have any questions?`)\n console.log(`Join our Discord server - ${chalk.yellow('https://discord.gg/hsG2A8PuGb')}`)\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 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"],"mappings":";;;;;AAEA,SAASA,UAAUC,eAAe;AAClC,OAAOC,YAAW;AAClB,OAAOC,cAAc;;;ACQd,IAAMC,YAAY;EACrB;IACIC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ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5B,QAAMR,QAAQY,SAAQ;AAC1B,CAAA;AAEJvD,QAAQwD,MAAK;","names":["Argument","Command","chalk","inquirer","templates","name","alias","hint","source","ora","basename","join","relative","copyFile","readFile","rm","writeFile","detectPackageManager","installPackage","chalk","downloadTemplate","existsSync","slugify","unlink","skipInstallation","location","appName","description","join","process","cwd","download","template","install","auth","includes","rm","force","recursive","removeLockFile","downloadTemplate","dir","registry","detectPackageManager","forceClean","installPackage","name","silent","complete","packageManager","console","log","chalk","cyan","relative","yellow","cleanup","pkgPath","pkg","readFile","then","JSON","parse","slugify","basename","replace","Promise","allSettled","writeFile","stringify","unlink","getBanner","copyExampleEnv","envPath","exampleEnvPath","existsSync","copyFile","basename","join","slugify","program","Command","name","description","version","option","addArgument","Argument","action","pathName","options","appName","inquirer","prompt","type","message","default","when","desc","template","install","location","token","slugify","basename","process","cwd","choices","templates","map","e","value","alias","disabled","source","kit","find","console","log","chalk","bgRed","red","exit","actions","Actions","join","spinner","ora","start","download","info","green","cleanup","copyExampleEnv","succeed","complete","parse"]}
1
+ {"version":3,"sources":["../src/run.ts","../src/templates.ts","../src/tsconfig.ts","../src/actions.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Argument, Command } from 'commander';\nimport chalk from 'chalk';\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';\n\nconst program = new Command();\n\nprogram\n .name('create-h3ravel')\n .description('CLI to create new h3ravel app')\n .version('0.1.0');\n\nprogram\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 let { appName, description } = await inquirer\n .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 when: () => !options.desc,\n }]\n )\n\n let { template, install, location, token } = await inquirer\n .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 },\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 console.log(chalk.bgRed(' Error: '), chalk.red(`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(chalk.green(\"Cleaning Up...\")).start();\n await actions.cleanup()\n\n spinner.info(chalk.green(\"Initializing Project...\")).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(chalk.green('Project initialized successfully!'))\n\n await actions.complete()\n });\n\nprogram.parse();\n","/*\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","import { baseTsconfig, mainTsconfig } from \"./tsconfig\";\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 chalk from \"chalk\";\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 console.log('')\n console.log('Your h3ravel project has been created successfully!')\n console.log(chalk.cyan('cd ' + relative(process.cwd(), this.location!)))\n console.log(chalk.cyan(`${packageManager} run dev`))\n console.log(chalk.cyan('Open http://localhost:4444'))\n console.log('')\n console.log(`Have any questions?`)\n console.log(`Join our Discord server - ${chalk.yellow('https://discord.gg/hsG2A8PuGb')}`)\n console.log(`Checkout the documentation - ${chalk.yellow('https://h3ravel.toneflix.net')}`)\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 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 }\n}\n"],"mappings":";;;;;AAEA,SAASA,UAAUC,eAAe;AAClC,OAAOC,YAAW;AAClB,OAAOC,cAAc;;;ACQd,IAAMC,YAAY;EACrB;IACIC,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;EACA;IACIH,MAAM;IACNC,OAAO;IACPC,MAAM;IACNC,QAAQ;EACZ;;;;ADpCJ,OAAOC,SAAS;;;AENT,IAAMC,eAAe;EAC1BC,SAAS;EACTC,iBAAiB;IACfC,SAAS;IACTC,QAAQ;IACRC,OAAO;MACL,SAAS;QAAC;;MACV,SAAS;QAAC;;MACV,UAAU;QAAC;;MACX,YAAY;QAAC;;MACb,YAAY;QAAC;;MACb,eAAe;QAAC;;IAClB;IACAC,QAAQ;IACRC,QAAQ;IACRC,kBAAkB;IAClBC,iBAAiB;IACjBC,QAAQ;IACRC,SAAS;IACTC,cAAc;IACdC,mBAAmB;IACnBC,QAAQ;IACRC,wBAAwB;IACxBC,uBAAuB;EACzB;EACAC,SAAS;IAAC;IAAe;;EACzBC,SAAS;IAAC;IAAU;;AACtB;AAEO,IAAMC,eAAe;EAC1BlB,SAAS;AACX;;;AC9BA,SAASmB,UAAUC,MAAMC,gBAAgB;AACzC,SAASC,UAAUC,OAAOC,UAAUC,IAAIC,iBAAiB;AACzD,SAASC,sBAAsBC,sBAAsB;AAErD,OAAOC,WAAW;A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AAA,EAA4BH,MAAK;AAC1D,QAAML,QAAQU,eAAc;AAC5B,QAAMV,QAAQW,eAAc;AAE5BR,UAAQS,QAAQhB,OAAMY,MAAM,mCAAA,CAAA;AAE5B,QAAMR,QAAQa,SAAQ;AAC1B,CAAA;AAEJxD,QAAQyD,MAAK;","names":["Argument","Command","chalk","inquirer","templates","name","alias","hint","source","ora","mainTsconfig","extends","compilerOptions","baseUrl","outDir","paths","target","module","moduleResolution","esModuleInterop","strict","allowJs","skipLibCheck","resolveJsonModule","noEmit","experimentalDecorators","emitDecoratorMetadata","include","exclude","baseTsconfig","basename","join","relative","copyFile","mkdir","readFile","rm","writeFile","detectPackageManager","installPackage","chalk","downloadTemplate","existsSync","slugify","unlink","skipInstallation","location","appName","description","join","process","cwd","download","template","install","auth","includes","rm","force","recursive","removeLockFile","downloadTemplate","dir","registry","detectPackageManager","forceClean","installPackage","name","silent","complete","packageManager","console","log","chalk","cyan","relative","yellow","cleanup","pkgPath","pkg","readFile","then","JSON","parse","slugify","basename","replace","Promise","allSettled","writeFile","stringify","unlink","getBanner","copyExampleEnv","envPath","exampleEnvPath","existsSync","copyFile","createTsConfig","tscPath","mkdir","mainTsconfig","baseTsconfig","basename","join","slugify","program","Command","name","description","version","option","addArgument","Argument","action","pathName","options","appName","inquirer","prompt","type","message","default","when","desc","template","install","location","token","slugify","basename","process","cwd","choices","templates","map","e","value","alias","disabled","source","kit","find","console","log","chalk","bgRed","red","exit","actions","Actions","join","spinner","ora","start","download","info","green","cleanup","copyExampleEnv","createTsConfig","succeed","complete","parse"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-h3ravel",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.1",
5
5
  "description": "Scaffold a new H3ravel applications using templates and starter kits",
6
6
  "main": "build/index.js",
7
7
  "bin": {
@@ -20,13 +20,14 @@
20
20
  "bin/run.js"
21
21
  ],
22
22
  "dependencies": {
23
- "@h3ravel/support": "^0.7.0",
24
23
  "@antfu/install-pkg": "1.1.0",
25
- "chalk": "^5.5.0",
24
+ "@h3ravel/shared": "^0.18.1",
25
+ "@h3ravel/support": "^0.10.0",
26
+ "@inquirer/core": "^10.2.2",
26
27
  "commander": "^14.0.0",
27
28
  "giget": "^2.0.0",
28
- "inquirer": "^12.9.0",
29
- "ora": "^8.2.0"
29
+ "inquirer": "^12.9.6",
30
+ "ora": "^9.0.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@changesets/cli": "^2.29.5",