elrh-cosca 0.2.6 → 0.2.8
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 +18 -2
- package/dist/elrh-cosca.mjs +1819 -1816
- package/dist/types/functions/update-json-file.d.ts +9 -2
- package/package.json +1 -1
- package/test/cosca-test.js +1 -0
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
type JsonObject = {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
type JsonArray = JsonValue[];
|
|
6
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
1
7
|
/**
|
|
2
8
|
* Updates a JSON file by modifying a specific key with new values.
|
|
3
9
|
*
|
|
4
10
|
* @param {string} pathToFile - The path to the JSON file to update (relative to CWD).
|
|
5
11
|
* @param {string} jsonKey - The key in the JSON file to update (can be new or existing).
|
|
6
|
-
* @param {
|
|
12
|
+
* @param {JsonPrimitive} patch - The new values to set for the specified key.
|
|
7
13
|
* @param {boolean} force - Whether to force the update without prompting.
|
|
8
14
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
9
15
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
10
16
|
* @throws Will throw an error if the file does not exist or cannot be parsed as JSON.
|
|
11
17
|
*/
|
|
12
|
-
export declare function updateJsonFile(pathToFile: string, jsonKey: string,
|
|
18
|
+
export declare function updateJsonFile(pathToFile: string, jsonKey: string, patch: JsonValue, force?: boolean, prompt?: string): Promise<void>;
|
|
19
|
+
export {};
|
package/package.json
CHANGED
package/test/cosca-test.js
CHANGED
|
@@ -37,6 +37,7 @@ async function main() {
|
|
|
37
37
|
|
|
38
38
|
console.log('\nTest updateJsonFile')
|
|
39
39
|
await updateJsonFile('test/fixtures/json-file.json', 'scripts', { 'cosca' : 'cosca' })
|
|
40
|
+
await updateJsonFile('test/fixtures/json-file.json', 'packageManager', 'pnpm' )
|
|
40
41
|
|
|
41
42
|
console.log('\nTest updateTextFile')
|
|
42
43
|
await updateTextFile('test/fixtures/text-file.txt', ['# COSCA'])
|