elrh-cosca 0.3.2 → 0.3.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  # COSCA
2
- Library of file-writting functions that help building CLI scripts for making changes in target projects - like adding default configuration files or new sections in `package.json`.
2
+ Library of file-writing functions that help building CLI scripts for making changes in target projects - like adding default configuration files or new sections in `package.json`.
3
3
 
4
4
  The first experimental "customers" are my [Nuxt Spec](https://github.com/AloisSeckar/nuxt-spec) and [Nuxt Ignis](https://github.com/AloisSeckar/nuxt-ignis) projects.
5
5
 
@@ -27,12 +27,12 @@ Path to `templateFile` must be prefixed with the package name to allow proper re
27
27
 
28
28
  Path to `targetFile` is relative to `process.cwd()` which allows consumers to run `npx your-script` in their project roots during development. Several checks are in place to prevent accidental and malicious paths being passed in. Path traversal outside of CWD or providing absolute paths is disallowed. If the target directory does not exist, it will be automatically created.
29
29
 
30
- By default the function asks for confirmation before attempting to create the file and if the file with the same name as `targetFile` is detected. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
30
+ By default the function asks for confirmation before attempting to create the file and if the file with the same name as `targetFile` is detected. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
31
31
 
32
32
  #### `createFileFromWebTemplate`
33
33
 
34
34
  ```ts
35
- async function createFileWebFromTemplate(
35
+ async function createFileFromWebTemplate(
36
36
  url: string, targetFile: string, force: boolean = false, prompt: string = ''
37
37
  ): Promise<void>
38
38
  ```
@@ -43,7 +43,7 @@ Contents of `url` must be accessible via `node:https.get` function and will be f
43
43
 
44
44
  Path to `targetFile` is relative to `process.cwd()` which allows consumers to run `npx your-script` in their project roots during development. Several checks are in place to prevent accidental and malicious paths being passed in. Path traversal outside of CWD or providing absolute paths is disallowed. If the target directory does not exist, it will be automatically created.
45
45
 
46
- By default the function asks for confirmation before attempting to create the file and if the file with the same name as `targetFile` is detected. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
46
+ By default the function asks for confirmation before attempting to create the file and if the file with the same name as `targetFile` is detected. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
47
47
 
48
48
  #### `updateConfigFile`
49
49
 
@@ -75,7 +75,7 @@ TypeError: 'set' on proxy: trap returned falsish for property '<YOUR_PROPERTY>'
75
75
  If possible, you need to alter your logic, e.g. by creating a new object via the spread operator.
76
76
 
77
77
 
78
- By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
78
+ By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
79
79
 
80
80
  #### `updateJsonFile`
81
81
 
@@ -99,7 +99,7 @@ Path to `targetFile` is relative to `process.cwd()`. Several checks are in place
99
99
 
100
100
  Currently it only allows adding new values under top-level keys. If the `jsonKey` exists, new values are merged into existing ones. Otherwise, new key is added. The function tracks if any real change was made and notifies the user if not.
101
101
 
102
- By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
102
+ By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
103
103
 
104
104
  #### `updateTextFile`
105
105
 
@@ -113,7 +113,7 @@ Takes a path to a plain text file and injects `rowsToAdd` at the end of the file
113
113
 
114
114
  Path to `targetFile` is relative to `process.cwd()`. Several checks are in place to prevent accidental and malicious paths being passed in. Path traversal outside of CWD or providing absolute paths is disallowed.
115
115
 
116
- By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
116
+ By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
117
117
 
118
118
  #### `removeFromJsonFile`
119
119
 
@@ -129,7 +129,7 @@ Path to `targetFile` is relative to `process.cwd()`. Several checks are in place
129
129
 
130
130
  Given `jsonKey` might point to a nested key using dot notation, e.g. `a.b.c`. If the key is not present, the function does nothing.
131
131
 
132
- By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
132
+ By default the function asks for confirmation before attempting to alter the `targetFile`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
133
133
 
134
134
  #### `deletePath`
135
135
 
@@ -143,7 +143,7 @@ Deletes given `targetPath` from FS. Path is resolved relatively to `process.cwd(
143
143
 
144
144
  If the `targetPath` does not exist, the function does nothing.
145
145
 
146
- By default the function asks for confirmation before attempting to delete the `targetPath`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passsing a custom `prompt` allows tailoring your own question to the user.
146
+ By default the function asks for confirmation before attempting to delete the `targetPath`. Setting the last optional parameter `force` to `true` will suppress manual confirmation prompts. Passing a custom `prompt` allows tailoring your own question to the user.
147
147
 
148
148
  ### List of content checkers
149
149
 
@@ -4,7 +4,7 @@ import Da from "node:readline";
4
4
  import Ma from "node:https";
5
5
  import "fs";
6
6
  function _e(a) {
7
- if (console.warn(a), !a)
7
+ if (!a)
8
8
  return { valid: !1, error: "Path cannot be empty" };
9
9
  if (/^[A-Za-z]:/.test(a) || a.startsWith("/"))
10
10
  return { valid: !1, error: `Path must be relative to CWD: '${a}'` };
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Deletes given path from FS.
3
3
  *
4
- * @param {string} targetPath - The path to the JSON file to update (relative to CWD).
5
- * @param {boolean} force - Whether to force the update without prompting.
4
+ * @param {string} targetPath - The path to delete (relative to CWD).
5
+ * @param {boolean} force - Whether to force the deletion without prompting.
6
6
  * @param {string} prompt - Custom prompt message displayed in terminal.
7
- * @returns {Promise<void>} An empty promise that resolves when the file is updated.
8
- * @throws Will throw an error if the path is invalid, the file does not exist or cannot be parsed as JSON.
7
+ * @returns {Promise<void>} An empty promise that resolves when the path is deleted.
8
+ * @throws Will throw an error if the path is invalid.
9
9
  */
10
10
  export declare function deletePath(targetPath: string, force?: boolean, prompt?: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elrh-cosca",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -18,10 +18,10 @@
18
18
  "module": "./dist/elrh-cosca.mjs",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "devDependencies": {
21
- "@types/node": "^24.3.0",
21
+ "@types/node": "^24.6.0",
22
22
  "magicast": "^0.3.5",
23
- "typescript": "^5.9.2",
24
- "vite": "^7.1.3",
23
+ "typescript": "^5.9.3",
24
+ "vite": "^7.1.8",
25
25
  "vite-plugin-dts": "^4.5.4",
26
26
  "vitest": "^3.2.4"
27
27
  },