@wtf/project-config 0.0.0-placeholder.0 → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +75 -1
- package/dist/define.d.ts +26 -0
- package/dist/define.js +7 -0
- package/dist/define.js.map +1 -0
- package/dist/env.d.ts +40 -0
- package/dist/env.js +160 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +151 -0
- package/dist/errors.js +175 -0
- package/dist/errors.js.map +1 -0
- package/dist/files.d.ts +51 -0
- package/dist/files.js +120 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +196 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +82 -0
- package/dist/load.js +140 -0
- package/dist/load.js.map +1 -0
- package/dist/locate.d.ts +71 -0
- package/dist/locate.js +121 -0
- package/dist/locate.js.map +1 -0
- package/dist/merge.d.ts +10 -0
- package/dist/merge.js +33 -0
- package/dist/merge.js.map +1 -0
- package/dist/node.d.ts +20 -0
- package/dist/node.js +90 -0
- package/dist/node.js.map +1 -0
- package/dist/path.d.ts +14 -0
- package/dist/path.js +40 -0
- package/dist/path.js.map +1 -0
- package/dist/placeholder.d.ts +37 -0
- package/dist/placeholder.js +47 -0
- package/dist/placeholder.js.map +1 -0
- package/dist/schema.d.ts +23 -0
- package/dist/schema.js +56 -0
- package/dist/schema.js.map +1 -0
- package/dist/section.d.ts +39 -0
- package/dist/section.js +169 -0
- package/dist/section.js.map +1 -0
- package/dist/text.d.ts +3 -0
- package/dist/text.js +3 -0
- package/dist/text.js.map +1 -0
- package/dist/write.d.ts +35 -0
- package/dist/write.js +209 -0
- package/dist/write.js.map +1 -0
- package/package.json +83 -5
package/dist/write.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value of a project's configuration written: {@link setConfigValue}, a value set at a path, and
|
|
3
|
+
* {@link unsetConfigValue}, a value taken away. Each writes the file in use, the key of
|
|
4
|
+
* package.json (`wtf` by default) or a JSON file of its names (`wtf.config.json` by default); with
|
|
5
|
+
* none, a set makes it in the key of package.json, or in the JSON file that is named; and it never
|
|
6
|
+
* writes a file of code, as `wtf.config.ts`. The text of the file is changed in place, by
|
|
7
|
+
* jsonc-parser, so what the write does not change stays as it was: its indent, its line ends and
|
|
8
|
+
* the order of its keys, and a new key is the last of its object. Each reads and writes by the
|
|
9
|
+
* platform it is given.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { nodeConfigPlatform } from '@wtf/project-config/node'
|
|
13
|
+
* import { setConfigValue } from '@wtf/project-config/write'
|
|
14
|
+
*
|
|
15
|
+
* await setConfigValue(process.cwd(), ['vite', 'compress'], false, {
|
|
16
|
+
* platform: nodeConfigPlatform()
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
import { applyEdits, format, modify } from 'jsonc-parser';
|
|
23
|
+
import { ConfigFileMismatchError, ConfigInCodeError, ConfigPathError, InvalidConfigFileError, NoConfigFileError, UnwritableConfigFileError } from "./errors.js";
|
|
24
|
+
import { filesOf, isObject, kindOf, PACKAGE_JSON } from "./files.js";
|
|
25
|
+
import { configNamesOf, jsonFilesOf, locateConfig } from "./locate.js";
|
|
26
|
+
import { textOfConfigPath, valueAt } from "./path.js";
|
|
27
|
+
/**
|
|
28
|
+
* The file in use, of the project in `folder`, checked against the file named: no code, and the
|
|
29
|
+
* one named, if one is, which is a JSON file of the names, or package.json.
|
|
30
|
+
*/
|
|
31
|
+
async function targetOf(folder, { file, ...options }) {
|
|
32
|
+
const json = jsonFilesOf(options);
|
|
33
|
+
if (file !== undefined && file !== PACKAGE_JSON && !json.includes(file))
|
|
34
|
+
throw new UnwritableConfigFileError(file, json);
|
|
35
|
+
const { root, key, sources } = await locateConfig(folder, options);
|
|
36
|
+
const [source, ...ignored] = sources;
|
|
37
|
+
if (source === undefined)
|
|
38
|
+
return { root, key, source: undefined, ignored };
|
|
39
|
+
if (kindOf(source.file) === 'code')
|
|
40
|
+
throw new ConfigInCodeError(source.path, { files: json, key });
|
|
41
|
+
if (file !== undefined && file !== source.file)
|
|
42
|
+
throw new ConfigFileMismatchError(source.path, file);
|
|
43
|
+
return { root, key, source, ignored };
|
|
44
|
+
}
|
|
45
|
+
/** How the text of a file is laid out: its indent, by the first line that has one, and its line
|
|
46
|
+
* ends. Two spaces, and `\n`, where it says nothing. */
|
|
47
|
+
function formattingOf(text) {
|
|
48
|
+
const indent = /^([ \t]+)\S/m.exec(text)?.[1];
|
|
49
|
+
const eol = text.includes('\r\n') ? '\r\n' : '\n';
|
|
50
|
+
if (indent === undefined)
|
|
51
|
+
return { insertSpaces: true, tabSize: 2, eol };
|
|
52
|
+
return indent.startsWith('\t')
|
|
53
|
+
? { insertSpaces: false, tabSize: 1, eol }
|
|
54
|
+
: { insertSpaces: true, tabSize: indent.length, eol };
|
|
55
|
+
}
|
|
56
|
+
/** The keys of `path` for jsonc-parser, from the top of the file: the index of a list as a
|
|
57
|
+
* number. A value on the way that is no object or list is a {@link ConfigPathError}. */
|
|
58
|
+
function keysOf(value, path, shown) {
|
|
59
|
+
const keys = [];
|
|
60
|
+
let at = value;
|
|
61
|
+
for (const [index, key] of path.entries()) {
|
|
62
|
+
if (at === undefined) {
|
|
63
|
+
keys.push(key);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(at)) {
|
|
67
|
+
if (!/^\d+$/.test(key))
|
|
68
|
+
throw new ConfigPathError(shown, `goes into ${textOfConfigPath(path.slice(0, index)) || 'the configuration'}, a list, by ${key}, which is no index.`);
|
|
69
|
+
keys.push(Number(key));
|
|
70
|
+
at = at[Number(key)];
|
|
71
|
+
}
|
|
72
|
+
else if (isObject(at)) {
|
|
73
|
+
keys.push(key);
|
|
74
|
+
at = Object.hasOwn(at, key) ? at[key] : undefined;
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
throw new ConfigPathError(shown, `goes into ${textOfConfigPath(path.slice(0, index))}, which is ${JSON.stringify(at)}, and holds no value.`);
|
|
78
|
+
}
|
|
79
|
+
return keys;
|
|
80
|
+
}
|
|
81
|
+
/** The JSON of the file at `path`, and its text. */
|
|
82
|
+
async function jsonAt(path, files) {
|
|
83
|
+
const text = (await files.text(path)) ?? '';
|
|
84
|
+
try {
|
|
85
|
+
return { text, json: JSON.parse(text) };
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw new InvalidConfigFileError(path, 'is no JSON.', { cause: error });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Whether two JSON values are the same. */
|
|
92
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
93
|
+
const isSpace = (char) => char !== undefined && ' \t\r\n'.includes(char);
|
|
94
|
+
/** The range of `text` from `start` to `end` that a change's layout is given to: with the space on
|
|
95
|
+
* each side of it, whole, and the token past that, so the space between the change and its
|
|
96
|
+
* neighbours is laid out too, and no line end is cut in two. */
|
|
97
|
+
function rangeOf(text, start, end) {
|
|
98
|
+
let from = start;
|
|
99
|
+
while (from > 0 && isSpace(text[from - 1]))
|
|
100
|
+
from -= 1;
|
|
101
|
+
let to = end;
|
|
102
|
+
while (to < text.length && isSpace(text[to]))
|
|
103
|
+
to += 1;
|
|
104
|
+
const offset = Math.max(0, from - 1);
|
|
105
|
+
return { offset, length: Math.min(text.length, to + 1) - offset };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The text of `text` with `value` at `keys`, from the top of the file; `undefined` takes the value
|
|
109
|
+
* away. jsonc-parser makes the change, and the layout of the file is given to what it writes, and
|
|
110
|
+
* to the space beside it, and to nothing else: its own formatting of a change would lay out the
|
|
111
|
+
* whole line it is on again, as an object on one line beside it.
|
|
112
|
+
*/
|
|
113
|
+
function edited(text, keys, value) {
|
|
114
|
+
// One edit, or none, of a value to take away that is not there.
|
|
115
|
+
const [edit] = modify(text, keys, value, {});
|
|
116
|
+
if (edit === undefined)
|
|
117
|
+
return text;
|
|
118
|
+
const result = applyEdits(text, [edit]);
|
|
119
|
+
const range = rangeOf(result, edit.offset, edit.offset + edit.content.length);
|
|
120
|
+
return applyEdits(result, format(result, range, { ...formattingOf(text), keepLines: false }));
|
|
121
|
+
}
|
|
122
|
+
/** The keys of the configuration in `file`, from the top of it: of package.json, its key. */
|
|
123
|
+
const prefixOf = (file, key) => (kindOf(file) === 'package' ? [key] : []);
|
|
124
|
+
/** Write `value`, or take it away (`undefined`), at `path` of the configuration in `source`. */
|
|
125
|
+
async function writeAt(target, path, value, files) {
|
|
126
|
+
const { root, key, source, ignored } = target;
|
|
127
|
+
const inPackage = kindOf(source.file) === 'package';
|
|
128
|
+
const { text, json } = await jsonAt(source.path, files);
|
|
129
|
+
const config = inPackage && isObject(json) ? json[key] : json;
|
|
130
|
+
if (!isObject(config))
|
|
131
|
+
throw new InvalidConfigFileError(source.path, inPackage ? `its "${key}" key is no JSON object.` : 'is no JSON object.');
|
|
132
|
+
const previous = valueAt(config, path);
|
|
133
|
+
const changed = !same(previous, value);
|
|
134
|
+
// A value taken away that is not there is no change, wherever the path goes.
|
|
135
|
+
if (changed) {
|
|
136
|
+
const keys = keysOf(config, path, textOfConfigPath(path));
|
|
137
|
+
await files.write(source.path, edited(text, [...prefixOf(source.file, key), ...keys], value));
|
|
138
|
+
}
|
|
139
|
+
return { root, key, source, ignored, path, previous, value, changed, created: false };
|
|
140
|
+
}
|
|
141
|
+
/** A path with at least one key: the whole configuration is no value to set or unset. */
|
|
142
|
+
function checked(path) {
|
|
143
|
+
if (path.length === 0 || path.some((key) => key === ''))
|
|
144
|
+
throw new ConfigPathError(textOfConfigPath(path), 'is no path: give at least one key.');
|
|
145
|
+
return path;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Set `value` at `path` of the configuration of the project in `folder`: in the file in use, the
|
|
149
|
+
* key of package.json (the namespace by default) or a JSON file of the names
|
|
150
|
+
* (`<namespace>.config.json` by default); with none, in the key, added to the package.json at the
|
|
151
|
+
* root, by default, or in the JSON file `options.file` names, made. An object on the way that is
|
|
152
|
+
* not there is made. Nothing is written when the value is already so.
|
|
153
|
+
*
|
|
154
|
+
* Throws a `ConfigInCodeError` when the configuration is code, as `<namespace>.config.ts`; a
|
|
155
|
+
* `NoConfigFileError` when there is none, and no package.json at the root to hold it, and no JSON
|
|
156
|
+
* file is named; a `ConfigFileMismatchError` when the file named is not the one in use; an
|
|
157
|
+
* `UnwritableConfigFileError` when the file named is neither a JSON file of the names nor
|
|
158
|
+
* package.json; and a `ConfigPathError` when the path goes into a value that is no object or list.
|
|
159
|
+
*/
|
|
160
|
+
export async function setConfigValue(folder, path, value, options) {
|
|
161
|
+
if (value === undefined)
|
|
162
|
+
throw new TypeError('A value of JSON is set, and not undefined.');
|
|
163
|
+
checked(path);
|
|
164
|
+
const { file = PACKAGE_JSON } = options;
|
|
165
|
+
const { namespace } = configNamesOf(options);
|
|
166
|
+
const files = filesOf(options.platform);
|
|
167
|
+
const target = await targetOf(folder, options);
|
|
168
|
+
if (target.source !== undefined)
|
|
169
|
+
return writeAt({ ...target, source: target.source }, path, value, files);
|
|
170
|
+
const { root, key, ignored } = target;
|
|
171
|
+
const source = { file, path: options.platform.path.join(root, file) };
|
|
172
|
+
const keys = keysOf({}, path, textOfConfigPath(path));
|
|
173
|
+
const made = { root, key, source, ignored, path, previous: undefined, value };
|
|
174
|
+
if (kindOf(file) === 'json') {
|
|
175
|
+
await files.write(source.path, edited('{}\n', keys, value));
|
|
176
|
+
return { ...made, changed: true, created: true };
|
|
177
|
+
}
|
|
178
|
+
const manifest = await files.text(source.path);
|
|
179
|
+
if (manifest === undefined)
|
|
180
|
+
throw new NoConfigFileError(root, { namespace, key, json: jsonFilesOf(options)[0] });
|
|
181
|
+
await files.write(source.path, edited(manifest, [key, ...keys], value));
|
|
182
|
+
return { ...made, changed: true, created: true };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Take away the value at `path` of the configuration of the project in `folder`, in the file in
|
|
186
|
+
* use: a JSON file of the names (`<namespace>.config.json` by default) or the key of package.json
|
|
187
|
+
* (the namespace by default). Nothing is written when no value is there, or no configuration:
|
|
188
|
+
* `changed` is false. An object it leaves empty stays. Throws a `ConfigInCodeError` when the
|
|
189
|
+
* configuration is code, and a `ConfigFileMismatchError` when the file named is not the one in use.
|
|
190
|
+
*/
|
|
191
|
+
export async function unsetConfigValue(folder, path, options) {
|
|
192
|
+
checked(path);
|
|
193
|
+
const target = await targetOf(folder, options);
|
|
194
|
+
const { root, key, source, ignored } = target;
|
|
195
|
+
if (source === undefined)
|
|
196
|
+
return {
|
|
197
|
+
root,
|
|
198
|
+
key,
|
|
199
|
+
source,
|
|
200
|
+
ignored,
|
|
201
|
+
path,
|
|
202
|
+
previous: undefined,
|
|
203
|
+
value: undefined,
|
|
204
|
+
changed: false,
|
|
205
|
+
created: false
|
|
206
|
+
};
|
|
207
|
+
return writeAt({ root, key, source, ignored }, path, undefined, filesOf(options.platform));
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,EAA0B,MAAM,EAAE,MAAM,cAAc,CAAA;AAEjF,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAc,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEhF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAA;AAC1F,OAAO,EAAE,gBAAg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,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,IAAgB,EAChB,OAAqB;IAErB,OAAO,CAAC,IAAI,CAAC,CAAA;IACb,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC7C,IAAI,MAAM,KAAK,SAAS;QACtB,OAAO;YACL,IAAI;YACJ,GAAG;YACH,MAAM;YACN,OAAO;YACP,IAAI;YACJ,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,KAAK;SACf,CAAA;IACH,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC5F,CAAC","sourcesContent":["/**\n * A value of a project's configuration written: {@link setConfigValue}, a value set at a path, and\n * {@link unsetConfigValue}, a value taken away. Each writes the file in use, the key of\n * package.json (`wtf` by default) or a JSON file of its names (`wtf.config.json` by default); with\n * none, a set makes it in the key of package.json, or in the JSON file that is named; and it never\n * writes a file of code, as `wtf.config.ts`. The text of the file is changed in place, by\n * jsonc-parser, so what the write does not change stays as it was: its indent, its line ends and\n * the order of its keys, and a new key is the last of its object. Each reads and writes by the\n * platform it is given.\n *\n * ```ts\n * import { nodeConfigPlatform } from '@wtf/project-config/node'\n * import { setConfigValue } from '@wtf/project-config/write'\n *\n * await setConfigValue(process.cwd(), ['vite', 'compress'], false, {\n * platform: nodeConfigPlatform()\n * })\n * ```\n *\n * @packageDocumentation\n */\nimport { applyEdits, format, type FormattingOptions, modify } from 'jsonc-parser'\n\nimport {\n ConfigFileMismatchError,\n ConfigInCodeError,\n ConfigPathError,\n InvalidConfigFileError,\n NoConfigFileError,\n UnwritableConfigFileError\n} from './errors.ts'\nimport { type Files, filesOf, isObject, kindOf, PACKAGE_JSON } from './files.ts'\nimport type { ConfigPath, ConfigSource, ConfigWrite } from './index.ts'\nimport { configNamesOf, jsonFilesOf, locateConfig, type LocateOptions } from './locate.ts'\nimport { textOfConfigPath, valueAt } from './path.ts'\n\n/** How a value of the configuration is written: where it is looked for, of the namespace and the\n * names of `ConfigNames`, each its default when it is not given, and the file to write. */\nexport type WriteOptions = LocateOptions & {\n /**\n * The file to write: where none holds the configuration, the one to make it in, the key of\n * package.json (`package.json`) by default, or a JSON file of the names, as\n * `<namespace>.config.json`; where one does, it must be that one, or the write is a\n * `ConfigFileMismatchError`. Any other file is an `UnwritableConfigFileError`.\n */\n readonly file?: string\n}\n\n/** The file of the configuration that a write changes: the one in use, which is no code. */\ntype Target = {\n readonly root: string\n readonly key: string\n readonly source: ConfigSource | undefined\n readonly ignored: readonly ConfigSource[]\n}\n\n/**\n * The file in use, of the project in `folder`, checked against the file named: no code, and the\n * one named, if one is, which is a JSON file of the names, or package.json.\n */\nasync function targetOf(folder: string, { file, ...options }: WriteOptions): Promise<Target> {\n const json = jsonFilesOf(options)\n if (file !== undefined && file !== PACKAGE_JSON && !json.includes(file))\n throw new UnwritableConfigFileError(file, json)\n const { root, key, sources } = await locateConfig(folder, options)\n const [source, ...ignored] = sources\n if (source === undefined) return { root, key, source: undefined, ignored }\n if (kindOf(source.file) === 'code') throw new ConfigInCodeError(source.path, { files: json, key })\n if (file !== undefined && file !== source.file)\n throw new ConfigFileMismatchError(source.path, file)\n return { root, key, source, ignored }\n}\n\n/** How the text of a file is laid out: its indent, by the first line that has one, and its line\n * ends. Two spaces, and `\\n`, where it says nothing. */\nfunction formattingOf(text: string): FormattingOptions {\n const indent = /^([ \\t]+)\\S/m.exec(text)?.[1]\n const eol = text.includes('\\r\\n') ? '\\r\\n' : '\\n'\n if (indent === undefined) return { insertSpaces: true, tabSize: 2, eol }\n return indent.startsWith('\\t')\n ? { insertSpaces: false, tabSize: 1, eol }\n : { insertSpaces: true, tabSize: indent.length, eol }\n}\n\n/** The keys of `path` for jsonc-parser, from the top of the file: the index of a list as a\n * number. A value on the way that is no object or list is a {@link ConfigPathError}. */\nfunction keysOf(value: unknown, path: ConfigPath, shown: string): (string | number)[] {\n const keys: (string | number)[] = []\n let at: unknown = value\n for (const [index, key] of path.entries()) {\n if (at === undefined) {\n keys.push(key)\n continue\n }\n if (Array.isArray(at)) {\n if (!/^\\d+$/.test(key))\n throw new ConfigPathError(\n shown,\n `goes into ${textOfConfigPath(path.slice(0, index)) || 'the configuration'}, a list, by ${key}, which is no index.`\n )\n keys.push(Number(key))\n at = at[Number(key)]\n } else if (isObject(at)) {\n keys.push(key)\n at = Object.hasOwn(at, key) ? at[key] : undefined\n } else\n throw new ConfigPathError(\n shown,\n `goes into ${textOfConfigPath(path.slice(0, index))}, which is ${JSON.stringify(at)}, and holds no value.`\n )\n }\n return keys\n}\n\n/** The JSON of the file at `path`, and its text. */\nasync function jsonAt(\n path: string,\n files: Files\n): Promise<{ readonly text: string; readonly json: unknown }> {\n const text = (await files.text(path)) ?? ''\n try {\n return { text, json: JSON.parse(text) }\n } catch (error) {\n throw new InvalidConfigFileError(path, 'is no JSON.', { cause: error })\n }\n}\n\n/** Whether two JSON values are the same. */\nconst same = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b)\n\nconst isSpace = (char: string | undefined): boolean =>\n char !== undefined && ' \\t\\r\\n'.includes(char)\n\n/** The range of `text` from `start` to `end` that a change's layout is given to: with the space on\n * each side of it, whole, and the token past that, so the space between the change and its\n * neighbours is laid out too, and no line end is cut in two. */\nfunction rangeOf(text: string, start: number, end: number): { offset: number; length: number } {\n let from = start\n while (from > 0 && isSpace(text[from - 1])) from -= 1\n let to = end\n while (to < text.length && isSpace(text[to])) to += 1\n const offset = Math.max(0, from - 1)\n return { offset, length: Math.min(text.length, to + 1) - offset }\n}\n\n/**\n * The text of `text` with `value` at `keys`, from the top of the file; `undefined` takes the value\n * away. jsonc-parser makes the change, and the layout of the file is given to what it writes, and\n * to the space beside it, and to nothing else: its own formatting of a change would lay out the\n * whole line it is on again, as an object on one line beside it.\n */\nfunction edited(text: string, keys: (string | number)[], value: unknown): string {\n // One edit, or none, of a value to take away that is not there.\n const [edit] = modify(text, keys, value, {})\n if (edit === undefined) return text\n const result = applyEdits(text, [edit])\n const range = rangeOf(result, edit.offset, edit.offset + edit.content.length)\n return applyEdits(result, format(result, range, { ...formattingOf(text), keepLines: false }))\n}\n\n/** The keys of the configuration in `file`, from the top of it: of package.json, its key. */\nconst prefixOf = (file: string, key: string): string[] => (kindOf(file) === 'package' ? [key] : [])\n\n/** Write `value`, or take it away (`undefined`), at `path` of the configuration in `source`. */\nasync function writeAt(\n target: Target & { readonly source: ConfigSource },\n path: ConfigPath,\n value: unknown,\n files: Files\n): Promise<ConfigWrite> {\n const { root, key, source, ignored } = target\n const inPackage = kindOf(source.file) === 'package'\n const { text, json } = await jsonAt(source.path, files)\n const config: unknown = inPackage && isObject(json) ? json[key] : json\n if (!isObject(config))\n throw new InvalidConfigFileError(\n source.path,\n inPackage ? `its \"${key}\" key is no JSON object.` : 'is no JSON object.'\n )\n const previous = valueAt(config, path)\n const changed = !same(previous, value)\n // A value taken away that is not there is no change, wherever the path goes.\n if (changed) {\n const keys = keysOf(config, path, textOfConfigPath(path))\n await files.write(source.path, edited(text, [...prefixOf(source.file, key), ...keys], value))\n }\n return { root, key, source, ignored, path, previous, value, changed, created: false }\n}\n\n/** A path with at least one key: the whole configuration is no value to set or unset. */\nfunction checked(path: ConfigPath): ConfigPath {\n if (path.length === 0 || path.some((key) => key === ''))\n throw new ConfigPathError(textOfConfigPath(path), 'is no path: give at least one key.')\n return path\n}\n\n/**\n * Set `value` at `path` of the configuration of the project in `folder`: in the file in use, the\n * key of package.json (the namespace by default) or a JSON file of the names\n * (`<namespace>.config.json` by default); with none, in the key, added to the package.json at the\n * root, by default, or in the JSON file `options.file` names, made. An object on the way that is\n * not there is made. Nothing is written when the value is already so.\n *\n * Throws a `ConfigInCodeError` when the configuration is code, as `<namespace>.config.ts`; a\n * `NoConfigFileError` when there is none, and no package.json at the root to hold it, and no JSON\n * file is named; a `ConfigFileMismatchError` when the file named is not the one in use; an\n * `UnwritableConfigFileError` when the file named is neither a JSON file of the names nor\n * package.json; and a `ConfigPathError` when the path goes into a value that is no object or list.\n */\nexport async function setConfigValue(\n folder: string,\n path: ConfigPath,\n value: unknown,\n options: WriteOptions\n): Promise<ConfigWrite> {\n if (value === undefined) throw new TypeError('A value of JSON is set, and not undefined.')\n checked(path)\n const { file = PACKAGE_JSON } = options\n const { namespace } = configNamesOf(options)\n const files = filesOf(options.platform)\n const target = await targetOf(folder, options)\n if (target.source !== undefined)\n return writeAt({ ...target, source: target.source }, path, value, files)\n const { root, key, ignored } = target\n const source: ConfigSource = { file, path: options.platform.path.join(root, file) }\n const keys = keysOf({}, path, textOfConfigPath(path))\n const made = { root, key, source, ignored, path, previous: undefined, value }\n if (kindOf(file) === 'json') {\n await files.write(source.path, edited('{}\\n', keys, value))\n return { ...made, changed: true, created: true }\n }\n const manifest = await files.text(source.path)\n if (manifest === undefined)\n throw new NoConfigFileError(root, { namespace, key, json: jsonFilesOf(options)[0] })\n await files.write(source.path, edited(manifest, [key, ...keys], value))\n return { ...made, changed: true, created: true }\n}\n\n/**\n * Take away the value at `path` of the configuration of the project in `folder`, in the file in\n * use: a JSON file of the names (`<namespace>.config.json` by default) or the key of package.json\n * (the namespace by default). Nothing is written when no value is there, or no configuration:\n * `changed` is false. An object it leaves empty stays. Throws a `ConfigInCodeError` when the\n * configuration is code, and a `ConfigFileMismatchError` when the file named is not the one in use.\n */\nexport async function unsetConfigValue(\n folder: string,\n path: ConfigPath,\n options: WriteOptions\n): Promise<ConfigWrite> {\n checked(path)\n const target = await targetOf(folder, options)\n const { root, key, source, ignored } = target\n if (source === undefined)\n return {\n root,\n key,\n source,\n ignored,\n path,\n previous: undefined,\n value: undefined,\n changed: false,\n created: false\n }\n return writeAt({ root, key, source, ignored }, path, undefined, filesOf(options.platform))\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wtf/project-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Read and write a project's configuration of its tools: one object under a namespace, wtf by default, with a section for each tool, in wtf.config.{mjs,js,ts,json} or the wtf key of package.json, the first found. Find it (./locate); load it, asynchronously with code, or synchronously of JSON and package.json alone (./load); read a tool's section, checked by its Standard Schema, a JSON Schema or a function, with WTF_<SECTION>_<KEY> variables over it (./section, ./env); replace ${env:NAME} placeholders (./placeholder); get a value by its path (./path); write a value (./write); the JSON Schema of the whole (./schema); a code config, typed (./define); Node's platform and loads (./node); and the errors (./errors).",
|
|
5
|
+
"homepage": "https://gitlab.com/wetryfun/project/project/-/tree/main/packages/project-config",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://gitlab.com/wetryfun/project/project/-/issues"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
10
|
+
"author": "Mikael Karon <mikael@karon.se>",
|
|
6
11
|
"repository": {
|
|
7
12
|
"type": "git",
|
|
8
|
-
"url": "git+https://gitlab.com/wetryfun/project/project.git"
|
|
13
|
+
"url": "git+https://gitlab.com/wetryfun/project/project.git",
|
|
14
|
+
"directory": "packages/project-config"
|
|
9
15
|
},
|
|
10
16
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
]
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./locate": {
|
|
26
|
+
"types": "./dist/locate.d.ts",
|
|
27
|
+
"default": "./dist/locate.js"
|
|
28
|
+
},
|
|
29
|
+
"./load": {
|
|
30
|
+
"types": "./dist/load.d.ts",
|
|
31
|
+
"default": "./dist/load.js"
|
|
32
|
+
},
|
|
33
|
+
"./section": {
|
|
34
|
+
"types": "./dist/section.d.ts",
|
|
35
|
+
"default": "./dist/section.js"
|
|
36
|
+
},
|
|
37
|
+
"./env": {
|
|
38
|
+
"types": "./dist/env.d.ts",
|
|
39
|
+
"default": "./dist/env.js"
|
|
40
|
+
},
|
|
41
|
+
"./placeholder": {
|
|
42
|
+
"types": "./dist/placeholder.d.ts",
|
|
43
|
+
"default": "./dist/placeholder.js"
|
|
44
|
+
},
|
|
45
|
+
"./path": {
|
|
46
|
+
"types": "./dist/path.d.ts",
|
|
47
|
+
"default": "./dist/path.js"
|
|
48
|
+
},
|
|
49
|
+
"./write": {
|
|
50
|
+
"types": "./dist/write.d.ts",
|
|
51
|
+
"default": "./dist/write.js"
|
|
52
|
+
},
|
|
53
|
+
"./schema": {
|
|
54
|
+
"types": "./dist/schema.d.ts",
|
|
55
|
+
"default": "./dist/schema.js"
|
|
56
|
+
},
|
|
57
|
+
"./define": {
|
|
58
|
+
"types": "./dist/define.d.ts",
|
|
59
|
+
"default": "./dist/define.js"
|
|
60
|
+
},
|
|
61
|
+
"./node": {
|
|
62
|
+
"types": "./dist/node.d.ts",
|
|
63
|
+
"default": "./dist/node.js"
|
|
64
|
+
},
|
|
65
|
+
"./errors": {
|
|
66
|
+
"types": "./dist/errors.d.ts",
|
|
67
|
+
"default": "./dist/errors.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "tsc -b"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@standard-schema/spec": "^1.1.0",
|
|
78
|
+
"@wtf/platform": "^2.0.0",
|
|
79
|
+
"@wtf/platform-fs": "^1.1.0",
|
|
80
|
+
"@wtf/platform-fs-node": "^1.1.0",
|
|
81
|
+
"@wtf/platform-node": "^2.0.0",
|
|
82
|
+
"ajv": "^8.20.0",
|
|
83
|
+
"jsonc-parser": "^3.3.1"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@wtf/platform-fs-memory": "^1.1.0"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=24.15.0"
|
|
90
|
+
}
|
|
13
91
|
}
|