@machinemetrics/mm-react-components 0.2.3-3 ā 0.2.3-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -25
- package/dist/README.md +6 -25
- package/dist/components/ui/progress.d.ts +1 -0
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/docs/GETTING_STARTED.md +3 -5
- package/dist/main.d.ts +1 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/mm-react-components.es.js.map +1 -1
- package/dist/mm-react-components.umd.js.map +1 -1
- package/dist/style.css +1 -0
- package/package.json +17 -7
- package/scripts/README.md +112 -112
- package/scripts/init.cjs +159 -0
- package/src/index.css +99 -489
- package/src/themes/carbide.css +379 -32
- package/dist/index.css +0 -527
- package/dist/themes/base.css +0 -536
- package/dist/themes/carbide.css +0 -1257
- package/dist/themes/complete.css +0 -8
- package/scripts/chakra-to-shadcn-migrator/README.md +0 -107
- package/src/themes/base.css +0 -536
- package/src/themes/complete.css +0 -8
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@keyframes mm-progress-shimmer{0%{transform:translate(-100%);opacity:0}10%{opacity:.15}50%{opacity:.25}to{transform:translate(100%);opacity:0}}[data-slot=progress-indicator]:before{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,.15) 50%,transparent 100%);transform:translate(-100%);pointer-events:none;animation:mm-progress-shimmer 2.4s ease-in-out infinite}@keyframes mm-progress-head-flash{0%{opacity:0;transform:translate(0)}30%{opacity:.6}to{opacity:0;transform:translate(8px)}}@keyframes mm-progress-breathe{0%,to{filter:brightness(1);opacity:1}50%{filter:brightness(1.35);opacity:.8}}[data-slot=progress] [data-slot=progress-indicator]:after{content:"";position:absolute;right:-2px;top:0;bottom:0;width:12px;pointer-events:none;background:radial-gradient(12px 12px at 100% 50%,rgba(255,255,255,.6),transparent 70%);opacity:0}.mmc-progress[data-animating=true] [data-slot=progress-indicator]:after{animation:mm-progress-head-flash .6s ease-out 1}[data-slot=progress-indicator]{animation:mm-progress-breathe 1.65s ease-in-out infinite}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machinemetrics/mm-react-components",
|
|
3
|
-
"version": "0.2.3-
|
|
3
|
+
"version": "0.2.3-5",
|
|
4
4
|
"description": "Industrial-grade React components for manufacturing applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,20 +29,28 @@
|
|
|
29
29
|
"import": "./dist/mm-react-components.es.js",
|
|
30
30
|
"require": "./dist/mm-react-components.umd.js"
|
|
31
31
|
},
|
|
32
|
-
"./styles": "./dist/
|
|
33
|
-
"./themes/base": "./dist/index.css",
|
|
32
|
+
"./styles": "./dist/lib/styles.css",
|
|
34
33
|
"./themes/carbide": "./dist/themes/carbide.css",
|
|
35
|
-
"./themes/complete": "./dist/themes/complete.css",
|
|
36
34
|
"./tailwind.config": "./tailwind.base.config.js",
|
|
37
35
|
"./docs/tailwind-setup": "./docs/TAILWIND_SETUP.md",
|
|
38
36
|
"./docs/getting-started": "./dist/docs/GETTING_STARTED.md",
|
|
39
|
-
"./README": "./dist/README.md"
|
|
37
|
+
"./README": "./dist/README.md",
|
|
38
|
+
"./migration/config": "./scripts/chakra-to-shadcn-migrator/chakra-to-shadcn.config.json",
|
|
39
|
+
"./agent-docs": "./agent-docs/"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=20"
|
|
43
43
|
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"autoprefixer": "^10.0.0",
|
|
46
|
+
"postcss": "^8.5.6",
|
|
47
|
+
"react": "^19.1.1",
|
|
48
|
+
"react-dom": "^19.1.1",
|
|
49
|
+
"tailwindcss": "^4.0.0"
|
|
50
|
+
},
|
|
44
51
|
"bin": {
|
|
45
|
-
"chakra-to-shadcn": "scripts/chakra-to-shadcn-migrator/bin/chakra-to-shadcn.js"
|
|
52
|
+
"chakra-to-shadcn": "scripts/chakra-to-shadcn-migrator/bin/chakra-to-shadcn.js",
|
|
53
|
+
"mm-init": "scripts/init.cjs"
|
|
46
54
|
},
|
|
47
55
|
"scripts": {
|
|
48
56
|
"build": "vite build --mode production && tsc --project tsconfig.build.json",
|
|
@@ -124,6 +132,7 @@
|
|
|
124
132
|
"devDependencies": {
|
|
125
133
|
"@eslint/js": "^9.33.0",
|
|
126
134
|
"@playwright/test": "^1.55.0",
|
|
135
|
+
"@tailwindcss/postcss": "^4.1.13",
|
|
127
136
|
"@tailwindcss/vite": "^4.1.13",
|
|
128
137
|
"@types/node": "^24.5.0",
|
|
129
138
|
"@types/react": "^19.1.10",
|
|
@@ -132,6 +141,7 @@
|
|
|
132
141
|
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
133
142
|
"@typescript-eslint/parser": "^8.43.0",
|
|
134
143
|
"@vitejs/plugin-react": "^5.0.0",
|
|
144
|
+
"autoprefixer": "^10.4.21",
|
|
135
145
|
"eslint": "^9.33.0",
|
|
136
146
|
"eslint-config-prettier": "^10.1.8",
|
|
137
147
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
@@ -142,7 +152,7 @@
|
|
|
142
152
|
"globals": "^16.3.0",
|
|
143
153
|
"playwright": "^1.55.0",
|
|
144
154
|
"prettier": "^3.6.2",
|
|
145
|
-
"tailwindcss": "^4.1.
|
|
155
|
+
"tailwindcss": "^4.1.14",
|
|
146
156
|
"terser": "^5.44.0",
|
|
147
157
|
"tsx": "^4.19.2",
|
|
148
158
|
"typescript": "~5.8.3",
|
package/scripts/README.md
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
# Scripts
|
|
1
|
+
# MM React Components - Initialization Scripts
|
|
2
2
|
|
|
3
|
-
This directory contains scripts
|
|
3
|
+
This directory contains initialization scripts to help users quickly set up the MachineMetrics React Components library in their projects.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Available Scripts
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### 1. Quick Initialization Script (`init.js`)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
npm run create-component <component-name>
|
|
11
|
-
```
|
|
9
|
+
**Usage:** `npm run init`
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
A streamlined initialization script that:
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
- Installs the component library and core dependencies
|
|
14
|
+
- Sets up basic CSS imports
|
|
15
|
+
- Provides minimal configuration
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
- `--skip-lint` - Skip running ESLint fixes
|
|
19
|
-
- `--skip-format` - Skip running Prettier formatting
|
|
20
|
-
- `--skip-tests` - Skip generating Playwright tests
|
|
21
|
-
- `--help` - Show help message
|
|
17
|
+
**Features:**
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
- ā
Fast setup (no interactive prompts)
|
|
20
|
+
- ā
Installs only essential dependencies
|
|
21
|
+
- ā
Basic theme integration
|
|
22
|
+
- ā
Perfect for quick prototyping
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
npm run create-component card
|
|
27
|
-
npm run create-component dialog --skip-preview
|
|
28
|
-
npm run create-component select --skip-lint --skip-format
|
|
29
|
-
npm run create-component button --skip-tests
|
|
30
|
-
```
|
|
24
|
+
### 2. NPX CLI Tool (`npx-init.js`)
|
|
31
25
|
|
|
32
|
-
**
|
|
26
|
+
**Usage:** `npx @machinemetrics/mm-react-components init`
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
2. Apply ESLint fixes (unless --skip-lint)
|
|
36
|
-
3. Apply Prettier formatting (unless --skip-format)
|
|
37
|
-
4. Generate preview component (unless --skip-preview)
|
|
38
|
-
5. Generate Playwright tests (unless --skip-tests)
|
|
39
|
-
6. Update main index.ts exports
|
|
28
|
+
An NPX CLI tool that can be run from any directory:
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
- Installs the component library
|
|
31
|
+
- Sets up peer dependencies
|
|
32
|
+
- Creates example components
|
|
33
|
+
- Configures CSS imports
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
**Features:**
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
- ā
Can be run via npx (no global installation needed)
|
|
38
|
+
- ā
Works in any React project
|
|
39
|
+
- ā
Creates example components
|
|
40
|
+
- ā
Minimal setup process
|
|
41
|
+
|
|
42
|
+
## Usage Examples
|
|
48
43
|
|
|
49
|
-
###
|
|
44
|
+
### For New Projects
|
|
50
45
|
|
|
51
46
|
```bash
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
# Create a new React project
|
|
48
|
+
npx create-react-app my-app
|
|
49
|
+
cd my-app
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
# Install MM React Components
|
|
52
|
+
npx @machinemetrics/mm-react-components init
|
|
53
|
+
```
|
|
56
54
|
|
|
57
|
-
###
|
|
55
|
+
### For Existing Projects
|
|
58
56
|
|
|
59
57
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
# Quick setup
|
|
59
|
+
npm run init
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
# Or use npx (recommended)
|
|
62
|
+
npx @machinemetrics/mm-react-components init
|
|
63
|
+
```
|
|
64
64
|
|
|
65
|
-
###
|
|
65
|
+
### NPX Usage
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
|
|
68
|
+
# Use directly with npx (no installation needed)
|
|
69
|
+
npx @machinemetrics/mm-react-components init
|
|
69
70
|
```
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
## What Gets Installed
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
### Core Dependencies
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
- `@machinemetrics/mm-react-components` - The component library
|
|
77
|
+
- `class-variance-authority` - Component variant management
|
|
78
|
+
- `clsx` - Conditional class names
|
|
79
|
+
- `tailwind-merge` - Tailwind class merging
|
|
80
|
+
- `@radix-ui/react-slot` - Radix UI primitives
|
|
81
|
+
- `lucide-react` - Icon library
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
2. **Filter** out custom components (like `theme-toggle`)
|
|
79
|
-
3. **Update** each remaining component using `npx shadcn@latest add <component> --yes --overwrite`
|
|
80
|
-
4. **Report** a summary of what was updated, skipped, or failed
|
|
83
|
+
### Optional Dependencies
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
- `react-hook-form` - Form handling
|
|
86
|
+
- `@hookform/resolvers` - Form validation resolvers
|
|
87
|
+
- `zod` - Schema validation
|
|
88
|
+
- `sonner` - Toast notifications
|
|
83
89
|
|
|
84
|
-
## What
|
|
90
|
+
## What Gets Created
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
### CSS Imports
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
5. **Skip or Overwrite**: Either skip existing tests (default) or overwrite them (with `--overwrite`)
|
|
93
|
-
6. **Report** a summary of generated, skipped, and total test files
|
|
94
|
+
```css
|
|
95
|
+
@import '@machinemetrics/mm-react-components/styles';
|
|
96
|
+
@import '@machinemetrics/mm-react-components/themes/carbide';
|
|
97
|
+
```
|
|
94
98
|
|
|
95
|
-
###
|
|
99
|
+
### Example Components
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
- Basic usage examples
|
|
102
|
+
- Advanced form examples
|
|
103
|
+
- Industrial/manufacturing use cases
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
- **Mobile Responsive Screenshot**: Tests the component at mobile viewport (375x667)
|
|
105
|
+
### Configuration Files
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
- TypeScript declarations
|
|
108
|
+
- Vite configuration (if needed)
|
|
109
|
+
- Example documentation
|
|
103
110
|
|
|
104
|
-
|
|
111
|
+
## Theme Integration
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
- ā
**Intelligent Preview Generation**: Creates appropriate preview components based on component type
|
|
108
|
-
- ā
**Special Component Handling**: Custom preview templates for complex components (card, dialog, etc.)
|
|
109
|
-
- ā
**Automatic Linting**: Applies ESLint fixes after component creation
|
|
110
|
-
- ā
**Automatic Formatting**: Applies Prettier formatting for consistent code style
|
|
111
|
-
- ā
**Playwright Test Generation**: Automatically generates visual regression tests
|
|
112
|
-
- ā
**Export Management**: Automatically updates index.ts with new component exports
|
|
113
|
-
- ā
**Error Handling**: Comprehensive error handling with detailed progress reporting
|
|
114
|
-
- ā
**Flexible Options**: Skip any step with command-line flags
|
|
115
|
-
- ā
**Help Documentation**: Built-in help with usage examples
|
|
113
|
+
The scripts automatically set up the Carbide theme for industrial applications:
|
|
116
114
|
|
|
117
|
-
|
|
115
|
+
```tsx
|
|
116
|
+
// Add to your root element
|
|
117
|
+
<div className="carbide">
|
|
118
|
+
<App />
|
|
119
|
+
</div>
|
|
120
|
+
```
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
- ā
**Smart Filtering**: Skips custom components automatically
|
|
121
|
-
- ā
**CLI Validation**: Let shadcn CLI determine if components are valid/updatable
|
|
122
|
-
- ā
**Detailed Progress**: Shows real-time updates and comprehensive summary
|
|
123
|
-
- ā
**Error Handling**: Reports failures and continues with other components
|
|
124
|
-
- ā
**Overwrite**: Uses `--overwrite` flag to ensure components are properly updated
|
|
122
|
+
## Troubleshooting
|
|
125
123
|
|
|
126
|
-
###
|
|
124
|
+
### Common Issues
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
- ā
**Dynamic Wait Logic**: Automatically adapts wait conditions for data tables vs regular components
|
|
132
|
-
- ā
**Mobile Testing**: Includes responsive testing at mobile viewport sizes
|
|
133
|
-
- ā
**Route Auto-Discovery**: Automatically finds all component preview routes
|
|
126
|
+
1. **"React not found"**
|
|
127
|
+
- Ensure you're in a React project directory
|
|
128
|
+
- Check that React is installed in package.json
|
|
134
129
|
|
|
135
|
-
|
|
130
|
+
2. **"Permission denied"**
|
|
131
|
+
- Make sure the script is executable: `chmod +x scripts/*.js`
|
|
136
132
|
|
|
137
|
-
|
|
133
|
+
3. **"Module not found"**
|
|
134
|
+
- Run `npm install` to install dependencies
|
|
135
|
+
- Check that the component library is properly installed
|
|
138
136
|
|
|
139
|
-
|
|
137
|
+
### Manual Setup
|
|
140
138
|
|
|
141
|
-
|
|
139
|
+
If the scripts fail, you can set up manually:
|
|
142
140
|
|
|
143
|
-
|
|
141
|
+
```bash
|
|
142
|
+
# Install the library
|
|
143
|
+
npm install @machinemetrics/mm-react-components
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
# Install peer dependencies
|
|
146
|
+
npm install class-variance-authority clsx tailwind-merge @radix-ui/react-slot lucide-react
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
-
|
|
148
|
+
# Add to your CSS
|
|
149
|
+
@import '@machinemetrics/mm-react-components/styles';
|
|
150
|
+
@import '@machinemetrics/mm-react-components/themes/carbide';
|
|
151
|
+
```
|
|
149
152
|
|
|
150
|
-
|
|
153
|
+
## Support
|
|
151
154
|
|
|
152
|
-
|
|
153
|
-
- `npx` command available
|
|
155
|
+
For issues or questions:
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
- GitHub Issues: https://github.com/machinemetrics/mm-react-components/issues
|
|
158
|
+
- Documentation: https://github.com/machinemetrics/mm-react-components#readme
|
|
156
159
|
|
|
157
|
-
|
|
160
|
+
## Contributing
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
npm run update-components -- --help
|
|
161
|
-
./scripts/update-components.sh --help
|
|
162
|
-
```
|
|
162
|
+
To improve the initialization scripts:
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
1. Fork the repository
|
|
165
|
+
2. Make your changes
|
|
166
|
+
3. Test with different React setups
|
|
167
|
+
4. Submit a pull request
|
|
165
168
|
|
|
166
|
-
|
|
169
|
+
## License
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
2. Make sure `npx` can access the shadcn CLI
|
|
170
|
-
3. Check that `src/components/ui/` directory exists
|
|
171
|
-
4. Verify you're in the project root directory
|
|
171
|
+
MIT License - see LICENSE file for details.
|
package/scripts/init.cjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MM React Components - Quick Init Script
|
|
5
|
+
*
|
|
6
|
+
* Simple initialization script for the MachineMetrics React Components library
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* eslint-disable no-undef */
|
|
10
|
+
|
|
11
|
+
const { execSync } = require('child_process');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
// Colors for console output
|
|
16
|
+
const colors = {
|
|
17
|
+
reset: '\x1b[0m',
|
|
18
|
+
bright: '\x1b[1m',
|
|
19
|
+
green: '\x1b[32m',
|
|
20
|
+
blue: '\x1b[34m',
|
|
21
|
+
cyan: '\x1b[36m',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function log(message, color = 'reset') {
|
|
25
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function main() {
|
|
29
|
+
log('š MM React Components - Quick Setup', 'bright');
|
|
30
|
+
log(
|
|
31
|
+
'Installing and configuring MachineMetrics React Components...\n',
|
|
32
|
+
'blue',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// Install the component library
|
|
37
|
+
log('š¦ Installing MM React Components...', 'cyan');
|
|
38
|
+
execSync('npm install @machinemetrics/mm-react-components@beta', {
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
});
|
|
41
|
+
log('ā
MM React Components installed', 'green');
|
|
42
|
+
|
|
43
|
+
// Install peer dependencies
|
|
44
|
+
log('š¦ Installing peer dependencies...', 'cyan');
|
|
45
|
+
const peerDeps = [
|
|
46
|
+
'class-variance-authority',
|
|
47
|
+
'clsx',
|
|
48
|
+
'tailwind-merge',
|
|
49
|
+
'@radix-ui/react-slot',
|
|
50
|
+
'lucide-react',
|
|
51
|
+
'tailwindcss',
|
|
52
|
+
'autoprefixer',
|
|
53
|
+
'postcss',
|
|
54
|
+
];
|
|
55
|
+
execSync(`npm install ${peerDeps.join(' ')}`, { stdio: 'inherit' });
|
|
56
|
+
log('ā
Peer dependencies installed', 'green');
|
|
57
|
+
|
|
58
|
+
// Create basic CSS import
|
|
59
|
+
const srcPath = path.join(process.cwd(), 'src');
|
|
60
|
+
const indexCssPath = path.join(srcPath, 'index.css');
|
|
61
|
+
|
|
62
|
+
// Ensure src directory exists
|
|
63
|
+
if (!fs.existsSync(srcPath)) {
|
|
64
|
+
fs.mkdirSync(srcPath, { recursive: true });
|
|
65
|
+
log('ā
Created src/ directory', 'green');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (fs.existsSync(indexCssPath)) {
|
|
69
|
+
const cssContent = fs.readFileSync(indexCssPath, 'utf8');
|
|
70
|
+
if (!cssContent.includes('@machinemetrics/mm-react-components')) {
|
|
71
|
+
const newCssContent = `@import '@machinemetrics/mm-react-components/themes/carbide';
|
|
72
|
+
|
|
73
|
+
${cssContent}`;
|
|
74
|
+
fs.writeFileSync(indexCssPath, newCssContent);
|
|
75
|
+
log('ā
Added Carbide theme import to existing index.css', 'green');
|
|
76
|
+
} else {
|
|
77
|
+
log('ā
Carbide theme import already present in index.css', 'green');
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
const cssContent = `@import '@machinemetrics/mm-react-components/themes/carbide';`;
|
|
81
|
+
|
|
82
|
+
fs.writeFileSync(indexCssPath, cssContent);
|
|
83
|
+
log('ā
Created index.css with Carbide theme import', 'green');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Always use the exported Tailwind config from the package
|
|
87
|
+
const tailwindConfigPath = path.join(process.cwd(), 'tailwind.config.js');
|
|
88
|
+
const packageConfigPath = path.join(
|
|
89
|
+
process.cwd(),
|
|
90
|
+
'node_modules/@machinemetrics/mm-react-components/tailwind.base.config.js',
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
if (!fs.existsSync(packageConfigPath)) {
|
|
94
|
+
log('ā Could not find exported Tailwind config in package', 'red');
|
|
95
|
+
log(
|
|
96
|
+
' This indicates the package installation may be incomplete.',
|
|
97
|
+
'red',
|
|
98
|
+
);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const configContent = fs.readFileSync(packageConfigPath, 'utf8');
|
|
103
|
+
// Convert ES module to CommonJS for compatibility
|
|
104
|
+
const commonJsConfig = configContent
|
|
105
|
+
.replace('export default', 'module.exports =')
|
|
106
|
+
.replace(/^\/\*\* @type \{import\('tailwindcss'\)\.Config\} \*\/\n/, '');
|
|
107
|
+
|
|
108
|
+
if (fs.existsSync(tailwindConfigPath)) {
|
|
109
|
+
log('ā
Replacing existing Tailwind config with package config', 'green');
|
|
110
|
+
} else {
|
|
111
|
+
log('ā
Creating tailwind.config.js from package config', 'green');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fs.writeFileSync(tailwindConfigPath, commonJsConfig);
|
|
115
|
+
|
|
116
|
+
// Check if PostCSS config exists and update it if needed
|
|
117
|
+
const postcssConfigPath = path.join(process.cwd(), 'postcss.config.js');
|
|
118
|
+
if (fs.existsSync(postcssConfigPath)) {
|
|
119
|
+
log('ā
Found existing PostCSS config', 'green');
|
|
120
|
+
} else {
|
|
121
|
+
// Create a basic PostCSS config
|
|
122
|
+
const postcssConfigContent = `module.exports = {
|
|
123
|
+
plugins: {
|
|
124
|
+
tailwindcss: {},
|
|
125
|
+
autoprefixer: {},
|
|
126
|
+
},
|
|
127
|
+
}`;
|
|
128
|
+
fs.writeFileSync(postcssConfigPath, postcssConfigContent);
|
|
129
|
+
log('ā
Created postcss.config.js', 'green');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Success message
|
|
133
|
+
log('\nš Setup complete!', 'green');
|
|
134
|
+
log('\nš Next steps:');
|
|
135
|
+
log(
|
|
136
|
+
' 1. Import components: import { Button } from "@machinemetrics/mm-react-components"',
|
|
137
|
+
);
|
|
138
|
+
log(
|
|
139
|
+
' 2. Add "carbide" class to your root element to activate the industrial theme',
|
|
140
|
+
);
|
|
141
|
+
log(' 3. The Carbide theme is already imported and ready to use!');
|
|
142
|
+
log(' 4. Check the documentation for examples');
|
|
143
|
+
|
|
144
|
+
log(
|
|
145
|
+
'\nš” Pro tip: The Carbide theme provides industrial-appropriate colors and styling',
|
|
146
|
+
);
|
|
147
|
+
log('\nš§ Tailwind CSS and PostCSS have been configured for you');
|
|
148
|
+
log('š Happy coding!', 'cyan');
|
|
149
|
+
} catch (error) {
|
|
150
|
+
log(`ā Setup failed: ${error.message}`, 'red');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (require.main === module) {
|
|
156
|
+
main();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = { main };
|