tshy 1.11.0 → 1.11.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;;AAWpC,wBAAwB"}
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;;AAkBpC,wBAAwB"}
@@ -1,9 +1,14 @@
1
1
  // get the package.json data for the cwd
2
2
  import { readFileSync } from 'fs';
3
+ import { parse, stringify } from 'polite-json';
3
4
  import fail from './fail.js';
5
+ const isPackage = (pkg) => !!pkg && typeof pkg === 'object' && !Array.isArray(pkg);
4
6
  const readPkg = () => {
5
7
  try {
6
- return JSON.parse(readFileSync('package.json', 'utf8'));
8
+ const res = parse(readFileSync('package.json', 'utf8'));
9
+ if (isPackage(res))
10
+ return res;
11
+ throw new Error('Invalid package.json contents: ' + stringify(res));
7
12
  }
8
13
  catch (er) {
9
14
  fail('failed to read package.json', er);
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,OAAO,GAAG,GAAY,EAAE;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAA;IACzD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,CAAC,6BAA6B,EAAE,EAAW,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,eAAe,OAAO,EAAE,CAAA","sourcesContent":["// get the package.json data for the cwd\n\nimport { readFileSync } from 'fs'\nimport fail from './fail.js'\nimport { Package } from './types.js'\n\nconst readPkg = (): Package => {\n try {\n return JSON.parse(readFileSync('package.json', 'utf8'))\n } catch (er) {\n fail('failed to read package.json', er as Error)\n process.exit(1)\n }\n}\n\nexport default readPkg()\n"]}
1
+ {"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,EAAc,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,SAAS,GAAG,CAAC,GAAe,EAAkB,EAAE,CACpD,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAEzD,MAAM,OAAO,GAAG,GAAY,EAAE;IAC5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAA;QACvD,IAAI,SAAS,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAA;QAC9B,MAAM,IAAI,KAAK,CACb,iCAAiC,GAAG,SAAS,CAAC,GAAG,CAAC,CACnD,CAAA;IACH,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,CAAC,6BAA6B,EAAE,EAAW,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,eAAe,OAAO,EAAE,CAAA","sourcesContent":["// get the package.json data for the cwd\n\nimport { readFileSync } from 'fs'\nimport { JSONResult, parse, stringify } from 'polite-json'\nimport fail from './fail.js'\nimport { Package } from './types.js'\n\nconst isPackage = (pkg: JSONResult): pkg is Package =>\n !!pkg && typeof pkg === 'object' && !Array.isArray(pkg)\n\nconst readPkg = (): Package => {\n try {\n const res = parse(readFileSync('package.json', 'utf8'))\n if (isPackage(res)) return res\n throw new Error(\n 'Invalid package.json contents: ' + stringify(res)\n )\n } catch (er) {\n fail('failed to read package.json', er as Error)\n process.exit(1)\n }\n}\n\nexport default readPkg()\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"write-package.d.ts","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":";AAGA,wBACoE"}
1
+ {"version":3,"file":"write-package.d.ts","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":";AAIA,wBAC+C"}
@@ -1,4 +1,5 @@
1
1
  import { writeFileSync } from 'fs';
2
+ import { stringify } from 'polite-json';
2
3
  import pkg from './package.js';
3
- export default () => writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
4
+ export default () => writeFileSync('package.json', stringify(pkg));
4
5
  //# sourceMappingURL=write-package.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"write-package.js","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,eAAe,GAAG,EAAE,CAClB,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA","sourcesContent":["import { writeFileSync } from 'fs'\nimport pkg from './package.js'\n\nexport default () =>\n writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\\n')\n"]}
1
+ {"version":3,"file":"write-package.js","sourceRoot":"","sources":["../../src/write-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,GAAG,MAAM,cAAc,CAAA;AAE9B,eAAe,GAAG,EAAE,CAClB,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA","sourcesContent":["import { writeFileSync } from 'fs'\nimport {stringify} from 'polite-json'\nimport pkg from './package.js'\n\nexport default () =>\n writeFileSync('package.json', stringify(pkg))\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tshy",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "TypeScript HYbridizer - Hybrid (CommonJS/ESM) TypeScript node package builder",
5
5
  "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
6
6
  "license": "BlueOak-1.0.0",
@@ -14,6 +14,7 @@
14
14
  "chokidar": "^3.5.3",
15
15
  "foreground-child": "^3.1.1",
16
16
  "mkdirp": "^3.0.1",
17
+ "polite-json": "^4.0.1",
17
18
  "resolve-import": "^1.4.4",
18
19
  "rimraf": "^5.0.1",
19
20
  "sync-content": "^1.0.2",