@stackframe/init-stack 2.5.3 → 2.5.5
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 +8 -0
- package/index.mjs +11 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.mjs
CHANGED
|
@@ -37,7 +37,13 @@ async function main() {
|
|
|
37
37
|
throw new UserError(`Expected file at ${nextConfigPath}. Only Next.js projects are currently supported.`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
const envPath = path.join(projectPath, '.env');
|
|
41
|
+
const envDevelopmentPath = path.join(projectPath, '.env.development');
|
|
42
|
+
const envDefaultPath = path.join(projectPath, '.env.default');
|
|
43
|
+
const envDefaultsPath = path.join(projectPath, '.env.defaults');
|
|
44
|
+
const envExamplePath = path.join(projectPath, '.env.example');
|
|
40
45
|
const envLocalPath = path.join(projectPath, '.env.local');
|
|
46
|
+
const potentialEnvLocations = [envPath, envDevelopmentPath, envDefaultPath, envDefaultsPath, envExamplePath, envLocalPath];
|
|
41
47
|
|
|
42
48
|
const hasSrcAppFolder = fs.existsSync(path.join(projectPath, 'src/app'));
|
|
43
49
|
const srcPath = path.join(projectPath, hasSrcAppFolder ? 'src' : '');
|
|
@@ -103,7 +109,9 @@ async function main() {
|
|
|
103
109
|
|
|
104
110
|
console.log();
|
|
105
111
|
console.log("Writing files...");
|
|
106
|
-
|
|
112
|
+
if (potentialEnvLocations.every((p) => !fs.existsSync(p))) {
|
|
113
|
+
await writeFile(envLocalPath, "# 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");
|
|
114
|
+
}
|
|
107
115
|
await writeFileIfNotExists(loadingPath, `export default function Loading() {\n${ind}// Stack uses React Suspense, which will render this page while user data is being fetched.\n${ind}// See: https://nextjs.org/docs/app/api-reference/file-conventions/loading\n${ind}return <></>;\n}\n`);
|
|
108
116
|
await writeFileIfNotExists(handlerPath, `import { StackHandler } from "@stackframe/stack";\nimport { stackServerApp } from "../../../stack";\n\nexport default function Handler(props${handlerFileExtension.includes("ts") ? ": any" : ""}) {\n${ind}return <StackHandler fullPage app={stackServerApp} {...props} />;\n}\n`);
|
|
109
117
|
await writeFileIfNotExists(stackAppPath, `import "server-only";\n\nimport { StackServerApp } from "@stackframe/stack";\n\nexport const stackServerApp = new StackServerApp({\n${ind}tokenStore: "nextjs-cookie",\n});\n`);
|
|
@@ -121,7 +129,7 @@ main().then(async() => {
|
|
|
121
129
|
console.log();
|
|
122
130
|
console.log("Next up, please create an account on https://app.stack-auth.com to create a new project, and copy the Next.js environment variables from a new API key into your .env.local file.");
|
|
123
131
|
console.log();
|
|
124
|
-
console.log("Then, you will be able to access your sign-in page on http://your-website.example.com/handler/
|
|
132
|
+
console.log("Then, you will be able to access your sign-in page on http://your-website.example.com/handler/sign-in. Congratulations!");
|
|
125
133
|
console.log();
|
|
126
134
|
console.log("For more information, please visit https://docs.stack-auth.com/docs/getting-started/setup");
|
|
127
135
|
console.log();
|
|
@@ -139,7 +147,7 @@ main().then(async() => {
|
|
|
139
147
|
if (err instanceof UserError) {
|
|
140
148
|
console.error("[ERR] Error: " + err.message);
|
|
141
149
|
} else {
|
|
142
|
-
console.error("[ERR] An error
|
|
150
|
+
console.error("[ERR] An error occurred during the initialization process.");
|
|
143
151
|
}
|
|
144
152
|
console.error("[ERR]");
|
|
145
153
|
console.error("[ERR] If you need assistance, please try installing Slack manually as described in https://docs.stack-auth.com/docs/getting-started/setup or join our Discord where we're happy to help: https://discord.stack-auth.com");
|