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

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/detector.js +27 -4
  2. package/package.json +1 -1
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
  }
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.19",
4
4
  "description": "CLI tool for setting up Coolify deployment on Panoptic projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",