wawesome 0.0.10 → 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 (2) hide show
  1. package/dist/index.mjs +29 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -161,7 +161,7 @@ async function buildJs(entryInput, options) {
161
161
  * that has to name this version — `--version`, the dependency a scaffolded
162
162
  * project pins — reads it here, so a release bumps one file.
163
163
  */
164
- const CLI_VERSION = "0.0.10";
164
+ const CLI_VERSION = "0.0.11";
165
165
  //#endregion
166
166
  //#region src/prompt.ts
167
167
  /**
@@ -551,7 +551,9 @@ function mountBase(origin, tenantSlug) {
551
551
  return `${origin.replace(/\/+$/, "")}${INVOCATION_PREFIX}/${encodeURIComponent(tenantSlug)}`;
552
552
  }
553
553
  function publicAddress(origin, tenantSlug, appSlug, functionSlug) {
554
- return `${mountBase(origin, tenantSlug)}/${encodeURIComponent(appSlug)}/${encodeURIComponent(functionSlug)}`;
554
+ const base = `${mountBase(origin, tenantSlug)}/${encodeURIComponent(appSlug)}`;
555
+ if (functionSlug === "root") return base;
556
+ return `${base}/${encodeURIComponent(functionSlug)}`;
555
557
  }
556
558
  /** The same address with the app and function still to be chosen. */
557
559
  function publicAddressTemplate(origin, tenantSlug) {
@@ -1736,7 +1738,10 @@ async function init(options) {
1736
1738
  let functionName;
1737
1739
  let appSlug;
1738
1740
  try {
1739
- functionName = await promptForSlug(session, "Function name", dirName);
1741
+ if (options.root) {
1742
+ functionName = "root";
1743
+ console.log(" Function name? root (locked by --root)");
1744
+ } else functionName = await promptForSlug(session, "Function name", dirName);
1740
1745
  console.log(" (an App groups the Functions of one project — its slug is part of the public URL)");
1741
1746
  appSlug = await promptForSlug(session, "App slug", dirName);
1742
1747
  } finally {
@@ -1760,7 +1765,26 @@ async function init(options) {
1760
1765
  if (fs.existsSync(indexPath)) console.log("[wawesome] src/index.ts already exists, skipping.");
1761
1766
  else {
1762
1767
  fs.mkdirSync(srcDir, { recursive: true });
1763
- fs.writeFileSync(indexPath, `/**
1768
+ fs.writeFileSync(indexPath, options.root ? `/**
1769
+ * Root Function Router
1770
+ * Handles all requests that don't match a specific function path.
1771
+ */
1772
+ export default {
1773
+ async fetch(request: Request): Promise<Response> {
1774
+ const url = new URL(request.url);
1775
+
1776
+ // Example router
1777
+ switch (url.pathname) {
1778
+ case "/":
1779
+ return Response.json({ message: "Welcome to the App Root!" });
1780
+ case "/health":
1781
+ return Response.json({ status: "ok" });
1782
+ default:
1783
+ return Response.json({ error: "Not Found" }, { status: 404 });
1784
+ }
1785
+ },
1786
+ };
1787
+ ` : `/**
1764
1788
  * Serverless Function Handler
1765
1789
  * Standard HTTP fetch request handler
1766
1790
  */
@@ -2571,7 +2595,7 @@ cli.command("logout", "Clear stored authentication credentials").action(() => lo
2571
2595
  cli.command("whoami", "Show current login session info").action(() => whoami());
2572
2596
  cli.command("workspace [action] [name]", "Show the workspace, or rename its public address").usage("workspace <action> [name]\n\nActions:\n show Show the workspace name, address, and whether it can still change\n rename <name> Change the public address, while nothing live depends on it").example("wawesome workspace").example("wawesome workspace rename northwind").option("-v, --verbose", "Enable verbose debug output").action((action, name, options) => workspaceCommand(action, name, options));
2573
2597
  cli.command("templates [action]", "Browse the template catalog").usage("templates [action]\n\nActions:\n list (ls) Show every available template (default)").example("wawesome templates").example("wawesome templates list").option("--api <url>", "API URL (default: https://api.wawesome.io)").option("-v, --verbose", "Enable verbose debug output").action((action, options) => templatesCommand(action, options));
2574
- cli.command("init", "Scaffold a new function project in the current directory").usage("init [options]\n\nWith --template, the project is fetched from the template catalog, wired up\nfrom what the template declares it needs, and deployed. Run 'wawesome templates'\nto see what is available.").example("wawesome init").example("wawesome init --template stripe-webhook").option("-t, --template <name>", "Scaffold from a catalog template and deploy it").option("--api <url>", "API URL (default: https://api.wawesome.io)").option("--no-install", "Skip installing dependencies after scaffolding").option("-v, --verbose", "Enable verbose debug output").action((options) => init(options));
2598
+ cli.command("init", "Scaffold a new function project in the current directory").usage("init [options]\n\nWith --template, the project is fetched from the template catalog, wired up\nfrom what the template declares it needs, and deployed. Run 'wawesome templates'\nto see what is available.").example("wawesome init").example("wawesome init --template stripe-webhook").option("-t, --template <name>", "Scaffold from a catalog template and deploy it").option("--api <url>", "API URL (default: https://api.wawesome.io)").option("--no-install", "Skip installing dependencies after scaffolding").option("--root", "Generate a root function router template").option("-v, --verbose", "Enable verbose debug output").action((options) => init(options));
2575
2599
  cli.command("logs [function-name-or-invocation-id]", "View invocation history, fetch log output, or follow live").usage(`logs [target] [options]
2576
2600
 
2577
2601
  The target argument determines what the command does:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wawesome",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "CLI tool for building and deploying serverless functions on wawesome.io platform",
5
5
  "type": "module",
6
6
  "bin": {