@ms-cloudpack/json-utilities 0.0.3 → 0.0.4
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/CHANGELOG.json +76 -1
- package/CHANGELOG.md +10 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/readJson.d.ts +9 -0
- package/lib/readJson.js +30 -0
- package/lib/readJson.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/writeJson.d.ts +8 -0
- package/lib/writeJson.js +23 -0
- package/lib/writeJson.js.map +1 -0
- package/package.json +9 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,82 @@
|
|
|
2
2
|
"name": "@ms-cloudpack/json-utilities",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 29 Sep 2022 17:46:14 GMT",
|
|
6
|
+
"tag": "@ms-cloudpack/json-utilities_v0.0.4",
|
|
7
|
+
"version": "0.0.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "altinokd@microsoft.com",
|
|
12
|
+
"package": "@ms-cloudpack/json-utilities",
|
|
13
|
+
"commit": "c80e6d3f2664fa15c9a8070b944ba660f206974f",
|
|
14
|
+
"comment": "Adding lib folder"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 28 Sep 2022 08:15:16 GMT",
|
|
21
|
+
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
22
|
+
"version": "0.0.3",
|
|
23
|
+
"comments": {
|
|
24
|
+
"none": [
|
|
25
|
+
{
|
|
26
|
+
"author": "elcraig@microsoft.com",
|
|
27
|
+
"package": "@ms-cloudpack/json-utilities",
|
|
28
|
+
"commit": "084168500b6320d6861a4c7e8f363fea9e4f831e",
|
|
29
|
+
"comment": "Fix lint issues with types"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Tue, 20 Sep 2022 08:13:46 GMT",
|
|
36
|
+
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
37
|
+
"version": "0.0.3",
|
|
38
|
+
"comments": {
|
|
39
|
+
"none": [
|
|
40
|
+
{
|
|
41
|
+
"author": "elcraig@microsoft.com",
|
|
42
|
+
"package": "@ms-cloudpack/json-utilities",
|
|
43
|
+
"commit": "52b4314b694af37388821ff5b8a3b16f61b8dc8f",
|
|
44
|
+
"comment": "Hoist commonly used devDependencies to the repo root"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"date": "Fri, 20 May 2022 04:26:15 GMT",
|
|
51
|
+
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
52
|
+
"version": "0.0.3",
|
|
53
|
+
"comments": {
|
|
54
|
+
"none": [
|
|
55
|
+
{
|
|
56
|
+
"author": "dzearing@microsoft.com",
|
|
57
|
+
"package": "@ms-cloudpack/json-utilities",
|
|
58
|
+
"commit": "b39bb143fc53e622c39f9e9fd349f71c9ebadd77",
|
|
59
|
+
"comment": "Adding api:update script."
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"date": "Sat, 14 May 2022 04:36:11 GMT",
|
|
66
|
+
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
67
|
+
"version": "0.0.3",
|
|
68
|
+
"comments": {
|
|
69
|
+
"none": [
|
|
70
|
+
{
|
|
71
|
+
"author": "dzearing@microsoft.com",
|
|
72
|
+
"package": "@ms-cloudpack/json-utilities",
|
|
73
|
+
"commit": "cc0844a7d18790d69e59b16dbd6eef8fab5bc4e0",
|
|
74
|
+
"comment": "Updating package details."
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"date": "Mon, 09 May 2022 23:39:35 GMT",
|
|
6
81
|
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
7
82
|
"version": "0.0.3",
|
|
8
83
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @ms-cloudpack/json-utilities
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 29 Sep 2022 17:46:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.0.4
|
|
8
|
+
|
|
9
|
+
Thu, 29 Sep 2022 17:46:14 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Adding lib folder (altinokd@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.0.3
|
|
8
16
|
|
|
9
|
-
Mon, 09 May 2022 23:39:
|
|
17
|
+
Mon, 09 May 2022 23:39:35 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.
|
|
3
|
+
*/
|
|
4
|
+
export declare function readJson<TData>(path: string): Promise<TData | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Synchronously reads JSON from a path and returns the object, or undefined if it does not exist
|
|
7
|
+
* or is unparsable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readJsonSync<TData>(path: string): TData | undefined;
|
package/lib/readJson.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
const { readFile } = fs.promises;
|
|
3
|
+
/**
|
|
4
|
+
* Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.
|
|
5
|
+
*/
|
|
6
|
+
export async function readJson(path) {
|
|
7
|
+
let result = undefined;
|
|
8
|
+
try {
|
|
9
|
+
result = JSON.parse(await readFile(path, 'utf8'));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
/* no-op */
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Synchronously reads JSON from a path and returns the object, or undefined if it does not exist
|
|
18
|
+
* or is unparsable.
|
|
19
|
+
*/
|
|
20
|
+
export function readJsonSync(path) {
|
|
21
|
+
let result = undefined;
|
|
22
|
+
try {
|
|
23
|
+
result = JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* no-op */
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=readJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readJson.js","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAQ,IAAY;IAChD,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KAC5D;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAQ,IAAY;IAC9C,IAAI,MAAM,GAAsB,SAAS,CAAC;IAE1C,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KAC7D;IAAC,MAAM;QACN,WAAW;KACZ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.31.2"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes json to a path. Ensures the path exists.
|
|
3
|
+
*/
|
|
4
|
+
export declare function writeJson(filePath: string, data: any): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Synchronously writes json to a path. Ensures the path exists.
|
|
7
|
+
*/
|
|
8
|
+
export declare function writeJsonSync(filePath: string, data: any): void;
|
package/lib/writeJson.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { ensureDir, ensureDirSync } from 'fs-extra';
|
|
4
|
+
const { writeFile } = fs.promises;
|
|
5
|
+
/**
|
|
6
|
+
* Writes json to a path. Ensures the path exists.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
export async function writeJson(filePath, data) {
|
|
10
|
+
const folderPath = path.dirname(filePath);
|
|
11
|
+
await ensureDir(folderPath);
|
|
12
|
+
await writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Synchronously writes json to a path. Ensures the path exists.
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
export function writeJsonSync(filePath, data) {
|
|
19
|
+
const folderPath = path.dirname(filePath);
|
|
20
|
+
ensureDirSync(folderPath);
|
|
21
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=writeJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeJson.js","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC;AAElC;;GAEG;AACH,8DAA8D;AAC9D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAS;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;IAC5B,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,IAAS;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1B,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/json-utilities",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Helpers for reading/writing json files.",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"types": "./lib/index.d.ts",
|
|
7
8
|
"sideEffects": false,
|
|
@@ -16,14 +17,15 @@
|
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@ms-cloudpack/eslint-config-base": "*",
|
|
19
|
-
"@ms-cloudpack/scripts": "*"
|
|
20
|
-
"@types/fs-extra": "9.0.13"
|
|
20
|
+
"@ms-cloudpack/scripts": "*"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
23
|
+
"api:update": "cloudpack-scripts api-update",
|
|
24
|
+
"api": "cloudpack-scripts api",
|
|
25
|
+
"build:watch": "cloudpack-scripts build-watch",
|
|
26
|
+
"build": "cloudpack-scripts build",
|
|
27
|
+
"lint:update": "cloudpack-scripts lint-update",
|
|
28
|
+
"lint": "cloudpack-scripts lint"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"/lib"
|