codex-configurator 0.2.0 → 0.2.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.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/configParser.js +27 -1
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ The table view follows TOML structure, with a root catalog of common keys:
|
|
|
60
60
|
- Attributes and subattributes are shown in strict alphabetical order.
|
|
61
61
|
- Unset boolean settings display explicit defaults as `true [default]` or `false [default]`.
|
|
62
62
|
- For placeholder keys like `<path>`, IDs entered in the UI are normalized under your home directory, and traversal outside home is rejected.
|
|
63
|
+
- New `<path>` entries are written as explicit tables (for example `[projects."/home/me/repo"]`) instead of inline empty objects.
|
|
63
64
|
|
|
64
65
|
- Dotted/table sections become navigable table nodes.
|
|
65
66
|
- Inline key-value pairs are shown as leaf entries.
|
package/package.json
CHANGED
package/src/configParser.js
CHANGED
|
@@ -171,6 +171,32 @@ export const readConfig = (configPath = CONFIG_PATH) => {
|
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
const normalizeFilePath = (outputPath) => outputPath || CONFIG_PATH;
|
|
174
|
+
const EMPTY_PATH_TABLE_MARKER_KEY = '__codex_configurator_empty_path_table_marker__';
|
|
175
|
+
|
|
176
|
+
const cloneForTomlWrite = (value, pathSegments = []) => {
|
|
177
|
+
if (Array.isArray(value)) {
|
|
178
|
+
return value.map((item, index) => cloneForTomlWrite(item, [...pathSegments, String(index)]));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (!isPlainObject(value)) {
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const customPlaceholder = getReferenceCustomIdPlaceholder(pathSegments);
|
|
186
|
+
const clonedEntries = Object.entries(value).map(([key, child]) => {
|
|
187
|
+
if (
|
|
188
|
+
customPlaceholder === '<path>' &&
|
|
189
|
+
isPlainObject(child) &&
|
|
190
|
+
Object.keys(child).length === 0
|
|
191
|
+
) {
|
|
192
|
+
return [key, { [EMPTY_PATH_TABLE_MARKER_KEY]: undefined }];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return [key, cloneForTomlWrite(child, [...pathSegments, key])];
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return Object.fromEntries(clonedEntries);
|
|
199
|
+
};
|
|
174
200
|
|
|
175
201
|
export const writeConfig = (data, outputPath = CONFIG_PATH) => {
|
|
176
202
|
const targetPath = normalizeFilePath(outputPath);
|
|
@@ -186,7 +212,7 @@ export const writeConfig = (data, outputPath = CONFIG_PATH) => {
|
|
|
186
212
|
fs.mkdirSync(directoryPath, { recursive: true, mode: 0o700 });
|
|
187
213
|
}
|
|
188
214
|
|
|
189
|
-
const payload = stringify(data);
|
|
215
|
+
const payload = stringify(cloneForTomlWrite(data));
|
|
190
216
|
let tempFd = null;
|
|
191
217
|
|
|
192
218
|
try {
|