@gpc-cli/config 0.1.1 → 0.1.2
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 +101 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @gpc-cli/config
|
|
2
|
+
|
|
3
|
+
Configuration loading and validation for GPC. Handles config files, environment variables, profiles, and XDG-compliant paths.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gpc-cli/config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
loadConfig,
|
|
16
|
+
findConfigFile,
|
|
17
|
+
loadEnvConfig,
|
|
18
|
+
getConfigDir,
|
|
19
|
+
initConfig,
|
|
20
|
+
} from "@gpc-cli/config";
|
|
21
|
+
|
|
22
|
+
// Load config (merges file + env vars)
|
|
23
|
+
const config = await loadConfig();
|
|
24
|
+
|
|
25
|
+
// Find .gpcrc.json in cwd or parents
|
|
26
|
+
const configPath = findConfigFile();
|
|
27
|
+
|
|
28
|
+
// Load from environment variables only
|
|
29
|
+
const envConfig = loadEnvConfig();
|
|
30
|
+
|
|
31
|
+
// Get XDG-compliant paths
|
|
32
|
+
const configDir = getConfigDir(); // ~/.config/gpc
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Config Sources
|
|
36
|
+
|
|
37
|
+
Configuration is merged in priority order:
|
|
38
|
+
|
|
39
|
+
1. CLI flags (highest)
|
|
40
|
+
2. Environment variables (`GPC_*`)
|
|
41
|
+
3. Project config (`.gpcrc.json` in cwd or parents)
|
|
42
|
+
4. User config (`~/.config/gpc/config.json`)
|
|
43
|
+
5. Defaults (lowest)
|
|
44
|
+
|
|
45
|
+
## Environment Variables
|
|
46
|
+
|
|
47
|
+
| Variable | Description |
|
|
48
|
+
|----------|-------------|
|
|
49
|
+
| `GPC_SERVICE_ACCOUNT` | Service account JSON string or file path |
|
|
50
|
+
| `GPC_APP` | Default package name |
|
|
51
|
+
| `GPC_PROFILE` | Auth profile name |
|
|
52
|
+
| `GPC_OUTPUT` | Default output format |
|
|
53
|
+
| `GPC_NO_COLOR` | Disable color output |
|
|
54
|
+
| `GPC_NO_INTERACTIVE` | Disable prompts |
|
|
55
|
+
|
|
56
|
+
## Profiles
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import {
|
|
60
|
+
setProfileConfig,
|
|
61
|
+
listProfiles,
|
|
62
|
+
deleteProfile,
|
|
63
|
+
} from "@gpc-cli/config";
|
|
64
|
+
|
|
65
|
+
// Create a profile
|
|
66
|
+
await setProfileConfig("production", {
|
|
67
|
+
serviceAccount: "./keys/prod.json",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// List profiles
|
|
71
|
+
const profiles = await listProfiles();
|
|
72
|
+
|
|
73
|
+
// Delete a profile
|
|
74
|
+
await deleteProfile("staging");
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API
|
|
78
|
+
|
|
79
|
+
| Function | Description |
|
|
80
|
+
|----------|-------------|
|
|
81
|
+
| `loadConfig()` | Load merged config from all sources |
|
|
82
|
+
| `findConfigFile()` | Find `.gpcrc.json` in cwd or parent directories |
|
|
83
|
+
| `loadEnvConfig()` | Load config from `GPC_*` env vars |
|
|
84
|
+
| `initConfig()` | Create initial `.gpcrc.json` |
|
|
85
|
+
| `setConfigValue()` | Set a config key/value |
|
|
86
|
+
| `getConfigDir()` | XDG config directory (`~/.config/gpc`) |
|
|
87
|
+
| `getDataDir()` | XDG data directory (`~/.local/share/gpc`) |
|
|
88
|
+
| `getCacheDir()` | XDG cache directory (`~/.cache/gpc`) |
|
|
89
|
+
| `listProfiles()` | List saved auth profiles |
|
|
90
|
+
| `setProfileConfig()` | Create or update a profile |
|
|
91
|
+
| `deleteProfile()` | Delete a profile |
|
|
92
|
+
| `approvePlugin()` | Approve a third-party plugin |
|
|
93
|
+
| `revokePluginApproval()` | Revoke plugin approval |
|
|
94
|
+
|
|
95
|
+
## Part of the GPC Monorepo
|
|
96
|
+
|
|
97
|
+
This is the config layer for [GPC](https://github.com/yasserstudio/gpc).
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|