@anthonyalayo/drizzle-kit 1.0.1

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.
Files changed (161) hide show
  1. package/.gitignore +25 -0
  2. package/README.md +79 -0
  3. package/build.dev.ts +51 -0
  4. package/build.ts +112 -0
  5. package/imports-checker/analyze.ts +78 -0
  6. package/imports-checker/checker.ts +296 -0
  7. package/imports-checker/grammar/grammar.ohm +121 -0
  8. package/imports-checker/grammar/grammar.ohm-bundle.d.ts +164 -0
  9. package/imports-checker/grammar/grammar.ohm-bundle.js +753 -0
  10. package/imports-checker/index.ts +48 -0
  11. package/package.json +142 -0
  12. package/patches/difflib@0.2.4.patch +31 -0
  13. package/src/@types/utils.ts +58 -0
  14. package/src/api.ts +504 -0
  15. package/src/cli/commands/_es5.ts +2 -0
  16. package/src/cli/commands/check.ts +52 -0
  17. package/src/cli/commands/drop.ts +60 -0
  18. package/src/cli/commands/introspect.ts +772 -0
  19. package/src/cli/commands/libSqlPushUtils.ts +355 -0
  20. package/src/cli/commands/migrate.ts +1526 -0
  21. package/src/cli/commands/mysqlIntrospect.ts +53 -0
  22. package/src/cli/commands/mysqlPushUtils.ts +352 -0
  23. package/src/cli/commands/mysqlUp.ts +102 -0
  24. package/src/cli/commands/pgIntrospect.ts +55 -0
  25. package/src/cli/commands/pgPushUtils.ts +269 -0
  26. package/src/cli/commands/pgUp.ts +217 -0
  27. package/src/cli/commands/push.ts +637 -0
  28. package/src/cli/commands/singlestoreIntrospect.ts +53 -0
  29. package/src/cli/commands/singlestorePushUtils.ts +456 -0
  30. package/src/cli/commands/singlestoreUp.ts +1 -0
  31. package/src/cli/commands/sqliteIntrospect.ts +96 -0
  32. package/src/cli/commands/sqlitePushUtils.ts +322 -0
  33. package/src/cli/commands/sqliteUp.ts +52 -0
  34. package/src/cli/commands/utils.ts +858 -0
  35. package/src/cli/connections.ts +914 -0
  36. package/src/cli/index.ts +48 -0
  37. package/src/cli/schema.ts +794 -0
  38. package/src/cli/selector-ui.ts +38 -0
  39. package/src/cli/utils.ts +112 -0
  40. package/src/cli/validations/cli.ts +79 -0
  41. package/src/cli/validations/common.ts +193 -0
  42. package/src/cli/validations/libsql.ts +27 -0
  43. package/src/cli/validations/mysql.ts +61 -0
  44. package/src/cli/validations/outputs.ts +91 -0
  45. package/src/cli/validations/postgres.ts +83 -0
  46. package/src/cli/validations/singlestore.ts +61 -0
  47. package/src/cli/validations/sqlite.ts +104 -0
  48. package/src/cli/validations/studio.ts +24 -0
  49. package/src/cli/views.ts +658 -0
  50. package/src/extensions/getTablesFilterByExtensions.ts +16 -0
  51. package/src/extensions/vector.ts +10 -0
  52. package/src/global.ts +61 -0
  53. package/src/index.ts +326 -0
  54. package/src/introspect-mysql.ts +1030 -0
  55. package/src/introspect-pg.ts +1435 -0
  56. package/src/introspect-singlestore.ts +913 -0
  57. package/src/introspect-sqlite.ts +533 -0
  58. package/src/jsonDiffer.js +882 -0
  59. package/src/jsonStatements.ts +3590 -0
  60. package/src/loader.mjs +57 -0
  61. package/src/migrationPreparator.ts +217 -0
  62. package/src/schemaValidator.ts +23 -0
  63. package/src/serializer/index.ts +142 -0
  64. package/src/serializer/mysqlImports.ts +38 -0
  65. package/src/serializer/mysqlSchema.ts +423 -0
  66. package/src/serializer/mysqlSerializer.ts +999 -0
  67. package/src/serializer/pgImports.ts +106 -0
  68. package/src/serializer/pgSchema.ts +937 -0
  69. package/src/serializer/pgSerializer.ts +2223 -0
  70. package/src/serializer/singlestoreImports.ts +38 -0
  71. package/src/serializer/singlestoreSchema.ts +257 -0
  72. package/src/serializer/singlestoreSerializer.ts +767 -0
  73. package/src/serializer/sqliteImports.ts +41 -0
  74. package/src/serializer/sqliteSchema.ts +352 -0
  75. package/src/serializer/sqliteSerializer.ts +931 -0
  76. package/src/serializer/studio.ts +694 -0
  77. package/src/serializer/utils.ts +45 -0
  78. package/src/simulator.ts +157 -0
  79. package/src/snapshotsDiffer.ts +4398 -0
  80. package/src/sqlgenerator.ts +4212 -0
  81. package/src/statementCombiner.ts +597 -0
  82. package/src/utils/certs.ts +44 -0
  83. package/src/utils/words.ts +1333 -0
  84. package/src/utils.ts +370 -0
  85. package/tests/bin.test.ts +58 -0
  86. package/tests/cli/d1http.config.ts +12 -0
  87. package/tests/cli/drizzle.config.ts +9 -0
  88. package/tests/cli/durable-sqlite.config.ts +7 -0
  89. package/tests/cli/expo.config.ts +7 -0
  90. package/tests/cli/postgres.config.ts +13 -0
  91. package/tests/cli/postgres2.config.ts +17 -0
  92. package/tests/cli/schema.ts +1 -0
  93. package/tests/cli/turso.config.ts +10 -0
  94. package/tests/cli-export.test.ts +79 -0
  95. package/tests/cli-generate.test.ts +259 -0
  96. package/tests/cli-migrate.test.ts +103 -0
  97. package/tests/cli-push.test.ts +126 -0
  98. package/tests/common.ts +15 -0
  99. package/tests/indexes/common.ts +21 -0
  100. package/tests/indexes/pg.test.ts +245 -0
  101. package/tests/introspect/libsql.test.ts +35 -0
  102. package/tests/introspect/mysql.test.ts +319 -0
  103. package/tests/introspect/pg.test.ts +894 -0
  104. package/tests/introspect/singlestore.test.ts +275 -0
  105. package/tests/introspect/sqlite.test.ts +122 -0
  106. package/tests/libsql-checks.test.ts +308 -0
  107. package/tests/libsql-statements.test.ts +989 -0
  108. package/tests/libsql-views.test.ts +218 -0
  109. package/tests/migrate/libsq-schema.ts +6 -0
  110. package/tests/migrate/libsql-migrate.test.ts +58 -0
  111. package/tests/migrate/migrations/0000_little_blizzard.sql +4 -0
  112. package/tests/migrate/migrations/0001_nebulous_storm.sql +10 -0
  113. package/tests/migrate/migrations/meta/0000_snapshot.json +40 -0
  114. package/tests/migrate/migrations/meta/0001_snapshot.json +40 -0
  115. package/tests/migrate/migrations/meta/_journal.json +20 -0
  116. package/tests/mysql-checks.test.ts +291 -0
  117. package/tests/mysql-generated.test.ts +1290 -0
  118. package/tests/mysql-schemas.test.ts +156 -0
  119. package/tests/mysql-views.test.ts +553 -0
  120. package/tests/mysql.test.ts +863 -0
  121. package/tests/pg-array.test.ts +368 -0
  122. package/tests/pg-checks.test.ts +329 -0
  123. package/tests/pg-columns.test.ts +484 -0
  124. package/tests/pg-domains.test.ts +306 -0
  125. package/tests/pg-enums.test.ts +751 -0
  126. package/tests/pg-generated.test.ts +529 -0
  127. package/tests/pg-identity.test.ts +447 -0
  128. package/tests/pg-schemas.test.ts +105 -0
  129. package/tests/pg-sequences.test.ts +298 -0
  130. package/tests/pg-tables.test.ts +1021 -0
  131. package/tests/pg-views.test.ts +1929 -0
  132. package/tests/push/common.ts +58 -0
  133. package/tests/push/libsql.test.ts +1400 -0
  134. package/tests/push/mysql-push.test.ts +345 -0
  135. package/tests/push/mysql.test.ts +788 -0
  136. package/tests/push/pg.test.ts +4341 -0
  137. package/tests/push/singlestore-push.test.ts +894 -0
  138. package/tests/push/singlestore.test.ts +444 -0
  139. package/tests/push/sqlite.test.ts +1613 -0
  140. package/tests/rls/pg-policy.test.ts +1656 -0
  141. package/tests/rls/pg-role.test.ts +234 -0
  142. package/tests/schemaDiffer.ts +2852 -0
  143. package/tests/singlestore-generated.test.ts +1290 -0
  144. package/tests/singlestore-schemas.test.ts +155 -0
  145. package/tests/singlestore.test.ts +978 -0
  146. package/tests/sqlite-checks.test.ts +308 -0
  147. package/tests/sqlite-columns.test.ts +1049 -0
  148. package/tests/sqlite-generated.test.ts +1726 -0
  149. package/tests/sqlite-tables.test.ts +637 -0
  150. package/tests/sqlite-views.test.ts +218 -0
  151. package/tests/statements-combiner/libsql-statements-combiner.test.ts +1812 -0
  152. package/tests/statements-combiner/singlestore-statements-combiner.test.ts +882 -0
  153. package/tests/statements-combiner/sqlite-statements-combiner.test.ts +1211 -0
  154. package/tests/test/sqlite.test.ts +39 -0
  155. package/tests/testsinglestore.ts +29 -0
  156. package/tests/validations.test.ts +869 -0
  157. package/tests/wrap-param.test.ts +16 -0
  158. package/tsconfig.build.json +4 -0
  159. package/tsconfig.cli-types.json +9 -0
  160. package/tsconfig.json +28 -0
  161. package/vitest.config.ts +34 -0
@@ -0,0 +1,48 @@
1
+ import chalk from 'chalk';
2
+ import { analyzeImports, ChainLink } from './checker';
3
+
4
+ const issues = analyzeImports({
5
+ basePath: './drizzle-kit',
6
+ localPaths: ['src'],
7
+ whiteList: [
8
+ '@drizzle-team/brocli',
9
+ 'json-diff',
10
+ 'path',
11
+ 'fs',
12
+ 'fs/*',
13
+ 'url',
14
+ 'zod',
15
+ 'node:*',
16
+ 'hono',
17
+ 'glob',
18
+ 'hono/*',
19
+ 'hono/**/*',
20
+ '@hono/*',
21
+ 'crypto',
22
+ 'hanji',
23
+ ],
24
+ entry: './drizzle-kit/src/cli/index.ts',
25
+ logger: true,
26
+ ignoreTypes: true,
27
+ }).issues;
28
+
29
+ const chainToString = (chains: ChainLink[]) => {
30
+ if (chains.length === 0) throw new Error();
31
+
32
+ let out = chains[0]!.file + '\n';
33
+ let indentation = 0;
34
+ for (let chain of chains) {
35
+ out += ' '.repeat(indentation)
36
+ + '└'
37
+ + chain.import
38
+ + ` ${chalk.gray(chain.file)}\n`;
39
+ indentation += 1;
40
+ }
41
+ return out;
42
+ };
43
+
44
+ console.log();
45
+ for (const issue of issues) {
46
+ console.log(chalk.red(issue.imports.map((it) => it.name).join('\n')));
47
+ console.log(issue.accessChains.map((it) => chainToString(it)).join('\n'));
48
+ }
package/package.json ADDED
@@ -0,0 +1,142 @@
1
+ {
2
+ "name": "@anthonyalayo/drizzle-kit",
3
+ "version": "1.0.1",
4
+ "homepage": "https://orm.drizzle.team",
5
+ "keywords": [
6
+ "drizzle",
7
+ "orm",
8
+ "pg",
9
+ "mysql",
10
+ "singlestore",
11
+ "postgresql",
12
+ "postgres",
13
+ "sqlite",
14
+ "database",
15
+ "sql",
16
+ "typescript",
17
+ "ts",
18
+ "drizzle-kit",
19
+ "migrations",
20
+ "schema"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/drizzle-team/drizzle-orm.git"
25
+ },
26
+ "author": "Drizzle Team",
27
+ "license": "MIT",
28
+ "bin": {
29
+ "drizzle-kit": "./bin.cjs"
30
+ },
31
+ "scripts": {
32
+ "api": "tsx ./dev/api.ts",
33
+ "migrate:old": "drizzle-kit generate:mysql",
34
+ "cli": "tsx ./src/cli/index.ts",
35
+ "test": "pnpm tsc && TEST_CONFIG_PATH_PREFIX=./tests/cli/ vitest",
36
+ "build": "rm -rf ./dist && tsx build.ts && cp package.json dist/ && attw --pack dist",
37
+ "build:dev": "rm -rf ./dist && tsx build.dev.ts && tsc -p tsconfig.cli-types.json && chmod +x ./dist/index.cjs",
38
+ "pack": "cp package.json README.md dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
39
+ "tsc": "tsc -p tsconfig.build.json --noEmit",
40
+ "publish": "npm publish package.tgz"
41
+ },
42
+ "dependencies": {
43
+ "@drizzle-team/brocli": "^0.10.2",
44
+ "@esbuild-kit/esm-loader": "^2.5.5",
45
+ "esbuild": "^0.19.7",
46
+ "esbuild-register": "^3.5.0"
47
+ },
48
+ "devDependencies": {
49
+ "@arethetypeswrong/cli": "^0.15.3",
50
+ "@aws-sdk/client-rds-data": "^3.556.0",
51
+ "@cloudflare/workers-types": "^4.20230518.0",
52
+ "@electric-sql/pglite": "^0.2.12",
53
+ "@hono/node-server": "^1.9.0",
54
+ "@hono/zod-validator": "^0.2.1",
55
+ "@libsql/client": "^0.10.0",
56
+ "@neondatabase/serverless": "^0.9.1",
57
+ "@originjs/vite-plugin-commonjs": "^1.0.3",
58
+ "@planetscale/database": "^1.16.0",
59
+ "@types/better-sqlite3": "^7.6.4",
60
+ "@types/dockerode": "^3.3.28",
61
+ "@types/glob": "^8.1.0",
62
+ "@types/json-diff": "^1.0.3",
63
+ "@types/micromatch": "^4.0.9",
64
+ "@types/minimatch": "^5.1.2",
65
+ "@types/node": "^18.11.15",
66
+ "@types/pg": "^8.10.7",
67
+ "@types/pluralize": "^0.0.33",
68
+ "@types/semver": "^7.5.5",
69
+ "@types/uuid": "^9.0.8",
70
+ "@types/ws": "^8.5.10",
71
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
72
+ "@typescript-eslint/parser": "^7.2.0",
73
+ "@vercel/postgres": "^0.8.0",
74
+ "ava": "^5.1.0",
75
+ "better-sqlite3": "^9.4.3",
76
+ "bun-types": "^0.6.6",
77
+ "camelcase": "^7.0.1",
78
+ "chalk": "^5.2.0",
79
+ "commander": "^12.1.0",
80
+ "dockerode": "^3.3.4",
81
+ "dotenv": "^16.0.3",
82
+ "drizzle-kit": "0.25.0-b1faa33",
83
+ "drizzle-orm": "workspace:./drizzle-orm/dist",
84
+ "env-paths": "^3.0.0",
85
+ "esbuild-node-externals": "^1.9.0",
86
+ "eslint": "^8.57.0",
87
+ "eslint-config-prettier": "^9.1.0",
88
+ "eslint-plugin-prettier": "^5.1.3",
89
+ "get-port": "^6.1.2",
90
+ "glob": "^8.1.0",
91
+ "hanji": "^0.0.5",
92
+ "hono": "^4.1.5",
93
+ "json-diff": "1.0.6",
94
+ "micromatch": "^4.0.8",
95
+ "minimatch": "^7.4.3",
96
+ "mysql2": "3.3.3",
97
+ "node-fetch": "^3.3.2",
98
+ "ohm-js": "^17.1.0",
99
+ "pg": "^8.11.5",
100
+ "pluralize": "^8.0.0",
101
+ "postgres": "^3.4.4",
102
+ "prettier": "^2.8.1",
103
+ "semver": "^7.5.4",
104
+ "superjson": "^2.2.1",
105
+ "tsup": "^8.0.2",
106
+ "tsx": "^3.12.1",
107
+ "typescript": "^5.6.3",
108
+ "uuid": "^9.0.1",
109
+ "vite-tsconfig-paths": "^4.3.2",
110
+ "vitest": "^1.4.0",
111
+ "wrangler": "^3.22.1",
112
+ "ws": "^8.16.0",
113
+ "zod": "^3.20.2",
114
+ "zx": "^7.2.2"
115
+ },
116
+ "exports": {
117
+ ".": {
118
+ "import": {
119
+ "types": "./index.d.mts",
120
+ "default": "./index.mjs"
121
+ },
122
+ "require": {
123
+ "types": "./index.d.ts",
124
+ "default": "./index.js"
125
+ },
126
+ "types": "./index.d.mts",
127
+ "default": "./index.mjs"
128
+ },
129
+ "./api": {
130
+ "import": {
131
+ "types": "./api.d.mts",
132
+ "default": "./api.mjs"
133
+ },
134
+ "require": {
135
+ "types": "./api.d.ts",
136
+ "default": "./api.js"
137
+ },
138
+ "types": "./api.d.mts",
139
+ "default": "./api.mjs"
140
+ }
141
+ }
142
+ }
@@ -0,0 +1,31 @@
1
+ diff --git a/lib/difflib.js b/lib/difflib.js
2
+ index 80d250e7e18bdc972df3621ee5c05ffff0e3659f..94916f33dbae0d3eea6f74e2c619c4c6f52cc125 100644
3
+ --- a/lib/difflib.js
4
+ +++ b/lib/difflib.js
5
+ @@ -17,7 +17,7 @@ Function restore(delta, which):
6
+
7
+ Function unifiedDiff(a, b):
8
+ For two lists of strings, return a delta in unified diff format.
9
+ -
10
+ +.
11
+ Class SequenceMatcher:
12
+ A flexible class for comparing pairs of sequences of any type.
13
+
14
+ @@ -75,7 +75,7 @@ Class Differ:
15
+
16
+ SequenceMatcher = (function() {
17
+
18
+ - SequenceMatcher.name = 'SequenceMatcher';
19
+ + // SequenceMatcher.name = 'SequenceMatcher';
20
+
21
+ /*
22
+ SequenceMatcher is a flexible class for comparing pairs of sequences of
23
+ @@ -737,7 +737,7 @@ Class Differ:
24
+
25
+ Differ = (function() {
26
+
27
+ - Differ.name = 'Differ';
28
+ + // Differ.name = 'Differ';
29
+
30
+ /*
31
+ Differ is a class for comparing sequences of lines of text, and
@@ -0,0 +1,58 @@
1
+ declare global {
2
+ interface String {
3
+ trimChar(char: string): string;
4
+ squashSpaces(): string;
5
+ capitalise(): string;
6
+ camelCase(): string;
7
+ snake_case(): string;
8
+
9
+ concatIf(it: string, condition: boolean): string;
10
+ }
11
+
12
+ interface Array<T> {
13
+ random(): T;
14
+ }
15
+ }
16
+
17
+ import camelcase from 'camelcase';
18
+
19
+ String.prototype.trimChar = function(char: string) {
20
+ let start = 0;
21
+ let end = this.length;
22
+
23
+ while (start < end && this[start] === char) ++start;
24
+ while (end > start && this[end - 1] === char) --end;
25
+
26
+ // this.toString() due to ava deep equal issue with String { "value" }
27
+ return start > 0 || end < this.length
28
+ ? this.substring(start, end)
29
+ : this.toString();
30
+ };
31
+
32
+ String.prototype.squashSpaces = function() {
33
+ return this.replace(/ +/g, ' ').trim();
34
+ };
35
+
36
+ String.prototype.camelCase = function() {
37
+ return camelcase(String(this));
38
+ };
39
+
40
+ String.prototype.capitalise = function() {
41
+ return this && this.length > 0
42
+ ? `${this[0].toUpperCase()}${this.slice(1)}`
43
+ : String(this);
44
+ };
45
+
46
+ String.prototype.concatIf = function(it: string, condition: boolean) {
47
+ return condition ? `${this}${it}` : String(this);
48
+ };
49
+
50
+ String.prototype.snake_case = function() {
51
+ return this && this.length > 0 ? `${this.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)}` : String(this);
52
+ };
53
+
54
+ Array.prototype.random = function() {
55
+ return this[~~(Math.random() * this.length)];
56
+ };
57
+
58
+ export {};