@leadcms/sdk 3.0.2 → 3.2.0

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 (88) hide show
  1. package/README.md +89 -47
  2. package/dist/cli/bin/generate-env.js +0 -0
  3. package/dist/cli/bin/init.js +0 -0
  4. package/dist/cli/bin/login.js +0 -0
  5. package/dist/cli/bin/pull-all.js +17 -1
  6. package/dist/cli/bin/pull-all.js.map +1 -1
  7. package/dist/cli/bin/pull-comments.js +0 -0
  8. package/dist/cli/bin/pull-content.js +13 -1
  9. package/dist/cli/bin/pull-content.js.map +1 -1
  10. package/dist/cli/bin/pull-media.js +0 -0
  11. package/dist/cli/bin/push-all.d.ts +7 -0
  12. package/dist/cli/bin/push-all.d.ts.map +1 -0
  13. package/dist/cli/bin/push-all.js +59 -0
  14. package/dist/cli/bin/push-all.js.map +1 -0
  15. package/dist/cli/bin/push-content.d.ts +6 -0
  16. package/dist/cli/bin/push-content.d.ts.map +1 -0
  17. package/dist/cli/bin/push-content.js +27 -0
  18. package/dist/cli/bin/push-content.js.map +1 -0
  19. package/dist/cli/bin/push-media.d.ts +6 -0
  20. package/dist/cli/bin/push-media.d.ts.map +1 -0
  21. package/dist/cli/bin/push-media.js +21 -0
  22. package/dist/cli/bin/push-media.js.map +1 -0
  23. package/dist/cli/bin/push.js +0 -0
  24. package/dist/cli/bin/status-all.d.ts +7 -0
  25. package/dist/cli/bin/status-all.d.ts.map +1 -0
  26. package/dist/cli/bin/status-all.js +56 -0
  27. package/dist/cli/bin/status-all.js.map +1 -0
  28. package/dist/cli/bin/status-content.d.ts +6 -0
  29. package/dist/cli/bin/status-content.d.ts.map +1 -0
  30. package/dist/cli/bin/status-content.js +30 -0
  31. package/dist/cli/bin/status-content.js.map +1 -0
  32. package/dist/cli/bin/status-media.d.ts +6 -0
  33. package/dist/cli/bin/status-media.d.ts.map +1 -0
  34. package/dist/cli/bin/status-media.js +20 -0
  35. package/dist/cli/bin/status-media.js.map +1 -0
  36. package/dist/cli/bin/status.js +0 -0
  37. package/dist/cli/bin/watch.js +0 -0
  38. package/dist/cli/index.js +39 -8
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/lib/cms.d.ts.map +1 -1
  41. package/dist/lib/cms.js +0 -38
  42. package/dist/lib/cms.js.map +1 -1
  43. package/dist/lib/content-transformation.d.ts +0 -10
  44. package/dist/lib/content-transformation.d.ts.map +1 -1
  45. package/dist/lib/content-transformation.js +18 -32
  46. package/dist/lib/content-transformation.js.map +1 -1
  47. package/dist/lib/data-service.d.ts +42 -0
  48. package/dist/lib/data-service.d.ts.map +1 -1
  49. package/dist/lib/data-service.js +316 -6
  50. package/dist/lib/data-service.js.map +1 -1
  51. package/dist/scripts/fetch-leadcms-comments.d.ts +6 -1
  52. package/dist/scripts/fetch-leadcms-comments.d.ts.map +1 -1
  53. package/dist/scripts/fetch-leadcms-comments.js +36 -8
  54. package/dist/scripts/fetch-leadcms-comments.js.map +1 -1
  55. package/dist/scripts/fetch-leadcms-content.d.ts +37 -1
  56. package/dist/scripts/fetch-leadcms-content.d.ts.map +1 -1
  57. package/dist/scripts/fetch-leadcms-content.js +239 -58
  58. package/dist/scripts/fetch-leadcms-content.js.map +1 -1
  59. package/dist/scripts/generate-env-js.d.ts +8 -1
  60. package/dist/scripts/generate-env-js.d.ts.map +1 -1
  61. package/dist/scripts/generate-env-js.js +26 -10
  62. package/dist/scripts/generate-env-js.js.map +1 -1
  63. package/dist/scripts/init-leadcms.d.ts +5 -1
  64. package/dist/scripts/init-leadcms.d.ts.map +1 -1
  65. package/dist/scripts/init-leadcms.js +11 -6
  66. package/dist/scripts/init-leadcms.js.map +1 -1
  67. package/dist/scripts/leadcms-helpers.d.ts +1 -6
  68. package/dist/scripts/leadcms-helpers.d.ts.map +1 -1
  69. package/dist/scripts/leadcms-helpers.js.map +1 -1
  70. package/dist/scripts/pull-all.d.ts +13 -1
  71. package/dist/scripts/pull-all.d.ts.map +1 -1
  72. package/dist/scripts/pull-all.js +66 -2
  73. package/dist/scripts/pull-all.js.map +1 -1
  74. package/dist/scripts/pull-content.d.ts +5 -1
  75. package/dist/scripts/pull-content.d.ts.map +1 -1
  76. package/dist/scripts/pull-content.js +48 -1
  77. package/dist/scripts/pull-content.js.map +1 -1
  78. package/dist/scripts/push-leadcms-content.d.ts +43 -0
  79. package/dist/scripts/push-leadcms-content.d.ts.map +1 -1
  80. package/dist/scripts/push-leadcms-content.js +115 -19
  81. package/dist/scripts/push-leadcms-content.js.map +1 -1
  82. package/dist/scripts/push-media.d.ts +136 -0
  83. package/dist/scripts/push-media.d.ts.map +1 -0
  84. package/dist/scripts/push-media.js +531 -0
  85. package/dist/scripts/push-media.js.map +1 -0
  86. package/dist/scripts/sse-watcher.d.ts.map +1 -1
  87. package/dist/scripts/sse-watcher.js.map +1 -1
  88. package/package.json +2 -2
package/README.md CHANGED
@@ -5,6 +5,7 @@ A comprehensive, framework-agnostic SDK and CLI tools for integrating with LeadC
5
5
  ## Installation
6
6
 
7
7
  ### For Build-Time Usage (Most Common)
8
+
8
9
  If you only use LeadCMS SDK during the build process (static site generation):
9
10
 
10
11
  ```bash
@@ -12,6 +13,7 @@ npm install --save-dev @leadcms/sdk
12
13
  ```
13
14
 
14
15
  ### For Runtime Usage
16
+
15
17
  If you need LeadCMS SDK in your production application (SSR, API routes, live preview):
16
18
 
17
19
  ```bash
@@ -19,6 +21,7 @@ npm install @leadcms/sdk
19
21
  ```
20
22
 
21
23
  ### Global CLI Installation
24
+
22
25
  For CLI tools and project setup:
23
26
 
24
27
  ```bash
@@ -28,18 +31,21 @@ npm install -g @leadcms/sdk
28
31
  ### When to Use Each Installation Method
29
32
 
30
33
  **Development Dependency (`--save-dev`)** - Recommended for:
34
+
31
35
  - āœ… Static Site Generators (Next.js, Astro, Gatsby, Nuxt)
32
36
  - āœ… Build-time content fetching and processing
33
37
  - āœ… Static route generation
34
38
  - āœ… Content pre-processing during build
35
39
 
36
40
  **Production Dependency (`--save`)** - Use when you need:
41
+
37
42
  - šŸ”„ Server-Side Rendering (SSR) with dynamic content
38
43
  - šŸ”„ API routes that fetch LeadCMS content at runtime
39
44
  - šŸ”„ Live preview functionality in production
40
45
  - šŸ”„ Runtime content loading and processing
41
46
 
42
47
  **Global Installation (`-g`)** - Best for:
48
+
43
49
  - šŸ› ļø CLI commands across multiple projects
44
50
  - šŸ› ļø Project initialization and setup
45
51
  - šŸ› ļø Content fetching and Docker template generation
@@ -49,18 +55,23 @@ npm install -g @leadcms/sdk
49
55
  Get started with LeadCMS in 3 simple steps:
50
56
 
51
57
  ### 1. Initialize Your Project
58
+
52
59
  ```bash
53
60
  npx leadcms init
54
61
  ```
62
+
55
63
  This will:
64
+
56
65
  - Connect to your LeadCMS instance
57
66
  - Detect available entity types (content, media, comments)
58
67
  - Create configuration files (`.env` and optionally `leadcms.config.json`)
59
68
 
60
69
  ### 2. Authenticate (for write access)
70
+
61
71
  ```bash
62
72
  npx leadcms login
63
73
  ```
74
+
64
75
  - **LeadCMS v1.2.88+**: Automatic device authentication via browser
65
76
  - **Older versions**: Guided manual token extraction
66
77
  - Saves your API token securely to `.env`
@@ -68,9 +79,11 @@ npx leadcms login
68
79
  **Skip this step** if you only need read-only access to public content.
69
80
 
70
81
  ### 3. Download Your Content
82
+
71
83
  ```bash
72
84
  npx leadcms pull
73
85
  ```
86
+
74
87
  Downloads all content, media, and comments to your local project.
75
88
 
76
89
  **That's it!** You're ready to use LeadCMS content in your application. See [Usage Examples](#usage-examples) below.
@@ -82,18 +95,21 @@ Downloads all content, media, and comments to your local project.
82
95
  The LeadCMS SDK includes comprehensive CI/CD workflows for GitHub Actions that provide:
83
96
 
84
97
  ### 🧪 Automated Testing
98
+
85
99
  - **Multi-Node Support**: Tests run on Node.js 18, 20, and 22
86
100
  - **Coverage Reports**: Automatic coverage reporting with visual coverage diffs on PRs
87
101
  - **Test Results**: Interactive test results displayed directly in GitHub Actions
88
102
  - **JUnit XML**: Structured test output for integration with external tools
89
103
 
90
104
  ### šŸ“Š Coverage Reporting
105
+
91
106
  - **LCOV Reports**: Line and branch coverage tracking
92
107
  - **PR Comments**: Automatic coverage comments on pull requests showing coverage changes
93
108
  - **Coverage Artifacts**: HTML coverage reports archived for 30 days
94
109
  - **Multiple Formats**: Coverage available in LCOV, HTML, and Clover formats
95
110
 
96
111
  ### šŸ”§ Quality Checks
112
+
97
113
  - **TypeScript Compilation**: Ensures type safety across all Node.js versions
98
114
  - **Package Validation**: Verifies package structure and CLI functionality
99
115
  - **Docker Template Testing**: Validates generated Docker configurations
@@ -115,8 +131,8 @@ jobs:
115
131
  - uses: actions/checkout@v4
116
132
  - uses: actions/setup-node@v4
117
133
  with:
118
- node-version: '20'
119
- cache: 'npm'
134
+ node-version: "20"
135
+ cache: "npm"
120
136
  - run: npm ci
121
137
  - run: npm test
122
138
  ```
@@ -137,6 +153,7 @@ npm run test:watch
137
153
  ### Test Coverage
138
154
 
139
155
  The SDK maintains high test coverage with comprehensive unit tests covering:
156
+
140
157
  - šŸ“„ Content retrieval and parsing
141
158
  - šŸŒ Multi-language support and translations
142
159
  - šŸ“ Draft content handling and user-specific overrides
@@ -159,6 +176,7 @@ LEADCMS_USE_MOCK=true LEADCMS_MOCK_SCENARIO=mixedOperations npx leadcms push --d
159
176
  ```
160
177
 
161
178
  **Available Mock Scenarios:**
179
+
162
180
  - `allNew` - Local content that doesn't exist remotely (default)
163
181
  - `noChanges` - All content is in sync
164
182
  - `hasConflicts` - Remote content is newer than local
@@ -167,6 +185,7 @@ LEADCMS_USE_MOCK=true LEADCMS_MOCK_SCENARIO=mixedOperations npx leadcms push --d
167
185
  - `missingContentTypes` - Content with unknown types
168
186
 
169
187
  **Mock Mode Activation:**
188
+
170
189
  - `NODE_ENV=test` - Automatically uses mock mode
171
190
  - `LEADCMS_USE_MOCK=true` - Force mock mode
172
191
 
@@ -228,15 +247,15 @@ npx leadcms init
228
247
  For advanced use cases, you can configure the SDK programmatically:
229
248
 
230
249
  ```typescript
231
- import { configure } from '@leadcms/sdk';
250
+ import { configure } from "@leadcms/sdk";
232
251
 
233
252
  configure({
234
- url: 'https://your-leadcms-instance.com',
235
- apiKey: 'your-api-key',
236
- defaultLanguage: 'en',
237
- contentDir: '.leadcms/content',
238
- mediaDir: 'public/media',
239
- enableDrafts: false
253
+ url: "https://your-leadcms-instance.com",
254
+ apiKey: "your-api-key",
255
+ defaultLanguage: "en",
256
+ contentDir: ".leadcms/content",
257
+ mediaDir: "public/media",
258
+ enableDrafts: false,
240
259
  });
241
260
  ```
242
261
 
@@ -254,6 +273,7 @@ configure({
254
273
  ## CLI Usage
255
274
 
256
275
  ### Check SDK version
276
+
257
277
  ```bash
258
278
  npx leadcms version
259
279
  # or
@@ -263,11 +283,13 @@ npx leadcms --version
263
283
  ```
264
284
 
265
285
  ### Initialize configuration
286
+
266
287
  ```bash
267
288
  npx leadcms init
268
289
  ```
269
290
 
270
291
  Interactive setup wizard that:
292
+
271
293
  1. **Connects to your LeadCMS instance** - Validates URL and checks for existing authentication
272
294
  2. **Fetches configuration** - Retrieves default language and available languages from public `/api/config` endpoint
273
295
  3. **Configures directories** - Sets content and media directories (defaults: `.leadcms/content`, `public/media`)
@@ -277,16 +299,19 @@ Interactive setup wizard that:
277
299
  **Note:** The `/api/config` endpoint is public and works without authentication. For write operations and private content, run `leadcms login` after initialization.
278
300
 
279
301
  ### Login to LeadCMS
302
+
280
303
  ```bash
281
304
  npx leadcms login
282
305
  ```
283
306
 
284
307
  Authenticates with your LeadCMS instance:
308
+
285
309
  - **Device Authentication** (LeadCMS v1.2.88+) - Opens a browser link for secure authentication
286
310
  - **Manual Token** (older versions) - Guides you through extracting an API token
287
311
  - **Saves token** - Automatically stores the token in your `.env` file
288
312
 
289
313
  **When to use:**
314
+
290
315
  - After running `leadcms init` if you need write access
291
316
  - To update an expired or invalid token
292
317
  - When switching between LeadCMS instances
@@ -315,7 +340,7 @@ Would you like to authenticate now? (Y/n): n
315
340
  1. English (United States) [en-US] (default)
316
341
  2. Russian (Russia) [ru-RU]
317
342
 
318
- Default language code [en-US]:
343
+ Default language code [en-US]:
319
344
  āœ“ Using default language: en-US
320
345
 
321
346
  šŸ“¦ Supported entity types:
@@ -341,12 +366,14 @@ Next steps:
341
366
  ```
342
367
 
343
368
  The wizard creates:
369
+
344
370
  - **`.env`** (or `.env` if exists) with `LEADCMS_URL`, `LEADCMS_DEFAULT_LANGUAGE`, and optionally `LEADCMS_API_KEY`
345
371
  - **`leadcms.config.json`** only if custom directories are specified
346
372
 
347
373
  **Anonymous Mode:** Perfect for static sites that only need public content. Omit the API key to skip authentication entirely.
348
374
 
349
375
  ### Generate Docker deployment templates
376
+
350
377
  ```bash
351
378
  npx leadcms docker
352
379
  # Creates Docker files for production and preview deployments
@@ -373,6 +400,7 @@ npx leadcms pull-comments
373
400
  > **Note:** `npx leadcms fetch` is still supported as an alias for backward compatibility.
374
401
 
375
402
  What each command does:
403
+
376
404
  - `npx leadcms pull` - Syncs content, media and comments into your project using the configured directories. Updates incremental sync tokens so subsequent runs are faster.
377
405
  - `npx leadcms pull-content` - Downloads only content entities (MDX/JSON files) and updates local metadata.
378
406
  - `npx leadcms pull-media` - Downloads media files to your `mediaDir` (e.g., `public/media`). Use this when you changed media or want to refresh assets separately from content.
@@ -381,11 +409,13 @@ What each command does:
381
409
  > **Note:** The CLI uses incremental sync tokens to avoid re-downloading unchanged items where supported by the LeadCMS API.
382
410
 
383
411
  ### Push local content to LeadCMS
412
+
384
413
  ```bash
385
414
  npx leadcms push [options]
386
415
  ```
387
416
 
388
417
  Push your local content changes to LeadCMS. This command will:
418
+
389
419
  - Analyze local MDX/JSON files and compare with remote content
390
420
  - Detect new content, updates, and conflicts using `updatedAt` timestamps
391
421
  - Prompt for confirmation before making changes
@@ -393,26 +423,29 @@ Push your local content changes to LeadCMS. This command will:
393
423
  - Update local files with remote metadata (id, createdAt, updatedAt) after sync
394
424
 
395
425
  **Options:**
396
- - `--force` - Override remote changes (skip conflict check)
397
426
 
427
+ - `--force` - Override remote changes (skip conflict check)
398
428
 
399
429
  **Content frontmatter / metadata (required and optional fields):**
430
+
400
431
  ```yaml
401
432
  ---
402
- type: "article" # required: Content type (must exist in LeadCMS)
403
- title: "Article Title" # required: Content title
404
- slug: "article-slug" # required: URL slug (unique per locale)
405
- language: "en" # required: Content language
433
+ type: "article" # required: Content type (must exist in LeadCMS)
434
+ title: "Article Title" # required: Content title
435
+ slug: "article-slug" # required: URL slug (unique per locale)
436
+ language: "en" # required: Content language
406
437
  publishedAt: "2024-10-29T10:00:00Z" # optional: Publication date (omit to create a draft or schedule a future publish)
407
438
  # updatedAt: "2024-10-29T10:00:00Z" # optional: maintained by the server; do not set for new content
408
439
  ---
409
440
  ```
410
441
 
411
442
  Notes:
443
+
412
444
  - `publishedAt` is optional. Omitting it is a valid way to create draft or scheduled content depending on your LeadCMS workflow.
413
445
  - `updatedAt` is typically set and maintained by the LeadCMS server after content is created or updated. The SDK will use `updatedAt` when present for conflict detection, but you should not rely on it being set for brand-new local files.
414
446
 
415
447
  ### Check sync status
448
+
416
449
  ```bash
417
450
  npx leadcms status
418
451
  ```
@@ -422,6 +455,7 @@ Shows the current sync status between local and remote **content** without makin
422
455
  **Note:** The `status` command currently only supports content. Media and comments do not have sync status checking yet.
423
456
 
424
457
  ### Watch for real-time updates
458
+
425
459
  ```bash
426
460
  npx leadcms watch
427
461
  ```
@@ -435,9 +469,9 @@ The SDK provides framework-agnostic data access. Most frameworks use it as a **d
435
469
  export function generateStaticParams() {
436
470
  // This runs at BUILD TIME, not runtime
437
471
  const routes = getAllContentRoutes();
438
- return routes.map(route => ({
472
+ return routes.map((route) => ({
439
473
  slug: route.slugParts,
440
- ...(route.isDefaultLocale ? {} : { locale: route.locale })
474
+ ...(route.isDefaultLocale ? {} : { locale: route.locale }),
441
475
  }));
442
476
  }
443
477
 
@@ -445,9 +479,9 @@ export function generateStaticParams() {
445
479
  export function getStaticPaths() {
446
480
  // This runs at BUILD TIME, not runtime
447
481
  const routes = getAllContentRoutes();
448
- return routes.map(route => ({
482
+ return routes.map((route) => ({
449
483
  params: { slug: route.slug },
450
- props: { locale: route.locale, path: route.path }
484
+ props: { locale: route.locale, path: route.path },
451
485
  }));
452
486
  }
453
487
 
@@ -456,11 +490,11 @@ exports.createPages = async ({ actions }) => {
456
490
  const { createPage } = actions;
457
491
  const routes = getAllContentRoutes();
458
492
 
459
- routes.forEach(route => {
493
+ routes.forEach((route) => {
460
494
  createPage({
461
495
  path: route.path,
462
- component: path.resolve('./src/templates/content.js'),
463
- context: { slug: route.slug, locale: route.locale }
496
+ component: path.resolve("./src/templates/content.js"),
497
+ context: { slug: route.slug, locale: route.locale },
464
498
  });
465
499
  });
466
500
  };
@@ -468,18 +502,18 @@ exports.createPages = async ({ actions }) => {
468
502
  // Runtime Usage Examples (Production dependency required)
469
503
 
470
504
  // Next.js API Route (Runtime)
471
- import { getCMSContentBySlugForLocale } from '@leadcms/sdk';
505
+ import { getCMSContentBySlugForLocale } from "@leadcms/sdk";
472
506
 
473
507
  export async function GET(request) {
474
508
  // This runs at REQUEST TIME, needs production dependency
475
- const content = getCMSContentBySlugForLocale('about', 'en');
509
+ const content = getCMSContentBySlugForLocale("about", "en");
476
510
  return Response.json(content);
477
511
  }
478
512
 
479
513
  // Express.js Server (Runtime)
480
- app.get('/api/content/:slug', (req, res) => {
514
+ app.get("/api/content/:slug", (req, res) => {
481
515
  // This runs at REQUEST TIME, needs production dependency
482
- const content = getCMSContentBySlugForLocale(req.params.slug, 'en');
516
+ const content = getCMSContentBySlugForLocale(req.params.slug, "en");
483
517
  res.json(content);
484
518
  });
485
519
  ```
@@ -491,17 +525,17 @@ app.get('/api/content/:slug', (req, res) => {
491
525
  Get content from your LeadCMS instance:
492
526
 
493
527
  ```typescript
494
- import {
528
+ import {
495
529
  getCMSContentBySlugForLocale,
496
530
  getAllContentSlugsForLocale,
497
- getAllContentRoutes
498
- } from '@leadcms/sdk';
531
+ getAllContentRoutes,
532
+ } from "@leadcms/sdk";
499
533
 
500
534
  // Get single content item
501
- const content = getCMSContentBySlugForLocale('about-us', 'en');
535
+ const content = getCMSContentBySlugForLocale("about-us", "en");
502
536
 
503
537
  // Get all content slugs
504
- const slugs = getAllContentSlugsForLocale('en');
538
+ const slugs = getAllContentSlugsForLocale("en");
505
539
 
506
540
  // Get all routes for static generation
507
541
  const routes = getAllContentRoutes();
@@ -514,21 +548,22 @@ const routes = getAllContentRoutes();
514
548
  The SDK automatically detects preview slugs and enables draft content access without requiring explicit configuration:
515
549
 
516
550
  ```typescript
517
- import { getCMSContentBySlugForLocale } from '@leadcms/sdk';
551
+ import { getCMSContentBySlugForLocale } from "@leadcms/sdk";
518
552
 
519
553
  // Normal slug - only returns published content
520
- const published = getCMSContentBySlugForLocale('home', 'en');
554
+ const published = getCMSContentBySlugForLocale("home", "en");
521
555
  // Returns: null if content has no publishedAt
522
556
 
523
557
  // Preview slug with GUID - automatically enables draft access
524
558
  const preview = getCMSContentBySlugForLocale(
525
- 'home-550e8400-e29b-41d4-a716-446655440000',
526
- 'en'
559
+ "home-550e8400-e29b-41d4-a716-446655440000",
560
+ "en",
527
561
  );
528
562
  // Returns: draft content even without publishedAt
529
563
  ```
530
564
 
531
565
  **How it works:**
566
+
532
567
  - When a slug contains a GUID pattern (e.g., `home-{userUid}`), the SDK automatically:
533
568
  1. Detects the GUID suffix
534
569
  2. Extracts the base slug and userUid
@@ -536,6 +571,7 @@ const preview = getCMSContentBySlugForLocale(
536
571
  4. Returns user's draft version or falls back to base content
537
572
 
538
573
  **Benefits:**
574
+
539
575
  - āœ… Zero configuration - works automatically with LeadCMS preview URLs
540
576
  - šŸ”’ Secure - only preview slugs (with valid GUID) can access drafts
541
577
  - šŸ”„ Backward compatible - normal slugs continue to require `publishedAt`
@@ -570,18 +606,15 @@ npx leadcms pull-comments
570
606
  ```
571
607
 
572
608
  ```typescript
573
- import {
574
- getCommentsForContent,
575
- getCommentsTreeForContent
576
- } from '@leadcms/sdk';
609
+ import { getCommentsForContent, getCommentsTreeForContent } from "@leadcms/sdk";
577
610
 
578
611
  // Get flat list of comments
579
612
  const comments = getCommentsForContent(contentId);
580
613
 
581
614
  // Get comments as tree for threading
582
615
  const tree = getCommentsTreeForContent(contentId, undefined, {
583
- sortOrder: 'newest',
584
- replySortOrder: 'oldest'
616
+ sortOrder: "newest",
617
+ replySortOrder: "oldest",
585
618
  });
586
619
  ```
587
620
 
@@ -598,6 +631,7 @@ npx leadcms docker
598
631
  ```
599
632
 
600
633
  This creates:
634
+
601
635
  - `Dockerfile` - Production static site deployment
602
636
  - `nginx.conf` - Optimized nginx configuration
603
637
  - `scripts/inject-runtime-env.sh` - Runtime environment injection
@@ -650,6 +684,7 @@ docker run -p 80:80 \
650
684
  ## Debugging
651
685
 
652
686
  ### Debug Logging
687
+
653
688
  Control SDK logging verbosity with environment variables:
654
689
 
655
690
  ```bash
@@ -663,32 +698,35 @@ NODE_ENV=production npm run build
663
698
  Debug mode is automatically enabled when `NODE_ENV=development` or `LEADCMS_DEBUG=true`.
664
699
 
665
700
  ### Error Handling
701
+
666
702
  The SDK provides detailed error information for missing configuration files:
667
703
 
668
704
  ```typescript
669
- import { loadContentConfig, loadContentConfigStrict } from '@leadcms/sdk';
705
+ import { loadContentConfig, loadContentConfigStrict } from "@leadcms/sdk";
670
706
 
671
707
  // Graceful handling - returns null for missing files
672
- const config = loadContentConfig('layout'); // Returns null if missing
708
+ const config = loadContentConfig("layout"); // Returns null if missing
673
709
 
674
710
  // Strict handling - throws detailed errors for debugging
675
711
  try {
676
- const config = loadContentConfigStrict('layout');
712
+ const config = loadContentConfigStrict("layout");
677
713
  } catch (error) {
678
- console.log('Missing configuration:', error.configName);
679
- console.log('Expected locale:', error.locale);
680
- console.log('Full error:', error.message);
714
+ console.log("Missing configuration:", error.configName);
715
+ console.log("Expected locale:", error.locale);
716
+ console.log("Full error:", error.message);
681
717
  // Error message includes: configName, locale, and expected file path
682
718
  }
683
719
  ```
684
720
 
685
721
  **Error Details Include:**
722
+
686
723
  - `configName` - The specific configuration name that was requested
687
724
  - `locale` - The locale that was being loaded
688
725
  - `message` - Full descriptive error including expected file path
689
726
  - Clear console logging of missing files with exact paths
690
727
 
691
728
  ### Performance Tips
729
+
692
730
  - āœ… Use configuration files instead of programmatic configuration for better caching
693
731
  - āœ… The SDK caches file reads automatically - no manual optimization needed
694
732
  - āœ… In production builds, logging is minimal to reduce noise
@@ -702,18 +740,22 @@ try {
702
740
  - **[Documentation Index](./docs/README)** - Central hub for all documentation
703
741
 
704
742
  #### Content & Media
743
+
705
744
  - **[Content Management](./docs/CONTENT_MANAGEMENT.md)** - Retrieving, organizing, and working with content
706
745
  - **[Media Management](./docs/MEDIA_MANAGEMENT.md)** - Handling media files and optimization
707
746
  - **[Draft Handling](./docs/DRAFT_HANDLING.md)** - Working with draft content and user-specific drafts
708
747
 
709
748
  #### Comments
749
+
710
750
  - **[Comment Tree Guide](./docs/COMMENT_TREE.md)** - Building threaded comment interfaces with sorting and filtering
711
751
 
712
752
  #### Setup & Configuration
753
+
713
754
  - **[Interactive Init](./docs/INTERACTIVE_INIT.md)** - Setup wizard and authentication
714
755
  - **[Public API Mode](./docs/PUBLIC_API_MODE.md)** - Security-first approach and operation modes
715
756
 
716
757
  #### Development
758
+
717
759
  - **[Development Guide](./docs/DEVELOPMENT.md)** - Local development, testing, and debugging
718
760
  - **[GitHub Actions](./docs/GITHUB_ACTIONS.md)** - CI/CD setup and automated publishing
719
761
 
File without changes
File without changes
File without changes
@@ -3,7 +3,23 @@
3
3
  * LeadCMS Pull All CLI Entry Point
4
4
  */
5
5
  import { pullAll } from '../../scripts/pull-all.js';
6
- pullAll().catch((error) => {
6
+ const args = process.argv.slice(2);
7
+ // Parse target ID or slug
8
+ let targetId;
9
+ let targetSlug;
10
+ let reset = false;
11
+ const idIndex = args.findIndex(arg => arg === '--id');
12
+ if (idIndex !== -1 && args[idIndex + 1]) {
13
+ targetId = args[idIndex + 1];
14
+ }
15
+ const slugIndex = args.findIndex(arg => arg === '--slug');
16
+ if (slugIndex !== -1 && args[slugIndex + 1]) {
17
+ targetSlug = args[slugIndex + 1];
18
+ }
19
+ if (args.includes('--reset')) {
20
+ reset = true;
21
+ }
22
+ pullAll({ targetId, targetSlug, reset }).catch((error) => {
7
23
  console.error('Error running LeadCMS pull:', error.message);
8
24
  process.exit(1);
9
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"pull-all.js","sourceRoot":"","sources":["../../../src/cli/bin/pull-all.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;IAC7B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"pull-all.js","sourceRoot":"","sources":["../../../src/cli/bin/pull-all.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,0BAA0B;AAC1B,IAAI,QAA4B,CAAC;AACjC,IAAI,UAA8B,CAAC;AACnC,IAAI,KAAK,GAAG,KAAK,CAAC;AAElB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;AACtD,IAAI,OAAO,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;IACxC,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC;AAC1D,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5C,UAAU,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;IAC7B,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED,OAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAU,EAAE,EAAE;IAC5D,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
File without changes
@@ -3,7 +3,19 @@
3
3
  * LeadCMS Pull Content CLI Entry Point
4
4
  */
5
5
  import { pullContent } from '../../scripts/pull-content.js';
6
- pullContent().catch((error) => {
6
+ const args = process.argv.slice(2);
7
+ // Parse target ID or slug
8
+ let targetId;
9
+ let targetSlug;
10
+ const idIndex = args.findIndex(arg => arg === '--id');
11
+ if (idIndex !== -1 && args[idIndex + 1]) {
12
+ targetId = args[idIndex + 1];
13
+ }
14
+ const slugIndex = args.findIndex(arg => arg === '--slug');
15
+ if (slugIndex !== -1 && args[slugIndex + 1]) {
16
+ targetSlug = args[slugIndex + 1];
17
+ }
18
+ pullContent({ targetId, targetSlug }).catch((error) => {
7
19
  console.error('Error running LeadCMS pull content:', error.message);
8
20
  process.exit(1);
9
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"pull-content.js","sourceRoot":"","sources":["../../../src/cli/bin/pull-content.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC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C"}
File without changes
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * LeadCMS Push All CLI Entry Point
4
+ * Pushes both content and media
5
+ */
6
+ import 'dotenv/config';
7
+ //# sourceMappingURL=push-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-all.d.ts","sourceRoot":"","sources":["../../../src/cli/bin/push-all.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,eAAe,CAAC"}
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * LeadCMS Push All CLI Entry Point
4
+ * Pushes both content and media
5
+ */
6
+ import 'dotenv/config';
7
+ import { pushLeadCMSContent } from '../../scripts/push-leadcms-content.js';
8
+ import { pushMedia } from '../../scripts/push-media.js';
9
+ const args = process.argv.slice(2);
10
+ // Parse common flags
11
+ const force = args.includes('--force') || args.includes('-f');
12
+ const dryRun = args.includes('--dry-run') || args.includes('-d');
13
+ const allowDelete = args.includes('--delete');
14
+ // Parse content-specific flags
15
+ let targetId;
16
+ let targetSlug;
17
+ const idIndex = args.findIndex(arg => arg === '--id');
18
+ if (idIndex !== -1 && args[idIndex + 1]) {
19
+ targetId = args[idIndex + 1];
20
+ }
21
+ const slugIndex = args.findIndex(arg => arg === '--slug');
22
+ if (slugIndex !== -1 && args[slugIndex + 1]) {
23
+ targetSlug = args[slugIndex + 1];
24
+ }
25
+ // Parse media-specific flags
26
+ let scopeUid;
27
+ const scopeIndex = args.findIndex(arg => arg === '--scope' || arg === '-s');
28
+ if (scopeIndex !== -1 && args[scopeIndex + 1]) {
29
+ scopeUid = args[scopeIndex + 1];
30
+ }
31
+ async function pushAll() {
32
+ try {
33
+ console.log('šŸš€ Starting push operation...\n');
34
+ // Push content first
35
+ console.log('šŸ“ Pushing content...');
36
+ await pushLeadCMSContent({
37
+ statusOnly: false,
38
+ force,
39
+ targetId,
40
+ targetSlug,
41
+ dryRun,
42
+ allowDelete
43
+ });
44
+ console.log('\nšŸ“· Pushing media...');
45
+ await pushMedia({
46
+ dryRun,
47
+ force,
48
+ scopeUid,
49
+ allowDelete
50
+ });
51
+ console.log('\nāœ… Push operation completed successfully!');
52
+ }
53
+ catch (error) {
54
+ console.error('\nāŒ Push operation failed:', error.message);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ pushAll();
59
+ //# sourceMappingURL=push-all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-all.js","sourceRoot":"","sources":["../../../src/cli/bin/push-all.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,qBAAqB;AACrB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAE9C,+BAA+B;AAC/B,IAAI,QAA4B,CAAC;AACjC,IAAI,UAA8B,CAAC;AAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;AACtD,IAAI,OAAO,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;IACxC,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,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C"}
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * LeadCMS Push Content CLI Entry Point
4
+ */
5
+ import 'dotenv/config';
6
+ //# sourceMappingURL=push-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-content.d.ts","sourceRoot":"","sources":["../../../src/cli/bin/push-content.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,eAAe,CAAC"}