@panoptic-it-solutions/coolify-setup 1.1.23 ā 1.1.25
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 +1 -1
- package/dist/git.js +33 -11
- package/dist/index.js +17 -3
- package/package.json +1 -1
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
|
-
//
|
|
48
|
-
const
|
|
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 (
|
|
80
|
+
if (sourceBranch === 'develop') {
|
|
81
81
|
// Already on develop, pull and push
|
|
82
82
|
try {
|
|
83
83
|
run('git pull --rebase origin develop');
|
|
@@ -89,23 +89,38 @@ export async function commitAndPushToDevelop(files) {
|
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
91
|
// On a feature branch - need to merge into develop
|
|
92
|
+
// First check if develop exists remotely
|
|
93
|
+
let developExistsRemotely = false;
|
|
92
94
|
try {
|
|
93
95
|
run('git fetch origin develop');
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
developExistsRemotely = true;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Develop doesn't exist remotely
|
|
100
|
+
}
|
|
101
|
+
if (developExistsRemotely) {
|
|
102
|
+
// Checkout develop (create local tracking branch if needed)
|
|
103
|
+
try {
|
|
104
|
+
run('git checkout develop');
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Local develop doesn't exist, create from remote
|
|
108
|
+
run('git checkout -b develop origin/develop');
|
|
109
|
+
}
|
|
110
|
+
// Pull latest changes
|
|
96
111
|
try {
|
|
97
112
|
run('git pull --rebase origin develop');
|
|
98
113
|
}
|
|
99
114
|
catch {
|
|
100
115
|
// Pull might fail, continue
|
|
101
116
|
}
|
|
102
|
-
// Merge the
|
|
103
|
-
run(`git merge ${
|
|
117
|
+
// Merge the source branch (which has the commits)
|
|
118
|
+
run(`git merge ${sourceBranch} --no-edit`);
|
|
104
119
|
run('git push origin develop');
|
|
105
120
|
}
|
|
106
|
-
|
|
107
|
-
// Develop doesn't exist remotely, create it from
|
|
108
|
-
run(`git push origin ${
|
|
121
|
+
else {
|
|
122
|
+
// Develop doesn't exist remotely, create it from source branch
|
|
123
|
+
run(`git push origin ${sourceBranch}:develop`);
|
|
109
124
|
}
|
|
110
125
|
}
|
|
111
126
|
result.pushed = true;
|
|
@@ -182,6 +197,13 @@ export async function setupGitHub(projectName) {
|
|
|
182
197
|
run('git checkout -b develop');
|
|
183
198
|
}
|
|
184
199
|
}
|
|
200
|
+
// Pull latest changes before pushing to avoid non-fast-forward errors
|
|
201
|
+
try {
|
|
202
|
+
run('git pull --rebase origin develop');
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// Pull might fail if remote doesn't exist yet, that's ok
|
|
206
|
+
}
|
|
185
207
|
run('git push origin develop -u');
|
|
186
208
|
result.developBranchCreated = true;
|
|
187
209
|
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
|
|
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
|
-
|
|
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
|
}
|