realtimex-crm 0.6.1 → 0.7.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.
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { fileURLToPath } from "node:url";
4
+ import { dirname, join } from "node:path";
5
+ import { writeFile, mkdir } from "node:fs/promises";
6
+ import { existsSync } from "node:fs";
7
+ import { spawn } from "node:child_process";
8
+ import { input, confirm } from "@inquirer/prompts";
9
+ import { tmpdir } from "node:os";
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+
14
+ // Path to the pre-built dist folder in the npm package
15
+ const DIST_PATH = join(__dirname, "..", "dist");
16
+
17
+ async function main() {
18
+ console.log(`
19
+ ╔═══════════════════════════════════════╗
20
+ ║ ║
21
+ ║ RealTimeX CRM Production Server ║
22
+ ║ ║
23
+ ╘═══════════════════════════════════════╝
24
+ `);
25
+
26
+ // Parse command line arguments for port
27
+ const args = process.argv.slice(2);
28
+ let port = 6173; // Default port
29
+
30
+ const portIndex = args.indexOf("--port");
31
+ if (portIndex !== -1 && args[portIndex + 1]) {
32
+ const customPort = parseInt(args[portIndex + 1], 10);
33
+ if (!isNaN(customPort) && customPort > 0 && customPort < 65536) {
34
+ port = customPort;
35
+ } else {
36
+ console.error("❌ Invalid port number. Using default port 6173.");
37
+ }
38
+ }
39
+
40
+ // Check if dist folder exists
41
+ if (!existsSync(DIST_PATH)) {
42
+ console.error("❌ Error: Production build not found.");
43
+ console.error(
44
+ "Please ensure realtimex-crm is properly installed with the dist folder.",
45
+ );
46
+ process.exit(1);
47
+ }
48
+
49
+ // Prompt for Supabase configuration
50
+ console.log("\n📝 Supabase Configuration\n");
51
+ console.log(
52
+ "You can configure Supabase now or later via Settings → Database in the app.\n",
53
+ );
54
+
55
+ const configureNow = await confirm({
56
+ message: "Configure Supabase now?",
57
+ default: false,
58
+ });
59
+
60
+ if (configureNow) {
61
+ const supabaseUrl = await input({
62
+ message: "Supabase URL:",
63
+ validate: (value) => {
64
+ if (!value.trim()) return "Supabase URL is required";
65
+ if (!value.includes("supabase.co") && !value.includes("localhost"))
66
+ return "URL should be a valid Supabase project URL";
67
+ return true;
68
+ },
69
+ });
70
+
71
+ const supabaseAnonKey = await input({
72
+ message: "Supabase Anon Key:",
73
+ validate: (value) => {
74
+ if (!value.trim()) return "Supabase Anon Key is required";
75
+ return true;
76
+ },
77
+ });
78
+
79
+ // Create a temporary .env file in the dist directory
80
+ // Note: This is a workaround since the built app expects env vars at build time
81
+ // The app will fall back to localStorage configuration if these aren't available
82
+ console.log("\n✅ Configuration saved!");
83
+ console.log(
84
+ "Note: You can update configuration anytime via Settings → Database in the app.\n",
85
+ );
86
+
87
+ // Save config to a temp location that the user can reference
88
+ const configPath = join(tmpdir(), "realtimex-crm-config.txt");
89
+ const configContent = `Supabase Configuration:
90
+ URL: ${supabaseUrl}
91
+ Anon Key: ${supabaseAnonKey}
92
+
93
+ To configure the app:
94
+ 1. Open the app in your browser
95
+ 2. Go to Settings → Database
96
+ 3. Enter these credentials
97
+ `;
98
+ await writeFile(configPath, configContent);
99
+ console.log(`Configuration details saved to: ${configPath}\n`);
100
+ }
101
+
102
+ console.log("\n🚀 Starting production server...\n");
103
+ console.log(` Local: http://localhost:${port}`);
104
+ console.log(` Network: http://127.0.0.1:${port}\n`);
105
+
106
+ if (!configureNow) {
107
+ console.log(
108
+ "💡 Configure Supabase via Settings → Database in the app after it loads.\n",
109
+ );
110
+ }
111
+
112
+ console.log("Press Ctrl+C to stop the server.\n");
113
+
114
+ // Start the server using the serve package
115
+ const serveProcess = spawn(
116
+ "npx",
117
+ ["serve", "-s", DIST_PATH, "-l", `tcp://127.0.0.1:${port}`, "--no-clipboard"],
118
+ {
119
+ stdio: "inherit",
120
+ shell: true,
121
+ },
122
+ );
123
+
124
+ // Handle process termination
125
+ process.on("SIGINT", () => {
126
+ console.log("\n\n👋 Stopping server...");
127
+ serveProcess.kill();
128
+ process.exit(0);
129
+ });
130
+
131
+ process.on("SIGTERM", () => {
132
+ serveProcess.kill();
133
+ process.exit(0);
134
+ });
135
+
136
+ serveProcess.on("error", (error) => {
137
+ console.error("\n❌ Error starting server:", error.message);
138
+ console.error(
139
+ '\nPlease ensure "serve" is installed: npm install -g serve',
140
+ );
141
+ process.exit(1);
142
+ });
143
+
144
+ serveProcess.on("exit", (code) => {
145
+ if (code !== 0 && code !== null) {
146
+ console.error(`\n❌ Server exited with code ${code}`);
147
+ process.exit(code);
148
+ }
149
+ });
150
+ }
151
+
152
+ main().catch((error) => {
153
+ console.error("\n❌ Error:", error.message);
154
+ process.exit(1);
155
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realtimex-crm",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "RealTimeX CRM - A full-featured CRM built with React, shadcn-admin-kit, and Supabase. Fork of Atomic CRM with RealTimeX App SDK integration.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,8 @@
14
14
  }
15
15
  },
16
16
  "bin": {
17
- "create-realtimex-crm": "./bin/create-realtimex-crm.js"
17
+ "create-realtimex-crm": "./bin/create-realtimex-crm.js",
18
+ "realtimex-crm": "./bin/realtimex-crm.js"
18
19
  },
19
20
  "files": [
20
21
  "dist",
@@ -147,6 +148,7 @@
147
148
  "prettier": "^3.6.2",
148
149
  "serve": "^14.2.5",
149
150
  "shadcn": "^3.5.0",
151
+ "supabase": "^2.67.2",
150
152
  "typescript": "~5.8.3",
151
153
  "typescript-eslint": "^8.35.1",
152
154
  "vite": "^7.0.4",