|
1 | 1 | import path from 'path'; |
2 | | -import { fileURLToPath } from 'url'; |
3 | 2 |
|
4 | | -const currentDir = path.dirname(fileURLToPath(import.meta.url)); |
| 3 | +const argvDir = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : ''; |
| 4 | +const cwd = process.cwd(); |
| 5 | +const baseDirCandidates = [argvDir, cwd].filter(Boolean); |
5 | 6 |
|
6 | | -export const webappPath = path.resolve(currentDir, '../../../../build/webapp'); |
7 | | -export const indexHtml = path.resolve(webappPath, './index.html'); |
| 7 | +let baseDir = cwd; |
| 8 | +for (const candidate of baseDirCandidates) { |
| 9 | + const normalized = path.normalize(candidate); |
| 10 | + if (normalized.endsWith(path.join('build', 'server'))) { |
| 11 | + baseDir = path.resolve(candidate, '..', '..'); |
| 12 | + break; |
| 13 | + } |
| 14 | + if (normalized.endsWith(path.join('packages', 'server'))) { |
| 15 | + baseDir = path.resolve(candidate, '..', '..'); |
| 16 | + break; |
| 17 | + } |
| 18 | +} |
8 | 19 |
|
9 | | -export const diagramStoragePath = path.resolve(currentDir, '../../../../diagrams'); |
| 20 | +const rootDir = process.env.APOLLON_BASE_DIR ? path.resolve(process.env.APOLLON_BASE_DIR) : baseDir; |
| 21 | + |
| 22 | +export const webappPath = path.resolve(rootDir, 'build/webapp'); |
| 23 | +export const indexHtml = path.resolve(webappPath, 'index.html'); |
| 24 | + |
| 25 | +export const diagramStoragePath = path.resolve(rootDir, 'diagrams'); |
10 | 26 |
|
11 | 27 | export const tokenLength = 20; |
0 commit comments