@studiocms/migrator 0.0.0-beta.0 → 0.1.0
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/LICENSE +21 -0
- package/README.md +63 -0
- package/package.json +55 -7
- package/public/favicon.svg +5 -0
- package/src/components/ErrorCard.astro +20 -0
- package/src/components/MigrationMeta.astro +74 -0
- package/src/components/MigrationStatus.astro +71 -0
- package/src/components/PageHeader.astro +24 -0
- package/src/components/StatusTables.astro +45 -0
- package/src/db/astro-db-drizzle-client.ts +14 -0
- package/src/db/astro-db-schema.ts +193 -0
- package/src/db/astrodb.ts +88 -0
- package/src/db/client.ts +156 -0
- package/src/db/drizzle-schema.ts +54 -0
- package/src/env.d.ts +3 -0
- package/src/fonts/css/onest-variable.css +16 -0
- package/src/fonts/woff2/onest-variable.woff2 +0 -0
- package/src/layouts/Layout.astro +30 -0
- package/src/lib/astro-db-drizzle-compat/core-types.ts +88 -0
- package/src/lib/astro-db-drizzle-compat/error-map.ts +105 -0
- package/src/lib/astro-db-drizzle-compat/index.ts +149 -0
- package/src/lib/astro-db-drizzle-compat/schemas.ts +249 -0
- package/src/lib/astro-db-drizzle-compat/types.ts +141 -0
- package/src/lib/astro-db-drizzle-compat/utils.ts +55 -0
- package/src/lib/astro-db-drizzle-compat/virtual.ts +91 -0
- package/src/lib/errors.ts +57 -0
- package/src/lib/logger.ts +4 -0
- package/src/lib/remapUtils.ts +170 -0
- package/src/lib/response-utils.ts +12 -0
- package/src/lib/tableMap.ts +236 -0
- package/src/pages/data-migrations.ts +268 -0
- package/src/pages/index.astro +259 -0
- package/src/pages/schema-migrations.ts +31 -0
- package/src/styles/global.css +165 -0
- package/start.mjs +163 -0
- package/utils/logger.mjs +93 -0
- package/utils/resolver.mjs +60 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a path resolver function with a configured base directory.
|
|
6
|
+
*
|
|
7
|
+
* @param baseOption - The base directory to resolve paths from:
|
|
8
|
+
* - `process.cwd()` for project root
|
|
9
|
+
* - `import.meta.url` for current module directory
|
|
10
|
+
* - Any string path for custom base directory
|
|
11
|
+
* @returns A resolver function that resolves paths relative to the configured base
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Resolve relative to project root
|
|
15
|
+
* const resolveFromRoot = createPathResolver(process.cwd());
|
|
16
|
+
* const configPath = resolveFromRoot('./config/app.json');
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Resolve relative to current module
|
|
20
|
+
* const resolveFromModule = createPathResolver(import.meta.url);
|
|
21
|
+
* const dataPath = resolveFromModule('./data.json');
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Resolve relative to custom directory
|
|
25
|
+
* const resolveFromPublic = createPathResolver('./public');
|
|
26
|
+
* const imagePath = resolveFromPublic('./images/logo.png');
|
|
27
|
+
*/
|
|
28
|
+
function createPathResolver(baseOption) {
|
|
29
|
+
// Convert import.meta.url to file path if needed
|
|
30
|
+
let baseDir;
|
|
31
|
+
|
|
32
|
+
if (typeof baseOption === 'string' && baseOption.startsWith('file://')) {
|
|
33
|
+
// It's import.meta.url - convert to directory path
|
|
34
|
+
const filePath = fileURLToPath(baseOption);
|
|
35
|
+
baseDir = path.dirname(filePath);
|
|
36
|
+
} else {
|
|
37
|
+
// It's already a regular path (process.cwd() or custom string)
|
|
38
|
+
baseDir = baseOption;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
/**
|
|
43
|
+
* Resolve path segments against the base directory.
|
|
44
|
+
*
|
|
45
|
+
* @param segments - Path segments to resolve.
|
|
46
|
+
* @returns The resolved absolute filesystem path.
|
|
47
|
+
*/
|
|
48
|
+
resolve: (...segments) => path.resolve(baseDir, ...segments),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolve path segments against the base directory and return a file URL.
|
|
52
|
+
*
|
|
53
|
+
* @param segments - Path segments to resolve.
|
|
54
|
+
* @returns The resolved file URL.
|
|
55
|
+
*/
|
|
56
|
+
resolveURL: (...segments) => pathToFileURL(path.resolve(baseDir, ...segments)),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default createPathResolver;
|