Skip to content

Commit fcc0b26

Browse files
committed
Init
0 parents  commit fcc0b26

130 files changed

Lines changed: 22425 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish-cli.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Release CLI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: Version strategy to publish
8+
required: true
9+
type: choice
10+
default: current
11+
options:
12+
- current
13+
- alpha
14+
- custom
15+
custom_version:
16+
description: Exact version when release_type is custom (for example 0.2.0)
17+
required: false
18+
type: string
19+
dry_run:
20+
description: Validate the release without publishing, tagging, or pushing
21+
required: false
22+
type: boolean
23+
default: false
24+
25+
concurrency:
26+
group: release-cli-main
27+
cancel-in-progress: false
28+
29+
jobs:
30+
release:
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: write
34+
id-token: write
35+
36+
steps:
37+
- name: Ensure workflow runs from main
38+
run: |
39+
if [ "${GITHUB_REF}" != "refs/heads/main" ]; then
40+
echo "This workflow only releases from main."
41+
exit 1
42+
fi
43+
44+
- uses: actions/checkout@v5
45+
with:
46+
fetch-depth: 0
47+
48+
- uses: pnpm/action-setup@v5
49+
with:
50+
version: 10.30.0
51+
52+
- uses: actions/setup-node@v6
53+
with:
54+
node-version: 24
55+
registry-url: https://registry.npmjs.org
56+
cache: pnpm
57+
58+
- name: Install dependencies
59+
run: pnpm install --frozen-lockfile
60+
61+
- name: Configure git author
62+
run: |
63+
git config user.name "github-actions[bot]"
64+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
65+
66+
- name: Bump CLI version
67+
id: cli_version
68+
env:
69+
RELEASE_TYPE: ${{ inputs.release_type }}
70+
CUSTOM_VERSION: ${{ inputs.custom_version }}
71+
run: |
72+
if [ "${RELEASE_TYPE}" = "custom" ] && [ -z "${CUSTOM_VERSION}" ]; then
73+
echo "custom_version is required when release_type=custom."
74+
exit 1
75+
fi
76+
77+
if [ "${RELEASE_TYPE}" = "current" ]; then
78+
VERSION="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('packages/cli/package.json', 'utf8')).version)")"
79+
printf 'version=%s\n' "${VERSION}" >> "$GITHUB_OUTPUT"
80+
exit 0
81+
fi
82+
83+
TARGET="prerelease --preid alpha"
84+
if [ "${RELEASE_TYPE}" = "custom" ]; then
85+
TARGET="${CUSTOM_VERSION}"
86+
fi
87+
88+
npm --prefix packages/cli version ${TARGET} --no-git-tag-version >/dev/null
89+
VERSION="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync('packages/cli/package.json', 'utf8')).version)")"
90+
printf 'version=%s\n' "${VERSION}" >> "$GITHUB_OUTPUT"
91+
92+
- name: Fail if version already exists on npm
93+
run: |
94+
PACKAGE='@prisma/cli'
95+
VERSION='${{ steps.cli_version.outputs.version }}'
96+
if npm view "${PACKAGE}@${VERSION}" version >/dev/null 2>&1; then
97+
echo "${PACKAGE}@${VERSION} already exists on npm."
98+
exit 1
99+
fi
100+
101+
- name: Run focused CLI tests
102+
run: pnpm --filter @prisma/cli test
103+
104+
- name: Build CLI package
105+
run: pnpm --filter @prisma/cli build
106+
107+
- name: Prepare staged publish package
108+
run: node scripts/prepare-cli-publish.mjs .publish/cli
109+
110+
- name: Audit staged package contents
111+
working-directory: .publish/cli
112+
run: |
113+
PACK_JSON="$(npm pack --dry-run --json)"
114+
PACK_JSON="${PACK_JSON}" node -e "
115+
const pack = JSON.parse(process.env.PACK_JSON)[0]
116+
const files = pack.files.map((file) => file.path).sort()
117+
const forbidden = files.filter((file) =>
118+
file.startsWith('src/') ||
119+
file.startsWith('tests/') ||
120+
file.startsWith('fixtures/') ||
121+
file.startsWith('docs/') ||
122+
file.startsWith('.prisma/') ||
123+
file.startsWith('.publish/')
124+
)
125+
if (forbidden.length) {
126+
console.error('Forbidden files in npm package:', forbidden.join(', '))
127+
process.exit(1)
128+
}
129+
for (const required of ['dist/cli.js', 'README.md', 'LICENSE', 'package.json']) {
130+
if (!files.includes(required)) {
131+
console.error('Missing required package file:', required)
132+
process.exit(1)
133+
}
134+
}
135+
"
136+
137+
- name: Smoke test staged tarball install
138+
run: |
139+
TARBALL="$(cd .publish/cli && npm pack --silent)"
140+
TMPDIR="$(mktemp -d)"
141+
cat > "${TMPDIR}/package.json" <<'EOF'
142+
{
143+
"name": "cli-publish-smoke",
144+
"private": true
145+
}
146+
EOF
147+
pnpm add -D "${PWD}/.publish/cli/${TARBALL}" --dir "${TMPDIR}"
148+
(
149+
cd "${TMPDIR}"
150+
pnpm prisma-cli --help
151+
pnpm prisma-cli auth whoami --json
152+
)
153+
154+
- name: Ensure release still targets the latest main
155+
if: ${{ !inputs.dry_run }}
156+
run: |
157+
git fetch origin main
158+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
159+
echo "main moved while the release was running. Rerun the workflow from the latest main."
160+
exit 1
161+
fi
162+
163+
- name: Publish to npm
164+
if: ${{ !inputs.dry_run }}
165+
working-directory: .publish/cli
166+
run: npm publish --access public --tag preview --provenance
167+
168+
- name: Commit release version
169+
if: ${{ !inputs.dry_run }}
170+
run: |
171+
VERSION='${{ steps.cli_version.outputs.version }}'
172+
git add packages/cli/package.json
173+
if ! git diff --cached --quiet; then
174+
git commit -m "chore(cli): release @prisma/cli v${VERSION}"
175+
fi
176+
git tag "cli-v${VERSION}"
177+
178+
- name: Push release commit and tag
179+
if: ${{ !inputs.dry_run }}
180+
run: |
181+
VERSION='${{ steps.cli_version.outputs.version }}'
182+
git push origin HEAD:main
183+
git push origin "cli-v${VERSION}"
184+
185+
- name: Summarize release
186+
run: |
187+
VERSION='${{ steps.cli_version.outputs.version }}'
188+
{
189+
echo "## Release CLI"
190+
echo
191+
echo "- Version: \`${VERSION}\`"
192+
echo "- Dry run: \`${{ inputs.dry_run }}\`"
193+
if [ '${{ inputs.dry_run }}' = 'true' ]; then
194+
echo "- Publish: skipped"
195+
echo "- Tag/push: skipped"
196+
else
197+
echo "- npm package: \`@prisma/cli@${VERSION}\`"
198+
echo "- npm dist-tag: \`preview\`"
199+
echo "- git tag: \`cli-v${VERSION}\`"
200+
fi
201+
} >> "$GITHUB_STEP_SUMMARY"

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Local CLI state
5+
.prisma/
6+
packages/*/.prisma/
7+
/prisma.config.ts
8+
tmp/
9+
10+
# Build and test output
11+
dist/
12+
.publish/
13+
coverage/
14+
.vitest/
15+
*.tsbuildinfo
16+
17+
# Logs
18+
*.log
19+
pnpm-debug.log*
20+
npm-debug.log*
21+
22+
# Environment files
23+
.env
24+
.env.local
25+
.env.*.local
26+
27+
# Editor and OS files
28+
.DS_Store
29+
.idea/
30+
.vscode/

AGENTS.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# AGENTS.md
2+
3+
## Purpose
4+
5+
This repo uses document-driven development for the new Prisma CLI.
6+
7+
The docs in `docs/product` are the source of truth. Do not invent product behavior in code that is not already grounded in those docs. If behavior is unclear or missing, update docs first.
8+
9+
## What This CLI Is
10+
11+
- This is the future unified Prisma CLI.
12+
- The first implementation slice is app deployment workflows, but the command model must preserve the long-term CLI for ORM, Postgres, and app workflows.
13+
14+
## Read These First
15+
16+
Start with `docs/README.md` for the public docs index.
17+
18+
1. `docs/product/resource-model.md`
19+
2. `docs/product/command-principles.md`
20+
3. `docs/product/command-spec.md`
21+
4. `docs/product/cli-style-guide.md`
22+
5. `docs/product/output-conventions.md`
23+
6. `docs/product/error-conventions.md`
24+
25+
Architecture and contributor workflow references:
26+
27+
- `ARCHITECTURE.md`
28+
- `docs/architecture/overview.md`
29+
- `docs/onboarding/getting-started.md`
30+
- `docs/onboarding/common-tasks.md`
31+
- `docs/onboarding/testing.md`
32+
33+
## Non-Negotiable Product Rules
34+
35+
- Group commands by developer workflow, not product ownership.
36+
- No `orm`, `postgres`, or `compute` namespaces in the command surface.
37+
- Canonical command shape is `prisma <group> <action>`.
38+
- The current preview uses only `auth`, `project`, `branch`, and `app`.
39+
- Preserve the long-term resource model:
40+
- `workspace -> project -> branch -> { app, database }`
41+
42+
For exact definitions and resolution rules, see `resource-model.md` and `command-spec.md`.
43+
44+
## Branch Model
45+
46+
Do not redefine this casually:
47+
48+
- everything under a project happens in a branch
49+
- `local` is local CLI context only, not a branch or deploy target
50+
- `production` is a protected durable branch
51+
- every other named branch is preview by default
52+
- preview branches are disposable by default
53+
- non-production branches can become durable later
54+
- first remote deploy defaults to preview
55+
- production is reached by `app promote` or explicit user targeting
56+
57+
See:
58+
59+
- `docs/product/resource-model.md`
60+
- `docs/product/command-spec.md`
61+
62+
## Output and Error Behavior
63+
64+
Before changing CLI UX, read:
65+
66+
- `docs/product/cli-style-guide.md`
67+
- `docs/product/output-conventions.md`
68+
- `docs/product/error-conventions.md`
69+
70+
Important themes:
71+
72+
- stdout is for machine-readable data
73+
- stderr is for human-oriented status and decoration
74+
- `--json` is explicit
75+
- non-TTY and non-interactive behavior must stay automation-friendly
76+
- structured error codes are the branching surface for agents and CI
77+
78+
## When Making Changes
79+
80+
- Prefer tightening existing docs over adding new surface area.
81+
- Keep nouns and verbs stable across docs, help, output, and code.
82+
- Do not add shortcuts or aliases as canonical forms.
83+
- Do not let the current app preview introduce abstractions that will block later ORM/Postgres integration.
84+
- If docs conflict, resolve the docs rather than guessing in implementation.
85+
86+
## Default Agent Workflow
87+
88+
1. Read the product docs above.
89+
2. Identify the relevant source-of-truth doc for the task.
90+
3. If implementation requires undefined behavior, update docs first.
91+
4. Keep changes aligned with the unified CLI direction, not just the current app slice.

ARCHITECTURE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Architecture
2+
3+
This repository contains the public preview implementation of the unified Prisma
4+
CLI.
5+
6+
The canonical architecture docs live under `docs/architecture`:
7+
8+
- [Architecture overview](docs/architecture/overview.md)
9+
- [Package structure](docs/architecture/package-structure.md)
10+
- [Architecture decisions](docs/architecture/adrs/README.md)
11+
12+
Product behavior is defined separately in `docs/product`. If architecture and
13+
product docs appear to disagree, update the product docs first and make the
14+
implementation follow them.
15+
16+
## Implementation Shape
17+
18+
The CLI is organized around a thin command layer and documented product rules:
19+
20+
- command modules define grammar, arguments, flags, and help text
21+
- controllers orchestrate command-specific flows
22+
- use cases enforce documented behavior and resource resolution
23+
- adapters isolate local state, config, auth, and platform boundaries
24+
- presenters and shell helpers own human and JSON output
25+
26+
This shape keeps the current app-focused preview small while preserving the
27+
long-term unified model for projects, branches, schemas, databases, and apps.
28+
29+
## Contribution Rule
30+
31+
Do not add new command behavior from architecture intuition alone. Start with
32+
the relevant product doc, then update the implementation and tests.

0 commit comments

Comments
 (0)