@djangocfg/ext-base 1.0.1 → 1.0.3

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.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
+ <div align="center">
2
+
3
+ ![DjangoCFG Extension Preview](https://unpkg.com/@djangocfg/ext-base@latest/preview.png)
4
+
5
+ **[📦 View in Marketplace](https://hub.djangocfg.com/extensions/djangocfg-ext-base)** • **[📖 Documentation](https://djangocfg.com)** • **[⭐ GitHub](https://github.com/markolofsen/django-cfg)**
6
+
7
+ </div>
8
+
1
9
  # @djangocfg/ext-base
2
10
 
3
11
  Base utilities and common code for building DjangoCFG extensions.
@@ -25,50 +33,67 @@ pnpm add @djangocfg/ext-base
25
33
 
26
34
  ## CLI Usage
27
35
 
28
- The package includes a CLI tool for managing DjangoCFG extensions:
36
+ The package includes a CLI tool for creating new DjangoCFG extensions:
29
37
 
30
38
  ```bash
31
- # List available extensions
32
- djangocfg-ext list
33
-
34
- # Show extension info
35
- djangocfg-ext info ext-leads
36
-
37
- # Interactive installation wizard
38
- djangocfg-ext install
39
-
40
- # Initialize extension in your project
41
- djangocfg-ext init
39
+ # Create a new extension with interactive wizard
40
+ djangocfg-ext create
42
41
 
43
42
  # Show help
44
43
  djangocfg-ext help
45
44
  ```
46
45
 
47
- ### Available Extensions
46
+ The CLI will guide you through creating a new extension with proper structure and configuration using the `createExtensionConfig` helper.
48
47
 
49
- - **@djangocfg/ext-leads** - Lead management and contact forms
50
- - **@djangocfg/ext-payments** - Payment processing with multiple providers
51
- - **@djangocfg/ext-newsletter** - Newsletter and email campaigns
52
- - **@djangocfg/ext-support** - Customer support and ticketing
53
- - **@djangocfg/ext-knowbase** - Knowledge base and documentation
48
+ **Features:**
49
+ - Interactive prompts for package name, description, icon, and category
50
+ - Automatic npm registry validation to prevent duplicate package names
51
+ - Support for both scoped (`@my-org/my-extension`) and unscoped (`my-extension`) package names
52
+ - Template generation with proper placeholder replacement
54
53
 
55
54
  ## Quick Start
56
55
 
57
56
  ### 1. Create extension metadata
58
57
 
58
+ Use the `createExtensionConfig` helper to automatically pull data from package.json:
59
+
59
60
  ```typescript
60
61
  // src/config.ts
61
- import type { ExtensionMetadata } from '@djangocfg/ext-base';
62
+ import { createExtensionConfig } from '@djangocfg/ext-base';
63
+ import packageJson from '../package.json';
62
64
 
63
- export const extensionConfig: ExtensionMetadata = {
65
+ export const extensionConfig = createExtensionConfig(packageJson, {
64
66
  name: 'my-extension',
65
- version: '1.0.0',
66
67
  displayName: 'My Extension',
67
- description: 'Amazing extension functionality',
68
- icon: '🚀',
69
- };
68
+ icon: 'Rocket', // Lucide icon name
69
+ category: 'utilities',
70
+ features: [
71
+ 'Feature 1',
72
+ 'Feature 2',
73
+ 'Feature 3',
74
+ ],
75
+ minVersion: '2.0.0',
76
+ examples: [
77
+ {
78
+ title: 'Basic Usage',
79
+ description: 'How to use this extension',
80
+ code: `import { MyComponent } from '@your-org/my-extension';`,
81
+ language: 'tsx',
82
+ },
83
+ ],
84
+ });
70
85
  ```
71
86
 
87
+ This automatically imports from package.json:
88
+ - version
89
+ - author
90
+ - description
91
+ - license
92
+ - homepage
93
+ - githubUrl (from repository)
94
+ - keywords
95
+ - peerDependencies
96
+
72
97
  ### 2. Create extension provider
73
98
 
74
99
  ```typescript
@@ -103,6 +128,58 @@ export default function RootLayout({ children }) {
103
128
 
104
129
  ## Core Features
105
130
 
131
+ ### Extension Config Helper
132
+
133
+ The `createExtensionConfig` helper creates a typed extension configuration by combining package.json data with manual metadata:
134
+
135
+ ```typescript
136
+ import { createExtensionConfig, type ExtensionConfigInput } from '@djangocfg/ext-base';
137
+ import packageJson from '../package.json';
138
+
139
+ export const extensionConfig = createExtensionConfig(packageJson, {
140
+ // Required fields
141
+ name: 'my-extension',
142
+ displayName: 'My Extension',
143
+ icon: 'Package', // Lucide icon name
144
+ category: 'utilities', // 'forms' | 'payments' | 'content' | 'support' | 'utilities' | 'analytics' | 'security' | 'integration' | 'other'
145
+ features: ['Feature list for marketplace'],
146
+
147
+ // Optional fields
148
+ minVersion: '2.0.0',
149
+ githubStars: 100,
150
+ examples: [
151
+ {
152
+ title: 'Example title',
153
+ description: 'Example description',
154
+ code: 'import { Component } from "@your-org/my-extension";',
155
+ language: 'tsx',
156
+ },
157
+ ],
158
+ });
159
+ ```
160
+
161
+ **Automatically imported from package.json:**
162
+ - `version` - Package version
163
+ - `author` - Author name (from string or object)
164
+ - `description` - Package description
165
+ - `license` - License type
166
+ - `homepage` - Homepage URL
167
+ - `githubUrl` - Repository URL
168
+ - `keywords` - Keywords array
169
+ - `peerDependencies` - Peer dependencies (workspace:* auto-replaced with latest)
170
+ - `packageDependencies` - Dependencies from package.json (workspace:* auto-replaced with latest)
171
+
172
+ **Auto-generated:**
173
+ - `npmUrl` - npm package URL (`https://www.npmjs.com/package/[name]`)
174
+ - `marketplaceId` - URL-safe ID (@ and / replaced with -), e.g. `@djangocfg/ext-newsletter` → `djangocfg-ext-newsletter`
175
+ - `marketplaceUrl` - Marketplace URL (only for official @djangocfg extensions): `https://hub.djangocfg.com/extensions/[marketplaceId]`
176
+ - `installCommand` - pnpm install command
177
+ - `downloadUrl` - npm tarball download URL
178
+ - `preview` - Preview image URL (`https://unpkg.com/[name]@latest/preview.png`)
179
+ - `tags` - Same as keywords
180
+
181
+ > **Note:** All `workspace:*` dependencies are automatically replaced with `latest` for marketplace display.
182
+
106
183
  ### Environment Configuration
107
184
 
108
185
  ```typescript
@@ -201,16 +278,63 @@ function MyComponent() {
201
278
  | `@djangocfg/ext-base/auth` | Auth re-exports (useAuth, types) | Client components only |
202
279
  | `@djangocfg/ext-base/api` | API utilities (createExtensionAPI, getSharedAuthStorage) | Server & client components |
203
280
 
281
+ **For your own extensions:**
282
+ - Use `@your-org/ext-name/config` to import extension metadata without loading React components (server-safe)
283
+ - This is the recommended way to import `extensionConfig` in server components and build tools
284
+
285
+ ## Extension Categories
286
+
287
+ The package exports a standardized list of extension categories:
288
+
289
+ ```typescript
290
+ import { EXTENSION_CATEGORIES } from '@djangocfg/ext-base';
291
+
292
+ // Array of { title: string, value: ExtensionCategory }
293
+ EXTENSION_CATEGORIES.forEach(category => {
294
+ console.log(category.title, category.value);
295
+ // Forms, forms
296
+ // Payments, payments
297
+ // Content, content
298
+ // Support, support
299
+ // Utilities, utilities
300
+ // Analytics, analytics
301
+ // Security, security
302
+ // Integration, integration
303
+ // Other, other
304
+ });
305
+ ```
306
+
307
+ Available categories:
308
+ - `forms` - Forms, CRM, Lead Management
309
+ - `payments` - Payment Processing, Billing
310
+ - `content` - Content Management, Marketing
311
+ - `support` - Support, Helpdesk, Tickets
312
+ - `utilities` - Tools, Base, Infrastructure
313
+ - `analytics` - Analytics, Tracking, Monitoring
314
+ - `security` - Security, Authentication, Authorization
315
+ - `integration` - Third-party Integrations
316
+ - `other` - Other/Uncategorized
317
+
204
318
  ## TypeScript Types
205
319
 
206
320
  ```typescript
207
321
  import type {
322
+ // Extension configuration
208
323
  ExtensionMetadata,
324
+ ExtensionConfigInput,
325
+ ExtensionCategory,
326
+ ExtensionExample,
327
+
328
+ // Provider
209
329
  ExtensionProviderProps,
330
+
331
+ // Pagination
210
332
  PaginatedResponse,
211
333
  PaginationParams,
212
334
  PaginationState,
213
335
  InfinitePaginationReturn,
336
+
337
+ // Utilities
214
338
  ExtensionLogger,
215
339
  ExtensionError,
216
340
  } from '@djangocfg/ext-base';
@@ -218,11 +342,16 @@ import type {
218
342
 
219
343
  ## Best Practices
220
344
 
345
+ - Use `createExtensionConfig` helper to maintain Single Source of Truth from package.json
221
346
  - Always wrap your extension with `ExtensionProvider` for proper registration
222
- - Define complete metadata in `config.ts`
347
+ - Use Lucide icon names (not emoji) for `icon` field
348
+ - **Include a `preview.png` file** in your extension root (1200x630px recommended) - it will be automatically served via unpkg
349
+ - Include comprehensive `features` list for marketplace visibility
350
+ - Provide code `examples` with proper syntax highlighting
223
351
  - Use provided pagination hooks for consistent data fetching
224
352
  - Use `createExtensionLogger` with consistent tags for structured logging
225
353
  - Separate client-only code using `/hooks` entry point
354
+ - List `preview.png` in your package.json `files` array for npm publication
226
355
 
227
356
  ## License
228
357
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ext-base",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Base utilities and common code for DjangoCFG extensions",
5
5
  "keywords": [
6
6
  "django",
@@ -15,7 +15,7 @@
15
15
  "name": "DjangoCFG",
16
16
  "url": "https://djangocfg.com"
17
17
  },
18
- "homepage": "https://djangocfg.com",
18
+ "homepage": "https://hub.djangocfg.com/extensions/djangocfg-ext-base",
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "https://github.com/markolofsen/django-cfg.git",
@@ -27,33 +27,35 @@
27
27
  "license": "MIT",
28
28
  "type": "module",
29
29
  "main": "./dist/index.cjs",
30
- "module": "./dist/index.mjs",
30
+ "module": "./dist/index.js",
31
31
  "types": "./dist/index.d.ts",
32
32
  "exports": {
33
33
  ".": {
34
34
  "types": "./dist/index.d.ts",
35
- "import": "./dist/index.mjs",
35
+ "import": "./dist/index.js",
36
36
  "require": "./dist/index.cjs"
37
37
  },
38
38
  "./hooks": {
39
39
  "types": "./dist/hooks.d.ts",
40
- "import": "./dist/hooks.mjs",
40
+ "import": "./dist/hooks.js",
41
41
  "require": "./dist/hooks.cjs"
42
42
  },
43
43
  "./auth": {
44
44
  "types": "./dist/auth.d.ts",
45
- "import": "./dist/auth.mjs",
45
+ "import": "./dist/auth.js",
46
46
  "require": "./dist/auth.cjs"
47
47
  },
48
48
  "./api": {
49
49
  "types": "./dist/api.d.ts",
50
- "import": "./dist/api.mjs",
50
+ "import": "./dist/api.js",
51
51
  "require": "./dist/api.cjs"
52
52
  }
53
53
  },
54
54
  "files": [
55
55
  "dist",
56
- "src"
56
+ "src",
57
+ "preview.png",
58
+ "templates"
57
59
  ],
58
60
  "bin": {
59
61
  "djangocfg-ext": "./dist/cli.mjs"
@@ -64,6 +66,7 @@
64
66
  "check": "tsc --noEmit",
65
67
  "cli": "tsx src/cli/index.ts",
66
68
  "cli:help": "tsx src/cli/index.ts --help",
69
+ "cli:create": "tsx src/cli/index.ts create",
67
70
  "cli:list": "tsx src/cli/index.ts list",
68
71
  "cli:info": "tsx src/cli/index.ts info"
69
72
  },
package/preview.png ADDED
Binary file