@lizard-build/cli 4.0.97 → 4.0.99
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/commands/fn.d.ts +33 -0
- package/dist/commands/fn.js +628 -0
- package/dist/commands/fn.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/skills-data.generated.js +2 -1
- package/dist/lib/skills-data.generated.js.map +1 -1
- package/dist/lib/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/package.json +1 -1
- package/skill-data/core/SKILL.md +2 -1
- package/skill-data/core/references/functions.md +112 -0
- package/src/commands/fn.ts +510 -0
- package/src/index.ts +2 -0
- package/src/lib/updater.ts +1 -1
- package/test/unit/skills.test.ts +2 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* `lizard fn`: Lizard Functions (AWS Lambda-compatible) from the CLI, made for one-command
|
|
4
|
+
* use by people and agents: `lizard fn deploy handler.py --packages requests --url`
|
|
5
|
+
* creates or updates the function, installs its packages (kept in a layer: unchanged ones
|
|
6
|
+
* are not reinstalled), waits until it is ready and prints how to call it.
|
|
7
|
+
* Everything goes through the platform as the logged-in user (no AWS keys needed);
|
|
8
|
+
* `lizard fn env` prints keys for the AWS SDKs / CLI when code needs them.
|
|
9
|
+
*/
|
|
10
|
+
export type Lang = "python" | "node" | "ruby" | "go" | "rust" | "shell";
|
|
11
|
+
export declare const DEFAULT_RUNTIME: Record<Lang, string>;
|
|
12
|
+
export interface Source {
|
|
13
|
+
lang: Lang;
|
|
14
|
+
files: {
|
|
15
|
+
name: string;
|
|
16
|
+
data: Buffer;
|
|
17
|
+
mode?: number;
|
|
18
|
+
}[];
|
|
19
|
+
handler: string;
|
|
20
|
+
entry: string;
|
|
21
|
+
deps: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** What a file or directory is: language, files to send, handler, and whether it has a dependency file. */
|
|
24
|
+
export declare function detectSource(p: string, opts?: {
|
|
25
|
+
runtime?: string;
|
|
26
|
+
handler?: string;
|
|
27
|
+
stdinName?: string;
|
|
28
|
+
stdin?: string;
|
|
29
|
+
}): Source;
|
|
30
|
+
/** The handler (module.function) from the source, as Lambda names it. */
|
|
31
|
+
export declare function findHandler(lang: Lang, entry: string, text: string): string;
|
|
32
|
+
export declare function zipFiles(files: Source["files"]): Buffer;
|
|
33
|
+
export declare function registerFn(program: Command): void;
|
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import * as zlib from "node:zlib";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { api, getBaseURL, getRequestToken, clientHeaders, APIError } from "../lib/api.js";
|
|
8
|
+
import { resolveProjectScope } from "../lib/resolve.js";
|
|
9
|
+
import { success, info, warn, fail, isJSONMode, printJSON, table } from "../lib/format.js";
|
|
10
|
+
export const DEFAULT_RUNTIME = {
|
|
11
|
+
python: "python3.13", node: "nodejs22.x", ruby: "ruby3.3", go: "provided.al2023", rust: "provided.al2023", shell: "provided.al2023",
|
|
12
|
+
};
|
|
13
|
+
const SKIP_DIRS = new Set([".git", "node_modules", "__pycache__", ".venv", "venv", "target", ".lizard", "dist-lizard"]);
|
|
14
|
+
/** What a file or directory is: language, files to send, handler, and whether it has a dependency file. */
|
|
15
|
+
export function detectSource(p, opts = {}) {
|
|
16
|
+
let files = [];
|
|
17
|
+
let entry;
|
|
18
|
+
if (opts.stdin !== undefined) {
|
|
19
|
+
entry = opts.stdinName || defaultFileFor(langOfRuntime(opts.runtime) ?? "python");
|
|
20
|
+
files = [{ name: entry, data: Buffer.from(opts.stdin) }];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const st = fs.statSync(p);
|
|
24
|
+
if (st.isDirectory()) {
|
|
25
|
+
files = walk(p);
|
|
26
|
+
entry = pickEntry(files.map((f) => f.name));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
entry = path.basename(p);
|
|
30
|
+
files = [{ name: entry, data: fs.readFileSync(p), mode: st.mode & 0o111 ? 0o100755 : undefined }];
|
|
31
|
+
// A dependency file next to a single file is part of the function.
|
|
32
|
+
for (const dep of ["requirements.txt", "package.json", "Gemfile", "go.mod", "go.sum"]) {
|
|
33
|
+
const dp = path.join(path.dirname(p), dep);
|
|
34
|
+
if (fs.existsSync(dp))
|
|
35
|
+
files.push({ name: dep, data: fs.readFileSync(dp) });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const names = files.map((f) => f.name);
|
|
40
|
+
const lang = langOfRuntime(opts.runtime) ?? (names.includes("Cargo.toml") ? "rust" : names.includes("go.mod") || entry.endsWith(".go") ? "go"
|
|
41
|
+
: /\.py$/.test(entry) ? "python" : /\.(m?js|cjs)$/.test(entry) ? "node" : /\.rb$/.test(entry) ? "ruby" : entry === "bootstrap" ? "shell"
|
|
42
|
+
: /\.ts$/.test(entry) ? (fail("TypeScript: compile it to .js first (e.g. npx esbuild index.ts --bundle --platform=node --outfile=index.mjs), then deploy the .js", 2), "node")
|
|
43
|
+
: (fail(`Can't tell the language of ${entry}: pass --runtime (e.g. python3.13, nodejs22.x, ruby3.3, provided.al2023)`, 2), "python"));
|
|
44
|
+
const text = files.find((f) => f.name === entry)?.data.toString("utf8") ?? "";
|
|
45
|
+
const handler = opts.handler ?? (lang === "go" || lang === "rust" || lang === "shell" ? "bootstrap" : findHandler(lang, entry, text));
|
|
46
|
+
const deps = names.some((n) => ["requirements.txt", "Gemfile", "go.mod", "Cargo.toml"].includes(n))
|
|
47
|
+
|| (names.includes("package.json") && hasNodeDeps(files.find((f) => f.name === "package.json").data));
|
|
48
|
+
return { lang, files, handler, entry, deps };
|
|
49
|
+
}
|
|
50
|
+
function langOfRuntime(rt) {
|
|
51
|
+
if (!rt)
|
|
52
|
+
return null;
|
|
53
|
+
if (/^python/.test(rt))
|
|
54
|
+
return "python";
|
|
55
|
+
if (/^nodejs/.test(rt))
|
|
56
|
+
return "node";
|
|
57
|
+
if (/^ruby/.test(rt))
|
|
58
|
+
return "ruby";
|
|
59
|
+
if (rt === "go" || rt === "go1.x")
|
|
60
|
+
return "go";
|
|
61
|
+
if (rt === "rust")
|
|
62
|
+
return "rust";
|
|
63
|
+
if (/^provided/.test(rt))
|
|
64
|
+
return null; // decided by the files
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const defaultFileFor = (l) => ({ python: "lambda_function.py", node: "index.mjs", ruby: "lambda_function.rb", go: "main.go", rust: "src/main.rs", shell: "bootstrap" }[l]);
|
|
68
|
+
function walk(root, rel = "") {
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const e of fs.readdirSync(path.join(root, rel), { withFileTypes: true })) {
|
|
71
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
72
|
+
if (e.isDirectory()) {
|
|
73
|
+
if (!SKIP_DIRS.has(e.name) && !e.name.startsWith("."))
|
|
74
|
+
out.push(...walk(root, r));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!e.isFile() || e.name === ".DS_Store")
|
|
78
|
+
continue;
|
|
79
|
+
const st = fs.statSync(path.join(root, r));
|
|
80
|
+
out.push({ name: r, data: fs.readFileSync(path.join(root, r)), mode: st.mode & 0o111 ? 0o100755 : undefined });
|
|
81
|
+
}
|
|
82
|
+
const size = out.reduce((n, f) => n + f.data.length, 0);
|
|
83
|
+
if (size > 50 * 1024 * 1024)
|
|
84
|
+
fail(`${root} is ${Math.round(size / 1048576)} MB; a function's source is at most 50 MB (dependencies are installed by Lizard: don't ship node_modules or venv)`, 2);
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
function pickEntry(names) {
|
|
88
|
+
for (const n of ["Cargo.toml", "go.mod", "lambda_function.py", "handler.py", "app.py", "main.py", "index.mjs", "index.js", "handler.mjs", "handler.js", "app.js", "lambda_function.rb", "handler.rb", "bootstrap"]) {
|
|
89
|
+
if (names.includes(n))
|
|
90
|
+
return n === "Cargo.toml" ? "src/main.rs" : n === "go.mod" ? (names.find((x) => !x.includes("/") && x.endsWith(".go")) ?? "main.go") : n;
|
|
91
|
+
}
|
|
92
|
+
const top = names.filter((n) => !n.includes("/"));
|
|
93
|
+
const guess = top.find((n) => /\.(py|m?js|cjs|rb|go)$/.test(n));
|
|
94
|
+
if (!guess)
|
|
95
|
+
fail("No function file found: name it handler.py, index.mjs, lambda_function.rb, main.go (or pass a file)", 2);
|
|
96
|
+
return guess;
|
|
97
|
+
}
|
|
98
|
+
/** The handler (module.function) from the source, as Lambda names it. */
|
|
99
|
+
export function findHandler(lang, entry, text) {
|
|
100
|
+
const mod = entry.replace(/\.(py|m?js|cjs|rb)$/, "");
|
|
101
|
+
if (lang === "python") {
|
|
102
|
+
const names = [...text.matchAll(/^(?:async\s+)?def\s+([A-Za-z_]\w*)\s*\(\s*(\w+)\s*,\s*(\w+)\s*\)/gm)].map((m) => m[1]);
|
|
103
|
+
const fn = ["lambda_handler", "handler", "main"].find((n) => names.includes(n)) ?? names[0] ?? "lambda_handler";
|
|
104
|
+
return `${mod}.${fn}`;
|
|
105
|
+
}
|
|
106
|
+
if (lang === "node") {
|
|
107
|
+
const exported = [...text.matchAll(/export\s+(?:const|let|var|async\s+function|function)\s+([A-Za-z_$][\w$]*)/g), ...text.matchAll(/(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=/g)].map((m) => m[1]);
|
|
108
|
+
const fn = ["handler", "lambdaHandler", "main"].find((n) => exported.includes(n)) ?? exported[0] ?? "handler";
|
|
109
|
+
return `${mod}.${fn}`;
|
|
110
|
+
}
|
|
111
|
+
if (lang === "ruby") {
|
|
112
|
+
const names = [...text.matchAll(/^def\s+([a-z_]\w*)/gm)].map((m) => m[1]);
|
|
113
|
+
return `${mod}.${["lambda_handler", "handler"].find((n) => names.includes(n)) ?? names[0] ?? "lambda_handler"}`;
|
|
114
|
+
}
|
|
115
|
+
return "bootstrap";
|
|
116
|
+
}
|
|
117
|
+
function hasNodeDeps(pkg) {
|
|
118
|
+
try {
|
|
119
|
+
return Object.keys(JSON.parse(pkg.toString("utf8")).dependencies ?? {}).length > 0;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// ---------------- zip (no dependency) ----------------
|
|
126
|
+
const CRC = (() => { const t = new Uint32Array(256); for (let n = 0; n < 256; n++) {
|
|
127
|
+
let c = n;
|
|
128
|
+
for (let k = 0; k < 8; k++)
|
|
129
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
130
|
+
t[n] = c >>> 0;
|
|
131
|
+
} return t; })();
|
|
132
|
+
const crc32 = (b) => { let c = 0xffffffff; for (let i = 0; i < b.length; i++)
|
|
133
|
+
c = CRC[(c ^ b[i]) & 0xff] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
|
134
|
+
export function zipFiles(files) {
|
|
135
|
+
const parts = [], central = [];
|
|
136
|
+
let off = 0;
|
|
137
|
+
for (const f of files) {
|
|
138
|
+
const name = Buffer.from(f.name), comp = zlib.deflateRawSync(f.data), crc = crc32(f.data);
|
|
139
|
+
const lh = Buffer.alloc(30);
|
|
140
|
+
lh.writeUInt32LE(0x04034b50, 0);
|
|
141
|
+
lh.writeUInt16LE(20, 4);
|
|
142
|
+
lh.writeUInt16LE(8, 8);
|
|
143
|
+
lh.writeUInt16LE(0x21, 12);
|
|
144
|
+
lh.writeUInt32LE(crc, 14);
|
|
145
|
+
lh.writeUInt32LE(comp.length, 18);
|
|
146
|
+
lh.writeUInt32LE(f.data.length, 22);
|
|
147
|
+
lh.writeUInt16LE(name.length, 26);
|
|
148
|
+
parts.push(lh, name, comp);
|
|
149
|
+
const ch = Buffer.alloc(46);
|
|
150
|
+
ch.writeUInt32LE(0x02014b50, 0);
|
|
151
|
+
ch.writeUInt16LE(0x0314, 4);
|
|
152
|
+
ch.writeUInt16LE(20, 6);
|
|
153
|
+
ch.writeUInt16LE(8, 10);
|
|
154
|
+
ch.writeUInt16LE(0x21, 14);
|
|
155
|
+
ch.writeUInt32LE(crc, 16);
|
|
156
|
+
ch.writeUInt32LE(comp.length, 20);
|
|
157
|
+
ch.writeUInt32LE(f.data.length, 24);
|
|
158
|
+
ch.writeUInt16LE(name.length, 28);
|
|
159
|
+
ch.writeUInt32LE((((f.mode ?? (f.name === "bootstrap" ? 0o100755 : 0o100644)) << 16) >>> 0), 38);
|
|
160
|
+
ch.writeUInt32LE(off, 42);
|
|
161
|
+
central.push(ch, name);
|
|
162
|
+
off += 30 + name.length + comp.length;
|
|
163
|
+
}
|
|
164
|
+
const cd = Buffer.concat(central), end = Buffer.alloc(22);
|
|
165
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
166
|
+
end.writeUInt16LE(files.length, 8);
|
|
167
|
+
end.writeUInt16LE(files.length, 10);
|
|
168
|
+
end.writeUInt32LE(cd.length, 12);
|
|
169
|
+
end.writeUInt32LE(off, 16);
|
|
170
|
+
return Buffer.concat([...parts, cd, end]);
|
|
171
|
+
}
|
|
172
|
+
const REGION_ALIASES = { us: "us-east-1", "us-east": "us-east-1", eu: "eu-west-lim-a", "eu-west": "eu-west-lim-a" };
|
|
173
|
+
async function regions() {
|
|
174
|
+
const r = await api.get("/api/functions/regions").catch(() => null);
|
|
175
|
+
const list = (Array.isArray(r) ? r : r?.regions ?? []).map((x) => (typeof x === "string" ? x : x.region ?? x.id)).filter(Boolean);
|
|
176
|
+
return list.filter((x) => !x.startsWith("canary"));
|
|
177
|
+
}
|
|
178
|
+
async function resolveRegion(flag) {
|
|
179
|
+
const all = await regions();
|
|
180
|
+
if (!flag)
|
|
181
|
+
return all.includes("us-east-1") ? "us-east-1" : all[0] ?? "us-east-1";
|
|
182
|
+
const r = REGION_ALIASES[flag] ?? flag;
|
|
183
|
+
if (all.length && !all.includes(r))
|
|
184
|
+
fail(`Lizard Functions runs in ${all.join(", ")} (aliases: us, eu); not in ${flag}`, 2);
|
|
185
|
+
return r;
|
|
186
|
+
}
|
|
187
|
+
async function accounts(projectId) {
|
|
188
|
+
return api.get(`/api/functions/accounts?projectId=${encodeURIComponent(projectId)}`);
|
|
189
|
+
}
|
|
190
|
+
async function accountFor(projectId, region, create) {
|
|
191
|
+
const a = (await accounts(projectId)).find((x) => x.region === region);
|
|
192
|
+
if (a || !create)
|
|
193
|
+
return a ?? null;
|
|
194
|
+
return api.post("/api/functions/accounts", { projectId, region, withKey: false });
|
|
195
|
+
}
|
|
196
|
+
/** One AWS API call as the account, through the platform (no AWS keys on this machine). */
|
|
197
|
+
async function aws(acct, method, p, body, opts = {}) {
|
|
198
|
+
const headers = { ...clientHeaders(), ...(opts.headers ?? {}) };
|
|
199
|
+
const tok = getRequestToken();
|
|
200
|
+
if (tok)
|
|
201
|
+
headers.authorization = `Bearer ${tok}`;
|
|
202
|
+
if (body !== undefined)
|
|
203
|
+
headers["content-type"] = "application/json";
|
|
204
|
+
if (opts.target)
|
|
205
|
+
headers["x-lizard-target"] = opts.target;
|
|
206
|
+
const res = await fetch(`${getBaseURL()}/api/functions/accounts/${acct.accountId}/aws/${p.replace(/^\//, "")}`, {
|
|
207
|
+
method, headers, body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(900_000),
|
|
208
|
+
});
|
|
209
|
+
const text = await res.text();
|
|
210
|
+
let data = undefined;
|
|
211
|
+
if (text) {
|
|
212
|
+
try {
|
|
213
|
+
data = JSON.parse(text);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
data = text;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (!res.ok) {
|
|
220
|
+
const msg = (data && (data.message || data.Message || data.error)) || text || res.statusText;
|
|
221
|
+
throw new APIError(res.status, String(msg), String(data?.__type ?? data?.Type ?? ""), data);
|
|
222
|
+
}
|
|
223
|
+
return { data, headers: res.headers, status: res.status };
|
|
224
|
+
}
|
|
225
|
+
const fnPath = (name) => `2015-03-31/functions/${encodeURIComponent(name)}`;
|
|
226
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
227
|
+
async function getFn(acct, name) {
|
|
228
|
+
try {
|
|
229
|
+
return (await aws(acct, "GET", fnPath(name))).data;
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
if (e instanceof APIError && e.status === 404)
|
|
233
|
+
return null;
|
|
234
|
+
throw e;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async function waitReady(acct, name, limitMs = 15 * 60_000, onTick) {
|
|
238
|
+
const end = Date.now() + limitMs;
|
|
239
|
+
for (;;) {
|
|
240
|
+
const f = (await getFn(acct, name))?.Configuration;
|
|
241
|
+
if (f) {
|
|
242
|
+
onTick?.(f);
|
|
243
|
+
if (f.State === "Failed")
|
|
244
|
+
throw new Error(f.StateReason || "the function failed to start");
|
|
245
|
+
if (f.LastUpdateStatus === "Failed")
|
|
246
|
+
throw new Error(f.LastUpdateStatusReason || "the update failed");
|
|
247
|
+
if (f.State === "Active" && f.LastUpdateStatus !== "InProgress")
|
|
248
|
+
return f;
|
|
249
|
+
}
|
|
250
|
+
if (Date.now() > end)
|
|
251
|
+
throw new Error("timed out waiting for the function");
|
|
252
|
+
await sleep(400);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function waitBuild(acct, id, spinner) {
|
|
256
|
+
const t0 = Date.now();
|
|
257
|
+
for (;;) {
|
|
258
|
+
const b = (await aws(acct, "GET", `lizard/builds/${id}`)).data;
|
|
259
|
+
if (b.Status !== "InProgress")
|
|
260
|
+
return b;
|
|
261
|
+
spinner(`${b.Kind === "layer" ? "installing packages" : `building (${b.Language})`}… ${Math.round((Date.now() - t0) / 1000)}s`);
|
|
262
|
+
await sleep(1000);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function parseEnv(list) {
|
|
266
|
+
if (!list?.length)
|
|
267
|
+
return undefined;
|
|
268
|
+
const out = {};
|
|
269
|
+
for (const kv of list) {
|
|
270
|
+
const i = kv.indexOf("=");
|
|
271
|
+
if (i < 1)
|
|
272
|
+
fail(`--env takes KEY=VALUE (got ${kv})`, 2);
|
|
273
|
+
out[kv.slice(0, i)] = kv.slice(i + 1);
|
|
274
|
+
}
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
const splitList = (v) => (Array.isArray(v) ? v : v ? [v] : []).flatMap((x) => x.split(/[,\s]+/)).map((x) => x.trim()).filter(Boolean);
|
|
278
|
+
const DEBUG = !!process.env.LIZARD_DEBUG_FN;
|
|
279
|
+
let tStart = Date.now();
|
|
280
|
+
function status(msg) {
|
|
281
|
+
if (DEBUG)
|
|
282
|
+
process.stderr.write(`[${((Date.now() - tStart) / 1000).toFixed(2)}s] ${msg}\n`);
|
|
283
|
+
if (!isJSONMode() && process.stderr.isTTY)
|
|
284
|
+
process.stderr.write(`\r\x1b[2K${chalk.dim(msg)}`);
|
|
285
|
+
}
|
|
286
|
+
function statusDone() { if (!isJSONMode() && process.stderr.isTTY)
|
|
287
|
+
process.stderr.write("\r\x1b[2K"); }
|
|
288
|
+
// ---------------- commands ----------------
|
|
289
|
+
export function registerFn(program) {
|
|
290
|
+
const fn = program.command("fn").alias("functions")
|
|
291
|
+
.description("Lizard Functions (AWS Lambda-compatible): deploy, invoke, logs")
|
|
292
|
+
.addHelpText("after", `
|
|
293
|
+
Examples:
|
|
294
|
+
lizard fn deploy handler.py --packages requests # create or update, install, wait, done
|
|
295
|
+
lizard fn deploy ./scraper --url # a directory (requirements.txt / package.json / go.mod / Cargo.toml)
|
|
296
|
+
echo 'def handler(e, c): return e' | lizard fn deploy - --name echo --runtime python3.13
|
|
297
|
+
lizard fn deploy main.go --schedule "rate(5 minutes)" # Go and Rust are compiled on Lizard
|
|
298
|
+
lizard fn invoke scraper '{"url": "https://example.com"}'
|
|
299
|
+
lizard fn logs scraper --since 10m
|
|
300
|
+
lizard fn ls
|
|
301
|
+
eval "$(lizard fn env)" # AWS SDK / CLI credentials and endpoint`);
|
|
302
|
+
fn.command("deploy")
|
|
303
|
+
.description("Create or update a function from a file, a directory or stdin (-); installs packages, waits until it is ready")
|
|
304
|
+
.argument("[path]", "file, directory or - for stdin", ".")
|
|
305
|
+
.option("--name <name>", "function name (default: from the file or directory)")
|
|
306
|
+
.option("--runtime <runtime>", "e.g. python3.13, nodejs22.x, ruby3.3, provided.al2023 (default: from the source)")
|
|
307
|
+
.option("--handler <handler>", "e.g. app.handler (default: found in the source)")
|
|
308
|
+
.option("--packages <list...>", "libraries to preinstall, e.g. requests numpy==2.1.3 (comma or space separated)")
|
|
309
|
+
.option("--env <KEY=VALUE...>", "environment variables")
|
|
310
|
+
.option("--memory <mb>", "memory in MB", (v) => parseInt(v, 10))
|
|
311
|
+
.option("--timeout <seconds>", "timeout in seconds", (v) => parseInt(v, 10))
|
|
312
|
+
.option("--url", "give it a public HTTPS URL")
|
|
313
|
+
.option("--schedule <expression>", 'run it on a schedule: "rate(5 minutes)" or "cron(0 9 * * ? *)"')
|
|
314
|
+
.option("--region <region>", "us-east-1 (us) or eu-west-lim-a (eu)")
|
|
315
|
+
.option("--project <id>", "project (default: the linked one)")
|
|
316
|
+
.action(async (p, o) => {
|
|
317
|
+
const t0 = Date.now();
|
|
318
|
+
tStart = t0;
|
|
319
|
+
const stdin = p === "-" ? fs.readFileSync(0, "utf8") : undefined;
|
|
320
|
+
if (p !== "-" && !fs.existsSync(p))
|
|
321
|
+
fail(`${p} does not exist`, 2);
|
|
322
|
+
if (stdin !== undefined && !o.name)
|
|
323
|
+
fail("--name is required with stdin", 2);
|
|
324
|
+
const src = detectSource(p, { runtime: o.runtime, handler: o.handler, stdin });
|
|
325
|
+
const name = o.name ?? defaultName(p, src);
|
|
326
|
+
if (!/^[A-Za-z0-9_-]{1,64}$/.test(name))
|
|
327
|
+
fail(`Function name ${name}: letters, numbers, hyphens and underscores, up to 64 (pass --name)`, 2);
|
|
328
|
+
const runtime = o.runtime && !/^(go|rust)$/.test(o.runtime) ? o.runtime : DEFAULT_RUNTIME[src.lang];
|
|
329
|
+
const packages = splitList(o.packages);
|
|
330
|
+
const { projectId } = await resolveProjectScope(o.project);
|
|
331
|
+
const region = await resolveRegion(o.region);
|
|
332
|
+
status(`account in ${region}…`);
|
|
333
|
+
const acct = (await accountFor(projectId, region, true));
|
|
334
|
+
const zipBuf = zipFiles(src.files);
|
|
335
|
+
const zip = zipBuf.toString("base64");
|
|
336
|
+
const zipSha = createHash("sha256").update(zipBuf).digest("base64");
|
|
337
|
+
const config = { Runtime: runtime, Handler: src.handler };
|
|
338
|
+
if (o.memory)
|
|
339
|
+
config.MemorySize = o.memory;
|
|
340
|
+
if (o.timeout)
|
|
341
|
+
config.Timeout = o.timeout;
|
|
342
|
+
const env = parseEnv(o.env);
|
|
343
|
+
if (env)
|
|
344
|
+
config.Environment = { Variables: env };
|
|
345
|
+
const existing = await getFn(acct, name);
|
|
346
|
+
const compiled = src.lang === "go" || src.lang === "rust";
|
|
347
|
+
let created = false;
|
|
348
|
+
// Code: built on Lizard when it has a dependency file (or is Go / Rust), else sent as is.
|
|
349
|
+
if (src.deps || compiled) {
|
|
350
|
+
status(existing ? "building…" : "creating (building)…");
|
|
351
|
+
if (existing)
|
|
352
|
+
await waitReady(acct, name);
|
|
353
|
+
if (existing)
|
|
354
|
+
await aws(acct, "PUT", `${fnPath(name)}/configuration`, config);
|
|
355
|
+
if (existing)
|
|
356
|
+
await waitReady(acct, name);
|
|
357
|
+
const job = (await aws(acct, "POST", `lizard/functions/${encodeURIComponent(name)}/build`, {
|
|
358
|
+
ZipFile: zip, Runtime: runtime, ...(compiled && packages.length ? { Packages: packages } : {}),
|
|
359
|
+
...(existing ? {} : { Create: { Role: "arn:aws:iam::000000000000:role/lizard-function", MemorySize: 512, Timeout: 30, ...config } }),
|
|
360
|
+
})).data;
|
|
361
|
+
const b = await waitBuild(acct, job.BuildId, status);
|
|
362
|
+
if (b.Status !== "Succeeded") {
|
|
363
|
+
statusDone();
|
|
364
|
+
fail(`Build failed: ${b.Error}\n${String(b.Log || "").slice(-3000)}`, 1, "BUILD_FAILED");
|
|
365
|
+
}
|
|
366
|
+
created = !existing;
|
|
367
|
+
}
|
|
368
|
+
else if (existing) {
|
|
369
|
+
// Only what changed is sent: the same code (by SHA-256) and the same settings are no-ops.
|
|
370
|
+
const c = existing.Configuration ?? {};
|
|
371
|
+
if (c.LastUpdateStatus === "InProgress")
|
|
372
|
+
await waitReady(acct, name);
|
|
373
|
+
if (c.CodeSha256 !== zipSha) {
|
|
374
|
+
status("updating code…");
|
|
375
|
+
await aws(acct, "PUT", `${fnPath(name)}/code`, { ZipFile: zip });
|
|
376
|
+
}
|
|
377
|
+
const changed = Object.entries(config).some(([k, v]) => JSON.stringify(k === "Environment" ? { Variables: c.Environment?.Variables ?? {} } : c[k]) !== JSON.stringify(v));
|
|
378
|
+
if (changed) {
|
|
379
|
+
status("updating settings…");
|
|
380
|
+
await waitReady(acct, name);
|
|
381
|
+
await aws(acct, "PUT", `${fnPath(name)}/configuration`, config);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
status("creating…");
|
|
386
|
+
await aws(acct, "POST", "2015-03-31/functions", { FunctionName: name, Role: "arn:aws:iam::000000000000:role/lizard-function", MemorySize: 512, Timeout: 30, ...config, Code: { ZipFile: zip } });
|
|
387
|
+
created = true;
|
|
388
|
+
}
|
|
389
|
+
// Packages (Node.js / Python / Ruby): the function's own layer, rebuilt only when the list changes.
|
|
390
|
+
let installed = null;
|
|
391
|
+
if (!compiled) {
|
|
392
|
+
await waitReady(acct, name, 15 * 60_000, (c) => status(c.State === "Pending" ? "preparing the runtime (the first one in a region takes up to a minute)…" : "updating…"));
|
|
393
|
+
const cur = (await aws(acct, "GET", `lizard/functions/${encodeURIComponent(name)}/packages`)).data;
|
|
394
|
+
const same = JSON.stringify([...(cur.Packages ?? [])].sort()) === JSON.stringify([...packages].sort());
|
|
395
|
+
if (o.packages !== undefined && !same) {
|
|
396
|
+
status("installing packages…");
|
|
397
|
+
const job = (await aws(acct, "PUT", `lizard/functions/${encodeURIComponent(name)}/packages`, { Packages: packages })).data;
|
|
398
|
+
if (job.BuildId) {
|
|
399
|
+
const b = await waitBuild(acct, job.BuildId, status);
|
|
400
|
+
if (b.Status !== "Succeeded") {
|
|
401
|
+
statusDone();
|
|
402
|
+
fail(`Installing packages failed: ${b.Error}\n${String(b.Log || "").slice(-3000)}`, 1, "BUILD_FAILED");
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
installed = o.packages !== undefined ? packages : cur.Packages ?? [];
|
|
407
|
+
}
|
|
408
|
+
const cfg = await waitReady(acct, name, 15 * 60_000, (c) => status(c.State === "Pending" ? "preparing the runtime (the first one in a region takes up to a minute)…" : "starting…"));
|
|
409
|
+
// URL and schedule.
|
|
410
|
+
let url = null;
|
|
411
|
+
if (o.url) {
|
|
412
|
+
try {
|
|
413
|
+
url = (await aws(acct, "GET", `2021-10-31/functions/${encodeURIComponent(name)}/url`)).data.FunctionUrl;
|
|
414
|
+
}
|
|
415
|
+
catch (e) {
|
|
416
|
+
if (!(e instanceof APIError && e.status === 404))
|
|
417
|
+
throw e;
|
|
418
|
+
url = (await aws(acct, "POST", `2021-10-31/functions/${encodeURIComponent(name)}/url`, { AuthType: "NONE", Cors: { AllowOrigins: ["*"] } })).data.FunctionUrl;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (o.schedule) {
|
|
422
|
+
const body = { ScheduleExpression: o.schedule, FlexibleTimeWindow: { Mode: "OFF" }, Target: { Arn: cfg.FunctionArn, RoleArn: "arn:aws:iam::000000000000:role/lizard-scheduler" }, State: "ENABLED" };
|
|
423
|
+
try {
|
|
424
|
+
await aws(acct, "PUT", `schedules/${encodeURIComponent(name)}`, body);
|
|
425
|
+
}
|
|
426
|
+
catch (e) {
|
|
427
|
+
if (e instanceof APIError && e.status === 404)
|
|
428
|
+
await aws(acct, "POST", `schedules/${encodeURIComponent(name)}`, body);
|
|
429
|
+
else
|
|
430
|
+
throw e;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
statusDone();
|
|
434
|
+
const secs = ((Date.now() - t0) / 1000).toFixed(1);
|
|
435
|
+
const out = { name, region, created, runtime: cfg.Runtime, handler: cfg.Handler, language: src.lang, arn: cfg.FunctionArn, packages: installed, url, schedule: o.schedule ?? null,
|
|
436
|
+
seconds: Number(secs), invoke: `lizard fn invoke ${name}${o.region ? ` --region ${region}` : ""} '{}'` };
|
|
437
|
+
if (isJSONMode())
|
|
438
|
+
return printJSON(out);
|
|
439
|
+
success(`${created ? "Created" : "Updated"} ${chalk.bold(name)} in ${region} (${cfg.Runtime}, ${cfg.Handler}) in ${secs}s`);
|
|
440
|
+
if (installed?.length)
|
|
441
|
+
info(`Packages: ${installed.join(" ")}`);
|
|
442
|
+
if (url)
|
|
443
|
+
info(`URL: ${chalk.cyan(url)}`);
|
|
444
|
+
if (o.schedule)
|
|
445
|
+
info(`Schedule: ${o.schedule}`);
|
|
446
|
+
info(`Call it: ${chalk.cyan(out.invoke)}`);
|
|
447
|
+
});
|
|
448
|
+
fn.command("invoke")
|
|
449
|
+
.description("Call a function and print its result (and its log with --logs)")
|
|
450
|
+
.argument("<name>")
|
|
451
|
+
.argument("[event]", "event JSON (default {}; - reads stdin)", "{}")
|
|
452
|
+
.option("--logs", "print the invocation's log")
|
|
453
|
+
.option("--async", "queue it (InvocationType Event) and return at once")
|
|
454
|
+
.option("--region <region>").option("--project <id>")
|
|
455
|
+
.action(async (name, event, o) => {
|
|
456
|
+
const acct = await existingAccount(o, name);
|
|
457
|
+
const body = event === "-" ? fs.readFileSync(0, "utf8") : event;
|
|
458
|
+
let parsed;
|
|
459
|
+
try {
|
|
460
|
+
parsed = JSON.parse(body);
|
|
461
|
+
}
|
|
462
|
+
catch {
|
|
463
|
+
fail("The event must be JSON", 2);
|
|
464
|
+
}
|
|
465
|
+
const r = await aws(acct, "POST", `${fnPath(name)}/invocations`, parsed, { headers: { "x-amz-log-type": "Tail", ...(o.async ? { "x-amz-invocation-type": "Event" } : {}) } });
|
|
466
|
+
const err = r.headers.get("x-amz-function-error");
|
|
467
|
+
const tail = r.headers.get("x-amz-log-result");
|
|
468
|
+
const logs = tail ? Buffer.from(tail, "base64").toString("utf8") : "";
|
|
469
|
+
if (isJSONMode()) {
|
|
470
|
+
if (err)
|
|
471
|
+
process.exitCode = 1;
|
|
472
|
+
return printJSON({ status: o.async ? "queued" : err ? "error" : "ok", error: err || undefined, result: r.data ?? null, logs: o.logs ? logs : undefined });
|
|
473
|
+
}
|
|
474
|
+
if (o.logs && logs)
|
|
475
|
+
process.stderr.write(chalk.dim(logs.endsWith("\n") ? logs : logs + "\n"));
|
|
476
|
+
if (o.async)
|
|
477
|
+
return success("Queued");
|
|
478
|
+
process.stdout.write((typeof r.data === "string" ? r.data : JSON.stringify(r.data ?? null, null, 2)) + "\n");
|
|
479
|
+
if (err) {
|
|
480
|
+
process.stderr.write(chalk.red(`Function error (${err})\n`));
|
|
481
|
+
if (!o.logs && logs)
|
|
482
|
+
process.stderr.write(chalk.dim(logs));
|
|
483
|
+
process.exitCode = 1;
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
fn.command("logs")
|
|
487
|
+
.description("A function's logs (CloudWatch Logs format)")
|
|
488
|
+
.argument("<name>")
|
|
489
|
+
.option("--since <duration>", "e.g. 10m, 2h, 1d", "1h")
|
|
490
|
+
.option("-f, --follow", "keep printing new lines")
|
|
491
|
+
.option("--region <region>").option("--project <id>")
|
|
492
|
+
.action(async (name, o) => {
|
|
493
|
+
const acct = await existingAccount(o, name);
|
|
494
|
+
let start = Date.now() - parseDuration(o.since);
|
|
495
|
+
const seen = new Set();
|
|
496
|
+
for (;;) {
|
|
497
|
+
const r = await aws(acct, "POST", "", { logGroupName: `/aws/lambda/${name}`, startTime: start, limit: 1000 }, { target: "Logs_20140328.FilterLogEvents" }).catch((e) => {
|
|
498
|
+
if (e instanceof APIError && (e.status === 400 || e.status === 404))
|
|
499
|
+
return { data: { events: [] } };
|
|
500
|
+
throw e;
|
|
501
|
+
});
|
|
502
|
+
const events = (r.data.events ?? []).filter((e) => !seen.has(e.eventId ?? `${e.timestamp}${e.message}`));
|
|
503
|
+
if (isJSONMode() && !o.follow)
|
|
504
|
+
return printJSON(events);
|
|
505
|
+
for (const e of events) {
|
|
506
|
+
seen.add(e.eventId ?? `${e.timestamp}${e.message}`);
|
|
507
|
+
if (isJSONMode())
|
|
508
|
+
printJSON(e);
|
|
509
|
+
else
|
|
510
|
+
process.stdout.write(`${chalk.dim(new Date(e.timestamp).toISOString())} ${e.message}${String(e.message).endsWith("\n") ? "" : "\n"}`);
|
|
511
|
+
start = Math.max(start, e.timestamp);
|
|
512
|
+
}
|
|
513
|
+
if (!o.follow)
|
|
514
|
+
return;
|
|
515
|
+
await sleep(2000);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
fn.command("ls").alias("list")
|
|
519
|
+
.description("Functions of the project, in every region")
|
|
520
|
+
.option("--project <id>")
|
|
521
|
+
.action(async (o) => {
|
|
522
|
+
const { projectId } = await resolveProjectScope(o.project);
|
|
523
|
+
const rows = [];
|
|
524
|
+
for (const a of await accounts(projectId)) {
|
|
525
|
+
const r = await aws(a, "GET", "2015-03-31/functions/?MaxItems=200").catch(() => ({ data: { Functions: [] } }));
|
|
526
|
+
for (const f of r.data.Functions ?? [])
|
|
527
|
+
rows.push({ name: f.FunctionName, region: a.region, runtime: f.Runtime ?? f.PackageType, state: f.State ?? "Active", memory: f.MemorySize, modified: f.LastModified });
|
|
528
|
+
}
|
|
529
|
+
if (isJSONMode())
|
|
530
|
+
return printJSON(rows);
|
|
531
|
+
if (!rows.length)
|
|
532
|
+
return info("No functions yet: lizard fn deploy handler.py");
|
|
533
|
+
table(["NAME", "REGION", "RUNTIME", "STATE", "MEMORY", "MODIFIED"], rows.map((r) => [r.name, r.region, r.runtime, r.state, `${r.memory} MB`, String(r.modified).slice(0, 19)]));
|
|
534
|
+
});
|
|
535
|
+
fn.command("rm").alias("delete")
|
|
536
|
+
.description("Delete a function (and its schedule)")
|
|
537
|
+
.argument("<name>")
|
|
538
|
+
.option("--region <region>").option("--project <id>")
|
|
539
|
+
.action(async (name, o) => {
|
|
540
|
+
const acct = await existingAccount(o, name);
|
|
541
|
+
await aws(acct, "DELETE", `schedules/${encodeURIComponent(name)}`).catch(() => { });
|
|
542
|
+
await aws(acct, "DELETE", fnPath(name));
|
|
543
|
+
if (isJSONMode())
|
|
544
|
+
return printJSON({ deleted: name, region: acct.region });
|
|
545
|
+
success(`Deleted ${name} (${acct.region})`);
|
|
546
|
+
});
|
|
547
|
+
fn.command("env")
|
|
548
|
+
.description("Print AWS credentials and endpoints for the project's functions (for the AWS SDKs / CLI): eval \"$(lizard fn env)\"")
|
|
549
|
+
.option("--new", "create a new access key instead of reusing this machine's")
|
|
550
|
+
.option("--region <region>").option("--project <id>")
|
|
551
|
+
.action(async (o) => {
|
|
552
|
+
const { projectId } = await resolveProjectScope(o.project);
|
|
553
|
+
const region = await resolveRegion(o.region);
|
|
554
|
+
await accountFor(projectId, region, true);
|
|
555
|
+
// One key per project on this machine, reused (eval'd in a shell profile, a key per run
|
|
556
|
+
// would pile up); kept only while the project still lists it.
|
|
557
|
+
const file = path.join(os.homedir(), ".lizard", "functions-keys.json");
|
|
558
|
+
let saved = {};
|
|
559
|
+
try {
|
|
560
|
+
saved = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
saved = {};
|
|
564
|
+
}
|
|
565
|
+
let k = o.new ? null : saved[projectId] ?? null;
|
|
566
|
+
if (k) {
|
|
567
|
+
const live = await api.get(`/api/functions/projects/${encodeURIComponent(projectId)}/keys`).catch(() => null);
|
|
568
|
+
if (!live?.keys?.some((x) => x.accessKeyId === k.accessKeyId))
|
|
569
|
+
k = null;
|
|
570
|
+
else
|
|
571
|
+
k.endpoints = live.endpoints ?? k.endpoints;
|
|
572
|
+
}
|
|
573
|
+
let created = false;
|
|
574
|
+
if (!k) {
|
|
575
|
+
k = await api.post(`/api/functions/projects/${encodeURIComponent(projectId)}/keys`);
|
|
576
|
+
saved[projectId] = { accessKeyId: k.accessKeyId, secretAccessKey: k.secretAccessKey, endpoints: k.endpoints };
|
|
577
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
578
|
+
fs.writeFileSync(file, JSON.stringify(saved, null, 2), { mode: 0o600 });
|
|
579
|
+
created = true;
|
|
580
|
+
}
|
|
581
|
+
const ep = k.endpoints?.[region];
|
|
582
|
+
if (!ep)
|
|
583
|
+
fail(`No Functions endpoint for ${region}`, 1);
|
|
584
|
+
const sh = (v) => `'${String(v).replace(/'/g, "'\\''")}'`;
|
|
585
|
+
// Shell exports by default even when stdout is a pipe: `eval "$(lizard fn env)"` is the point.
|
|
586
|
+
if (process.argv.includes("--json"))
|
|
587
|
+
return printJSON({ AWS_ACCESS_KEY_ID: k.accessKeyId, AWS_SECRET_ACCESS_KEY: k.secretAccessKey, AWS_REGION: region, AWS_ENDPOINT_URL_LAMBDA: ep, endpoints: k.endpoints, created });
|
|
588
|
+
const vars = [["AWS_ACCESS_KEY_ID", k.accessKeyId], ["AWS_SECRET_ACCESS_KEY", k.secretAccessKey], ["AWS_REGION", region], ["AWS_DEFAULT_REGION", region],
|
|
589
|
+
...["LAMBDA", "SQS", "SCHEDULER", "EVENTBRIDGE", "CLOUDWATCH_LOGS"].map((s2) => [`AWS_ENDPOINT_URL_${s2}`, ep])];
|
|
590
|
+
process.stdout.write(vars.map(([n, v]) => `export ${n}=${sh(v)}`).join("\n") + "\n");
|
|
591
|
+
if (created && process.stderr.isTTY)
|
|
592
|
+
warn(`Created an access key for this project (saved in ${file}; Access keys in the dashboard lists and deletes keys).`);
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function defaultName(p, src) {
|
|
596
|
+
const base = p === "." ? path.basename(process.cwd()) : fs.existsSync(p) && fs.statSync(p).isDirectory() ? path.basename(path.resolve(p)) : path.basename(p).replace(/\.[^.]+$/, "");
|
|
597
|
+
const n = (["handler", "lambda_function", "index", "main", "app", "bootstrap"].includes(base) ? path.basename(path.resolve(path.dirname(p === "." ? "./x" : p))) : base)
|
|
598
|
+
.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
|
|
599
|
+
return n || `fn-${src.lang}`;
|
|
600
|
+
}
|
|
601
|
+
/** The region holding the function: --region, or the one region where it exists. */
|
|
602
|
+
async function existingAccount(o, name) {
|
|
603
|
+
const { projectId } = await resolveProjectScope(o.project);
|
|
604
|
+
const all = await accounts(projectId);
|
|
605
|
+
if (o.region) {
|
|
606
|
+
const region = await resolveRegion(o.region);
|
|
607
|
+
const a = all.find((x) => x.region === region);
|
|
608
|
+
if (!a)
|
|
609
|
+
fail(`No functions in ${region} for this project`, 1, "NOT_FOUND");
|
|
610
|
+
return a;
|
|
611
|
+
}
|
|
612
|
+
const holding = [];
|
|
613
|
+
for (const a of all)
|
|
614
|
+
if (await getFn(a, name).catch(() => null))
|
|
615
|
+
holding.push(a);
|
|
616
|
+
if (!holding.length)
|
|
617
|
+
fail(`Function ${name} not found (lizard fn ls)`, 1, "NOT_FOUND");
|
|
618
|
+
if (holding.length > 1)
|
|
619
|
+
fail(`${name} exists in ${holding.map((a) => a.region).join(" and ")}: pass --region`, 2);
|
|
620
|
+
return holding[0];
|
|
621
|
+
}
|
|
622
|
+
function parseDuration(s) {
|
|
623
|
+
const m = String(s).match(/^(\d+)\s*(s|m|h|d)?$/);
|
|
624
|
+
if (!m)
|
|
625
|
+
fail(`--since takes e.g. 30s, 10m, 2h, 1d (got ${s})`, 2);
|
|
626
|
+
return Number(m[1]) * { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[m[2] ?? "m"];
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=fn.js.map
|