@panoptic-it-solutions/coolify-setup 1.1.9 → 1.1.11

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.
Files changed (2) hide show
  1. package/dist/generator.js +55 -34
  2. package/package.json +1 -1
package/dist/generator.js CHANGED
@@ -48,43 +48,64 @@ function addEsbuildToPackageJson(packageManager) {
48
48
  }
49
49
  }
50
50
  function moveMigrationsToLibDb() {
51
- const result = { movedMigrations: false, movedMigrateTs: false };
51
+ const result = {
52
+ migrations: false,
53
+ helpers: false,
54
+ migrateTs: false,
55
+ queriesTs: false,
56
+ schemaTs: false,
57
+ };
52
58
  const cwd = process.cwd();
53
- // Check if db/migrations exists at root level (sibling to lib)
54
- const dbMigrationsPath = join(cwd, 'db/migrations');
55
- const libDbMigrationsPath = join(cwd, 'lib/db/migrations');
56
- if (existsSync(dbMigrationsPath) && !existsSync(libDbMigrationsPath)) {
57
- // Ensure lib/db directory exists
58
- ensureDir(join(libDbMigrationsPath, 'dummy'));
59
- // Move the entire migrations folder
60
- renameSync(dbMigrationsPath, libDbMigrationsPath);
61
- result.movedMigrations = true;
62
- console.log('Moved db/migrations → lib/db/migrations');
63
- }
64
- // Check if db/migrate.ts exists at root level
65
- const dbMigrateTsPath = join(cwd, 'db/migrate.ts');
66
- const libDbMigrateTsPath = join(cwd, 'lib/db/migrate.ts');
67
- if (existsSync(dbMigrateTsPath) && !existsSync(libDbMigrateTsPath)) {
68
- // Ensure lib/db directory exists
69
- ensureDir(libDbMigrateTsPath);
70
- // Move migrate.ts
71
- renameSync(dbMigrateTsPath, libDbMigrateTsPath);
72
- result.movedMigrateTs = true;
73
- console.log('Moved db/migrate.ts lib/db/migrate.ts');
74
- }
75
- // Clean up empty db directory if it exists and is empty
76
- const dbPath = join(cwd, 'db');
77
- if (existsSync(dbPath)) {
78
- try {
79
- const contents = readdirSync(dbPath);
80
- if (contents.length === 0) {
81
- // Remove empty directory
82
- execSync(`rmdir "${dbPath}"`, { stdio: 'pipe' });
83
- console.log('Removed empty db/ directory');
59
+ // Items to move to lib/db/
60
+ const itemsToMove = [
61
+ { name: 'migrations', resultKey: 'migrations', isDir: true },
62
+ { name: 'helpers', resultKey: 'helpers', isDir: true },
63
+ { name: 'migrate.ts', resultKey: 'migrateTs', isDir: false },
64
+ { name: 'queries.ts', resultKey: 'queriesTs', isDir: false },
65
+ { name: 'schema.ts', resultKey: 'schemaTs', isDir: false },
66
+ ];
67
+ // Source directories to check (in order of priority)
68
+ 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
84
91
  }
85
92
  }
86
- catch {
87
- // Ignore errors when cleaning up
93
+ }
94
+ // Clean up empty db directories
95
+ for (const sourceRoot of sourceRoots) {
96
+ const dbPath = join(cwd, sourceRoot);
97
+ if (existsSync(dbPath)) {
98
+ try {
99
+ const contents = readdirSync(dbPath);
100
+ if (contents.length === 0) {
101
+ // Remove empty directory
102
+ execSync(`rmdir "${dbPath}"`, { stdio: 'pipe' });
103
+ console.log(`Removed empty ${sourceRoot}/ directory`);
104
+ }
105
+ }
106
+ catch {
107
+ // Ignore errors when cleaning up
108
+ }
88
109
  }
89
110
  }
90
111
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",