@drmhse/authos-cli
CLI tool for scaffolding AuthOS authentication components in your project.
Installation
npm install @drmhse/authos-cli -g
Or use without installing globally:
npx @drmhse/authos-cli init
Commands
authos init
Initialize AuthOS in your project. This command detects your framework (React, Next.js, Vue, Nuxt) and sets up the appropriate configuration and environment variables.
authos init [--skip-install]
Options:
--skip-install: Skip automatic installation of adapter packages.
The init command will:
- Detect your framework from package.json dependencies (or prompt if unknown).
- Install the appropriate AuthOS adapter package (
@drmhse/authos-reactor@drmhse/authos-vue). - Set up
AUTHOS_BASE_URLin your.envor.env.localfile.
authos add
Generate and add AuthOS components to your project.
authos add <template> [--force]
Options:
-f, --force: Overwrite existing files without prompting.
Available templates:
login-form- Styled login form with email/password and MFA support.org-switcher- Dropdown for switching between organizations.user-profile- User avatar button with dropdown menu.
authos list
List all available component templates with descriptions.
authos list
Programmatic Usage
You can also use the CLI programmatic API:
import { initCommand, addCommand, getAvailableTemplates } from '@drmhse/authos-cli';
// Get available templates
const templates = getAvailableTemplates();
// Initialize AuthOS
await initCommand({
skipInstall: false
});
// Add a component
await addCommand('login-form', {
force: true
});
Troubleshooting
Framework Detection Failed
If authos init fails to detect your framework, it will prompt you to select it manually. Ensure you are running the command from the root directory of your project where package.json is located.
Component Installation Errors
If authos add fails to write files:
- Ensure you have write permissions in your project directory.
- The tool expects a standard project structure. If your components are in a non-standard location, you may need to move them manually after generation.
License
MIT © DRM HSE