@astrojs/db 0.10.6 → 0.10.7
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/core/cli/commands/login/index.js +1 -1
- package/dist/core/cli/print-help.js +1 -1
- package/dist/core/errors.d.ts +1 -0
- package/dist/core/errors.js +5 -0
- package/dist/core/tokens.js +12 -3
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -2
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +5 -1
- package/package.json +4 -3
|
@@ -9,7 +9,7 @@ import { SESSION_LOGIN_FILE } from "../../../tokens.js";
|
|
|
9
9
|
import { getAstroStudioUrl } from "../../../utils.js";
|
|
10
10
|
const isWebContainer = (
|
|
11
11
|
// Stackblitz heuristic
|
|
12
|
-
process.versions?.webcontainer ?? //
|
|
12
|
+
process.versions?.webcontainer ?? // GitHub Codespaces heuristic
|
|
13
13
|
process.env.CODESPACE_NAME
|
|
14
14
|
);
|
|
15
15
|
async function cmd({
|
package/dist/core/errors.d.ts
CHANGED
package/dist/core/errors.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { bold, cyan, red } from "kleur/colors";
|
|
2
|
+
const MISSING_SESSION_ID_CI_ERROR = `${red("\u25B6 ASTRO_STUDIO_APP_TOKEN required")}
|
|
3
|
+
|
|
4
|
+
To authenticate with Astro Studio add the token to your CI's environment variables.
|
|
5
|
+
`;
|
|
2
6
|
const MISSING_SESSION_ID_ERROR = `${red("\u25B6 Login required!")}
|
|
3
7
|
|
|
4
8
|
To authenticate with Astro Studio, run
|
|
@@ -53,6 +57,7 @@ export {
|
|
|
53
57
|
INTEGRATION_TABLE_CONFLICT_ERROR,
|
|
54
58
|
MISSING_EXECUTE_PATH_ERROR,
|
|
55
59
|
MISSING_PROJECT_ID_ERROR,
|
|
60
|
+
MISSING_SESSION_ID_CI_ERROR,
|
|
56
61
|
MISSING_SESSION_ID_ERROR,
|
|
57
62
|
RENAME_COLUMN_ERROR,
|
|
58
63
|
RENAME_TABLE_ERROR,
|
package/dist/core/tokens.js
CHANGED
|
@@ -2,10 +2,15 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
+
import ci from "ci-info";
|
|
5
6
|
import { green } from "kleur/colors";
|
|
6
7
|
import ora from "ora";
|
|
7
8
|
import { safeFetch } from "../runtime/utils.js";
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
MISSING_PROJECT_ID_ERROR,
|
|
11
|
+
MISSING_SESSION_ID_CI_ERROR,
|
|
12
|
+
MISSING_SESSION_ID_ERROR
|
|
13
|
+
} from "./errors.js";
|
|
9
14
|
import { getAstroStudioEnv, getAstroStudioUrl } from "./utils.js";
|
|
10
15
|
const SESSION_LOGIN_FILE = pathToFileURL(join(homedir(), ".astro", "session-token"));
|
|
11
16
|
const PROJECT_ID_FILE = pathToFileURL(join(process.cwd(), ".astro", "link"));
|
|
@@ -159,11 +164,15 @@ async function getManagedAppTokenOrExit(token) {
|
|
|
159
164
|
}
|
|
160
165
|
const sessionToken = await getSessionIdFromFile();
|
|
161
166
|
if (!sessionToken) {
|
|
162
|
-
|
|
167
|
+
if (ci.isCI) {
|
|
168
|
+
console.error(MISSING_SESSION_ID_CI_ERROR);
|
|
169
|
+
} else {
|
|
170
|
+
console.error(MISSING_SESSION_ID_ERROR);
|
|
171
|
+
}
|
|
163
172
|
process.exit(1);
|
|
164
173
|
}
|
|
165
174
|
const projectId = await getProjectIdFromFile();
|
|
166
|
-
if (!
|
|
175
|
+
if (!projectId) {
|
|
167
176
|
console.error(MISSING_PROJECT_ID_ERROR);
|
|
168
177
|
process.exit(1);
|
|
169
178
|
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ColumnDataType } from 'drizzle-orm';
|
|
2
|
-
import {
|
|
2
|
+
import type { DBColumn, DBTable } from '../core/types.js';
|
|
3
3
|
export type { Table } from './types.js';
|
|
4
4
|
export { createRemoteDatabaseClient, createLocalDatabaseClient } from './db-client.js';
|
|
5
5
|
export { seedLocal } from './seed-local.js';
|
package/dist/runtime/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
sqliteTable,
|
|
7
7
|
text
|
|
8
8
|
} from "drizzle-orm/sqlite-core";
|
|
9
|
-
import {} from "../core/types.js";
|
|
10
9
|
import { isSerializedSQL } from "./types.js";
|
|
11
10
|
import { pathToFileURL } from "./utils.js";
|
|
12
11
|
import { createRemoteDatabaseClient, createLocalDatabaseClient } from "./db-client.js";
|
|
@@ -116,7 +115,7 @@ function normalizeDatabaseUrl(envDbUrl, defaultDbUrl) {
|
|
|
116
115
|
if (envDbUrl.startsWith("file://")) {
|
|
117
116
|
return envDbUrl;
|
|
118
117
|
}
|
|
119
|
-
return new URL(envDbUrl, pathToFileURL(process.cwd())).toString();
|
|
118
|
+
return new URL(envDbUrl, pathToFileURL(process.cwd()) + "/").toString();
|
|
120
119
|
} else {
|
|
121
120
|
return defaultDbUrl;
|
|
122
121
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { defineDbIntegration } from './core/utils.js';
|
|
2
|
-
|
|
2
|
+
import type { ColumnsConfig, TableConfig } from './core/types.js';
|
|
3
|
+
import { type Table } from './runtime/index.js';
|
|
4
|
+
export declare function asDrizzleTable<TableName extends string = string, TColumns extends ColumnsConfig = ColumnsConfig>(name: TableName, tableConfig: TableConfig<TColumns>): Table<TableName, TColumns>;
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { defineDbIntegration } from "./core/utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { tableSchema } from "./core/schemas.js";
|
|
3
|
+
import { asDrizzleTable as internal_asDrizzleTable } from "./runtime/index.js";
|
|
4
|
+
function asDrizzleTable(name, tableConfig) {
|
|
5
|
+
return internal_asDrizzleTable(name, tableSchema.parse(tableConfig));
|
|
6
|
+
}
|
|
3
7
|
export {
|
|
4
8
|
asDrizzleTable,
|
|
5
9
|
defineDbIntegration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/db",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7",
|
|
4
4
|
"description": "Add libSQL and Astro Studio support to your Astro site",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@libsql/client": "^0.6.0",
|
|
66
66
|
"async-listen": "^3.0.1",
|
|
67
|
+
"ci-info": "^4.0.0",
|
|
67
68
|
"deep-diff": "^1.0.2",
|
|
68
69
|
"drizzle-orm": "^0.30.9",
|
|
69
70
|
"github-slugger": "^2.0.0",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"prompts": "^2.4.2",
|
|
75
76
|
"strip-ansi": "^7.1.0",
|
|
76
77
|
"yargs-parser": "^21.1.1",
|
|
77
|
-
"zod": "^3.23.
|
|
78
|
+
"zod": "^3.23.5"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@types/chai": "^4.3.14",
|
|
@@ -88,7 +89,7 @@
|
|
|
88
89
|
"mocha": "^10.4.0",
|
|
89
90
|
"typescript": "^5.4.5",
|
|
90
91
|
"vite": "^5.2.10",
|
|
91
|
-
"astro": "4.
|
|
92
|
+
"astro": "4.7.1",
|
|
92
93
|
"astro-scripts": "0.0.14"
|
|
93
94
|
},
|
|
94
95
|
"scripts": {
|