@stackframe/init-stack 2.8.36 → 2.8.40

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @stackframe/init-stack
2
2
 
3
+ ## 2.8.40
4
+
5
+ ### Patch Changes
6
+
7
+ - Various changes
8
+ - Updated dependencies
9
+ - @stackframe/stack-shared@2.8.40
10
+
11
+ ## 2.8.39
12
+
13
+ ### Patch Changes
14
+
15
+ - Various changes
16
+ - Updated dependencies
17
+ - @stackframe/stack-shared@2.8.39
18
+
19
+ ## 2.8.38
20
+
21
+ ### Patch Changes
22
+
23
+ - Various changes
24
+ - Updated dependencies
25
+ - @stackframe/stack-shared@2.8.38
26
+
27
+ ## 2.8.37
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies
32
+ - @stackframe/stack-shared@2.8.37
33
+
3
34
  ## 2.8.36
4
35
 
5
36
  ### Patch Changes
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { PostHog } from "posthog-node";
14
14
  // package.json
15
15
  var package_default = {
16
16
  name: "@stackframe/init-stack",
17
- version: "2.8.36",
17
+ version: "2.8.40",
18
18
  description: "The setup wizard for Stack. https://stack-auth.com",
19
19
  main: "dist/index.js",
20
20
  type: "module",
@@ -26,19 +26,23 @@ var package_default = {
26
26
  lint: "eslint --ext .tsx,.ts .",
27
27
  typecheck: "tsc --noEmit",
28
28
  "init-stack": "node dist/index.js",
29
- "init-stack:local": "STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js node dist/index.js",
29
+ "init-stack:local": "STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE=../../react node dist/index.js",
30
30
  "test-run": "pnpm run build && pnpm run test-run-js && pnpm run test-run-node && pnpm run test-run-next && pnpm run test-run-neon && pnpm run test-run-no-browser",
31
31
  "test-run:manual": "pnpm run build && pnpm run test-run-js:manual && pnpm run test-run-node:manual && pnpm run test-run-next:manual && pnpm run test-run-neon:manual",
32
32
  "ensure-neon": `grep -q '"@neondatabase/serverless"' ./test-run-output/package.json && echo 'Initialized Neon successfully!'`,
33
33
  "test-run-neon": "pnpm run test-run-node --neon && pnpm run ensure-neon",
34
34
  "test-run-neon:manual": "pnpm run test-run-node:manual --neon && pnpm run ensure-neon",
35
- "test-run-no-browser": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm --no-browser",
35
+ "test-run-no-browser": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser",
36
36
  "test-run-node:manual": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init && cd .. && pnpm run init-stack:local test-run-output",
37
- "test-run-node": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm",
37
+ "test-run-node": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser",
38
38
  "test-run-js:manual": "rimraf test-run-output && npx -y sv create test-run-output --no-install && pnpm run init-stack:local test-run-output",
39
- "test-run-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --client --npm",
39
+ "test-run-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --no-browser",
40
40
  "test-run-next:manual": "rimraf test-run-output && npx -y create-next-app@latest test-run-output && pnpm run init-stack:local test-run-output",
41
- "test-run-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output"
41
+ "test-run-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --no-browser",
42
+ "test-run-keys-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --project-id my-project-id --publishable-client-key my-publishable-client-key",
43
+ "test-run-keys-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --project-id my-project-id --publishable-client-key my-publishable-client-key",
44
+ "test-run-react": "rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --on-question error --no-browser --npm",
45
+ "test-run-react:manual": "rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --react"
42
46
  },
43
47
  files: [
44
48
  "README.md",
@@ -81,25 +85,60 @@ var jsLikeFileExtensions = [
81
85
  "cjs",
82
86
  "js"
83
87
  ];
88
+ var UserError = class extends Error {
89
+ constructor(message) {
90
+ super(message);
91
+ this.name = "UserError";
92
+ }
93
+ };
94
+ var UnansweredQuestionError = class extends UserError {
95
+ constructor(message) {
96
+ super(message + ", or use --on-question <guess|ask> to answer questions automatically or interactively");
97
+ this.name = "UnansweredQuestionError";
98
+ }
99
+ };
100
+ function isTruthyEnv(name) {
101
+ const v = process.env[name];
102
+ if (!v) return false;
103
+ const s = String(v).toLowerCase();
104
+ return s === "1" || s === "true" || s === "yes";
105
+ }
106
+ function isNonInteractiveEnv() {
107
+ if (isTruthyEnv("CI")) return true;
108
+ if (isTruthyEnv("GITHUB_ACTIONS")) return true;
109
+ if (isTruthyEnv("NONINTERACTIVE")) return true;
110
+ if (isTruthyEnv("NO_INTERACTIVE")) return true;
111
+ if (isTruthyEnv("PNPM_NON_INTERACTIVE")) return true;
112
+ if (isTruthyEnv("YARN_ENABLE_NON_INTERACTIVE")) return true;
113
+ if (isTruthyEnv("CURSOR_AGENT")) return true;
114
+ if (isTruthyEnv("CLAUDECODE")) return true;
115
+ return false;
116
+ }
117
+ function resolveOnQuestionMode(opt) {
118
+ if (!opt || opt === "default") {
119
+ return isNonInteractiveEnv() ? "error" : "ask";
120
+ }
121
+ if (opt === "ask" || opt === "guess" || opt === "error") {
122
+ return opt;
123
+ }
124
+ throw new UserError(`Invalid argument for --on-question: "${opt}". Valid modes are: "ask", "guess", "error", "default".`);
125
+ }
84
126
  var program = new Command();
85
- program.name(package_default.name).description("Stack Auth Initialization Tool").version(package_default.version).argument("[project-path]", "Path to your project").usage(`[project-path] [options]`).option("--dry-run", "Run without making any changes").option("--neon", "Use Neon database").option("--js", "Initialize for JavaScript project").option("--next", "Initialize for Next.js project").option("--npm", "Use npm as package manager").option("--yarn", "Use yarn as package manager").option("--pnpm", "Use pnpm as package manager").option("--bun", "Use bun as package manager").option("--client", "Initialize client-side only").option("--server", "Initialize server-side only").option("--no-browser", "Don't open browser for environment variable setup").addHelpText("after", `
127
+ program.name(package_default.name).description("Stack Auth Initialization Tool").version(package_default.version).argument("[project-path]", "Path to your project").usage(`[project-path] [options]`).option("--dry-run", "Run without making any changes").option("--neon", "Use Neon database").option("--js", "Initialize for JavaScript project").option("--next", "Initialize for Next.js project").option("--react", "Initialize for React project").option("--npm", "Use npm as package manager").option("--yarn", "Use yarn as package manager").option("--pnpm", "Use pnpm as package manager").option("--bun", "Use bun as package manager").option("--client", "Initialize client-side only").option("--server", "Initialize server-side only").option("--project-id <project-id>", "Project ID to use in setup").option("--publishable-client-key <publishable-client-key>", "Publishable client key to use in setup").option("--no-browser", "Don't open browser for environment variable setup").option("--on-question <mode>", "How to handle interactive questions: ask | guess | error | default", "default").addHelpText("after", `
86
128
  For more information, please visit https://docs.stack-auth.com/getting-started/setup`);
87
129
  program.parse();
88
130
  var options = program.opts();
89
131
  var savedProjectPath = program.args[0] || void 0;
90
132
  var isDryRun = options.dryRun || false;
91
133
  var isNeon = options.neon || false;
92
- var typeFromArgs = options.js ? "js" : options.next ? "next" : void 0;
134
+ var typeFromArgs = options.js ? "js" : options.next ? "next" : options.react ? "react" : void 0;
93
135
  var packageManagerFromArgs = options.npm ? "npm" : options.yarn ? "yarn" : options.pnpm ? "pnpm" : options.bun ? "bun" : void 0;
94
136
  var isClient = options.client || false;
95
137
  var isServer = options.server || false;
138
+ var projectIdFromArgs = options.projectId;
139
+ var publishableClientKeyFromArgs = options.publishableClientKey;
140
+ var onQuestionMode = resolveOnQuestionMode(options.onQuestion);
96
141
  var noBrowser = !options.browser;
97
- var UserError = class extends Error {
98
- constructor(message) {
99
- super(message);
100
- this.name = "UserError";
101
- }
102
- };
103
142
  var ansis = {
104
143
  red: "\x1B[31m",
105
144
  blue: "\x1B[34m",
@@ -183,11 +222,25 @@ async function main() {
183
222
  if (type === "next") {
184
223
  const projectInfo = await Steps.getNextProjectInfo({ packageJson: projectPackageJson });
185
224
  await Steps.updateNextLayoutFile(projectInfo);
225
+ await Steps.writeStackAppFile(projectInfo, "client");
186
226
  await Steps.writeStackAppFile(projectInfo, "server");
187
227
  await Steps.writeNextHandlerFile(projectInfo);
188
228
  await Steps.writeNextLoadingFile(projectInfo);
189
229
  nextSteps.push(`Copy the environment variables from the new API key into your .env.local file`);
190
- } else if (type === "js") {
230
+ } else if (type === "react") {
231
+ const defaultExtension = await Steps.guessDefaultFileExtension();
232
+ const srcPath = await Steps.guessSrcPath();
233
+ const hasReactRouterDom = !!(projectPackageJson.dependencies?.["react-router-dom"] || projectPackageJson.devDependencies?.["react-router-dom"]);
234
+ const { fileName } = await Steps.writeReactClientFile({
235
+ srcPath,
236
+ defaultExtension,
237
+ indentation: " ",
238
+ hasReactRouterDom
239
+ });
240
+ nextSteps.push(
241
+ `Copy the environment variables from the new API key into your own environment and reference them in ${fileName}`
242
+ );
243
+ } else {
191
244
  const defaultExtension = await Steps.guessDefaultFileExtension();
192
245
  const where = await Steps.getServerOrClientOrBoth();
193
246
  const srcPath = await Steps.guessSrcPath();
@@ -205,8 +258,6 @@ async function main() {
205
258
  `Copy the environment variables from the new API key into your own environment and reference them in ${appFiles.join(" and ")}`,
206
259
  `Follow the instructions on how to use Stack Auth's vanilla SDK at http://docs.stack-auth.com/others/js-client`
207
260
  );
208
- } else {
209
- throw new Error("Unknown type: " + type);
210
261
  }
211
262
  const { packageManager } = await Steps.getPackageManager();
212
263
  await capture(`package-manager-selected`, {
@@ -216,8 +267,15 @@ async function main() {
216
267
  await Steps.ensureReady(type);
217
268
  console.log();
218
269
  console.log(colorize.bold`Installing dependencies...`);
219
- const installCommand = packageManager === "yarn" ? "yarn add" : `${packageManager} install`;
220
- await shellNicelyFormatted(`${installCommand} ${packagesToInstall.join(" ")}`, {
270
+ const installCommandMap = /* @__PURE__ */ new Map([
271
+ ["npm", "npm install"],
272
+ ["yarn", "yarn add"],
273
+ ["pnpm", "pnpm add"],
274
+ ["bun", "bun add"]
275
+ ]);
276
+ const installCommand = installCommandMap.get(packageManager) ?? `${packageManager} install`;
277
+ const safePackages = packagesToInstall.map((p) => JSON.stringify(p));
278
+ await shellNicelyFormatted(`${installCommand} ${safePackages.join(" ")}`, {
221
279
  shell: true,
222
280
  cwd: projectPath
223
281
  });
@@ -274,7 +332,7 @@ ${colorize.bold`Next steps:`}
274
332
 
275
333
  For more information, please visit https://docs.stack-auth.com/getting-started/setup
276
334
  `.trim());
277
- if (!process.env.STACK_DISABLE_INTERACTIVE && !noBrowser) {
335
+ if (!noBrowser) {
278
336
  await open(`https://app.stack-auth.com/wizard-congrats?stack-init-id=${encodeURIComponent(distinctId)}`);
279
337
  }
280
338
  await ph_client.shutdown();
@@ -337,7 +395,18 @@ var Steps = {
337
395
  async getProjectType({ packageJson }) {
338
396
  if (typeFromArgs) return typeFromArgs;
339
397
  const maybeNextProject = await Steps.maybeGetNextProjectInfo({ packageJson });
340
- if (!("error" in maybeNextProject)) return "next";
398
+ if (!("error" in maybeNextProject)) {
399
+ return "next";
400
+ }
401
+ if (packageJson.dependencies?.["react"] || packageJson.dependencies?.["react-dom"]) {
402
+ return "react";
403
+ }
404
+ if (onQuestionMode === "guess") {
405
+ return "js";
406
+ }
407
+ if (onQuestionMode === "error") {
408
+ throw new UnansweredQuestionError("Unable to auto-detect project type (checked for Next.js and React dependencies). Re-run with one of: --js, --react, or --next.");
409
+ }
341
410
  const { type } = await inquirer.prompt([
342
411
  {
343
412
  type: "list",
@@ -345,6 +414,7 @@ var Steps = {
345
414
  message: "Which integration would you like to install?",
346
415
  choices: [
347
416
  { name: "None (vanilla JS, Node.js, etc)", value: "js" },
417
+ { name: "React", value: "react" },
348
418
  { name: "Next.js", value: "next" }
349
419
  ]
350
420
  }
@@ -352,10 +422,12 @@ var Steps = {
352
422
  return type;
353
423
  },
354
424
  async getStackPackageName(type, install = false) {
355
- return {
356
- "js": install && process.env.STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE || "@stackframe/js",
357
- "next": install && process.env.STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE || "@stackframe/stack"
358
- }[type] ?? throwErr("Unknown type in addStackPackage: " + type);
425
+ const mapping = {
426
+ js: install && process.env.STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE || "@stackframe/js",
427
+ next: install && process.env.STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE || "@stackframe/stack",
428
+ react: install && process.env.STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE || "@stackframe/react"
429
+ };
430
+ return mapping[type];
359
431
  },
360
432
  async addStackPackage(type) {
361
433
  packagesToInstall.push(await Steps.getStackPackageName(type, true));
@@ -412,7 +484,20 @@ Only Next.js 14 & 15 projects are currently supported. See Next's upgrade guide:
412
484
  envLocalPath
413
485
  ];
414
486
  if (potentialEnvLocations.every((p) => !fs.existsSync(p))) {
415
- const envContent = noBrowser ? "# Stack Auth keys\n# To get these variables:\n# 1. Go to https://app.stack-auth.com\n# 2. Create a new project\n# 3. Copy the keys below\nNEXT_PUBLIC_STACK_PROJECT_ID=\nNEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\nSTACK_SECRET_SERVER_KEY=\n" : "# Stack Auth keys\n# Get these variables by creating a project on https://app.stack-auth.com.\nNEXT_PUBLIC_STACK_PROJECT_ID=\nNEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\nSTACK_SECRET_SERVER_KEY=\n";
487
+ const envContent = noBrowser ? `# Stack Auth keys
488
+ # To get these variables:
489
+ # 1. Go to https://app.stack-auth.com
490
+ # 2. Create a new project
491
+ # 3. Copy the keys below
492
+ NEXT_PUBLIC_STACK_PROJECT_ID="${projectIdFromArgs ?? ""}"
493
+ NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY="${publishableClientKeyFromArgs ?? ""}"
494
+ STACK_SECRET_SERVER_KEY=
495
+ ` : `# Stack Auth keys
496
+ # Get these variables by creating a project on https://app.stack-auth.com.
497
+ NEXT_PUBLIC_STACK_PROJECT_ID="${projectIdFromArgs ?? ""}"
498
+ NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY="${publishableClientKeyFromArgs ?? ""}"
499
+ STACK_SECRET_SERVER_KEY=
500
+ `;
416
501
  laterWriteFile(envLocalPath, envContent);
417
502
  return true;
418
503
  }
@@ -446,11 +531,8 @@ Only Next.js 14 & 15 projects are currently supported. See Next's upgrade guide:
446
531
  const clientOrServerCap = {
447
532
  client: "Client",
448
533
  server: "Server"
449
- }[clientOrServer] ?? throwErr("unknown clientOrServer " + clientOrServer);
450
- const relativeStackAppPath = {
451
- js: `stack/${clientOrServer}`,
452
- next: "stack"
453
- }[type] ?? throwErr("unknown type");
534
+ }[clientOrServer];
535
+ const relativeStackAppPath = `stack/${clientOrServer}`;
454
536
  const stackAppPathWithoutExtension = path.join(srcPath, relativeStackAppPath);
455
537
  const stackAppFileExtension = await findJsExtension(stackAppPathWithoutExtension) ?? defaultExtension;
456
538
  const stackAppPath = stackAppPathWithoutExtension + "." + stackAppFileExtension;
@@ -458,31 +540,81 @@ Only Next.js 14 & 15 projects are currently supported. See Next's upgrade guide:
458
540
  if (stackAppContent) {
459
541
  if (!stackAppContent.includes("@stackframe/")) {
460
542
  throw new UserError(
461
- `A file at the path ${stackAppPath} already exists. Stack uses the stack.ts file to initialize the Stack SDK. Please remove the existing file and try again.`
543
+ `A file at the path ${stackAppPath} already exists. Stack uses the stack/${clientOrServer}.ts file to initialize the Stack SDK. Please remove the existing file and try again.`
462
544
  );
463
545
  }
464
546
  throw new UserError(
465
547
  `It seems that you already installed Stack in this project.`
466
548
  );
467
549
  }
550
+ const tokenStore = type === "next" ? '"nextjs-cookie"' : clientOrServer === "client" ? '"cookie"' : '"memory"';
551
+ const publishableClientKeyWrite = clientOrServer === "server" ? `process.env.STACK_PUBLISHABLE_CLIENT_KEY ${publishableClientKeyFromArgs ? `|| ${JSON.stringify(publishableClientKeyFromArgs)}` : ""}` : `'${publishableClientKeyFromArgs ?? "INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE"}'`;
552
+ const jsOptions = type === "js" ? [
553
+ `
554
+
555
+ ${indentation}// get your Stack Auth API keys from https://app.stack-auth.com${clientOrServer === "client" ? ` and store them in a safe place (eg. environment variables)` : ""}`,
556
+ `${projectIdFromArgs ? `${indentation}projectId: ${JSON.stringify(projectIdFromArgs)},` : ""}`,
557
+ `${indentation}publishableClientKey: ${publishableClientKeyWrite},`,
558
+ `${clientOrServer === "server" ? `${indentation}secretServerKey: process.env.STACK_SECRET_SERVER_KEY,` : ""}`
559
+ ].filter(Boolean).join("\n") : "";
560
+ const nextClientOptions = type === "next" && clientOrServer === "client" ? (() => {
561
+ const lines = [
562
+ projectIdFromArgs ? `${indentation}projectId: process.env.NEXT_PUBLIC_STACK_PROJECT_ID ?? ${JSON.stringify(projectIdFromArgs)},` : "",
563
+ publishableClientKeyFromArgs ? `${indentation}publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY ?? ${JSON.stringify(publishableClientKeyFromArgs)},` : ""
564
+ ].filter(Boolean).join("\n");
565
+ return lines ? `
566
+ ${lines}` : "";
567
+ })() : "";
468
568
  laterWriteFileIfNotExists(
469
569
  stackAppPath,
470
570
  `
471
- ${type === "next" ? `import "server-only";` : ""}
571
+ ${type === "next" && clientOrServer === "server" ? `import "server-only";` : ""}
472
572
 
473
573
  import { Stack${clientOrServerCap}App } from ${JSON.stringify(packageName)};
474
574
 
475
575
  export const stack${clientOrServerCap}App = new Stack${clientOrServerCap}App({
476
- ${indentation}tokenStore: ${type === "next" ? '"nextjs-cookie"' : clientOrServer === "client" ? '"cookie"' : '"memory"'},${type === "js" ? `
477
-
478
- ${indentation}// get your Stack Auth API keys from https://app.stack-auth.com${clientOrServer === "client" ? ` and store them in a safe place (eg. environment variables)` : ""}` : ""}${type === "js" ? `
479
- ${indentation}publishableClientKey: ${clientOrServer === "server" ? "process.env.STACK_PUBLISHABLE_CLIENT_KEY" : "INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE"},` : ""}${type === "js" && clientOrServer === "server" ? `
480
- ${indentation}secretServerKey: process.env.STACK_SECRET_SERVER_KEY,` : ""}
576
+ ${indentation}tokenStore: ${tokenStore},${jsOptions}${nextClientOptions}
481
577
  });
482
578
  `.trim() + "\n"
483
579
  );
484
580
  return { fileName: stackAppPath };
485
581
  },
582
+ async writeReactClientFile({ srcPath, defaultExtension, indentation, hasReactRouterDom }) {
583
+ const packageName = await Steps.getStackPackageName("react");
584
+ const relativeStackAppPath = `stack/client`;
585
+ const stackAppPathWithoutExtension = path.join(srcPath, relativeStackAppPath);
586
+ const stackAppFileExtension = await findJsExtension(stackAppPathWithoutExtension) ?? defaultExtension;
587
+ const stackAppPath = stackAppPathWithoutExtension + "." + stackAppFileExtension;
588
+ const stackAppContent = await readFile(stackAppPath);
589
+ if (stackAppContent) {
590
+ if (!stackAppContent.includes("@stackframe/")) {
591
+ throw new UserError(`A file at the path ${stackAppPath} already exists. Stack uses the stack/client.ts file to initialize the Stack SDK. Please remove the existing file and try again.`);
592
+ }
593
+ throw new UserError(`It seems that you already installed Stack in this project.`);
594
+ }
595
+ const publishableClientKeyWrite = `'${publishableClientKeyFromArgs ?? "INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE"}'`;
596
+ const projectIdWrite = `'${projectIdFromArgs ?? "INSERT_PROJECT_ID"}'`;
597
+ const imports = hasReactRouterDom ? `import { StackClientApp } from ${JSON.stringify(packageName)};
598
+ import { useNavigate } from "react-router-dom";
599
+
600
+ ` : `import { StackClientApp } from ${JSON.stringify(packageName)};
601
+
602
+ `;
603
+ const redirectMethod = hasReactRouterDom ? `,
604
+ ${indentation}redirectMethod: {
605
+ ${indentation}${indentation}useNavigate,
606
+ ${indentation}}` : "";
607
+ laterWriteFileIfNotExists(
608
+ stackAppPath,
609
+ `${imports}export const stackClientApp = new StackClientApp({
610
+ ${indentation}tokenStore: "cookie",
611
+ ${indentation}projectId: ${projectIdWrite},
612
+ ${indentation}publishableClientKey: ${publishableClientKeyWrite}${redirectMethod},
613
+ });
614
+ `
615
+ );
616
+ return { fileName: stackAppPath };
617
+ },
486
618
  async writeNextHandlerFile(projectInfo) {
487
619
  const handlerPathWithoutExtension = path.join(
488
620
  projectInfo.appPath,
@@ -493,17 +625,17 @@ ${indentation}secretServerKey: process.env.STACK_SECRET_SERVER_KEY,` : ""}
493
625
  const handlerContent = await readFile(handlerPath);
494
626
  if (handlerContent && !handlerContent.includes("@stackframe/")) {
495
627
  throw new UserError(
496
- `A file at the path ${handlerPath} already exists. Stack uses the /handler path to handle incoming requests. Please remove the existing file and try again.`
628
+ `A file at the path ${handlerPath} already exists.Stack uses the / handler path to handle incoming requests.Please remove the existing file and try again.`
497
629
  );
498
630
  }
499
631
  laterWriteFileIfNotExists(
500
632
  handlerPath,
501
- `import { StackHandler } from "@stackframe/stack";
502
- import { stackServerApp } from "../../../stack";
633
+ `import { StackHandler } from "@stackframe/stack";
634
+ import { stackServerApp } from "../../../stack/server";
503
635
 
504
- export default function Handler(props${handlerFileExtension.includes("ts") ? ": unknown" : ""}) {
505
- ${projectInfo.indentation}return <StackHandler fullPage app={stackServerApp} routeProps={props} />;
506
- }
636
+ export default function Handler(props${handlerFileExtension.includes("ts") ? ": unknown" : ""}) {
637
+ ${projectInfo.indentation} return <StackHandler fullPage app = { stackServerApp } routeProps = { props } />;
638
+ }
507
639
  `
508
640
  );
509
641
  },
@@ -514,6 +646,7 @@ ${projectInfo.indentation}return <StackHandler fullPage app={stackServerApp} rou
514
646
  laterWriteFileIfNotExists(
515
647
  loadingPath,
516
648
  `export default function Loading() {
649
+
517
650
  ${projectInfo.indentation}// Stack uses React Suspense, which will render this page while user data is being fetched.
518
651
  ${projectInfo.indentation}// See: https://nextjs.org/docs/app/api-reference/file-conventions/loading
519
652
  ${projectInfo.indentation}return <></>;
@@ -537,11 +670,13 @@ ${projectInfo.indentation}return <></>;
537
670
  },
538
671
  async ensureReady(type) {
539
672
  const projectPath = await getProjectPath();
540
- const typeString = {
673
+ const typeStringMap = {
541
674
  js: "JavaScript",
542
- next: "Next.js"
543
- }[type] ?? throwErr("unknown type");
544
- const isReady = !!process.env.STACK_DISABLE_INTERACTIVE || (await inquirer.prompt([
675
+ next: "Next.js",
676
+ react: "React"
677
+ };
678
+ const typeString = typeStringMap[type];
679
+ const isReady = onQuestionMode !== "ask" || (await inquirer.prompt([
545
680
  {
546
681
  type: "confirm",
547
682
  name: "ready",
@@ -557,6 +692,10 @@ ${projectInfo.indentation}return <></>;
557
692
  if (isClient && isServer) return ["server", "client"];
558
693
  if (isServer) return ["server"];
559
694
  if (isClient) return ["client"];
695
+ if (onQuestionMode === "guess") return ["server", "client"];
696
+ if (onQuestionMode === "error") {
697
+ throw new UnansweredQuestionError("Ambiguous installation type. Re-run with --server, --client, or both.");
698
+ }
560
699
  return (await inquirer.prompt([{
561
700
  type: "list",
562
701
  name: "type",
@@ -598,7 +737,7 @@ async function getUpdatedLayout(originalLayout) {
598
737
  const importInsertLocationM1 = firstImportLocationM1 ?? (hasStringAsFirstLine ? layout.indexOf("\n") : -1);
599
738
  const importInsertLocation = importInsertLocationM1 + 1;
600
739
  const importStatement = `import { StackProvider, StackTheme } from "@stackframe/stack";
601
- import { stackServerApp } from "../stack";
740
+ import { stackClientApp } from "../stack/client";
602
741
  `;
603
742
  layout = layout.slice(0, importInsertLocation) + importStatement + layout.slice(importInsertLocation);
604
743
  const bodyOpenTag = /<\s*body[^>]*>/.exec(layout);
@@ -620,7 +759,7 @@ import { stackServerApp } from "../stack";
620
759
  lines,
621
760
  bodyCloseStartIndex
622
761
  );
623
- const insertOpen = "<StackProvider app={stackServerApp}><StackTheme>";
762
+ const insertOpen = "<StackProvider app={stackClientApp}><StackTheme>";
624
763
  const insertClose = "</StackTheme></StackProvider>";
625
764
  layout = layout.slice(0, bodyCloseStartIndex) + insertClose + layout.slice(bodyCloseStartIndex);
626
765
  layout = layout.slice(0, bodyOpenEndIndex) + insertOpen + layout.slice(bodyOpenEndIndex);
@@ -660,6 +799,9 @@ async function getProjectPath() {
660
799
  path.join(savedProjectPath, "package.json")
661
800
  );
662
801
  if (askForPathModification) {
802
+ if (onQuestionMode === "guess" || onQuestionMode === "error") {
803
+ throw new UserError(`No package.json file found in ${savedProjectPath}. Re-run providing the project path argument (e.g. 'init-stack <project-path>').`);
804
+ }
663
805
  savedProjectPath = (await inquirer.prompt([
664
806
  {
665
807
  type: "input",
@@ -686,7 +828,7 @@ async function promptPackageManager() {
686
828
  const yarnLock = fs.existsSync(path.join(projectPath, "yarn.lock"));
687
829
  const pnpmLock = fs.existsSync(path.join(projectPath, "pnpm-lock.yaml"));
688
830
  const npmLock = fs.existsSync(path.join(projectPath, "package-lock.json"));
689
- const bunLock = fs.existsSync(path.join(projectPath, "bun.lockb"));
831
+ const bunLock = fs.existsSync(path.join(projectPath, "bun.lockb")) || fs.existsSync(path.join(projectPath, "bun.lock"));
690
832
  if (yarnLock && !pnpmLock && !npmLock && !bunLock) {
691
833
  return "yarn";
692
834
  } else if (!yarnLock && pnpmLock && !npmLock && !bunLock) {
@@ -696,6 +838,10 @@ async function promptPackageManager() {
696
838
  } else if (!yarnLock && !pnpmLock && !npmLock && bunLock) {
697
839
  return "bun";
698
840
  }
841
+ if (onQuestionMode === "guess") return "npm";
842
+ if (onQuestionMode === "error") {
843
+ throw new UnansweredQuestionError("Unable to determine the package manager. Re-run with one of: --npm, --yarn, --pnpm, or --bun.");
844
+ }
699
845
  const answers = await inquirer.prompt([
700
846
  {
701
847
  type: "list",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import * as child_process from \"child_process\";\nimport { Command } from \"commander\";\nimport * as crypto from 'crypto';\nimport * as fs from \"fs\";\nimport inquirer from \"inquirer\";\nimport open from \"open\";\nimport * as os from 'os';\nimport * as path from \"path\";\nimport { PostHog } from 'posthog-node';\nimport packageJson from '../package.json';\n\nconst jsLikeFileExtensions: string[] = [\n \"mtsx\",\n \"ctsx\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"ts\",\n \"mjsx\",\n \"cjsx\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n \"js\",\n];\n\n// Setup command line parsing\nconst program = new Command();\nprogram\n .name(packageJson.name)\n .description(\"Stack Auth Initialization Tool\")\n .version(packageJson.version)\n .argument(\"[project-path]\", \"Path to your project\")\n .usage(`[project-path] [options]`)\n .option(\"--dry-run\", \"Run without making any changes\")\n .option(\"--neon\", \"Use Neon database\")\n .option(\"--js\", \"Initialize for JavaScript project\")\n .option(\"--next\", \"Initialize for Next.js project\")\n .option(\"--npm\", \"Use npm as package manager\")\n .option(\"--yarn\", \"Use yarn as package manager\")\n .option(\"--pnpm\", \"Use pnpm as package manager\")\n .option(\"--bun\", \"Use bun as package manager\")\n .option(\"--client\", \"Initialize client-side only\")\n .option(\"--server\", \"Initialize server-side only\")\n .option(\"--no-browser\", \"Don't open browser for environment variable setup\")\n .addHelpText('after', `\nFor more information, please visit https://docs.stack-auth.com/getting-started/setup`);\n\nprogram.parse();\n\nconst options = program.opts();\n\n// Keep existing variables but assign from Commander\nlet savedProjectPath: string | undefined = program.args[0] || undefined;\nconst isDryRun: boolean = options.dryRun || false;\nconst isNeon: boolean = options.neon || false;\nconst typeFromArgs: string | undefined = options.js ? \"js\" : options.next ? \"next\" : undefined;\nconst packageManagerFromArgs: string | undefined = options.npm ? \"npm\" : options.yarn ? \"yarn\" : options.pnpm ? \"pnpm\" : options.bun ? \"bun\" : undefined;\nconst isClient: boolean = options.client || false;\nconst isServer: boolean = options.server || false;\n// Commander negates the boolean options with prefix `--no-`\n// so `--no-browser` becomes `browser: false`\nconst noBrowser: boolean = !options.browser;\n\nclass UserError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UserError\";\n }\n}\n\ntype Ansis = {\n red: string,\n blue: string,\n green: string,\n yellow: string,\n clear: string,\n bold: string,\n};\n\nconst ansis: Ansis = {\n red: \"\\x1b[31m\",\n blue: \"\\x1b[34m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n\n clear: \"\\x1b[0m\",\n bold: \"\\x1b[1m\",\n};\n\ntype TemplateFunction = (strings: TemplateStringsArray, ...values: any[]) => string;\n\ntype Colorize = {\n red: TemplateFunction,\n blue: TemplateFunction,\n green: TemplateFunction,\n yellow: TemplateFunction,\n bold: TemplateFunction,\n};\n\nconst colorize: Colorize = {\n red: (strings, ...values) => ansis.red + templateIdentity(strings, ...values) + ansis.clear,\n blue: (strings, ...values) => ansis.blue + templateIdentity(strings, ...values) + ansis.clear,\n green: (strings, ...values) => ansis.green + templateIdentity(strings, ...values) + ansis.clear,\n yellow: (strings, ...values) => ansis.yellow + templateIdentity(strings, ...values) + ansis.clear,\n bold: (strings, ...values) => ansis.bold + templateIdentity(strings, ...values) + ansis.clear,\n};\n\nconst filesCreated: string[] = [];\nconst filesModified: string[] = [];\nconst commandsExecuted: string[] = [];\n\nconst packagesToInstall: string[] = [];\nconst writeFileHandlers: Array<() => Promise<void>> = [];\nconst nextSteps: string[] = [\n `Create an account and Stack Auth API key for your project on https://app.stack-auth.com`,\n];\n\n\nconst STACK_AUTH_PUBLIC_HOG_KEY = \"phc_vIUFi0HzHo7oV26OsaZbUASqxvs8qOmap1UBYAutU4k\";\nconst EVENT_PREFIX = \"stack-init-\";\nconst ph_client = new PostHog(STACK_AUTH_PUBLIC_HOG_KEY, {\n host: \"https://eu.i.posthog.com\",\n flushAt: 1,\n flushInterval: 0,\n});\nconst distinctId = crypto.randomUUID();\n\n\nasync function capture(event: string, properties: Record<string, any>) {\n ph_client.capture({\n event: `${EVENT_PREFIX}${event}`,\n distinctId,\n properties,\n });\n}\n\n\nasync function main(): Promise<void> {\n // Welcome message\n console.log();\n console.log(`\n ██████\n ██████████████\n████████████████████\n████████████████████ WELCOME TO\n█████████████████ ╔═╗╔╦╗╔═╗╔═╗╦╔═ ┌─┐┬ ┬┌┬┐┬ ┬\n█████████████ ╚═╗ ║ ╠═╣║ ╠╩╗ ├─┤│ │ │ ├─┤\n█████████████ ████ ╚═╝ ╩ ╩ ╩╚═╝╩ ╩ ┴ ┴└─┘ ┴ ┴ ┴\n █████████████████\n ██████ ██\n████ ████\n █████ █████\n ██████\n `);\n console.log();\n\n await capture(\"start\", {\n version: packageJson.version,\n isDryRun,\n isNeon,\n typeFromArgs,\n packageManagerFromArgs,\n isClient,\n isServer,\n noBrowser,\n platform: os.platform(),\n arch: os.arch(),\n nodeVersion: process.version,\n });\n\n // Wait just briefly so we can use `Steps` in here (it's defined only after the call to `main()`)\n await new Promise<void>((resolve) => resolve());\n\n\n // Prepare some stuff\n await clearStdin();\n const projectPath = await getProjectPath();\n\n\n // Steps\n const { packageJson: projectPackageJson } = await Steps.getProject();\n const type = await Steps.getProjectType({ packageJson: projectPackageJson });\n\n await capture(\"project-type-selected\", {\n type,\n wasSpecifiedInArgs: !!typeFromArgs,\n });\n\n await Steps.addStackPackage(type);\n if (isNeon) packagesToInstall.push('@neondatabase/serverless');\n\n await Steps.writeEnvVars(type);\n\n if (type === \"next\") {\n const projectInfo = await Steps.getNextProjectInfo({ packageJson: projectPackageJson });\n await Steps.updateNextLayoutFile(projectInfo);\n await Steps.writeStackAppFile(projectInfo, \"server\");\n await Steps.writeNextHandlerFile(projectInfo);\n await Steps.writeNextLoadingFile(projectInfo);\n nextSteps.push(`Copy the environment variables from the new API key into your .env.local file`);\n } else if (type === \"js\") {\n const defaultExtension = await Steps.guessDefaultFileExtension();\n const where = await Steps.getServerOrClientOrBoth();\n const srcPath = await Steps.guessSrcPath();\n const appFiles: string[] = [];\n for (const w of where) {\n const { fileName } = await Steps.writeStackAppFile({\n type,\n defaultExtension,\n indentation: \" \",\n srcPath,\n }, w);\n appFiles.push(fileName);\n }\n nextSteps.push(\n `Copy the environment variables from the new API key into your own environment and reference them in ${appFiles.join(\" and \")}`,\n `Follow the instructions on how to use Stack Auth's vanilla SDK at http://docs.stack-auth.com/others/js-client`,\n );\n } else {\n throw new Error(\"Unknown type: \" + type);\n }\n\n const { packageManager } = await Steps.getPackageManager();\n\n await capture(`package-manager-selected`, {\n packageManager,\n wasSpecifiedInArgs: !!packageManagerFromArgs,\n });\n\n await Steps.ensureReady(type);\n\n\n // Install dependencies\n console.log();\n console.log(colorize.bold`Installing dependencies...`);\n const installCommand = packageManager === \"yarn\" ? \"yarn add\" : `${packageManager} install`;\n await shellNicelyFormatted(`${installCommand} ${packagesToInstall.join(' ')}`, {\n shell: true,\n cwd: projectPath,\n });\n\n await capture(`dependencies-installed`, {\n packageManager,\n packages: packagesToInstall,\n });\n\n // Write files\n console.log();\n console.log(colorize.bold`Writing files...`);\n console.log();\n for (const writeFileHandler of writeFileHandlers) {\n await writeFileHandler();\n }\n console.log(`${colorize.green`√`} Done writing files`);\n\n console.log('\\n\\n\\n');\n console.log(colorize.bold`${colorize.green`Installation succeeded!`}`);\n console.log();\n console.log(\"Commands executed:\");\n for (const command of commandsExecuted) {\n console.log(` ${colorize.blue`${command}`}`);\n }\n console.log();\n console.log(\"Files written:\");\n for (const file of filesModified) {\n console.log(` ${colorize.yellow`${file}`}`);\n }\n for (const file of filesCreated) {\n console.log(` ${colorize.green`${file}`}`);\n }\n console.log();\n\n await capture(\"complete\", {\n success: true,\n type,\n packageManager,\n isNeon,\n isClient,\n isServer,\n noBrowser,\n filesCreated,\n filesModified,\n commandsExecuted,\n });\n\n // Success!\n console.log(`\n${colorize.green`===============================================`}\n\n${colorize.green`Successfully installed Stack! 🚀🚀🚀`}\n\n${colorize.bold`Next steps:`}\n\n1. ${noBrowser ?\n `Create a project at https://app.stack-auth.com and get your API keys` :\n `Complete the setup in your browser to get your API keys`}\n2. Add the API keys to your .env.local file\n3. Import the Stack components in your app\n4. Add authentication to your app\n\nFor more information, please visit https://docs.stack-auth.com/getting-started/setup\n `.trim());\n if (!process.env.STACK_DISABLE_INTERACTIVE && !noBrowser) {\n await open(`https://app.stack-auth.com/wizard-congrats?stack-init-id=${encodeURIComponent(distinctId)}`);\n }\n await ph_client.shutdown();\n}\n\n// eslint-disable-next-line no-restricted-syntax\nmain().catch(async (err) => {\n try {\n await capture(\"error\", {\n error: err.message,\n errorType: err instanceof UserError ? \"UserError\" : \"SystemError\",\n stack: err.stack,\n });\n } catch (e) { }\n if (!(err instanceof UserError)) {\n console.error(err);\n }\n console.error('\\n\\n\\n\\n');\n console.log(colorize.red`===============================================`);\n console.error();\n if (err instanceof UserError) {\n console.error(`${colorize.red`ERROR!`} ${err.message}`);\n } else {\n console.error(\"An error occurred during the initialization process.\");\n }\n console.error();\n console.log(colorize.red`===============================================`);\n console.error();\n console.error(\n \"If you need assistance, please try installing Stack manually as described in https://docs.stack-auth.com/getting-started/setup or join our Discord where we're happy to help: https://discord.stack-auth.com\"\n );\n if (!(err instanceof UserError)) {\n console.error(\"\");\n console.error(`Error message: ${err.message}`);\n }\n console.error();\n await ph_client.shutdown();\n process.exit(1);\n});\n\n\ntype PackageJson = {\n dependencies?: Record<string, string>,\n devDependencies?: Record<string, string>,\n [key: string]: any,\n}\n\ntype ProjectInfo = {\n type: string,\n srcPath: string,\n appPath: string,\n defaultExtension: string,\n indentation: string,\n}\n\ntype NextProjectInfoError = {\n error: string,\n}\n\ntype NextProjectInfoResult = ProjectInfo | NextProjectInfoError;\n\ntype StackAppFileOptions = {\n type: string,\n srcPath: string,\n defaultExtension: string,\n indentation: string,\n}\n\ntype StackAppFileResult = {\n fileName: string,\n}\n\nconst Steps = {\n async getProject(): Promise<{ packageJson: PackageJson }> {\n let projectPath = await getProjectPath();\n if (!fs.existsSync(projectPath)) {\n throw new UserError(`The project path ${projectPath} does not exist`);\n }\n\n const packageJsonPath = path.join(projectPath, \"package.json\");\n if (!fs.existsSync(packageJsonPath)) {\n throw new UserError(\n `The package.json file does not exist in the project path ${projectPath}. You must initialize a new project first before installing Stack.`\n );\n }\n\n const packageJsonText = fs.readFileSync(packageJsonPath, \"utf-8\");\n let packageJson: PackageJson;\n try {\n packageJson = JSON.parse(packageJsonText);\n } catch (e) {\n throw new UserError(`package.json file is not valid JSON: ${e}`);\n }\n\n return { packageJson };\n },\n\n async getProjectType({ packageJson }: { packageJson: PackageJson }): Promise<string> {\n if (typeFromArgs) return typeFromArgs;\n\n const maybeNextProject = await Steps.maybeGetNextProjectInfo({ packageJson });\n if (!(\"error\" in maybeNextProject)) return \"next\";\n\n const { type } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"type\",\n message: \"Which integration would you like to install?\",\n choices: [\n { name: \"None (vanilla JS, Node.js, etc)\", value: \"js\" },\n { name: \"Next.js\", value: \"next\" },\n ]\n }\n ]);\n\n return type;\n },\n\n async getStackPackageName(type: string, install = false): Promise<string> {\n return {\n \"js\": (install && process.env.STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE) || \"@stackframe/js\",\n \"next\": (install && process.env.STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE) || \"@stackframe/stack\",\n }[type] ?? throwErr(\"Unknown type in addStackPackage: \" + type);\n },\n\n async addStackPackage(type: string): Promise<void> {\n packagesToInstall.push(await Steps.getStackPackageName(type, true));\n },\n\n async getNextProjectInfo({ packageJson }: { packageJson: PackageJson }): Promise<ProjectInfo> {\n const maybe = await Steps.maybeGetNextProjectInfo({ packageJson });\n if (\"error\" in maybe) throw new UserError(maybe.error);\n return maybe;\n },\n\n async maybeGetNextProjectInfo({ packageJson }: { packageJson: PackageJson }): Promise<NextProjectInfoResult> {\n const projectPath = await getProjectPath();\n\n const nextVersionInPackageJson = packageJson.dependencies?.[\"next\"] ?? packageJson.devDependencies?.[\"next\"];\n if (!nextVersionInPackageJson) {\n return { error: `The project at ${projectPath} does not appear to be a Next.js project, or does not have 'next' installed as a dependency.` };\n }\n if (\n !nextVersionInPackageJson.includes(\"14\") &&\n !nextVersionInPackageJson.includes(\"15\") &&\n nextVersionInPackageJson !== \"latest\"\n ) {\n return { error: `The project at ${projectPath} is using an unsupported version of Next.js (found ${nextVersionInPackageJson}).\\n\\nOnly Next.js 14 & 15 projects are currently supported. See Next's upgrade guide: https://nextjs.org/docs/app/building-your-application/upgrading/version-14` };\n }\n\n const nextConfigPathWithoutExtension = path.join(projectPath, \"next.config\");\n const nextConfigFileExtension = await findJsExtension(\n nextConfigPathWithoutExtension\n );\n const nextConfigPath =\n nextConfigPathWithoutExtension + \".\" + (nextConfigFileExtension ?? \"js\");\n if (!fs.existsSync(nextConfigPath)) {\n return { error: `Expected file at ${nextConfigPath}. Only Next.js projects are currently supported.` };\n }\n\n const hasSrcAppFolder = fs.existsSync(path.join(projectPath, \"src/app\"));\n const srcPath = path.join(projectPath, hasSrcAppFolder ? \"src\" : \"\");\n const appPath = path.join(srcPath, \"app\");\n if (!fs.existsSync(appPath)) {\n return { error: `The app path ${appPath} does not exist. Only the Next.js app router is supported.` };\n }\n\n const dryUpdateNextLayoutFileResult = await Steps.dryUpdateNextLayoutFile({ appPath, defaultExtension: \"jsx\" });\n\n return {\n type: \"next\",\n srcPath,\n appPath,\n defaultExtension: dryUpdateNextLayoutFileResult.fileExtension,\n indentation: dryUpdateNextLayoutFileResult.indentation,\n };\n },\n\n async writeEnvVars(type: string): Promise<boolean> {\n const projectPath = await getProjectPath();\n\n // TODO: in non-Next environments, ask the user what method they prefer for envvars\n if (type !== \"next\") return false;\n\n const envLocalPath = path.join(projectPath, \".env.local\");\n\n const potentialEnvLocations = [\n path.join(projectPath, \".env\"),\n path.join(projectPath, \".env.development\"),\n path.join(projectPath, \".env.default\"),\n path.join(projectPath, \".env.defaults\"),\n path.join(projectPath, \".env.example\"),\n envLocalPath,\n ];\n if (potentialEnvLocations.every((p) => !fs.existsSync(p))) {\n const envContent = noBrowser\n ? \"# Stack Auth keys\\n\" +\n \"# To get these variables:\\n\" +\n \"# 1. Go to https://app.stack-auth.com\\n\" +\n \"# 2. Create a new project\\n\" +\n \"# 3. Copy the keys below\\n\" +\n \"NEXT_PUBLIC_STACK_PROJECT_ID=\\n\" +\n \"NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\\n\" +\n \"STACK_SECRET_SERVER_KEY=\\n\"\n : \"# Stack Auth keys\\n\" +\n \"# Get these variables by creating a project on https://app.stack-auth.com.\\n\" +\n \"NEXT_PUBLIC_STACK_PROJECT_ID=\\n\" +\n \"NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\\n\" +\n \"STACK_SECRET_SERVER_KEY=\\n\";\n\n laterWriteFile(envLocalPath, envContent);\n return true;\n }\n\n return false;\n },\n\n async dryUpdateNextLayoutFile({ appPath, defaultExtension }: { appPath: string, defaultExtension: string }): Promise<{\n path: string,\n updatedContent: string,\n fileExtension: string,\n indentation: string,\n }> {\n const layoutPathWithoutExtension = path.join(appPath, \"layout\");\n const layoutFileExtension =\n (await findJsExtension(layoutPathWithoutExtension)) ?? defaultExtension;\n const layoutPath = layoutPathWithoutExtension + \".\" + layoutFileExtension;\n const layoutContent =\n (await readFile(layoutPath)) ??\n throwErr(\n `The layout file at ${layoutPath} does not exist. Stack requires a layout file to be present in the /app folder.`\n );\n const updatedLayoutResult =\n (await getUpdatedLayout(layoutContent)) ??\n throwErr(\n \"Unable to parse root layout file. Make sure it contains a <body> tag. If it still doesn't work, you may need to manually install Stack. See: https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#root-layout-required\"\n );\n const updatedLayoutContent = updatedLayoutResult.content;\n return {\n path: layoutPath,\n updatedContent: updatedLayoutContent,\n fileExtension: layoutFileExtension,\n indentation: updatedLayoutResult.indentation\n };\n },\n\n async updateNextLayoutFile(projectInfo: ProjectInfo): Promise<{\n path: string,\n updatedContent: string,\n fileExtension: string,\n indentation: string,\n }> {\n const res = await Steps.dryUpdateNextLayoutFile(projectInfo);\n laterWriteFile(res.path, res.updatedContent);\n return res;\n },\n\n async writeStackAppFile({ type, srcPath, defaultExtension, indentation }: StackAppFileOptions, clientOrServer: string): Promise<StackAppFileResult> {\n const packageName = await Steps.getStackPackageName(type);\n\n const clientOrServerCap = {\n client: \"Client\",\n server: \"Server\",\n }[clientOrServer] ?? throwErr(\"unknown clientOrServer \" + clientOrServer);\n\n const relativeStackAppPath = {\n js: `stack/${clientOrServer}`,\n next: \"stack\",\n }[type] ?? throwErr(\"unknown type\");\n\n const stackAppPathWithoutExtension = path.join(srcPath, relativeStackAppPath);\n const stackAppFileExtension =\n (await findJsExtension(stackAppPathWithoutExtension)) ?? defaultExtension;\n const stackAppPath =\n stackAppPathWithoutExtension + \".\" + stackAppFileExtension;\n const stackAppContent = await readFile(stackAppPath);\n if (stackAppContent) {\n if (!stackAppContent.includes(\"@stackframe/\")) {\n throw new UserError(\n `A file at the path ${stackAppPath} already exists. Stack uses the stack.ts file to initialize the Stack SDK. Please remove the existing file and try again.`\n );\n }\n throw new UserError(\n `It seems that you already installed Stack in this project.`\n );\n }\n laterWriteFileIfNotExists(\n stackAppPath,\n `\n${type === \"next\" ? `import \"server-only\";` : \"\"}\n\nimport { Stack${clientOrServerCap}App } from ${JSON.stringify(packageName)};\n\nexport const stack${clientOrServerCap}App = new Stack${clientOrServerCap}App({\n${indentation}tokenStore: ${type === \"next\" ? '\"nextjs-cookie\"' : (clientOrServer === \"client\" ? '\"cookie\"' : '\"memory\"')},${\ntype === \"js\" ? `\\n\\n${indentation}// get your Stack Auth API keys from https://app.stack-auth.com${clientOrServer === \"client\" ? ` and store them in a safe place (eg. environment variables)` : \"\"}` : \"\"}${\ntype === \"js\" ? `\\n${indentation}publishableClientKey: ${clientOrServer === \"server\" ? 'process.env.STACK_PUBLISHABLE_CLIENT_KEY' : 'INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE'},` : \"\"}${\ntype === \"js\" && clientOrServer === \"server\" ? `\\n${indentation}secretServerKey: process.env.STACK_SECRET_SERVER_KEY,` : \"\"}\n});\n `.trim() + \"\\n\"\n );\n return { fileName: stackAppPath };\n },\n\n async writeNextHandlerFile(projectInfo: ProjectInfo): Promise<void> {\n const handlerPathWithoutExtension = path.join(\n projectInfo.appPath,\n \"handler/[...stack]/page\"\n );\n const handlerFileExtension =\n (await findJsExtension(handlerPathWithoutExtension)) ?? projectInfo.defaultExtension;\n const handlerPath = handlerPathWithoutExtension + \".\" + handlerFileExtension;\n const handlerContent = await readFile(handlerPath);\n if (handlerContent && !handlerContent.includes(\"@stackframe/\")) {\n throw new UserError(\n `A file at the path ${handlerPath} already exists. Stack uses the /handler path to handle incoming requests. Please remove the existing file and try again.`\n );\n }\n laterWriteFileIfNotExists(\n handlerPath,\n `import { StackHandler } from \"@stackframe/stack\";\\nimport { stackServerApp } from \"../../../stack\";\\n\\nexport default function Handler(props${\n handlerFileExtension.includes(\"ts\") ? \": unknown\" : \"\"\n }) {\\n${projectInfo.indentation}return <StackHandler fullPage app={stackServerApp} routeProps={props} />;\\n}\\n`\n );\n },\n\n async writeNextLoadingFile(projectInfo: ProjectInfo): Promise<void> {\n let loadingPathWithoutExtension = path.join(projectInfo.appPath, \"loading\");\n const loadingFileExtension =\n (await findJsExtension(loadingPathWithoutExtension)) ?? projectInfo.defaultExtension;\n const loadingPath = loadingPathWithoutExtension + \".\" + loadingFileExtension;\n laterWriteFileIfNotExists(\n loadingPath,\n `export default function Loading() {\\n${projectInfo.indentation}// Stack uses React Suspense, which will render this page while user data is being fetched.\\n${projectInfo.indentation}// See: https://nextjs.org/docs/app/api-reference/file-conventions/loading\\n${projectInfo.indentation}return <></>;\\n}\\n`\n );\n },\n\n async getPackageManager(): Promise<{ packageManager: string }> {\n if (packageManagerFromArgs) return { packageManager: packageManagerFromArgs };\n const packageManager = await promptPackageManager();\n const versionCommand = `${packageManager} --version`;\n\n try {\n await shellNicelyFormatted(versionCommand, { shell: true, quiet: true });\n } catch (err) {\n console.error(err);\n throw new UserError(\n `Could not run the package manager command '${versionCommand}'. Please make sure ${packageManager} is installed on your system.`\n );\n }\n\n return { packageManager };\n },\n\n async ensureReady(type: string): Promise<void> {\n const projectPath = await getProjectPath();\n\n const typeString = {\n js: \"JavaScript\",\n next: \"Next.js\"\n }[type] ?? throwErr(\"unknown type\");\n const isReady = !!process.env.STACK_DISABLE_INTERACTIVE || (await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"ready\",\n message: `Found a ${typeString} project at ${projectPath} — ready to install Stack Auth?`,\n default: true,\n },\n ])).ready;\n if (!isReady) {\n throw new UserError(\"Installation aborted.\");\n }\n },\n\n async getServerOrClientOrBoth(): Promise<string[]> {\n if (isClient && isServer) return [\"server\", \"client\"];\n if (isServer) return [\"server\"];\n if (isClient) return [\"client\"];\n\n return (await inquirer.prompt([{\n type: \"list\",\n name: \"type\",\n message: \"Do you want to use Stack Auth on the server, or on the client?\",\n choices: [\n { name: \"Client (eg. Vite, HTML)\", value: [\"client\"] },\n { name: \"Server (eg. Node.js)\", value: [\"server\"] },\n { name: \"Both\", value: [\"server\", \"client\"] }\n ]\n }])).type;\n },\n\n /**\n * note: this is a heuristic, specific frameworks may have better heuristics (eg. the Next.js code uses the extension of the global layout file)\n */\n async guessDefaultFileExtension(): Promise<string> {\n const projectPath = await getProjectPath();\n const hasTsConfig = fs.existsSync(\n path.join(projectPath, \"tsconfig.json\")\n );\n return hasTsConfig ? \"ts\" : \"js\";\n },\n\n /**\n * note: this is a heuristic, specific frameworks may have better heuristics (eg. the Next.js code uses the location of the app folder)\n */\n async guessSrcPath(): Promise<string> {\n const projectPath = await getProjectPath();\n const potentialSrcPath = path.join(projectPath, \"src\");\n const hasSrcFolder = fs.existsSync(\n path.join(projectPath, \"src\")\n );\n return hasSrcFolder ? potentialSrcPath : projectPath;\n },\n\n\n};\n\n\ntype LayoutResult = {\n content: string,\n indentation: string,\n}\n\nasync function getUpdatedLayout(originalLayout: string): Promise<LayoutResult | undefined> {\n let layout = originalLayout;\n const indentation = guessIndentation(originalLayout);\n\n const firstImportLocationM1 = /\\simport\\s/.exec(layout)?.index;\n const hasStringAsFirstLine = layout.startsWith('\"') || layout.startsWith(\"'\");\n const importInsertLocationM1 =\n firstImportLocationM1 ?? (hasStringAsFirstLine ? layout.indexOf(\"\\n\") : -1);\n const importInsertLocation = importInsertLocationM1 + 1;\n const importStatement = `import { StackProvider, StackTheme } from \"@stackframe/stack\";\\nimport { stackServerApp } from \"../stack\";\\n`;\n layout =\n layout.slice(0, importInsertLocation) +\n importStatement +\n layout.slice(importInsertLocation);\n\n const bodyOpenTag = /<\\s*body[^>]*>/.exec(layout);\n const bodyCloseTag = /<\\s*\\/\\s*body[^>]*>/.exec(layout);\n if (!bodyOpenTag || !bodyCloseTag) {\n return undefined;\n }\n const bodyOpenEndIndex = bodyOpenTag.index + bodyOpenTag[0].length;\n const bodyCloseStartIndex = bodyCloseTag.index;\n if (bodyCloseStartIndex <= bodyOpenEndIndex) {\n return undefined;\n }\n\n const lines = layout.split(\"\\n\");\n const [bodyOpenEndLine, bodyOpenEndIndexInLine] = getLineIndex(\n lines,\n bodyOpenEndIndex\n );\n const [bodyCloseStartLine, bodyCloseStartIndexInLine] = getLineIndex(\n lines,\n bodyCloseStartIndex\n );\n\n const insertOpen = \"<StackProvider app={stackServerApp}><StackTheme>\";\n const insertClose = \"</StackTheme></StackProvider>\";\n\n layout =\n layout.slice(0, bodyCloseStartIndex) +\n insertClose +\n layout.slice(bodyCloseStartIndex);\n layout =\n layout.slice(0, bodyOpenEndIndex) +\n insertOpen +\n layout.slice(bodyOpenEndIndex);\n\n return {\n content: `${layout}`,\n indentation,\n };\n}\n\nfunction guessIndentation(str: string): string {\n const lines = str.split(\"\\n\");\n const linesLeadingWhitespaces = lines\n .map((line) => line.match(/^\\s*/)![0])\n .filter((ws) => ws.length > 0);\n const isMostlyTabs =\n linesLeadingWhitespaces.filter((ws) => ws.includes(\"\\t\")).length >=\n (linesLeadingWhitespaces.length * 2) / 3;\n if (isMostlyTabs) return \"\\t\";\n const linesLeadingWhitespacesCount = linesLeadingWhitespaces.map(\n (ws) => ws.length\n );\n const min = Math.min(Infinity, ...linesLeadingWhitespacesCount);\n return Number.isFinite(min) ? \" \".repeat(Math.max(2, min)) : \" \";\n}\n\nfunction getLineIndex(lines: string[], stringIndex: number): [number, number] {\n let lineIndex = 0;\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n if (stringIndex < lineIndex + line.length) {\n return [l, stringIndex - lineIndex];\n }\n lineIndex += line.length + 1;\n }\n throw new Error(\n `Index ${stringIndex} is out of bounds for lines ${JSON.stringify(lines)}`\n );\n}\n\nasync function getProjectPath(): Promise<string> {\n if (savedProjectPath === undefined) {\n savedProjectPath = process.cwd();\n\n const askForPathModification = !fs.existsSync(\n path.join(savedProjectPath, \"package.json\")\n );\n if (askForPathModification) {\n savedProjectPath = (\n await inquirer.prompt([\n {\n type: \"input\",\n name: \"newPath\",\n message: \"Please enter the path to your project:\",\n default: \".\",\n },\n ])\n ).newPath;\n }\n }\n return savedProjectPath as string;\n}\n\nasync function findJsExtension(fullPathWithoutExtension: string): Promise<string | null> {\n for (const ext of jsLikeFileExtensions) {\n const fullPath = fullPathWithoutExtension + \".\" + ext;\n if (fs.existsSync(fullPath)) {\n return ext;\n }\n }\n return null;\n}\n\nasync function promptPackageManager(): Promise<string> {\n const projectPath = await getProjectPath();\n const yarnLock = fs.existsSync(path.join(projectPath, \"yarn.lock\"));\n const pnpmLock = fs.existsSync(path.join(projectPath, \"pnpm-lock.yaml\"));\n const npmLock = fs.existsSync(path.join(projectPath, \"package-lock.json\"));\n const bunLock = fs.existsSync(path.join(projectPath, \"bun.lockb\"));\n\n if (yarnLock && !pnpmLock && !npmLock && !bunLock) {\n return \"yarn\";\n } else if (!yarnLock && pnpmLock && !npmLock && !bunLock) {\n return \"pnpm\";\n } else if (!yarnLock && !pnpmLock && npmLock && !bunLock) {\n return \"npm\";\n } else if (!yarnLock && !pnpmLock && !npmLock && bunLock) {\n return \"bun\";\n }\n\n const answers = await inquirer.prompt([\n {\n type: \"list\",\n name: \"packageManager\",\n message: \"Which package manager are you using for this project?\",\n choices: [\"npm\", \"yarn\", \"pnpm\", \"bun\"],\n },\n ]);\n return answers.packageManager;\n}\n\ntype ShellOptions = {\n quiet?: boolean,\n shell?: boolean,\n cwd?: string,\n [key: string]: any,\n}\n\nasync function shellNicelyFormatted(command: string, { quiet, ...options }: ShellOptions): Promise<void> {\n let ui: any;\n let interval: NodeJS.Timeout | undefined;\n if (!quiet) {\n console.log();\n ui = new inquirer.ui.BottomBar();\n let dots = 4;\n ui.updateBottomBar(\n colorize.blue`Running command: ${command}...`\n );\n interval = setInterval(() => {\n if (!isDryRun) {\n ui.updateBottomBar(\n colorize.blue`Running command: ${command}${\".\".repeat(dots++ % 5)}`\n );\n }\n }, 700);\n }\n\n try {\n if (!isDryRun) {\n const child = child_process.spawn(command, options);\n if (!quiet) {\n child.stdout.pipe(ui.log);\n child.stderr.pipe(ui.log);\n }\n\n await new Promise<void>((resolve, reject) => {\n child.on(\"exit\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`Command ${command} failed with code ${code}`));\n }\n });\n });\n } else {\n console.log(`[DRY-RUN] Would have run: ${command}`);\n }\n\n if (!quiet) {\n commandsExecuted.push(command);\n ui.updateBottomBar(\n `${colorize.green`√`} Command ${command} succeeded\\n`\n );\n }\n } catch (e) {\n if (!quiet) {\n ui.updateBottomBar(\n `${colorize.red`X`} Command ${command} failed\\n`\n );\n }\n throw e;\n } finally {\n if (interval) {\n clearTimeout(interval);\n }\n if (!quiet) {\n ui.close();\n }\n }\n}\n\nasync function readFile(fullPath: string): Promise<string | null> {\n try {\n if (!isDryRun) {\n return fs.readFileSync(fullPath, \"utf-8\");\n }\n return null;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n return null;\n }\n throw err;\n }\n}\n\nasync function writeFile(fullPath: string, content: string): Promise<void> {\n let create = !fs.existsSync(fullPath);\n if (!isDryRun) {\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content);\n } else {\n console.log(`[DRY-RUN] Would have written to ${fullPath}`);\n }\n const relativeToProjectPath = path.relative(await getProjectPath(), fullPath);\n if (!create) {\n filesModified.push(relativeToProjectPath);\n } else {\n filesCreated.push(relativeToProjectPath);\n }\n}\n\nfunction laterWriteFile(fullPath: string, content: string): void {\n writeFileHandlers.push(async () => {\n await writeFile(fullPath, content);\n });\n}\n\nasync function writeFileIfNotExists(fullPath: string, content: string): Promise<void> {\n if (!fs.existsSync(fullPath)) {\n await writeFile(fullPath, content);\n }\n}\n\nfunction laterWriteFileIfNotExists(fullPath: string, content: string): void {\n writeFileHandlers.push(async () => {\n await writeFileIfNotExists(fullPath, content);\n });\n}\n\nfunction assertInteractive(): true {\n if (process.env.STACK_DISABLE_INTERACTIVE) {\n throw new UserError(\"STACK_DISABLE_INTERACTIVE is set, but wizard requires interactivity to complete. Make sure you supplied all required command line arguments!\");\n }\n return true;\n}\n\nfunction throwErr(message: string): never {\n throw new Error(message);\n}\n\n// TODO import this function from stack-shared instead (but that would require us to fix the build to let us import it)\nexport function templateIdentity(strings: TemplateStringsArray, ...values: any[]): string {\n if (strings.length === 0) return \"\";\n if (values.length !== strings.length - 1) throw new Error(\"Invalid number of values; must be one less than strings\");\n\n return strings.slice(1).reduce((result, string, i) => `${result}${values[i] ?? \"n/a\"}${string}`, strings[0]);\n}\n\nasync function clearStdin(): Promise<void> {\n await new Promise<void>((resolve) => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n }\n process.stdin.resume();\n process.stdin.removeAllListeners('data');\n\n const flush = () => {\n while (process.stdin.read() !== null) {}\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n resolve();\n };\n\n // Add a small delay to allow any buffered input to clear\n setTimeout(flush, 10);\n });\n}\n","{\n \"name\": \"@stackframe/init-stack\",\n \"version\": \"2.8.36\",\n \"description\": \"The setup wizard for Stack. https://stack-auth.com\",\n \"main\": \"dist/index.js\",\n \"type\": \"module\",\n \"bin\": \"./dist/index.js\",\n \"scripts\": {\n \"clean\": \"rimraf test-run-output && rimraf node_modules && rimraf dist\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint --ext .tsx,.ts .\",\n \"typecheck\": \"tsc --noEmit\",\n \"init-stack\": \"node dist/index.js\",\n \"init-stack:local\": \"STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js node dist/index.js\",\n \"test-run\": \"pnpm run build && pnpm run test-run-js && pnpm run test-run-node && pnpm run test-run-next && pnpm run test-run-neon && pnpm run test-run-no-browser\",\n \"test-run:manual\": \"pnpm run build && pnpm run test-run-js:manual && pnpm run test-run-node:manual && pnpm run test-run-next:manual && pnpm run test-run-neon:manual\",\n \"ensure-neon\": \"grep -q '\\\"@neondatabase/serverless\\\"' ./test-run-output/package.json && echo 'Initialized Neon successfully!'\",\n \"test-run-neon\": \"pnpm run test-run-node --neon && pnpm run ensure-neon\",\n \"test-run-neon:manual\": \"pnpm run test-run-node:manual --neon && pnpm run ensure-neon\",\n \"test-run-no-browser\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm --no-browser\",\n \"test-run-node:manual\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init && cd .. && pnpm run init-stack:local test-run-output\",\n \"test-run-node\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm\",\n \"test-run-js:manual\": \"rimraf test-run-output && npx -y sv create test-run-output --no-install && pnpm run init-stack:local test-run-output\",\n \"test-run-js\": \"rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --client --npm\",\n \"test-run-next:manual\": \"rimraf test-run-output && npx -y create-next-app@latest test-run-output && pnpm run init-stack:local test-run-output\",\n \"test-run-next\": \"rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output\"\n },\n \"files\": [\n \"README.md\",\n \"dist\",\n \"CHANGELOG.md\",\n \"LICENSE\"\n ],\n \"homepage\": \"https://stack-auth.com\",\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@stackframe/stack-shared\": \"workspace:*\",\n \"commander\": \"^13.1.0\",\n \"inquirer\": \"^9.2.19\",\n \"open\": \"^10.1.0\",\n \"posthog-node\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/inquirer\": \"^9.0.7\",\n \"@types/node\": \"20.17.6\",\n \"rimraf\": \"^6.0.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"5.3.3\"\n }\n}\n"],"mappings":";;;AAAA,YAAY,mBAAmB;AAC/B,SAAS,eAAe;AACxB,YAAY,YAAY;AACxB,YAAY,QAAQ;AACpB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,eAAe;;;ACRxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,KAAO;AAAA,EACP,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,cAAc;AAAA,IACd,oBAAoB;AAAA,IACpB,YAAY;AAAA,IACZ,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,IACjB,sBAAsB;AAAA,IACtB,eAAe;AAAA,IACf,wBAAwB;AAAA,IACxB,iBAAiB;AAAA,EACnB;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAY;AAAA,EACZ,UAAY,CAAC;AAAA,EACb,QAAU;AAAA,EACV,SAAW;AAAA,EACX,cAAgB;AAAA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,GAAG,MAAM,IAAI,QAAQ,CAAC,CAAC;AAC7G;AAEA,eAAe,aAA4B;AACzC,QAAM,IAAI,QAAc,CAAC,YAAY;AACnC,QAAI,QAAQ,MAAM,OAAO;AACrB,cAAQ,MAAM,WAAW,IAAI;AAAA,IACjC;AACE,YAAQ,MAAM,OAAO;AACrB,YAAQ,MAAM,mBAAmB,MAAM;AAEvC,UAAM,QAAQ,MAAM;AAClB,aAAO,QAAQ,MAAM,KAAK,MAAM,MAAM;AAAA,MAAC;AACvC,UAAI,QAAQ,MAAM,OAAO;AACrB,gBAAQ,MAAM,WAAW,KAAK;AAAA,MAClC;AACE,cAAQ;AAAA,IACZ;AAGA,eAAW,OAAO,EAAE;AAAA,EACxB,CAAC;AACH;","names":["options"]}
1
+ {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import * as child_process from \"child_process\";\nimport { Command } from \"commander\";\nimport * as crypto from 'crypto';\nimport * as fs from \"fs\";\nimport inquirer from \"inquirer\";\nimport open from \"open\";\nimport * as os from 'os';\nimport * as path from \"path\";\nimport { PostHog } from 'posthog-node';\nimport packageJson from '../package.json';\n\nconst jsLikeFileExtensions: string[] = [\n \"mtsx\",\n \"ctsx\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"ts\",\n \"mjsx\",\n \"cjsx\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n \"js\",\n];\n\nclass UserError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"UserError\";\n }\n}\n\nclass UnansweredQuestionError extends UserError {\n constructor(message: string) {\n super(message + \", or use --on-question <guess|ask> to answer questions automatically or interactively\");\n this.name = \"UnansweredQuestionError\";\n }\n}\n\ntype OnQuestionMode = \"ask\" | \"guess\" | \"error\";\n\nfunction isTruthyEnv(name: string): boolean {\n const v = process.env[name];\n if (!v) return false;\n const s = String(v).toLowerCase();\n return s === \"1\" || s === \"true\" || s === \"yes\";\n}\n\nfunction isNonInteractiveEnv(): boolean {\n if (isTruthyEnv(\"CI\")) return true;\n if (isTruthyEnv(\"GITHUB_ACTIONS\")) return true;\n if (isTruthyEnv(\"NONINTERACTIVE\")) return true;\n if (isTruthyEnv(\"NO_INTERACTIVE\")) return true;\n if (isTruthyEnv(\"PNPM_NON_INTERACTIVE\")) return true;\n if (isTruthyEnv(\"YARN_ENABLE_NON_INTERACTIVE\")) return true;\n if (isTruthyEnv(\"CURSOR_AGENT\")) return true;\n if (isTruthyEnv(\"CLAUDECODE\")) return true;\n return false;\n}\n\nfunction resolveOnQuestionMode(opt: string): OnQuestionMode {\n if (!opt || opt === \"default\") {\n return isNonInteractiveEnv() ? \"error\" : \"ask\";\n }\n if (opt === \"ask\" || opt === \"guess\" || opt === \"error\") {\n return opt;\n }\n throw new UserError(`Invalid argument for --on-question: \"${opt}\". Valid modes are: \"ask\", \"guess\", \"error\", \"default\".`);\n}\n\n// Setup command line parsing\nconst program = new Command();\nprogram\n .name(packageJson.name)\n .description(\"Stack Auth Initialization Tool\")\n .version(packageJson.version)\n .argument(\"[project-path]\", \"Path to your project\")\n .usage(`[project-path] [options]`)\n .option(\"--dry-run\", \"Run without making any changes\")\n .option(\"--neon\", \"Use Neon database\")\n .option(\"--js\", \"Initialize for JavaScript project\")\n .option(\"--next\", \"Initialize for Next.js project\")\n .option(\"--react\", \"Initialize for React project\")\n .option(\"--npm\", \"Use npm as package manager\")\n .option(\"--yarn\", \"Use yarn as package manager\")\n .option(\"--pnpm\", \"Use pnpm as package manager\")\n .option(\"--bun\", \"Use bun as package manager\")\n .option(\"--client\", \"Initialize client-side only\")\n .option(\"--server\", \"Initialize server-side only\")\n .option(\"--project-id <project-id>\", \"Project ID to use in setup\")\n .option(\"--publishable-client-key <publishable-client-key>\", \"Publishable client key to use in setup\")\n .option(\"--no-browser\", \"Don't open browser for environment variable setup\")\n .option(\"--on-question <mode>\", \"How to handle interactive questions: ask | guess | error | default\", \"default\")\n .addHelpText('after', `\nFor more information, please visit https://docs.stack-auth.com/getting-started/setup`);\n\nprogram.parse();\n\nconst options = program.opts();\n\n// Keep existing variables but assign from Commander\nlet savedProjectPath: string | undefined = program.args[0] || undefined;\nconst isDryRun: boolean = options.dryRun || false;\nconst isNeon: boolean = options.neon || false;\nconst typeFromArgs: \"js\" | \"next\" | \"react\" | undefined = options.js ? \"js\" : options.next ? \"next\" : options.react ? \"react\" : undefined;\nconst packageManagerFromArgs: string | undefined = options.npm ? \"npm\" : options.yarn ? \"yarn\" : options.pnpm ? \"pnpm\" : options.bun ? \"bun\" : undefined;\nconst isClient: boolean = options.client || false;\nconst isServer: boolean = options.server || false;\nconst projectIdFromArgs: string | undefined = options.projectId;\nconst publishableClientKeyFromArgs: string | undefined = options.publishableClientKey;\nconst onQuestionMode: OnQuestionMode = resolveOnQuestionMode(options.onQuestion);\n\n// Commander negates the boolean options with prefix `--no-`\n// so `--no-browser` becomes `browser: false`\nconst noBrowser: boolean = !options.browser;\n\ntype Ansis = {\n red: string,\n blue: string,\n green: string,\n yellow: string,\n clear: string,\n bold: string,\n};\n\nconst ansis: Ansis = {\n red: \"\\x1b[31m\",\n blue: \"\\x1b[34m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n\n clear: \"\\x1b[0m\",\n bold: \"\\x1b[1m\",\n};\n\ntype TemplateFunction = (strings: TemplateStringsArray, ...values: any[]) => string;\n\ntype Colorize = {\n red: TemplateFunction,\n blue: TemplateFunction,\n green: TemplateFunction,\n yellow: TemplateFunction,\n bold: TemplateFunction,\n};\n\nconst colorize: Colorize = {\n red: (strings, ...values) => ansis.red + templateIdentity(strings, ...values) + ansis.clear,\n blue: (strings, ...values) => ansis.blue + templateIdentity(strings, ...values) + ansis.clear,\n green: (strings, ...values) => ansis.green + templateIdentity(strings, ...values) + ansis.clear,\n yellow: (strings, ...values) => ansis.yellow + templateIdentity(strings, ...values) + ansis.clear,\n bold: (strings, ...values) => ansis.bold + templateIdentity(strings, ...values) + ansis.clear,\n};\n\nconst filesCreated: string[] = [];\nconst filesModified: string[] = [];\nconst commandsExecuted: string[] = [];\n\nconst packagesToInstall: string[] = [];\nconst writeFileHandlers: Array<() => Promise<void>> = [];\nconst nextSteps: string[] = [\n `Create an account and Stack Auth API key for your project on https://app.stack-auth.com`,\n];\n\n\nconst STACK_AUTH_PUBLIC_HOG_KEY = \"phc_vIUFi0HzHo7oV26OsaZbUASqxvs8qOmap1UBYAutU4k\";\nconst EVENT_PREFIX = \"stack-init-\";\nconst ph_client = new PostHog(STACK_AUTH_PUBLIC_HOG_KEY, {\n host: \"https://eu.i.posthog.com\",\n flushAt: 1,\n flushInterval: 0,\n});\nconst distinctId = crypto.randomUUID();\n\n\nasync function capture(event: string, properties: Record<string, any>) {\n ph_client.capture({\n event: `${EVENT_PREFIX}${event}`,\n distinctId,\n properties,\n });\n}\n\n\nasync function main(): Promise<void> {\n // Welcome message\n console.log();\n console.log(`\n ██████\n ██████████████\n████████████████████\n████████████████████ WELCOME TO\n█████████████████ ╔═╗╔╦╗╔═╗╔═╗╦╔═ ┌─┐┬ ┬┌┬┐┬ ┬\n█████████████ ╚═╗ ║ ╠═╣║ ╠╩╗ ├─┤│ │ │ ├─┤\n█████████████ ████ ╚═╝ ╩ ╩ ╩╚═╝╩ ╩ ┴ ┴└─┘ ┴ ┴ ┴\n █████████████████\n ██████ ██\n████ ████\n █████ █████\n ██████\n `);\n console.log();\n\n await capture(\"start\", {\n version: packageJson.version,\n isDryRun,\n isNeon,\n typeFromArgs,\n packageManagerFromArgs,\n isClient,\n isServer,\n noBrowser,\n platform: os.platform(),\n arch: os.arch(),\n nodeVersion: process.version,\n });\n\n // Wait just briefly so we can use `Steps` in here (it's defined only after the call to `main()`)\n await new Promise<void>((resolve) => resolve());\n\n\n // Prepare some stuff\n await clearStdin();\n const projectPath = await getProjectPath();\n\n\n // Steps\n const { packageJson: projectPackageJson } = await Steps.getProject();\n const type = await Steps.getProjectType({ packageJson: projectPackageJson });\n\n await capture(\"project-type-selected\", {\n type,\n wasSpecifiedInArgs: !!typeFromArgs,\n });\n\n await Steps.addStackPackage(type);\n if (isNeon) packagesToInstall.push('@neondatabase/serverless');\n\n await Steps.writeEnvVars(type);\n\n if (type === \"next\") {\n const projectInfo = await Steps.getNextProjectInfo({ packageJson: projectPackageJson });\n await Steps.updateNextLayoutFile(projectInfo);\n await Steps.writeStackAppFile(projectInfo, \"client\");\n await Steps.writeStackAppFile(projectInfo, \"server\");\n await Steps.writeNextHandlerFile(projectInfo);\n await Steps.writeNextLoadingFile(projectInfo);\n nextSteps.push(`Copy the environment variables from the new API key into your .env.local file`);\n } else if (type === \"react\") {\n const defaultExtension = await Steps.guessDefaultFileExtension();\n const srcPath = await Steps.guessSrcPath();\n const hasReactRouterDom = !!(projectPackageJson.dependencies?.[\"react-router-dom\"] || projectPackageJson.devDependencies?.[\"react-router-dom\"]);\n const { fileName } = await Steps.writeReactClientFile({\n srcPath,\n defaultExtension,\n indentation: \" \",\n hasReactRouterDom,\n });\n nextSteps.push(\n `Copy the environment variables from the new API key into your own environment and reference them in ${fileName}`,\n );\n } else {\n const defaultExtension = await Steps.guessDefaultFileExtension();\n const where = await Steps.getServerOrClientOrBoth();\n const srcPath = await Steps.guessSrcPath();\n const appFiles: string[] = [];\n for (const w of where) {\n const { fileName } = await Steps.writeStackAppFile({\n type,\n defaultExtension,\n indentation: \" \",\n srcPath,\n }, w);\n appFiles.push(fileName);\n }\n nextSteps.push(\n `Copy the environment variables from the new API key into your own environment and reference them in ${appFiles.join(\" and \")}`,\n `Follow the instructions on how to use Stack Auth's vanilla SDK at http://docs.stack-auth.com/others/js-client`,\n );\n }\n\n const { packageManager } = await Steps.getPackageManager();\n\n await capture(`package-manager-selected`, {\n packageManager,\n wasSpecifiedInArgs: !!packageManagerFromArgs,\n });\n\n await Steps.ensureReady(type);\n\n\n // Install dependencies\n console.log();\n console.log(colorize.bold`Installing dependencies...`);\n const installCommandMap = new Map<string, string>([\n [\"npm\", \"npm install\"],\n [\"yarn\", \"yarn add\"],\n [\"pnpm\", \"pnpm add\"],\n [\"bun\", \"bun add\"],\n ]);\n const installCommand = installCommandMap.get(packageManager) ?? `${packageManager} install`;\n // Quote each package name to avoid shell interpretation of env-overridden values.\n const safePackages = packagesToInstall.map((p) => JSON.stringify(p));\n await shellNicelyFormatted(`${installCommand} ${safePackages.join(' ')}`, {\n shell: true,\n cwd: projectPath,\n });\n\n await capture(`dependencies-installed`, {\n packageManager,\n packages: packagesToInstall,\n });\n\n // Write files\n console.log();\n console.log(colorize.bold`Writing files...`);\n console.log();\n for (const writeFileHandler of writeFileHandlers) {\n await writeFileHandler();\n }\n console.log(`${colorize.green`√`} Done writing files`);\n\n console.log('\\n\\n\\n');\n console.log(colorize.bold`${colorize.green`Installation succeeded!`}`);\n console.log();\n console.log(\"Commands executed:\");\n for (const command of commandsExecuted) {\n console.log(` ${colorize.blue`${command}`}`);\n }\n console.log();\n console.log(\"Files written:\");\n for (const file of filesModified) {\n console.log(` ${colorize.yellow`${file}`}`);\n }\n for (const file of filesCreated) {\n console.log(` ${colorize.green`${file}`}`);\n }\n console.log();\n\n await capture(\"complete\", {\n success: true,\n type,\n packageManager,\n isNeon,\n isClient,\n isServer,\n noBrowser,\n filesCreated,\n filesModified,\n commandsExecuted,\n });\n\n // Success!\n console.log(`\n${colorize.green`===============================================`}\n\n${colorize.green`Successfully installed Stack! 🚀🚀🚀`}\n\n${colorize.bold`Next steps:`}\n\n1. ${noBrowser ?\n `Create a project at https://app.stack-auth.com and get your API keys` :\n `Complete the setup in your browser to get your API keys`}\n2. Add the API keys to your .env.local file\n3. Import the Stack components in your app\n4. Add authentication to your app\n\nFor more information, please visit https://docs.stack-auth.com/getting-started/setup\n `.trim());\n if (!noBrowser) {\n await open(`https://app.stack-auth.com/wizard-congrats?stack-init-id=${encodeURIComponent(distinctId)}`);\n }\n await ph_client.shutdown();\n}\n\n// eslint-disable-next-line no-restricted-syntax\nmain().catch(async (err) => {\n try {\n await capture(\"error\", {\n error: err.message,\n errorType: err instanceof UserError ? \"UserError\" : \"SystemError\",\n stack: err.stack,\n });\n } catch (e) { }\n if (!(err instanceof UserError)) {\n console.error(err);\n }\n console.error('\\n\\n\\n\\n');\n console.log(colorize.red`===============================================`);\n console.error();\n if (err instanceof UserError) {\n console.error(`${colorize.red`ERROR!`} ${err.message}`);\n } else {\n console.error(\"An error occurred during the initialization process.\");\n }\n console.error();\n console.log(colorize.red`===============================================`);\n console.error();\n console.error(\n \"If you need assistance, please try installing Stack manually as described in https://docs.stack-auth.com/getting-started/setup or join our Discord where we're happy to help: https://discord.stack-auth.com\"\n );\n if (!(err instanceof UserError)) {\n console.error(\"\");\n console.error(`Error message: ${err.message}`);\n }\n console.error();\n await ph_client.shutdown();\n process.exit(1);\n});\n\n\ntype PackageJson = {\n dependencies?: Record<string, string>,\n devDependencies?: Record<string, string>,\n [key: string]: any,\n}\n\ntype ProjectInfo = {\n type: \"js\" | \"next\" | \"react\",\n srcPath: string,\n appPath: string,\n defaultExtension: string,\n indentation: string,\n}\n\ntype NextProjectInfoError = {\n error: string,\n}\n\ntype NextProjectInfoResult = ProjectInfo | NextProjectInfoError;\n\ntype StackAppFileOptions = {\n type: \"js\" | \"next\" | \"react\",\n srcPath: string,\n defaultExtension: string,\n indentation: string,\n}\n\ntype StackAppFileResult = {\n fileName: string,\n}\n\nconst Steps = {\n async getProject(): Promise<{ packageJson: PackageJson }> {\n let projectPath = await getProjectPath();\n if (!fs.existsSync(projectPath)) {\n throw new UserError(`The project path ${projectPath} does not exist`);\n }\n\n const packageJsonPath = path.join(projectPath, \"package.json\");\n if (!fs.existsSync(packageJsonPath)) {\n throw new UserError(\n `The package.json file does not exist in the project path ${projectPath}. You must initialize a new project first before installing Stack.`\n );\n }\n\n const packageJsonText = fs.readFileSync(packageJsonPath, \"utf-8\");\n let packageJson: PackageJson;\n try {\n packageJson = JSON.parse(packageJsonText);\n } catch (e) {\n throw new UserError(`package.json file is not valid JSON: ${e}`);\n }\n\n return { packageJson };\n },\n\n async getProjectType({ packageJson }: { packageJson: PackageJson }): Promise<\"js\" | \"next\" | \"react\"> {\n if (typeFromArgs) return typeFromArgs;\n\n const maybeNextProject = await Steps.maybeGetNextProjectInfo({ packageJson });\n if (!(\"error\" in maybeNextProject)) {\n return \"next\";\n }\n if (packageJson.dependencies?.[\"react\"] || packageJson.dependencies?.[\"react-dom\"]) {\n return \"react\";\n }\n if (onQuestionMode === \"guess\") {\n return \"js\";\n }\n if (onQuestionMode === \"error\") {\n throw new UnansweredQuestionError(\"Unable to auto-detect project type (checked for Next.js and React dependencies). Re-run with one of: --js, --react, or --next.\");\n }\n\n const { type } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"type\",\n message: \"Which integration would you like to install?\",\n choices: [\n { name: \"None (vanilla JS, Node.js, etc)\", value: \"js\" },\n { name: \"React\", value: \"react\" },\n { name: \"Next.js\", value: \"next\" },\n ]\n }\n ]);\n\n return type;\n },\n\n async getStackPackageName(type: \"js\" | \"next\" | \"react\", install = false): Promise<string> {\n const mapping = {\n js: (install && process.env.STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE) || \"@stackframe/js\",\n next: (install && process.env.STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE) || \"@stackframe/stack\",\n react: (install && process.env.STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE) || \"@stackframe/react\",\n } as const;\n return mapping[type];\n },\n\n async addStackPackage(type: \"js\" | \"next\" | \"react\"): Promise<void> {\n packagesToInstall.push(await Steps.getStackPackageName(type, true));\n },\n\n async getNextProjectInfo({ packageJson }: { packageJson: PackageJson }): Promise<ProjectInfo> {\n const maybe = await Steps.maybeGetNextProjectInfo({ packageJson });\n if (\"error\" in maybe) throw new UserError(maybe.error);\n return maybe;\n },\n\n async maybeGetNextProjectInfo({ packageJson }: { packageJson: PackageJson }): Promise<NextProjectInfoResult> {\n const projectPath = await getProjectPath();\n\n const nextVersionInPackageJson = packageJson.dependencies?.[\"next\"] ?? packageJson.devDependencies?.[\"next\"];\n if (!nextVersionInPackageJson) {\n return { error: `The project at ${projectPath} does not appear to be a Next.js project, or does not have 'next' installed as a dependency.` };\n }\n if (\n !nextVersionInPackageJson.includes(\"14\") &&\n !nextVersionInPackageJson.includes(\"15\") &&\n nextVersionInPackageJson !== \"latest\"\n ) {\n return { error: `The project at ${projectPath} is using an unsupported version of Next.js (found ${nextVersionInPackageJson}).\\n\\nOnly Next.js 14 & 15 projects are currently supported. See Next's upgrade guide: https://nextjs.org/docs/app/building-your-application/upgrading/version-14` };\n }\n\n const nextConfigPathWithoutExtension = path.join(projectPath, \"next.config\");\n const nextConfigFileExtension = await findJsExtension(\n nextConfigPathWithoutExtension\n );\n const nextConfigPath =\n nextConfigPathWithoutExtension + \".\" + (nextConfigFileExtension ?? \"js\");\n if (!fs.existsSync(nextConfigPath)) {\n return { error: `Expected file at ${nextConfigPath}. Only Next.js projects are currently supported.` };\n }\n\n const hasSrcAppFolder = fs.existsSync(path.join(projectPath, \"src/app\"));\n const srcPath = path.join(projectPath, hasSrcAppFolder ? \"src\" : \"\");\n const appPath = path.join(srcPath, \"app\");\n if (!fs.existsSync(appPath)) {\n return { error: `The app path ${appPath} does not exist. Only the Next.js app router is supported.` };\n }\n\n const dryUpdateNextLayoutFileResult = await Steps.dryUpdateNextLayoutFile({ appPath, defaultExtension: \"jsx\" });\n\n return {\n type: \"next\",\n srcPath,\n appPath,\n defaultExtension: dryUpdateNextLayoutFileResult.fileExtension,\n indentation: dryUpdateNextLayoutFileResult.indentation,\n };\n },\n\n async writeEnvVars(type: \"js\" | \"next\" | \"react\"): Promise<boolean> {\n const projectPath = await getProjectPath();\n\n // TODO: in non-Next environments, ask the user what method they prefer for envvars\n if (type !== \"next\") return false;\n\n const envLocalPath = path.join(projectPath, \".env.local\");\n\n const potentialEnvLocations = [\n path.join(projectPath, \".env\"),\n path.join(projectPath, \".env.development\"),\n path.join(projectPath, \".env.default\"),\n path.join(projectPath, \".env.defaults\"),\n path.join(projectPath, \".env.example\"),\n envLocalPath,\n ];\n if (potentialEnvLocations.every((p) => !fs.existsSync(p))) {\n const envContent = noBrowser\n ? \"# Stack Auth keys\\n\" +\n \"# To get these variables:\\n\" +\n \"# 1. Go to https://app.stack-auth.com\\n\" +\n \"# 2. Create a new project\\n\" +\n \"# 3. Copy the keys below\\n\" +\n `NEXT_PUBLIC_STACK_PROJECT_ID=\"${projectIdFromArgs ?? \"\"}\"\\n` +\n `NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\"${publishableClientKeyFromArgs ?? \"\"}\"\\n` +\n \"STACK_SECRET_SERVER_KEY=\\n\"\n : \"# Stack Auth keys\\n\" +\n \"# Get these variables by creating a project on https://app.stack-auth.com.\\n\" +\n `NEXT_PUBLIC_STACK_PROJECT_ID=\"${projectIdFromArgs ?? \"\"}\"\\n` +\n `NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=\"${publishableClientKeyFromArgs ?? \"\"}\"\\n` +\n \"STACK_SECRET_SERVER_KEY=\\n\";\n\n laterWriteFile(envLocalPath, envContent);\n return true;\n }\n\n return false;\n },\n\n async dryUpdateNextLayoutFile({ appPath, defaultExtension }: { appPath: string, defaultExtension: string }): Promise<{\n path: string,\n updatedContent: string,\n fileExtension: string,\n indentation: string,\n }> {\n const layoutPathWithoutExtension = path.join(appPath, \"layout\");\n const layoutFileExtension =\n (await findJsExtension(layoutPathWithoutExtension)) ?? defaultExtension;\n const layoutPath = layoutPathWithoutExtension + \".\" + layoutFileExtension;\n const layoutContent =\n (await readFile(layoutPath)) ??\n throwErr(\n `The layout file at ${layoutPath} does not exist. Stack requires a layout file to be present in the /app folder.`\n );\n const updatedLayoutResult =\n (await getUpdatedLayout(layoutContent)) ??\n throwErr(\n \"Unable to parse root layout file. Make sure it contains a <body> tag. If it still doesn't work, you may need to manually install Stack. See: https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts#root-layout-required\"\n );\n const updatedLayoutContent = updatedLayoutResult.content;\n return {\n path: layoutPath,\n updatedContent: updatedLayoutContent,\n fileExtension: layoutFileExtension,\n indentation: updatedLayoutResult.indentation\n };\n },\n\n async updateNextLayoutFile(projectInfo: ProjectInfo): Promise<{\n path: string,\n updatedContent: string,\n fileExtension: string,\n indentation: string,\n }> {\n const res = await Steps.dryUpdateNextLayoutFile(projectInfo);\n laterWriteFile(res.path, res.updatedContent);\n return res;\n },\n\n async writeStackAppFile({ type, srcPath, defaultExtension, indentation }: StackAppFileOptions, clientOrServer: \"server\" | \"client\"): Promise<StackAppFileResult> {\n const packageName = await Steps.getStackPackageName(type);\n\n const clientOrServerCap = {\n client: \"Client\",\n server: \"Server\",\n }[clientOrServer as \"client\" | \"server\"];\n const relativeStackAppPath = `stack/${clientOrServer}`;\n\n const stackAppPathWithoutExtension = path.join(srcPath, relativeStackAppPath);\n const stackAppFileExtension =\n (await findJsExtension(stackAppPathWithoutExtension)) ?? defaultExtension;\n const stackAppPath =\n stackAppPathWithoutExtension + \".\" + stackAppFileExtension;\n const stackAppContent = await readFile(stackAppPath);\n if (stackAppContent) {\n if (!stackAppContent.includes(\"@stackframe/\")) {\n throw new UserError(\n `A file at the path ${stackAppPath} already exists. Stack uses the stack/${clientOrServer}.ts file to initialize the Stack SDK. Please remove the existing file and try again.`\n );\n }\n throw new UserError(\n `It seems that you already installed Stack in this project.`\n );\n }\n\n const tokenStore = type === \"next\" ? '\"nextjs-cookie\"' : (clientOrServer === \"client\" ? '\"cookie\"' : '\"memory\"');\n const publishableClientKeyWrite = clientOrServer === \"server\"\n ? `process.env.STACK_PUBLISHABLE_CLIENT_KEY ${publishableClientKeyFromArgs ? `|| ${JSON.stringify(publishableClientKeyFromArgs)}` : \"\"}`\n : `'${publishableClientKeyFromArgs ?? 'INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE'}'`;\n const jsOptions = type === \"js\" ? [\n `\\n\\n${indentation}// get your Stack Auth API keys from https://app.stack-auth.com${clientOrServer === \"client\" ? ` and store them in a safe place (eg. environment variables)` : \"\"}`,\n `${projectIdFromArgs ? `${indentation}projectId: ${JSON.stringify(projectIdFromArgs)},` : \"\"}`,\n `${indentation}publishableClientKey: ${publishableClientKeyWrite},`,\n `${clientOrServer === \"server\" ? `${indentation}secretServerKey: process.env.STACK_SECRET_SERVER_KEY,` : \"\"}`,\n ].filter(Boolean).join(\"\\n\") : \"\";\n\n const nextClientOptions = (type === \"next\" && clientOrServer === \"client\")\n ? (() => {\n const lines = [\n projectIdFromArgs ? `${indentation}projectId: process.env.NEXT_PUBLIC_STACK_PROJECT_ID ?? ${JSON.stringify(projectIdFromArgs)},` : \"\",\n publishableClientKeyFromArgs ? `${indentation}publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY ?? ${JSON.stringify(publishableClientKeyFromArgs)},` : \"\",\n ].filter(Boolean).join(\"\\n\");\n return lines ? `\\n${lines}` : \"\";\n })()\n : \"\";\n\n\n laterWriteFileIfNotExists(\n stackAppPath,\n `\n${type === \"next\" && clientOrServer === \"server\" ? `import \"server-only\";` : \"\"}\n\nimport { Stack${clientOrServerCap}App } from ${JSON.stringify(packageName)};\n\nexport const stack${clientOrServerCap}App = new Stack${clientOrServerCap}App({\n${indentation}tokenStore: ${tokenStore},${jsOptions}${nextClientOptions}\n});\n `.trim() + \"\\n\"\n );\n return { fileName: stackAppPath };\n },\n\n async writeReactClientFile({ srcPath, defaultExtension, indentation, hasReactRouterDom }: { srcPath: string, defaultExtension: string, indentation: string, hasReactRouterDom: boolean }): Promise<StackAppFileResult> {\n const packageName = await Steps.getStackPackageName(\"react\");\n const relativeStackAppPath = `stack/client`;\n const stackAppPathWithoutExtension = path.join(srcPath, relativeStackAppPath);\n const stackAppFileExtension = (await findJsExtension(stackAppPathWithoutExtension)) ?? defaultExtension;\n const stackAppPath = stackAppPathWithoutExtension + \".\" + stackAppFileExtension;\n const stackAppContent = await readFile(stackAppPath);\n if (stackAppContent) {\n if (!stackAppContent.includes(\"@stackframe/\")) {\n throw new UserError(`A file at the path ${stackAppPath} already exists. Stack uses the stack/client.ts file to initialize the Stack SDK. Please remove the existing file and try again.`);\n }\n throw new UserError(`It seems that you already installed Stack in this project.`);\n }\n\n const publishableClientKeyWrite = `'${publishableClientKeyFromArgs ?? 'INSERT_YOUR_PUBLISHABLE_CLIENT_KEY_HERE'}'`;\n const projectIdWrite = `'${projectIdFromArgs ?? 'INSERT_PROJECT_ID'}'`;\n\n const imports = hasReactRouterDom\n ? `import { StackClientApp } from ${JSON.stringify(packageName)};\\nimport { useNavigate } from \"react-router-dom\";\\n\\n`\n : `import { StackClientApp } from ${JSON.stringify(packageName)};\\n\\n`;\n\n const redirectMethod = hasReactRouterDom\n ? `,\\n${indentation}redirectMethod: {\\n${indentation}${indentation}useNavigate,\\n${indentation}}`\n : \"\";\n\n laterWriteFileIfNotExists(\n stackAppPath,\n `${imports}export const stackClientApp = new StackClientApp({ \\n${indentation}tokenStore: \"cookie\", \\n${indentation}projectId: ${projectIdWrite}, \\n${indentation}publishableClientKey: ${publishableClientKeyWrite}${redirectMethod}, \\n}); \\n`\n );\n return { fileName: stackAppPath };\n },\n\n async writeNextHandlerFile(projectInfo: ProjectInfo): Promise<void> {\n const handlerPathWithoutExtension = path.join(\n projectInfo.appPath,\n \"handler/[...stack]/page\"\n );\n const handlerFileExtension =\n (await findJsExtension(handlerPathWithoutExtension)) ?? projectInfo.defaultExtension;\n const handlerPath = handlerPathWithoutExtension + \".\" + handlerFileExtension;\n const handlerContent = await readFile(handlerPath);\n if (handlerContent && !handlerContent.includes(\"@stackframe/\")) {\n throw new UserError(\n `A file at the path ${handlerPath} already exists.Stack uses the / handler path to handle incoming requests.Please remove the existing file and try again.`\n );\n }\n laterWriteFileIfNotExists(\n handlerPath,\n `import { StackHandler } from \"@stackframe/stack\"; \\nimport { stackServerApp } from \"../../../stack/server\"; \\n\\nexport default function Handler(props${handlerFileExtension.includes(\"ts\") ? \": unknown\" : \"\"\n }) { \\n${projectInfo.indentation} return <StackHandler fullPage app = { stackServerApp } routeProps = { props } />; \\n } \\n`\n );\n },\n\n async writeNextLoadingFile(projectInfo: ProjectInfo): Promise<void> {\n let loadingPathWithoutExtension = path.join(projectInfo.appPath, \"loading\");\n const loadingFileExtension =\n (await findJsExtension(loadingPathWithoutExtension)) ?? projectInfo.defaultExtension;\n const loadingPath = loadingPathWithoutExtension + \".\" + loadingFileExtension;\n laterWriteFileIfNotExists(\n loadingPath,\n `export default function Loading() {\n\\n${projectInfo.indentation}// Stack uses React Suspense, which will render this page while user data is being fetched.\\n${projectInfo.indentation}// See: https://nextjs.org/docs/app/api-reference/file-conventions/loading\\n${projectInfo.indentation}return <></>;\\n}\\n`\n );\n },\n\n async getPackageManager(): Promise<{ packageManager: string }> {\n if (packageManagerFromArgs) return { packageManager: packageManagerFromArgs };\n const packageManager = await promptPackageManager();\n const versionCommand = `${packageManager} --version`;\n\n try {\n await shellNicelyFormatted(versionCommand, { shell: true, quiet: true });\n } catch (err) {\n console.error(err);\n throw new UserError(\n `Could not run the package manager command '${versionCommand}'. Please make sure ${packageManager} is installed on your system.`\n );\n }\n\n return { packageManager };\n },\n\n async ensureReady(type: \"js\" | \"next\" | \"react\"): Promise<void> {\n const projectPath = await getProjectPath();\n\n const typeStringMap = {\n js: \"JavaScript\",\n next: \"Next.js\",\n react: \"React\",\n } as const;\n const typeString = typeStringMap[type];\n const isReady = (onQuestionMode !== \"ask\") || (await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"ready\",\n message: `Found a ${typeString} project at ${projectPath} — ready to install Stack Auth?`,\n default: true,\n },\n ])).ready;\n if (!isReady) {\n throw new UserError(\"Installation aborted.\");\n }\n },\n\n async getServerOrClientOrBoth(): Promise<Array<\"server\" | \"client\">> {\n if (isClient && isServer) return [\"server\", \"client\"];\n if (isServer) return [\"server\"];\n if (isClient) return [\"client\"];\n\n if (onQuestionMode === \"guess\") return [\"server\", \"client\"];\n if (onQuestionMode === \"error\") {\n throw new UnansweredQuestionError(\"Ambiguous installation type. Re-run with --server, --client, or both.\");\n }\n\n return (await inquirer.prompt([{\n type: \"list\",\n name: \"type\",\n message: \"Do you want to use Stack Auth on the server, or on the client?\",\n choices: [\n { name: \"Client (eg. Vite, HTML)\", value: [\"client\"] },\n { name: \"Server (eg. Node.js)\", value: [\"server\"] },\n { name: \"Both\", value: [\"server\", \"client\"] }\n ]\n }])).type;\n },\n\n /**\n * note: this is a heuristic, specific frameworks may have better heuristics (eg. the Next.js code uses the extension of the global layout file)\n */\n async guessDefaultFileExtension(): Promise<string> {\n const projectPath = await getProjectPath();\n const hasTsConfig = fs.existsSync(\n path.join(projectPath, \"tsconfig.json\")\n );\n return hasTsConfig ? \"ts\" : \"js\";\n },\n\n /**\n * note: this is a heuristic, specific frameworks may have better heuristics (eg. the Next.js code uses the location of the app folder)\n */\n async guessSrcPath(): Promise<string> {\n const projectPath = await getProjectPath();\n const potentialSrcPath = path.join(projectPath, \"src\");\n const hasSrcFolder = fs.existsSync(\n path.join(projectPath, \"src\")\n );\n return hasSrcFolder ? potentialSrcPath : projectPath;\n },\n\n\n};\n\n\ntype LayoutResult = {\n content: string,\n indentation: string,\n}\n\nasync function getUpdatedLayout(originalLayout: string): Promise<LayoutResult | undefined> {\n let layout = originalLayout;\n const indentation = guessIndentation(originalLayout);\n\n const firstImportLocationM1 = /\\simport\\s/.exec(layout)?.index;\n const hasStringAsFirstLine = layout.startsWith('\"') || layout.startsWith(\"'\");\n const importInsertLocationM1 =\n firstImportLocationM1 ?? (hasStringAsFirstLine ? layout.indexOf(\"\\n\") : -1);\n const importInsertLocation = importInsertLocationM1 + 1;\n const importStatement = `import { StackProvider, StackTheme } from \"@stackframe/stack\";\\nimport { stackClientApp } from \"../stack/client\";\\n`;\n layout =\n layout.slice(0, importInsertLocation) +\n importStatement +\n layout.slice(importInsertLocation);\n\n const bodyOpenTag = /<\\s*body[^>]*>/.exec(layout);\n const bodyCloseTag = /<\\s*\\/\\s*body[^>]*>/.exec(layout);\n if (!bodyOpenTag || !bodyCloseTag) {\n return undefined;\n }\n const bodyOpenEndIndex = bodyOpenTag.index + bodyOpenTag[0].length;\n const bodyCloseStartIndex = bodyCloseTag.index;\n if (bodyCloseStartIndex <= bodyOpenEndIndex) {\n return undefined;\n }\n\n const lines = layout.split(\"\\n\");\n const [bodyOpenEndLine, bodyOpenEndIndexInLine] = getLineIndex(\n lines,\n bodyOpenEndIndex\n );\n const [bodyCloseStartLine, bodyCloseStartIndexInLine] = getLineIndex(\n lines,\n bodyCloseStartIndex\n );\n\n const insertOpen = \"<StackProvider app={stackClientApp}><StackTheme>\";\n const insertClose = \"</StackTheme></StackProvider>\";\n\n layout =\n layout.slice(0, bodyCloseStartIndex) +\n insertClose +\n layout.slice(bodyCloseStartIndex);\n layout =\n layout.slice(0, bodyOpenEndIndex) +\n insertOpen +\n layout.slice(bodyOpenEndIndex);\n\n return {\n content: `${layout}`,\n indentation,\n };\n}\n\nfunction guessIndentation(str: string): string {\n const lines = str.split(\"\\n\");\n const linesLeadingWhitespaces = lines\n .map((line) => line.match(/^\\s*/)![0])\n .filter((ws) => ws.length > 0);\n const isMostlyTabs =\n linesLeadingWhitespaces.filter((ws) => ws.includes(\"\\t\")).length >=\n (linesLeadingWhitespaces.length * 2) / 3;\n if (isMostlyTabs) return \"\\t\";\n const linesLeadingWhitespacesCount = linesLeadingWhitespaces.map(\n (ws) => ws.length\n );\n const min = Math.min(Infinity, ...linesLeadingWhitespacesCount);\n return Number.isFinite(min) ? \" \".repeat(Math.max(2, min)) : \" \";\n}\n\nfunction getLineIndex(lines: string[], stringIndex: number): [number, number] {\n let lineIndex = 0;\n for (let l = 0; l < lines.length; l++) {\n const line = lines[l];\n if (stringIndex < lineIndex + line.length) {\n return [l, stringIndex - lineIndex];\n }\n lineIndex += line.length + 1;\n }\n throw new Error(\n `Index ${stringIndex} is out of bounds for lines ${JSON.stringify(lines)}`\n );\n}\n\nasync function getProjectPath(): Promise<string> {\n if (savedProjectPath === undefined) {\n savedProjectPath = process.cwd();\n\n const askForPathModification = !fs.existsSync(\n path.join(savedProjectPath, \"package.json\")\n );\n if (askForPathModification) {\n if (onQuestionMode === \"guess\" || onQuestionMode === \"error\") {\n throw new UserError(`No package.json file found in ${savedProjectPath}. Re-run providing the project path argument (e.g. 'init-stack <project-path>').`);\n }\n savedProjectPath = (\n await inquirer.prompt([\n {\n type: \"input\",\n name: \"newPath\",\n message: \"Please enter the path to your project:\",\n default: \".\",\n },\n ])\n ).newPath;\n }\n }\n return savedProjectPath as string;\n}\n\nasync function findJsExtension(fullPathWithoutExtension: string): Promise<string | null> {\n for (const ext of jsLikeFileExtensions) {\n const fullPath = fullPathWithoutExtension + \".\" + ext;\n if (fs.existsSync(fullPath)) {\n return ext;\n }\n }\n return null;\n}\n\nasync function promptPackageManager(): Promise<string> {\n const projectPath = await getProjectPath();\n const yarnLock = fs.existsSync(path.join(projectPath, \"yarn.lock\"));\n const pnpmLock = fs.existsSync(path.join(projectPath, \"pnpm-lock.yaml\"));\n const npmLock = fs.existsSync(path.join(projectPath, \"package-lock.json\"));\n const bunLock = fs.existsSync(path.join(projectPath, \"bun.lockb\")) || fs.existsSync(path.join(projectPath, \"bun.lock\"));\n\n if (yarnLock && !pnpmLock && !npmLock && !bunLock) {\n return \"yarn\";\n } else if (!yarnLock && pnpmLock && !npmLock && !bunLock) {\n return \"pnpm\";\n } else if (!yarnLock && !pnpmLock && npmLock && !bunLock) {\n return \"npm\";\n } else if (!yarnLock && !pnpmLock && !npmLock && bunLock) {\n return \"bun\";\n }\n\n if (onQuestionMode === \"guess\") return \"npm\";\n if (onQuestionMode === \"error\") {\n throw new UnansweredQuestionError(\"Unable to determine the package manager. Re-run with one of: --npm, --yarn, --pnpm, or --bun.\");\n }\n\n const answers = await inquirer.prompt([\n {\n type: \"list\",\n name: \"packageManager\",\n message: \"Which package manager are you using for this project?\",\n choices: [\"npm\", \"yarn\", \"pnpm\", \"bun\"],\n },\n ]);\n return answers.packageManager;\n}\n\ntype ShellOptions = {\n quiet?: boolean,\n shell?: boolean,\n cwd?: string,\n [key: string]: any,\n}\n\nasync function shellNicelyFormatted(command: string, { quiet, ...options }: ShellOptions): Promise<void> {\n let ui: any;\n let interval: NodeJS.Timeout | undefined;\n if (!quiet) {\n console.log();\n ui = new inquirer.ui.BottomBar();\n let dots = 4;\n ui.updateBottomBar(\n colorize.blue`Running command: ${command}...`\n );\n interval = setInterval(() => {\n if (!isDryRun) {\n ui.updateBottomBar(\n colorize.blue`Running command: ${command}${\".\".repeat(dots++ % 5)}`\n );\n }\n }, 700);\n }\n\n try {\n if (!isDryRun) {\n const child = child_process.spawn(command, options);\n if (!quiet) {\n child.stdout.pipe(ui.log);\n child.stderr.pipe(ui.log);\n }\n\n await new Promise<void>((resolve, reject) => {\n child.on(\"exit\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`Command ${command} failed with code ${code}`));\n }\n });\n });\n } else {\n console.log(`[DRY-RUN] Would have run: ${command}`);\n }\n\n if (!quiet) {\n commandsExecuted.push(command);\n ui.updateBottomBar(\n `${colorize.green`√`} Command ${command} succeeded\\n`\n );\n }\n } catch (e) {\n if (!quiet) {\n ui.updateBottomBar(\n `${colorize.red`X`} Command ${command} failed\\n`\n );\n }\n throw e;\n } finally {\n if (interval) {\n clearTimeout(interval);\n }\n if (!quiet) {\n ui.close();\n }\n }\n}\n\nasync function readFile(fullPath: string): Promise<string | null> {\n try {\n if (!isDryRun) {\n return fs.readFileSync(fullPath, \"utf-8\");\n }\n return null;\n } catch (err: any) {\n if (err.code === \"ENOENT\") {\n return null;\n }\n throw err;\n }\n}\n\nasync function writeFile(fullPath: string, content: string): Promise<void> {\n let create = !fs.existsSync(fullPath);\n if (!isDryRun) {\n fs.mkdirSync(path.dirname(fullPath), { recursive: true });\n fs.writeFileSync(fullPath, content);\n } else {\n console.log(`[DRY-RUN] Would have written to ${fullPath}`);\n }\n const relativeToProjectPath = path.relative(await getProjectPath(), fullPath);\n if (!create) {\n filesModified.push(relativeToProjectPath);\n } else {\n filesCreated.push(relativeToProjectPath);\n }\n}\n\nfunction laterWriteFile(fullPath: string, content: string): void {\n writeFileHandlers.push(async () => {\n await writeFile(fullPath, content);\n });\n}\n\nasync function writeFileIfNotExists(fullPath: string, content: string): Promise<void> {\n if (!fs.existsSync(fullPath)) {\n await writeFile(fullPath, content);\n }\n}\n\nfunction laterWriteFileIfNotExists(fullPath: string, content: string): void {\n writeFileHandlers.push(async () => {\n await writeFileIfNotExists(fullPath, content);\n });\n}\n\nfunction throwErr(message: string): never {\n throw new Error(message);\n}\n\n// TODO import this function from stack-shared instead (but that would require us to fix the build to let us import it)\nexport function templateIdentity(strings: TemplateStringsArray, ...values: any[]): string {\n if (strings.length === 0) return \"\";\n if (values.length !== strings.length - 1) throw new Error(\"Invalid number of values; must be one less than strings\");\n\n return strings.slice(1).reduce((result, string, i) => `${result}${values[i] ?? \"n/a\"}${string}`, strings[0]);\n}\n\nasync function clearStdin(): Promise<void> {\n await new Promise<void>((resolve) => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n }\n process.stdin.resume();\n process.stdin.removeAllListeners('data');\n\n const flush = () => {\n while (process.stdin.read() !== null) { }\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n resolve();\n };\n\n // Add a small delay to allow any buffered input to clear\n setTimeout(flush, 10);\n });\n}\n","{\n \"name\": \"@stackframe/init-stack\",\n \"version\": \"2.8.40\",\n \"description\": \"The setup wizard for Stack. https://stack-auth.com\",\n \"main\": \"dist/index.js\",\n \"type\": \"module\",\n \"bin\": \"./dist/index.js\",\n \"scripts\": {\n \"clean\": \"rimraf test-run-output && rimraf node_modules && rimraf dist\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint --ext .tsx,.ts .\",\n \"typecheck\": \"tsc --noEmit\",\n \"init-stack\": \"node dist/index.js\",\n \"init-stack:local\": \"STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE=../../react node dist/index.js\",\n \"test-run\": \"pnpm run build && pnpm run test-run-js && pnpm run test-run-node && pnpm run test-run-next && pnpm run test-run-neon && pnpm run test-run-no-browser\",\n \"test-run:manual\": \"pnpm run build && pnpm run test-run-js:manual && pnpm run test-run-node:manual && pnpm run test-run-next:manual && pnpm run test-run-neon:manual\",\n \"ensure-neon\": \"grep -q '\\\"@neondatabase/serverless\\\"' ./test-run-output/package.json && echo 'Initialized Neon successfully!'\",\n \"test-run-neon\": \"pnpm run test-run-node --neon && pnpm run ensure-neon\",\n \"test-run-neon:manual\": \"pnpm run test-run-node:manual --neon && pnpm run ensure-neon\",\n \"test-run-no-browser\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser\",\n \"test-run-node:manual\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init && cd .. && pnpm run init-stack:local test-run-output\",\n \"test-run-node\": \"rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser\",\n \"test-run-js:manual\": \"rimraf test-run-output && npx -y sv create test-run-output --no-install && pnpm run init-stack:local test-run-output\",\n \"test-run-js\": \"rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --no-browser\",\n \"test-run-next:manual\": \"rimraf test-run-output && npx -y create-next-app@latest test-run-output && pnpm run init-stack:local test-run-output\",\n \"test-run-next\": \"rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --no-browser\",\n \"test-run-keys-next\": \"rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --project-id my-project-id --publishable-client-key my-publishable-client-key\",\n \"test-run-keys-js\": \"rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --project-id my-project-id --publishable-client-key my-publishable-client-key\",\n \"test-run-react\": \"rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --on-question error --no-browser --npm\",\n \"test-run-react:manual\": \"rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --react\"\n },\n \"files\": [\n \"README.md\",\n \"dist\",\n \"CHANGELOG.md\",\n \"LICENSE\"\n ],\n \"homepage\": \"https://stack-auth.com\",\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@stackframe/stack-shared\": \"workspace:*\",\n \"commander\": \"^13.1.0\",\n \"inquirer\": \"^9.2.19\",\n \"open\": \"^10.1.0\",\n \"posthog-node\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/inquirer\": \"^9.0.7\",\n \"@types/node\": \"20.17.6\",\n \"rimraf\": \"^6.0.1\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"5.3.3\"\n }\n}\n"],"mappings":";;;AAAA,YAAY,mBAAmB;AAC/B,SAAS,eAAe;AACxB,YAAY,YAAY;AACxB,YAAY,QAAQ;AACpB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,eAAe;;;ACRxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,KAAO;AAAA,EACP,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA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AAA,MAAE;AACxC,UAAI,QAAQ,MAAM,OAAO;AACvB,gBAAQ,MAAM,WAAW,KAAK;AAAA,MAChC;AACA,cAAQ;AAAA,IACV;AAGA,eAAW,OAAO,EAAE;AAAA,EACtB,CAAC;AACH;","names":["options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/init-stack",
3
- "version": "2.8.36",
3
+ "version": "2.8.40",
4
4
  "description": "The setup wizard for Stack. https://stack-auth.com",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "inquirer": "^9.2.19",
21
21
  "open": "^10.1.0",
22
22
  "posthog-node": "^4.1.0",
23
- "@stackframe/stack-shared": "2.8.36"
23
+ "@stackframe/stack-shared": "2.8.40"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/inquirer": "^9.0.7",
@@ -36,18 +36,22 @@
36
36
  "lint": "eslint --ext .tsx,.ts .",
37
37
  "typecheck": "tsc --noEmit",
38
38
  "init-stack": "node dist/index.js",
39
- "init-stack:local": "STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js node dist/index.js",
39
+ "init-stack:local": "STACK_NEXT_INSTALL_PACKAGE_NAME_OVERRIDE=../../stack STACK_JS_INSTALL_PACKAGE_NAME_OVERRIDE=../../js STACK_REACT_INSTALL_PACKAGE_NAME_OVERRIDE=../../react node dist/index.js",
40
40
  "test-run": "pnpm run build && pnpm run test-run-js && pnpm run test-run-node && pnpm run test-run-next && pnpm run test-run-neon && pnpm run test-run-no-browser",
41
41
  "test-run:manual": "pnpm run build && pnpm run test-run-js:manual && pnpm run test-run-node:manual && pnpm run test-run-next:manual && pnpm run test-run-neon:manual",
42
42
  "ensure-neon": "grep -q '\"@neondatabase/serverless\"' ./test-run-output/package.json && echo 'Initialized Neon successfully!'",
43
43
  "test-run-neon": "pnpm run test-run-node --neon && pnpm run ensure-neon",
44
44
  "test-run-neon:manual": "pnpm run test-run-node:manual --neon && pnpm run ensure-neon",
45
- "test-run-no-browser": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm --no-browser",
45
+ "test-run-no-browser": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser",
46
46
  "test-run-node:manual": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init && cd .. && pnpm run init-stack:local test-run-output",
47
- "test-run-node": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --server --npm",
47
+ "test-run-node": "rimraf test-run-output && mkdir test-run-output && cd test-run-output && npm init --init-author-name example-author --init-license UNLICENSED --init-author-url http://example.com --init-module test-run-output --init-version 1.0.0 -y && cd .. && pnpm run init-stack:local test-run-output --on-question error --js --server --npm --no-browser",
48
48
  "test-run-js:manual": "rimraf test-run-output && npx -y sv create test-run-output --no-install && pnpm run init-stack:local test-run-output",
49
- "test-run-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output --js --client --npm",
49
+ "test-run-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --no-browser",
50
50
  "test-run-next:manual": "rimraf test-run-output && npx -y create-next-app@latest test-run-output && pnpm run init-stack:local test-run-output",
51
- "test-run-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && STACK_DISABLE_INTERACTIVE=true pnpm run init-stack:local test-run-output"
51
+ "test-run-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --no-browser",
52
+ "test-run-keys-next": "rimraf test-run-output && npx -y create-next-app@latest test-run-output --app --ts --no-src-dir --tailwind --use-npm --eslint --import-alias '##@#/*' --turbopack && pnpm run init-stack:local test-run-output --on-question error --project-id my-project-id --publishable-client-key my-publishable-client-key",
53
+ "test-run-keys-js": "rimraf test-run-output && npx -y sv create test-run-output --template minimal --types ts --no-add-ons --no-install && pnpm run init-stack:local test-run-output --on-question error --js --client --npm --project-id my-project-id --publishable-client-key my-publishable-client-key",
54
+ "test-run-react": "rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --on-question error --no-browser --npm",
55
+ "test-run-react:manual": "rimraf test-run-output && npx -y create-vite@latest test-run-output --template react-ts && pnpm run init-stack:local test-run-output --react"
52
56
  }
53
57
  }