@nodesecure/rc 1.3.0 → 1.5.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.
Files changed (39) hide show
  1. package/README.md +75 -20
  2. package/dist/constants.d.ts +2 -2
  3. package/dist/constants.js +2 -2
  4. package/dist/functions/memoize.d.ts +14 -0
  5. package/dist/functions/memoize.js +20 -0
  6. package/dist/functions/memoize.js.map +1 -0
  7. package/dist/functions/read.d.ts +27 -21
  8. package/dist/functions/read.js +33 -31
  9. package/dist/functions/read.js.map +1 -1
  10. package/dist/functions/write.d.ts +19 -19
  11. package/dist/functions/write.js +25 -27
  12. package/dist/functions/write.js.map +1 -1
  13. package/dist/index.d.ts +5 -4
  14. package/dist/index.js +5 -4
  15. package/dist/index.js.map +1 -1
  16. package/dist/projects/ci.d.ts +25 -25
  17. package/dist/projects/ci.js +10 -10
  18. package/dist/projects/report.d.ts +69 -69
  19. package/dist/projects/report.js +32 -32
  20. package/dist/projects/scanner.d.ts +18 -0
  21. package/dist/projects/scanner.js +7 -0
  22. package/dist/projects/scanner.js.map +1 -0
  23. package/dist/rc.d.ts +43 -40
  24. package/dist/rc.js +33 -32
  25. package/dist/rc.js.map +1 -1
  26. package/dist/schema/defs/author.json +13 -0
  27. package/dist/schema/defs/ci.json +58 -58
  28. package/dist/schema/defs/ciWarnings.json +8 -8
  29. package/dist/schema/defs/report.json +98 -98
  30. package/dist/schema/defs/reportChart.json +27 -27
  31. package/dist/schema/defs/scanner.json +12 -0
  32. package/dist/schema/loader.d.ts +1 -1
  33. package/dist/schema/loader.js +19 -19
  34. package/dist/schema/nodesecurerc.json +42 -39
  35. package/dist/utils/index.d.ts +1 -1
  36. package/dist/utils/index.js +1 -1
  37. package/dist/utils/readJSON.d.ts +1 -1
  38. package/dist/utils/readJSON.js +6 -6
  39. package/package.json +16 -17
package/README.md CHANGED
@@ -1,11 +1,21 @@
1
- # rc
2
-
3
- ![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/NodeSecure/rc/master/package.json&query=$.version&label=Version)
4
- [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/NodeSecure/rc/commit-activity)
5
- [![mit](https://img.shields.io/github/license/Naereen/StrapDown.js.svg?style=for-the-badge)](https://github.com/NodeSecure/rc/blob/master/LICENSE)
6
- [![OpenSSF
7
- Scorecard](https://api.securityscorecards.dev/projects/github.com/NodeSecure/rc/badge?style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/NodeSecure/rc)
8
- ![build](https://img.shields.io/github/actions/workflow/status/NodeSecure/rc/main.yml?style=for-the-badge)
1
+ <p align="center">
2
+ <img src="https://user-images.githubusercontent.com/4438263/216045720-779bf16d-1d35-409f-a0e6-4019bda8edde.jpg" alt="@nodesecure/rc">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://github.com/NodeSecure/rc">
7
+ <img src="https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/NodeSecure/rc/master/package.json&query=$.version&label=Version" alt="npm version">
8
+ </a>
9
+ <a href="https://github.com/NodeSecure/rc/blob/master/LICENSE">
10
+ <img src="https://img.shields.io/github/license/NodeSecure/rc.svg?style=for-the-badge" alt="license">
11
+ </a>
12
+ <a href="https://api.securityscorecards.dev/projects/github.com/NodeSecure/rc">
13
+ <img src="https://api.securityscorecards.dev/projects/github.com/NodeSecure/rc/badge?style=for-the-badge" alt="ossf scorecard">
14
+ </a>
15
+ <a href="https://github.com/NodeSecure/rc/actions?query=workflow%3A%22Node.js+CI%22">
16
+ <img src="https://img.shields.io/github/actions/workflow/status/NodeSecure/rc/main.yml?style=for-the-badge" alt="github ci workflow">
17
+ </a>
18
+ </p>
9
19
 
10
20
  NodeSecure runtime configuration.
11
21
 
@@ -25,7 +35,7 @@ $ yarn add @nodesecure/rc
25
35
 
26
36
  ## Usage example
27
37
 
28
- Read:
38
+ read:
29
39
 
30
40
  ```ts
31
41
  import * as RC from "@nodesecure/rc";
@@ -36,7 +46,7 @@ const configurationPayload = (
36
46
  console.log(configurationPayload);
37
47
  ```
38
48
 
39
- Write:
49
+ write:
40
50
 
41
51
  ```ts
42
52
  import assert from "node:assert/strict";
@@ -51,7 +61,23 @@ const result = (await RC.write(void 0, writeOpts)).unwrap();
51
61
  assert.strictEqual(result, void 0);
52
62
  ```
53
63
 
54
- > 👀 .read and .write return Rust like [Result](https://doc.rust-lang.org/std/result/) object. Under the hood we use [ts-results](https://github.com/vultix/ts-results) to achieve this.
64
+ memoize/memoized:
65
+
66
+ ```ts
67
+ import * as RC from "@nodesecure/rc";
68
+ import assert from "node:assert";
69
+
70
+ const configurationPayload = (
71
+ await RC.read(void 0, { createMode: "ci" })
72
+ ).unwrap()
73
+
74
+ RC.memoize(configurationPayload, { overwrite: true });
75
+
76
+ const memoizedPayload = RC.memoized();
77
+ assert.deepEqual(configurationPayload, memoizedPayload);
78
+ ```
79
+
80
+ > 👀 .read and .write return Rust like [Result](https://doc.rust-lang.org/std/result/) object.
55
81
 
56
82
  ## API
57
83
 
@@ -73,6 +99,12 @@ interface createReadOptions {
73
99
  * @default `minimal`
74
100
  */
75
101
  createMode?: RCGenerationMode | RCGenerationMode[];
102
+ /**
103
+ * RC automatic caching option. This option allows to cache a configuration passed in parameter.
104
+ *
105
+ * @default false
106
+ */
107
+ memoize?: boolean;
76
108
  }
77
109
 
78
110
  export type readOptions = RequireAtLeastOne<
@@ -115,6 +147,28 @@ export interface writePartialPayload {
115
147
 
116
148
  export type writeOptions = writeCompletePayload | writePartialPayload;
117
149
  ```
150
+ ### memoize(payload: Partial< RC >, options: memoizeOptions = {}): void
151
+ By default, the memory API overwrites the previous stored payload. When the `OVERWRITE` option is `false`, it merges new properties with existing properties.
152
+
153
+ ```ts
154
+ export interface memoizeOptions {
155
+ overwrite?: boolean;
156
+ }
157
+ ```
158
+ The `overwrite` option is used to specify whether data should be overwritten or merged.
159
+
160
+ ### memoized(options: memoizedOptions): Partial< RC > | null
161
+ This method returns null, when the default value is null, otherwise, it returns the current value of `memoizedValue`.
162
+
163
+ ```ts
164
+ export interface memoizedOptions {
165
+ defaultValue: Partial<RC>;
166
+ }
167
+ ```
168
+ If the `defaultValue` property is at null, then this value will be returned when `memoized` is called.
169
+
170
+ ### clearMemoized(): void
171
+ Clear/reset memoized RC
118
172
 
119
173
  ### homedir(): string
120
174
 
@@ -140,7 +194,7 @@ assert.strictEqual(RC.CONSTANTS.CONFIGURATION_NAME, ".nodesecurerc");
140
194
  We provide by default a configuration generation that we consider `minimal`. On the contrary, a `complete` value will indicate the generation with all possible default keys.
141
195
 
142
196
  ```ts
143
- export type RCGenerationMode = "minimal" | "ci" | "report" | "complete";
197
+ export type RCGenerationMode = "minimal" | "ci" | "report" | "scanner" | "complete";
144
198
  ```
145
199
 
146
200
  However, depending on the NodeSecure tool you are working on, it can be interesting to generate a configuration with some property sets specific to your needs.
@@ -168,9 +222,7 @@ console.log(RC.JSONSchema);
168
222
  ## Contributors ✨
169
223
 
170
224
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
171
-
172
- [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
173
-
225
+ [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
174
226
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
175
227
 
176
228
  Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
@@ -179,11 +231,14 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
179
231
  <!-- prettier-ignore-start -->
180
232
  <!-- markdownlint-disable -->
181
233
  <table>
182
- <tr>
183
- <td align="center"><a href="https://www.linkedin.com/in/thomas-gentilhomme/"><img src="https://avatars.githubusercontent.com/u/4438263?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gentilhomme</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=fraxken" title="Code">💻</a> <a href="https://github.com/NodeSecure/rc/issues?q=author%3Afraxken" title="Bug reports">🐛</a> <a href="https://github.com/NodeSecure/rc/pulls?q=is%3Apr+reviewed-by%3Afraxken" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/NodeSecure/rc/commits?author=fraxken" title="Documentation">📖</a> <a href="#security-fraxken" title="Security">🛡️</a></td>
184
- <td align="center"><a href="https://dev.to/antoinecoulon"><img src="https://avatars.githubusercontent.com/u/43391199?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antoine Coulon</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=antoine-coulon" title="Code">💻</a> <a href="https://github.com/NodeSecure/rc/issues?q=author%3Aantoine-coulon" title="Bug reports">🐛</a> <a href="https://github.com/NodeSecure/rc/pulls?q=is%3Apr+reviewed-by%3Aantoine-coulon" title="Reviewed Pull Requests">👀</a></td>
185
- <td align="center"><a href="https://github.com/PierreDemailly"><img src="https://avatars.githubusercontent.com/u/39910767?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PierreD</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=PierreDemailly" title="Code">💻</a></td>
186
- </tr>
234
+ <tbody>
235
+ <tr>
236
+ <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/thomas-gentilhomme/"><img src="https://avatars.githubusercontent.com/u/4438263?v=4?s=100" width="100px;" alt="Gentilhomme"/><br /><sub><b>Gentilhomme</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=fraxken" title="Code">💻</a> <a href="https://github.com/NodeSecure/rc/issues?q=author%3Afraxken" title="Bug reports">🐛</a> <a href="https://github.com/NodeSecure/rc/pulls?q=is%3Apr+reviewed-by%3Afraxken" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/NodeSecure/rc/commits?author=fraxken" title="Documentation">📖</a> <a href="#security-fraxken" title="Security">🛡️</a></td>
237
+ <td align="center" valign="top" width="14.28%"><a href="https://dev.to/antoinecoulon"><img src="https://avatars.githubusercontent.com/u/43391199?v=4?s=100" width="100px;" alt="Antoine Coulon"/><br /><sub><b>Antoine Coulon</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=antoine-coulon" title="Code">💻</a> <a href="https://github.com/NodeSecure/rc/issues?q=author%3Aantoine-coulon" title="Bug reports">🐛</a> <a href="https://github.com/NodeSecure/rc/pulls?q=is%3Apr+reviewed-by%3Aantoine-coulon" title="Reviewed Pull Requests">👀</a></td>
238
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/PierreDemailly"><img src="https://avatars.githubusercontent.com/u/39910767?v=4?s=100" width="100px;" alt="PierreD"/><br /><sub><b>PierreD</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=PierreDemailly" title="Code">💻</a></td>
239
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/fabnguess"><img src="https://avatars.githubusercontent.com/u/72697416?v=4?s=100" width="100px;" alt="Kouadio Fabrice Nguessan"/><br /><sub><b>Kouadio Fabrice Nguessan</b></sub></a><br /><a href="https://github.com/NodeSecure/rc/commits?author=fabnguess" title="Code">💻</a> <a href="#maintenance-fabnguess" title="Maintenance">🚧</a></td>
240
+ </tr>
241
+ </tbody>
187
242
  </table>
188
243
 
189
244
  <!-- markdownlint-restore -->
@@ -1,2 +1,2 @@
1
- export declare const CONFIGURATION_NAME = ".nodesecurerc";
2
- export declare const GLOBAL_CONFIGURATION_DIRECTORY = "nodesecure";
1
+ export declare const CONFIGURATION_NAME = ".nodesecurerc";
2
+ export declare const GLOBAL_CONFIGURATION_DIRECTORY = "nodesecure";
package/dist/constants.js CHANGED
@@ -1,3 +1,3 @@
1
- export const CONFIGURATION_NAME = ".nodesecurerc";
2
- export const GLOBAL_CONFIGURATION_DIRECTORY = "nodesecure";
1
+ export const CONFIGURATION_NAME = ".nodesecurerc";
2
+ export const GLOBAL_CONFIGURATION_DIRECTORY = "nodesecure";
3
3
  //# sourceMappingURL=constants.js.map
@@ -0,0 +1,14 @@
1
+ import { RC } from "../rc.js";
2
+ export interface memoizeOptions {
3
+ /**
4
+ * If enabled it will overwrite (crush) the previous memoized RC
5
+ * @default true
6
+ */
7
+ overwrite?: boolean;
8
+ }
9
+ export declare function memoize(payload: Partial<RC>, options?: memoizeOptions): void;
10
+ export interface memoizedOptions {
11
+ defaultValue: Partial<RC>;
12
+ }
13
+ export declare function memoized(options?: memoizedOptions): Partial<RC> | null;
14
+ export declare function clearMemoized(): void;
@@ -0,0 +1,20 @@
1
+ // Import Third-party Dependencies
2
+ import merge from "lodash.merge";
3
+ let memoizedValue = null;
4
+ export function memoize(payload, options = {}) {
5
+ const { overwrite = true } = options;
6
+ if (memoizedValue === null || overwrite) {
7
+ memoizedValue = payload;
8
+ }
9
+ else {
10
+ memoizedValue = merge({}, memoizedValue, payload);
11
+ }
12
+ }
13
+ export function memoized(options) {
14
+ const { defaultValue = null } = options ?? {};
15
+ return memoizedValue ?? defaultValue;
16
+ }
17
+ export function clearMemoized() {
18
+ memoizedValue = null;
19
+ }
20
+ //# sourceMappingURL=memoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/functions/memoize.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,KAAK,MAAM,cAAc,CAAC;AAKjC,IAAI,aAAa,GAAuB,IAAI,CAAC;AAU7C,MAAM,UAAU,OAAO,CACrB,OAAoB,EACpB,UAA0B,EAAE;IAE5B,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAErC,IAAI,aAAa,KAAK,IAAI,IAAI,SAAS,EAAE;QACvC,aAAa,GAAG,OAAO,CAAC;KACzB;SACI;QACH,aAAa,GAAG,KAAK,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;KACnD;AACH,CAAC;AAMD,MAAM,UAAU,QAAQ,CACtB,OAAyB;IAEzB,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE9C,OAAO,aAAa,IAAI,YAAY,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC"}
@@ -1,21 +1,27 @@
1
- /// <reference types="node" />
2
- import { Result } from "ts-results";
3
- import { RequireAtLeastOne } from "type-fest";
4
- import { RC, RCGenerationMode } from "../rc.js";
5
- interface createReadOptions {
6
- /**
7
- * If enabled the file will be created if it does not exist on the disk.
8
- *
9
- * @default false
10
- */
11
- createIfDoesNotExist?: boolean;
12
- /**
13
- * RC Generation mode. This option allows to generate a more or less complete configuration for some NodeSecure tools.
14
- *
15
- * @default `minimal`
16
- */
17
- createMode?: RCGenerationMode | RCGenerationMode[];
18
- }
19
- export type readOptions = RequireAtLeastOne<createReadOptions, "createIfDoesNotExist" | "createMode">;
20
- export declare function read(location?: string, options?: readOptions): Promise<Result<RC, NodeJS.ErrnoException>>;
21
- export {};
1
+ /// <reference types="node" />
2
+ import { Result } from "@openally/result";
3
+ import { RequireAtLeastOne } from "type-fest";
4
+ import { RC, RCGenerationMode } from "../rc.js";
5
+ interface createReadOptions {
6
+ /**
7
+ * If enabled the file will be created if it does not exist on the disk.
8
+ *
9
+ * @default false
10
+ */
11
+ createIfDoesNotExist?: boolean;
12
+ /**
13
+ * RC Generation mode. This option allows to generate a more or less complete configuration for some NodeSecure tools.
14
+ *
15
+ * @default `minimal`
16
+ */
17
+ createMode?: RCGenerationMode | RCGenerationMode[];
18
+ /**
19
+ * RC automatic caching option. This option allows to cache a configuration passed in parameter.
20
+ *
21
+ * @default false
22
+ */
23
+ memoize?: boolean;
24
+ }
25
+ export type readOptions = RequireAtLeastOne<createReadOptions, "createIfDoesNotExist" | "createMode">;
26
+ export declare function read(location?: string, options?: readOptions): Promise<Result<RC, NodeJS.ErrnoException>>;
27
+ export {};
@@ -1,32 +1,34 @@
1
- // Import Node.js Dependencies
2
- import path from "node:path";
3
- import { once } from "node:events";
4
- // Import Third-party Dependencies
5
- import Config from "@slimio/config";
6
- import TR from "ts-results";
7
- // Import Internal Dependencies
8
- import { JSONSchema, generateDefaultRC } from "../rc.js";
9
- import * as CONSTANTS from "../constants.js";
10
- // CONSTANTS
11
- const { Ok, Err } = TR;
12
- export async function read(location = process.cwd(), options = Object.create(null)) {
13
- try {
14
- const { createIfDoesNotExist = Boolean(options.createMode), createMode } = options;
15
- const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
16
- const cfg = new Config(cfgPath, {
17
- defaultSchema: JSONSchema,
18
- createOnNoEntry: createIfDoesNotExist
19
- });
20
- await cfg.read(createIfDoesNotExist ? generateDefaultRC(createMode) : void 0);
21
- if (createIfDoesNotExist) {
22
- await once(cfg, "configWritten");
23
- }
24
- const result = cfg.payload;
25
- await cfg.close();
26
- return new Ok(result);
27
- }
28
- catch (error) {
29
- return new Err(error);
30
- }
31
- }
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ import { once } from "node:events";
4
+ // Import Third-party Dependencies
5
+ import Config from "@slimio/config";
6
+ import { Ok, Err } from "@openally/result";
7
+ // Import Internal Dependencies
8
+ import { JSONSchema, generateDefaultRC } from "../rc.js";
9
+ import * as CONSTANTS from "../constants.js";
10
+ import { memoize } from "./memoize.js";
11
+ export async function read(location = process.cwd(), options = Object.create(null)) {
12
+ try {
13
+ const { createIfDoesNotExist = Boolean(options.createMode), createMode, memoize: memoizeRc = false } = options;
14
+ const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
15
+ const cfg = new Config(cfgPath, {
16
+ defaultSchema: JSONSchema,
17
+ createOnNoEntry: createIfDoesNotExist
18
+ });
19
+ await cfg.read(createIfDoesNotExist ? generateDefaultRC(createMode) : void 0);
20
+ if (createIfDoesNotExist) {
21
+ await once(cfg, "configWritten");
22
+ }
23
+ const result = cfg.payload;
24
+ if (memoizeRc) {
25
+ memoize(result);
26
+ }
27
+ await cfg.close();
28
+ return Ok(result);
29
+ }
30
+ catch (error) {
31
+ return Err(error);
32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AAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,oBAAoB,EAAE;YACxB,MAAM,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SAClC;QACD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;QAE3B,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC;SACjB;QAED,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;KACnB;IACD,OAAO,KAAK,EAAE;QACZ,OAAO,GAAG,CAAC,KAA8B,CAAC,CAAC;KAC5C;AACH,CAAC"}
@@ -1,19 +1,19 @@
1
- /// <reference types="node" />
2
- import { Result } from "ts-results";
3
- import { RC } from "../rc.js";
4
- /**
5
- * Overwrite the complete payload. partialUpdate property is mandatory.
6
- */
7
- export interface writeCompletePayload {
8
- payload: RC;
9
- partialUpdate?: false;
10
- }
11
- /**
12
- * Partially update the payload. This implies not to rewrite the content of the file when enabled.
13
- **/
14
- export interface writePartialPayload {
15
- payload: Partial<RC>;
16
- partialUpdate: true;
17
- }
18
- export type writeOptions = writeCompletePayload | writePartialPayload;
19
- export declare function write(location: string | undefined, options: writeOptions): Promise<Result<void, NodeJS.ErrnoException>>;
1
+ /// <reference types="node" />
2
+ import { Result } from "@openally/result";
3
+ import { RC } from "../rc.js";
4
+ /**
5
+ * Overwrite the complete payload. partialUpdate property is mandatory.
6
+ */
7
+ export interface writeCompletePayload {
8
+ payload: RC;
9
+ partialUpdate?: false;
10
+ }
11
+ /**
12
+ * Partially update the payload. This implies not to rewrite the content of the file when enabled.
13
+ **/
14
+ export interface writePartialPayload {
15
+ payload: Partial<RC>;
16
+ partialUpdate: true;
17
+ }
18
+ export type writeOptions = writeCompletePayload | writePartialPayload;
19
+ export declare function write(location: string | undefined, options: writeOptions): Promise<Result<void, NodeJS.ErrnoException>>;
@@ -1,28 +1,26 @@
1
- // Import Node.js Dependencies
2
- import path from "path";
3
- // Import Third-party Dependencies
4
- import Config from "@slimio/config";
5
- import TR from "ts-results";
6
- // Import Internal Dependencies
7
- import { JSONSchema } from "../rc.js";
8
- import * as CONSTANTS from "../constants.js";
9
- // CONSTANTS
10
- const { Ok, Err } = TR;
11
- export async function write(location = process.cwd(), options) {
12
- try {
13
- const { payload, partialUpdate = false } = options;
14
- const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
15
- const cfg = new Config(cfgPath, {
16
- defaultSchema: JSONSchema
17
- });
18
- await cfg.read();
19
- const newPayloadValue = partialUpdate ? Object.assign(cfg.payload, payload) : payload;
20
- cfg.payload = newPayloadValue;
21
- await cfg.close();
22
- return new Ok(void 0);
23
- }
24
- catch (error) {
25
- return new Err(error);
26
- }
27
- }
1
+ // Import Node.js Dependencies
2
+ import path from "path";
3
+ // Import Third-party Dependencies
4
+ import Config from "@slimio/config";
5
+ import { Ok, Err } from "@openally/result";
6
+ // Import Internal Dependencies
7
+ import { JSONSchema } from "../rc.js";
8
+ import * as CONSTANTS from "../constants.js";
9
+ export async function write(location = process.cwd(), options) {
10
+ try {
11
+ const { payload, partialUpdate = false } = options;
12
+ const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
13
+ const cfg = new Config(cfgPath, {
14
+ defaultSchema: JSONSchema
15
+ });
16
+ await cfg.read();
17
+ const newPayloadValue = partialUpdate ? Object.assign(cfg.payload, payload) : payload;
18
+ cfg.payload = newPayloadValue;
19
+ await cfg.close();
20
+ return Ok(void 0);
21
+ }
22
+ catch (error) {
23
+ return Err(error);
24
+ }
25
+ }
28
26
  //# sourceMappingURL=write.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/functions/write.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,kCAAkC;AAClC,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAc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+BAA+B;AAC/B,OAAO,EAAM,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAmB7C,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,EACxB,OAAqB;IAErB,IAAI;QACF,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QAEnD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAK,OAAO,EAAE;YAClC,aAAa,EAAE,UAAU;SAC1B,CAAC,CAAC;QACH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAa,CAAC;QAC5F,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC;QAE9B,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACnB;IACD,OAAO,KAAK,EAAE;QACZ,OAAO,GAAG,CAAC,KAA8B,CAAC,CAAC;KAC5C;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from "./functions/read.js";
2
- export * from "./functions/write.js";
3
- export * as CONSTANTS from "./constants.js";
4
- export { RC, JSONSchema, homedir } from "./rc.js";
1
+ export * from "./functions/read.js";
2
+ export * from "./functions/write.js";
3
+ export * from "./functions/memoize.js";
4
+ export * as CONSTANTS from "./constants.js";
5
+ export { RC, Author, JSONSchema, homedir } from "./rc.js";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export * from "./functions/read.js";
2
- export * from "./functions/write.js";
3
- export * as CONSTANTS from "./constants.js";
4
- export { JSONSchema, homedir } from "./rc.js";
1
+ export * from "./functions/read.js";
2
+ export * from "./functions/write.js";
3
+ export * from "./functions/memoize.js";
4
+ export * as CONSTANTS from "./constants.js";
5
+ export { JSONSchema, homedir } from "./rc.js";
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAM,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAc,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -1,25 +1,25 @@
1
- import * as jsxray from "@nodesecure/js-x-ray";
2
- /**
3
- * Configuration dedicated for NodeSecure CI (or nsci)
4
- * @see https://github.com/NodeSecure/ci
5
- * @see https://github.com/NodeSecure/ci-action
6
- */
7
- export interface CiConfiguration {
8
- /**
9
- * List of enabled reporters
10
- * @see https://github.com/NodeSecure/ci#reporters
11
- */
12
- reporters?: ("console" | "html")[];
13
- vulnerabilities?: {
14
- severity?: "medium" | "high" | "critical" | "all";
15
- };
16
- /**
17
- * JS-X-Ray warnings configuration
18
- * @see https://github.com/NodeSecure/js-x-ray#warnings-legends-v20
19
- */
20
- warnings?: CiWarnings | Record<jsxray.WarningName, CiWarnings>;
21
- }
22
- export type CiWarnings = "off" | "error" | "warning";
23
- export declare function generateCIConfiguration(): {
24
- ci: CiConfiguration;
25
- };
1
+ import * as jsxray from "@nodesecure/js-x-ray";
2
+ /**
3
+ * Configuration dedicated for NodeSecure CI (or nsci)
4
+ * @see https://github.com/NodeSecure/ci
5
+ * @see https://github.com/NodeSecure/ci-action
6
+ */
7
+ export interface CiConfiguration {
8
+ /**
9
+ * List of enabled reporters
10
+ * @see https://github.com/NodeSecure/ci#reporters
11
+ */
12
+ reporters?: ("console" | "html")[];
13
+ vulnerabilities?: {
14
+ severity?: "medium" | "high" | "critical" | "all";
15
+ };
16
+ /**
17
+ * JS-X-Ray warnings configuration
18
+ * @see https://github.com/NodeSecure/js-x-ray#warnings-legends-v20
19
+ */
20
+ warnings?: CiWarnings | Record<jsxray.WarningName, CiWarnings>;
21
+ }
22
+ export type CiWarnings = "off" | "error" | "warning";
23
+ export declare function generateCIConfiguration(): {
24
+ ci: CiConfiguration;
25
+ };
@@ -1,11 +1,11 @@
1
- export function generateCIConfiguration() {
2
- const ci = {
3
- reporters: ["console"],
4
- vulnerabilities: {
5
- severity: "medium"
6
- },
7
- warnings: "error"
8
- };
9
- return { ci };
10
- }
1
+ export function generateCIConfiguration() {
2
+ const ci = {
3
+ reporters: ["console"],
4
+ vulnerabilities: {
5
+ severity: "medium"
6
+ },
7
+ warnings: "error"
8
+ };
9
+ return { ci };
10
+ }
11
11
  //# sourceMappingURL=ci.js.map