@quickback-dev/cli 0.46.0 → 0.47.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.
Files changed (44) hide show
  1. package/dist/commands/compile.d.ts +1 -1
  2. package/dist/commands/compile.js +1 -1
  3. package/dist/docs/content.js +11 -11
  4. package/dist/docs/content.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/lib/file-loader.d.ts +1 -1
  7. package/dist/lib/file-loader.d.ts.map +1 -1
  8. package/dist/lib/file-loader.js +16 -3
  9. package/dist/lib/file-loader.js.map +1 -1
  10. package/dist/skill/docs/changelog.md +389 -0
  11. package/dist/skill/docs/compiler/definitions/access.md +17 -0
  12. package/dist/skill/docs/compiler/definitions/actions.md +9 -4
  13. package/dist/skill/docs/compiler/definitions/diagnostics.md +88 -57
  14. package/dist/skill/docs/compiler/targets/hono-api/database/neon.md +27 -8
  15. package/dist/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +2 -1
  16. package/dist/skill/docs/stack/account-ui/features/organizations.md +1 -1
  17. package/dist/skill/docs/stack/cms/pages.md +1 -1
  18. package/dist/skill/docs/stack/realtime/durable-objects.md +9 -0
  19. package/dist/skill/docs/stack/realtime/live-views.md +4 -0
  20. package/dist/skill/docs/stack/realtime/using-realtime.md +2 -2
  21. package/package.json +1 -1
  22. package/src/skill/docs/changelog.md +389 -0
  23. package/src/skill/docs/compiler/definitions/access.md +17 -0
  24. package/src/skill/docs/compiler/definitions/actions.md +9 -4
  25. package/src/skill/docs/compiler/definitions/diagnostics.md +88 -57
  26. package/src/skill/docs/compiler/targets/hono-api/database/neon.md +27 -8
  27. package/src/skill/docs/compiler/targets/hono-api/using-the-api/openapi.md +2 -1
  28. package/src/skill/docs/stack/account-ui/features/organizations.md +1 -1
  29. package/src/skill/docs/stack/cms/pages.md +1 -1
  30. package/src/skill/docs/stack/realtime/durable-objects.md +9 -0
  31. package/src/skill/docs/stack/realtime/live-views.md +4 -0
  32. package/src/skill/docs/stack/realtime/using-realtime.md +2 -2
  33. package/dist/commands/init.d.ts +0 -6
  34. package/dist/commands/init.d.ts.map +0 -1
  35. package/dist/commands/init.js +0 -405
  36. package/dist/commands/init.js.map +0 -1
  37. package/dist/lib/sweep-stale.d.ts +0 -25
  38. package/dist/lib/sweep-stale.d.ts.map +0 -1
  39. package/dist/lib/sweep-stale.js +0 -179
  40. package/dist/lib/sweep-stale.js.map +0 -1
  41. package/dist/lib/sweep-stale.test.d.ts +0 -2
  42. package/dist/lib/sweep-stale.test.d.ts.map +0 -1
  43. package/dist/lib/sweep-stale.test.js +0 -130
  44. package/dist/lib/sweep-stale.test.js.map +0 -1
@@ -1,405 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "fs";
2
- import { join, resolve } from "path";
3
- import pc from "picocolors";
4
- export async function init(options) {
5
- const targetPath = resolve(options?.path || ".");
6
- const quickbackPath = join(targetPath, "quickback");
7
- // Check if quickback folder already exists
8
- if (existsSync(quickbackPath)) {
9
- console.error(pc.red("Error: quickback folder already exists in this directory"));
10
- process.exit(1);
11
- }
12
- console.log(pc.cyan("Creating quickback project structure..."));
13
- try {
14
- // Create folder structure
15
- mkdirSync(quickbackPath, { recursive: true });
16
- mkdirSync(join(quickbackPath, "definitions"), { recursive: true });
17
- mkdirSync(join(quickbackPath, "definitions", "auth"), { recursive: true });
18
- mkdirSync(join(quickbackPath, "definitions", "features"), { recursive: true });
19
- mkdirSync(join(quickbackPath, "definitions", "features", "todos"), { recursive: true });
20
- mkdirSync(join(quickbackPath, "output"), { recursive: true });
21
- // Create quickback.config.ts with new provider-based format
22
- //
23
- // The block between [quickback:options-start] / [quickback:options-end]
24
- // is owned by Quickback and **regenerated on every `quickback
25
- // compile`** — the CLI splices in whatever the server returns.
26
- // Keeping it server-driven means new options appear automatically
27
- // when you upgrade Quickback (no CLI bump needed) and any options
28
- // you've already set get omitted from the block to avoid
29
- // duplication. To enable an option, copy its line *above* the
30
- // start sentinel; Quickback will preserve it and drop it from the
31
- // managed block on the next compile.
32
- const configContent = `/**
33
- * Quickback Configuration
34
- *
35
- * This file defines your backend configuration using the provider system.
36
- * Use presets for quick setup, or define individual providers for customization.
37
- *
38
- * The block between [quickback:options-start] and [quickback:options-end]
39
- * is regenerated on every \`quickback compile\` to reflect the current set
40
- * of options Quickback supports — auth flavors, file uploads, agent
41
- * surfaces, ETag, OpenAPI publishing, custom bindings, and so on. Copy
42
- * any line you want to enable *above* the start sentinel; Quickback
43
- * preserves anything outside the marker block and drops it from the
44
- * managed block on the next compile.
45
- */
46
- import { defineConfig } from "@quickback/compiler";
47
- import { cloudflare } from "@quickback/compiler/presets";
48
-
49
- export default defineConfig({
50
- // Project settings
51
- name: "my-quickback-app",
52
- template: "hono", // "hono" | "nextjs"
53
-
54
- // Use a preset for quick setup (includes runtime, database, storage, auth)
55
- providers: cloudflare({
56
- // Optional customization:
57
- // databaseBinding: "DATABASE",
58
- // kvBinding: "KV",
59
- }),
60
-
61
- // Build settings
62
- build: {
63
- outputDir: "./output",
64
- },
65
-
66
- // [quickback:options-start]
67
- // Run \`quickback compile\` to populate this block with every available option.
68
- // [quickback:options-end]
69
- });
70
-
71
- /**
72
- * Alternative: For local development with Bun and SQLite, use:
73
- *
74
- * import { bun } from "@quickback/compiler/presets";
75
- *
76
- * providers: bun({
77
- * databasePath: "./data/app.db",
78
- * }),
79
- */
80
- `;
81
- writeFileSync(join(quickbackPath, "quickback.config.ts"), configContent);
82
- // Create auth definition
83
- const authConfigContent = `/**
84
- * Better Auth Configuration
85
- *
86
- * This file defines your authentication configuration for Better Auth.
87
- * Modify this to customize authentication behavior in your application.
88
- */
89
-
90
- export const authConfig = {
91
- // Core settings
92
- autoDetectIpAddress: true,
93
- geolocationTracking: true,
94
-
95
- // Authentication methods
96
- emailAndPassword: {
97
- enabled: true,
98
- requireEmailVerification: false
99
- },
100
-
101
- // Plugins - Add or remove based on your needs
102
- // Available plugins: "anonymous", "openAPI", "twoFactor", "passkey", "magicLink"
103
- plugins: ["anonymous"],
104
-
105
- // Rate limiting configuration
106
- rateLimit: {
107
- enabled: true,
108
- window: 60, // seconds (minimum for KV is 60s)
109
- max: 100, // requests per window
110
- customRules: {
111
- // Add custom rate limit rules for specific endpoints
112
- "/sign-in/email": {
113
- window: 60,
114
- max: 10
115
- },
116
- "/sign-in/social": {
117
- window: 60,
118
- max: 10
119
- }
120
- }
121
- },
122
-
123
- // Social providers - Enable and configure as needed
124
- socialProviders: {
125
- google: {
126
- enabled: false,
127
- // clientId and clientSecret will be read from environment variables
128
- },
129
- github: {
130
- enabled: false,
131
- },
132
- discord: {
133
- enabled: false,
134
- }
135
- },
136
-
137
- // Session configuration
138
- session: {
139
- expiresInDays: 30,
140
- updateAgeInDays: 1
141
- },
142
-
143
- // Database configuration
144
- database: {
145
- // Additional database-specific options
146
- usePlural: true, // Use plural table names (users, sessions, etc.)
147
- debugLogs: true // Enable debug logging for database operations
148
- }
149
- };
150
- `;
151
- writeFileSync(join(quickbackPath, "definitions", "auth", "better-auth.ts"), authConfigContent);
152
- // Create example todos feature
153
- const todosSchemaContent = `/**
154
- * Todos Feature Schema
155
- *
156
- * Example feature definition showing how to create database schemas
157
- * and API endpoints for your application features.
158
- */
159
-
160
- import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
161
- import { sql } from "drizzle-orm";
162
-
163
- export const todos = sqliteTable("todos", {
164
- id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
165
- userId: text("user_id").notNull(),
166
- title: text("title").notNull(),
167
- description: text("description"),
168
- completed: integer("completed", { mode: "boolean" }).default(false).notNull(),
169
- createdAt: integer("created_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
170
- updatedAt: integer("updated_at", { mode: "timestamp" }).$defaultFn(() => new Date()),
171
- });
172
-
173
- export type Todo = typeof todos.$inferSelect;
174
- export type NewTodo = typeof todos.$inferInsert;
175
- `;
176
- writeFileSync(join(quickbackPath, "definitions", "features", "todos", "schema.ts"), todosSchemaContent);
177
- // Create todos API routes
178
- const todosRoutesContent = `/**
179
- * Todos API Routes
180
- *
181
- * Example API implementation for the todos feature.
182
- * Shows how to create authenticated CRUD endpoints.
183
- */
184
-
185
- import { Hono } from "hono";
186
- import { eq, and } from "drizzle-orm";
187
- import type { Todo, NewTodo } from "./schema";
188
-
189
- export function createTodosRoutes(auth: any, db: any, todos: any) {
190
- const app = new Hono();
191
-
192
- // Get all todos for the authenticated user
193
- app.get("/", async (c) => {
194
- const session = await auth.api.getSession({
195
- headers: c.req.raw.headers,
196
- });
197
-
198
- if (!session) {
199
- return c.json({ error: "Unauthorized" }, 401);
200
- }
201
-
202
- const userTodos = await db
203
- .select()
204
- .from(todos)
205
- .where(eq(todos.userId, session.user.id));
206
-
207
- return c.json(userTodos);
208
- });
209
-
210
- // Create a new todo
211
- app.post("/", async (c) => {
212
- const session = await auth.api.getSession({
213
- headers: c.req.raw.headers,
214
- });
215
-
216
- if (!session) {
217
- return c.json({ error: "Unauthorized" }, 401);
218
- }
219
-
220
- const body = await c.req.json<{ title: string; description?: string }>();
221
-
222
- if (!body.title) {
223
- return c.json({ error: "Title is required" }, 400);
224
- }
225
-
226
- const newTodo: NewTodo = {
227
- userId: session.user.id,
228
- title: body.title,
229
- description: body.description,
230
- };
231
-
232
- const [todo] = await db.insert(todos).values(newTodo).returning();
233
- return c.json(todo, 201);
234
- });
235
-
236
- // Update a todo
237
- app.patch("/:id", async (c) => {
238
- const session = await auth.api.getSession({
239
- headers: c.req.raw.headers,
240
- });
241
-
242
- if (!session) {
243
- return c.json({ error: "Unauthorized" }, 401);
244
- }
245
-
246
- const id = c.req.param("id");
247
- const body = await c.req.json<{ title?: string; description?: string; completed?: boolean }>();
248
-
249
- const [updatedTodo] = await db
250
- .update(todos)
251
- .set({
252
- ...body,
253
- updatedAt: new Date(),
254
- })
255
- .where(and(eq(todos.id, id), eq(todos.userId, session.user.id)))
256
- .returning();
257
-
258
- if (!updatedTodo) {
259
- return c.json({ error: "Todo not found" }, 404);
260
- }
261
-
262
- return c.json(updatedTodo);
263
- });
264
-
265
- // Delete a todo
266
- app.delete("/:id", async (c) => {
267
- const session = await auth.api.getSession({
268
- headers: c.req.raw.headers,
269
- });
270
-
271
- if (!session) {
272
- return c.json({ error: "Unauthorized" }, 401);
273
- }
274
-
275
- const id = c.req.param("id");
276
-
277
- const [deletedTodo] = await db
278
- .delete(todos)
279
- .where(and(eq(todos.id, id), eq(todos.userId, session.user.id)))
280
- .returning();
281
-
282
- if (!deletedTodo) {
283
- return c.json({ error: "Todo not found" }, 404);
284
- }
285
-
286
- return c.json({ message: "Todo deleted successfully" });
287
- });
288
-
289
- return app;
290
- }
291
- `;
292
- writeFileSync(join(quickbackPath, "definitions", "features", "todos", "routes.ts"), todosRoutesContent);
293
- // Create todos README
294
- const todosReadmeContent = `# Todos Feature
295
-
296
- This is an example feature showing how to structure your application features in Quickback.
297
-
298
- ## Structure
299
-
300
- - **schema.ts** - Defines the database schema using Drizzle ORM
301
- - **routes.ts** - Implements the API endpoints for CRUD operations
302
-
303
- ## Usage
304
-
305
- This feature will be automatically integrated into your application when you run the Quickback compiler. The routes will be mounted at \`/api/todos\`.
306
-
307
- ## Endpoints
308
-
309
- - \`GET /api/todos\` - Get all todos for the authenticated user
310
- - \`POST /api/todos\` - Create a new todo
311
- - \`PATCH /api/todos/:id\` - Update a todo
312
- - \`DELETE /api/todos/:id\` - Delete a todo
313
-
314
- All endpoints require authentication via Better Auth sessions.
315
- `;
316
- writeFileSync(join(quickbackPath, "definitions", "features", "todos", "README.md"), todosReadmeContent);
317
- // Create .gitignore
318
- const gitignoreContent = `# Output directory
319
- output/
320
-
321
- # Dependencies
322
- node_modules/
323
-
324
- # Environment files
325
- .env
326
- .env.local
327
- .env.*.local
328
-
329
- # IDE
330
- .vscode/
331
- .idea/
332
-
333
- # OS
334
- .DS_Store
335
- Thumbs.db
336
-
337
- # Logs
338
- *.log
339
-
340
- # Build artifacts
341
- dist/
342
- build/
343
- .next/
344
- `;
345
- writeFileSync(join(quickbackPath, ".gitignore"), gitignoreContent);
346
- // Create README
347
- const readmeContent = `# Quickback Project
348
-
349
- This is a Quickback project structure for building Cloudflare Workers applications with authentication.
350
-
351
- ## Structure
352
-
353
- - **quickback.config.ts** - Main configuration file for your project
354
- - **definitions/** - Contains all your feature and configuration definitions
355
- - **auth/** - Authentication configuration (Better Auth)
356
- - **features/** - Your application features (APIs, schemas, etc.)
357
- - **output/** - Generated code output (gitignored)
358
-
359
- ## Getting Started
360
-
361
- 1. Customize \`quickback.config.ts\` with your project settings
362
- 2. Modify \`definitions/auth/better-auth.ts\` for authentication configuration
363
- 3. Add your own features in \`definitions/features/\`
364
- 4. Run the Quickback compiler to generate your application:
365
-
366
- \`\`\`bash
367
- npx @quickback/compiler generate
368
- \`\`\`
369
-
370
- ## Adding Features
371
-
372
- Create a new directory under \`definitions/features/\` with:
373
- - \`schema.ts\` - Database schema definitions
374
- - \`routes.ts\` - API route implementations
375
- - Any other files needed for your feature
376
-
377
- ## Environment Variables
378
-
379
- Configure the following in your \`.env\` file:
380
- - \`CLOUDFLARE_ACCOUNT_ID\` - Your Cloudflare account ID
381
- - Social provider credentials (if using social auth)
382
- - Database connection strings (for Hyperdrive)
383
-
384
- ## Learn More
385
-
386
- - [Quickback Documentation](https://github.com/quickback/quickback-compiler)
387
- - [Better Auth Documentation](https://www.better-auth.com)
388
- - [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers)
389
- `;
390
- writeFileSync(join(quickbackPath, "README.md"), readmeContent);
391
- console.log(pc.green("\n✅ Quickback project structure created successfully!"));
392
- console.log(pc.cyan("\nNext steps:"));
393
- console.log(pc.white(` 1. cd ${quickbackPath}`));
394
- console.log(pc.white(" 2. Customize quickback.config.ts"));
395
- console.log(pc.white(" 3. Modify auth configuration in definitions/auth/"));
396
- console.log(pc.white(" 4. Add your features in definitions/features/"));
397
- console.log(pc.white(" 5. Run: npx @quickback/compiler generate"));
398
- console.log(pc.cyan("\nFor more information, see the README.md file in the quickback folder."));
399
- }
400
- catch (error) {
401
- console.error(pc.red("Error creating quickback structure:"), error);
402
- process.exit(1);
403
- }
404
- }
405
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,YAAY,CAAC;AAM5B,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAqB;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,IAAI,GAAG,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAEpD,2CAA2C;IAC3C,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC,CAAC;QAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC,CAAC;IAEhE,IAAI,CAAC;QACD,0BAA0B;QAC1B,SAAS,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,UAAU,CAAC,EAAE,EAAE,S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;QACpE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC,CAAC;IAEpG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,qCAAqC,CAAC,EAAE,KAAK,CAAC,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC"}
@@ -1,25 +0,0 @@
1
- export interface SweepOptions {
2
- /**
3
- * If set, copy the target dir into `<archiveDir>/<targetBasename>-<ISO>/`
4
- * before deleting anything. No-op when no orphans are found.
5
- */
6
- archiveDir?: string;
7
- /** How many archives to retain. Defaults to 3. */
8
- archiveKeep?: number;
9
- /** Subtrees (relative to outputDir) to skip — e.g. SPA asset dirs that already get a hard wipe upstream. */
10
- skipPrefixes?: Iterable<string>;
11
- }
12
- export interface SweepResult {
13
- /** Files deleted because they were stale orphans. */
14
- deleted: string[];
15
- /** Files NOT deleted despite being missing from the manifest — they lacked the generated-header marker. */
16
- preserved: string[];
17
- /** Path to the archive created before deletion (undefined when nothing was deleted or archiveDir wasn't set). */
18
- archivePath?: string;
19
- }
20
- /**
21
- * Sweep stale generated files under `targetDir`. Paths in `manifest` are
22
- * relative to `outputDir` (matching the wire shape the compiler returns).
23
- */
24
- export declare function sweepStaleGeneratedFiles(outputDir: string, targetDir: string, manifest: Iterable<string>, options?: SweepOptions): Promise<SweepResult>;
25
- //# sourceMappingURL=sweep-stale.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sweep-stale.d.ts","sourceRoot":"","sources":["../../src/lib/sweep-stale.ts"],"names":[],"mappings":"AAyCA,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,2GAA2G;IAC3G,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iHAAiH;IACjH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC1B,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
@@ -1,179 +0,0 @@
1
- /**
2
- * Stale-file sweep for generated output trees.
3
- *
4
- * `src/` is hermetic — every file there is emitted by the compiler and
5
- * carries the "Generated by quickback.dev" header. When a feature is
6
- * removed/renamed or a generator stops emitting a file, the orphaned file
7
- * lingers under merge-only writes and can mask bugs (dead routes, ghost
8
- * imports, mismatched types, stale schemas the user assumes are current).
9
- *
10
- * This helper walks a target dir, deletes any file whose path isn't in the
11
- * compiler's manifest *and* carries the generated-header marker, then
12
- * collapses the empty directories left behind. Files without the marker are
13
- * preserved (defence against accidentally nuking hand-authored content that
14
- * snuck into a generated tree).
15
- *
16
- * Before any deletes, it copies the target dir into a timestamped archive
17
- * under `archiveDir` (when provided). The archive is uncompressed (just a
18
- * recursive copy via Node's built-in fs.cp) so it's trivially inspectable
19
- * and recoverable with `cp -r`. Old archives beyond `archiveKeep` are
20
- * pruned. The archive is skipped entirely on no-op compiles where no
21
- * orphans were found.
22
- */
23
- import { promises as fs } from 'fs';
24
- import { join, relative, sep } from 'path';
25
- const GENERATED_MARKER = 'Generated by quickback.dev';
26
- const HEADER_PROBE_BYTES = 512;
27
- const DEFAULT_ARCHIVE_KEEP = 3;
28
- /**
29
- * OS / editor noise that every contributor accidentally drops into checked-out
30
- * trees. These files are *never* compiler output and *never* user-authored
31
- * content the user cares about — silently skip them rather than warning the
32
- * user every compile that ".DS_Store has no Quickback header".
33
- */
34
- const SILENT_IGNORE_BASENAMES = new Set([
35
- '.DS_Store',
36
- 'Thumbs.db',
37
- '.localized',
38
- ]);
39
- /**
40
- * Sweep stale generated files under `targetDir`. Paths in `manifest` are
41
- * relative to `outputDir` (matching the wire shape the compiler returns).
42
- */
43
- export async function sweepStaleGeneratedFiles(outputDir, targetDir, manifest, options = {}) {
44
- const result = { deleted: [], preserved: [] };
45
- const fullTarget = join(outputDir, targetDir);
46
- if (!(await pathExists(fullTarget)))
47
- return result;
48
- const manifestSet = new Set();
49
- for (const p of manifest)
50
- manifestSet.add(normalizePath(p));
51
- const skipNormalized = [...(options.skipPrefixes ?? [])].map(normalizePath);
52
- const isSkipped = (relPath) => skipNormalized.some((sp) => relPath === sp || relPath.startsWith(sp + '/'));
53
- const onDisk = [];
54
- await collectFiles(fullTarget, outputDir, onDisk);
55
- // First pass: identify deletions without acting, so the archive captures
56
- // the pre-delete state and runs only when there's something to lose.
57
- const toDelete = [];
58
- for (const relPath of onDisk) {
59
- if (manifestSet.has(relPath))
60
- continue;
61
- if (isSkipped(relPath))
62
- continue;
63
- const base = relPath.slice(relPath.lastIndexOf('/') + 1);
64
- if (SILENT_IGNORE_BASENAMES.has(base))
65
- continue;
66
- const fullPath = join(outputDir, relPath);
67
- if (await fileHasMarker(fullPath, GENERATED_MARKER)) {
68
- toDelete.push(relPath);
69
- }
70
- else {
71
- result.preserved.push(relPath);
72
- }
73
- }
74
- if (toDelete.length === 0)
75
- return result;
76
- if (options.archiveDir) {
77
- result.archivePath = await archiveDirectory(fullTarget, options.archiveDir, basename(targetDir));
78
- await pruneArchives(options.archiveDir, basename(targetDir), options.archiveKeep ?? DEFAULT_ARCHIVE_KEEP);
79
- }
80
- for (const relPath of toDelete) {
81
- await fs.unlink(join(outputDir, relPath));
82
- result.deleted.push(relPath);
83
- }
84
- await removeEmptyDirs(fullTarget);
85
- return result;
86
- }
87
- async function archiveDirectory(srcDir, archiveBase, prefix) {
88
- const stamp = new Date().toISOString().replace(/[:.]/g, '-').replace(/Z$/, '');
89
- const dest = join(archiveBase, `${prefix}-${stamp}`);
90
- await fs.mkdir(archiveBase, { recursive: true });
91
- // fs.cp with recursive copies the tree, preserves dir structure, no deps.
92
- await fs.cp(srcDir, dest, { recursive: true, force: true });
93
- return dest;
94
- }
95
- async function pruneArchives(archiveBase, prefix, keep) {
96
- if (!(await pathExists(archiveBase)))
97
- return;
98
- const entries = await fs.readdir(archiveBase);
99
- const stamped = entries.filter((e) => e.startsWith(`${prefix}-`)).sort().reverse();
100
- const stale = stamped.slice(keep);
101
- for (const old of stale) {
102
- await fs.rm(join(archiveBase, old), { recursive: true, force: true }).catch(() => { });
103
- }
104
- }
105
- async function pathExists(p) {
106
- try {
107
- await fs.access(p);
108
- return true;
109
- }
110
- catch {
111
- return false;
112
- }
113
- }
114
- async function collectFiles(dir, outputDir, into) {
115
- let entries;
116
- try {
117
- entries = await fs.readdir(dir, { withFileTypes: true });
118
- }
119
- catch {
120
- return;
121
- }
122
- for (const entry of entries) {
123
- const full = join(dir, entry.name);
124
- if (entry.isDirectory()) {
125
- await collectFiles(full, outputDir, into);
126
- }
127
- else if (entry.isFile()) {
128
- into.push(normalizePath(relative(outputDir, full)));
129
- }
130
- }
131
- }
132
- async function fileHasMarker(path, marker) {
133
- let handle = null;
134
- try {
135
- handle = await fs.open(path, 'r');
136
- const buf = Buffer.alloc(HEADER_PROBE_BYTES);
137
- const { bytesRead } = await handle.read(buf, 0, HEADER_PROBE_BYTES, 0);
138
- return buf.subarray(0, bytesRead).toString('utf8').includes(marker);
139
- }
140
- catch {
141
- return false;
142
- }
143
- finally {
144
- if (handle)
145
- await handle.close();
146
- }
147
- }
148
- async function removeEmptyDirs(dir) {
149
- let entries;
150
- try {
151
- entries = await fs.readdir(dir, { withFileTypes: true });
152
- }
153
- catch {
154
- return;
155
- }
156
- for (const entry of entries) {
157
- if (entry.isDirectory()) {
158
- await removeEmptyDirs(join(dir, entry.name));
159
- }
160
- }
161
- try {
162
- const after = await fs.readdir(dir);
163
- if (after.length === 0) {
164
- await fs.rmdir(dir).catch(() => { });
165
- }
166
- }
167
- catch {
168
- /* ignore */
169
- }
170
- }
171
- function normalizePath(p) {
172
- return sep === '/' ? p : p.split(sep).join('/');
173
- }
174
- function basename(p) {
175
- const norm = normalizePath(p).replace(/\/+$/, '');
176
- const idx = norm.lastIndexOf('/');
177
- return idx >= 0 ? norm.slice(idx + 1) : norm;
178
- }
179
- //# sourceMappingURL=sweep-stale.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sweep-stale.js","sourceRoot":"","sources":["../../src/lib/sweep-stale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE3C,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AACtD,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,WAAW;IACX,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AAuBH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,SAAiB,EACjB,SAAiB,EACjB,QAA0B,EAC1B,UAAwB,EAAE;IAE1B,MAAM,MAAM,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE9C,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IAEnD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC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T,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sweep-stale.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sweep-stale.test.d.ts","sourceRoot":"","sources":["../../src/lib/sweep-stale.test.ts"],"names":[],"mappings":""}