stack/packages/init-stack
BilalG1 6bf092af0b
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
init script: fix stack client app options , add --on-question, remove --agent-mode
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- RECURSEML_SUMMARY:START -->
## High-level PR Summary
This PR enhances the initialization script for Stack Auth by adding
support for `projectId` and `publishableClientKey` (pck) parameters when
initializing a Next.js client application. The changes include: 1)
Adding logic to pass these parameters from environment variables or
directly from arguments to the Next.js client configuration, 2) Updating
the layout template to use the client-side Stack app instead of the
server-side app in the provider component, and 3) Improving Bun lock
file detection by checking for both `bun.lockb` and `bun.lock` formats.
These changes ensure proper configuration of Next.js client applications
with the required Stack Auth credentials.

⏱️ Estimated Review Time: 5-15 minutes

<details>
<summary>💡 Review Order Suggestion</summary>

| Order | File Path |
|-------|-----------|
| 1 | `packages/init-stack/src/index.ts` |
</details>



<!-- RECURSEML_SUMMARY:END -->
<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Enhances Stack Auth init script with `projectId` and
`publishableClientKey` support, updates Next.js layout, and improves Bun
detection.
> 
>   - **Behavior**:
> - Adds `projectId` and `publishableClientKey` support to Next.js
client configuration in `index.ts`.
> - Updates layout template to use client-side Stack app in
`getUpdatedLayout()`.
>     - Improves Bun lock file detection in `promptPackageManager()`.
>   - **Options**:
> - Introduces `--on-question` option to control interactive prompts in
`index.ts`.
>   - **Scripts**:
> - Standardizes test scripts to use `--on-question error` in
`package.json`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 67a98f5aba. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- RECURSEML_ANALYSIS:START -->
## Review by RecurseML

_🔍 Review performed on
[7a0bf86..0b443e4](7a0bf86cb3...0b443e460f)_

 No bugs found, your code is sparkling clean

<details>
<summary> Files analyzed, no issues (1)</summary>

  • `packages/init-stack/src/index.ts`
</details>

[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)
<!-- RECURSEML_ANALYSIS:END -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a new --on-question option to control interactive prompt
behavior; client-oriented layout generation now emits client-side config
(public env keys supported).
* **Bug Fixes**
* Improved Bun detection (recognizes both lockfile variants) and
clearer, mode-aware guidance for ambiguous project/package-manager
detection.
* **Chores**
* Test/init scripts updated to use --on-question error for deterministic
non-interactive runs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
2025-09-25 02:16:04 +00:00
..
src init script: fix stack client app options , add --on-question, remove --agent-mode 2025-09-25 02:16:04 +00:00
.eslintrc.cjs tsup for stack-shared (#647) 2025-04-28 21:26:52 -07:00
.gitignore Support create-next-app@15 with the setup wizard (#340) 2024-11-13 13:58:42 +01:00
CHANGELOG.md chore: update package versions 2025-09-20 10:31:35 -07:00
LICENSE Setup wizard 2024-04-24 12:20:31 +02:00
package.json init script: fix stack client app options , add --on-question, remove --agent-mode 2025-09-25 02:16:04 +00:00
README.md Allows for --no-browser in Stack Auth init command (#521) 2025-03-10 04:53:36 +01:00
tsconfig.json Convert packages/init-stack to TypeScript (#465) 2025-02-25 23:02:25 +00:00
tsup.config.ts Convert packages/init-stack to TypeScript (#465) 2025-02-25 23:02:25 +00:00
vitest.config.ts In-source unit tests (#429) 2025-02-14 11:47:52 -08:00

Stack Auth Initialization Tool

This package provides a command-line tool to initialize Stack Auth in your project.

Usage

npx init-stack [project-path] [options]

Options

  • --help, -h: Show help message
  • --dry-run: Run without making any changes
  • --neon: Use Neon database
  • --js: Initialize for JavaScript project
  • --next: Initialize for Next.js project
  • --npm: Use npm as package manager
  • --yarn: Use yarn as package manager
  • --pnpm: Use pnpm as package manager
  • --bun: Use bun as package manager
  • --client: Initialize client-side only
  • --server: Initialize server-side only
  • --no-browser: Don't open browser for environment variable setup

Environment Variables

  • STACK_DISABLE_INTERACTIVE: Set to any value to disable interactive prompts. Useful for CI/CD environments.

Examples

Initialize Stack Auth in a Next.js project without opening the browser:

npx init-stack --next --no-browser

Initialize Stack Auth in a JavaScript project with npm:

npx init-stack --js --npm

For more information, please visit Stack Auth Documentation.