@panoptic-it-solutions/coolify-setup 1.1.17 → 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 +30 -6
  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'));
@@ -26,15 +43,22 @@ export async function detectProject() {
26
43
  packageManager = 'yarn';
27
44
  // Detect where migrations are located (check in order of priority)
28
45
  const possibleDbPaths = [
29
- 'src/lib/db', // Already in src/lib/db
30
- 'lib/db', // Already in lib/db
31
- 'src/db', // Common with src/ directory
32
- 'db', // Common without src/
33
- 'drizzle', // Alternative location
46
+ 'src/lib/db', // Common location for Next.js with src/
47
+ 'lib/db', // Common location for Next.js
48
+ 'src/db', // Common drizzle location with src/
49
+ 'db', // Common drizzle location
50
+ 'drizzle', // Alternative drizzle location
34
51
  ];
52
+ // Paths that could be stale copies from previous script runs
53
+ const potentialStalePaths = ['src/lib/db', 'lib/db'];
35
54
  let dbPath = null;
36
55
  for (const path of possibleDbPaths) {
37
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
+ }
38
62
  dbPath = path;
39
63
  break;
40
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panoptic-it-solutions/coolify-setup",
3
- "version": "1.1.17",
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",