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