@feltdb/core 0.6.0 → 0.6.1
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/dist/cli/commands.js
CHANGED
|
@@ -8,7 +8,7 @@ import net from 'net';
|
|
|
8
8
|
import { createRequire } from 'module';
|
|
9
9
|
import { spawn, spawnSync } from 'child_process';
|
|
10
10
|
import { createFeltDB, diffFlowSpec, formatFlowSpec, parseFlowSpec, planFlowSpecMigration, validateFlowSpec } from '@feltdb/core';
|
|
11
|
-
import { discoverWorkspace, generatePairingToken, persistPairingToken, displayWorkspaceStatus } from './workspace-integration.js';
|
|
11
|
+
import { discoverWorkspace, generatePairingToken, persistPairingToken, displayWorkspaceStatus, initializeWorkspace } from './workspace-integration.js';
|
|
12
12
|
function loadProjectEnvironment(file = path.resolve('.env.local')) {
|
|
13
13
|
if (!fs.existsSync(file))
|
|
14
14
|
return;
|
|
@@ -431,11 +431,50 @@ async function handleDev(args) {
|
|
|
431
431
|
var _a, _b, _c;
|
|
432
432
|
loadProjectEnvironment();
|
|
433
433
|
console.log('🚀 Starting FeltDB development server...\n');
|
|
434
|
-
|
|
435
|
-
const configPath = path.join(
|
|
434
|
+
const projectDir = process.cwd();
|
|
435
|
+
const configPath = path.join(projectDir, 'feltdb.config.json');
|
|
436
|
+
// Initialize workspace if needed
|
|
437
|
+
let workspace = discoverWorkspace(projectDir);
|
|
438
|
+
if (!workspace) {
|
|
439
|
+
// Get project name from package.json
|
|
440
|
+
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
441
|
+
let projectId = path.basename(projectDir);
|
|
442
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
443
|
+
try {
|
|
444
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
445
|
+
projectId = packageJson.name || projectId;
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
// Use default projectId if package.json parsing fails
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
workspace = initializeWorkspace(projectDir, projectId);
|
|
452
|
+
console.log(`✨ Initialized Development Workspace`);
|
|
453
|
+
console.log(` Workspace ID: ${workspace.workspaceId}\n`);
|
|
454
|
+
}
|
|
455
|
+
// Create feltdb.config.json if it doesn't exist
|
|
436
456
|
if (!fs.existsSync(configPath)) {
|
|
437
|
-
|
|
438
|
-
|
|
457
|
+
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
458
|
+
let namespace = path.basename(projectDir);
|
|
459
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
460
|
+
try {
|
|
461
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
462
|
+
namespace = packageJson.name || namespace;
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
// Use default namespace if package.json parsing fails
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
const defaultConfig = {
|
|
469
|
+
namespace,
|
|
470
|
+
runtime: 'browser',
|
|
471
|
+
storage: 'indexeddb',
|
|
472
|
+
distributed: true,
|
|
473
|
+
agents: { enabled: false },
|
|
474
|
+
capabilities: { search: true },
|
|
475
|
+
};
|
|
476
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2) + '\n');
|
|
477
|
+
console.log(`✨ Created feltdb.config.json with default configuration\n`);
|
|
439
478
|
}
|
|
440
479
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
441
480
|
if (config.runtime === 'managed') {
|
|
@@ -480,9 +519,8 @@ async function handleDev(args) {
|
|
|
480
519
|
selfHostedStarted = true;
|
|
481
520
|
(_c = process.env).VITE_FELTDB_URL || (_c.VITE_FELTDB_URL = 'http://127.0.0.1:7700');
|
|
482
521
|
}
|
|
483
|
-
//
|
|
484
|
-
// This enables
|
|
485
|
-
const workspace = discoverWorkspace(process.cwd());
|
|
522
|
+
// Generate pairing token for the workspace
|
|
523
|
+
// This enables browsers and IDEs to discover and connect to the workspace
|
|
486
524
|
let pairingToken = null;
|
|
487
525
|
if (workspace) {
|
|
488
526
|
const token = generatePairingToken();
|
package/dist/cli/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import * as path from 'path';
|
|
|
23
23
|
import * as readline from 'readline';
|
|
24
24
|
import { getClient } from './api-client.js';
|
|
25
25
|
import { loadFeltDBConfig, createDefaultConfig, validateModel, } from './config.js';
|
|
26
|
-
const VERSION = '0.
|
|
26
|
+
const VERSION = '0.6.1';
|
|
27
27
|
function prompt(question) {
|
|
28
28
|
const rl = readline.createInterface({
|
|
29
29
|
input: process.stdin,
|
|
@@ -73,6 +73,37 @@ export function readPairingToken(projectDir) {
|
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Generate a unique workspace ID
|
|
78
|
+
* Format: ws_<projectId>_<timestamp>_<random>
|
|
79
|
+
*/
|
|
80
|
+
export function generateWorkspaceId(projectId) {
|
|
81
|
+
const timestamp = Date.now();
|
|
82
|
+
const random = Math.random().toString(36).substring(2, 9);
|
|
83
|
+
return `ws_${projectId}_${timestamp}_${random}`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Initialize development workspace for a project
|
|
87
|
+
* Creates .feltdb/workspace.json with workspace discovery information.
|
|
88
|
+
*/
|
|
89
|
+
export function initializeWorkspace(projectDir, projectId) {
|
|
90
|
+
const feltdbDir = path.join(projectDir, '.feltdb');
|
|
91
|
+
// Ensure .feltdb directory exists
|
|
92
|
+
if (!fs.existsSync(feltdbDir)) {
|
|
93
|
+
fs.mkdirSync(feltdbDir, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
// Create workspace discovery
|
|
96
|
+
const workspaceId = generateWorkspaceId(projectId);
|
|
97
|
+
const discovery = {
|
|
98
|
+
workspaceId,
|
|
99
|
+
projectId,
|
|
100
|
+
version: 1,
|
|
101
|
+
};
|
|
102
|
+
// Write workspace.json
|
|
103
|
+
const workspacePath = path.join(feltdbDir, 'workspace.json');
|
|
104
|
+
fs.writeFileSync(workspacePath, JSON.stringify(discovery, null, 2) + '\n');
|
|
105
|
+
return discovery;
|
|
106
|
+
}
|
|
76
107
|
/**
|
|
77
108
|
* Display workspace status information
|
|
78
109
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// One release train keeps generated applications installable. The repository
|
|
2
2
|
// validation script checks these values against every workspace manifest.
|
|
3
|
-
export const FELTDB_PACKAGE_VERSION = '0.6.
|
|
3
|
+
export const FELTDB_PACKAGE_VERSION = '0.6.1';
|
|
4
4
|
export const feltdbPackageRange = `^${FELTDB_PACKAGE_VERSION}`;
|
package/package.json
CHANGED