create-seamless 0.0.7 → 0.0.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/index.js +49 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -7,12 +7,32 @@ import { promisify } from "util";
|
|
|
7
7
|
import { createWriteStream } from "fs";
|
|
8
8
|
import AdmZip from "adm-zip";
|
|
9
9
|
import { randomBytes } from "crypto";
|
|
10
|
+
import net from "net";
|
|
10
11
|
|
|
11
12
|
const streamPipeline = promisify(pipeline);
|
|
12
13
|
|
|
13
14
|
const MIN_NODE_MAJOR = 18;
|
|
14
15
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
15
16
|
|
|
17
|
+
function ensureExecutable(filePath) {
|
|
18
|
+
if (fs.existsSync(filePath)) {
|
|
19
|
+
fs.chmodSync(filePath, 0o755);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isPortAvailable(port) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
const server = net
|
|
26
|
+
.createServer()
|
|
27
|
+
.once("error", () => resolve(false))
|
|
28
|
+
.once("listening", () => {
|
|
29
|
+
server.close();
|
|
30
|
+
resolve(true);
|
|
31
|
+
})
|
|
32
|
+
.listen(port);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
function printHelp() {
|
|
17
37
|
console.log(`
|
|
18
38
|
create-seamless
|
|
@@ -30,7 +50,7 @@ Options:
|
|
|
30
50
|
|
|
31
51
|
--auth-port <n> Auth server port (default: 5312)
|
|
32
52
|
--api-port <n> API server port (default: 3000)
|
|
33
|
-
--web-port <n> Web server port (default:
|
|
53
|
+
--web-port <n> Web server port (default: 5001)
|
|
34
54
|
|
|
35
55
|
-h, --help Show this help message
|
|
36
56
|
|
|
@@ -274,6 +294,7 @@ services:
|
|
|
274
294
|
- ./api/.env
|
|
275
295
|
environment:
|
|
276
296
|
AUTH_SERVER_URL: http://auth:${authPort}
|
|
297
|
+
DB_HOST: db
|
|
277
298
|
volumes:
|
|
278
299
|
- ./api:/app
|
|
279
300
|
- /app/node_modules
|
|
@@ -343,6 +364,16 @@ async function downloadRepo(repo, dest) {
|
|
|
343
364
|
console.log(`\nCreating Seamless project: ${projectName}\n`);
|
|
344
365
|
const API_SERVICE_TOKEN = randomBytes(32).toString("hex");
|
|
345
366
|
|
|
367
|
+
let dbHostPort = "5432";
|
|
368
|
+
|
|
369
|
+
if (!(await isPortAvailable(5432))) {
|
|
370
|
+
dbHostPort = "5433";
|
|
371
|
+
console.log(`
|
|
372
|
+
⚠️ Port 5432 is already in use on your machine.
|
|
373
|
+
Using 5433 for Docker Postgres instead.
|
|
374
|
+
`);
|
|
375
|
+
}
|
|
376
|
+
|
|
346
377
|
if (AUTH) {
|
|
347
378
|
const dir = path.join(root, "auth");
|
|
348
379
|
fs.mkdirSync(dir);
|
|
@@ -367,7 +398,7 @@ async function downloadRepo(repo, dest) {
|
|
|
367
398
|
|
|
368
399
|
DB_LOGGING: "false",
|
|
369
400
|
DB_HOST: "localhost",
|
|
370
|
-
DB_PORT:
|
|
401
|
+
DB_PORT: dbHostPort,
|
|
371
402
|
DB_NAME: "seamless_auth",
|
|
372
403
|
DB_USER: "myuser",
|
|
373
404
|
DB_PASSWORD: "mypassword",
|
|
@@ -400,7 +431,7 @@ async function downloadRepo(repo, dest) {
|
|
|
400
431
|
API_SERVICE_TOKEN: API_SERVICE_TOKEN,
|
|
401
432
|
|
|
402
433
|
DB_HOST: "localhost",
|
|
403
|
-
DB_PORT:
|
|
434
|
+
DB_PORT: dbHostPort,
|
|
404
435
|
DB_NAME: "seamless_api",
|
|
405
436
|
DB_USER: "myuser",
|
|
406
437
|
DB_PASSWORD: "mypassword",
|
|
@@ -416,8 +447,8 @@ async function downloadRepo(repo, dest) {
|
|
|
416
447
|
await downloadRepo(REPOS.web, dir);
|
|
417
448
|
|
|
418
449
|
writeEnv(dir, {
|
|
419
|
-
VITE_AUTH_SERVER_URL: `http://localhost:${apiPort}
|
|
420
|
-
VITE_API_URL: `http://localhost:${apiPort}
|
|
450
|
+
VITE_AUTH_SERVER_URL: `http://localhost:${apiPort}/`,
|
|
451
|
+
VITE_API_URL: `http://localhost:${apiPort}/`,
|
|
421
452
|
PORT: webPort,
|
|
422
453
|
});
|
|
423
454
|
}
|
|
@@ -429,10 +460,17 @@ async function downloadRepo(repo, dest) {
|
|
|
429
460
|
}
|
|
430
461
|
|
|
431
462
|
if (AUTH && API && WEB) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
463
|
+
const compose = GENERATED_DOCKER_COMPOSE.replace(
|
|
464
|
+
'"5432:5432"',
|
|
465
|
+
`"${dbHostPort}:5432"`,
|
|
435
466
|
);
|
|
467
|
+
|
|
468
|
+
fs.writeFileSync(path.join(root, "docker-compose.yml"), compose);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (AUTH) {
|
|
472
|
+
const authScriptPath = path.join(root, "auth", "validateEnvs.sh");
|
|
473
|
+
ensureExecutable(authScriptPath);
|
|
436
474
|
}
|
|
437
475
|
|
|
438
476
|
const pgDir = path.join(root, "postgres_init");
|
|
@@ -469,6 +507,9 @@ Start development:
|
|
|
469
507
|
|
|
470
508
|
docker compose up
|
|
471
509
|
|
|
510
|
+
If you already have Postgres running locally,
|
|
511
|
+
the generator may map Docker to port 5433 instead.
|
|
512
|
+
|
|
472
513
|
Docs: https://docs.seamlessauth.com/docs
|
|
473
514
|
Happy hacking. 🚀
|
|
474
515
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-seamless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "The starter script for Seamless Auth",
|
|
5
5
|
"homepage": "https://github.com/fells-code/create-seamless#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"@types/adm-zip": "^0.5.7",
|
|
34
34
|
"@types/node": "^24.10.1"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|