Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5fa318e
chore: configure Conventional Commits, Husky, and Changesets
ankur-arch Jul 18, 2025
81c7bc5
chore: remove unused pre-commit hook
ankur-arch Jul 18, 2025
55faa7e
chore: add action to publish to npm
ankur-arch Jul 18, 2025
3dd6d13
chore: add release on pull request too
ankur-arch Jul 18, 2025
b514d48
feat: publish feature branch on npm
ankur-arch Jul 18, 2025
9583877
fix: change working dir for bumping version path
ankur-arch Jul 18, 2025
abb8905
fix: remove git checks in PR
ankur-arch Jul 18, 2025
a1017c5
fix: publish git checks
ankur-arch Jul 18, 2025
4ac8813
fix: add npm auth
ankur-arch Jul 18, 2025
c4e26e1
fix: add temporary domain
ankur-arch Jul 18, 2025
f769602
fix: add run id
ankur-arch Jul 18, 2025
a1f884b
feat: add more packages
ankur-arch Jul 18, 2025
a2cc1e6
fix: fix directories
ankur-arch Jul 18, 2025
a546243
fix: add unique prelease versions
ankur-arch Jul 18, 2025
9cb25ae
fix: add index.js files to packages
ankur-arch Jul 18, 2025
6c8b75e
fix: add all scripts
ankur-arch Jul 18, 2025
ab386d8
fix: add QoL improvements to CLI
ankur-arch Jul 21, 2025
d4dba92
fix: make CLI refinements
ankur-arch Jul 21, 2025
452daad
feat: add CF deployment to the release
ankur-arch Jul 21, 2025
d92f120
feat: add separate workflows
ankur-arch Jul 21, 2025
951634c
fix: add installation for wrangler cli
ankur-arch Jul 21, 2025
5dbd549
fix: update to cfs wrangler v3 api
ankur-arch Jul 21, 2025
b4fbbe0
fix: update workflow files and remove the dependencies of CF deployme…
ankur-arch Jul 21, 2025
c9e0ee5
fix: broken git workflow action
ankur-arch Jul 21, 2025
126ccfc
fix: clean-up comment
ankur-arch Jul 21, 2025
0966507
fix: correct comment to test for GH bot
ankur-arch Jul 21, 2025
c9a1fda
chore: update versions
ankur-arch Jul 21, 2025
53d8dbc
feat: add more options to the interactive mode
ankur-arch Jul 21, 2025
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
13 changes: 13 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/cli/changelog",
{ "repo": "https://github.com/prisma/create-db" }
],
"commit": false,
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["create-db-worker", "claim-db-worker"],
"linked": [["create-db", "create-db-worker", "claim-db-worker"]]
}
122 changes: 122 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# .github/workflows/preview.yml
name: Preview deploy all Workers and CLIs

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize

env:
# each folder under the repo root that contains one of your CLIs
WORKSPACES: create-db create-pg create-postgres

jobs:
preview:
name: 🚧 Preview release (PR #${{ github.event.number }})
runs-on: ubuntu-latest

steps:
- name: 🛎️ Checkout full history
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true

- name: 🤐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV

- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: 🔧 Install dependencies
run: pnpm install

- name: ❌ Disable pnpm git-checks
run: pnpm config set git-checks false

- name: 📄 Copy README to child CLIs
run: |
for pkg in create-pg create-postgres; do
cp create-db/README.md "$pkg/README.md"
done

- name: 🔖 Create unique preview tag
run: |
echo "PRE_TAG=pr${{ github.event.number }}-${{ github.event.pull_request.head.ref }}-${{ github.run_id }}" >> $GITHUB_ENV

# — CF Worker preview deploys commented out; we will use pre-built URLs
# - name: ☁️ Deploy create-db-worker (preview)
# uses: cloudflare/wrangler-action@v3
# with:
# apiToken: ${{ secrets.CF_API_TOKEN }}
# accountId: ${{ secrets.CF_ACCOUNT_ID }}
# environment: ${{ env.PRE_TAG }}
# workingDirectory: create-db-worker
#
# - name: ☁️ Deploy claim-db-worker (preview)
# uses: cloudflare/wrangler-action@v3
# with:
# apiToken: ${{ secrets.CF_API_TOKEN }}
# accountId: ${{ secrets.CF_ACCOUNT_ID }}
# environment: ${{ env.PRE_TAG }}
# workingDirectory: claim-db-worker

- name: 🔑 Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc

- name: 🚀 Bump & publish CLI previews
env:
CREATE_DB_WORKER_URL: ${{ secrets.CREATE_DB_WORKER_URL }}
CLAIM_DB_WORKER_URL: ${{ secrets.CLAIM_DB_WORKER_URL }}
run: |
for pkg in $WORKSPACES; do
cd "$pkg"
npm version prerelease \
--preid "$PRE_TAG" \
--no-git-tag-version
pnpm publish --access public --tag pr${{ github.event.number }}
cd - >/dev/null
done

- name: 💬 Post preview-testing instructions
uses: actions/github-script@v6
env:
PRE_TAG: ${{ env.PRE_TAG }}
CREATE_DB_WORKER_URL: ${{ steps.deploy-db.outputs.deployment-url }}
CLAIM_DB_WORKER_URL: ${{ steps.deploy-claim.outputs.deployment-url }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = process.env.PRE_TAG;
const dbUrl = process.env.CREATE_DB_WORKER_URL;
const clUrl = process.env.CLAIM_DB_WORKER_URL;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: `
✅ **Preview CLIs & Workers are live!**

Test the CLIs locally under tag \`${tag}\`:

\`\`\`bash
npx create-db@${tag}
npx create-pg@${tag}
npx create-postgres@${tag}
\`\`\`

**Worker URLs**
• Create-DB Worker: ${dbUrl}
• Claim-DB Worker: ${clUrl}

> These will live as long as this PR exists under tag \`${tag}\`.`
});
- name: 🧹 Cleanup npm auth
run: rm -f ~/.npmrc
117 changes: 117 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Release all CLIs & Deploy CF Workers

on:
push:
branches:
- main

env:
# each folder under the repo root that contains one of your CLIs
WORKSPACES: create-db create-pg create-postgres

jobs:
release:
name: 🚀 Release all CLIs & workers
runs-on: ubuntu-latest

steps:
- name: 🛎️ Checkout full & tags
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true

- name: 🤐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV

- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: 🔧 Install dependencies
run: pnpm install

- name: ✔️ Check for pending changesets
run: |
pnpm changeset status --output status.json
if [ "$(jq '.changesets | length' status.json)" -eq 0 ]; then
echo "❌ No changesets found. Please run 'pnpm changeset' and add a summary." >&2
exit 1
fi
# install jq if missing
- name: 🔧 Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: 🔄 Bump versions & generate changelogs
id: bump
run: pnpm changeset version

- name: 📄 Copy README to child CLIs
run: |
for pkg in create-pg create-postgres; do
cp create-db/README.md "$pkg/README.md"
done

- name: 💾 Commit & push version bump
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# collect all bumped package@version
VERSIONS=$(jq -r '.packages | to_entries[]
| select(.value.changes != null)
| .value.name + "@" + .value.packageJSON.version'
status.json | paste -sd ', ' -)
git commit -am "chore(release): bump $VERSIONS [skip ci]" || echo "no version changes"
git push origin main --follow-tags

- name: 📑 Aggregate changelogs
run: |
echo "# Release ${{ steps.bump.outputs.newVersion }}" > AGGREGATED_CHANGELOG.md
for pkg in $WORKSPACES; do
echo "## $pkg" >> AGGREGATED_CHANGELOG.md
# pull just the section for the new version from each CHANGELOG
sed -n "/^## ${{ steps.bump.outputs.newVersion }}/,/^## /p" $pkg/CHANGELOG.md \
| sed '1d;$d' \
>> AGGREGATED_CHANGELOG.md
echo "" >> AGGREGATED_CHANGELOG.md
done

- name: 🚩 Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: v${{ steps.bump.outputs.newVersion }}
release_name: Release ${{ steps.bump.outputs.newVersion }}
body_path: AGGREGATED_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🔑 Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc

- name: 🚀 Publish all real releases
run: |
for pkg in $WORKSPACES; do
cd "$pkg"
pnpm publish --access public
cd - >/dev/null
done

# — CF production deploys commented out; we rely on existing worker URLs
# - name: ☁️ Deploy create-db-worker (production)
# uses: cloudflare/wrangler-action@v3
# with:
# apiToken: ${{ secrets.CF_API_TOKEN }}
# accountId: ${{ secrets.CF_ACCOUNT_ID }}
# workingDirectory: create-db-worker
#
# - name: ☁️ Deploy claim-db-worker (production)
# uses: cloudflare/wrangler-action@v3
# with:
# apiToken: ${{ secrets.CF_API_TOKEN }}
# accountId: ${{ secrets.CF_ACCOUNT_ID }}
# workingDirectory: claim-db-worker

- name: 🧹 Cleanup npm auth
run: rm -f ~/.npmrc
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec commitlint --edit ".git/COMMIT_EDITMSG"
6 changes: 6 additions & 0 deletions .husky/install.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Skip Husky install in production and CI
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
process.exit(0);
}
const husky = (await import("husky")).default;
console.log(husky());
4 changes: 2 additions & 2 deletions claim-db-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion claim-db-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "claim-worker",
"version": "0.0.0",
"version": "0.0.2",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
Expand Down
3 changes: 1 addition & 2 deletions claim-db-worker/worker-configuration.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: 00fcf8e66278f341b375a3636e58a563)
// Generated by Wrangler by running `wrangler types` (hash: f1ff04827a5b267b343805d7909ab04e)
// Runtime types generated with [email protected] 2025-06-28
declare namespace Cloudflare {
interface Env {
CLAIM_DB_RATE_LIMIT_KV: KVNamespace;
INTEGRATION_TOKEN: string;
CLIENT_ID: string;
CLIENT_SECRET: string;
CREATE_DB_DATASET: AnalyticsEngineDataset;
CLAIM_DB_RATE_LIMITER: RateLimit;
Expand Down
4 changes: 4 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// commitlint.config.js
module.exports = {
extends: ["@commitlint/config-conventional"],
};
4 changes: 2 additions & 2 deletions create-db-worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion create-db-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "worker",
"version": "0.0.0",
"version": "0.0.2",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
Expand Down
15 changes: 11 additions & 4 deletions create-db-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@ export { DeleteDbWorkflow };
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// --- Rate limiting ---
const { success } = await env.CREATE_DB_RATE_LIMITER.limit({ key: request.url })
const { success } = await env.CREATE_DB_RATE_LIMITER.limit({ key: request.url });

if (!success) {
return new Response(`429 Failure - rate limit exceeded for ${request.url}`, { status: 429 });
}


const url = new URL(request.url);

// --- Health check route ---
if (url.pathname === '/health' && request.method === 'GET') {
return new Response(JSON.stringify({ status: 'ok', service: 'create-db', timestamp: Date.now() }), {
status: 200,
headers: { 'Content-Type': 'application/json' },
});
}

// --- Get available regions ---
if (url.pathname === '/regions' && request.method === 'GET') {
const regionsResponse = await fetch('https://api.prisma.io/regions', {
Expand Down Expand Up @@ -64,8 +71,8 @@ export default {
const projectID = JSON.parse(prismaText).id;
await env.DELETE_DB_WORKFLOW.create({ params: { projectID } });
env.CREATE_DB_DATASET.writeDataPoint({
blobs: ["database_created"],
indexes: ["create_db"]
blobs: ['database_created'],
indexes: ['create_db'],
});
} catch (e) {
console.error('Error parsing prismaText or triggering workflow:', e);
Expand Down
3 changes: 2 additions & 1 deletion create-db-worker/worker-configuration.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: d48bd8fb2abdc865acfb1543cf121ab8)
// Generated by Wrangler by running `wrangler types` (hash: 63ac3638913b0dc240976e75200d8232)
// Runtime types generated with [email protected] 2025-06-27
declare namespace Cloudflare {
interface Env {
CREATE_DB_RATE_LIMIT_KV: KVNamespace;
INTEGRATION_TOKEN: string;
CLIENT_SECRET: string;
CREATE_DB_DATASET: AnalyticsEngineDataset;
CREATE_DB_RATE_LIMITER: RateLimit;
DELETE_DB_WORKFLOW: Workflow;
Expand Down
Loading