Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
heimdallrj committed Sep 8, 2024
1 parent 946bdf2 commit da52eed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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] <namespace>
```

**Run**
```bash
cd <namespace>
hydra serve
```

### Development Setup

**Prerequisites**

- Node.js (v14 or later)
- npm (v7 or later)

### Setup
### Setting up locally

```bash
git clone [email protected]:hydra-js/cli.git hydra-cli
Expand All @@ -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] <namespace>
```

### Running locally with `npm link`
Expand All @@ -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] <namespace>
```

This allows you to test changes to the CLI tool without needing to reinstall it each time you make modifications.
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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.');

Expand All @@ -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);
Expand Down

0 comments on commit da52eed

Please sign in to comment.