@basaltkit/deploy 0.10.0 → 0.10.1

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/init.js +13 -5
  2. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -444,27 +444,35 @@ export async function init(host, dir, flags, switches) {
444
444
  host.out.error(`${file} already exists — init never overwrites it (--force to replace it)`);
445
445
  return 1;
446
446
  }
447
- const answer = async (key, question, fallback) => {
447
+ // host.prompt adds the ": " itself. With `choices`, a terminal answer outside
448
+ // them is asked again (a typo must not abort init); a flag is never re-asked.
449
+ const answer = async (key, question, fallback, choices) => {
448
450
  const given = flags.get(key);
449
451
  if (given !== undefined)
450
452
  return given;
451
453
  if (!host.interactive())
452
454
  return fallback;
453
- const typed = (await host.prompt(`${question}${fallback ? ` [${fallback}]` : ''}: `, { secret: false }))?.trim();
454
- return typed || fallback;
455
+ for (let attempt = 0; attempt < 3; attempt += 1) {
456
+ const typed = (await host.prompt(`${question}${fallback ? ` [${fallback}]` : ''}`, { secret: false }))?.trim();
457
+ const value = typed || fallback;
458
+ if (!choices || value === undefined || choices.includes(value))
459
+ return value;
460
+ host.out.warn(`"${value}" is not one of: ${choices.join(', ')}`);
461
+ }
462
+ return undefined;
455
463
  };
456
464
  const domain = await answer('domain', 'Domain the app answers on (e.g. acme.example.ao)');
457
465
  if (!domain || !/^[a-z0-9.-]+\.[a-z]{2,}$/.test(domain)) {
458
466
  host.out.error(`--domain=<host> is required${domain ? `: "${domain}" is not a host name` : ''}`);
459
467
  return 1;
460
468
  }
461
- const tenants = await answer('tenants', 'Tenants on subdomains (<id>.domain)? subdomain | none', 'none');
469
+ const tenants = await answer('tenants', `Multi-tenant, each tenant on its own subdomain (<tenant>.${domain})? subdomain | none`, 'none', ['subdomain', 'none']);
462
470
  if (tenants !== 'subdomain' && tenants !== 'none') {
463
471
  host.out.error('--tenants is subdomain or none');
464
472
  return 1;
465
473
  }
466
474
  const branch = (await answer('branch', 'Branch deployed', 'main')) ?? 'main';
467
- const proxy = (await answer('proxy', 'Proxy on this server: apache | caddy | none', 'apache')) ?? 'apache';
475
+ const proxy = (await answer('proxy', 'Proxy on this server: apache | caddy | none', 'apache', ['apache', 'caddy', 'none'])) ?? 'apache';
468
476
  if (proxy !== 'apache' && proxy !== 'caddy' && proxy !== 'none') {
469
477
  host.out.error('--proxy is apache, caddy or none');
470
478
  return 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basaltkit/deploy",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "engines": {
5
5
  "node": ">=22.5.0"
6
6
  },