@panoptic-it-solutions/coolify-setup 1.1.18 → 1.1.20

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/detector.js CHANGED
@@ -1,8 +1,25 @@
1
- import { existsSync, readFileSync } from 'fs';
1
+ import { existsSync, readFileSync, readdirSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  function exists(filename) {
4
4
  return existsSync(join(process.cwd(), filename));
5
5
  }
6
+ // Check if a db folder is a real project folder (has schema.ts, index.ts, etc.)
7
+ // vs a stale copy we made (only has migrations, migrate.ts, migrate.bundle.js)
8
+ function isRealDbFolder(path) {
9
+ const fullPath = join(process.cwd(), path);
10
+ if (!existsSync(fullPath))
11
+ return false;
12
+ try {
13
+ const contents = readdirSync(fullPath);
14
+ // Our old copies only contain these files
15
+ const ourFiles = ['migrations', 'migrate.ts', 'migrate.bundle.js'];
16
+ // If folder has ANY other files, it's a real db folder
17
+ return contents.some(f => !ourFiles.includes(f));
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
6
23
  function getProjectName() {
7
24
  try {
8
25
  const packageJson = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8'));
@@ -25,17 +42,23 @@ export async function detectProject() {
25
42
  else if (hasYarnLock)
26
43
  packageManager = 'yarn';
27
44
  // Detect where migrations are located (check in order of priority)
28
- // Prefer natural drizzle locations over our old copy destinations (lib/db, src/lib/db)
29
45
  const possibleDbPaths = [
46
+ 'src/lib/db', // Common location for Next.js with src/
47
+ 'lib/db', // Common location for Next.js
30
48
  'src/db', // Common drizzle location with src/
31
49
  'db', // Common drizzle location
32
50
  'drizzle', // Alternative drizzle location
33
- 'src/lib/db', // Our old copy destination (check last)
34
- 'lib/db', // Our old copy destination (check last)
35
51
  ];
52
+ // Paths that could be stale copies from previous script runs
53
+ const potentialStalePaths = ['src/lib/db', 'lib/db'];
36
54
  let dbPath = null;
37
55
  for (const path of possibleDbPaths) {
38
56
  if (exists(`${path}/migrations`)) {
57
+ // For potential stale paths, check if it's a real db folder (has schema.ts, etc.)
58
+ // If it only contains migrations/migrate.ts/migrate.bundle.js, skip it
59
+ if (potentialStalePaths.includes(path) && !isRealDbFolder(path)) {
60
+ continue; // Skip stale copies
61
+ }
39
62
  dbPath = path;
40
63
  break;
41
64
  }
@@ -36,6 +36,9 @@ function generateNextjsDockerfile(options) {
36
36
  // postgres must be externalized due to pnpm's symlink structure causing resolution issues
37
37
  const migrationBundle = includePostgres ? `
38
38
 
39
+ # Create migrations folder if it doesn't exist (may be gitignored)
40
+ RUN mkdir -p ${dbPath}/migrations
41
+
39
42
  # Build the migration bundle (single JS file with all deps baked in)
40
43
  # This avoids module resolution issues in the standalone container
41
44
  # postgres is externalized and copied separately due to pnpm symlink resolution issues
@@ -2,17 +2,26 @@ export function generateEntrypoint(options) {
2
2
  const { projectType, includePostgres, dbPath } = options;
3
3
  // For Next.js standalone, we run the bundled JS file (no tsx needed)
4
4
  // For Node.js, we use tsx since full node_modules is available
5
+ // Check if migrations exist before running (folder may be empty if gitignored)
5
6
  const migrationStep = includePostgres
6
7
  ? projectType === 'nextjs'
7
8
  ? `
8
- # Run database migrations (bundled JS with all deps baked in)
9
- echo " Running database migrations..."
10
- node ${dbPath}/migrate.bundle.js
9
+ # Run database migrations if any exist (bundled JS with all deps baked in)
10
+ if [ -n "$(ls -A ${dbPath}/migrations 2>/dev/null)" ]; then
11
+ echo "⏳ Running database migrations..."
12
+ node ${dbPath}/migrate.bundle.js
13
+ else
14
+ echo "⏭️ No migrations found, skipping..."
15
+ fi
11
16
  `
12
17
  : `
13
- # Run database migrations
14
- echo " Running database migrations..."
15
- npx tsx scripts/migrate.ts
18
+ # Run database migrations if any exist
19
+ if [ -n "$(ls -A scripts/migrations 2>/dev/null)" ]; then
20
+ echo "⏳ Running database migrations..."
21
+ npx tsx scripts/migrate.ts
22
+ else
23
+ echo "⏭️ No migrations found, skipping..."
24
+ fi
16
25
  `
17
26
  : '';
18
27
  const startCmd = projectType === 'nextjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",