@panoptic-it-solutions/coolify-setup 1.1.22 → 1.1.24

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/git.d.ts CHANGED
@@ -14,5 +14,5 @@ export interface CommitAndPushResult {
14
14
  branchName: string;
15
15
  warnings: string[];
16
16
  }
17
- export declare function commitAndPushToDevelop(files: string[]): Promise<CommitAndPushResult>;
17
+ export declare function commitAndPushToDevelop(files: string[], originalBranch?: string): Promise<CommitAndPushResult>;
18
18
  export declare function setupGitHub(projectName: string): Promise<GitHubSetupResult>;
package/dist/git.js CHANGED
@@ -33,7 +33,7 @@ function isCorrectRemote(remoteUrl, projectName) {
33
33
  ];
34
34
  return expectedPatterns.some(pattern => remoteUrl.includes(pattern));
35
35
  }
36
- export async function commitAndPushToDevelop(files) {
36
+ export async function commitAndPushToDevelop(files, originalBranch) {
37
37
  const result = {
38
38
  committed: false,
39
39
  pushed: false,
@@ -44,6 +44,8 @@ export async function commitAndPushToDevelop(files) {
44
44
  if (!isGitRepo()) {
45
45
  run('git init');
46
46
  }
47
+ // Use passed-in branch name, or detect current branch
48
+ const sourceBranch = originalBranch || run('git branch --show-current');
47
49
  // Stage all specified files (use -A to also stage deletions)
48
50
  for (const file of files) {
49
51
  try {
@@ -53,26 +55,19 @@ export async function commitAndPushToDevelop(files) {
53
55
  // File might not exist, that's ok
54
56
  }
55
57
  }
56
- // Check if there are staged changes
58
+ // Check if there are staged changes and commit if so
59
+ let hasNewCommit = false;
57
60
  try {
58
61
  const status = run('git diff --cached --name-only');
59
- if (!status) {
60
- result.warnings.push('No changes to commit');
61
- return result;
62
+ if (status) {
63
+ // Commit the changes
64
+ run('git commit -m "chore: add Coolify deployment configuration"');
65
+ result.committed = true;
66
+ hasNewCommit = true;
62
67
  }
63
68
  }
64
69
  catch {
65
- result.warnings.push('Failed to check git status');
66
- return result;
67
- }
68
- // Commit the changes
69
- try {
70
- run('git commit -m "chore: add Coolify deployment configuration"');
71
- result.committed = true;
72
- }
73
- catch (error) {
74
- result.warnings.push(`Failed to commit: ${error}`);
75
- return result;
70
+ // Commit might fail if nothing staged, that's ok
76
71
  }
77
72
  // Check if remote exists
78
73
  const remoteUrl = getGitRemoteUrl();
@@ -82,9 +77,8 @@ export async function commitAndPushToDevelop(files) {
82
77
  }
83
78
  // Ensure develop branch exists and push to it
84
79
  try {
85
- const currentBranch = run('git branch --show-current');
86
- if (currentBranch === 'develop') {
87
- // Pull latest changes with rebase, then push
80
+ if (sourceBranch === 'develop') {
81
+ // Already on develop, pull and push
88
82
  try {
89
83
  run('git pull --rebase origin develop');
90
84
  }
@@ -94,18 +88,24 @@ export async function commitAndPushToDevelop(files) {
94
88
  run('git push origin develop');
95
89
  }
96
90
  else {
97
- // Check if develop exists remotely
91
+ // On a feature branch - need to merge into develop
98
92
  try {
99
93
  run('git fetch origin develop');
100
- // Develop exists, checkout and merge/rebase current changes
94
+ // Develop exists remotely, checkout and merge feature branch
101
95
  run('git checkout develop');
102
- run('git pull --rebase origin develop');
103
- run(`git merge ${currentBranch} --no-edit`);
96
+ try {
97
+ run('git pull --rebase origin develop');
98
+ }
99
+ catch {
100
+ // Pull might fail, continue
101
+ }
102
+ // Merge the source branch (which has the commits)
103
+ run(`git merge ${sourceBranch} --no-edit`);
104
104
  run('git push origin develop');
105
105
  }
106
106
  catch {
107
- // Develop doesn't exist remotely, create it from current branch
108
- run('git push origin HEAD:develop');
107
+ // Develop doesn't exist remotely, create it from source branch
108
+ run(`git push origin ${sourceBranch}:develop`);
109
109
  }
110
110
  }
111
111
  result.pushed = true;
@@ -182,6 +182,13 @@ export async function setupGitHub(projectName) {
182
182
  run('git checkout -b develop');
183
183
  }
184
184
  }
185
+ // Pull latest changes before pushing to avoid non-fast-forward errors
186
+ try {
187
+ run('git pull --rebase origin develop');
188
+ }
189
+ catch {
190
+ // Pull might fail if remote doesn't exist yet, that's ok
191
+ }
185
192
  run('git push origin develop -u');
186
193
  result.developBranchCreated = true;
187
194
  result.repoPushed = true;
package/dist/index.js CHANGED
@@ -2,9 +2,18 @@
2
2
  import chalk from 'chalk';
3
3
  import ora from 'ora';
4
4
  import prompts from 'prompts';
5
+ import { execSync } from 'child_process';
5
6
  import { detectProject } from './detector.js';
6
7
  import { generateFiles } from './generator.js';
7
8
  import { setupGitHub, commitAndPushToDevelop } from './git.js';
9
+ function getCurrentBranch() {
10
+ try {
11
+ return execSync('git branch --show-current', { encoding: 'utf-8', stdio: 'pipe' }).trim();
12
+ }
13
+ catch {
14
+ return 'develop';
15
+ }
16
+ }
8
17
  async function main() {
9
18
  console.log(chalk.bold.cyan('\nšŸš€ Panoptic Coolify Setup\n'));
10
19
  // Detect project type
@@ -113,6 +122,8 @@ async function main() {
113
122
  console.log(chalk.green(' āœ“ scripts/migrate.ts'));
114
123
  }
115
124
  }
125
+ // Save original branch before any git operations (setupGitHub may switch branches)
126
+ const originalBranch = getCurrentBranch();
116
127
  // Setup GitHub first (creates repo/remote if needed)
117
128
  if (response.createRepo) {
118
129
  console.log(chalk.bold('\nSetting up GitHub...'));
@@ -141,10 +152,13 @@ async function main() {
141
152
  for (const warning of result.warnings) {
142
153
  console.log(chalk.yellow(` ⚠ ${warning}`));
143
154
  }
144
- // If nothing succeeded, show a failure message
155
+ // If nothing succeeded, show appropriate failure message
145
156
  if (!result.repoCreated && !result.repoPushed && result.warnings.length > 0) {
146
157
  console.log(chalk.red('\n āœ— GitHub setup did not complete successfully'));
147
- console.log(chalk.yellow(' You can manually run: gh repo create Panoptic-IT-Solutions/' + response.projectName));
158
+ // Only suggest repo create if there's no existing remote
159
+ if (!result.existingRemote) {
160
+ console.log(chalk.yellow(' You can manually run: gh repo create Panoptic-IT-Solutions/' + response.projectName));
161
+ }
148
162
  }
149
163
  }
150
164
  catch (error) {
@@ -155,7 +169,7 @@ async function main() {
155
169
  // Commit and push generated files to develop
156
170
  console.log(chalk.bold('\nCommitting and pushing to develop...'));
157
171
  try {
158
- const commitResult = await commitAndPushToDevelop(generatedFiles);
172
+ const commitResult = await commitAndPushToDevelop(generatedFiles, originalBranch);
159
173
  if (commitResult.committed) {
160
174
  console.log(chalk.green(' āœ“ Committed changes'));
161
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",