wawesome 0.0.10 → 0.0.12
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/dist/index.mjs +35 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -130,7 +130,12 @@ async function buildJs(entryInput, options) {
|
|
|
130
130
|
bundle: true,
|
|
131
131
|
format: "esm",
|
|
132
132
|
outfile: outPath,
|
|
133
|
-
platform: "
|
|
133
|
+
platform: "browser",
|
|
134
|
+
conditions: [
|
|
135
|
+
"workerd",
|
|
136
|
+
"worker",
|
|
137
|
+
"browser"
|
|
138
|
+
],
|
|
134
139
|
target: "es2022",
|
|
135
140
|
treeShaking: true,
|
|
136
141
|
minify: true,
|
|
@@ -161,7 +166,7 @@ async function buildJs(entryInput, options) {
|
|
|
161
166
|
* that has to name this version — `--version`, the dependency a scaffolded
|
|
162
167
|
* project pins — reads it here, so a release bumps one file.
|
|
163
168
|
*/
|
|
164
|
-
const CLI_VERSION = "0.0.
|
|
169
|
+
const CLI_VERSION = "0.0.12";
|
|
165
170
|
//#endregion
|
|
166
171
|
//#region src/prompt.ts
|
|
167
172
|
/**
|
|
@@ -551,7 +556,9 @@ function mountBase(origin, tenantSlug) {
|
|
|
551
556
|
return `${origin.replace(/\/+$/, "")}${INVOCATION_PREFIX}/${encodeURIComponent(tenantSlug)}`;
|
|
552
557
|
}
|
|
553
558
|
function publicAddress(origin, tenantSlug, appSlug, functionSlug) {
|
|
554
|
-
|
|
559
|
+
const base = `${mountBase(origin, tenantSlug)}/${encodeURIComponent(appSlug)}`;
|
|
560
|
+
if (functionSlug === "root") return base;
|
|
561
|
+
return `${base}/${encodeURIComponent(functionSlug)}`;
|
|
555
562
|
}
|
|
556
563
|
/** The same address with the app and function still to be chosen. */
|
|
557
564
|
function publicAddressTemplate(origin, tenantSlug) {
|
|
@@ -1736,7 +1743,10 @@ async function init(options) {
|
|
|
1736
1743
|
let functionName;
|
|
1737
1744
|
let appSlug;
|
|
1738
1745
|
try {
|
|
1739
|
-
|
|
1746
|
+
if (options.root) {
|
|
1747
|
+
functionName = "root";
|
|
1748
|
+
console.log(" Function name? root (locked by --root)");
|
|
1749
|
+
} else functionName = await promptForSlug(session, "Function name", dirName);
|
|
1740
1750
|
console.log(" (an App groups the Functions of one project — its slug is part of the public URL)");
|
|
1741
1751
|
appSlug = await promptForSlug(session, "App slug", dirName);
|
|
1742
1752
|
} finally {
|
|
@@ -1760,7 +1770,26 @@ async function init(options) {
|
|
|
1760
1770
|
if (fs.existsSync(indexPath)) console.log("[wawesome] src/index.ts already exists, skipping.");
|
|
1761
1771
|
else {
|
|
1762
1772
|
fs.mkdirSync(srcDir, { recursive: true });
|
|
1763
|
-
fs.writeFileSync(indexPath, `/**
|
|
1773
|
+
fs.writeFileSync(indexPath, options.root ? `/**
|
|
1774
|
+
* Root Function Router
|
|
1775
|
+
* Handles all requests that don't match a specific function path.
|
|
1776
|
+
*/
|
|
1777
|
+
export default {
|
|
1778
|
+
async fetch(request: Request): Promise<Response> {
|
|
1779
|
+
const url = new URL(request.url);
|
|
1780
|
+
|
|
1781
|
+
// Example router
|
|
1782
|
+
switch (url.pathname) {
|
|
1783
|
+
case "/":
|
|
1784
|
+
return Response.json({ message: "Welcome to the App Root!" });
|
|
1785
|
+
case "/health":
|
|
1786
|
+
return Response.json({ status: "ok" });
|
|
1787
|
+
default:
|
|
1788
|
+
return Response.json({ error: "Not Found" }, { status: 404 });
|
|
1789
|
+
}
|
|
1790
|
+
},
|
|
1791
|
+
};
|
|
1792
|
+
` : `/**
|
|
1764
1793
|
* Serverless Function Handler
|
|
1765
1794
|
* Standard HTTP fetch request handler
|
|
1766
1795
|
*/
|
|
@@ -2571,7 +2600,7 @@ cli.command("logout", "Clear stored authentication credentials").action(() => lo
|
|
|
2571
2600
|
cli.command("whoami", "Show current login session info").action(() => whoami());
|
|
2572
2601
|
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
2602
|
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));
|
|
2603
|
+
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
2604
|
cli.command("logs [function-name-or-invocation-id]", "View invocation history, fetch log output, or follow live").usage(`logs [target] [options]
|
|
2576
2605
|
|
|
2577
2606
|
The target argument determines what the command does:
|