@ms-cloudpack/json-utilities 0.0.4 → 0.0.6
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/lib/index.js.map +1 -1
- package/lib/readJson.js +3 -2
- package/lib/readJson.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/writeJson.js +2 -2
- package/lib/writeJson.js.map +1 -1
- package/package.json +3 -3
- package/CHANGELOG.json +0 -118
- package/CHANGELOG.md +0 -29
package/lib/index.js.map
CHANGED
|
@@ -1 +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"}
|
|
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","sourcesContent":["export { readJson, readJsonSync } from './readJson.js';\nexport { writeJson, writeJsonSync } from './writeJson.js';\n"]}
|
package/lib/readJson.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
|
|
2
|
+
// NOTE: Importing the whole module (not named exports) is required to make Jest mocks work elsewhere.
|
|
3
|
+
import fsPromises from 'fs/promises';
|
|
3
4
|
/**
|
|
4
5
|
* Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.
|
|
5
6
|
*/
|
|
6
7
|
export async function readJson(path) {
|
|
7
8
|
let result = undefined;
|
|
8
9
|
try {
|
|
9
|
-
result = JSON.parse(await readFile(path, 'utf8'));
|
|
10
|
+
result = JSON.parse(await fsPromises.readFile(path, 'utf8'));
|
|
10
11
|
}
|
|
11
12
|
catch {
|
|
12
13
|
/* no-op */
|
package/lib/readJson.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readJson.js","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"readJson.js","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,sGAAsG;AACtG,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC;;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,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAU,CAAC;KACvE;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","sourcesContent":["import fs from 'fs';\n// NOTE: Importing the whole module (not named exports) is required to make Jest mocks work elsewhere.\nimport fsPromises from 'fs/promises';\n\n/**\n * Reads JSON from a path and returns the object, or undefined if it does not exist or is unparsable.\n */\nexport async function readJson<TData>(path: string): Promise<TData | undefined> {\n let result: TData | undefined = undefined;\n\n try {\n result = JSON.parse(await fsPromises.readFile(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n\n/**\n * Synchronously reads JSON from a path and returns the object, or undefined if it does not exist\n * or is unparsable.\n */\nexport function readJsonSync<TData>(path: string): TData | undefined {\n let result: TData | undefined = undefined;\n\n try {\n result = JSON.parse(fs.readFileSync(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/lib/writeJson.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import fsPromises from 'fs/promises';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { ensureDir, ensureDirSync } from 'fs-extra';
|
|
4
|
-
const { writeFile } = fs.promises;
|
|
5
5
|
/**
|
|
6
6
|
* Writes json to a path. Ensures the path exists.
|
|
7
7
|
*/
|
|
@@ -9,7 +9,7 @@ const { writeFile } = fs.promises;
|
|
|
9
9
|
export async function writeJson(filePath, data) {
|
|
10
10
|
const folderPath = path.dirname(filePath);
|
|
11
11
|
await ensureDir(folderPath);
|
|
12
|
-
await writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
12
|
+
await fsPromises.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Synchronously writes json to a path. Ensures the path exists.
|
package/lib/writeJson.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeJson.js","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"writeJson.js","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD;;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,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9E,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","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { ensureDir, ensureDirSync } from 'fs-extra';\n\n/**\n * Writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function writeJson(filePath: string, data: any): Promise<void> {\n const folderPath = path.dirname(filePath);\n\n await ensureDir(folderPath);\n await fsPromises.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n\n/**\n * Synchronously writes json to a path. Ensures the path exists.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function writeJsonSync(filePath: string, data: any): void {\n const folderPath = path.dirname(filePath);\n\n ensureDirSync(folderPath);\n fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/json-utilities",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Helpers for reading/writing json files.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"fs-extra": "^
|
|
16
|
+
"fs-extra": "^11.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@ms-cloudpack/eslint-config-base": "*",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"lint": "cloudpack-scripts lint"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
|
-
"
|
|
31
|
+
"lib/**/!(*.test.*)"
|
|
32
32
|
]
|
|
33
33
|
}
|
package/CHANGELOG.json
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ms-cloudpack/json-utilities",
|
|
3
|
-
"entries": [
|
|
4
|
-
{
|
|
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",
|
|
81
|
-
"tag": "@ms-cloudpack/json-utilities_v0.0.3",
|
|
82
|
-
"version": "0.0.3",
|
|
83
|
-
"comments": {
|
|
84
|
-
"none": [
|
|
85
|
-
{
|
|
86
|
-
"author": "dzearing@microsoft.com",
|
|
87
|
-
"package": "@ms-cloudpack/json-utilities",
|
|
88
|
-
"commit": "e68680ba160469e2aad19a0c1ef20de03bced434",
|
|
89
|
-
"comment": "removing changes."
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"patch": [
|
|
93
|
-
{
|
|
94
|
-
"author": "bot@renovateapp.com",
|
|
95
|
-
"package": "@ms-cloudpack/json-utilities",
|
|
96
|
-
"commit": "e68680ba160469e2aad19a0c1ef20de03bced434",
|
|
97
|
-
"comment": "Cleaning up problems found with depcheck"
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"date": "Mon, 09 May 2022 18:54:56 GMT",
|
|
104
|
-
"tag": "@ms-cloudpack/json-utilities_v0.0.2",
|
|
105
|
-
"version": "0.0.2",
|
|
106
|
-
"comments": {
|
|
107
|
-
"patch": [
|
|
108
|
-
{
|
|
109
|
-
"author": "dzearing@microsoft.com",
|
|
110
|
-
"package": "@ms-cloudpack/json-utilities",
|
|
111
|
-
"commit": "13c322180c016e6c653d4694b9f3380adeb8ad6f",
|
|
112
|
-
"comment": "Initial publish."
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Change Log - @ms-cloudpack/json-utilities
|
|
2
|
-
|
|
3
|
-
This log was last generated on Thu, 29 Sep 2022 17:46:14 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
<!-- Start content -->
|
|
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
|
-
|
|
15
|
-
## 0.0.3
|
|
16
|
-
|
|
17
|
-
Mon, 09 May 2022 23:39:35 GMT
|
|
18
|
-
|
|
19
|
-
### Patches
|
|
20
|
-
|
|
21
|
-
- Cleaning up problems found with depcheck (bot@renovateapp.com)
|
|
22
|
-
|
|
23
|
-
## 0.0.2
|
|
24
|
-
|
|
25
|
-
Mon, 09 May 2022 18:54:56 GMT
|
|
26
|
-
|
|
27
|
-
### Patches
|
|
28
|
-
|
|
29
|
-
- Initial publish. (dzearing@microsoft.com)
|