@panoptic-it-solutions/coolify-setup 1.1.27 → 1.1.28

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.
Files changed (2) hide show
  1. package/dist/git.js +74 -16
  2. package/package.json +1 -1
package/dist/git.js CHANGED
@@ -45,7 +45,11 @@ export async function commitAndPushToDevelop(files, originalBranch) {
45
45
  run('git init');
46
46
  }
47
47
  // Use passed-in branch name, or detect current branch
48
- const sourceBranch = originalBranch || run('git branch --show-current');
48
+ let sourceBranch = originalBranch || run('git branch --show-current');
49
+ // Handle detached HEAD state
50
+ if (!sourceBranch) {
51
+ sourceBranch = 'develop';
52
+ }
49
53
  // Stage all specified files (use -A to also stage deletions)
50
54
  for (const file of files) {
51
55
  try {
@@ -143,8 +147,27 @@ export async function commitAndPushToDevelop(files, originalBranch) {
143
147
  // Pull might fail, continue
144
148
  }
145
149
  // Merge the source branch (which has the commits)
146
- run(`git merge ${sourceBranch} --no-edit`);
150
+ try {
151
+ run(`git merge ${sourceBranch} --no-edit`);
152
+ }
153
+ catch {
154
+ // Merge conflict - abort and report
155
+ try {
156
+ run('git merge --abort');
157
+ }
158
+ catch {
159
+ // Abort might fail, continue
160
+ }
161
+ throw new Error(`Merge conflict between develop and ${sourceBranch}. Please resolve manually.`);
162
+ }
147
163
  run('git push origin develop');
164
+ // Return to original branch
165
+ try {
166
+ run(`git checkout ${sourceBranch}`);
167
+ }
168
+ catch {
169
+ // Might fail if worktree, that's ok - user is on develop
170
+ }
148
171
  }
149
172
  }
150
173
  else {
@@ -215,27 +238,62 @@ export async function setupGitHub(projectName) {
215
238
  }
216
239
  // Ensure we're on develop branch and push to it
217
240
  try {
218
- const currentBranch = run('git branch --show-current');
241
+ const currentBranch = run('git branch --show-current') || 'develop';
219
242
  if (currentBranch !== 'develop') {
220
- // Check if develop exists locally
243
+ // Try to checkout develop
244
+ let checkoutSucceeded = false;
221
245
  try {
222
- run('git checkout develop');
246
+ // Check if develop exists locally
247
+ try {
248
+ run('git rev-parse --verify develop');
249
+ run('git checkout develop');
250
+ }
251
+ catch {
252
+ // Create develop from current branch
253
+ run('git checkout -b develop');
254
+ }
255
+ checkoutSucceeded = true;
223
256
  }
224
257
  catch {
225
- // Create develop from current branch
226
- run('git checkout -b develop');
258
+ // Checkout failed - might be worktree issue
259
+ // Try to push current branch to develop instead
260
+ try {
261
+ run(`git push origin ${currentBranch}:develop -u`);
262
+ result.developBranchCreated = true;
263
+ result.repoPushed = true;
264
+ // Skip the rest of develop push logic since we already pushed
265
+ checkoutSucceeded = false;
266
+ }
267
+ catch {
268
+ result.warnings.push('Failed to push develop branch (checkout failed, possibly worktree conflict)');
269
+ checkoutSucceeded = false;
270
+ }
271
+ }
272
+ if (checkoutSucceeded) {
273
+ // Pull latest changes before pushing to avoid non-fast-forward errors
274
+ try {
275
+ run('git pull --rebase origin develop');
276
+ }
277
+ catch {
278
+ // Pull might fail if remote doesn't exist yet, that's ok
279
+ }
280
+ run('git push origin develop -u');
281
+ result.developBranchCreated = true;
282
+ result.repoPushed = true;
227
283
  }
228
284
  }
229
- // Pull latest changes before pushing to avoid non-fast-forward errors
230
- try {
231
- run('git pull --rebase origin develop');
232
- }
233
- catch {
234
- // Pull might fail if remote doesn't exist yet, that's ok
285
+ else {
286
+ // Already on develop
287
+ try {
288
+ run('git pull --rebase origin develop');
289
+ }
290
+ catch {
291
+ // Pull might fail if remote doesn't exist yet, that's ok
292
+ }
293
+ run('git push origin develop -u');
294
+ result.developBranchCreated = true;
295
+ result.repoPushed = true;
235
296
  }
236
- run('git push origin develop -u');
237
- result.developBranchCreated = true;
238
- result.repoPushed = true;
239
297
  }
240
298
  catch {
241
299
  result.warnings.push('Failed to push develop branch');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",