galaxy-design 0.2.0
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 +320 -0
- package/dist/bin.js +11 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/add.js +252 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/init-old.js +159 -0
- package/dist/commands/init-old.js.map +1 -0
- package/dist/commands/init.js +266 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cli.js +5 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/registries/blocks-angular.json +89 -0
- package/dist/registries/blocks-flutter.json +60 -0
- package/dist/registries/blocks-react-native.json +60 -0
- package/dist/registries/blocks-react.json +89 -0
- package/dist/registries/blocks-vue.json +89 -0
- package/dist/registries/registry-angular.json +557 -0
- package/dist/registries/registry-flutter.json +491 -0
- package/dist/registries/registry-flutter.json.old +258 -0
- package/dist/registries/registry-react-native.json +491 -0
- package/dist/registries/registry-react-native.json.old +379 -0
- package/dist/registries/registry-react.json +526 -0
- package/dist/registries/registry-vue.json +586 -0
- package/dist/registry.json +460 -0
- package/dist/schemas/components-schema.json +91 -0
- package/dist/templates/tailwind.config.template +45 -0
- package/dist/templates/utils.ts.template +11 -0
- package/dist/utils/component-copier.js +207 -0
- package/dist/utils/component-copier.js.map +1 -0
- package/dist/utils/components-config.js +58 -0
- package/dist/utils/components-config.js.map +1 -0
- package/dist/utils/config-schema.js +221 -0
- package/dist/utils/config-schema.js.map +1 -0
- package/dist/utils/config.js +88 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/detect.js +86 -0
- package/dist/utils/detect.js.map +1 -0
- package/dist/utils/files.js +52 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/framework-registry.js +133 -0
- package/dist/utils/framework-registry.js.map +1 -0
- package/dist/utils/github-fetcher.js +120 -0
- package/dist/utils/github-fetcher.js.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/package-manager.js +173 -0
- package/dist/utils/package-manager.js.map +1 -0
- package/dist/utils/platform-detector.js +176 -0
- package/dist/utils/platform-detector.js.map +1 -0
- package/dist/utils/registry-loader.js +143 -0
- package/dist/utils/registry-loader.js.map +1 -0
- package/dist/utils/registry.js +92 -0
- package/dist/utils/registry.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Detect project platform based on file structure and config files
|
|
6
|
+
*
|
|
7
|
+
* Detection priority:
|
|
8
|
+
* 1. Mobile platforms (React Native, Flutter) - highest priority
|
|
9
|
+
* 2. Web frameworks (Vue, React, Angular)
|
|
10
|
+
* 3. Unknown
|
|
11
|
+
*/ export function detectPlatform(cwd) {
|
|
12
|
+
const evidence = [];
|
|
13
|
+
// Check for Flutter (highest priority for mobile)
|
|
14
|
+
if (existsSync(join(cwd, 'pubspec.yaml'))) {
|
|
15
|
+
evidence.push('Found pubspec.yaml (Flutter project file)');
|
|
16
|
+
// Additional Flutter indicators
|
|
17
|
+
if (existsSync(join(cwd, 'lib'))) {
|
|
18
|
+
evidence.push('Found lib/ directory (Flutter source directory)');
|
|
19
|
+
}
|
|
20
|
+
if (existsSync(join(cwd, 'android')) && existsSync(join(cwd, 'ios'))) {
|
|
21
|
+
evidence.push('Found android/ and ios/ directories (Flutter mobile platforms)');
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
platform: 'flutter',
|
|
25
|
+
confidence: 'high',
|
|
26
|
+
evidence
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Check for React Native
|
|
30
|
+
const hasPackageJson = existsSync(join(cwd, 'package.json'));
|
|
31
|
+
const hasIosDir = existsSync(join(cwd, 'ios'));
|
|
32
|
+
const hasAndroidDir = existsSync(join(cwd, 'android'));
|
|
33
|
+
const hasAppJson = existsSync(join(cwd, 'app.json'));
|
|
34
|
+
if (hasPackageJson && (hasIosDir || hasAndroidDir)) {
|
|
35
|
+
evidence.push('Found package.json with mobile platform directories');
|
|
36
|
+
if (hasIosDir) evidence.push('Found ios/ directory');
|
|
37
|
+
if (hasAndroidDir) evidence.push('Found android/ directory');
|
|
38
|
+
if (hasAppJson) evidence.push('Found app.json (React Native config)');
|
|
39
|
+
// Check package.json for react-native dependency
|
|
40
|
+
try {
|
|
41
|
+
var _packageJson_dependencies;
|
|
42
|
+
const packageJson = require(join(cwd, 'package.json'));
|
|
43
|
+
if ((_packageJson_dependencies = packageJson.dependencies) == null ? void 0 : _packageJson_dependencies['react-native']) {
|
|
44
|
+
evidence.push('Found react-native in dependencies');
|
|
45
|
+
return {
|
|
46
|
+
platform: 'react-native',
|
|
47
|
+
confidence: 'high',
|
|
48
|
+
evidence
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// Ignore JSON parse errors
|
|
53
|
+
}
|
|
54
|
+
// If has mobile dirs but no react-native dep, still consider it RN with medium confidence
|
|
55
|
+
return {
|
|
56
|
+
platform: 'react-native',
|
|
57
|
+
confidence: 'medium',
|
|
58
|
+
evidence
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Check for Web frameworks (only if not mobile)
|
|
62
|
+
if (hasPackageJson) {
|
|
63
|
+
try {
|
|
64
|
+
const packageJson = require(join(cwd, 'package.json'));
|
|
65
|
+
const deps = _extends({}, packageJson.dependencies, packageJson.devDependencies);
|
|
66
|
+
// Check for Vue
|
|
67
|
+
if (deps['vue'] || deps['@vue/cli']) {
|
|
68
|
+
evidence.push('Found Vue in dependencies');
|
|
69
|
+
if (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {
|
|
70
|
+
evidence.push('Found vite.config (Vue + Vite)');
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
platform: 'vue',
|
|
74
|
+
confidence: 'high',
|
|
75
|
+
evidence,
|
|
76
|
+
framework: 'vue'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Check for Angular
|
|
80
|
+
if (deps['@angular/core']) {
|
|
81
|
+
evidence.push('Found @angular/core in dependencies');
|
|
82
|
+
if (existsSync(join(cwd, 'angular.json'))) {
|
|
83
|
+
evidence.push('Found angular.json (Angular config)');
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
platform: 'angular',
|
|
87
|
+
confidence: 'high',
|
|
88
|
+
evidence,
|
|
89
|
+
framework: 'angular'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Check for React (web)
|
|
93
|
+
if (deps['react'] && !hasIosDir && !hasAndroidDir) {
|
|
94
|
+
evidence.push('Found React in dependencies (web project)');
|
|
95
|
+
if (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {
|
|
96
|
+
evidence.push('Found vite.config (React + Vite)');
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
platform: 'react',
|
|
100
|
+
confidence: 'high',
|
|
101
|
+
evidence,
|
|
102
|
+
framework: 'react'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
// Ignore errors
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Unknown platform
|
|
110
|
+
return {
|
|
111
|
+
platform: 'unknown',
|
|
112
|
+
confidence: 'low',
|
|
113
|
+
evidence: [
|
|
114
|
+
'No recognized project structure found'
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get human-readable platform name
|
|
120
|
+
*/ export function getPlatformDisplayName(platform) {
|
|
121
|
+
const names = {
|
|
122
|
+
'react-native': 'React Native',
|
|
123
|
+
'flutter': 'Flutter',
|
|
124
|
+
'vue': 'Vue.js',
|
|
125
|
+
'react': 'React',
|
|
126
|
+
'angular': 'Angular',
|
|
127
|
+
'unknown': 'Unknown'
|
|
128
|
+
};
|
|
129
|
+
return names[platform];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if platform is mobile
|
|
133
|
+
*/ export function isMobilePlatform(platform) {
|
|
134
|
+
return platform === 'react-native' || platform === 'flutter';
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Check if platform is web
|
|
138
|
+
*/ export function isWebPlatform(platform) {
|
|
139
|
+
return platform === 'vue' || platform === 'react' || platform === 'angular';
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get registry file name for platform
|
|
143
|
+
*/ export function getRegistryFileName(platform) {
|
|
144
|
+
switch(platform){
|
|
145
|
+
case 'react-native':
|
|
146
|
+
return 'registry-react-native.json';
|
|
147
|
+
case 'flutter':
|
|
148
|
+
return 'registry-flutter.json';
|
|
149
|
+
case 'vue':
|
|
150
|
+
case 'react':
|
|
151
|
+
case 'angular':
|
|
152
|
+
return 'registry.json'; // Web platforms use same registry
|
|
153
|
+
default:
|
|
154
|
+
return 'registry.json';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get component source directory for platform
|
|
159
|
+
*/ export function getComponentSourceDir(platform) {
|
|
160
|
+
switch(platform){
|
|
161
|
+
case 'react-native':
|
|
162
|
+
return 'packages/react-native/src/components';
|
|
163
|
+
case 'flutter':
|
|
164
|
+
return 'packages/flutter/lib/components';
|
|
165
|
+
case 'vue':
|
|
166
|
+
return 'packages/vue/src/components';
|
|
167
|
+
case 'react':
|
|
168
|
+
return 'packages/react/src/components';
|
|
169
|
+
case 'angular':
|
|
170
|
+
return 'packages/angular/src/components';
|
|
171
|
+
default:
|
|
172
|
+
throw new Error(`Unknown platform: ${platform}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=platform-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/platform-detector.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\n\n/**\n * Supported platforms for Galaxy UI CLI\n */\nexport type Platform = 'react-native' | 'flutter' | 'vue' | 'react' | 'angular' | 'unknown';\n\n/**\n * Platform detection result with confidence level\n */\nexport interface PlatformDetectionResult {\n\tplatform: Platform;\n\tconfidence: 'high' | 'medium' | 'low';\n\tevidence: string[];\n\tframework?: string; // For web platforms: vue, react, angular\n}\n\n/**\n * Detect project platform based on file structure and config files\n *\n * Detection priority:\n * 1. Mobile platforms (React Native, Flutter) - highest priority\n * 2. Web frameworks (Vue, React, Angular)\n * 3. Unknown\n */\nexport function detectPlatform(cwd: string): PlatformDetectionResult {\n\tconst evidence: string[] = [];\n\n\t// Check for Flutter (highest priority for mobile)\n\tif (existsSync(join(cwd, 'pubspec.yaml'))) {\n\t\tevidence.push('Found pubspec.yaml (Flutter project file)');\n\n\t\t// Additional Flutter indicators\n\t\tif (existsSync(join(cwd, 'lib'))) {\n\t\t\tevidence.push('Found lib/ directory (Flutter source directory)');\n\t\t}\n\t\tif (existsSync(join(cwd, 'android')) && existsSync(join(cwd, 'ios'))) {\n\t\t\tevidence.push('Found android/ and ios/ directories (Flutter mobile platforms)');\n\t\t}\n\n\t\treturn {\n\t\t\tplatform: 'flutter',\n\t\t\tconfidence: 'high',\n\t\t\tevidence,\n\t\t};\n\t}\n\n\t// Check for React Native\n\tconst hasPackageJson = existsSync(join(cwd, 'package.json'));\n\tconst hasIosDir = existsSync(join(cwd, 'ios'));\n\tconst hasAndroidDir = existsSync(join(cwd, 'android'));\n\tconst hasAppJson = existsSync(join(cwd, 'app.json'));\n\n\tif (hasPackageJson && (hasIosDir || hasAndroidDir)) {\n\t\tevidence.push('Found package.json with mobile platform directories');\n\n\t\tif (hasIosDir) evidence.push('Found ios/ directory');\n\t\tif (hasAndroidDir) evidence.push('Found android/ directory');\n\t\tif (hasAppJson) evidence.push('Found app.json (React Native config)');\n\n\t\t// Check package.json for react-native dependency\n\t\ttry {\n\t\t\tconst packageJson = require(join(cwd, 'package.json'));\n\t\t\tif (packageJson.dependencies?.['react-native']) {\n\t\t\t\tevidence.push('Found react-native in dependencies');\n\t\t\t\treturn {\n\t\t\t\t\tplatform: 'react-native',\n\t\t\t\t\tconfidence: 'high',\n\t\t\t\t\tevidence,\n\t\t\t\t};\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Ignore JSON parse errors\n\t\t}\n\n\t\t// If has mobile dirs but no react-native dep, still consider it RN with medium confidence\n\t\treturn {\n\t\t\tplatform: 'react-native',\n\t\t\tconfidence: 'medium',\n\t\t\tevidence,\n\t\t};\n\t}\n\n\t// Check for Web frameworks (only if not mobile)\n\tif (hasPackageJson) {\n\t\ttry {\n\t\t\tconst packageJson = require(join(cwd, 'package.json'));\n\t\t\tconst deps = { ...packageJson.dependencies, ...packageJson.devDependencies };\n\n\t\t\t// Check for Vue\n\t\t\tif (deps['vue'] || deps['@vue/cli']) {\n\t\t\t\tevidence.push('Found Vue in dependencies');\n\t\t\t\tif (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {\n\t\t\t\t\tevidence.push('Found vite.config (Vue + Vite)');\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tplatform: 'vue',\n\t\t\t\t\tconfidence: 'high',\n\t\t\t\t\tevidence,\n\t\t\t\t\tframework: 'vue',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check for Angular\n\t\t\tif (deps['@angular/core']) {\n\t\t\t\tevidence.push('Found @angular/core in dependencies');\n\t\t\t\tif (existsSync(join(cwd, 'angular.json'))) {\n\t\t\t\t\tevidence.push('Found angular.json (Angular config)');\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tplatform: 'angular',\n\t\t\t\t\tconfidence: 'high',\n\t\t\t\t\tevidence,\n\t\t\t\t\tframework: 'angular',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check for React (web)\n\t\t\tif (deps['react'] && !hasIosDir && !hasAndroidDir) {\n\t\t\t\tevidence.push('Found React in dependencies (web project)');\n\t\t\t\tif (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js'))) {\n\t\t\t\t\tevidence.push('Found vite.config (React + Vite)');\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tplatform: 'react',\n\t\t\t\t\tconfidence: 'high',\n\t\t\t\t\tevidence,\n\t\t\t\t\tframework: 'react',\n\t\t\t\t};\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Ignore errors\n\t\t}\n\t}\n\n\t// Unknown platform\n\treturn {\n\t\tplatform: 'unknown',\n\t\tconfidence: 'low',\n\t\tevidence: ['No recognized project structure found'],\n\t};\n}\n\n/**\n * Get human-readable platform name\n */\nexport function getPlatformDisplayName(platform: Platform): string {\n\tconst names: Record<Platform, string> = {\n\t\t'react-native': 'React Native',\n\t\t'flutter': 'Flutter',\n\t\t'vue': 'Vue.js',\n\t\t'react': 'React',\n\t\t'angular': 'Angular',\n\t\t'unknown': 'Unknown',\n\t};\n\treturn names[platform];\n}\n\n/**\n * Check if platform is mobile\n */\nexport function isMobilePlatform(platform: Platform): boolean {\n\treturn platform === 'react-native' || platform === 'flutter';\n}\n\n/**\n * Check if platform is web\n */\nexport function isWebPlatform(platform: Platform): boolean {\n\treturn platform === 'vue' || platform === 'react' || platform === 'angular';\n}\n\n/**\n * Get registry file name for platform\n */\nexport function getRegistryFileName(platform: Platform): string {\n\tswitch (platform) {\n\t\tcase 'react-native':\n\t\t\treturn 'registry-react-native.json';\n\t\tcase 'flutter':\n\t\t\treturn 'registry-flutter.json';\n\t\tcase 'vue':\n\t\tcase 'react':\n\t\tcase 'angular':\n\t\t\treturn 'registry.json'; // Web platforms use same registry\n\t\tdefault:\n\t\t\treturn 'registry.json';\n\t}\n}\n\n/**\n * Get component source directory for platform\n */\nexport function getComponentSourceDir(platform: Platform): string {\n\tswitch (platform) {\n\t\tcase 'react-native':\n\t\t\treturn 'packages/react-native/src/components';\n\t\tcase 'flutter':\n\t\t\treturn 'packages/flutter/lib/components';\n\t\tcase 'vue':\n\t\t\treturn 'packages/vue/src/components';\n\t\tcase 'react':\n\t\t\treturn 'packages/react/src/components';\n\t\tcase 'angular':\n\t\t\treturn 'packages/angular/src/components';\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown platform: ${platform}`);\n\t}\n}\n"],"names":["existsSync","join","detectPlatform","cwd","evidence","push","platform","confidence","hasPackageJson","hasIosDir","hasAndroidDir","hasAppJson","packageJson","require","dependencies","error","deps","devDependencies","framework","getPlatformDisplayName","names","isMobilePlatform","isWebPlatform","getRegistryFileName","getComponentSourceDir","Error"],"mappings":";AAAA,SAASA,UAAU,QAAQ,KAAK;AAChC,SAASC,IAAI,QAAQ,OAAO;AAiB5B;;;;;;;CAOC,GACD,OAAO,SAASC,eAAeC,GAAW;IACzC,MAAMC,WAAqB,EAAE;IAE7B,kDAAkD;IAClD,IAAIJ,WAAWC,KAAKE,KAAK,kBAAkB;QAC1CC,SAASC,IAAI,CAAC;QAEd,gCAAgC;QAChC,IAAIL,WAAWC,KAAKE,KAAK,SAAS;YACjCC,SAASC,IAAI,CAAC;QACf;QACA,IAAIL,WAAWC,KAAKE,KAAK,eAAeH,WAAWC,KAAKE,KAAK,SAAS;YACrEC,SAASC,IAAI,CAAC;QACf;QAEA,OAAO;YACNC,UAAU;YACVC,YAAY;YACZH;QACD;IACD;IAEA,yBAAyB;IACzB,MAAMI,iBAAiBR,WAAWC,KAAKE,KAAK;IAC5C,MAAMM,YAAYT,WAAWC,KAAKE,KAAK;IACvC,MAAMO,gBAAgBV,WAAWC,KAAKE,KAAK;IAC3C,MAAMQ,aAAaX,WAAWC,KAAKE,KAAK;IAExC,IAAIK,kBAAmBC,CAAAA,aAAaC,aAAY,GAAI;QACnDN,SAASC,IAAI,CAAC;QAEd,IAAII,WAAWL,SAASC,IAAI,CAAC;QAC7B,IAAIK,eAAeN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AoB;oBACvFC,SAASC,IAAI,CAAC;gBACf;gBACA,OAAO;oBACNC,UAAU;oBACVC,YAAY;oBACZH;oBACAc,WAAW;gBACZ;YACD;QACD,EAAE,OAAOH,OAAO;QACf,gBAAgB;QACjB;IACD;IAEA,mBAAmB;IACnB,OAAO;QACNT,UAAU;QACVC,YAAY;QACZH,UAAU;YAAC;SAAwC;IACpD;AACD;AAEA;;CAEC,GACD,OAAO,SAASe,uBAAuBb,QAAkB;IACxD,MAAMc,QAAkC;QACvC,gBAAgB;QAChB,WAAW;QACX,OAAO;QACP,SAAS;QACT,WAAW;QACX,WAAW;IACZ;IACA,OAAOA,KAAK,CAACd,SAAS;AACvB;AAEA;;CAEC,GACD,OAAO,SAASe,iBAAiBf,QAAkB;IAClD,OAAOA,aAAa,kBAAkBA,aAAa;AACpD;AAEA;;CAEC,GACD,OAAO,SAASgB,cAAchB,QAAkB;IAC/C,OAAOA,aAAa,SAASA,aAAa,WAAWA,aAAa;AACnE;AAEA;;CAEC,GACD,OAAO,SAASiB,oBAAoBjB,QAAkB;IACrD,OAAQA;QACP,KAAK;YACJ,OAAO;QACR,KAAK;YACJ,OAAO;QACR,KAAK;QACL,KAAK;QACL,KAAK;YACJ,OAAO,iBAAiB,kCAAkC;QAC3D;YACC,OAAO;IACT;AACD;AAEA;;CAEC,GACD,OAAO,SAASkB,sBAAsBlB,QAAkB;IACvD,OAAQA;QACP,KAAK;YACJ,OAAO;QACR,KAAK;YACJ,OAAO;QACR,KAAK;YACJ,OAAO;QACR,KAAK;YACJ,OAAO;QACR,KAAK;YACJ,OAAO;QACR;YACC,MAAM,IAAImB,MAAM,CAAC,kBAAkB,EAAEnB,UAAU;IACjD;AACD"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { getRegistryFileName } from './platform-detector';
|
|
4
|
+
/**
|
|
5
|
+
* Load registry for specific platform
|
|
6
|
+
*
|
|
7
|
+
* @param platform - Target platform
|
|
8
|
+
* @param registryDir - Directory containing registry files (default: CLI src dir)
|
|
9
|
+
* @returns Registry data
|
|
10
|
+
*/ export function loadRegistry(platform, registryDir) {
|
|
11
|
+
const fileName = getRegistryFileName(platform);
|
|
12
|
+
const registryPath = registryDir ? join(registryDir, fileName) : join(__dirname, '..', fileName);
|
|
13
|
+
try {
|
|
14
|
+
const content = readFileSync(registryPath, 'utf-8');
|
|
15
|
+
const registry = JSON.parse(content);
|
|
16
|
+
return registry;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error(`Failed to load registry for platform "${platform}": ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get component metadata from registry
|
|
23
|
+
*
|
|
24
|
+
* @param componentName - Name of component to get
|
|
25
|
+
* @param platform - Target platform
|
|
26
|
+
* @param registryDir - Optional registry directory
|
|
27
|
+
* @returns Component metadata or undefined if not found
|
|
28
|
+
*/ export function getComponent(componentName, platform, registryDir) {
|
|
29
|
+
const registry = loadRegistry(platform, registryDir);
|
|
30
|
+
return registry.components[componentName];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List all components for platform
|
|
34
|
+
*
|
|
35
|
+
* @param platform - Target platform
|
|
36
|
+
* @param category - Optional category filter
|
|
37
|
+
* @param registryDir - Optional registry directory
|
|
38
|
+
* @returns Array of component names
|
|
39
|
+
*/ export function listComponents(platform, category, registryDir) {
|
|
40
|
+
const registry = loadRegistry(platform, registryDir);
|
|
41
|
+
if (category) {
|
|
42
|
+
// Filter by category
|
|
43
|
+
const components = Object.entries(registry.components).filter(([, meta])=>meta.type === category).map(([name])=>name);
|
|
44
|
+
return components.sort();
|
|
45
|
+
}
|
|
46
|
+
// Return all components
|
|
47
|
+
return Object.keys(registry.components).sort();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all component groups/categories
|
|
51
|
+
*
|
|
52
|
+
* @param platform - Target platform
|
|
53
|
+
* @param registryDir - Optional registry directory
|
|
54
|
+
* @returns Component groups
|
|
55
|
+
*/ export function getGroups(platform, registryDir) {
|
|
56
|
+
const registry = loadRegistry(platform, registryDir);
|
|
57
|
+
return registry.groups;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Search components by name or description
|
|
61
|
+
*
|
|
62
|
+
* @param query - Search query
|
|
63
|
+
* @param platform - Target platform
|
|
64
|
+
* @param registryDir - Optional registry directory
|
|
65
|
+
* @returns Array of matching component names
|
|
66
|
+
*/ export function searchComponents(query, platform, registryDir) {
|
|
67
|
+
const registry = loadRegistry(platform, registryDir);
|
|
68
|
+
const lowerQuery = query.toLowerCase();
|
|
69
|
+
const results = Object.entries(registry.components).map(([name, meta])=>{
|
|
70
|
+
const nameMatch = name.toLowerCase().includes(lowerQuery);
|
|
71
|
+
const descMatch = meta.description.toLowerCase().includes(lowerQuery);
|
|
72
|
+
const typeMatch = meta.type.toLowerCase().includes(lowerQuery);
|
|
73
|
+
let relevance = 'low';
|
|
74
|
+
if (nameMatch) relevance = 'high';
|
|
75
|
+
else if (typeMatch) relevance = 'medium';
|
|
76
|
+
else if (descMatch) relevance = 'low';
|
|
77
|
+
const isMatch = nameMatch || descMatch || typeMatch;
|
|
78
|
+
return {
|
|
79
|
+
name,
|
|
80
|
+
relevance,
|
|
81
|
+
isMatch
|
|
82
|
+
};
|
|
83
|
+
}).filter((result)=>result.isMatch).sort((a, b)=>{
|
|
84
|
+
const order = {
|
|
85
|
+
high: 0,
|
|
86
|
+
medium: 1,
|
|
87
|
+
low: 2
|
|
88
|
+
};
|
|
89
|
+
return order[a.relevance] - order[b.relevance];
|
|
90
|
+
});
|
|
91
|
+
return results;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Validate component dependencies
|
|
95
|
+
*
|
|
96
|
+
* Check if all component dependencies are available
|
|
97
|
+
*
|
|
98
|
+
* @param componentName - Component to validate
|
|
99
|
+
* @param platform - Target platform
|
|
100
|
+
* @param registryDir - Optional registry directory
|
|
101
|
+
* @returns Validation result with missing dependencies
|
|
102
|
+
*/ export function validateComponentDependencies(componentName, platform, registryDir) {
|
|
103
|
+
const component = getComponent(componentName, platform, registryDir);
|
|
104
|
+
if (!component) {
|
|
105
|
+
return {
|
|
106
|
+
valid: false,
|
|
107
|
+
missing: []
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Check internal component dependencies
|
|
111
|
+
const missing = [];
|
|
112
|
+
const registry = loadRegistry(platform, registryDir);
|
|
113
|
+
for (const dep of component.dependencies){
|
|
114
|
+
if (!registry.components[dep]) {
|
|
115
|
+
missing.push(dep);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
valid: missing.length === 0,
|
|
120
|
+
missing
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get component statistics for platform
|
|
125
|
+
*
|
|
126
|
+
* @param platform - Target platform
|
|
127
|
+
* @param registryDir - Optional registry directory
|
|
128
|
+
* @returns Statistics object
|
|
129
|
+
*/ export function getRegistryStats(platform, registryDir) {
|
|
130
|
+
const registry = loadRegistry(platform, registryDir);
|
|
131
|
+
const groupCounts = {};
|
|
132
|
+
for (const [groupName, group] of Object.entries(registry.groups)){
|
|
133
|
+
groupCounts[groupName] = group.components.length;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
totalComponents: Object.keys(registry.components).length,
|
|
137
|
+
groupCounts,
|
|
138
|
+
platform: registry.platform || platform,
|
|
139
|
+
version: registry.version || 'unknown'
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=registry-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/registry-loader.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { join } from 'path';\nimport type { Platform } from './platform-detector';\nimport { getRegistryFileName } from './platform-detector';\n\n/**\n * Component metadata from registry\n */\nexport interface ComponentMetadata {\n\tname: string;\n\ttype: string;\n\tdescription: string;\n\tfiles: string[];\n\tdependencies: string[];\n\tpeerDependencies: string[];\n\texports: string[];\n\tselector?: string; // For Angular\n}\n\n/**\n * Component group/category\n */\nexport interface ComponentGroup {\n\tname: string;\n\tdescription?: string;\n\tcomponents: string[];\n}\n\n/**\n * Registry data structure\n */\nexport interface Registry {\n\tplatform?: string;\n\tversion?: string;\n\tcomponents: Record<string, ComponentMetadata>;\n\tgroups: Record<string, ComponentGroup>;\n}\n\n/**\n * Load registry for specific platform\n *\n * @param platform - Target platform\n * @param registryDir - Directory containing registry files (default: CLI src dir)\n * @returns Registry data\n */\nexport function loadRegistry(platform: Platform, registryDir?: string): Registry {\n\tconst fileName = getRegistryFileName(platform);\n\tconst registryPath = registryDir\n\t\t? join(registryDir, fileName)\n\t\t: join(__dirname, '..', fileName);\n\n\ttry {\n\t\tconst content = readFileSync(registryPath, 'utf-8');\n\t\tconst registry = JSON.parse(content) as Registry;\n\t\treturn registry;\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to load registry for platform \"${platform}\": ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t);\n\t}\n}\n\n/**\n * Get component metadata from registry\n *\n * @param componentName - Name of component to get\n * @param platform - Target platform\n * @param registryDir - Optional registry directory\n * @returns Component metadata or undefined if not found\n */\nexport function getComponent(\n\tcomponentName: string,\n\tplatform: Platform,\n\tregistryDir?: string,\n): ComponentMetadata | undefined {\n\tconst registry = loadRegistry(platform, registryDir);\n\treturn registry.components[componentName];\n}\n\n/**\n * List all components for platform\n *\n * @param platform - Target platform\n * @param category - Optional category filter\n * @param registryDir - Optional registry directory\n * @returns Array of component names\n */\nexport function listComponents(\n\tplatform: Platform,\n\tcategory?: string,\n\tregistryDir?: string,\n): string[] {\n\tconst registry = loadRegistry(platform, registryDir);\n\n\tif (category) {\n\t\t// Filter by category\n\t\tconst components = Object.entries(registry.components)\n\t\t\t.filter(([, meta]) => meta.type === category)\n\t\t\t.map(([name]) => name);\n\t\treturn components.sort();\n\t}\n\n\t// Return all components\n\treturn Object.keys(registry.components).sort();\n}\n\n/**\n * Get all component groups/categories\n *\n * @param platform - Target platform\n * @param registryDir - Optional registry directory\n * @returns Component groups\n */\nexport function getGroups(platform: Platform, registryDir?: string): Record<string, ComponentGroup> {\n\tconst registry = loadRegistry(platform, registryDir);\n\treturn registry.groups;\n}\n\n/**\n * Search components by name or description\n *\n * @param query - Search query\n * @param platform - Target platform\n * @param registryDir - Optional registry directory\n * @returns Array of matching component names\n */\nexport function searchComponents(\n\tquery: string,\n\tplatform: Platform,\n\tregistryDir?: string,\n): Array<{ name: string; relevance: 'high' | 'medium' | 'low' }> {\n\tconst registry = loadRegistry(platform, registryDir);\n\tconst lowerQuery = query.toLowerCase();\n\n\tconst results = Object.entries(registry.components)\n\t\t.map(([name, meta]) => {\n\t\t\tconst nameMatch = name.toLowerCase().includes(lowerQuery);\n\t\t\tconst descMatch = meta.description.toLowerCase().includes(lowerQuery);\n\t\t\tconst typeMatch = meta.type.toLowerCase().includes(lowerQuery);\n\n\t\t\tlet relevance: 'high' | 'medium' | 'low' = 'low';\n\t\t\tif (nameMatch) relevance = 'high';\n\t\t\telse if (typeMatch) relevance = 'medium';\n\t\t\telse if (descMatch) relevance = 'low';\n\n\t\t\tconst isMatch = nameMatch || descMatch || typeMatch;\n\n\t\t\treturn { name, relevance, isMatch };\n\t\t})\n\t\t.filter((result) => result.isMatch)\n\t\t.sort((a, b) => {\n\t\t\tconst order = { high: 0, medium: 1, low: 2 };\n\t\t\treturn order[a.relevance] - order[b.relevance];\n\t\t});\n\n\treturn results;\n}\n\n/**\n * Validate component dependencies\n *\n * Check if all component dependencies are available\n *\n * @param componentName - Component to validate\n * @param platform - Target platform\n * @param registryDir - Optional registry directory\n * @returns Validation result with missing dependencies\n */\nexport function validateComponentDependencies(\n\tcomponentName: string,\n\tplatform: Platform,\n\tregistryDir?: string,\n): { valid: boolean; missing: string[] } {\n\tconst component = getComponent(componentName, platform, registryDir);\n\n\tif (!component) {\n\t\treturn { valid: false, missing: [] };\n\t}\n\n\t// Check internal component dependencies\n\tconst missing: string[] = [];\n\tconst registry = loadRegistry(platform, registryDir);\n\n\tfor (const dep of component.dependencies) {\n\t\tif (!registry.components[dep]) {\n\t\t\tmissing.push(dep);\n\t\t}\n\t}\n\n\treturn {\n\t\tvalid: missing.length === 0,\n\t\tmissing,\n\t};\n}\n\n/**\n * Get component statistics for platform\n *\n * @param platform - Target platform\n * @param registryDir - Optional registry directory\n * @returns Statistics object\n */\nexport function getRegistryStats(\n\tplatform: Platform,\n\tregistryDir?: string,\n): {\n\ttotalComponents: number;\n\tgroupCounts: Record<string, number>;\n\tplatform: string;\n\tversion: string;\n} {\n\tconst registry = loadRegistry(platform, registryDir);\n\n\tconst groupCounts: Record<string, number> = {};\n\tfor (const [groupName, group] of Object.entries(registry.groups)) {\n\t\tgroupCounts[groupName] = group.components.length;\n\t}\n\n\treturn {\n\t\ttotalComponents: Object.keys(registry.components).length,\n\t\tgroupCounts,\n\t\tplatform: registry.platform || platform,\n\t\tversion: registry.version || 'unknown',\n\t};\n}\n"],"names":["readFileSync","join","getRegistryFileName","loadRegistry","platform","registryDir","fileName","registryPath","__dirname","content","registry","JSON","parse","error","Error","message","getComponent","componentName","components","listComponents","category","Object","entries","filter","meta","type","map","name","sort","keys","getGroups","groups","searchComponents","query","lowerQuery","toLowerCase","results","nameMatch","includes","descMatch","description","typeMatch","relevance","isMatch","result","a","b","order","high","medium","low","validateComponentDependencies","component","valid","missing","dep","dependencies","push","length","getRegistryStats","groupCounts","groupName","group","totalComponents","version"],"mappings":"AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC,mBAAmB,QAAQ,sBAAsB;AAmC1D;;;;;;CAMC,GACD,OAAO,SAASC,aAAaC,QAAkB,EAAEC,WAAoB;IACpE,MAAMC,WAAWJ,oBA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,EAClBC,WAAoB;IAOpB,MAAMK,WAAWP,aAAaC,UAAUC;IAExC,MAAMuD,cAAsC,CAAC;IAC7C,KAAK,MAAM,CAACC,WAAWC,MAAM,IAAIzC,OAAOC,OAAO,CAACZ,SAASqB,MAAM,EAAG;QACjE6B,WAAW,CAACC,UAAU,GAAGC,MAAM5C,UAAU,CAACwC,MAAM;IACjD;IAEA,OAAO;QACNK,iBAAiB1C,OAAOQ,IAAI,CAACnB,SAASQ,UAAU,EAAEwC,MAAM;QACxDE;QACAxD,UAAUM,SAASN,QAAQ,IAAIA;QAC/B4D,SAAStD,SAASsD,OAAO,IAAI;IAC9B;AACD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { resolve, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
let cachedRegistry = null;
|
|
7
|
+
/**
|
|
8
|
+
* Load the component registry
|
|
9
|
+
*/ export function loadRegistry() {
|
|
10
|
+
if (cachedRegistry) {
|
|
11
|
+
return cachedRegistry;
|
|
12
|
+
}
|
|
13
|
+
const registryPath = resolve(__dirname, '../registry.json');
|
|
14
|
+
const registryContent = readFileSync(registryPath, 'utf-8');
|
|
15
|
+
cachedRegistry = JSON.parse(registryContent);
|
|
16
|
+
return cachedRegistry;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a component by name
|
|
20
|
+
*/ export function getComponent(name) {
|
|
21
|
+
const registry = loadRegistry();
|
|
22
|
+
return registry.components[name];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all components
|
|
26
|
+
*/ export function getAllComponents() {
|
|
27
|
+
const registry = loadRegistry();
|
|
28
|
+
return registry.components;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get components by type
|
|
32
|
+
*/ export function getComponentsByType(type) {
|
|
33
|
+
const registry = loadRegistry();
|
|
34
|
+
return Object.values(registry.components).filter((c)=>c.type === type);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get components by group name
|
|
38
|
+
*/ export function getComponentsByGroup(groupName) {
|
|
39
|
+
const registry = loadRegistry();
|
|
40
|
+
const group = registry.groups[groupName];
|
|
41
|
+
if (!group) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return group.components.map((name)=>registry.components[name]).filter(Boolean);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get all component groups
|
|
48
|
+
*/ export function getAllGroups() {
|
|
49
|
+
const registry = loadRegistry();
|
|
50
|
+
return registry.groups;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a component exists
|
|
54
|
+
*/ export function componentExists(name) {
|
|
55
|
+
const registry = loadRegistry();
|
|
56
|
+
return !!registry.components[name];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get component dependencies (including peer dependencies)
|
|
60
|
+
*/ export function getComponentDependencies(name) {
|
|
61
|
+
const component = getComponent(name);
|
|
62
|
+
if (!component) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const deps = new Set();
|
|
66
|
+
// Add component dependencies
|
|
67
|
+
component.dependencies.forEach((dep)=>deps.add(dep));
|
|
68
|
+
return Array.from(deps);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolve component names with aliases
|
|
72
|
+
*/ export function resolveComponentName(input) {
|
|
73
|
+
const registry = loadRegistry();
|
|
74
|
+
// Check exact match
|
|
75
|
+
if (registry.components[input]) {
|
|
76
|
+
return input;
|
|
77
|
+
}
|
|
78
|
+
// Check group match
|
|
79
|
+
if (registry.groups[input]) {
|
|
80
|
+
return input;
|
|
81
|
+
}
|
|
82
|
+
// Check case-insensitive match
|
|
83
|
+
const lowerInput = input.toLowerCase();
|
|
84
|
+
for (const name of Object.keys(registry.components)){
|
|
85
|
+
if (name.toLowerCase() === lowerInput) {
|
|
86
|
+
return name;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/registry.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { resolve, dirname } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport interface Component {\n name: string;\n selector: string;\n type: 'form' | 'layout' | 'navigation' | 'data-display' | 'modal-overlay' | 'other';\n description: string;\n files: string[];\n dependencies: string[];\n peerDependencies: string[];\n exports: string[];\n}\n\nexport interface ComponentGroup {\n name: string;\n components: string[];\n}\n\nexport interface Registry {\n components: Record<string, Component>;\n groups: Record<string, ComponentGroup>;\n}\n\nlet cachedRegistry: Registry | null = null;\n\n/**\n * Load the component registry\n */\nexport function loadRegistry(): Registry {\n if (cachedRegistry) {\n return cachedRegistry;\n }\n\n const registryPath = resolve(__dirname, '../registry.json');\n const registryContent = readFileSync(registryPath, 'utf-8');\n cachedRegistry = JSON.parse(registryContent);\n return cachedRegistry;\n}\n\n/**\n * Get a component by name\n */\nexport function getComponent(name: string): Component | undefined {\n const registry = loadRegistry();\n return registry.components[name];\n}\n\n/**\n * Get all components\n */\nexport function getAllComponents(): Record<string, Component> {\n const registry = loadRegistry();\n return registry.components;\n}\n\n/**\n * Get components by type\n */\nexport function getComponentsByType(type: 'form' | 'layout' | 'navigation' | 'data-display' | 'modal-overlay' | 'other'): Component[] {\n const registry = loadRegistry();\n return Object.values(registry.components).filter(c => c.type === type);\n}\n\n/**\n * Get components by group name\n */\nexport function getComponentsByGroup(groupName: string): Component[] {\n const registry = loadRegistry();\n const group = registry.groups[groupName];\n\n if (!group) {\n return [];\n }\n\n return group.components\n .map(name => registry.components[name])\n .filter(Boolean);\n}\n\n/**\n * Get all component groups\n */\nexport function getAllGroups(): Record<string, ComponentGroup> {\n const registry = loadRegistry();\n return registry.groups;\n}\n\n/**\n * Check if a component exists\n */\nexport function componentExists(name: string): boolean {\n const registry = loadRegistry();\n return !!registry.components[name];\n}\n\n/**\n * Get component dependencies (including peer dependencies)\n */\nexport function getComponentDependencies(name: string): string[] {\n const component = getComponent(name);\n if (!component) {\n return [];\n }\n\n const deps = new Set<string>();\n\n // Add component dependencies\n component.dependencies.forEach(dep => deps.add(dep));\n\n return Array.from(deps);\n}\n\n/**\n * Resolve component names with aliases\n */\nexport function resolveComponentName(input: string): string | null {\n const registry = loadRegistry();\n\n // Check exact match\n if (registry.components[input]) {\n return input;\n }\n\n // Check group match\n if (registry.groups[input]) {\n return input;\n }\n\n // Check case-insensitive match\n const lowerInput = input.toLowerCase();\n for (const name of Object.keys(registry.components)) {\n if (name.toLowerCase() === lowerInput) {\n return name;\n }\n }\n\n return null;\n}\n"],"names":["readFileSync","resolve","dirname","fileURLToPath","__filename","url","__dirname","cachedRegistry","loadRegistry","registryPath","registryContent","JSON","parse","getComponent","name","registry","components","getAllComponents","getComponentsByType","type","Object","values","filter","c","getComponentsByGroup","groupName","group","groups","map","Boolean","getAllGroups","componentExists","getComponentDependencies","component","deps","Set","dependencies","forEach","dep","add","Array","from","resolveComponentName","input","lowerInput","toLowerCase","keys"],"mappings":"AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,OAAO,EAAEC,OAAO,QAAQ,OAAO;AACxC,SAASC,aAAa,QAAQ,MAAM;AAEpC,MAAMC,aAAaD,cAAc,YAAYE,GAAG;AAChD,MAAMC,YAAYJ,QAAQE;AAuB1B,IAAIG,iBAAkC;AAEtC;;CAEC,GACD,OAAO,SAASC;IACd,IAAID,gBAAgB;QAClB,OAAOA;IACT;IAEA,MAAME,eAAeR,QAAQK,WAAW;IACxC,MAAMI,kBAAkBV,aAAaS,cAAc;IACnDF,iBAAiBI,KAAKC,KAAK,CAACF;IAC5B,OAAOH;AAC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AAC2B,MAAM,EAAE;QAC9B,OAAOA;IACT;IAEA,oBAAoB;IACpB,IAAI5B,SAASY,MAAM,CAACgB,MAAM,EAAE;QAC1B,OAAOA;IACT;IAEA,+BAA+B;IAC/B,MAAMC,aAAaD,MAAME,WAAW;IACpC,KAAK,MAAM/B,QAAQM,OAAO0B,IAAI,CAAC/B,SAASC,UAAU,EAAG;QACnD,IAAIF,KAAK+B,WAAW,OAAOD,YAAY;YACrC,OAAO9B;QACT;IACF;IAEA,OAAO;AACT"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "galaxy-design",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CLI tool for adding Galaxy UI components to your Vue, React, Angular, React Native, or Flutter project",
|
|
5
|
+
"author": "Bùi Trọng Hiếu (kevinbui) <kevinbui210191@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/buikevin/galaxy-design.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://galaxy-design.vercel.app",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/buikevin/galaxy-design/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"galaxy-design",
|
|
17
|
+
"galaxy-ui",
|
|
18
|
+
"ui-components",
|
|
19
|
+
"vue",
|
|
20
|
+
"react",
|
|
21
|
+
"angular",
|
|
22
|
+
"react-native",
|
|
23
|
+
"flutter",
|
|
24
|
+
"mobile",
|
|
25
|
+
"tailwind",
|
|
26
|
+
"nativewind",
|
|
27
|
+
"radix-ui",
|
|
28
|
+
"cli",
|
|
29
|
+
"component-library",
|
|
30
|
+
"cross-platform",
|
|
31
|
+
"design-system",
|
|
32
|
+
"shadcn"
|
|
33
|
+
],
|
|
34
|
+
"private": false,
|
|
35
|
+
"packageManager": "bun@1.2.19",
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"module": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"bin": {
|
|
41
|
+
"galaxy-design": "./dist/bin.js",
|
|
42
|
+
"galaxy-ui-cli": "./dist/bin.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"exports": {
|
|
50
|
+
"./package.json": "./package.json",
|
|
51
|
+
".": {
|
|
52
|
+
"@galaxy-ui-cli/source": "./src/index.ts",
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"import": "./dist/index.js",
|
|
55
|
+
"default": "./dist/index.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "swc src -d dist --config-file .swcrc --strip-leading-paths && cp src/registry.json dist/ && cp -r src/registries dist/ && cp -r src/schemas dist/ && cp -r src/templates dist/",
|
|
60
|
+
"prepublishOnly": "npm run build"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@swc/helpers": "~0.5.11",
|
|
64
|
+
"chalk": "^5.6.2",
|
|
65
|
+
"commander": "^14.0.2",
|
|
66
|
+
"cosmiconfig": "^9.0.0",
|
|
67
|
+
"execa": "^9.6.0",
|
|
68
|
+
"ora": "^9.0.0",
|
|
69
|
+
"prompts": "^2.4.2",
|
|
70
|
+
"zod": "^4.1.12"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@swc/cli": "^0.4.1-nightly.20240914",
|
|
74
|
+
"@swc/core": "^1.9.3",
|
|
75
|
+
"typescript": "^5.7.3"
|
|
76
|
+
}
|
|
77
|
+
}
|