@oaysus/cli 0.1.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 +166 -0
- package/bin/oaysus.js +6 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +174 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +75 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +23 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +44 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/components/App.d.ts +43 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/App.js +63 -0
- package/dist/components/App.js.map +1 -0
- package/dist/components/BuildProgress.d.ts +16 -0
- package/dist/components/BuildProgress.d.ts.map +1 -0
- package/dist/components/BuildProgress.js +42 -0
- package/dist/components/BuildProgress.js.map +1 -0
- package/dist/components/ErrorMessage.d.ts +13 -0
- package/dist/components/ErrorMessage.d.ts.map +1 -0
- package/dist/components/ErrorMessage.js +29 -0
- package/dist/components/ErrorMessage.js.map +1 -0
- package/dist/components/FileList.d.ts +13 -0
- package/dist/components/FileList.d.ts.map +1 -0
- package/dist/components/FileList.js +25 -0
- package/dist/components/FileList.js.map +1 -0
- package/dist/components/Header.d.ts +12 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +18 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/LastCommand.d.ts +9 -0
- package/dist/components/LastCommand.d.ts.map +1 -0
- package/dist/components/LastCommand.js +39 -0
- package/dist/components/LastCommand.js.map +1 -0
- package/dist/components/Logo.d.ts +14 -0
- package/dist/components/Logo.d.ts.map +1 -0
- package/dist/components/Logo.js +44 -0
- package/dist/components/Logo.js.map +1 -0
- package/dist/components/ProgressBar.d.ts +13 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +20 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/SlashCommands.d.ts +17 -0
- package/dist/components/SlashCommands.d.ts.map +1 -0
- package/dist/components/SlashCommands.js +59 -0
- package/dist/components/SlashCommands.js.map +1 -0
- package/dist/components/Spinner.d.ts +13 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +16 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/StatusCard.d.ts +14 -0
- package/dist/components/StatusCard.d.ts.map +1 -0
- package/dist/components/StatusCard.js +40 -0
- package/dist/components/StatusCard.js.map +1 -0
- package/dist/components/SuccessMessage.d.ts +12 -0
- package/dist/components/SuccessMessage.d.ts.map +1 -0
- package/dist/components/SuccessMessage.js +18 -0
- package/dist/components/SuccessMessage.js.map +1 -0
- package/dist/components/UploadProgress.d.ts +13 -0
- package/dist/components/UploadProgress.d.ts.map +1 -0
- package/dist/components/UploadProgress.js +40 -0
- package/dist/components/UploadProgress.js.map +1 -0
- package/dist/components/ValidationProgress.d.ts +12 -0
- package/dist/components/ValidationProgress.d.ts.map +1 -0
- package/dist/components/ValidationProgress.js +44 -0
- package/dist/components/ValidationProgress.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/core/framework-registry.d.ts +27 -0
- package/dist/lib/core/framework-registry.d.ts.map +1 -0
- package/dist/lib/core/framework-registry.js +67 -0
- package/dist/lib/core/framework-registry.js.map +1 -0
- package/dist/lib/core/types.d.ts +124 -0
- package/dist/lib/core/types.d.ts.map +1 -0
- package/dist/lib/core/types.js +6 -0
- package/dist/lib/core/types.js.map +1 -0
- package/dist/lib/project-generator.d.ts +15 -0
- package/dist/lib/project-generator.d.ts.map +1 -0
- package/dist/lib/project-generator.js +286 -0
- package/dist/lib/project-generator.js.map +1 -0
- package/dist/lib/push.d.ts +20 -0
- package/dist/lib/push.d.ts.map +1 -0
- package/dist/lib/push.js +222 -0
- package/dist/lib/push.js.map +1 -0
- package/dist/lib/react/builder.d.ts +45 -0
- package/dist/lib/react/builder.d.ts.map +1 -0
- package/dist/lib/react/builder.js +381 -0
- package/dist/lib/react/builder.js.map +1 -0
- package/dist/lib/react/bundler.d.ts +104 -0
- package/dist/lib/react/bundler.d.ts.map +1 -0
- package/dist/lib/react/bundler.js +654 -0
- package/dist/lib/react/bundler.js.map +1 -0
- package/dist/lib/react/config.d.ts +34 -0
- package/dist/lib/react/config.d.ts.map +1 -0
- package/dist/lib/react/config.js +64 -0
- package/dist/lib/react/config.js.map +1 -0
- package/dist/lib/react/import-map.d.ts +54 -0
- package/dist/lib/react/import-map.d.ts.map +1 -0
- package/dist/lib/react/import-map.js +187 -0
- package/dist/lib/react/import-map.js.map +1 -0
- package/dist/lib/shared/auth-middleware.d.ts +29 -0
- package/dist/lib/shared/auth-middleware.d.ts.map +1 -0
- package/dist/lib/shared/auth-middleware.js +48 -0
- package/dist/lib/shared/auth-middleware.js.map +1 -0
- package/dist/lib/shared/auth.d.ts +50 -0
- package/dist/lib/shared/auth.d.ts.map +1 -0
- package/dist/lib/shared/auth.js +243 -0
- package/dist/lib/shared/auth.js.map +1 -0
- package/dist/lib/shared/cdn-downloader.d.ts +30 -0
- package/dist/lib/shared/cdn-downloader.d.ts.map +1 -0
- package/dist/lib/shared/cdn-downloader.js +126 -0
- package/dist/lib/shared/cdn-downloader.js.map +1 -0
- package/dist/lib/shared/command-history.d.ts +29 -0
- package/dist/lib/shared/command-history.d.ts.map +1 -0
- package/dist/lib/shared/command-history.js +73 -0
- package/dist/lib/shared/command-history.js.map +1 -0
- package/dist/lib/shared/commands.d.ts +24 -0
- package/dist/lib/shared/commands.d.ts.map +1 -0
- package/dist/lib/shared/commands.js +63 -0
- package/dist/lib/shared/commands.js.map +1 -0
- package/dist/lib/shared/config.d.ts +40 -0
- package/dist/lib/shared/config.d.ts.map +1 -0
- package/dist/lib/shared/config.js +69 -0
- package/dist/lib/shared/config.js.map +1 -0
- package/dist/lib/shared/file-utils.d.ts +45 -0
- package/dist/lib/shared/file-utils.d.ts.map +1 -0
- package/dist/lib/shared/file-utils.js +88 -0
- package/dist/lib/shared/file-utils.js.map +1 -0
- package/dist/lib/shared/import-analyzer.d.ts +49 -0
- package/dist/lib/shared/import-analyzer.d.ts.map +1 -0
- package/dist/lib/shared/import-analyzer.js +268 -0
- package/dist/lib/shared/import-analyzer.js.map +1 -0
- package/dist/lib/shared/path-builder.d.ts +55 -0
- package/dist/lib/shared/path-builder.d.ts.map +1 -0
- package/dist/lib/shared/path-builder.js +66 -0
- package/dist/lib/shared/path-builder.js.map +1 -0
- package/dist/lib/shared/uploader.d.ts +79 -0
- package/dist/lib/shared/uploader.d.ts.map +1 -0
- package/dist/lib/shared/uploader.js +340 -0
- package/dist/lib/shared/uploader.js.map +1 -0
- package/dist/lib/shared/zip-creator.d.ts +18 -0
- package/dist/lib/shared/zip-creator.d.ts.map +1 -0
- package/dist/lib/shared/zip-creator.js +131 -0
- package/dist/lib/shared/zip-creator.js.map +1 -0
- package/dist/lib/svelte/builder.d.ts +37 -0
- package/dist/lib/svelte/builder.d.ts.map +1 -0
- package/dist/lib/svelte/builder.js +364 -0
- package/dist/lib/svelte/builder.js.map +1 -0
- package/dist/lib/svelte/bundler.d.ts +92 -0
- package/dist/lib/svelte/bundler.d.ts.map +1 -0
- package/dist/lib/svelte/bundler.js +499 -0
- package/dist/lib/svelte/bundler.js.map +1 -0
- package/dist/lib/svelte/config.d.ts +22 -0
- package/dist/lib/svelte/config.d.ts.map +1 -0
- package/dist/lib/svelte/config.js +65 -0
- package/dist/lib/svelte/config.js.map +1 -0
- package/dist/lib/svelte/import-map.d.ts +42 -0
- package/dist/lib/svelte/import-map.d.ts.map +1 -0
- package/dist/lib/svelte/import-map.js +197 -0
- package/dist/lib/svelte/import-map.js.map +1 -0
- package/dist/lib/template-manager.d.ts +33 -0
- package/dist/lib/template-manager.d.ts.map +1 -0
- package/dist/lib/template-manager.js +69 -0
- package/dist/lib/template-manager.js.map +1 -0
- package/dist/lib/validator.d.ts +10 -0
- package/dist/lib/validator.d.ts.map +1 -0
- package/dist/lib/validator.js +343 -0
- package/dist/lib/validator.js.map +1 -0
- package/dist/lib/vue/builder.d.ts +37 -0
- package/dist/lib/vue/builder.d.ts.map +1 -0
- package/dist/lib/vue/builder.js +366 -0
- package/dist/lib/vue/builder.js.map +1 -0
- package/dist/lib/vue/bundler.d.ts +78 -0
- package/dist/lib/vue/bundler.d.ts.map +1 -0
- package/dist/lib/vue/bundler.js +208 -0
- package/dist/lib/vue/bundler.js.map +1 -0
- package/dist/lib/vue/config.d.ts +18 -0
- package/dist/lib/vue/config.d.ts.map +1 -0
- package/dist/lib/vue/config.js +42 -0
- package/dist/lib/vue/config.js.map +1 -0
- package/dist/lib/vue/import-map.d.ts +42 -0
- package/dist/lib/vue/import-map.d.ts.map +1 -0
- package/dist/lib/vue/import-map.js +156 -0
- package/dist/lib/vue/import-map.js.map +1 -0
- package/dist/screens/BuildScreen.d.ts +8 -0
- package/dist/screens/BuildScreen.d.ts.map +1 -0
- package/dist/screens/BuildScreen.js +158 -0
- package/dist/screens/BuildScreen.js.map +1 -0
- package/dist/screens/CreateScreen.d.ts +12 -0
- package/dist/screens/CreateScreen.d.ts.map +1 -0
- package/dist/screens/CreateScreen.js +305 -0
- package/dist/screens/CreateScreen.js.map +1 -0
- package/dist/screens/InitScreen.d.ts +11 -0
- package/dist/screens/InitScreen.d.ts.map +1 -0
- package/dist/screens/InitScreen.js +339 -0
- package/dist/screens/InitScreen.js.map +1 -0
- package/dist/screens/LoginScreen.d.ts +15 -0
- package/dist/screens/LoginScreen.d.ts.map +1 -0
- package/dist/screens/LoginScreen.js +427 -0
- package/dist/screens/LoginScreen.js.map +1 -0
- package/dist/screens/LogoutScreen.d.ts +15 -0
- package/dist/screens/LogoutScreen.d.ts.map +1 -0
- package/dist/screens/LogoutScreen.js +187 -0
- package/dist/screens/LogoutScreen.js.map +1 -0
- package/dist/screens/PushScreen.d.ts +12 -0
- package/dist/screens/PushScreen.d.ts.map +1 -0
- package/dist/screens/PushScreen.js +546 -0
- package/dist/screens/PushScreen.js.map +1 -0
- package/dist/screens/ValidateScreen.d.ts +12 -0
- package/dist/screens/ValidateScreen.d.ts.map +1 -0
- package/dist/screens/ValidateScreen.js +193 -0
- package/dist/screens/ValidateScreen.js.map +1 -0
- package/dist/screens/WelcomeScreen.d.ts +39 -0
- package/dist/screens/WelcomeScreen.d.ts.map +1 -0
- package/dist/screens/WelcomeScreen.js +297 -0
- package/dist/screens/WelcomeScreen.js.map +1 -0
- package/dist/screens/WhoamiScreen.d.ts +14 -0
- package/dist/screens/WhoamiScreen.d.ts.map +1 -0
- package/dist/screens/WhoamiScreen.js +180 -0
- package/dist/screens/WhoamiScreen.js.map +1 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/templates.d.ts +55 -0
- package/dist/types/templates.d.ts.map +1 -0
- package/dist/types/templates.js +6 -0
- package/dist/types/templates.js.map +1 -0
- package/dist/types/validation.d.ts +108 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/validation.js +6 -0
- package/dist/types/validation.js.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte Import Map Generator
|
|
3
|
+
* Svelte-specific implementation for generating import maps
|
|
4
|
+
*/
|
|
5
|
+
import { SVELTE_EXTERNALS } from './config.js';
|
|
6
|
+
// Svelte-specific import mappings for bundled sub-exports
|
|
7
|
+
// Maps import specifiers to bundled filenames (8 optimized bundles)
|
|
8
|
+
const SVELTE_IMPORT_MAPPINGS = {
|
|
9
|
+
'svelte': ['internal/client', 'internal/disclose-version', 'store', 'motion', 'transition', 'animate', 'easing']
|
|
10
|
+
};
|
|
11
|
+
// Map from import specifier to bundled filename
|
|
12
|
+
const SVELTE_BUNDLE_FILENAMES = {
|
|
13
|
+
'internal/client': 'internal-client.js',
|
|
14
|
+
'internal/disclose-version': 'internal-disclose-version.js',
|
|
15
|
+
'store': 'store.js',
|
|
16
|
+
'motion': 'motion.js',
|
|
17
|
+
'transition': 'transition.js',
|
|
18
|
+
'animate': 'animate.js',
|
|
19
|
+
'easing': 'easing.js'
|
|
20
|
+
};
|
|
21
|
+
// Dev-only packages that shouldn't be in import map
|
|
22
|
+
const DEV_ONLY_PATTERNS = [
|
|
23
|
+
/^@types\//,
|
|
24
|
+
/^typescript$/,
|
|
25
|
+
/^eslint/,
|
|
26
|
+
/^prettier/,
|
|
27
|
+
/^vite$/,
|
|
28
|
+
/^vitest/,
|
|
29
|
+
/^jest/,
|
|
30
|
+
/^@testing-library/,
|
|
31
|
+
/^autoprefixer$/,
|
|
32
|
+
/^postcss$/,
|
|
33
|
+
/^tailwindcss$/,
|
|
34
|
+
/^@tailwindcss\//,
|
|
35
|
+
/^@vitejs\//,
|
|
36
|
+
/^@sveltejs\/vite-plugin/,
|
|
37
|
+
/^svelte-check$/,
|
|
38
|
+
/^vue-tsc$/
|
|
39
|
+
];
|
|
40
|
+
class SvelteImportMapGenerator {
|
|
41
|
+
/**
|
|
42
|
+
* Check if a package is dev-only
|
|
43
|
+
*/
|
|
44
|
+
isDevOnlyPackage(packageName) {
|
|
45
|
+
return DEV_ONLY_PATTERNS.some(pattern => pattern.test(packageName));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generate import map from package.json dependencies
|
|
49
|
+
* Uses esm.sh CDN for now
|
|
50
|
+
*/
|
|
51
|
+
generateImportMapFromPackageJson(packageJson) {
|
|
52
|
+
const imports = {};
|
|
53
|
+
// Get all dependencies
|
|
54
|
+
const deps = {
|
|
55
|
+
...packageJson.dependencies,
|
|
56
|
+
...packageJson.devDependencies
|
|
57
|
+
};
|
|
58
|
+
// Generate import map entries for each dependency
|
|
59
|
+
for (const [packageName, versionRange] of Object.entries(deps || {})) {
|
|
60
|
+
// Skip dev-only packages
|
|
61
|
+
if (this.isDevOnlyPackage(packageName)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Only include Svelte framework dependencies
|
|
65
|
+
if (!SVELTE_EXTERNALS.includes(packageName)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Clean version
|
|
69
|
+
const version = versionRange.replace(/^[\^~>=<]/, '');
|
|
70
|
+
// Use esm.sh CDN
|
|
71
|
+
const baseUrl = `https://esm.sh/${packageName}@${version}`;
|
|
72
|
+
// Add main export
|
|
73
|
+
imports[packageName] = baseUrl;
|
|
74
|
+
// Add Svelte-specific sub-exports
|
|
75
|
+
const subExports = SVELTE_IMPORT_MAPPINGS[packageName];
|
|
76
|
+
if (subExports) {
|
|
77
|
+
for (const exportName of subExports) {
|
|
78
|
+
// For CDN, keep the slash path (esm.sh handles it)
|
|
79
|
+
imports[`${packageName}/${exportName}`] = `${baseUrl}/${exportName}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// For Svelte with CDN, also map nested internal paths (esm.sh will handle them)
|
|
83
|
+
if (packageName === 'svelte') {
|
|
84
|
+
imports['svelte/internal/client'] = `${baseUrl}/internal/client`;
|
|
85
|
+
imports['svelte/internal/server'] = `${baseUrl}/internal/server`;
|
|
86
|
+
imports['svelte/internal/disclose-version'] = `${baseUrl}/internal/disclose-version`;
|
|
87
|
+
imports['svelte/internal/flags/legacy'] = `${baseUrl}/internal/flags/legacy`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { imports };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate import map using R2 URLs
|
|
94
|
+
*/
|
|
95
|
+
generateImportMapWithR2Urls(packageJson, options) {
|
|
96
|
+
const imports = {};
|
|
97
|
+
const { r2PublicUrl, r2BasePath } = options;
|
|
98
|
+
// Get all dependencies
|
|
99
|
+
const deps = {
|
|
100
|
+
...packageJson.dependencies,
|
|
101
|
+
...packageJson.devDependencies
|
|
102
|
+
};
|
|
103
|
+
// Generate import map entries
|
|
104
|
+
for (const [packageName, versionRange] of Object.entries(deps || {})) {
|
|
105
|
+
// Skip dev-only packages
|
|
106
|
+
if (this.isDevOnlyPackage(packageName)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// Only include Svelte framework dependencies
|
|
110
|
+
if (!SVELTE_EXTERNALS.includes(packageName)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
// Clean version
|
|
114
|
+
const version = versionRange.replace(/^[\^~>=<]/, '');
|
|
115
|
+
// Build R2 URL
|
|
116
|
+
const baseUrl = r2BasePath
|
|
117
|
+
? `${r2PublicUrl}/${r2BasePath}/deps/${packageName}@${version}`
|
|
118
|
+
: `${r2PublicUrl}/deps/${packageName}@${version}`;
|
|
119
|
+
// Use local bundled Svelte (bundler creates optimized production bundles)
|
|
120
|
+
if (packageName === 'svelte') {
|
|
121
|
+
imports[packageName] = `${baseUrl}/index.js`;
|
|
122
|
+
imports['svelte/internal/client'] = `${baseUrl}/internal-client.js`;
|
|
123
|
+
imports['svelte/internal/disclose-version'] = `${baseUrl}/internal-disclose-version.js`;
|
|
124
|
+
imports['svelte/store'] = `${baseUrl}/store.js`;
|
|
125
|
+
imports['svelte/motion'] = `${baseUrl}/motion.js`;
|
|
126
|
+
imports['svelte/transition'] = `${baseUrl}/transition.js`;
|
|
127
|
+
imports['svelte/animate'] = `${baseUrl}/animate.js`;
|
|
128
|
+
imports['svelte/easing'] = `${baseUrl}/easing.js`;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// Add main export for non-Svelte packages
|
|
132
|
+
imports[packageName] = `${baseUrl}/index.js`;
|
|
133
|
+
// Add sub-exports (for non-Svelte packages)
|
|
134
|
+
const subExports = SVELTE_IMPORT_MAPPINGS[packageName];
|
|
135
|
+
if (subExports) {
|
|
136
|
+
for (const exportName of subExports) {
|
|
137
|
+
// Replace slashes with dashes to match bundled filename
|
|
138
|
+
const exportPath = exportName.replace(/\//g, '-');
|
|
139
|
+
imports[`${packageName}/${exportName}`] = `${baseUrl}/${exportPath}.js`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { imports };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Generate import map with stylesheets from package.json using R2 URLs
|
|
147
|
+
*/
|
|
148
|
+
generateImportMapWithStylesheets(packageJson, options) {
|
|
149
|
+
const { imports } = this.generateImportMapWithR2Urls(packageJson, options);
|
|
150
|
+
const stylesheets = {};
|
|
151
|
+
const { r2PublicUrl, r2BasePath } = options;
|
|
152
|
+
// Get all dependencies
|
|
153
|
+
const deps = {
|
|
154
|
+
...packageJson.dependencies,
|
|
155
|
+
...packageJson.devDependencies
|
|
156
|
+
};
|
|
157
|
+
// Check if Tailwind is used
|
|
158
|
+
if (deps.tailwindcss) {
|
|
159
|
+
stylesheets['tailwindcss'] = r2BasePath
|
|
160
|
+
? `${r2PublicUrl}/${r2BasePath}/theme.css`
|
|
161
|
+
: `${r2PublicUrl}/theme.css`;
|
|
162
|
+
}
|
|
163
|
+
return { imports, stylesheets };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get list of dependencies that need to be bundled
|
|
167
|
+
*/
|
|
168
|
+
getDependenciesToBundle(packageJson) {
|
|
169
|
+
const deps = [];
|
|
170
|
+
const allDeps = {
|
|
171
|
+
...packageJson.dependencies,
|
|
172
|
+
...packageJson.devDependencies
|
|
173
|
+
};
|
|
174
|
+
for (const [packageName, versionRange] of Object.entries(allDeps || {})) {
|
|
175
|
+
// Skip dev-only packages
|
|
176
|
+
if (this.isDevOnlyPackage(packageName))
|
|
177
|
+
continue;
|
|
178
|
+
// Only include Svelte framework dependencies
|
|
179
|
+
if (!SVELTE_EXTERNALS.includes(packageName))
|
|
180
|
+
continue;
|
|
181
|
+
// Clean version
|
|
182
|
+
const version = versionRange.replace(/^[\^~>=<]/, '');
|
|
183
|
+
deps.push({ name: packageName, version });
|
|
184
|
+
}
|
|
185
|
+
return deps;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Export singleton instance
|
|
189
|
+
const importMapGenerator = new SvelteImportMapGenerator();
|
|
190
|
+
export default importMapGenerator;
|
|
191
|
+
export { importMapGenerator };
|
|
192
|
+
// Export helper functions for backward compatibility
|
|
193
|
+
export const generateImportMapFromPackageJson = (packageJson) => importMapGenerator.generateImportMapFromPackageJson(packageJson);
|
|
194
|
+
export const generateImportMapWithR2Urls = (packageJson, options) => importMapGenerator.generateImportMapWithR2Urls(packageJson, options);
|
|
195
|
+
export const generateImportMapWithStylesheets = (packageJson, options) => importMapGenerator.generateImportMapWithStylesheets(packageJson, options);
|
|
196
|
+
export const getDependenciesToBundle = (packageJson) => importMapGenerator.getDependenciesToBundle(packageJson);
|
|
197
|
+
//# sourceMappingURL=import-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-map.js","sourceRoot":"","sources":["../../../src/lib/svelte/import-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,0DAA0D;AAC1D,oEAAoE;AACpE,MAAM,sBAAsB,GAA6B;IACvD,QAAQ,EAAE,CAAC,iBAAiB,EAAE,2BAA2B,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;CACjH,CAAC;AAEF,gDAAgD;AAChD,MAAM,uBAAuB,GAA2B;IACtD,iBAAiB,EAAE,oBAAoB;IACvC,2BAA2B,EAAE,8BAA8B;IAC3D,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,WAAW;IACrB,YAAY,EAAE,eAAe;IAC7B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AAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAAE,SAAS;YAEtD,gBAAgB;YAChB,MAAM,OAAO,GAAI,YAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAClE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,kBAAkB,GAAG,IAAI,wBAAwB,EAAE,CAAC;AAC1D,eAAe,kBAAkB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,qDAAqD;AACrD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,WAAgB,EAAE,EAAE,CACnE,kBAAkB,CAAC,gCAAgC,CAAC,WAAW,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,WAAgB,EAAE,OAA2B,EAAE,EAAE,CAC3F,kBAAkB,CAAC,2BAA2B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,WAAgB,EAAE,OAA2B,EAAE,EAAE,CAChG,kBAAkB,CAAC,gCAAgC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAAgB,EAAE,EAAE,CAC1D,kBAAkB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Manager
|
|
3
|
+
* Handles template file operations and variable replacement
|
|
4
|
+
*/
|
|
5
|
+
import { Framework, TemplateVariables } from '../types/templates.js';
|
|
6
|
+
/**
|
|
7
|
+
* Get the templates directory path
|
|
8
|
+
* Templates are in src/templates, but when running from dist/,
|
|
9
|
+
* we need to go up to project root and back into src/templates
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTemplatesDir(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get the template directory for a specific framework
|
|
14
|
+
* All projects use theme pack structure
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTemplateDir(framework: Framework): string;
|
|
17
|
+
/**
|
|
18
|
+
* Replace template variables in content
|
|
19
|
+
*/
|
|
20
|
+
export declare function replaceVariables(content: string, variables: TemplateVariables): string;
|
|
21
|
+
/**
|
|
22
|
+
* Process a template file and write to destination
|
|
23
|
+
*/
|
|
24
|
+
export declare function processTemplate(templatePath: string, targetPath: string, variables: TemplateVariables): void;
|
|
25
|
+
/**
|
|
26
|
+
* Get file extension for framework
|
|
27
|
+
*/
|
|
28
|
+
export declare function getComponentExtension(framework: Framework): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get example component type based on framework
|
|
31
|
+
*/
|
|
32
|
+
export declare function getExampleComponentType(framework: Framework): string;
|
|
33
|
+
//# sourceMappingURL=template-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-manager.d.ts","sourceRoot":"","sources":["../../src/lib/template-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAGxC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAG3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAWtF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,iBAAiB,GAC3B,IAAI,CAIN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAWlE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Manager
|
|
3
|
+
* Handles template file operations and variable replacement
|
|
4
|
+
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { readFile, writeFile } from './shared/file-utils.js';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
/**
|
|
11
|
+
* Get the templates directory path
|
|
12
|
+
* Templates are in src/templates, but when running from dist/,
|
|
13
|
+
* we need to go up to project root and back into src/templates
|
|
14
|
+
*/
|
|
15
|
+
export function getTemplatesDir() {
|
|
16
|
+
// From dist/lib/ -> go up to project root -> into src/templates
|
|
17
|
+
return path.join(__dirname, '..', '..', 'src', 'templates');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the template directory for a specific framework
|
|
21
|
+
* All projects use theme pack structure
|
|
22
|
+
*/
|
|
23
|
+
export function getTemplateDir(framework) {
|
|
24
|
+
const templateName = `${framework}-theme-pack`;
|
|
25
|
+
return path.join(getTemplatesDir(), templateName);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Replace template variables in content
|
|
29
|
+
*/
|
|
30
|
+
export function replaceVariables(content, variables) {
|
|
31
|
+
let result = content;
|
|
32
|
+
Object.entries(variables).forEach(([key, value]) => {
|
|
33
|
+
if (value !== undefined) {
|
|
34
|
+
const regex = new RegExp(`{{${key}}}`, 'g');
|
|
35
|
+
result = result.replace(regex, value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Process a template file and write to destination
|
|
42
|
+
*/
|
|
43
|
+
export function processTemplate(templatePath, targetPath, variables) {
|
|
44
|
+
const content = readFile(templatePath);
|
|
45
|
+
const processedContent = replaceVariables(content, variables);
|
|
46
|
+
writeFile(targetPath, processedContent);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get file extension for framework
|
|
50
|
+
*/
|
|
51
|
+
export function getComponentExtension(framework) {
|
|
52
|
+
switch (framework) {
|
|
53
|
+
case 'react':
|
|
54
|
+
return '.tsx';
|
|
55
|
+
case 'vue':
|
|
56
|
+
return '.vue';
|
|
57
|
+
case 'svelte':
|
|
58
|
+
return '.svelte';
|
|
59
|
+
default:
|
|
60
|
+
return '.tsx';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get example component type based on framework
|
|
65
|
+
*/
|
|
66
|
+
export function getExampleComponentType(framework) {
|
|
67
|
+
return `${framework}-hero`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=template-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-manager.js","sourceRoot":"","sources":["../../src/lib/template-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,gEAAgE;IAChE,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,SAAoB;IACjD,MAAM,YAAY,GAAG,GAAG,SAAS,aAAa,CAAC;I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**
|
|
2
|
+
* Package Validator
|
|
3
|
+
* Validates component packages before upload
|
|
4
|
+
*/
|
|
5
|
+
import type { ValidationResult } from '../types/validation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Validate a component package
|
|
8
|
+
*/
|
|
9
|
+
export declare function validatePackage(projectPath: string): Promise<ValidationResult>;
|
|
10
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAIjB,MAAM,wBAAwB,CAAC;AAoFhC;;GAEG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgRpF"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package Validator
|
|
3
|
+
* Validates component packages before upload
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
// Zod Schemas for validation
|
|
10
|
+
const PackageJsonSchema = z.object({
|
|
11
|
+
name: z.string().regex(/^[a-z0-9-]+$/, 'Package name must be lowercase letters, numbers, and hyphens only'),
|
|
12
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/, 'Version must follow semver format (e.g., 1.0.0)'),
|
|
13
|
+
description: z.string().optional(),
|
|
14
|
+
author: z.string().optional(),
|
|
15
|
+
license: z.string().optional(),
|
|
16
|
+
dependencies: z.record(z.string(), z.unknown()).optional(),
|
|
17
|
+
devDependencies: z.record(z.string(), z.unknown()).optional(),
|
|
18
|
+
oaysus: z.object({
|
|
19
|
+
theme: z.object({
|
|
20
|
+
name: z.string(),
|
|
21
|
+
displayName: z.string(),
|
|
22
|
+
category: z.string().optional(),
|
|
23
|
+
isPremium: z.boolean().optional(),
|
|
24
|
+
tags: z.array(z.string()).optional(),
|
|
25
|
+
}).optional(),
|
|
26
|
+
}).optional(),
|
|
27
|
+
});
|
|
28
|
+
const ComponentSchemaSchema = z.object({
|
|
29
|
+
type: z.string(),
|
|
30
|
+
displayName: z.string(),
|
|
31
|
+
description: z.string().optional(),
|
|
32
|
+
category: z.string().optional(),
|
|
33
|
+
props: z.record(z.string(), z.object({
|
|
34
|
+
type: z.string(),
|
|
35
|
+
default: z.any().optional(),
|
|
36
|
+
required: z.boolean().optional(),
|
|
37
|
+
description: z.string().optional(),
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Check if a file exists
|
|
42
|
+
*/
|
|
43
|
+
async function fileExists(filePath) {
|
|
44
|
+
try {
|
|
45
|
+
await fs.access(filePath);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Detect framework from package.json dependencies
|
|
54
|
+
*/
|
|
55
|
+
function detectFramework(packageJson) {
|
|
56
|
+
const allDeps = {
|
|
57
|
+
...packageJson.dependencies,
|
|
58
|
+
...packageJson.devDependencies,
|
|
59
|
+
};
|
|
60
|
+
if (allDeps?.react)
|
|
61
|
+
return 'react';
|
|
62
|
+
if (allDeps?.vue)
|
|
63
|
+
return 'vue';
|
|
64
|
+
if (allDeps?.svelte)
|
|
65
|
+
return 'svelte';
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Detect project type from directory structure
|
|
70
|
+
*/
|
|
71
|
+
async function detectType(projectPath, framework) {
|
|
72
|
+
const extension = framework === 'react' ? '.tsx' : framework === 'vue' ? '.vue' : '.svelte';
|
|
73
|
+
// Check for root index file (single component)
|
|
74
|
+
const hasRootIndex = await fileExists(path.join(projectPath, `index${extension}`));
|
|
75
|
+
// Check for components directory (theme pack)
|
|
76
|
+
const hasComponentsDir = await fileExists(path.join(projectPath, 'components'));
|
|
77
|
+
if (hasRootIndex && !hasComponentsDir) {
|
|
78
|
+
return 'component';
|
|
79
|
+
}
|
|
80
|
+
else if (hasComponentsDir) {
|
|
81
|
+
return 'theme-pack';
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validate a component package
|
|
87
|
+
*/
|
|
88
|
+
export async function validatePackage(projectPath) {
|
|
89
|
+
const errors = [];
|
|
90
|
+
const warnings = [];
|
|
91
|
+
const components = [];
|
|
92
|
+
try {
|
|
93
|
+
// 1. Check package.json exists
|
|
94
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
95
|
+
if (!await fileExists(packageJsonPath)) {
|
|
96
|
+
errors.push('Missing package.json');
|
|
97
|
+
return {
|
|
98
|
+
valid: false,
|
|
99
|
+
errors,
|
|
100
|
+
warnings,
|
|
101
|
+
components,
|
|
102
|
+
packageJson: {},
|
|
103
|
+
inferredConfig: {}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// 2. Validate package.json
|
|
107
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
108
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
109
|
+
const packageValidation = PackageJsonSchema.safeParse(packageJson);
|
|
110
|
+
if (!packageValidation.success) {
|
|
111
|
+
const zodError = packageValidation.error;
|
|
112
|
+
zodError.issues.forEach((issue) => {
|
|
113
|
+
const pathStr = issue.path.map(String).join('.');
|
|
114
|
+
errors.push(`Invalid package.json: ${pathStr}: ${issue.message}`);
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
valid: false,
|
|
118
|
+
errors,
|
|
119
|
+
warnings,
|
|
120
|
+
components,
|
|
121
|
+
packageJson,
|
|
122
|
+
inferredConfig: {}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// 3. Detect framework from dependencies
|
|
126
|
+
const framework = detectFramework(packageJson);
|
|
127
|
+
if (!framework) {
|
|
128
|
+
errors.push('Cannot detect framework - add react, vue, or svelte to package.json dependencies');
|
|
129
|
+
return {
|
|
130
|
+
valid: false,
|
|
131
|
+
errors,
|
|
132
|
+
warnings,
|
|
133
|
+
components,
|
|
134
|
+
packageJson,
|
|
135
|
+
inferredConfig: {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// 4. Detect project type from structure
|
|
139
|
+
const type = await detectType(projectPath, framework);
|
|
140
|
+
if (!type) {
|
|
141
|
+
errors.push('Cannot determine project type - need index.tsx in root (single component) OR components/ directory (theme pack)');
|
|
142
|
+
return {
|
|
143
|
+
valid: false,
|
|
144
|
+
errors,
|
|
145
|
+
warnings,
|
|
146
|
+
components,
|
|
147
|
+
packageJson,
|
|
148
|
+
inferredConfig: {}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// 5. Validate theme metadata (REQUIRED for theme-pack)
|
|
152
|
+
if (type === 'theme-pack') {
|
|
153
|
+
if (!packageJson.oaysus?.theme) {
|
|
154
|
+
errors.push('');
|
|
155
|
+
errors.push('╔════════════════════════════════════════════════════════════════╗');
|
|
156
|
+
errors.push('║ Missing Required Theme Metadata ║');
|
|
157
|
+
errors.push('╚════════════════════════════════════════════════════════════════╝');
|
|
158
|
+
errors.push('');
|
|
159
|
+
errors.push('Theme packs require theme metadata in package.json');
|
|
160
|
+
errors.push('');
|
|
161
|
+
errors.push('Add this to your package.json:');
|
|
162
|
+
errors.push('');
|
|
163
|
+
errors.push(' "oaysus": {');
|
|
164
|
+
errors.push(' "theme": {');
|
|
165
|
+
errors.push(' "name": "your-theme-name",');
|
|
166
|
+
errors.push(' "displayName": "Your Theme Name",');
|
|
167
|
+
errors.push(' "description": "Description of your theme",');
|
|
168
|
+
errors.push(' "category": "marketing",');
|
|
169
|
+
errors.push(' "isPremium": false,');
|
|
170
|
+
errors.push(' "tags": ["marketing", "components"]');
|
|
171
|
+
errors.push(' }');
|
|
172
|
+
errors.push(' }');
|
|
173
|
+
errors.push('');
|
|
174
|
+
return {
|
|
175
|
+
valid: false,
|
|
176
|
+
errors,
|
|
177
|
+
warnings,
|
|
178
|
+
components,
|
|
179
|
+
packageJson,
|
|
180
|
+
inferredConfig: {
|
|
181
|
+
framework,
|
|
182
|
+
type,
|
|
183
|
+
componentCount: 0,
|
|
184
|
+
version: packageJson.version,
|
|
185
|
+
name: packageJson.name
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Validate theme has required fields
|
|
190
|
+
if (!packageJson.oaysus.theme.name || !packageJson.oaysus.theme.displayName) {
|
|
191
|
+
errors.push('Theme must have "name" and "displayName" fields');
|
|
192
|
+
return {
|
|
193
|
+
valid: false,
|
|
194
|
+
errors,
|
|
195
|
+
warnings,
|
|
196
|
+
components,
|
|
197
|
+
packageJson,
|
|
198
|
+
inferredConfig: {
|
|
199
|
+
framework,
|
|
200
|
+
type,
|
|
201
|
+
componentCount: 0,
|
|
202
|
+
version: packageJson.version,
|
|
203
|
+
name: packageJson.name
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// 6. Determine component entry point extension
|
|
209
|
+
const extension = framework === 'react' ? '.tsx' : framework === 'vue' ? '.vue' : '.svelte';
|
|
210
|
+
// 7. Discover components based on inferred type
|
|
211
|
+
let schemaFiles = [];
|
|
212
|
+
if (type === 'component') {
|
|
213
|
+
// Single component: look for schema.json in root
|
|
214
|
+
if (await fileExists(path.join(projectPath, 'schema.json'))) {
|
|
215
|
+
schemaFiles = ['schema.json'];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// Theme pack: search for schema.json files in components/
|
|
220
|
+
schemaFiles = await glob('components/**/schema.json', {
|
|
221
|
+
cwd: projectPath,
|
|
222
|
+
ignore: ['node_modules/**', 'dist/**', 'build/**'],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (schemaFiles.length === 0) {
|
|
226
|
+
errors.push('No components found (no schema.json files detected)');
|
|
227
|
+
return {
|
|
228
|
+
valid: false,
|
|
229
|
+
errors,
|
|
230
|
+
warnings,
|
|
231
|
+
components,
|
|
232
|
+
packageJson,
|
|
233
|
+
inferredConfig: {
|
|
234
|
+
framework,
|
|
235
|
+
type,
|
|
236
|
+
componentCount: 0,
|
|
237
|
+
version: packageJson.version,
|
|
238
|
+
name: packageJson.name
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
// 8. Validate each component
|
|
243
|
+
for (const schemaFile of schemaFiles) {
|
|
244
|
+
const schemaPath = path.join(projectPath, schemaFile);
|
|
245
|
+
const componentDir = path.dirname(schemaPath);
|
|
246
|
+
try {
|
|
247
|
+
// Validate schema file
|
|
248
|
+
const schemaContent = await fs.readFile(schemaPath, 'utf-8');
|
|
249
|
+
const schema = JSON.parse(schemaContent);
|
|
250
|
+
const schemaValidation = ComponentSchemaSchema.safeParse(schema);
|
|
251
|
+
if (!schemaValidation.success) {
|
|
252
|
+
const zodError = schemaValidation.error;
|
|
253
|
+
zodError.issues.forEach((issue) => {
|
|
254
|
+
const pathStr = issue.path.map(String).join('.');
|
|
255
|
+
errors.push(`Invalid schema in ${schemaFile}: ${pathStr}: ${issue.message}`);
|
|
256
|
+
});
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
// Check entry point exists
|
|
260
|
+
let entryPoint;
|
|
261
|
+
if (type === 'component') {
|
|
262
|
+
// Single component: index.tsx/vue/svelte in root
|
|
263
|
+
entryPoint = path.join(projectPath, `index${extension}`);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
// Theme pack: index.tsx/vue/svelte in component directory
|
|
267
|
+
entryPoint = path.join(componentDir, `index${extension}`);
|
|
268
|
+
}
|
|
269
|
+
if (!await fileExists(entryPoint)) {
|
|
270
|
+
errors.push(`Missing entry point: ${path.relative(projectPath, entryPoint)}`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
// Add to components list
|
|
274
|
+
components.push({
|
|
275
|
+
name: schema.type,
|
|
276
|
+
displayName: schema.displayName,
|
|
277
|
+
path: componentDir,
|
|
278
|
+
schema: schema,
|
|
279
|
+
entryPoint: entryPoint,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
catch (err) {
|
|
283
|
+
errors.push(`Failed to process ${schemaFile}: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (components.length === 0) {
|
|
287
|
+
errors.push('No valid components found');
|
|
288
|
+
return {
|
|
289
|
+
valid: false,
|
|
290
|
+
errors,
|
|
291
|
+
warnings,
|
|
292
|
+
components,
|
|
293
|
+
packageJson,
|
|
294
|
+
inferredConfig: {
|
|
295
|
+
framework,
|
|
296
|
+
type,
|
|
297
|
+
componentCount: 0,
|
|
298
|
+
version: packageJson.version,
|
|
299
|
+
name: packageJson.name
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// 8. Check for node_modules (should not be committed)
|
|
304
|
+
if (await fileExists(path.join(projectPath, 'node_modules'))) {
|
|
305
|
+
warnings.push('node_modules directory found (will be automatically excluded from ZIP)');
|
|
306
|
+
}
|
|
307
|
+
// 9. Check for common unnecessary files
|
|
308
|
+
const unnecessaryFiles = ['.git', '.DS_Store', 'dist', 'build', 'coverage'];
|
|
309
|
+
for (const file of unnecessaryFiles) {
|
|
310
|
+
if (await fileExists(path.join(projectPath, file))) {
|
|
311
|
+
warnings.push(`${file} found (will be automatically excluded from ZIP)`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Success - return with inferred configuration
|
|
315
|
+
return {
|
|
316
|
+
valid: errors.length === 0,
|
|
317
|
+
errors,
|
|
318
|
+
warnings,
|
|
319
|
+
components,
|
|
320
|
+
packageJson,
|
|
321
|
+
inferredConfig: {
|
|
322
|
+
framework,
|
|
323
|
+
type,
|
|
324
|
+
componentCount: components.length,
|
|
325
|
+
version: packageJson.version,
|
|
326
|
+
name: packageJson.name,
|
|
327
|
+
theme: packageJson.oaysus?.theme
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
errors.push(`Validation error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
333
|
+
return {
|
|
334
|
+
valid: false,
|
|
335
|
+
errors,
|
|
336
|
+
warnings,
|
|
337
|
+
components,
|
|
338
|
+
packageJson: {},
|
|
339
|
+
inferredConfig: {}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=validator.js.map
|