@ms-cloudpack/json-utilities 0.0.5 → 0.0.7

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.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { readJson, readJsonSync } from './readJson.js';
2
2
  export { writeJson, writeJsonSync } from './writeJson.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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"}
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.d.ts CHANGED
@@ -7,3 +7,4 @@ export declare function readJson<TData>(path: string): Promise<TData | undefined
7
7
  * or is unparsable.
8
8
  */
9
9
  export declare function readJsonSync<TData>(path: string): TData | undefined;
10
+ //# sourceMappingURL=readJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readJson.d.ts","sourceRoot":"","sources":["../src/readJson.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAU9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAWnE"}
package/lib/readJson.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import fs from 'fs';
2
- const { readFile } = fs.promises;
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 */
@@ -20,6 +21,7 @@ export async function readJson(path) {
20
21
  export function readJsonSync(path) {
21
22
  let result = undefined;
22
23
  try {
24
+ // eslint-disable-next-line no-restricted-syntax
23
25
  result = JSON.parse(fs.readFileSync(path, 'utf8'));
24
26
  }
25
27
  catch {
@@ -1 +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"}
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,gDAAgD;QAChD,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 // eslint-disable-next-line no-restricted-syntax\n result = JSON.parse(fs.readFileSync(path, 'utf8')) as TData;\n } catch {\n /* no-op */\n }\n\n return result;\n}\n"]}
@@ -1,11 +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.34.3"
9
- }
10
- ]
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.36.1"
9
+ }
10
+ ]
11
+ }
@@ -6,3 +6,4 @@ export declare function writeJson(filePath: string, data: any): Promise<void>;
6
6
  * Synchronously writes json to a path. Ensures the path exists.
7
7
  */
8
8
  export declare function writeJsonSync(filePath: string, data: any): void;
9
+ //# sourceMappingURL=writeJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeJson.d.ts","sourceRoot":"","sources":["../src/writeJson.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1E;AAED;;GAEG;AAEH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAM/D"}
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.
@@ -18,6 +18,7 @@ export async function writeJson(filePath, data) {
18
18
  export function writeJsonSync(filePath, data) {
19
19
  const folderPath = path.dirname(filePath);
20
20
  ensureDirSync(folderPath);
21
+ // eslint-disable-next-line no-restricted-syntax
21
22
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
22
23
  }
23
24
  //# sourceMappingURL=writeJson.js.map
@@ -1 +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,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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 // eslint-disable-next-line no-restricted-syntax\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.5",
3
+ "version": "0.0.7",
4
4
  "description": "Helpers for reading/writing json files.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,11 +16,10 @@
16
16
  "fs-extra": "^11.0.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@ms-cloudpack/eslint-config-base": "*",
19
+ "@ms-cloudpack/eslint-plugin-internal": "*",
20
20
  "@ms-cloudpack/scripts": "*"
21
21
  },
22
22
  "scripts": {
23
- "api:update": "cloudpack-scripts api-update",
24
23
  "api": "cloudpack-scripts api",
25
24
  "build:watch": "cloudpack-scripts build-watch",
26
25
  "build": "cloudpack-scripts build",