@astrojs/db 0.1.1 → 0.1.2
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/cli/commands/push/index.js +7 -2
- package/dist/cli/index.js +18 -1
- package/package.json +3 -2
|
@@ -3,7 +3,12 @@ import { eq, sql } from "drizzle-orm";
|
|
|
3
3
|
import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
|
|
4
4
|
import { appTokenError } from "../../../errors.js";
|
|
5
5
|
import { collectionToTable, createLocalDatabaseClient } from "../../../internal.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getMigrations,
|
|
8
|
+
initializeFromMigrations,
|
|
9
|
+
loadInitialSnapshot,
|
|
10
|
+
loadMigration
|
|
11
|
+
} from "../../../migrations.js";
|
|
7
12
|
import {
|
|
8
13
|
STUDIO_ADMIN_TABLE_ROW_ID,
|
|
9
14
|
adminTable,
|
|
@@ -18,6 +23,7 @@ const sqliteDialect = new SQLiteAsyncDialect();
|
|
|
18
23
|
async function cmd({ config, flags }) {
|
|
19
24
|
const isSeedData = flags.seed;
|
|
20
25
|
const isDryRun = flags.dryRun;
|
|
26
|
+
const appToken = flags.token ?? getAstroStudioEnv().ASTRO_STUDIO_APP_TOKEN;
|
|
21
27
|
const currentDb = config.db?.collections ?? {};
|
|
22
28
|
const currentSnapshot = JSON.parse(JSON.stringify(currentDb));
|
|
23
29
|
const allMigrationFiles = await getMigrations();
|
|
@@ -31,7 +37,6 @@ async function cmd({ config, flags }) {
|
|
|
31
37
|
console.log("Changes detected!");
|
|
32
38
|
process.exit(1);
|
|
33
39
|
}
|
|
34
|
-
const appToken = getAstroStudioEnv().ASTRO_STUDIO_APP_TOKEN;
|
|
35
40
|
if (!appToken) {
|
|
36
41
|
console.error(appTokenError);
|
|
37
42
|
process.exit(1);
|
package/dist/cli/index.js
CHANGED
|
@@ -14,10 +14,27 @@ async function cli({ flags, config }) {
|
|
|
14
14
|
return await verifyCommand({ config, flags });
|
|
15
15
|
}
|
|
16
16
|
default: {
|
|
17
|
-
|
|
17
|
+
if (command == null) {
|
|
18
|
+
console.error(`No command provided.
|
|
19
|
+
|
|
20
|
+
${showHelp()}`);
|
|
21
|
+
} else {
|
|
22
|
+
console.error(`Unknown command: ${command}
|
|
23
|
+
|
|
24
|
+
${showHelp()}`);
|
|
25
|
+
}
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
20
28
|
}
|
|
29
|
+
function showHelp() {
|
|
30
|
+
return `astro db <command>
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
|
|
34
|
+
astro db sync Creates snapshot based on your schema
|
|
35
|
+
astro db push Pushes migrations to Astro Studio
|
|
36
|
+
astro db verify Verifies migrations have been pushed and errors if not`;
|
|
37
|
+
}
|
|
21
38
|
}
|
|
22
39
|
export {
|
|
23
40
|
cli
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"./internal-drizzle": {
|
|
21
21
|
"types": "./dist/internal-drizzle.d.ts",
|
|
22
22
|
"import": "./dist/internal-drizzle.js"
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
24
25
|
},
|
|
25
26
|
"typesVersions": {
|
|
26
27
|
"*": {
|