flaghoist 0.1.3 → 0.2.0

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 (2) hide show
  1. package/dist/index.js +45 -3
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  import { spawnSync } from "child_process";
11
11
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
12
12
  import { dirname, join } from "path";
13
+ import { createInterface } from "readline/promises";
13
14
  import { parseArgs } from "util";
14
15
 
15
16
  // src/admin.ts
@@ -392,7 +393,48 @@ function ensureDependencies() {
392
393
  throw new Error("`npm install` failed. Run it yourself, then `flaghoist deploy` again.");
393
394
  }
394
395
  }
395
- function runDeploy() {
396
+ function parseDeployTarget(args) {
397
+ const i = args.indexOf("--target");
398
+ if (i < 0) return null;
399
+ const value = args[i + 1]?.toLowerCase();
400
+ if (value === "cloudflare" || value === "cf" || value === "workers") return "cloudflare";
401
+ return "other";
402
+ }
403
+ async function promptDeployTarget() {
404
+ console.log("Where do you want to deploy?");
405
+ console.log(" 1) Cloudflare Workers recommended, deploys in one command");
406
+ console.log(" 2) Another platform Render, a container, any Node host");
407
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
408
+ try {
409
+ const answer = (await rl.question("Choose [1]: ")).trim().toLowerCase();
410
+ return answer === "2" || answer.startsWith("o") || answer.startsWith("r") ? "other" : "cloudflare";
411
+ } finally {
412
+ rl.close();
413
+ }
414
+ }
415
+ function printOtherTargets() {
416
+ console.log(`
417
+ Flaghoist runs on any Node, Bun, Deno, or container host, not just Cloudflare.
418
+
419
+ The project scaffolded here is a Cloudflare Worker. To run it elsewhere you serve the same
420
+ createFlagServer() app on Node and point it at Postgres or Redis instead of Workers KV.
421
+
422
+ Guides:
423
+ Render https://docs.flaghoist.dev/deploy/render/
424
+ All targets https://docs.flaghoist.dev/deploy/overview/
425
+
426
+ More platforms are on the way. Missing one you need? Open an issue at
427
+ https://github.com/flaghoist/flaghoist/issues.`);
428
+ }
429
+ async function runDeploy(args) {
430
+ let target = parseDeployTarget(args);
431
+ if (target === null) {
432
+ target = process.stdin.isTTY ? await promptDeployTarget() : "cloudflare";
433
+ }
434
+ if (target === "other") {
435
+ printOtherTargets();
436
+ return;
437
+ }
396
438
  const config = loadConfig();
397
439
  if (!existsSync("src/index.ts")) writeProject(config, ".");
398
440
  ensureDependencies();
@@ -409,7 +451,7 @@ Usage: flaghoist <command>
409
451
  Scaffolding
410
452
  init [--name N] [--storage cloudflare-kv|redis|postgres|memory]
411
453
  eject Generate a code project you own
412
- deploy Deploy to Cloudflare via wrangler
454
+ deploy [--target T] Deploy (prompts for the platform; T is cloudflare or other)
413
455
 
414
456
  Flag management (needs --url/--token or FLAGS_URL/FLAGS_ADMIN_TOKEN)
415
457
  flag list
@@ -430,7 +472,7 @@ async function main() {
430
472
  case "eject":
431
473
  return runEject();
432
474
  case "deploy":
433
- return runDeploy();
475
+ return runDeploy(rest);
434
476
  case "-v":
435
477
  case "--version":
436
478
  return console.log(VERSION);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flaghoist",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Scaffold, deploy, and manage your Flaghoist feature-flag service from the terminal.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -26,9 +26,9 @@
26
26
  "smol-toml": "^1.8.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@flaghoist/adapter-memory": "0.1.1",
30
- "@flaghoist/core": "0.1.1",
31
- "@flaghoist/server": "0.1.2"
29
+ "@flaghoist/core": "0.1.2",
30
+ "@flaghoist/adapter-memory": "0.1.2",
31
+ "@flaghoist/server": "0.3.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"