@firtoz/drizzle-indexeddb 0.4.2 → 0.4.3
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/CHANGELOG.md +6 -0
- package/README.md +37 -3
- package/package.json +4 -1
- package/src/bin/generate-migrations.ts +28 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @firtoz/drizzle-indexeddb
|
|
2
2
|
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ed6dfce`](https://github.com/firtoz/fullstack-toolkit/commit/ed6dfce75be95d5349381ab43c6c22b25b164414) Thanks [@firtoz](https://github.com/firtoz)! - Enable drizzle and output dir configuration in drizzle-indexeddb-generate
|
|
8
|
+
|
|
3
9
|
## 0.4.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -385,8 +385,8 @@ bun drizzle-indexeddb-generate --help
|
|
|
385
385
|
|
|
386
386
|
| Option | Description | Default |
|
|
387
387
|
|--------|-------------|---------|
|
|
388
|
-
| `--drizzle-dir <path
|
|
389
|
-
| `--output-dir <path
|
|
388
|
+
| `--drizzle-dir <path>`, `-d` | Path to Drizzle directory | `./drizzle` |
|
|
389
|
+
| `--output-dir <path>`, `-o` | Path to output directory | `<drizzle-dir>/indexeddb-migrations` |
|
|
390
390
|
|
|
391
391
|
### npm scripts
|
|
392
392
|
|
|
@@ -395,11 +395,13 @@ Add to your `package.json`:
|
|
|
395
395
|
```json
|
|
396
396
|
{
|
|
397
397
|
"scripts": {
|
|
398
|
-
"db:generate": "bun drizzle-kit generate && bun drizzle-indexeddb-generate"
|
|
398
|
+
"db:generate": "bun --bun drizzle-kit generate && bun drizzle-indexeddb-generate"
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
+
> **Note:** The `--bun` flag forces bun's runtime instead of Node, which is needed because this package exports raw TypeScript. See [Troubleshooting](#err_unsupported_node_modules_type_stripping-error) if you encounter type stripping errors.
|
|
404
|
+
|
|
403
405
|
## Advanced Usage
|
|
404
406
|
|
|
405
407
|
### Custom Sync Configuration
|
|
@@ -666,6 +668,38 @@ Remove from schema and regenerate - the migrator will delete the object store.
|
|
|
666
668
|
|
|
667
669
|
## Troubleshooting
|
|
668
670
|
|
|
671
|
+
### "ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING" Error
|
|
672
|
+
|
|
673
|
+
If you see this error when running `drizzle-kit generate`:
|
|
674
|
+
|
|
675
|
+
```
|
|
676
|
+
Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
This happens because this package exports raw TypeScript files, and Node's built-in type stripping doesn't work inside `node_modules`.
|
|
680
|
+
|
|
681
|
+
**Solution:** Use `bun --bun` to force bun's runtime instead of Node:
|
|
682
|
+
|
|
683
|
+
```bash
|
|
684
|
+
bun --bun drizzle-kit generate
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
Or in your `package.json`:
|
|
688
|
+
|
|
689
|
+
```json
|
|
690
|
+
{
|
|
691
|
+
"scripts": {
|
|
692
|
+
"db:generate": "bun --bun drizzle-kit generate && bun drizzle-indexeddb-generate"
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
**Alternative:** If you're not using bun, use `tsx`:
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
npx tsx node_modules/drizzle-kit/bin.cjs generate --config ./drizzle.config.ts
|
|
701
|
+
```
|
|
702
|
+
|
|
669
703
|
### "Primary key structure changed" Error
|
|
670
704
|
|
|
671
705
|
This happens when you change the primary key of a table. IndexedDB doesn't support changing keyPath after creation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/drizzle-indexeddb",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "IndexedDB migrations powered by Drizzle ORM",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -83,5 +83,8 @@
|
|
|
83
83
|
"drizzle-valibot": "^0.4.2",
|
|
84
84
|
"react": "^19.2.1",
|
|
85
85
|
"valibot": "^1.2.0"
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"citty": "^0.1.6"
|
|
86
89
|
}
|
|
87
90
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
11
11
|
import { join, resolve } from "node:path";
|
|
12
|
+
import { defineCommand, runMain } from "citty";
|
|
12
13
|
import type {
|
|
13
14
|
JournalEntry,
|
|
14
15
|
Journal,
|
|
@@ -240,49 +241,34 @@ export default migrations;
|
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
// CLI entry point
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
--drizzle-dir <path> Path to Drizzle directory (default: ./drizzle)
|
|
270
|
-
--output-dir <path> Path to output directory (default: ./drizzle/indexeddb-migrations)
|
|
271
|
-
-h, --help Show this help message
|
|
272
|
-
|
|
273
|
-
Examples:
|
|
274
|
-
bun drizzle-indexeddb-generate
|
|
275
|
-
bun drizzle-indexeddb-generate --drizzle-dir ./db/drizzle
|
|
276
|
-
bun drizzle-indexeddb-generate --output-dir ./src/migrations
|
|
277
|
-
`);
|
|
278
|
-
} else {
|
|
279
|
-
console.error(`Unknown command: ${command}`);
|
|
280
|
-
console.error(`Run 'bun drizzle-indexeddb-generate --help' for usage`);
|
|
281
|
-
process.exit(1);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
244
|
+
const main = defineCommand({
|
|
245
|
+
meta: {
|
|
246
|
+
name: "drizzle-indexeddb-generate",
|
|
247
|
+
description: "Generate IndexedDB migrations from Drizzle schema",
|
|
248
|
+
},
|
|
249
|
+
args: {
|
|
250
|
+
drizzleDir: {
|
|
251
|
+
type: "string",
|
|
252
|
+
alias: "d",
|
|
253
|
+
default: "./drizzle",
|
|
254
|
+
description: "Path to Drizzle directory",
|
|
255
|
+
},
|
|
256
|
+
outputDir: {
|
|
257
|
+
type: "string",
|
|
258
|
+
alias: "o",
|
|
259
|
+
description:
|
|
260
|
+
"Path to output directory (default: <drizzle-dir>/indexeddb-migrations)",
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
run({ args }) {
|
|
264
|
+
generateIndexedDBMigrations({
|
|
265
|
+
drizzleDir: args.drizzleDir,
|
|
266
|
+
outputDir: args.outputDir,
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
});
|
|
284
270
|
|
|
285
271
|
// Only run CLI when executed directly (not when imported)
|
|
286
272
|
if (import.meta.main) {
|
|
287
|
-
main
|
|
273
|
+
runMain(main);
|
|
288
274
|
}
|