@panoptic-it-solutions/coolify-setup 1.1.42 → 1.1.44
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/generator.js +8 -0
- package/dist/git.js +72 -22
- package/dist/index.js +6 -0
- package/package.json +1 -1
package/dist/generator.js
CHANGED
|
@@ -63,6 +63,14 @@ function runDrizzleKitGenerate(packageManager) {
|
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
try {
|
|
66
|
+
// First, update drizzle-orm and drizzle-kit to latest versions to avoid version mismatch
|
|
67
|
+
const updateCmd = packageManager === 'pnpm'
|
|
68
|
+
? 'pnpm update drizzle-orm drizzle-kit'
|
|
69
|
+
: packageManager === 'yarn'
|
|
70
|
+
? 'yarn upgrade drizzle-orm drizzle-kit'
|
|
71
|
+
: 'npm update drizzle-orm drizzle-kit';
|
|
72
|
+
console.log(`Updating drizzle packages...`);
|
|
73
|
+
execSync(updateCmd, { stdio: 'inherit', cwd: process.cwd() });
|
|
66
74
|
// Use the package manager's exec command to run drizzle-kit
|
|
67
75
|
const execCmd = packageManager === 'pnpm'
|
|
68
76
|
? 'pnpm drizzle-kit generate'
|
package/dist/git.js
CHANGED
|
@@ -2,6 +2,51 @@ import { execSync, exec } from 'child_process';
|
|
|
2
2
|
import { promisify } from 'util';
|
|
3
3
|
const execAsync = promisify(exec);
|
|
4
4
|
const ORG = 'Panoptic-IT-Solutions';
|
|
5
|
+
// Cache the detected remote name to avoid repeated lookups
|
|
6
|
+
let cachedRemoteName = null;
|
|
7
|
+
/**
|
|
8
|
+
* Find the remote that points to Panoptic-IT-Solutions.
|
|
9
|
+
* Could be 'origin', 'panoptic', or any other name.
|
|
10
|
+
* Returns null if no Panoptic remote is found.
|
|
11
|
+
*/
|
|
12
|
+
function findPanopticRemote() {
|
|
13
|
+
if (cachedRemoteName !== null) {
|
|
14
|
+
return cachedRemoteName || null;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const remotes = run('git remote').split('\n').filter(Boolean);
|
|
18
|
+
for (const remote of remotes) {
|
|
19
|
+
try {
|
|
20
|
+
const url = run(`git remote get-url ${remote}`);
|
|
21
|
+
if (url.includes(`github.com/${ORG}/`) || url.includes(`github.com:${ORG}/`)) {
|
|
22
|
+
cachedRemoteName = remote;
|
|
23
|
+
return remote;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Skip remotes that fail to get URL
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Not a git repo or no remotes
|
|
33
|
+
}
|
|
34
|
+
cachedRemoteName = ''; // Empty string means we checked but found nothing
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the remote name to use for git operations.
|
|
39
|
+
* Prefers the Panoptic remote if found, otherwise falls back to 'origin'.
|
|
40
|
+
*/
|
|
41
|
+
function getRemoteName() {
|
|
42
|
+
return findPanopticRemote() || 'origin';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Clear the cached remote name (useful after adding/removing remotes)
|
|
46
|
+
*/
|
|
47
|
+
function clearRemoteCache() {
|
|
48
|
+
cachedRemoteName = null;
|
|
49
|
+
}
|
|
5
50
|
function run(command) {
|
|
6
51
|
return execSync(command, { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
7
52
|
}
|
|
@@ -10,8 +55,9 @@ async function runAsync(command) {
|
|
|
10
55
|
return stdout.trim();
|
|
11
56
|
}
|
|
12
57
|
function getGitRemoteUrl() {
|
|
58
|
+
const remote = getRemoteName();
|
|
13
59
|
try {
|
|
14
|
-
return run(
|
|
60
|
+
return run(`git remote get-url ${remote}`);
|
|
15
61
|
}
|
|
16
62
|
catch {
|
|
17
63
|
return null;
|
|
@@ -40,6 +86,8 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
40
86
|
branchName: 'develop',
|
|
41
87
|
warnings: [],
|
|
42
88
|
};
|
|
89
|
+
// Get the remote name (could be 'origin', 'panoptic', etc.)
|
|
90
|
+
const remote = getRemoteName();
|
|
43
91
|
// Initialize git if not already a repo
|
|
44
92
|
if (!isGitRepo()) {
|
|
45
93
|
run('git init');
|
|
@@ -84,19 +132,19 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
84
132
|
if (sourceBranch === 'develop') {
|
|
85
133
|
// Already on develop, pull and push
|
|
86
134
|
try {
|
|
87
|
-
run(
|
|
135
|
+
run(`git pull --rebase ${remote} develop`);
|
|
88
136
|
}
|
|
89
137
|
catch {
|
|
90
138
|
// Pull might fail if remote doesn't exist yet, that's ok
|
|
91
139
|
}
|
|
92
|
-
run(
|
|
140
|
+
run(`git push ${remote} develop`);
|
|
93
141
|
}
|
|
94
142
|
else {
|
|
95
143
|
// On a feature branch - need to merge into develop
|
|
96
144
|
// First check if develop exists remotely
|
|
97
145
|
let developExistsRemotely = false;
|
|
98
146
|
try {
|
|
99
|
-
run(
|
|
147
|
+
run(`git fetch ${remote} develop`);
|
|
100
148
|
developExistsRemotely = true;
|
|
101
149
|
}
|
|
102
150
|
catch {
|
|
@@ -119,7 +167,7 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
119
167
|
run('git checkout develop');
|
|
120
168
|
}
|
|
121
169
|
else {
|
|
122
|
-
run(
|
|
170
|
+
run(`git checkout -b develop ${remote}/develop`);
|
|
123
171
|
}
|
|
124
172
|
checkoutSucceeded = true;
|
|
125
173
|
}
|
|
@@ -127,9 +175,9 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
127
175
|
// Checkout failed - might be worktree issue
|
|
128
176
|
// Try fast-forward push if source branch contains all develop commits
|
|
129
177
|
try {
|
|
130
|
-
run(`git merge-base --is-ancestor
|
|
178
|
+
run(`git merge-base --is-ancestor ${remote}/develop ${sourceBranch}`);
|
|
131
179
|
// Source branch is ahead of develop, can fast-forward push
|
|
132
|
-
run(`git push
|
|
180
|
+
run(`git push ${remote} ${sourceBranch}:develop`);
|
|
133
181
|
result.pushed = true;
|
|
134
182
|
return result;
|
|
135
183
|
}
|
|
@@ -141,7 +189,7 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
141
189
|
if (checkoutSucceeded) {
|
|
142
190
|
// Pull latest changes
|
|
143
191
|
try {
|
|
144
|
-
run(
|
|
192
|
+
run(`git pull --rebase ${remote} develop`);
|
|
145
193
|
}
|
|
146
194
|
catch {
|
|
147
195
|
// Pull might fail, continue
|
|
@@ -160,7 +208,7 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
160
208
|
}
|
|
161
209
|
throw new Error(`Merge conflict between develop and ${sourceBranch}. Please resolve manually.`);
|
|
162
210
|
}
|
|
163
|
-
run(
|
|
211
|
+
run(`git push ${remote} develop`);
|
|
164
212
|
// Return to original branch
|
|
165
213
|
try {
|
|
166
214
|
run(`git checkout ${sourceBranch}`);
|
|
@@ -172,7 +220,7 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
172
220
|
}
|
|
173
221
|
else {
|
|
174
222
|
// Develop doesn't exist remotely, create it from source branch
|
|
175
|
-
run(`git push
|
|
223
|
+
run(`git push ${remote} ${sourceBranch}:develop`);
|
|
176
224
|
}
|
|
177
225
|
}
|
|
178
226
|
result.pushed = true;
|
|
@@ -193,6 +241,8 @@ export async function setupGitHub(projectName) {
|
|
|
193
241
|
existingRemote: null,
|
|
194
242
|
warnings: [],
|
|
195
243
|
};
|
|
244
|
+
// Get the remote name (could be 'origin', 'panoptic', etc.)
|
|
245
|
+
const remote = getRemoteName();
|
|
196
246
|
// Initialize git if not already a repo
|
|
197
247
|
if (!isGitRepo()) {
|
|
198
248
|
run('git init');
|
|
@@ -220,7 +270,7 @@ export async function setupGitHub(projectName) {
|
|
|
220
270
|
// Validate remote points to the correct repo
|
|
221
271
|
if (!isCorrectRemote(existingRemote, projectName)) {
|
|
222
272
|
result.warnings.push(`Existing remote '${existingRemote}' does not match expected repo '${ORG}/${projectName}'. ` +
|
|
223
|
-
`Remove it with 'git remote remove
|
|
273
|
+
`Remove it with 'git remote remove ${remote}' and re-run setup to create the correct repo.`);
|
|
224
274
|
// Don't proceed with operations that would push to the wrong repo
|
|
225
275
|
return result;
|
|
226
276
|
}
|
|
@@ -272,15 +322,15 @@ export async function setupGitHub(projectName) {
|
|
|
272
322
|
try {
|
|
273
323
|
// First fetch to check if develop exists remotely
|
|
274
324
|
try {
|
|
275
|
-
run(
|
|
325
|
+
run(`git fetch ${remote} develop`);
|
|
276
326
|
// Check if current branch contains all develop commits (fast-forward possible)
|
|
277
|
-
run(`git merge-base --is-ancestor
|
|
327
|
+
run(`git merge-base --is-ancestor ${remote}/develop ${currentBranch}`);
|
|
278
328
|
}
|
|
279
329
|
catch {
|
|
280
330
|
// Either develop doesn't exist remotely, or can't fast-forward
|
|
281
331
|
// Try push anyway - will fail if develop exists and diverged
|
|
282
332
|
}
|
|
283
|
-
run(`git push
|
|
333
|
+
run(`git push ${remote} ${currentBranch}:develop -u`);
|
|
284
334
|
result.developBranchCreated = true;
|
|
285
335
|
result.repoPushed = true;
|
|
286
336
|
// Skip the rest of develop push logic since we already pushed
|
|
@@ -294,12 +344,12 @@ export async function setupGitHub(projectName) {
|
|
|
294
344
|
if (checkoutSucceeded) {
|
|
295
345
|
// Pull latest changes before pushing to avoid non-fast-forward errors
|
|
296
346
|
try {
|
|
297
|
-
run(
|
|
347
|
+
run(`git pull --rebase ${remote} develop`);
|
|
298
348
|
}
|
|
299
349
|
catch {
|
|
300
350
|
// Pull might fail if remote doesn't exist yet, that's ok
|
|
301
351
|
}
|
|
302
|
-
run(
|
|
352
|
+
run(`git push ${remote} develop -u`);
|
|
303
353
|
result.developBranchCreated = true;
|
|
304
354
|
result.repoPushed = true;
|
|
305
355
|
}
|
|
@@ -307,12 +357,12 @@ export async function setupGitHub(projectName) {
|
|
|
307
357
|
else {
|
|
308
358
|
// Already on develop
|
|
309
359
|
try {
|
|
310
|
-
run(
|
|
360
|
+
run(`git pull --rebase ${remote} develop`);
|
|
311
361
|
}
|
|
312
362
|
catch {
|
|
313
363
|
// Pull might fail if remote doesn't exist yet, that's ok
|
|
314
364
|
}
|
|
315
|
-
run(
|
|
365
|
+
run(`git push ${remote} develop -u`);
|
|
316
366
|
result.developBranchCreated = true;
|
|
317
367
|
result.repoPushed = true;
|
|
318
368
|
}
|
|
@@ -324,13 +374,13 @@ export async function setupGitHub(projectName) {
|
|
|
324
374
|
// Create main branch from develop if it doesn't exist
|
|
325
375
|
try {
|
|
326
376
|
// Check if main exists remotely
|
|
327
|
-
run(
|
|
377
|
+
run(`git ls-remote --exit-code --heads ${remote} main`);
|
|
328
378
|
result.mainBranchPushed = true; // Already exists
|
|
329
379
|
}
|
|
330
380
|
catch {
|
|
331
381
|
// Main doesn't exist, create it from develop
|
|
332
382
|
try {
|
|
333
|
-
run(
|
|
383
|
+
run(`git push ${remote} develop:main`);
|
|
334
384
|
result.mainBranchPushed = true;
|
|
335
385
|
}
|
|
336
386
|
catch {
|
|
@@ -340,13 +390,13 @@ export async function setupGitHub(projectName) {
|
|
|
340
390
|
// Create staging branch from develop if it doesn't exist
|
|
341
391
|
try {
|
|
342
392
|
// Check if staging exists remotely
|
|
343
|
-
run(
|
|
393
|
+
run(`git ls-remote --exit-code --heads ${remote} staging`);
|
|
344
394
|
result.stagingBranchCreated = true; // Already exists
|
|
345
395
|
}
|
|
346
396
|
catch {
|
|
347
397
|
// Staging doesn't exist, create it from develop
|
|
348
398
|
try {
|
|
349
|
-
run(
|
|
399
|
+
run(`git push ${remote} develop:staging`);
|
|
350
400
|
result.stagingBranchCreated = true;
|
|
351
401
|
}
|
|
352
402
|
catch {
|
package/dist/index.js
CHANGED
|
@@ -229,6 +229,12 @@ async function main() {
|
|
|
229
229
|
console.log(chalk.green(' ✅ MINIO_ENDPOINT=http://minio:9000\n'));
|
|
230
230
|
}
|
|
231
231
|
console.log(chalk.yellow(' Docker containers use service names for internal DNS resolution.\n'));
|
|
232
|
+
console.log(chalk.bgRed.white.bold(' ⚠️ IMPORTANT: Database Not Shared Between Environments '));
|
|
233
|
+
console.log(chalk.yellow('\n Each environment (staging, production) has its OWN database.'));
|
|
234
|
+
console.log(chalk.yellow(' Deploying to staging does NOT copy production data.\n'));
|
|
235
|
+
console.log(' To copy data between environments:');
|
|
236
|
+
console.log(' • Use pg_dump/pg_restore for PostgreSQL');
|
|
237
|
+
console.log(' • Or set up a shared external database service\n');
|
|
232
238
|
}
|
|
233
239
|
console.log(chalk.bold('Branching Strategy:\n'));
|
|
234
240
|
console.log(' develop → Default branch, main development');
|