@stackframe/init-stack 2.7.7 → 2.7.9
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 +13 -0
- package/index.mjs +59 -82
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
package/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import inquirer from "inquirer";
|
|
4
|
-
import * as fs from "fs";
|
|
5
3
|
import * as child_process from "child_process";
|
|
6
|
-
import * as
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import inquirer from "inquirer";
|
|
7
6
|
import open from "open";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { templateIdentity, deindent } from '@stackframe/stack-shared/dist/utils/strings'
|
|
8
9
|
|
|
9
10
|
const jsLikeFileExtensions = [
|
|
10
11
|
"mtsx",
|
|
@@ -31,16 +32,26 @@ class UserError extends Error {
|
|
|
31
32
|
let savedProjectPath = process.argv[2] || undefined;
|
|
32
33
|
|
|
33
34
|
const isDryRun = process.argv.includes("--dry-run");
|
|
35
|
+
const isNeon = process.argv.includes("--neon");
|
|
34
36
|
|
|
35
37
|
const ansis = {
|
|
36
38
|
red: "\x1b[31m",
|
|
37
39
|
blue: "\x1b[34m",
|
|
38
40
|
green: "\x1b[32m",
|
|
39
41
|
yellow: "\x1b[33m",
|
|
42
|
+
|
|
40
43
|
clear: "\x1b[0m",
|
|
41
44
|
bold: "\x1b[1m",
|
|
42
45
|
};
|
|
43
46
|
|
|
47
|
+
const colorize = {
|
|
48
|
+
red: (strings, ...values) => ansis.red + templateIdentity(strings, ...values) + ansis.clear,
|
|
49
|
+
blue: (strings, ...values) => ansis.blue + templateIdentity(strings, ...values) + ansis.clear,
|
|
50
|
+
green: (strings, ...values) => ansis.green + templateIdentity(strings, ...values) + ansis.clear,
|
|
51
|
+
yellow: (strings, ...values) => ansis.yellow + templateIdentity(strings, ...values) + ansis.clear,
|
|
52
|
+
bold: (strings, ...values) => ansis.bold + templateIdentity(strings, ...values) + ansis.clear,
|
|
53
|
+
}
|
|
54
|
+
|
|
44
55
|
const filesCreated = [];
|
|
45
56
|
const filesModified = [];
|
|
46
57
|
const commandsExecuted = [];
|
|
@@ -103,18 +114,15 @@ async function main() {
|
|
|
103
114
|
);
|
|
104
115
|
}
|
|
105
116
|
|
|
106
|
-
|
|
107
|
-
const envDevelopmentPath = path.join(projectPath, ".env.development");
|
|
108
|
-
const envDefaultPath = path.join(projectPath, ".env.default");
|
|
109
|
-
const envDefaultsPath = path.join(projectPath, ".env.defaults");
|
|
110
|
-
const envExamplePath = path.join(projectPath, ".env.example");
|
|
117
|
+
|
|
111
118
|
const envLocalPath = path.join(projectPath, ".env.local");
|
|
119
|
+
|
|
112
120
|
const potentialEnvLocations = [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
path.join(projectPath, ".env"),
|
|
122
|
+
path.join(projectPath, ".env.development"),
|
|
123
|
+
path.join(projectPath, ".env.default"),
|
|
124
|
+
path.join(projectPath, ".env.defaults"),
|
|
125
|
+
path.join(projectPath, ".env.example"),
|
|
118
126
|
envLocalPath,
|
|
119
127
|
];
|
|
120
128
|
|
|
@@ -184,8 +192,6 @@ async function main() {
|
|
|
184
192
|
|
|
185
193
|
const packageManager = await getPackageManager();
|
|
186
194
|
const versionCommand = `${packageManager} --version`;
|
|
187
|
-
const installCommand =
|
|
188
|
-
packageManager === "yarn" ? "yarn add" : `${packageManager} install`;
|
|
189
195
|
|
|
190
196
|
try {
|
|
191
197
|
await shellNicelyFormatted(versionCommand, { shell: true, quiet: true });
|
|
@@ -195,8 +201,6 @@ async function main() {
|
|
|
195
201
|
);
|
|
196
202
|
}
|
|
197
203
|
|
|
198
|
-
const stackPackageName = process.env.STACK_PACKAGE_NAME_OVERRIDE || "@stackframe/stack";
|
|
199
|
-
|
|
200
204
|
const isReady = await inquirer.prompt([
|
|
201
205
|
{
|
|
202
206
|
type: "confirm",
|
|
@@ -210,14 +214,20 @@ async function main() {
|
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
console.log();
|
|
213
|
-
console.log(
|
|
214
|
-
|
|
217
|
+
console.log(colorize.bold`Installing dependencies...`);
|
|
218
|
+
const packagesToInstall = [process.env.STACK_PACKAGE_NAME_OVERRIDE || "@stackframe/stack"];
|
|
219
|
+
if (isNeon) {
|
|
220
|
+
packagesToInstall.push('@neondatabase/serverless');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const installCommand = packageManager === "yarn" ? "yarn add" : `${packageManager} install`;
|
|
224
|
+
await shellNicelyFormatted(`${installCommand} ${packagesToInstall.join(' ')}`, {
|
|
215
225
|
shell: true,
|
|
216
226
|
cwd: projectPath,
|
|
217
227
|
});
|
|
218
228
|
|
|
219
229
|
console.log();
|
|
220
|
-
console.log(
|
|
230
|
+
console.log(colorize.bold`Writing files...`);
|
|
221
231
|
console.log();
|
|
222
232
|
if (potentialEnvLocations.every((p) => !fs.existsSync(p))) {
|
|
223
233
|
await writeFile(
|
|
@@ -240,62 +250,42 @@ async function main() {
|
|
|
240
250
|
`import "server-only";\n\nimport { StackServerApp } from "@stackframe/stack";\n\nexport const stackServerApp = new StackServerApp({\n${ind}tokenStore: "nextjs-cookie",\n});\n`
|
|
241
251
|
);
|
|
242
252
|
await writeFile(layoutPath, updatedLayoutContent);
|
|
243
|
-
console.log(`${
|
|
253
|
+
console.log(`${colorize.green`√`} Done writing files`);
|
|
244
254
|
|
|
245
|
-
console.log();
|
|
246
|
-
console.log();
|
|
247
|
-
console.log();
|
|
248
|
-
console.log(
|
|
249
|
-
`${ansis.bold}${ansis.green}Installation succeeded!${ansis.clear}`
|
|
250
|
-
);
|
|
255
|
+
console.log('\n\n\n');
|
|
256
|
+
console.log(colorize.bold`${colorize.green`Installation succeeded!`}`);
|
|
251
257
|
console.log();
|
|
252
258
|
console.log("Commands executed:");
|
|
253
259
|
for (const command of commandsExecuted) {
|
|
254
|
-
console.log(` ${
|
|
260
|
+
console.log(` ${colorize.blue`${command}`}`);
|
|
255
261
|
}
|
|
256
262
|
console.log();
|
|
257
263
|
console.log("Files written:");
|
|
258
264
|
for (const file of filesModified) {
|
|
259
|
-
console.log(` ${
|
|
265
|
+
console.log(` ${colorize.yellow`${file}`}`);
|
|
260
266
|
}
|
|
261
267
|
for (const file of filesCreated) {
|
|
262
|
-
console.log(` ${
|
|
268
|
+
console.log(` ${colorize.green`${file}`}`);
|
|
263
269
|
}
|
|
264
270
|
}
|
|
265
271
|
main()
|
|
266
272
|
.then(async () => {
|
|
267
|
-
console.log(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
);
|
|
283
|
-
console.log(
|
|
284
|
-
" 2. Copy the environment variables from the new API key into your .env.local file"
|
|
285
|
-
);
|
|
286
|
-
console.log();
|
|
287
|
-
console.log(
|
|
288
|
-
"Then, you will be able to access your sign-in page on http://your-website.example.com/handler/sign-in. That's it!"
|
|
289
|
-
);
|
|
290
|
-
console.log();
|
|
291
|
-
console.log(
|
|
292
|
-
`${ansis.green}===============================================${ansis.clear}`
|
|
293
|
-
);
|
|
294
|
-
console.log();
|
|
295
|
-
console.log(
|
|
296
|
-
"For more information, please visit https://docs.stack-auth.com/getting-started/setup"
|
|
297
|
-
);
|
|
298
|
-
console.log();
|
|
273
|
+
console.log(deindent`
|
|
274
|
+
${colorize.green`===============================================`}
|
|
275
|
+
|
|
276
|
+
${colorize.green`Successfully installed Stack! 🚀🚀🚀`}
|
|
277
|
+
|
|
278
|
+
Next steps:
|
|
279
|
+
|
|
280
|
+
1. Create an account and project on https://app.stack-auth.com
|
|
281
|
+
2. Copy the environment variables from the new API key into your .env.local file
|
|
282
|
+
|
|
283
|
+
Then, you will be able to access your sign-in page on http://your-website.example.com/handler/sign-in. That's it!
|
|
284
|
+
|
|
285
|
+
${colorize.green`===============================================`}
|
|
286
|
+
|
|
287
|
+
For more information, please visit https://docs.stack-auth.com/getting-started/setup
|
|
288
|
+
`);
|
|
299
289
|
if (!process.env.STACK_DISABLE_INTERACTIVE) {
|
|
300
290
|
await open("https://app.stack-auth.com/wizard-congrats");
|
|
301
291
|
}
|
|
@@ -304,23 +294,16 @@ main()
|
|
|
304
294
|
if (!(err instanceof UserError)) {
|
|
305
295
|
console.error(err);
|
|
306
296
|
}
|
|
307
|
-
console.error();
|
|
308
|
-
console.
|
|
309
|
-
console.error();
|
|
310
|
-
console.error();
|
|
311
|
-
console.error(
|
|
312
|
-
`${ansis.red}===============================================${ansis.clear}`
|
|
313
|
-
);
|
|
297
|
+
console.error('\n\n\n\n');
|
|
298
|
+
console.log(colorize.red`===============================================`);
|
|
314
299
|
console.error();
|
|
315
300
|
if (err instanceof UserError) {
|
|
316
|
-
console.error(`${
|
|
301
|
+
console.error(`${colorize.red`ERROR!`} ${err.message}`);
|
|
317
302
|
} else {
|
|
318
303
|
console.error("An error occurred during the initialization process.");
|
|
319
304
|
}
|
|
320
305
|
console.error();
|
|
321
|
-
console.
|
|
322
|
-
`${ansis.red}===============================================${ansis.clear}`
|
|
323
|
-
);
|
|
306
|
+
console.log(colorize.red`===============================================`);
|
|
324
307
|
console.error();
|
|
325
308
|
console.error(
|
|
326
309
|
"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"
|
|
@@ -483,14 +466,12 @@ async function shellNicelyFormatted(command, { quiet, ...options }) {
|
|
|
483
466
|
const ui = new inquirer.ui.BottomBar();
|
|
484
467
|
let dots = 4;
|
|
485
468
|
ui.updateBottomBar(
|
|
486
|
-
|
|
469
|
+
colorize.blue`Running command: ${command}...`
|
|
487
470
|
);
|
|
488
471
|
const interval = setInterval(() => {
|
|
489
472
|
if (!isDryRun) {
|
|
490
473
|
ui.updateBottomBar(
|
|
491
|
-
|
|
492
|
-
ansis.clear
|
|
493
|
-
}`
|
|
474
|
+
colorize.blue`Running command: ${command}${".".repeat(dots++ % 5)}`
|
|
494
475
|
);
|
|
495
476
|
}
|
|
496
477
|
}, 700);
|
|
@@ -523,7 +504,7 @@ async function shellNicelyFormatted(command, { quiet, ...options }) {
|
|
|
523
504
|
ui.updateBottomBar(
|
|
524
505
|
quiet
|
|
525
506
|
? ""
|
|
526
|
-
: `${
|
|
507
|
+
: `${colorize.green`√`} Command ${command} succeeded\n`
|
|
527
508
|
);
|
|
528
509
|
ui.close();
|
|
529
510
|
}
|
|
@@ -564,10 +545,6 @@ async function writeFileIfNotExists(fullPath, content) {
|
|
|
564
545
|
}
|
|
565
546
|
}
|
|
566
547
|
|
|
567
|
-
async function wait(ms) {
|
|
568
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
569
|
-
}
|
|
570
|
-
|
|
571
548
|
function throwErr(message) {
|
|
572
549
|
throw new Error(message);
|
|
573
550
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/init-stack",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.9",
|
|
4
4
|
"description": "The setup wizard for Stack. https://stack-auth.com",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": "./index.mjs",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"inquirer": "^9.2.19",
|
|
19
|
-
"open": "^10.1.0"
|
|
19
|
+
"open": "^10.1.0",
|
|
20
|
+
"@stackframe/stack-shared": "2.7.9"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
23
|
"clean": "rimraf test-run-output && rimraf node_modules",
|