realtimex-crm 0.7.5 → 0.7.7

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.
@@ -23,10 +23,16 @@ async function main() {
23
23
  ╘═══════════════════════════════════════╝
24
24
  `);
25
25
 
26
- // Parse command line arguments for port
26
+ // --- Argument and Environment Variable Parsing ---
27
27
  const args = process.argv.slice(2);
28
- let port = 6173; // Default port
28
+ const nonInteractiveYes = args.includes('-y');
29
+ const nonInteractiveNo = args.includes('-n');
30
+
31
+ const supabaseUrlFromEnv = process.env.SUPABASE_URL;
32
+ const supabaseAnonKeyFromEnv = process.env.SUPABASE_ANON_KEY;
29
33
 
34
+ // --- Port Configuration ---
35
+ let port = 6173; // Default port
30
36
  const portIndex = args.indexOf("--port");
31
37
  if (portIndex !== -1 && args[portIndex + 1]) {
32
38
  const customPort = parseInt(args[portIndex + 1], 10);
@@ -46,48 +52,66 @@ async function main() {
46
52
  process.exit(1);
47
53
  }
48
54
 
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
- );
55
+ // --- Determine if Supabase configuration should run ---
56
+ let configureNow;
57
+ if (nonInteractiveNo) {
58
+ configureNow = false;
59
+ } else if (nonInteractiveYes || supabaseUrlFromEnv) {
60
+ configureNow = true;
61
+ } else {
62
+ console.log("\n📝 Supabase Configuration\n");
63
+ console.log(
64
+ "You can configure Supabase now or later via Settings → Database in the app.\n",
65
+ );
66
+ configureNow = await confirm({
67
+ message: "Configure Supabase now?",
68
+ default: false,
69
+ });
70
+ }
54
71
 
55
- const configureNow = await confirm({
56
- message: "Configure Supabase now?",
57
- default: false,
58
- });
59
72
 
60
73
  if (configureNow) {
61
- console.log("First, ensure you are logged in to the Supabase CLI.");
62
- console.log("Run `npx supabase login` if you haven't already.");
63
-
64
- const supabaseUrl = await input({
65
- message: "Supabase URL:",
66
- validate: (value) => {
67
- if (!value.trim()) return "Supabase URL is required";
68
- if (!value.includes("supabase.co") && !value.includes("localhost"))
69
- return "URL should be a valid Supabase project URL";
70
- return true;
71
- },
72
- });
74
+ // --- Get Supabase Credentials ---
75
+ let supabaseUrl = supabaseUrlFromEnv;
76
+ let supabaseAnonKey = supabaseAnonKeyFromEnv;
77
+
78
+ if (!supabaseUrl || !supabaseAnonKey) {
79
+ console.log("\n📝 Supabase Configuration\n");
80
+ console.log("First, ensure you are logged in to the Supabase CLI.");
81
+ console.log("Run `npx supabase login` if you haven't already.\n");
82
+ }
73
83
 
74
- const supabaseAnonKey = await input({
75
- message: "Supabase Publishable API Key (anon key):",
76
- validate: (value) => {
77
- if (!value.trim()) return "Supabase Publishable API Key is required";
78
- return true;
79
- },
80
- });
84
+ if (!supabaseUrl) {
85
+ supabaseUrl = await input({
86
+ message: "Supabase URL:",
87
+ validate: (value) => {
88
+ if (!value.trim()) return "Supabase URL is required";
89
+ if (!value.includes("supabase.co") && !value.includes("localhost"))
90
+ return "URL should be a valid Supabase project URL";
91
+ return true;
92
+ },
93
+ });
94
+ } else {
95
+ console.log(`Using SUPABASE_URL from environment.`);
96
+ }
81
97
 
82
- // Create a temporary .env file in the dist directory
83
- // Note: This is a workaround since the built app expects env vars at build time
84
- // The app will fall back to localStorage configuration if these aren't available
98
+ if (!supabaseAnonKey) {
99
+ supabaseAnonKey = await input({
100
+ message: "Supabase Publishable API Key (anon key):",
101
+ validate: (value) => {
102
+ if (!value.trim()) return "Supabase Publishable API Key is required";
103
+ return true;
104
+ },
105
+ });
106
+ } else {
107
+ console.log(`Using SUPABASE_ANON_KEY from environment.`);
108
+ }
109
+
110
+ // --- Save Configuration ---
85
111
  console.log("\n✅ Configuration saved!");
86
112
  console.log(
87
113
  "Note: You can update configuration anytime via Settings → Database in the app.\n",
88
114
  );
89
-
90
- // Save config to a temp location that the user can reference
91
115
  const configPath = join(tmpdir(), "realtimex-crm-config.txt");
92
116
  const configContent = `Supabase Configuration:
93
117
  URL: ${supabaseUrl}
@@ -101,14 +125,15 @@ To configure the app:
101
125
  await writeFile(configPath, configContent);
102
126
  console.log(`Configuration details saved to: ${configPath}\n`);
103
127
 
104
- // Helper to run supabase commands
128
+
129
+ // --- Supabase CLI Commands ---
105
130
  const runSupabaseCommand = async (command, message) => {
106
- const cwd = process.cwd();
107
- console.log(`\n${message} (from directory: ${cwd})`);
131
+ const packageRoot = join(__dirname, '..');
132
+ console.log(`\n${message} (from package root: ${packageRoot})`);
108
133
  const proc = spawn("npx", ["supabase", ...command], {
109
134
  stdio: "inherit",
110
135
  shell: true,
111
- cwd: cwd,
136
+ cwd: packageRoot,
112
137
  });
113
138
 
114
139
  return new Promise((resolve, reject) => {
@@ -128,18 +153,20 @@ To configure the app:
128
153
  });
129
154
  };
130
155
 
131
- // Link the project
132
156
  const projectRefMatch = supabaseUrl.match(/https:\/\/([a-zA-Z0-9_-]+)\.supabase\.co/);
133
157
  if (projectRefMatch && projectRefMatch[1]) {
134
158
  const projectRef = projectRefMatch[1];
135
159
  try {
136
160
  await runSupabaseCommand(["link", "--project-ref", projectRef], `🔗 Linking to Supabase project '${projectRef}'...`);
137
161
 
138
- const runDbPush = await confirm({
139
- message: "Run `npx supabase db push` to apply migrations?",
140
- default: false,
141
- });
142
-
162
+ let runDbPush = nonInteractiveYes;
163
+ if (!nonInteractiveYes && !nonInteractiveNo) {
164
+ runDbPush = await confirm({
165
+ message: "Run `npx supabase db push` to apply migrations?",
166
+ default: false,
167
+ });
168
+ }
169
+
143
170
  if (runDbPush) {
144
171
  try {
145
172
  await runSupabaseCommand(["db", "push"], "🚀 Running `npx supabase db push`...");
@@ -148,10 +175,13 @@ To configure the app:
148
175
  }
149
176
  }
150
177
 
151
- const runFunctionsDeploy = await confirm({
152
- message: "Run `npx supabase functions deploy` to deploy functions?",
153
- default: false,
154
- });
178
+ let runFunctionsDeploy = nonInteractiveYes;
179
+ if (!nonInteractiveYes && !nonInteractiveNo) {
180
+ runFunctionsDeploy = await confirm({
181
+ message: "Run `npx supabase functions deploy` to deploy functions?",
182
+ default: false,
183
+ });
184
+ }
155
185
 
156
186
  if (runFunctionsDeploy) {
157
187
  try {
@@ -168,6 +198,7 @@ To configure the app:
168
198
  }
169
199
  }
170
200
 
201
+ // --- Start Production Server ---
171
202
  console.log("\n🚀 Starting production server...\n");
172
203
  console.log(` Local: http://localhost:${port}`);
173
204
  console.log(` Network: http://127.0.0.1:${port}\n`);
@@ -180,7 +211,6 @@ To configure the app:
180
211
 
181
212
  console.log("Press Ctrl+C to stop the server.\n");
182
213
 
183
- // Start the server using the serve package
184
214
  const serveProcess = spawn(
185
215
  "npx",
186
216
  ["serve", "-s", DIST_PATH, "-l", `tcp://127.0.0.1:${port}`, "--no-clipboard"],
@@ -190,7 +220,6 @@ To configure the app:
190
220
  },
191
221
  );
192
222
 
193
- // Handle process termination
194
223
  process.on("SIGINT", () => {
195
224
  console.log("\n\n👋 Stopping server...");
196
225
  serveProcess.kill();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "realtimex-crm",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
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",