A CLI for scaffolding ATProto web applications

chore(templates): dynamically add scripts and dependencies to template package.json

besaid.zone 602b2b60 c0f97556

verified
+25 -19
+22
src/commands/init.ts
··· 22 existsSync, 23 mkdirSync, 24 readdirSync, 25 rmSync, 26 statSync, 27 } from "node:fs"; 28 import { join, resolve } from "node:path"; 29 import { fileURLToPath } from "node:url"; ··· 173 const destinationTemplateFiles = resolve(root, file); 174 copy(sourceTemplateFiles, destinationTemplateFiles); 175 } 176 177 appendFileSync( 178 join(root, ".gitignore"),
··· 22 existsSync, 23 mkdirSync, 24 readdirSync, 25 + readFileSync, 26 rmSync, 27 statSync, 28 + writeFileSync, 29 } from "node:fs"; 30 import { join, resolve } from "node:path"; 31 import { fileURLToPath } from "node:url"; ··· 175 const destinationTemplateFiles = resolve(root, file); 176 copy(sourceTemplateFiles, destinationTemplateFiles); 177 } 178 + 179 + // add atproto related scripts and packages to package.json 180 + const pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8")); 181 + pkg.name = projectName; 182 + pkg.dependencies = { 183 + ...pkg.dependencies, 184 + "@atproto/lex": "0.0.16", 185 + }; 186 + 187 + pkg.scripts = { 188 + ...pkg.scripts, 189 + "update-lexicons": "lex install --update --save", 190 + postinstall: "lex install --ci", 191 + prebuild: "lex build --out ./src/__generated__", 192 + }; 193 + 194 + writeFileSync( 195 + join(root, "package.json"), 196 + JSON.stringify(pkg, null, 2) + "\n", 197 + ); 198 199 appendFileSync( 200 join(root, ".gitignore"),
+1 -5
templates/react-ts/package.json
··· 6 "scripts": { 7 "dev": "vite", 8 "build": "tsc -b && vite build", 9 - "preview": "vite preview", 10 - "update-lexicons": "lex install --update --save", 11 - "postinstall": "lex install --ci", 12 - "prebuild": "lex build --out ./src/__generated__" 13 }, 14 "dependencies": { 15 - "@atproto/lex": "0.0.16", 16 "react": "^19.2.4", 17 "react-dom": "^19.2.4" 18 },
··· 6 "scripts": { 7 "dev": "vite", 8 "build": "tsc -b && vite build", 9 + "preview": "vite preview" 10 }, 11 "dependencies": { 12 "react": "^19.2.4", 13 "react-dom": "^19.2.4" 14 },
+1 -7
templates/svelte-ts/package.json
··· 7 "dev": "vite", 8 "build": "vite build", 9 "preview": "vite preview", 10 - "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", 11 - "update-lexicons": "lex install --update --save", 12 - "postinstall": "lex install --ci", 13 - "prebuild": "lex build --out ./src/__generated__" 14 - }, 15 - "dependencies": { 16 - "@atproto/lex": "^0.0.16" 17 }, 18 "devDependencies": { 19 "@sveltejs/vite-plugin-svelte": "^6.2.1",
··· 7 "dev": "vite", 8 "build": "vite build", 9 "preview": "vite preview", 10 + "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json" 11 }, 12 "devDependencies": { 13 "@sveltejs/vite-plugin-svelte": "^6.2.1",
+1 -7
templates/vanilla/package.json
··· 6 "scripts": { 7 "dev": "vite", 8 "build": "vite build", 9 - "preview": "vite preview", 10 - "update-lexicons": "lex install --update --save", 11 - "postinstall": "lex install --ci", 12 - "prebuild": "lex build --out ./src/__generated__" 13 - }, 14 - "dependencies": { 15 - "@atproto/lex": "^0.0.16" 16 }, 17 "devDependencies": { 18 "vite": "^7.3.1"
··· 6 "scripts": { 7 "dev": "vite", 8 "build": "vite build", 9 + "preview": "vite preview" 10 }, 11 "devDependencies": { 12 "vite": "^7.3.1"