localflare-core 0.2.0-beta.2 → 0.2.0-beta.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 +73 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# localflare-core
|
|
2
2
|
|
|
3
|
-
Core
|
|
3
|
+
Core configuration parser and utilities for [Localflare](https://www.npmjs.com/package/localflare).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/localflare-core)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
This package provides
|
|
10
|
+
This package provides core utilities for Localflare:
|
|
11
11
|
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
12
|
+
- **Config Parser** - Reads and parses `wrangler.toml` / `wrangler.json` / `wrangler.jsonc` configuration files
|
|
13
|
+
- **Binding Discovery** - Extracts D1, KV, R2, Durable Objects, and Queue binding configurations
|
|
14
|
+
- **Type Definitions** - TypeScript types for wrangler configuration and Localflare manifests
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -24,52 +24,88 @@ pnpm add localflare-core
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
parseWranglerConfig,
|
|
29
|
+
findWranglerConfig,
|
|
30
|
+
WRANGLER_CONFIG_FILES
|
|
31
|
+
} from 'localflare-core';
|
|
32
|
+
|
|
33
|
+
// Find wrangler config in current directory
|
|
34
|
+
const configPath = findWranglerConfig(process.cwd());
|
|
35
|
+
// Returns: ./wrangler.toml, ./wrangler.json, or ./wrangler.jsonc
|
|
36
|
+
|
|
37
|
+
// Parse the configuration
|
|
38
|
+
const config = parseWranglerConfig(configPath);
|
|
39
|
+
|
|
40
|
+
// Access binding configurations
|
|
41
|
+
console.log(config.d1_databases); // D1 database bindings
|
|
42
|
+
console.log(config.kv_namespaces); // KV namespace bindings
|
|
43
|
+
console.log(config.r2_buckets); // R2 bucket bindings
|
|
44
|
+
console.log(config.durable_objects); // Durable Object bindings
|
|
45
|
+
console.log(config.queues); // Queue producer/consumer config
|
|
46
|
+
```
|
|
28
47
|
|
|
29
|
-
|
|
30
|
-
configPath: './wrangler.toml',
|
|
31
|
-
port: 8787,
|
|
32
|
-
persist: '.localflare'
|
|
33
|
-
});
|
|
48
|
+
## API Reference
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
await core.start();
|
|
50
|
+
### `findWranglerConfig(directory: string): string | null`
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
const bindings = core.getBindings();
|
|
52
|
+
Searches for a wrangler configuration file in the specified directory.
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
const
|
|
54
|
+
```typescript
|
|
55
|
+
const configPath = findWranglerConfig('/path/to/project');
|
|
56
|
+
// Returns: '/path/to/project/wrangler.toml' or null
|
|
57
|
+
```
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
const kvNamespaces = bindings.kv;
|
|
59
|
+
### `parseWranglerConfig(configPath: string): WranglerConfig`
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
Parses a wrangler configuration file (TOML, JSON, or JSONC format).
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const config = parseWranglerConfig('./wrangler.toml');
|
|
49
65
|
```
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
### `WRANGLER_CONFIG_FILES`
|
|
68
|
+
|
|
69
|
+
Array of supported config file names: `['wrangler.toml', 'wrangler.json', 'wrangler.jsonc']`
|
|
70
|
+
|
|
71
|
+
## Types
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
interface WranglerConfig {
|
|
75
|
+
name?: string;
|
|
76
|
+
main?: string;
|
|
77
|
+
compatibility_date?: string;
|
|
78
|
+
d1_databases?: D1DatabaseConfig[];
|
|
79
|
+
kv_namespaces?: KVNamespaceConfig[];
|
|
80
|
+
r2_buckets?: R2BucketConfig[];
|
|
81
|
+
durable_objects?: { bindings: DurableObjectConfig[] };
|
|
82
|
+
queues?: {
|
|
83
|
+
producers?: QueueProducerConfig[];
|
|
84
|
+
consumers?: QueueConsumerConfig[];
|
|
85
|
+
};
|
|
86
|
+
vars?: Record<string, string>;
|
|
87
|
+
// ... and more
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface LocalflareManifest {
|
|
91
|
+
name: string;
|
|
92
|
+
d1: { binding: string; database_name: string }[];
|
|
93
|
+
kv: { binding: string }[];
|
|
94
|
+
r2: { binding: string; bucket_name: string }[];
|
|
95
|
+
queues: {
|
|
96
|
+
producers: { binding: string; queue: string }[];
|
|
97
|
+
consumers: { queue: string; max_batch_size?: number; /* ... */ }[];
|
|
98
|
+
};
|
|
99
|
+
do: { binding: string; className: string }[];
|
|
100
|
+
}
|
|
101
|
+
```
|
|
65
102
|
|
|
66
103
|
## Related Packages
|
|
67
104
|
|
|
68
105
|
| Package | Description |
|
|
69
106
|
|---------|-------------|
|
|
70
107
|
| [`localflare`](https://www.npmjs.com/package/localflare) | CLI tool (main package) |
|
|
71
|
-
| [`localflare-
|
|
72
|
-
| [`localflare-dashboard`](https://www.npmjs.com/package/localflare-dashboard) | React dashboard UI |
|
|
108
|
+
| [`localflare-api`](https://www.npmjs.com/package/localflare-api) | Dashboard API worker |
|
|
73
109
|
|
|
74
110
|
## License
|
|
75
111
|
|