@panoptic-it-solutions/coolify-setup 1.1.30 → 1.1.32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, writeFileSync, readFileSync, unlinkSync, readdirSync, rmSync } from 'fs';
2
2
  import { join, dirname } from 'path';
3
3
  import { execSync } from 'child_process';
4
- import { generateDockerfile, generateDockerCompose, generateDockerComposeBuild, generateWorkflow, generateEntrypoint, generateMigrateScript, generateClaudeRules, } from './templates/index.js';
4
+ import { generateDockerfile, generateDockerCompose, generateDockerComposeBuild, generateWorkflow, generateStagingWorkflow, generateEntrypoint, generateMigrateScript, generateClaudeRules, } from './templates/index.js';
5
5
  function ensureDir(filePath) {
6
6
  const dir = dirname(filePath);
7
7
  if (!existsSync(dir)) {
@@ -157,6 +157,9 @@ export async function generateFiles(options) {
157
157
  projectName,
158
158
  });
159
159
  writeFile('.github/workflows/build-deploy.yml', workflow);
160
+ // Generate staging version workflow
161
+ const stagingWorkflow = generateStagingWorkflow();
162
+ writeFile('.github/workflows/staging-version.yml', stagingWorkflow);
160
163
  // Generate entrypoint.sh
161
164
  const entrypoint = generateEntrypoint({
162
165
  projectType,
package/dist/git.js CHANGED
@@ -237,50 +237,75 @@ export async function setupGitHub(projectName) {
237
237
  }
238
238
  }
239
239
  // Ensure we're on develop branch and push to it
240
+ // Skip if there are uncommitted changes - commitAndPushToDevelop will handle it
241
+ let hasUncommittedChanges = false;
240
242
  try {
241
- const currentBranch = run('git branch --show-current') || 'develop';
242
- if (currentBranch !== 'develop') {
243
- // Try to checkout develop
244
- let checkoutSucceeded = false;
245
- try {
246
- // Check if develop exists locally
243
+ const status = run('git status --porcelain');
244
+ hasUncommittedChanges = status.length > 0;
245
+ }
246
+ catch {
247
+ // If status check fails, proceed anyway
248
+ }
249
+ if (!hasUncommittedChanges) {
250
+ // Only try to push develop if there are no uncommitted changes
251
+ // (commitAndPushToDevelop will handle it after committing)
252
+ try {
253
+ const currentBranch = run('git branch --show-current') || 'develop';
254
+ if (currentBranch !== 'develop') {
255
+ // Try to checkout develop
256
+ let checkoutSucceeded = false;
247
257
  try {
248
- run('git rev-parse --verify develop');
249
- run('git checkout develop');
258
+ // Check if develop exists locally
259
+ try {
260
+ run('git rev-parse --verify develop');
261
+ run('git checkout develop');
262
+ }
263
+ catch {
264
+ // Create develop from current branch
265
+ run('git checkout -b develop');
266
+ }
267
+ checkoutSucceeded = true;
250
268
  }
251
269
  catch {
252
- // Create develop from current branch
253
- run('git checkout -b develop');
270
+ // Checkout failed - might be worktree issue
271
+ // Try to push current branch to develop instead (if fast-forward possible)
272
+ try {
273
+ // First fetch to check if develop exists remotely
274
+ try {
275
+ run('git fetch origin develop');
276
+ // Check if current branch contains all develop commits (fast-forward possible)
277
+ run(`git merge-base --is-ancestor origin/develop ${currentBranch}`);
278
+ }
279
+ catch {
280
+ // Either develop doesn't exist remotely, or can't fast-forward
281
+ // Try push anyway - will fail if develop exists and diverged
282
+ }
283
+ run(`git push origin ${currentBranch}:develop -u`);
284
+ result.developBranchCreated = true;
285
+ result.repoPushed = true;
286
+ // Skip the rest of develop push logic since we already pushed
287
+ checkoutSucceeded = false;
288
+ }
289
+ catch {
290
+ result.warnings.push('Failed to push develop branch (checkout failed, possibly worktree conflict or branches diverged)');
291
+ checkoutSucceeded = false;
292
+ }
254
293
  }
255
- checkoutSucceeded = true;
256
- }
257
- catch {
258
- // Checkout failed - might be worktree issue
259
- // Try to push current branch to develop instead (if fast-forward possible)
260
- try {
261
- // First fetch to check if develop exists remotely
294
+ if (checkoutSucceeded) {
295
+ // Pull latest changes before pushing to avoid non-fast-forward errors
262
296
  try {
263
- run('git fetch origin develop');
264
- // Check if current branch contains all develop commits (fast-forward possible)
265
- run(`git merge-base --is-ancestor origin/develop ${currentBranch}`);
297
+ run('git pull --rebase origin develop');
266
298
  }
267
299
  catch {
268
- // Either develop doesn't exist remotely, or can't fast-forward
269
- // Try push anyway - will fail if develop exists and diverged
300
+ // Pull might fail if remote doesn't exist yet, that's ok
270
301
  }
271
- run(`git push origin ${currentBranch}:develop -u`);
302
+ run('git push origin develop -u');
272
303
  result.developBranchCreated = true;
273
304
  result.repoPushed = true;
274
- // Skip the rest of develop push logic since we already pushed
275
- checkoutSucceeded = false;
276
- }
277
- catch {
278
- result.warnings.push('Failed to push develop branch (checkout failed, possibly worktree conflict or branches diverged)');
279
- checkoutSucceeded = false;
280
305
  }
281
306
  }
282
- if (checkoutSucceeded) {
283
- // Pull latest changes before pushing to avoid non-fast-forward errors
307
+ else {
308
+ // Already on develop
284
309
  try {
285
310
  run('git pull --rebase origin develop');
286
311
  }
@@ -292,22 +317,10 @@ export async function setupGitHub(projectName) {
292
317
  result.repoPushed = true;
293
318
  }
294
319
  }
295
- else {
296
- // Already on develop
297
- try {
298
- run('git pull --rebase origin develop');
299
- }
300
- catch {
301
- // Pull might fail if remote doesn't exist yet, that's ok
302
- }
303
- run('git push origin develop -u');
304
- result.developBranchCreated = true;
305
- result.repoPushed = true;
320
+ catch {
321
+ result.warnings.push('Failed to push develop branch');
306
322
  }
307
323
  }
308
- catch {
309
- result.warnings.push('Failed to push develop branch');
310
- }
311
324
  // Create main branch from develop if it doesn't exist
312
325
  try {
313
326
  // Check if main exists remotely
package/dist/index.js CHANGED
@@ -81,6 +81,7 @@ async function main() {
81
81
  'docker-compose.yml',
82
82
  'docker-compose.build.yml',
83
83
  '.github/workflows/build-deploy.yml',
84
+ '.github/workflows/staging-version.yml',
84
85
  '.claude/rules/coolify.md',
85
86
  'entrypoint.sh',
86
87
  'package.json', // May be modified with esbuild
@@ -111,6 +112,7 @@ async function main() {
111
112
  console.log(chalk.green(' ✓ docker-compose.yml'));
112
113
  console.log(chalk.green(' ✓ docker-compose.build.yml'));
113
114
  console.log(chalk.green(' ✓ .github/workflows/build-deploy.yml'));
115
+ console.log(chalk.green(' ✓ .github/workflows/staging-version.yml'));
114
116
  console.log(chalk.green(' ✓ .claude/rules/coolify.md'));
115
117
  console.log(chalk.green(' ✓ entrypoint.sh'));
116
118
  if (response.includePostgres) {
@@ -2,6 +2,7 @@ export { generateDockerfile, type DockerfileOptions } from './dockerfile.js';
2
2
  export { generateDockerCompose, type DockerComposeOptions } from './docker-compose.js';
3
3
  export { generateDockerComposeBuild, type DockerComposeBuildOptions } from './docker-compose-build.js';
4
4
  export { generateWorkflow, type WorkflowOptions } from './workflow.js';
5
+ export { generateStagingWorkflow } from './staging-workflow.js';
5
6
  export { generateEntrypoint, type EntrypointOptions } from './entrypoint.js';
6
7
  export { generateMigrateScript, type MigrateScriptOptions } from './migrate.js';
7
8
  export { generateClaudeRules } from './claude-rules.js';
@@ -2,6 +2,7 @@ export { generateDockerfile } from './dockerfile.js';
2
2
  export { generateDockerCompose } from './docker-compose.js';
3
3
  export { generateDockerComposeBuild } from './docker-compose-build.js';
4
4
  export { generateWorkflow } from './workflow.js';
5
+ export { generateStagingWorkflow } from './staging-workflow.js';
5
6
  export { generateEntrypoint } from './entrypoint.js';
6
7
  export { generateMigrateScript } from './migrate.js';
7
8
  export { generateClaudeRules } from './claude-rules.js';
@@ -0,0 +1 @@
1
+ export declare function generateStagingWorkflow(): string;
@@ -0,0 +1,176 @@
1
+ export function generateStagingWorkflow() {
2
+ return `name: Staging Version
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - staging
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ version:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ token: \${{ secrets.GITHUB_TOKEN }}
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '22'
26
+
27
+ - name: Configure Git
28
+ run: |
29
+ git config user.name "github-actions[bot]"
30
+ git config user.email "github-actions[bot]@users.noreply.github.com"
31
+
32
+ - name: Get last staging tag
33
+ id: last_tag
34
+ run: |
35
+ LAST_TAG=\$(git tag -l "staging-v*" --sort=-v:refname | head -n1)
36
+ if [ -z "\$LAST_TAG" ]; then
37
+ LAST_TAG=\$(git rev-list --max-parents=0 HEAD)
38
+ fi
39
+ echo "tag=\$LAST_TAG" >> \$GITHUB_OUTPUT
40
+
41
+ - name: Determine version bump from commits
42
+ id: bump
43
+ run: |
44
+ COMMITS=\$(git log \${{ steps.last_tag.outputs.tag }}..HEAD --pretty=format:"%s" 2>/dev/null || git log --pretty=format:"%s")
45
+
46
+ BUMP="patch"
47
+
48
+ if echo "\$COMMITS" | grep -qiE "^feat(\\(.+\\))?!:|BREAKING CHANGE:"; then
49
+ BUMP="major"
50
+ elif echo "\$COMMITS" | grep -qiE "^feat(\\(.+\\))?:"; then
51
+ BUMP="minor"
52
+ fi
53
+
54
+ echo "type=\$BUMP" >> \$GITHUB_OUTPUT
55
+
56
+ - name: Bump version
57
+ id: version
58
+ run: |
59
+ CURRENT=\$(node -p "require('./package.json').version")
60
+ LAST_TAG="\${{ steps.last_tag.outputs.tag }}"
61
+
62
+ # Check if HEAD is the same as the last tag (rerun scenario with no new commits)
63
+ LAST_TAG_SHA=\$(git rev-parse "\$LAST_TAG" 2>/dev/null || echo "")
64
+ HEAD_SHA=\$(git rev-parse HEAD)
65
+
66
+ if [ "\$LAST_TAG_SHA" = "\$HEAD_SHA" ]; then
67
+ echo "HEAD is at \$LAST_TAG, no new commits to version"
68
+ echo "version=\$CURRENT" >> \$GITHUB_OUTPUT
69
+ echo "skip_commit=true" >> \$GITHUB_OUTPUT
70
+ exit 0
71
+ fi
72
+
73
+ # Check if there are any commits since last tag (excluding version bump commits)
74
+ NEW_COMMITS=\$(git log "\$LAST_TAG"..HEAD --pretty=format:"%s" --invert-grep --grep="^chore(release):" 2>/dev/null | head -1)
75
+ if [ -z "\$NEW_COMMITS" ]; then
76
+ echo "No new commits since \$LAST_TAG (only release commits)"
77
+ echo "version=\$CURRENT" >> \$GITHUB_OUTPUT
78
+ echo "skip_commit=true" >> \$GITHUB_OUTPUT
79
+ exit 0
80
+ fi
81
+
82
+ IFS='.' read -r MAJOR MINOR PATCH <<< "\$CURRENT"
83
+
84
+ case "\${{ steps.bump.outputs.type }}" in
85
+ major)
86
+ MAJOR=\$((MAJOR + 1))
87
+ MINOR=0
88
+ PATCH=0
89
+ ;;
90
+ minor)
91
+ MINOR=\$((MINOR + 1))
92
+ PATCH=0
93
+ ;;
94
+ patch)
95
+ PATCH=\$((PATCH + 1))
96
+ ;;
97
+ esac
98
+
99
+ NEW_VERSION="\${MAJOR}.\${MINOR}.\${PATCH}"
100
+ npm version \$NEW_VERSION --no-git-tag-version
101
+
102
+ echo "version=\$NEW_VERSION" >> \$GITHUB_OUTPUT
103
+ echo "skip_commit=false" >> \$GITHUB_OUTPUT
104
+
105
+ - name: Generate changelog
106
+ id: changelog
107
+ if: steps.version.outputs.skip_commit != 'true'
108
+ run: |
109
+ LAST_TAG="\${{ steps.last_tag.outputs.tag }}"
110
+
111
+ {
112
+ echo "changelog<<EOF"
113
+ echo "## Changes in v\${{ steps.version.outputs.version }}"
114
+ echo ""
115
+
116
+ # Features
117
+ FEATURES=\$(git log \$LAST_TAG..HEAD --pretty=format:"- %s" --grep="^feat" 2>/dev/null || true)
118
+ if [ -n "\$FEATURES" ]; then
119
+ echo "### Features"
120
+ echo "\$FEATURES"
121
+ echo ""
122
+ fi
123
+
124
+ # Fixes
125
+ FIXES=\$(git log \$LAST_TAG..HEAD --pretty=format:"- %s" --grep="^fix" 2>/dev/null || true)
126
+ if [ -n "\$FIXES" ]; then
127
+ echo "### Bug Fixes"
128
+ echo "\$FIXES"
129
+ echo ""
130
+ fi
131
+
132
+ # Other changes
133
+ OTHERS=\$(git log \$LAST_TAG..HEAD --pretty=format:"- %s" --invert-grep --grep="^feat" --grep="^fix" 2>/dev/null | head -20 || true)
134
+ if [ -n "\$OTHERS" ]; then
135
+ echo "### Other Changes"
136
+ echo "\$OTHERS"
137
+ echo ""
138
+ fi
139
+
140
+ echo "EOF"
141
+ } >> \$GITHUB_OUTPUT
142
+
143
+ - name: Commit version bump
144
+ if: steps.version.outputs.skip_commit != 'true'
145
+ run: |
146
+ git add package.json
147
+ git commit -m "chore(release): v\${{ steps.version.outputs.version }}"
148
+
149
+ - name: Create and push tag
150
+ if: steps.version.outputs.skip_commit != 'true'
151
+ run: |
152
+ TAG_NAME="staging-v\${{ steps.version.outputs.version }}"
153
+ # Check if tag already exists
154
+ if git rev-parse "\$TAG_NAME" >/dev/null 2>&1; then
155
+ EXISTING_SHA=\$(git rev-parse "\$TAG_NAME")
156
+ CURRENT_SHA=\$(git rev-parse HEAD)
157
+ if [ "\$EXISTING_SHA" = "\$CURRENT_SHA" ]; then
158
+ echo "Tag \$TAG_NAME already exists at current commit, skipping"
159
+ else
160
+ echo "Error: Tag \$TAG_NAME exists at different commit"
161
+ exit 1
162
+ fi
163
+ else
164
+ git tag "\$TAG_NAME"
165
+ fi
166
+ git push origin staging --tags
167
+
168
+ - name: Output version info
169
+ run: |
170
+ echo "## Version Summary" >> \$GITHUB_STEP_SUMMARY
171
+ echo "" >> \$GITHUB_STEP_SUMMARY
172
+ echo "**Version:** v\${{ steps.version.outputs.version }}" >> \$GITHUB_STEP_SUMMARY
173
+ echo "**Bump Type:** \${{ steps.bump.outputs.type }}" >> \$GITHUB_STEP_SUMMARY
174
+ echo "**Skipped:** \${{ steps.version.outputs.skip_commit }}" >> \$GITHUB_STEP_SUMMARY
175
+ `;
176
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",