A CLI for scaffolding ATProto web applications
2
fork

Configure Feed

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

ok tests are passing now

+50 -18
+32 -11
__tests__/cli.test.ts
··· 1 - import { join } from "node:path" 2 - import { expect, test } from "vitest" 3 1 import child_process from "node:child_process"; 4 - import { promisify } from "node:util" 5 - const exec = promisify(child_process.exec) 2 + import { join } from "node:path"; 3 + import { expect, test } from "vitest"; 4 + 5 + const CLI_PATH = join(import.meta.dirname, ".."); 6 + 7 + async function run(args: string[], input = "\n") { 8 + const proc = child_process.spawn( 9 + "node", 10 + [CLI_PATH, ...args], 11 + { stdio: ["pipe", "pipe", "pipe"] } 12 + ); 13 + 14 + let stdout = ""; 15 + let stderr = ""; 16 + 17 + proc.stdout?.on("data", (data) => { 18 + stdout += data.toString(); 19 + }); 20 + proc.stderr?.on("data", (data) => { 21 + stderr += data.toString(); 22 + }); 6 23 7 - const CLI_PATH = join(import.meta.dirname, "..") 8 - const DEFAULT_PROJECT_NAME = "my-atproto-app" 24 + proc.stdin?.write(input); 25 + proc.stdin?.end(); 9 26 10 - async function run(args?: string[]) { 11 - return exec(`node ${CLI_PATH} ${args?.join(' ')}`) 27 + return new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve, reject) => { 28 + proc.on("close", (code) => { 29 + resolve({ stdout, stderr, code }); 30 + }); 31 + proc.on("error", reject); 32 + }); 12 33 } 13 34 14 35 test("should prompt for project name", async () => { 15 - const { stdout } = await run() 16 - expect(stdout).toContain("Please provide a name for this project:") 17 - }) 36 + const { stdout } = await run(["create"]); 37 + expect(stdout).toContain("Please provide a name for this project:"); 38 + });
+3
index.js
··· 1 + #!/usr/bin/env node 2 + 3 + import './dist/index.js'
+11 -3
package.json
··· 6 6 "atproto", 7 7 "cli" 8 8 ], 9 + "homepage": "https://tangled.org/did:plc:qttsv4e7pu2jl3ilanfgc3zn/create-atproto-app#readme", 10 + "bugs": { 11 + "url": "https://tangled.org/did:plc:qttsv4e7pu2jl3ilanfgc3zn/create-atproto-app/issues" 12 + }, 9 13 "license": "MIT", 10 14 "author": "Dane MIller <me@dane.computer>", 15 + "repository": { 16 + "type": "git", 17 + "url": "git+https://tangled.org/did:plc:qttsv4e7pu2jl3ilanfgc3zn/create-atproto-app" 18 + }, 11 19 "bin": { 12 - "create-atproto-app": "src/index.js" 20 + "create-atproto-app": "index.js" 13 21 }, 14 22 "files": [ 15 23 "index.js", ··· 17 25 "dist" 18 26 ], 19 27 "type": "module", 20 - "main": "dist/index.js", 28 + "main": "index.js", 21 29 "scripts": { 22 30 "dev": "tsx src/index.ts", 23 31 "build": "tsdown", ··· 26 34 "test:run": "vitest run" 27 35 }, 28 36 "dependencies": { 29 - "@clack/prompts": "^1.0.1", 30 37 "create-vite": "^8.3.0" 31 38 }, 32 39 "devDependencies": { 40 + "@clack/prompts": "^1.0.1", 33 41 "@types/node": "^22.0.0", 34 42 "citty": "^0.2.1", 35 43 "lefthook": "^2.1.1",
+1 -1
src/commands/create.ts
··· 130 130 message: pc.yellow( 131 131 `A project with the name of ${projectName} already exists, should we overwrite the existing folder?`, 132 132 ), 133 - initialValue: false 133 + initialValue: false, 134 134 })); 135 135 136 136 if (overwrite === false) {
+3 -3
tsdown.config.ts
··· 1 - import { defineConfig } from "tsdown" 1 + import { defineConfig } from "tsdown"; 2 2 3 3 export default defineConfig({ 4 4 entry: "src/index.ts", 5 5 target: "node20", 6 6 minify: true, 7 7 inlineOnly: false, 8 - fixedExtension: false 9 - }) 8 + fixedExtension: false, 9 + });