Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

lex-cli non-deno

+70 -13
+16 -5
common/logger.ts
··· 7 7 type Sink, 8 8 } from "@logtape/logtape"; 9 9 import { getFileSink } from "@logtape/file"; 10 + import process from "node:process"; 11 + 12 + // Runtime detection for Deno vs Node.js 13 + const isDeno = typeof Deno !== "undefined"; 14 + const getEnv = (key: string): string | undefined => { 15 + if (isDeno) { 16 + return Deno.env.get(key); 17 + } else { 18 + return process.env[key]; 19 + } 20 + }; 10 21 11 - const allSystemsEnabled = !Deno.env.get("LOG_SYSTEMS"); 12 - const enabledSystems = (Deno.env.get("LOG_SYSTEMS") || "") 22 + const allSystemsEnabled = !getEnv("LOG_SYSTEMS"); 23 + const enabledSystems = (getEnv("LOG_SYSTEMS") || "") 13 24 .replace(",", " ") 14 25 .split(" ") 15 26 .filter(Boolean); 16 27 17 - const enabledEnv = Deno.env.get("LOG_ENABLED"); 28 + const enabledEnv = getEnv("LOG_ENABLED"); 18 29 const enabled = enabledEnv === "true" || enabledEnv === "t" || 19 30 enabledEnv === "1"; 20 31 21 - const level = (Deno.env.get("LOG_LEVEL") || "info") as LogLevel; 22 - const logDestination = Deno.env.get("LOG_DESTINATION"); 32 + const level = (getEnv("LOG_LEVEL") || "info") as LogLevel; 33 + const logDestination = getEnv("LOG_DESTINATION"); 23 34 24 35 // Initialize LogTape configuration 25 36 let configured = false;
+17 -1
deno.lock
··· 55 55 "npm:multiformats@*": "13.4.0", 56 56 "npm:multiformats@^13.4.0": "13.4.0", 57 57 "npm:multiformats@^13.4.1": "13.4.1", 58 + "npm:prettier@^3.6.2": "3.6.2", 58 59 "npm:rate-limiter-flexible@^2.4.1": "2.4.2", 59 60 "npm:uint8arrays@3.0.0": "3.0.0", 60 61 "npm:uint8arrays@^5.1.0": "5.1.0", ··· 428 429 ], 429 430 "bin": true 430 431 }, 432 + "prettier@3.6.2": { 433 + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", 434 + "bin": true 435 + }, 431 436 "rate-limiter-flexible@2.4.2": { 432 437 "integrity": "sha512-rMATGGOdO1suFyf/mI5LYhts71g1sbdhmd6YvdiXO2gJnd42Tt6QS4JUKJKSWVVkMtBacm6l40FR7Trjo6Iruw==" 433 438 }, ··· 465 470 "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==" 466 471 } 467 472 }, 473 + "remote": { 474 + "https://deno.land/x/deno_fmt@0.1.5/mod.ts": "bb74c57907b77a301cef37236af9de85c2cb0ac75f79a9c60db3208e979f19a8", 475 + "https://deno.land/x/deno_fmt@0.1.5/src/context.ts": "baf814994ef5696f8ced9b5d0156b81ec75207e41e989c76b84b87dbe50d6e54", 476 + "https://deno.land/x/deno_fmt@0.1.5/src/dprint.ts": "a5ea7261f77998f0e8d5d9e581c6d15afe86aa9ab32af2dccfe4865b008a2774", 477 + "https://deno.land/x/deno_fmt@0.1.5/src/fmt.ts": "52941a928918a62c5efe9594b83ed1bf89f324ca132c292695ea17e791315dfa", 478 + "https://deno.land/x/deno_fmt@0.1.5/src/helpers.ts": "45da2c3cab4faf8f883bce5b9edd83cde5d80f5f75ca42e41195759b98acbcdf", 479 + "https://deno.land/x/deno_fmt@0.1.5/src/lru.ts": "0a22753be042c5ea63dcf830a04e3481a9cded5b755de7b6146be97a36274ffa", 480 + "https://deno.land/x/deno_fmt@0.1.5/src/options.ts": "840c13cf1d78255681b91625eb7719b2883f68f4f0f25142f697bf0e57304b02", 481 + "https://deno.land/x/deno_fmt@0.1.5/src/sha256.ts": "eea8272cd53072763ad5fa8e632a572676cde41e027485116a8f84a49a669bf8" 482 + }, 468 483 "workspace": { 469 484 "members": { 470 485 "common": { ··· 493 508 "jsr:@std/path@^1.1.2", 494 509 "jsr:@ts-morph/ts-morph@26", 495 510 "jsr:@zod/zod@^4.1.5", 496 - "npm:@atproto/lexicon@~0.4.14" 511 + "npm:@atproto/lexicon@~0.4.14", 512 + "npm:prettier@^3.6.2" 497 513 ] 498 514 }, 499 515 "syntax": {
+3 -2
lex-cli/cmd/gen-api.ts
··· 9 9 import { formatGeneratedFiles } from "../codegen/util.ts"; 10 10 11 11 const command = new Command() 12 - .command("gen-api") 13 12 .description("Generate a TS client API") 14 13 .option("--js", "use .js extension for imports instead of .ts") 15 14 .option("-o, --outdir <outdir>", "dir path to write to", { required: true }) ··· 26 25 console.log("This will write the following files:"); 27 26 printFileDiff(diff); 28 27 applyFileDiff(diff); 29 - await formatGeneratedFiles(outdir); 28 + if (typeof Deno !== "undefined") { 29 + await formatGeneratedFiles(outdir); 30 + } 30 31 console.log("API generated."); 31 32 }, 32 33 );
+8 -1
lex-cli/cmd/gen-md.ts
··· 1 1 import { Command } from "@cliffy/command"; 2 2 import { readAllLexicons } from "../util.ts"; 3 3 import * as mdGen from "../mdgen/index.ts"; 4 + import process from "node:process"; 5 + 6 + const isDeno = typeof Deno !== "undefined"; 4 7 5 8 const command = new Command() 6 9 .description("Generate markdown documentation") ··· 12 15 console.error( 13 16 "Must supply the path to a .md file as the first parameter", 14 17 ); 15 - Deno.exit(1); 18 + if (isDeno) { 19 + Deno.exit(1); 20 + } else { 21 + process.exit(1); 22 + } 16 23 } 17 24 const lexicons = readAllLexicons(input); 18 25 await mdGen.process(output, lexicons);
+3 -1
lex-cli/cmd/gen-server.ts
··· 27 27 console.log("This will write the following files:"); 28 28 printFileDiff(diff); 29 29 applyFileDiff(diff); 30 - await formatGeneratedFiles(outdir); 30 + if (typeof Deno !== "undefined") { 31 + await formatGeneratedFiles(outdir); 32 + } 31 33 console.log("API generated."); 32 34 }, 33 35 );
+16 -1
lex-cli/codegen/common.ts
··· 6 6 import type { LexiconDoc } from "@atproto/lexicon"; 7 7 import type { GeneratedFile } from "../types.ts"; 8 8 import type { CodeGenOptions } from "./util.ts"; 9 + import { format, type Options as PrettierOptions } from "prettier"; 10 + import * as fmt from "deno_fmt"; 11 + 12 + const PRETTIER_OPTS: PrettierOptions = { 13 + parser: "typescript", 14 + tabWidth: 2, 15 + semi: false, 16 + singleQuote: true, 17 + trailingComma: "all", 18 + }; 9 19 10 20 export const utilTs = ( 11 21 project: Project, ··· 276 286 const file = project.createSourceFile(path); 277 287 gen(file); 278 288 await file.save(); // Save in the "in memory" file system 279 - const content = `${banner()}${file.getFullText()}`; 289 + let content = `${banner()}${file.getFullText()}`; 290 + if (!(typeof Deno !== "undefined")) { 291 + content = await format(content, PRETTIER_OPTS); 292 + } else { 293 + content = await fmt.format(content); 294 + } 280 295 281 296 return { path, content }; 282 297 }
+3 -1
lex-cli/deno.json
··· 9 9 "@std/fs": "jsr:@std/fs@^1.0.19", 10 10 "@std/path": "jsr:@std/path@^1.1.2", 11 11 "@atproto/lexicon": "npm:@atproto/lexicon@^0.4.14", 12 + "prettier": "npm:prettier@^3.6.2", 12 13 "ts-morph": "jsr:@ts-morph/ts-morph@^26.0.0", 13 - "zod": "jsr:@zod/zod@^4.1.5" 14 + "zod": "jsr:@zod/zod@^4.1.5", 15 + "deno_fmt": "https://deno.land/x/deno_fmt@0.1.5/mod.ts" 14 16 } 15 17 }
+4 -1
lex-cli/mod.ts
··· 2 2 3 3 import { Command } from "@cliffy/command"; 4 4 import { genApi, genMd, genServer, genTsObj } from "./cmd/index.ts"; 5 + import process from "node:process"; 6 + 7 + const isDeno = typeof Deno !== "undefined"; 5 8 6 9 await new Command() 7 10 .name("lex-cli") ··· 10 13 .command("gen-md", genMd) 11 14 .command("gen-server", genServer) 12 15 .command("gen-ts-obj", genTsObj) 13 - .parse(Deno.args); 16 + .parse(isDeno ? Deno.args : process.argv.slice(2));