elrh-cosca 0.3.0 → 0.3.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 +38 -0
- package/dist/elrh-cosca.mjs +931 -884
- package/dist/types/checks/file-exists.d.ts +8 -0
- package/dist/types/checks/has-json-key.d.ts +9 -0
- package/dist/types/checks/has-text.d.ts +9 -0
- package/dist/types/functions/create-file-from-template.d.ts +1 -1
- package/dist/types/functions/create-file-from-web-template.d.ts +1 -1
- package/dist/types/functions/delete-path.d.ts +1 -1
- package/dist/types/functions/remove-from-json-file.d.ts +1 -1
- package/dist/types/functions/update-config-file.d.ts +1 -1
- package/dist/types/functions/update-json-file.d.ts +1 -1
- package/dist/types/functions/update-text-file.d.ts +1 -1
- package/dist/types/main.d.ts +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the specified file exists on FS.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} targetFile - The path to the text file to be checked (relative to CWD).
|
|
5
|
+
* @returns {boolean} True if the file exists, false otherwise.
|
|
6
|
+
* @throws Will throw an error if the path is invalid (can't traverse past CWD).
|
|
7
|
+
*/
|
|
8
|
+
export declare function fileExists(targetFile: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a JSON file contains specified key.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} targetFile - The path to the JSON file to be checked (relative to CWD).
|
|
5
|
+
* @param {string} jsonKey - The key in the JSON file to be checked for existence (may use dot notation for nested keys).
|
|
6
|
+
* @returns {boolean} True if the key exists in target file, false otherwise.
|
|
7
|
+
* @throws Will throw an error if the path is invalid, file does not exist or cannot be parsed as JSON.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasJsonKey(targetFile: string, jsonKey: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a text file contains specified row.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} targetFile - The path to the text file to be checked (relative to CWD).
|
|
5
|
+
* @param {string} row - The text row to be checked for existence.
|
|
6
|
+
* @returns {boolean} True if the row exists in target file, false otherwise. Row must be matched completely, but surrounding whitespaces are ignored.
|
|
7
|
+
* @throws Will throw an error if the path is invalid or the file does not exist.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasText(targetFile: string, row: string): boolean;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {boolean} force - Whether to force creation without prompting.
|
|
7
7
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
8
8
|
* @returns {Promise<void>} An empty promise that resolves when the file is created.
|
|
9
|
-
* @throws Will throw an error if the template file cannot be found or the target file failed to be created.
|
|
9
|
+
* @throws Will throw an error if the path is invalid, the template file cannot be found or the target file failed to be created.
|
|
10
10
|
*/
|
|
11
11
|
export declare function createFileFromTemplate(templateFile: string, targetFile: string, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {boolean} force - Whether to force creation without prompting.
|
|
7
7
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
8
8
|
* @returns {Promise<void>} An empty promise that resolves when the file is created.
|
|
9
|
-
* @throws Will throw an error if the remote template cannot be fetched or the target file failed to be created.
|
|
9
|
+
* @throws Will throw an error if the path is invalid, the remote template cannot be fetched or the target file failed to be created.
|
|
10
10
|
*/
|
|
11
11
|
export declare function createFileFromWebTemplate(url: string, targetFile: string, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* @param {boolean} force - Whether to force the update without prompting.
|
|
6
6
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
7
7
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
8
|
-
* @throws Will throw an error if the file does not exist or cannot be parsed as JSON.
|
|
8
|
+
* @throws Will throw an error if the path is invalid, the file does not exist or cannot be parsed as JSON.
|
|
9
9
|
*/
|
|
10
10
|
export declare function deletePath(targetPath: string, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {boolean} force - Whether to force the update without prompting.
|
|
7
7
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
8
8
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
9
|
-
* @throws Will throw an error if the file does not exist or cannot be parsed as JSON.
|
|
9
|
+
* @throws Will throw an error if the path is invalid, the file does not exist or cannot be parsed as JSON.
|
|
10
10
|
*/
|
|
11
11
|
export declare function removeFromJsonFile(targetFile: string, jsonKey: string, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
* @param {string} targetFile - Path to file, relative to project root (process.cwd()).
|
|
10
10
|
* @param {object} newConfig - Config to merge in (takes precedence).
|
|
11
11
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
12
|
-
* @throws Will throw an error
|
|
12
|
+
* @throws Will throw an error the path is invalid, the file doesn't exist or no config export is found or it cannot be processed.
|
|
13
13
|
*/
|
|
14
14
|
export declare function updateConfigFile(targetFile: string, newConfig: Record<string | number | symbol, any>, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -8,6 +8,6 @@ import { JsonValue } from '../types/json.js';
|
|
|
8
8
|
* @param {boolean} force - Whether to force the update without prompting.
|
|
9
9
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
10
10
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
11
|
-
* @throws Will throw an error if the file does not exist or cannot be parsed as JSON.
|
|
11
|
+
* @throws Will throw an error if the path is invalid, the file does not exist or cannot be parsed as JSON.
|
|
12
12
|
*/
|
|
13
13
|
export declare function updateJsonFile(targetFile: string, jsonKey: string, patch: JsonValue, force?: boolean, prompt?: string): Promise<void>;
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {boolean} force - Whether to force the update without prompting.
|
|
7
7
|
* @param {string} prompt - Custom prompt message displayed in terminal.
|
|
8
8
|
* @returns {Promise<void>} An empty promise that resolves when the file is updated.
|
|
9
|
-
* @throws Will throw an error if the file does not exist.
|
|
9
|
+
* @throws Will throw an error if the path is invalid or the file does not exist.
|
|
10
10
|
*/
|
|
11
11
|
export declare function updateTextFile(targetFile: string, rowsToAdd: string[], force?: boolean, prompt?: string): Promise<void>;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { fileExists } from './checks/file-exists';
|
|
2
|
+
import { hasJsonKey } from './checks/has-json-key';
|
|
3
|
+
import { hasText } from './checks/has-text';
|
|
1
4
|
import { createFileFromTemplate } from './functions/create-file-from-template';
|
|
2
5
|
import { createFileFromWebTemplate } from './functions/create-file-from-web-template';
|
|
3
6
|
import { deletePath } from './functions/delete-path';
|
|
@@ -11,4 +14,4 @@ import { showMessage } from './terminal/show-message';
|
|
|
11
14
|
import { getEnvValue } from './utils/get-env-value';
|
|
12
15
|
import { parseQualifiedPath } from './utils/parse-qualified-path';
|
|
13
16
|
import { resolvePackagePath } from './utils/resolve-package-path';
|
|
14
|
-
export { createFileFromTemplate, createFileFromWebTemplate, deletePath, removeFromJsonFile, updateConfigFile, updateJsonFile, updateTextFile, promptUser, showError, showMessage, getEnvValue, parseQualifiedPath, resolvePackagePath, };
|
|
17
|
+
export { fileExists, hasJsonKey, hasText, createFileFromTemplate, createFileFromWebTemplate, deletePath, removeFromJsonFile, updateConfigFile, updateJsonFile, updateTextFile, promptUser, showError, showMessage, getEnvValue, parseQualifiedPath, resolvePackagePath, };
|