Integration with Scaffolding Tools
ai-jue is designed to be easily integrated into modern frontend development scaffolds and workflows. This document guides you on how to integrate ai-jue into your project templates or existing scaffolds.
Scenario 1: Integrating in Project Templates
If you maintain an internal company project template (e.g., based on Vite or Next.js), you can pre-configure ai-jue in the template so that new projects created from it automatically have standardized AI configurations.
Steps
Install Dependencies: Add
ai-jueand required presets to thepackage.jsonof your template project:json{ "devDependencies": { "ai-jue": "^1.0.0", "jue-preset-react": "^1.0.0" } }Add Configuration File: Add
ai.config.jsto the template root directory:javascriptmodule.exports = { preset: 'react', // Other company standard configurations... };Configure
postinstallScript (Optional): To ensure AI configuration files are generated immediately after developers install dependencies, you can add apostinstallscript topackage.json:json{ "scripts": { "postinstall": "npx jue apply --all" } }Note: Use
postinstallwith caution as it may add unnecessary overhead in CI environments. It is recommended to check theCI=trueenvironment variable.
Scenario 2: Using npx Initialization Script
If you don't maintain a full template but want to provide a one-line command to add AI capabilities to existing projects, you can write a simple initialization script or document.
Example Script
#!/bin/bash
# setup-ai.sh
# 1. Install Dependencies
npm install -D ai-jue jue-preset-base
# 2. Initialize Configuration
npx jue init
# 3. Apply Configuration
npx jue apply --all
echo "AI environment configuration complete!"Users just need to run:
curl -s https://your-company.com/setup-ai.sh | bashScenario 3: CI/CD Integration
In some scenarios, you may want to ensure that the AI configuration file used in the CI environment is up-to-date (e.g., if you added generated configuration files to .gitignore).
GitHub Actions Example
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
# Explicitly generate AI configuration (if the build process depends on it)
- run: npx jue apply --all
- run: npm run buildBest Practices
- Version Locking: When integrating in templates, it is recommended to lock the versions of
ai-jueand preset packages to ensure consistency across all new projects. - Documentation: Briefly explain the existence and purpose of AI configuration in the template's
README.md. - Environment Distinction: If your preset includes tools for the development environment (such as local debugging helpers), ensure they do not leak into production builds (
ai-jueby default only generates configuration files and does not affect runtime code, so it is usually safe).