@panoptic-it-solutions/coolify-setup 1.1.1 → 1.1.3

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
@@ -8,4 +8,11 @@ export interface GitHubSetupResult {
8
8
  existingRemote: string | null;
9
9
  warnings: string[];
10
10
  }
11
+ export interface CommitAndPushResult {
12
+ committed: boolean;
13
+ pushed: boolean;
14
+ branchName: string;
15
+ warnings: string[];
16
+ }
17
+ export declare function commitAndPushToDevelop(files: string[]): Promise<CommitAndPushResult>;
11
18
  export declare function setupGitHub(projectName: string): Promise<GitHubSetupResult>;
package/dist/git.js CHANGED
@@ -33,6 +33,81 @@ function isCorrectRemote(remoteUrl, projectName) {
33
33
  ];
34
34
  return expectedPatterns.some(pattern => remoteUrl.includes(pattern));
35
35
  }
36
+ export async function commitAndPushToDevelop(files) {
37
+ const result = {
38
+ committed: false,
39
+ pushed: false,
40
+ branchName: 'develop',
41
+ warnings: [],
42
+ };
43
+ // Initialize git if not already a repo
44
+ if (!isGitRepo()) {
45
+ run('git init');
46
+ }
47
+ // Stage all specified files
48
+ for (const file of files) {
49
+ try {
50
+ run(`git add "${file}"`);
51
+ }
52
+ catch {
53
+ // File might not exist, that's ok
54
+ }
55
+ }
56
+ // Check if there are staged changes
57
+ try {
58
+ const status = run('git diff --cached --name-only');
59
+ if (!status) {
60
+ result.warnings.push('No changes to commit');
61
+ return result;
62
+ }
63
+ }
64
+ 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;
76
+ }
77
+ // Check if remote exists
78
+ const remoteUrl = getGitRemoteUrl();
79
+ if (!remoteUrl) {
80
+ result.warnings.push('No remote configured - files committed locally but not pushed');
81
+ return result;
82
+ }
83
+ // Ensure develop branch exists and push to it
84
+ try {
85
+ const currentBranch = run('git branch --show-current');
86
+ if (currentBranch === 'develop') {
87
+ // Already on develop, just push
88
+ run('git push origin develop');
89
+ }
90
+ else {
91
+ // Check if develop exists remotely
92
+ try {
93
+ run('git fetch origin develop');
94
+ // Develop exists, checkout and merge/rebase current changes
95
+ run('git checkout develop');
96
+ run(`git merge ${currentBranch} --no-edit`);
97
+ run('git push origin develop');
98
+ }
99
+ catch {
100
+ // Develop doesn't exist remotely, create it from current branch
101
+ run('git push origin HEAD:develop');
102
+ }
103
+ }
104
+ result.pushed = true;
105
+ }
106
+ catch (error) {
107
+ result.warnings.push(`Failed to push to develop: ${error}`);
108
+ }
109
+ return result;
110
+ }
36
111
  export async function setupGitHub(projectName) {
37
112
  const result = {
38
113
  repoCreated: false,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import ora from 'ora';
4
4
  import prompts from 'prompts';
5
5
  import { detectProject } from './detector.js';
6
6
  import { generateFiles } from './generator.js';
7
- import { setupGitHub } from './git.js';
7
+ import { setupGitHub, commitAndPushToDevelop } from './git.js';
8
8
  async function main() {
9
9
  console.log(chalk.bold.cyan('\nšŸš€ Panoptic Coolify Setup\n'));
10
10
  // Detect project type
@@ -65,6 +65,36 @@ async function main() {
65
65
  includeRedis: response.includeRedis,
66
66
  includeMinio: response.includeMinio,
67
67
  });
68
+ // Track generated files for commit
69
+ const generatedFiles = [
70
+ 'Dockerfile',
71
+ 'docker-compose.yml',
72
+ 'docker-compose.build.yml',
73
+ '.github/workflows/build-deploy.yml',
74
+ '.claude/rules/coolify.md',
75
+ 'entrypoint.sh',
76
+ 'package.json', // May be modified with esbuild
77
+ ];
78
+ // Add lockfile based on package manager
79
+ if (project.packageManager === 'pnpm') {
80
+ generatedFiles.push('pnpm-lock.yaml');
81
+ }
82
+ else if (project.packageManager === 'yarn') {
83
+ generatedFiles.push('yarn.lock');
84
+ }
85
+ else {
86
+ generatedFiles.push('package-lock.json');
87
+ }
88
+ // Add migrate script if postgres included
89
+ if (response.includePostgres) {
90
+ if (project.type === 'nextjs') {
91
+ generatedFiles.push('lib/db/migrate.ts');
92
+ generatedFiles.push('tsconfig.json'); // May be modified with exclude
93
+ }
94
+ else {
95
+ generatedFiles.push('scripts/migrate.ts');
96
+ }
97
+ }
68
98
  console.log(chalk.green(' āœ“ Dockerfile'));
69
99
  console.log(chalk.green(' āœ“ docker-compose.yml'));
70
100
  console.log(chalk.green(' āœ“ docker-compose.build.yml'));
@@ -72,7 +102,30 @@ async function main() {
72
102
  console.log(chalk.green(' āœ“ .claude/rules/coolify.md'));
73
103
  console.log(chalk.green(' āœ“ entrypoint.sh'));
74
104
  if (response.includePostgres) {
75
- console.log(chalk.green(' āœ“ scripts/migrate.ts'));
105
+ if (project.type === 'nextjs') {
106
+ console.log(chalk.green(' āœ“ lib/db/migrate.ts'));
107
+ }
108
+ else {
109
+ console.log(chalk.green(' āœ“ scripts/migrate.ts'));
110
+ }
111
+ }
112
+ // Commit and push to develop
113
+ console.log(chalk.bold('\nCommitting and pushing to develop...'));
114
+ try {
115
+ const commitResult = await commitAndPushToDevelop(generatedFiles);
116
+ if (commitResult.committed) {
117
+ console.log(chalk.green(' āœ“ Committed changes'));
118
+ }
119
+ if (commitResult.pushed) {
120
+ console.log(chalk.green(' āœ“ Pushed to develop branch'));
121
+ }
122
+ for (const warning of commitResult.warnings) {
123
+ console.log(chalk.yellow(` ⚠ ${warning}`));
124
+ }
125
+ }
126
+ catch (error) {
127
+ console.log(chalk.yellow(` ⚠ Failed to commit/push: ${error}`));
128
+ console.log(chalk.yellow(' You may need to manually commit and push the generated files'));
76
129
  }
77
130
  // Setup GitHub
78
131
  if (response.createRepo) {
@@ -120,8 +173,7 @@ async function main() {
120
173
  console.log('Next steps:');
121
174
  console.log(chalk.cyan(' 1. Review the generated files'));
122
175
  console.log(chalk.cyan(' 2. Update .env with your secrets'));
123
- console.log(chalk.cyan(' 3. Push to develop to trigger first build'));
124
- console.log(chalk.cyan(' 4. Configure Coolify to deploy from staging branch\n'));
176
+ console.log(chalk.cyan(' 3. Configure Coolify to deploy from staging branch\n'));
125
177
  }
126
178
  main().catch((error) => {
127
179
  console.error(chalk.red('Error:'), error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",