@bangerpage/cli 0.2.0 → 0.2.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.
- package/dist/bin.js +129 -20
- package/dist/bin.js.map +4 -4
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/skill.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/skill/SKILL.md +3 -3
- package/dist/skill/meta.json +2 -2
- package/dist/skill/reference/patterns.md +1 -1
- package/dist/skill/reference/publishing.md +39 -0
- package/dist/skill/templates/starter.html +1 -1
- package/dist/zip.d.ts +9 -0
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
-
import { readFileSync as
|
|
4
|
+
import { readFileSync as readFileSync9, realpathSync } from "node:fs";
|
|
5
5
|
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
|
|
6
6
|
|
|
7
7
|
// src/browser.ts
|
|
@@ -372,7 +372,7 @@ function escapeRegExp(value) {
|
|
|
372
372
|
}
|
|
373
373
|
function runtimeUrlPattern(corePackage) {
|
|
374
374
|
const hosts = CDN_HOSTS.map(escapeRegExp).join("|");
|
|
375
|
-
return new RegExp(`^https?://(${hosts})/${escapeRegExp(corePackage)}(@[^/]+)?/dist/index\\.js$`);
|
|
375
|
+
return new RegExp(`^https?://(${hosts})/${escapeRegExp(corePackage)}(@[^/]+)?/dist/(?:index|standalone)\\.js$`);
|
|
376
376
|
}
|
|
377
377
|
function moduleScripts(html) {
|
|
378
378
|
const found = [];
|
|
@@ -772,6 +772,7 @@ async function forEachLanguage(file, lang, opts, fn) {
|
|
|
772
772
|
|
|
773
773
|
// src/commands/check.ts
|
|
774
774
|
var USAGE = "usage: banger check [file] [--json]";
|
|
775
|
+
var FONT_MESSAGE = /^(theme )?fonts? (stylesheet|timed out|load failed)/;
|
|
775
776
|
function hasLanguages(html) {
|
|
776
777
|
const visit = (node) => {
|
|
777
778
|
for (const child of node.childNodes) {
|
|
@@ -795,6 +796,7 @@ function oldRuntimeWarning(html) {
|
|
|
795
796
|
async function checkDeck(file) {
|
|
796
797
|
const warnings = [];
|
|
797
798
|
const failed = /* @__PURE__ */ new Set();
|
|
799
|
+
const notes = /* @__PURE__ */ new Set();
|
|
798
800
|
const html = readInput(file);
|
|
799
801
|
const pinned = runtimeVersionWarning(html, CORE_PACKAGE, coreVersion())?.message;
|
|
800
802
|
const oldRuntime = pinned !== void 0 && hasLanguages(html) ? oldRuntimeWarning(html) : null;
|
|
@@ -804,7 +806,8 @@ async function checkDeck(file) {
|
|
|
804
806
|
if (oldRuntime) warnings.push(oldRuntime);
|
|
805
807
|
else process.stderr.write(`note: ${message}
|
|
806
808
|
`);
|
|
807
|
-
} else
|
|
809
|
+
} else if (FONT_MESSAGE.test(message)) notes.add(message);
|
|
810
|
+
else warnings.push(`${tag}${message}`);
|
|
808
811
|
};
|
|
809
812
|
let firstSteps = [];
|
|
810
813
|
let firstLanguage = "";
|
|
@@ -827,7 +830,7 @@ async function checkDeck(file) {
|
|
|
827
830
|
}
|
|
828
831
|
return session.path.length;
|
|
829
832
|
});
|
|
830
|
-
return { ok: warnings.length === 0 && failed.size === 0, stops: stops[0], warnings, failed: [...failed] };
|
|
833
|
+
return { ok: warnings.length === 0 && failed.size === 0, stops: stops[0], warnings, failed: [...failed], notes: [...notes] };
|
|
831
834
|
}
|
|
832
835
|
async function runCheck(argv) {
|
|
833
836
|
if (argv.includes("--help")) {
|
|
@@ -844,6 +847,8 @@ async function runCheck(argv) {
|
|
|
844
847
|
for (const line of result.failed) process.stdout.write(`${line}
|
|
845
848
|
`);
|
|
846
849
|
for (const line of result.warnings) process.stdout.write(`warning: ${line}
|
|
850
|
+
`);
|
|
851
|
+
for (const line of result.notes) process.stdout.write(`note: ${line} (layout checked with fallback fonts)
|
|
847
852
|
`);
|
|
848
853
|
const problems = result.failed.length + result.warnings.length;
|
|
849
854
|
process.stdout.write(
|
|
@@ -1166,24 +1171,107 @@ the deck ${known.slug} is gone; delete ${statePath(dir)} to publish it as a new
|
|
|
1166
1171
|
}
|
|
1167
1172
|
|
|
1168
1173
|
// src/commands/skill.ts
|
|
1169
|
-
import { cpSync, existsSync as existsSync6, readFileSync as
|
|
1174
|
+
import { cpSync, existsSync as existsSync6, readFileSync as readFileSync7, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
1170
1175
|
import { homedir as homedir2 } from "node:os";
|
|
1171
|
-
import { join as
|
|
1176
|
+
import { join as join8, resolve as resolve5 } from "node:path";
|
|
1172
1177
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
1173
|
-
|
|
1178
|
+
|
|
1179
|
+
// src/zip.ts
|
|
1180
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync4 } from "node:fs";
|
|
1181
|
+
import { join as join7, relative as relative2, sep as sep3 } from "node:path";
|
|
1182
|
+
import { deflateRawSync } from "node:zlib";
|
|
1183
|
+
var CRC_TABLE = (() => {
|
|
1184
|
+
const table = new Uint32Array(256);
|
|
1185
|
+
for (let n = 0; n < 256; n++) {
|
|
1186
|
+
let c = n;
|
|
1187
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
1188
|
+
table[n] = c >>> 0;
|
|
1189
|
+
}
|
|
1190
|
+
return table;
|
|
1191
|
+
})();
|
|
1192
|
+
function crc32(data) {
|
|
1193
|
+
let crc = 4294967295;
|
|
1194
|
+
for (const byte of data) crc = CRC_TABLE[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
1195
|
+
return (crc ^ 4294967295) >>> 0;
|
|
1196
|
+
}
|
|
1197
|
+
var DOS_DATE = 0 << 9 | 1 << 5 | 1;
|
|
1198
|
+
var DOS_TIME = 0;
|
|
1199
|
+
function createZip(entries) {
|
|
1200
|
+
const locals = [];
|
|
1201
|
+
const centrals = [];
|
|
1202
|
+
let offset = 0;
|
|
1203
|
+
for (const entry2 of entries) {
|
|
1204
|
+
const name = Buffer.from(entry2.name, "utf8");
|
|
1205
|
+
const compressed = deflateRawSync(entry2.data);
|
|
1206
|
+
const crc = crc32(entry2.data);
|
|
1207
|
+
const local = Buffer.alloc(30);
|
|
1208
|
+
local.writeUInt32LE(67324752, 0);
|
|
1209
|
+
local.writeUInt16LE(20, 4);
|
|
1210
|
+
local.writeUInt16LE(2048, 6);
|
|
1211
|
+
local.writeUInt16LE(8, 8);
|
|
1212
|
+
local.writeUInt16LE(DOS_TIME, 10);
|
|
1213
|
+
local.writeUInt16LE(DOS_DATE, 12);
|
|
1214
|
+
local.writeUInt32LE(crc, 14);
|
|
1215
|
+
local.writeUInt32LE(compressed.length, 18);
|
|
1216
|
+
local.writeUInt32LE(entry2.data.length, 22);
|
|
1217
|
+
local.writeUInt16LE(name.length, 26);
|
|
1218
|
+
locals.push(local, name, compressed);
|
|
1219
|
+
const central = Buffer.alloc(46);
|
|
1220
|
+
central.writeUInt32LE(33639248, 0);
|
|
1221
|
+
central.writeUInt16LE(20, 4);
|
|
1222
|
+
central.writeUInt16LE(20, 6);
|
|
1223
|
+
central.writeUInt16LE(2048, 8);
|
|
1224
|
+
central.writeUInt16LE(8, 10);
|
|
1225
|
+
central.writeUInt16LE(DOS_TIME, 12);
|
|
1226
|
+
central.writeUInt16LE(DOS_DATE, 14);
|
|
1227
|
+
central.writeUInt32LE(crc, 16);
|
|
1228
|
+
central.writeUInt32LE(compressed.length, 20);
|
|
1229
|
+
central.writeUInt32LE(entry2.data.length, 24);
|
|
1230
|
+
central.writeUInt16LE(name.length, 28);
|
|
1231
|
+
central.writeUInt32LE(offset, 42);
|
|
1232
|
+
centrals.push(central, name);
|
|
1233
|
+
offset += local.length + name.length + compressed.length;
|
|
1234
|
+
}
|
|
1235
|
+
const centralSize = centrals.reduce((sum, b) => sum + b.length, 0);
|
|
1236
|
+
const end = Buffer.alloc(22);
|
|
1237
|
+
end.writeUInt32LE(101010256, 0);
|
|
1238
|
+
end.writeUInt16LE(entries.length, 8);
|
|
1239
|
+
end.writeUInt16LE(entries.length, 10);
|
|
1240
|
+
end.writeUInt32LE(centralSize, 12);
|
|
1241
|
+
end.writeUInt32LE(offset, 16);
|
|
1242
|
+
return Buffer.concat([...locals, ...centrals, end]);
|
|
1243
|
+
}
|
|
1244
|
+
function directoryEntries(dir, prefix) {
|
|
1245
|
+
const files = [];
|
|
1246
|
+
const walk = (current) => {
|
|
1247
|
+
for (const name of readdirSync2(current).sort()) {
|
|
1248
|
+
const full = join7(current, name);
|
|
1249
|
+
if (statSync4(full).isDirectory()) walk(full);
|
|
1250
|
+
else files.push(full);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
walk(dir);
|
|
1254
|
+
return files.map((file) => ({
|
|
1255
|
+
name: `${prefix}/${relative2(dir, file).split(sep3).join("/")}`,
|
|
1256
|
+
data: readFileSync6(file)
|
|
1257
|
+
}));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// src/commands/skill.ts
|
|
1261
|
+
var USAGE6 = "usage: banger skill install [--project | --dir <path>] [--force]\n banger skill pack [--out <file>]";
|
|
1174
1262
|
var MARKER = ".banger-skill";
|
|
1175
1263
|
function installSkill(opts) {
|
|
1176
|
-
if (!existsSync6(
|
|
1264
|
+
if (!existsSync6(join8(opts.source, "SKILL.md"))) throw new CliError(2, `the bundled skill is missing: ${opts.source}`);
|
|
1177
1265
|
let outcome = "installed";
|
|
1178
1266
|
if (existsSync6(opts.dest)) {
|
|
1179
|
-
if (!existsSync6(
|
|
1267
|
+
if (!existsSync6(join8(opts.dest, MARKER)) && !opts.force) {
|
|
1180
1268
|
throw new CliError(2, `${opts.dest} already exists and was not written by banger; pass --force to replace it`);
|
|
1181
1269
|
}
|
|
1182
1270
|
rmSync2(opts.dest, { recursive: true, force: true });
|
|
1183
1271
|
outcome = "updated";
|
|
1184
1272
|
}
|
|
1185
1273
|
cpSync(opts.source, opts.dest, { recursive: true });
|
|
1186
|
-
writeFileSync3(
|
|
1274
|
+
writeFileSync3(join8(opts.dest, MARKER), `${opts.version}
|
|
1187
1275
|
`);
|
|
1188
1276
|
return outcome;
|
|
1189
1277
|
}
|
|
@@ -1192,10 +1280,26 @@ function bundledSkill() {
|
|
|
1192
1280
|
}
|
|
1193
1281
|
function cliVersion() {
|
|
1194
1282
|
const manifest = fileURLToPath3(new URL("../package.json", import.meta.url));
|
|
1195
|
-
return JSON.parse(
|
|
1283
|
+
return JSON.parse(readFileSync7(manifest, "utf8")).version;
|
|
1284
|
+
}
|
|
1285
|
+
function packSkill(source, out) {
|
|
1286
|
+
if (!existsSync6(join8(source, "SKILL.md"))) throw new CliError(2, `the bundled skill is missing: ${source}`);
|
|
1287
|
+
writeFileSync3(out, createZip(directoryEntries(source, "banger")));
|
|
1288
|
+
}
|
|
1289
|
+
function runPack(rest) {
|
|
1290
|
+
const { values, positionals } = parseArgsStrict(rest, { out: { type: "string" } });
|
|
1291
|
+
if (positionals.length > 0) throw new CliError(2, USAGE6);
|
|
1292
|
+
const out = resolve5(values.out ?? "banger-skill.zip");
|
|
1293
|
+
packSkill(bundledSkill(), out);
|
|
1294
|
+
process.stdout.write(`packed: ${out}
|
|
1295
|
+
|
|
1296
|
+
${PACK_NEXT_STEPS}
|
|
1297
|
+
${NEXT_STEPS}`);
|
|
1298
|
+
return 0;
|
|
1196
1299
|
}
|
|
1197
1300
|
function runSkill(argv) {
|
|
1198
1301
|
const [sub, ...rest] = argv;
|
|
1302
|
+
if (sub === "pack") return runPack(rest);
|
|
1199
1303
|
if (sub !== "install") throw new CliError(2, USAGE6);
|
|
1200
1304
|
const { values, positionals } = parseArgsStrict(rest, {
|
|
1201
1305
|
project: { type: "boolean" },
|
|
@@ -1203,7 +1307,7 @@ function runSkill(argv) {
|
|
|
1203
1307
|
force: { type: "boolean" }
|
|
1204
1308
|
});
|
|
1205
1309
|
if (positionals.length > 0 || values.project && values.dir !== void 0) throw new CliError(2, USAGE6);
|
|
1206
|
-
const dest = values.dir !== void 0 ? resolve5(values.dir) : values.project ? resolve5(".claude", "skills", "banger") :
|
|
1310
|
+
const dest = values.dir !== void 0 ? resolve5(values.dir) : values.project ? resolve5(".claude", "skills", "banger") : join8(homedir2(), ".claude", "skills", "banger");
|
|
1207
1311
|
const outcome = installSkill({ source: bundledSkill(), dest, version: cliVersion(), force: values.force });
|
|
1208
1312
|
process.stdout.write(`${outcome}: ${dest}
|
|
1209
1313
|
|
|
@@ -1221,10 +1325,13 @@ Start by asking, for example:
|
|
|
1221
1325
|
To see the talk, run \`banger preview\` in the talk's folder.
|
|
1222
1326
|
More: https://banger.page/start
|
|
1223
1327
|
`;
|
|
1328
|
+
var PACK_NEXT_STEPS = `To use the skill in the Claude app (claude.ai or Claude Desktop), upload this file
|
|
1329
|
+
from the app's Skills settings. Code execution must be on.
|
|
1330
|
+
`;
|
|
1224
1331
|
|
|
1225
1332
|
// src/commands/snap.ts
|
|
1226
1333
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
1227
|
-
import { dirname as dirname5, join as
|
|
1334
|
+
import { dirname as dirname5, join as join9 } from "node:path";
|
|
1228
1335
|
var USAGE7 = "usage: banger snap [file] [--stop N] [--step M|last] [--steps last|all] [--out path] [--out-dir dir] [--scale 1|2] [--lang <language>|all]";
|
|
1229
1336
|
function parseCount(name, value) {
|
|
1230
1337
|
if (!/^\d+$/.test(value)) throw new CliError(2, `invalid --${name}: ${value}`);
|
|
@@ -1273,13 +1380,13 @@ async function runSnap(argv) {
|
|
|
1273
1380
|
}
|
|
1274
1381
|
const states = expandStates(session.path, selection, only);
|
|
1275
1382
|
const single = only !== void 0;
|
|
1276
|
-
const dir = run.tag !== "" ?
|
|
1383
|
+
const dir = run.tag !== "" ? join9(outDir, run.language) : outDir;
|
|
1277
1384
|
if (!single) await clearStopFiles(dir);
|
|
1278
1385
|
for (const ref of states) {
|
|
1279
1386
|
const report = await session.goto(ref);
|
|
1280
1387
|
for (const failure of report.failed) failures.add(`${run.tag}${formatReadyFailure(failure)}`);
|
|
1281
1388
|
const png = await captureState(session, ref);
|
|
1282
|
-
const target = single && values.out ||
|
|
1389
|
+
const target = single && values.out || join9(dir, stopFileName(ref.stop, ref.step));
|
|
1283
1390
|
await mkdir2(dirname5(target), { recursive: true });
|
|
1284
1391
|
await writeFile2(target, png);
|
|
1285
1392
|
}
|
|
@@ -1363,15 +1470,15 @@ ${USAGE8}`);
|
|
|
1363
1470
|
}
|
|
1364
1471
|
|
|
1365
1472
|
// src/update-check.ts
|
|
1366
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
1473
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "node:fs";
|
|
1367
1474
|
import { homedir as homedir3 } from "node:os";
|
|
1368
|
-
import { dirname as dirname6, join as
|
|
1475
|
+
import { dirname as dirname6, join as join10 } from "node:path";
|
|
1369
1476
|
var PACKAGE = "@bangerpage/cli";
|
|
1370
1477
|
var LATEST_URL = "https://registry.npmjs.org/@bangerpage%2fcli/latest";
|
|
1371
1478
|
var INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
1372
1479
|
var TIMEOUT_MS = 2e3;
|
|
1373
1480
|
function updateCacheFile(env = process.env) {
|
|
1374
|
-
return
|
|
1481
|
+
return join10(env.XDG_CACHE_HOME || join10(homedir3(), ".cache"), "banger", "update-check.json");
|
|
1375
1482
|
}
|
|
1376
1483
|
function enabled(env, isTTY) {
|
|
1377
1484
|
return isTTY && !env.CI && !env.BANGER_NO_UPDATE_CHECK && !env.NO_UPDATE_NOTIFIER;
|
|
@@ -1389,7 +1496,7 @@ function isNewer(latest, current) {
|
|
|
1389
1496
|
}
|
|
1390
1497
|
function readCache(file) {
|
|
1391
1498
|
try {
|
|
1392
|
-
const data = JSON.parse(
|
|
1499
|
+
const data = JSON.parse(readFileSync8(file, "utf8"));
|
|
1393
1500
|
return typeof data.checkedAt === "number" && typeof data.latest === "string" ? { checkedAt: data.checkedAt, latest: data.latest } : void 0;
|
|
1394
1501
|
} catch {
|
|
1395
1502
|
return void 0;
|
|
@@ -1440,6 +1547,8 @@ commands:
|
|
|
1440
1547
|
skill install [--project | --dir <path>] [--force]
|
|
1441
1548
|
copy the agent skill to ~/.claude/skills/banger
|
|
1442
1549
|
(--project: ./.claude/skills/banger)
|
|
1550
|
+
skill pack [--out <file>] write the skill as a zip to upload in the Claude app
|
|
1551
|
+
(default: ./banger-skill.zip)
|
|
1443
1552
|
login [--token <token>] log in to banger.page in the browser (or store a token made
|
|
1444
1553
|
on the site's settings page)
|
|
1445
1554
|
logout forget the stored token
|
|
@@ -1463,7 +1572,7 @@ options:
|
|
|
1463
1572
|
var COMMANDS = /* @__PURE__ */ new Set(["init", "preview", "snap", "check", "export", "theme", "skill", "login", "logout", "publish"]);
|
|
1464
1573
|
function version() {
|
|
1465
1574
|
const manifest = fileURLToPath4(new URL("../package.json", import.meta.url));
|
|
1466
|
-
return JSON.parse(
|
|
1575
|
+
return JSON.parse(readFileSync9(manifest, "utf8")).version;
|
|
1467
1576
|
}
|
|
1468
1577
|
async function dispatch(argv) {
|
|
1469
1578
|
const [command, ...rest] = argv;
|