@panoptic-it-solutions/coolify-setup 1.1.23 → 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,8 +44,8 @@ export async function commitAndPushToDevelop(files) {
44
44
  if (!isGitRepo()) {
45
45
  run('git init');
46
46
  }
47
- // Save the original branch name before any operations
48
- const originalBranch = run('git branch --show-current');
47
+ // Use passed-in branch name, or detect current branch
48
+ const sourceBranch = originalBranch || run('git branch --show-current');
49
49
  // Stage all specified files (use -A to also stage deletions)
50
50
  for (const file of files) {
51
51
  try {
@@ -77,7 +77,7 @@ export async function commitAndPushToDevelop(files) {
77
77
  }
78
78
  // Ensure develop branch exists and push to it
79
79
  try {
80
- if (originalBranch === 'develop') {
80
+ if (sourceBranch === 'develop') {
81
81
  // Already on develop, pull and push
82
82
  try {
83
83
  run('git pull --rebase origin develop');
@@ -99,13 +99,13 @@ export async function commitAndPushToDevelop(files) {
99
99
  catch {
100
100
  // Pull might fail, continue
101
101
  }
102
- // Merge the original branch (which has the commits)
103
- run(`git merge ${originalBranch} --no-edit`);
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 feature branch
108
- run(`git push origin ${originalBranch}: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.23",
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",