@ng-shangjc/cli
v1.0.16-beta
Published
<p align="center"> <a href="https://juliancallejas.github.io/ng-shangjc-docs"> <img src="https://res.cloudinary.com/dphleqb5t/image/upload/v1772819746/shangjc/shangjc-64-bg-dark_kwzs81.svg" width="307" alt="Shangjc" /> </a> </p>
Downloads
1,802
Readme
@ng-shangjc/cli
A powerful CLI tool for managing and installing ng-shangjc UI components in your Angular projects.
Official Documentation
Installation
Install the CLI globally:
npm install -g @ng-shangjc/cliOr use npx to run without installation:
npx @ng-shangjc/cli <command>Prerequisites
- Angular project (angular.json must be present)
- Node.js 16 or higher
- One of the following package managers:
- npm (default)
- yarn
- pnpm
Commands
init
Initialize shangjc configuration in your Angular project.
ng-shangjc initThis command will:
- Verify you're in an Angular project
- Detect your project's package manager (npm, yarn, or pnpm)
- Create a
shangjc.config.jsonconfiguration file - Prompt for component installation preferences
- Set up your project for component installations
Configuration options:
- Components Path: Where to install components (default:
src/ui/shangjc) - Component Type: Standalone (recommended) or Module-based
- Project Type: Angular application setup
- Package Manager: Auto-detected (npm, yarn, or pnpm)
- Theme Configuration: Default theme and variants
- Tailwind Config: Whether to configure Tailwind CSS
install
Install a specific component into your project.
ng-shangjc install <component>Options:
-p, --path <path>: Override the installation path from config
Examples:
# Install button component
ng-shangjc install button
# Install to custom path
ng-shangjc install button --path src/components/ui
# Install dialog component
ng-shangjc install dialogAvailable Components:
accordion- Accordion componentalert- Alert/notification componentbadge- Badge componentbutton- Button componentcard- Card container componentcheckbox- Checkbox componentdialog- Modal dialog componentdropdown-menu- Dropdown Menu componentinput- Input field componentselect- Select dropdown componentswitch- Toggle switch componenttabs- Tabs componenttextarea- Textarea component
Installation Process:
- Validates component availability
- Checks for existing installation
- Uses your detected package manager for all installations
- Installs dependencies (like @ng-shangjc/utils)
- Copies component files to your project
- Generates index.ts file
- Updates shangjc.config.json
- Provides usage instructions
variants
Show variant configurations for components.
# Show all component variants
ng-shangjc variants
# Show variants for specific component
ng-shangjc variants buttonThis command displays:
- Available variants for each component
- Default variant settings
- CSS classes for each variant
- Variant descriptions
Configuration File
The CLI creates and manages a shangjc.config.json file in your project root:
{
"version": "1.0.0",
"componentsPath": "src/ui/shangjc",
"componentType": "standalone",
"projectType": "angular",
"packageManager": "npm",
"theme": {
"current": "default",
"variants": {
"button": ["primary", "secondary", "outline"],
"card": ["default", "elevated"]
}
},
"tailwindConfig": true,
"installedComponents": ["button", "input"],
"utilsVersion": "1.0.0"
}
``
## Component Usage
After installing components, you can import and use them in your Angular application:
```typescript
// Import the component
import { ButtonComponent } from './ui/shangjc/button';
// Use in your component
@Component({
selector: 'app-example',
template: `
<shangjc-button variant="primary" size="md">
Click me
</shangjc-button>
`,
standalone: true,
imports: [ButtonComponent]
})
export class ExampleComponent {}Features
- Interactive Setup: Guided initialization with prompts
- Package Manager Detection: Automatically detects and uses npm, yarn, or pnpm
- Dependency Management: Automatic installation of required dependencies
- Configuration Management: Centralized config file for project settings
- Component Variants: Support for multiple component themes and styles
- Path Validation: Ensures components are installed in valid locations
- Reinstallation Support: Option to reinstall existing components
- Error Handling: Clear error messages and validation
Package Manager Support
The CLI automatically detects and uses your project's package manager:
Detection Priority
- pnpm - If
pnpm-lock.yamlexists - yarn - If
yarn.lockexists - npm - If
package-lock.jsonexists - Fallback - Checks PATH availability (pnpm → yarn → npm)
Installation Commands
- npm:
npm install <package>andnpm install --save-dev <package> - yarn:
yarn add <package>andyarn add --dev <package> - pnpm:
pnpm add <package>andpnpm add --save-dev <package>
The detected package manager is stored in shangjc.config.json and used for all subsequent installations.
Troubleshooting
"Not an Angular project" error
Ensure you're running the CLI from the root directory of your Angular project where angular.json is located.
Component installation fails
- Check that you have sufficient permissions
- Verify your network connection for dependency installation
- Ensure the target directory is writable
Configuration issues
- Delete
shangjc.config.jsonand runng-shangjc initagain - Check that your components path starts with
src/
Development
For CLI development:
# Clone the repository
git clone <repository-url>
# Install dependencies
npm install
# Build the CLI
npm run build
# Run in development mode
npm run devContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License.
Support
For issues and questions:
- Create an issue on GitHub
- Check the documentation
- Review existing issues for solutions
