diff --git a/README.md b/README.md index cdf634e..b9e8c13 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,35 @@ -# Hydra-JS CLI +# @hydra-js/cli -## Development +Command-line Toolkit for Hydra.js -### Prerequisites +## Getting started + +### Usage + +**Install** +```bash +npm i -g @hydra-js/cli +``` + +**Create a new App** +```bash +hydra create [-f|--force] +``` + +**Run** +```bash +cd +hydra serve +``` + +### Development Setup + +**Prerequisites** - Node.js (v14 or later) - npm (v7 or later) -### Setup +### Setting up locally ```bash git clone git@github.com:hydra-js/cli.git hydra-cli @@ -17,10 +39,10 @@ npm install ### Running locally -To run the CLI tool locally without installing it globally, use: +To run the CLI tool locally without installing it, use: ```bash -node index.js init [appName] +node index.js create [-f|--force] ``` ### Running locally with `npm link` @@ -39,7 +61,7 @@ npm link 2. Now you can run the `hydra` command from anywhere on your system: ```bash -hydra init [appName] +hydra create [-f|--force] ``` This allows you to test changes to the CLI tool without needing to reinstall it each time you make modifications. diff --git a/index.js b/index.js index fb316ee..d3fd3a5 100755 --- a/index.js +++ b/index.js @@ -16,16 +16,16 @@ const subdirectory = 'packages/server-nodejs'; program.name('hydra').description(pkg.description).version(pkg.version); program - .command('init [appName]') + .command('create [namespace]') .description( 'Initialize a Hydra App' ) - .action(async (appName = 'my-hydra-app') => { - const tempRepoPath = path.join(process.cwd(), appName, '__tmp'); - const appPath = path.join(process.cwd(), appName); + .action(async (namespace = 'my-hydra-app') => { + const tempRepoPath = path.join(process.cwd(), namespace, '__tmp'); + const appPath = path.join(process.cwd(), namespace); if (fs.existsSync(appPath)) { - console.error(`Error: Directory ${appName} already exists.`); + console.error(`Error: Directory ${namespace} already exists.`); process.exit(1); } @@ -42,7 +42,7 @@ program ); } - console.log(`Copying ${subdirectory} to ${appName}...`); + console.log(`Copying ${subdirectory} to ${namespace}...`); await fs.copy(sourcePath, appPath); console.log('Subdirectory copied successfully.'); @@ -52,7 +52,7 @@ program await fs.remove(tempRepoPath); console.log('Cleanup completed.'); - console.log(`Project ${appName} generated successfully.`); + console.log(`Project ${namespace} generated successfully.`); } catch (err) { console.error('Failed to generate project:', err); await fs.remove(tempRepoPath);