@panoptic-it-solutions/coolify-setup 1.1.12 → 1.1.14
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 +21 -59
- package/dist/index.js +1 -4
- package/package.json +1 -1
package/dist/generator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import { generateDockerfile, generateDockerCompose, generateDockerComposeBuild, generateWorkflow, generateEntrypoint, generateMigrateScript, generateClaudeRules, } from './templates/index.js';
|
|
@@ -47,68 +47,30 @@ function addEsbuildToPackageJson(packageManager) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const result = {
|
|
52
|
-
migrations: false,
|
|
53
|
-
helpers: false,
|
|
54
|
-
migrateTs: false,
|
|
55
|
-
queriesTs: false,
|
|
56
|
-
schemaTs: false,
|
|
57
|
-
};
|
|
50
|
+
function copyMigrationsToLibDb() {
|
|
58
51
|
const cwd = process.cwd();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
{ name: 'queries.ts', resultKey: 'queriesTs', isDir: false },
|
|
65
|
-
{ name: 'schema.ts', resultKey: 'schemaTs', isDir: false },
|
|
66
|
-
];
|
|
52
|
+
const destPath = join(cwd, 'lib/db/migrations');
|
|
53
|
+
// Skip if destination already exists
|
|
54
|
+
if (existsSync(destPath)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
67
57
|
// Source directories to check (in order of priority)
|
|
68
58
|
const sourceRoots = ['db', 'src/db'];
|
|
69
|
-
for (const item of itemsToMove) {
|
|
70
|
-
const destPath = join(cwd, 'lib/db', item.name);
|
|
71
|
-
// Skip if destination already exists
|
|
72
|
-
if (existsSync(destPath)) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
// Try each source root
|
|
76
|
-
for (const sourceRoot of sourceRoots) {
|
|
77
|
-
const sourcePath = join(cwd, sourceRoot, item.name);
|
|
78
|
-
if (existsSync(sourcePath)) {
|
|
79
|
-
// Ensure lib/db directory exists
|
|
80
|
-
if (item.isDir) {
|
|
81
|
-
ensureDir(join(destPath, 'dummy'));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
ensureDir(destPath);
|
|
85
|
-
}
|
|
86
|
-
// Move the item
|
|
87
|
-
renameSync(sourcePath, destPath);
|
|
88
|
-
result[item.resultKey] = true;
|
|
89
|
-
console.log(`Moved ${sourceRoot}/${item.name} → lib/db/${item.name}`);
|
|
90
|
-
break; // Found and moved, no need to check other source roots
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Clean up empty db directories
|
|
95
59
|
for (const sourceRoot of sourceRoots) {
|
|
96
|
-
const
|
|
97
|
-
if (existsSync(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
// Ignore errors when cleaning up
|
|
108
|
-
}
|
|
60
|
+
const sourcePath = join(cwd, sourceRoot, 'migrations');
|
|
61
|
+
if (existsSync(sourcePath)) {
|
|
62
|
+
// Ensure lib/db directory exists
|
|
63
|
+
ensureDir(join(destPath, 'dummy'));
|
|
64
|
+
// Copy (not move) to preserve source imports
|
|
65
|
+
execSync(`cp -r "${sourcePath}/." "${destPath}"`, { stdio: 'pipe' });
|
|
66
|
+
console.log(`Copied ${sourceRoot}/migrations → lib/db/migrations`);
|
|
67
|
+
return true;
|
|
109
68
|
}
|
|
110
69
|
}
|
|
111
|
-
|
|
70
|
+
// No migrations found - create empty folder so Docker build doesn't fail
|
|
71
|
+
ensureDir(join(destPath, 'dummy'));
|
|
72
|
+
console.log('Created empty lib/db/migrations (no source migrations found)');
|
|
73
|
+
return true;
|
|
112
74
|
}
|
|
113
75
|
function excludeMigrateFromTsConfig(migratePath) {
|
|
114
76
|
const tsconfigPath = join(process.cwd(), 'tsconfig.json');
|
|
@@ -180,8 +142,8 @@ export async function generateFiles(options) {
|
|
|
180
142
|
if (added) {
|
|
181
143
|
console.log('Added esbuild to devDependencies (required for migration bundling)');
|
|
182
144
|
}
|
|
183
|
-
//
|
|
184
|
-
|
|
145
|
+
// Copy migrations to lib/db/ for Docker build (don't move - preserve source imports)
|
|
146
|
+
copyMigrationsToLibDb();
|
|
185
147
|
// Write migrate.ts to lib/db/ for Next.js projects (will be bundled at build time)
|
|
186
148
|
const migratePath = 'lib/db/migrate.ts';
|
|
187
149
|
const existingMigratePath = join(process.cwd(), migratePath);
|
package/dist/index.js
CHANGED
|
@@ -89,11 +89,8 @@ async function main() {
|
|
|
89
89
|
if (response.includePostgres) {
|
|
90
90
|
if (project.type === 'nextjs') {
|
|
91
91
|
generatedFiles.push('lib/db/migrate.ts');
|
|
92
|
-
generatedFiles.push('lib/db/'); // Include
|
|
92
|
+
generatedFiles.push('lib/db/migrations/'); // Include copied migrations folder
|
|
93
93
|
generatedFiles.push('tsconfig.json'); // May be modified with exclude
|
|
94
|
-
// Stage deletions of source db folder if files were moved
|
|
95
|
-
generatedFiles.push('db/');
|
|
96
|
-
generatedFiles.push('src/db/');
|
|
97
94
|
}
|
|
98
95
|
else {
|
|
99
96
|
generatedFiles.push('scripts/migrate.ts');
|