Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions drizzle-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"build:ext": "rm -rf ./dist && vitest run bin.test && vitest run ./tests/postgres/ && vitest run ./tests/sqlite && vitest run ./tests/mysql && tsx build.ext.ts",
"pack": "cp package.json README.md dist/ && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
"pack:artifact": "pnpm run pack",
"pack:replit": "pnpm run build && tsx scripts/prepare-replit-package.ts && (cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
"publish": "npm publish package.tgz",
"publish:replit": "pnpm run pack:replit && npm publish package.tgz --provenance=false",
"test:postgres": "vitest run ./postgres/",
"test:other": "vitest run ./mysql/ ./sqlite/ ./other",
"test:cockroach": "vitest run ./cockroach",
Expand Down Expand Up @@ -141,6 +143,18 @@
"types": "./index.d.mts",
"default": "./index.mjs"
},
"./api": {
"import": {
"types": "./api.d.mts",
"default": "./api.mjs"
},
"require": {
"types": "./api.d.ts",
"default": "./api.js"
},
"types": "./api.d.mts",
"default": "./api.mjs"
},
"./api-postgres": {
"import": {
"types": "./api-postgres.d.mts",
Expand Down
14 changes: 14 additions & 0 deletions drizzle-kit/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async function buildDeclarations() {

await tsdown({
entry: {
api: './src/ext/api.ts',
'api-postgres': './src/ext/api-postgres.ts',
'api-mysql': './src/ext/api-mysql.ts',
'api-sqlite': './src/ext/api-sqlite.ts',
Expand Down Expand Up @@ -152,6 +153,7 @@ async function copyDeclarationsAndCleanTemp() {

async function postProcessApiFiles() {
const apiFiles = [
'dist/api.js',
'dist/api-postgres.js',
'dist/api-mysql.js',
'dist/api-sqlite.js',
Expand Down Expand Up @@ -188,6 +190,18 @@ async function main() {
outputName: 'index.mjs',
format: 'esm',
}),
buildBundle({
name: 'api-cjs',
input: './src/ext/api.ts',
outputName: 'api.js',
format: 'cjs',
}),
buildBundle({
name: 'api-esm',
input: './src/ext/api.ts',
outputName: 'api.mjs',
format: 'esm',
}),
buildBundle({
name: 'api-postgres-cjs',
input: './src/ext/api-postgres.ts',
Expand Down
32 changes: 32 additions & 0 deletions drizzle-kit/scripts/prepare-replit-package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { readFile, writeFile } from 'node:fs/promises';

async function main() {
const packagePath = 'dist/package.json';
const parsed: unknown = JSON.parse(await readFile(packagePath, 'utf8'));

if (
typeof parsed !== 'object'
|| parsed === null
|| !('name' in parsed)
|| parsed.name !== 'drizzle-kit'
|| !('dependencies' in parsed)
|| typeof parsed.dependencies !== 'object'
|| parsed.dependencies === null
|| !('@drizzle-team/brocli' in parsed.dependencies)
) {
throw new Error('Expected the built drizzle-kit package manifest');
}
const dependencies = Object.fromEntries(
Object.entries(parsed.dependencies).filter(([name]) => name !== '@drizzle-team/brocli'),
);

await writeFile(
packagePath,
`${JSON.stringify({ ...parsed, name: '@drizzle-team/drizzle-kit', dependencies }, null, '\t')}\n`,
);
}

main().catch((error: unknown) => {
console.error(error);
process.exit(1);
});
Loading
Loading