create-seamless 0.0.8 → 0.0.11

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +47 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # create-seamless
2
2
 
3
- [![License: AGPL-3](https://img.shields.io/badge/License-AGPL3-yellow.svg)](LICENSE)
3
+ [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL3-yellow.svg)](LICENSE)
4
4
  [![npm version](https://img.shields.io/npm/v/create-seamless.svg?style=flat)](https://www.npmjs.com/package/create-seamless)
5
5
 
6
6
  `create-seamless` is a project scaffolding tool for building applications with **Seamless Auth**, an open source, passwordless authentication system.
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: 5173)
53
+ --web-port <n> Web server port (default: 5001)
34
54
 
35
55
  -h, --help Show this help message
36
56
 
@@ -344,6 +364,16 @@ async function downloadRepo(repo, dest) {
344
364
  console.log(`\nCreating Seamless project: ${projectName}\n`);
345
365
  const API_SERVICE_TOKEN = randomBytes(32).toString("hex");
346
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
+
347
377
  if (AUTH) {
348
378
  const dir = path.join(root, "auth");
349
379
  fs.mkdirSync(dir);
@@ -368,7 +398,7 @@ async function downloadRepo(repo, dest) {
368
398
 
369
399
  DB_LOGGING: "false",
370
400
  DB_HOST: "localhost",
371
- DB_PORT: "5432",
401
+ DB_PORT: dbHostPort,
372
402
  DB_NAME: "seamless_auth",
373
403
  DB_USER: "myuser",
374
404
  DB_PASSWORD: "mypassword",
@@ -399,9 +429,10 @@ async function downloadRepo(repo, dest) {
399
429
  UI_ORIGIN: `http://localhost:${webPort}`,
400
430
  COOKIE_SIGNING_KEY: randomBytes(32).toString("hex"),
401
431
  API_SERVICE_TOKEN: API_SERVICE_TOKEN,
432
+ JWKS_KID: "dev-main",
402
433
 
403
434
  DB_HOST: "localhost",
404
- DB_PORT: "5432",
435
+ DB_PORT: dbHostPort,
405
436
  DB_NAME: "seamless_api",
406
437
  DB_USER: "myuser",
407
438
  DB_PASSWORD: "mypassword",
@@ -430,10 +461,17 @@ async function downloadRepo(repo, dest) {
430
461
  }
431
462
 
432
463
  if (AUTH && API && WEB) {
433
- fs.writeFileSync(
434
- path.join(root, "Docker-compose.yml"),
435
- GENERATED_DOCKER_COMPOSE,
464
+ const compose = GENERATED_DOCKER_COMPOSE.replace(
465
+ '"5432:5432"',
466
+ `"${dbHostPort}:5432"`,
436
467
  );
468
+
469
+ fs.writeFileSync(path.join(root, "docker-compose.yml"), compose);
470
+ }
471
+
472
+ if (AUTH) {
473
+ const authScriptPath = path.join(root, "auth", "validateEnvs.sh");
474
+ ensureExecutable(authScriptPath);
437
475
  }
438
476
 
439
477
  const pgDir = path.join(root, "postgres_init");
@@ -470,6 +508,9 @@ Start development:
470
508
 
471
509
  docker compose up
472
510
 
511
+ If you already have Postgres running locally,
512
+ the generator may map Docker to port 5433 instead.
513
+
473
514
  Docs: https://docs.seamlessauth.com/docs
474
515
  Happy hacking. 🚀
475
516
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-seamless",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "description": "The starter script for Seamless Auth",
5
5
  "homepage": "https://github.com/fells-code/create-seamless#readme",
6
6
  "bugs": {