@oaysus/cli 0.1.13 → 0.1.15
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 +35 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +151 -85
- package/dist/cli.js.map +1 -1
- package/dist/components/App.d.ts +26 -10
- package/dist/components/App.d.ts.map +1 -1
- package/dist/components/App.js +23 -8
- package/dist/components/App.js.map +1 -1
- package/dist/components/SlashCommands.js +1 -1
- package/dist/lib/push.d.ts.map +1 -1
- package/dist/lib/push.js +29 -1
- package/dist/lib/push.js.map +1 -1
- package/dist/lib/shared/commands.d.ts +11 -1
- package/dist/lib/shared/commands.d.ts.map +1 -1
- package/dist/lib/shared/commands.js +55 -13
- package/dist/lib/shared/commands.js.map +1 -1
- package/dist/lib/shared/uploader.d.ts +1 -0
- package/dist/lib/shared/uploader.d.ts.map +1 -1
- package/dist/lib/shared/uploader.js +4 -2
- package/dist/lib/shared/uploader.js.map +1 -1
- package/dist/lib/site/asset-puller.d.ts +93 -0
- package/dist/lib/site/asset-puller.d.ts.map +1 -0
- package/dist/lib/site/asset-puller.js +376 -0
- package/dist/lib/site/asset-puller.js.map +1 -0
- package/dist/lib/site/asset-resolver.d.ts +44 -0
- package/dist/lib/site/asset-resolver.d.ts.map +1 -0
- package/dist/lib/site/asset-resolver.js +225 -0
- package/dist/lib/site/asset-resolver.js.map +1 -0
- package/dist/lib/site/asset-uploader.d.ts +58 -0
- package/dist/lib/site/asset-uploader.d.ts.map +1 -0
- package/dist/lib/site/asset-uploader.js +261 -0
- package/dist/lib/site/asset-uploader.js.map +1 -0
- package/dist/lib/site/index.d.ts +14 -0
- package/dist/lib/site/index.d.ts.map +1 -0
- package/dist/lib/site/index.js +15 -0
- package/dist/lib/site/index.js.map +1 -0
- package/dist/lib/site/metadata.d.ts +99 -0
- package/dist/lib/site/metadata.d.ts.map +1 -0
- package/dist/lib/site/metadata.js +470 -0
- package/dist/lib/site/metadata.js.map +1 -0
- package/dist/lib/site/page-publisher.d.ts +51 -0
- package/dist/lib/site/page-publisher.d.ts.map +1 -0
- package/dist/lib/site/page-publisher.js +460 -0
- package/dist/lib/site/page-publisher.js.map +1 -0
- package/dist/lib/site/page-puller.d.ts +93 -0
- package/dist/lib/site/page-puller.d.ts.map +1 -0
- package/dist/lib/site/page-puller.js +346 -0
- package/dist/lib/site/page-puller.js.map +1 -0
- package/dist/lib/site/page-validator.d.ts +29 -0
- package/dist/lib/site/page-validator.d.ts.map +1 -0
- package/dist/lib/site/page-validator.js +282 -0
- package/dist/lib/site/page-validator.js.map +1 -0
- package/dist/lib/site/project-loader.d.ts +45 -0
- package/dist/lib/site/project-loader.d.ts.map +1 -0
- package/dist/lib/site/project-loader.js +276 -0
- package/dist/lib/site/project-loader.js.map +1 -0
- package/dist/lib/site/shared-component-resolver.d.ts +89 -0
- package/dist/lib/site/shared-component-resolver.d.ts.map +1 -0
- package/dist/lib/site/shared-component-resolver.js +222 -0
- package/dist/lib/site/shared-component-resolver.js.map +1 -0
- package/dist/screens/WelcomeScreen.d.ts +26 -10
- package/dist/screens/WelcomeScreen.d.ts.map +1 -1
- package/dist/screens/WelcomeScreen.js +44 -21
- package/dist/screens/WelcomeScreen.js.map +1 -1
- package/dist/screens/site/SiteInitScreen.d.ts +12 -0
- package/dist/screens/site/SiteInitScreen.d.ts.map +1 -0
- package/dist/screens/site/SiteInitScreen.js +282 -0
- package/dist/screens/site/SiteInitScreen.js.map +1 -0
- package/dist/screens/site/SitePublishScreen.d.ts +15 -0
- package/dist/screens/site/SitePublishScreen.d.ts.map +1 -0
- package/dist/screens/site/SitePublishScreen.js +330 -0
- package/dist/screens/site/SitePublishScreen.js.map +1 -0
- package/dist/screens/site/SitePullScreen.d.ts +14 -0
- package/dist/screens/site/SitePullScreen.d.ts.map +1 -0
- package/dist/screens/site/SitePullScreen.js +455 -0
- package/dist/screens/site/SitePullScreen.js.map +1 -0
- package/dist/screens/site/SiteValidateScreen.d.ts +12 -0
- package/dist/screens/site/SiteValidateScreen.d.ts.map +1 -0
- package/dist/screens/site/SiteValidateScreen.js +201 -0
- package/dist/screens/site/SiteValidateScreen.js.map +1 -0
- package/dist/types/site.d.ts +348 -0
- package/dist/types/site.d.ts.map +1 -0
- package/dist/types/site.js +6 -0
- package/dist/types/site.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata Manager
|
|
3
|
+
* Handles the .oaysus/ directory containing project metadata:
|
|
4
|
+
* - config.json: Project configuration (websiteId, etc.)
|
|
5
|
+
* - components.json: Component catalog with schemas
|
|
6
|
+
* - assets.json: Asset manifest for sync tracking
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'fs/promises';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import { loadCredentials } from '../shared/auth.js';
|
|
12
|
+
import { SSO_BASE_URL, debug } from '../shared/config.js';
|
|
13
|
+
const OAYSUS_DIR = '.oaysus';
|
|
14
|
+
const CONFIG_FILE = 'config.json';
|
|
15
|
+
const COMPONENTS_FILE = 'components.json';
|
|
16
|
+
const ASSETS_FILE = 'assets.json';
|
|
17
|
+
/**
|
|
18
|
+
* Check if a file exists
|
|
19
|
+
*/
|
|
20
|
+
async function fileExists(filePath) {
|
|
21
|
+
try {
|
|
22
|
+
await fs.access(filePath);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Ensure the .oaysus directory exists
|
|
31
|
+
*/
|
|
32
|
+
export async function ensureOaysusDir(projectPath) {
|
|
33
|
+
const oaysusDir = path.join(projectPath, OAYSUS_DIR);
|
|
34
|
+
await fs.mkdir(oaysusDir, { recursive: true });
|
|
35
|
+
return oaysusDir;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a project has .oaysus metadata
|
|
39
|
+
*/
|
|
40
|
+
export async function hasOaysusMetadata(projectPath) {
|
|
41
|
+
const configPath = path.join(projectPath, OAYSUS_DIR, CONFIG_FILE);
|
|
42
|
+
return fileExists(configPath);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Find project root by looking for .oaysus/ directory
|
|
46
|
+
* Falls back to oaysus.website.json for backward compatibility
|
|
47
|
+
*/
|
|
48
|
+
export async function findProjectRoot(startPath = process.cwd()) {
|
|
49
|
+
let currentPath = path.resolve(startPath);
|
|
50
|
+
for (let i = 0; i < 10; i++) {
|
|
51
|
+
// Check for new .oaysus/ directory
|
|
52
|
+
const oaysusDir = path.join(currentPath, OAYSUS_DIR);
|
|
53
|
+
if (await fileExists(oaysusDir)) {
|
|
54
|
+
return currentPath;
|
|
55
|
+
}
|
|
56
|
+
// Backward compatibility: check for oaysus.website.json
|
|
57
|
+
const legacyConfig = path.join(currentPath, 'oaysus.website.json');
|
|
58
|
+
if (await fileExists(legacyConfig)) {
|
|
59
|
+
return currentPath;
|
|
60
|
+
}
|
|
61
|
+
const parentPath = path.dirname(currentPath);
|
|
62
|
+
if (parentPath === currentPath)
|
|
63
|
+
break;
|
|
64
|
+
currentPath = parentPath;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Config Management
|
|
70
|
+
// ============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* Load project config from .oaysus/config.json
|
|
73
|
+
*/
|
|
74
|
+
export async function loadConfig(projectPath) {
|
|
75
|
+
const configPath = path.join(projectPath, OAYSUS_DIR, CONFIG_FILE);
|
|
76
|
+
try {
|
|
77
|
+
const content = await fs.readFile(configPath, 'utf-8');
|
|
78
|
+
return JSON.parse(content);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Save project config to .oaysus/config.json
|
|
86
|
+
*/
|
|
87
|
+
export async function saveConfig(projectPath, config) {
|
|
88
|
+
await ensureOaysusDir(projectPath);
|
|
89
|
+
const configPath = path.join(projectPath, OAYSUS_DIR, CONFIG_FILE);
|
|
90
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get websiteId from config or credentials
|
|
94
|
+
*/
|
|
95
|
+
export async function getWebsiteId(projectPath) {
|
|
96
|
+
// Try .oaysus/config.json first
|
|
97
|
+
const config = await loadConfig(projectPath);
|
|
98
|
+
if (config?.websiteId) {
|
|
99
|
+
return config.websiteId;
|
|
100
|
+
}
|
|
101
|
+
// Try legacy oaysus.website.json
|
|
102
|
+
const legacyPath = path.join(projectPath, 'oaysus.website.json');
|
|
103
|
+
try {
|
|
104
|
+
const content = await fs.readFile(legacyPath, 'utf-8');
|
|
105
|
+
const legacy = JSON.parse(content);
|
|
106
|
+
if (legacy.websiteId) {
|
|
107
|
+
return legacy.websiteId;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Ignore
|
|
112
|
+
}
|
|
113
|
+
// Fall back to credentials
|
|
114
|
+
const credentials = await loadCredentials();
|
|
115
|
+
return credentials?.websiteId || null;
|
|
116
|
+
}
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// Component Catalog Management
|
|
119
|
+
// ============================================================================
|
|
120
|
+
/**
|
|
121
|
+
* Load component catalog from .oaysus/components.json
|
|
122
|
+
*/
|
|
123
|
+
export async function loadComponentCatalog(projectPath) {
|
|
124
|
+
const catalogPath = path.join(projectPath, OAYSUS_DIR, COMPONENTS_FILE);
|
|
125
|
+
try {
|
|
126
|
+
const content = await fs.readFile(catalogPath, 'utf-8');
|
|
127
|
+
return JSON.parse(content);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Save component catalog to .oaysus/components.json
|
|
135
|
+
*/
|
|
136
|
+
export async function saveComponentCatalog(projectPath, catalog) {
|
|
137
|
+
await ensureOaysusDir(projectPath);
|
|
138
|
+
const catalogPath = path.join(projectPath, OAYSUS_DIR, COMPONENTS_FILE);
|
|
139
|
+
await fs.writeFile(catalogPath, JSON.stringify(catalog, null, 2), 'utf-8');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Fetch components from server and build catalog
|
|
143
|
+
*/
|
|
144
|
+
export async function syncComponentCatalog(options) {
|
|
145
|
+
const { projectPath, force = false } = options;
|
|
146
|
+
let { websiteId, jwt } = options;
|
|
147
|
+
// Get credentials if not provided
|
|
148
|
+
if (!websiteId || !jwt) {
|
|
149
|
+
const credentials = await loadCredentials();
|
|
150
|
+
if (!credentials) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: 'Not authenticated. Run "oaysus login"',
|
|
154
|
+
componentCount: 0,
|
|
155
|
+
themePackCount: 0,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
websiteId = websiteId || credentials.websiteId;
|
|
159
|
+
jwt = jwt || credentials.jwt;
|
|
160
|
+
}
|
|
161
|
+
if (!websiteId) {
|
|
162
|
+
return {
|
|
163
|
+
success: false,
|
|
164
|
+
error: 'No website ID found',
|
|
165
|
+
componentCount: 0,
|
|
166
|
+
themePackCount: 0,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
debug('Syncing component catalog for website:', websiteId);
|
|
170
|
+
try {
|
|
171
|
+
// Fetch installed components
|
|
172
|
+
const componentsUrl = `${SSO_BASE_URL}/hosting/page-builder/components/custom`;
|
|
173
|
+
const componentsResponse = await axios.get(componentsUrl, {
|
|
174
|
+
params: { websiteId },
|
|
175
|
+
headers: { Authorization: `Bearer ${jwt}` },
|
|
176
|
+
});
|
|
177
|
+
if (!componentsResponse.data.success) {
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
error: componentsResponse.data.error || 'Failed to fetch components',
|
|
181
|
+
componentCount: 0,
|
|
182
|
+
themePackCount: 0,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const serverComponents = componentsResponse.data.components || [];
|
|
186
|
+
// Group components by theme pack
|
|
187
|
+
const themePackMap = new Map();
|
|
188
|
+
const allComponentTypes = [];
|
|
189
|
+
for (const comp of serverComponents) {
|
|
190
|
+
const themePackId = comp.themePackId || 'custom';
|
|
191
|
+
const themePackName = comp.themePack?.displayName || themePackId;
|
|
192
|
+
if (!themePackMap.has(themePackId)) {
|
|
193
|
+
themePackMap.set(themePackId, {
|
|
194
|
+
id: themePackId,
|
|
195
|
+
name: themePackName,
|
|
196
|
+
version: comp.version,
|
|
197
|
+
installed: true,
|
|
198
|
+
components: [],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const catalogComponent = {
|
|
202
|
+
type: comp.type || comp.name,
|
|
203
|
+
displayName: comp.displayName || comp.name,
|
|
204
|
+
description: comp.description,
|
|
205
|
+
category: comp.category,
|
|
206
|
+
schema: comp.schema,
|
|
207
|
+
defaultProps: comp.defaultProps,
|
|
208
|
+
// defaultShared from schema - used for shared component resolution
|
|
209
|
+
defaultShared: comp.defaultShared || false,
|
|
210
|
+
};
|
|
211
|
+
themePackMap.get(themePackId).components.push(catalogComponent);
|
|
212
|
+
allComponentTypes.push(catalogComponent.type);
|
|
213
|
+
}
|
|
214
|
+
const catalog = {
|
|
215
|
+
version: 1,
|
|
216
|
+
lastSyncedAt: new Date().toISOString(),
|
|
217
|
+
websiteId,
|
|
218
|
+
themePacks: Array.from(themePackMap.values()),
|
|
219
|
+
allComponentTypes,
|
|
220
|
+
};
|
|
221
|
+
// Save to disk
|
|
222
|
+
await saveComponentCatalog(projectPath, catalog);
|
|
223
|
+
debug('Component catalog synced:', allComponentTypes.length, 'components');
|
|
224
|
+
return {
|
|
225
|
+
success: true,
|
|
226
|
+
catalog,
|
|
227
|
+
componentCount: allComponentTypes.length,
|
|
228
|
+
themePackCount: themePackMap.size,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
let errorMessage = 'Failed to sync component catalog';
|
|
233
|
+
if (axios.isAxiosError(error)) {
|
|
234
|
+
if (error.response?.status === 401) {
|
|
235
|
+
errorMessage = 'Authentication failed. Please run "oaysus login"';
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
errorMessage = error.response?.data?.error || error.message;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (error instanceof Error) {
|
|
242
|
+
errorMessage = error.message;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
success: false,
|
|
246
|
+
error: errorMessage,
|
|
247
|
+
componentCount: 0,
|
|
248
|
+
themePackCount: 0,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Check if component catalog is stale (older than threshold)
|
|
254
|
+
* Can take either a ComponentCatalog object or a project path
|
|
255
|
+
*/
|
|
256
|
+
export async function isCatalogStale(catalogOrPath, maxAgeMs = 24 * 60 * 60 * 1000) {
|
|
257
|
+
let catalog;
|
|
258
|
+
if (typeof catalogOrPath === 'string') {
|
|
259
|
+
catalog = await loadComponentCatalog(catalogOrPath);
|
|
260
|
+
if (!catalog) {
|
|
261
|
+
return true; // No catalog = stale
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
catalog = catalogOrPath;
|
|
266
|
+
}
|
|
267
|
+
const lastSynced = new Date(catalog.lastSyncedAt).getTime();
|
|
268
|
+
const now = Date.now();
|
|
269
|
+
return now - lastSynced > maxAgeMs;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Check if a component type exists in the catalog
|
|
273
|
+
*/
|
|
274
|
+
export function componentExists(catalog, componentType) {
|
|
275
|
+
return catalog.allComponentTypes.includes(componentType);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Find a component in the catalog by type
|
|
279
|
+
*/
|
|
280
|
+
export function findComponent(catalog, componentType) {
|
|
281
|
+
for (const themePack of catalog.themePacks) {
|
|
282
|
+
const component = themePack.components.find(c => c.type === componentType);
|
|
283
|
+
if (component) {
|
|
284
|
+
return component;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Check if a component type should be shared by default
|
|
291
|
+
*/
|
|
292
|
+
export function isDefaultShared(catalog, componentType) {
|
|
293
|
+
const component = findComponent(catalog, componentType);
|
|
294
|
+
return component?.defaultShared === true;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Get suggestions for a misspelled component type
|
|
298
|
+
*/
|
|
299
|
+
export function getSuggestions(catalog, componentType, maxSuggestions = 3) {
|
|
300
|
+
const input = componentType.toLowerCase();
|
|
301
|
+
const scored = catalog.allComponentTypes.map(type => {
|
|
302
|
+
const target = type.toLowerCase();
|
|
303
|
+
// Simple similarity: count matching characters
|
|
304
|
+
let matches = 0;
|
|
305
|
+
for (const char of input) {
|
|
306
|
+
if (target.includes(char))
|
|
307
|
+
matches++;
|
|
308
|
+
}
|
|
309
|
+
// Bonus for prefix match
|
|
310
|
+
if (target.startsWith(input.slice(0, 3)))
|
|
311
|
+
matches += 5;
|
|
312
|
+
return { type, score: matches };
|
|
313
|
+
});
|
|
314
|
+
scored.sort((a, b) => b.score - a.score);
|
|
315
|
+
return scored.slice(0, maxSuggestions).map(s => s.type);
|
|
316
|
+
}
|
|
317
|
+
// ============================================================================
|
|
318
|
+
// Asset Manifest Management
|
|
319
|
+
// ============================================================================
|
|
320
|
+
/**
|
|
321
|
+
* Load asset manifest from .oaysus/assets.json
|
|
322
|
+
*/
|
|
323
|
+
export async function loadAssetManifest(projectPath) {
|
|
324
|
+
// Try new location first
|
|
325
|
+
const newPath = path.join(projectPath, OAYSUS_DIR, ASSETS_FILE);
|
|
326
|
+
try {
|
|
327
|
+
const content = await fs.readFile(newPath, 'utf-8');
|
|
328
|
+
return JSON.parse(content);
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
// Fall back to legacy location
|
|
332
|
+
const legacyPath = path.join(projectPath, 'assets', 'assets.json');
|
|
333
|
+
try {
|
|
334
|
+
const content = await fs.readFile(legacyPath, 'utf-8');
|
|
335
|
+
return JSON.parse(content);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// Return empty manifest
|
|
339
|
+
return { version: 1, assets: {} };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Save asset manifest to .oaysus/assets.json
|
|
345
|
+
*/
|
|
346
|
+
export async function saveAssetManifest(projectPath, manifest) {
|
|
347
|
+
await ensureOaysusDir(projectPath);
|
|
348
|
+
const manifestPath = path.join(projectPath, OAYSUS_DIR, ASSETS_FILE);
|
|
349
|
+
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
350
|
+
}
|
|
351
|
+
// ============================================================================
|
|
352
|
+
// Migration from legacy oaysus.website.json
|
|
353
|
+
// ============================================================================
|
|
354
|
+
/**
|
|
355
|
+
* Migrate from legacy oaysus.website.json to .oaysus/
|
|
356
|
+
*/
|
|
357
|
+
export async function migrateLegacyConfig(projectPath) {
|
|
358
|
+
const legacyPath = path.join(projectPath, 'oaysus.website.json');
|
|
359
|
+
try {
|
|
360
|
+
const content = await fs.readFile(legacyPath, 'utf-8');
|
|
361
|
+
const legacy = JSON.parse(content);
|
|
362
|
+
// Get websiteId from legacy or credentials
|
|
363
|
+
let websiteId = legacy.websiteId;
|
|
364
|
+
if (!websiteId) {
|
|
365
|
+
const credentials = await loadCredentials();
|
|
366
|
+
websiteId = credentials?.websiteId;
|
|
367
|
+
}
|
|
368
|
+
if (!websiteId) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
// Create new config
|
|
372
|
+
const config = {
|
|
373
|
+
version: 1,
|
|
374
|
+
websiteId,
|
|
375
|
+
};
|
|
376
|
+
await saveConfig(projectPath, config);
|
|
377
|
+
// Migrate assets.json if it exists in legacy location
|
|
378
|
+
const legacyAssetsPath = path.join(projectPath, 'assets', 'assets.json');
|
|
379
|
+
if (await fileExists(legacyAssetsPath)) {
|
|
380
|
+
const assetsContent = await fs.readFile(legacyAssetsPath, 'utf-8');
|
|
381
|
+
const manifest = JSON.parse(assetsContent);
|
|
382
|
+
await saveAssetManifest(projectPath, manifest);
|
|
383
|
+
}
|
|
384
|
+
debug('Migrated legacy config to .oaysus/');
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
catch {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// ============================================================================
|
|
392
|
+
// Initialization
|
|
393
|
+
// ============================================================================
|
|
394
|
+
/**
|
|
395
|
+
* Initialize .oaysus/ metadata for a project
|
|
396
|
+
*/
|
|
397
|
+
export async function initializeMetadata(options) {
|
|
398
|
+
const { projectPath, websiteId, websiteName, subdomain, syncComponents = true } = options;
|
|
399
|
+
try {
|
|
400
|
+
// Create config
|
|
401
|
+
const config = {
|
|
402
|
+
version: 1,
|
|
403
|
+
websiteId,
|
|
404
|
+
websiteName,
|
|
405
|
+
subdomain,
|
|
406
|
+
lastSyncedAt: new Date().toISOString(),
|
|
407
|
+
};
|
|
408
|
+
await saveConfig(projectPath, config);
|
|
409
|
+
// Sync component catalog if requested
|
|
410
|
+
if (syncComponents) {
|
|
411
|
+
let jwt = options.jwt;
|
|
412
|
+
if (!jwt) {
|
|
413
|
+
const credentials = await loadCredentials();
|
|
414
|
+
jwt = credentials?.jwt;
|
|
415
|
+
}
|
|
416
|
+
if (jwt) {
|
|
417
|
+
const syncResult = await syncComponentCatalog({
|
|
418
|
+
projectPath,
|
|
419
|
+
websiteId,
|
|
420
|
+
jwt,
|
|
421
|
+
});
|
|
422
|
+
if (!syncResult.success) {
|
|
423
|
+
return {
|
|
424
|
+
success: false,
|
|
425
|
+
error: `Created config but failed to sync components: ${syncResult.error}`,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Create empty asset manifest
|
|
431
|
+
await saveAssetManifest(projectPath, { version: 1, assets: {} });
|
|
432
|
+
return { success: true };
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
return {
|
|
436
|
+
success: false,
|
|
437
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Format component catalog for display
|
|
443
|
+
*/
|
|
444
|
+
export function formatCatalogForDisplay(catalog) {
|
|
445
|
+
const lines = [];
|
|
446
|
+
lines.push(`Component Catalog (synced ${new Date(catalog.lastSyncedAt).toLocaleString()})`);
|
|
447
|
+
lines.push(`Website: ${catalog.websiteId}`);
|
|
448
|
+
lines.push('');
|
|
449
|
+
if (catalog.themePacks.length === 0) {
|
|
450
|
+
lines.push('No components installed. Upload a theme pack first.');
|
|
451
|
+
return lines;
|
|
452
|
+
}
|
|
453
|
+
for (const themePack of catalog.themePacks) {
|
|
454
|
+
lines.push(`Theme Pack: ${themePack.name}${themePack.version ? ` v${themePack.version}` : ''}`);
|
|
455
|
+
for (let i = 0; i < themePack.components.length; i++) {
|
|
456
|
+
const comp = themePack.components[i];
|
|
457
|
+
const isLast = i === themePack.components.length - 1;
|
|
458
|
+
const prefix = isLast ? '└──' : '├──';
|
|
459
|
+
let line = ` ${prefix} ${comp.type}`;
|
|
460
|
+
if (comp.description) {
|
|
461
|
+
line += ` - ${comp.description}`;
|
|
462
|
+
}
|
|
463
|
+
lines.push(line);
|
|
464
|
+
}
|
|
465
|
+
lines.push('');
|
|
466
|
+
}
|
|
467
|
+
lines.push(`Total: ${catalog.allComponentTypes.length} components`);
|
|
468
|
+
return lines;
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrD,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAEtC,IAAI,IAAI,GAAG,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,IAAI,IAAI,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACnC,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,iBAAiB,CAAC,MAAM,aAAa,CAAC,CAAC;IAEpE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page Publisher
|
|
3
|
+
* Publishes pages to the Oaysus platform via API
|
|
4
|
+
*/
|
|
5
|
+
import type { PageDefinition, LoadedProject, PublishPageResult, PublishResult, UploadedAssetInfo } from '../../types/site.js';
|
|
6
|
+
/**
|
|
7
|
+
* Publish progress callback
|
|
8
|
+
*/
|
|
9
|
+
export type PublishProgressCallback = (stage: 'validating' | 'resolving-shared' | 'uploading-assets' | 'publishing-pages', current: number, total: number, detail?: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Check which pages from a project already exist on the server
|
|
12
|
+
* Returns list of slugs that will be overwritten
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkExistingPages(project: LoadedProject, options?: {
|
|
15
|
+
websiteId?: string;
|
|
16
|
+
jwt?: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
existingPages: string[];
|
|
19
|
+
newPages: string[];
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Publish a single page (create or update)
|
|
23
|
+
*/
|
|
24
|
+
export declare function publishPage(page: PageDefinition, options: {
|
|
25
|
+
websiteId: string;
|
|
26
|
+
jwt: string;
|
|
27
|
+
assetMap?: Map<string, UploadedAssetInfo>;
|
|
28
|
+
}): Promise<PublishPageResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Publish an entire project
|
|
31
|
+
*/
|
|
32
|
+
export declare function publishProject(project: LoadedProject, options?: {
|
|
33
|
+
websiteId?: string;
|
|
34
|
+
jwt?: string;
|
|
35
|
+
dryRun?: boolean;
|
|
36
|
+
skipValidation?: boolean;
|
|
37
|
+
onProgress?: PublishProgressCallback;
|
|
38
|
+
}): Promise<PublishResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Publish a single page file from a project
|
|
41
|
+
*/
|
|
42
|
+
export declare function publishSinglePage(project: LoadedProject, pageIdentifier: string, options?: {
|
|
43
|
+
websiteId?: string;
|
|
44
|
+
jwt?: string;
|
|
45
|
+
onProgress?: PublishProgressCallback;
|
|
46
|
+
}): Promise<PublishResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Format publish results for display
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatPublishResults(result: PublishResult): string[];
|
|
51
|
+
//# sourceMappingURL=page-publisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-publisher.d.ts","sourceRoot":"","sources":["../../../src/lib/site/page-publisher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,aAAa,EAEb,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAS7B;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,KAAK,EAAE,YAAY,GAAG,kBAAkB,GAAG,kBA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