@minimalstuff/tooling 0.2.1 → 0.3.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 (2) hide show
  1. package/dist/cli/index.mjs +12 -2
  2. package/package.json +2 -1
@@ -6,6 +6,7 @@ import { join } from "node:path";
6
6
  import { existsSync } from "node:fs";
7
7
  import { installPackage } from "@antfu/install-pkg";
8
8
  import { mkdir, readFile, writeFile } from "node:fs/promises";
9
+ import { parse, printParseErrorCode } from "jsonc-parser";
9
10
  import { fileURLToPath } from "node:url";
10
11
  //#region src/constants.ts
11
12
  const TOOLING_PACKAGE_NAME = "@minimalstuff/tooling";
@@ -61,7 +62,16 @@ async function updateVscodeSettings(cwd) {
61
62
  let settings = {};
62
63
  if (existsSync(settingsPath)) {
63
64
  const content = await readFile(settingsPath, "utf-8");
64
- settings = JSON.parse(content);
65
+ const parseErrors = [];
66
+ const parsed = parse(content, parseErrors, {
67
+ allowTrailingComma: true,
68
+ allowEmptyContent: true
69
+ });
70
+ if (parseErrors.length > 0) {
71
+ const detail = parseErrors.map((e) => `${printParseErrorCode(e.error)} @${e.offset}`).join(", ");
72
+ throw new SyntaxError(`Invalid JSONC in ${settingsPath}: ${detail}`);
73
+ }
74
+ if (parsed !== null && parsed !== void 0 && typeof parsed === "object" && !Array.isArray(parsed)) settings = parsed;
65
75
  }
66
76
  for (const [key, value] of Object.entries(vscodeSettings)) if (!(key in settings)) settings[key] = value;
67
77
  await writeFile(settingsPath, JSON.stringify(settings, null, 2));
@@ -76,7 +86,7 @@ async function addScriptsToPackageJson(cwd) {
76
86
  }
77
87
  //#endregion
78
88
  //#region package.json
79
- var version = "0.2.1";
89
+ var version = "0.3.0";
80
90
  //#endregion
81
91
  //#region src/cli/update_pkg.json.ts
82
92
  async function updatePkgJson(_) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimalstuff/tooling",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Shared tooling configs: EditorConfig, OXC (oxlint + oxfmt)",
5
5
  "keywords": [
6
6
  "editorconfig",
@@ -44,6 +44,7 @@
44
44
  "@antfu/install-pkg": "^1.1.0",
45
45
  "@clack/prompts": "^1.0.1",
46
46
  "eslint-plugin-perfectionist": "^5.5.0",
47
+ "jsonc-parser": "^3.3.1",
47
48
  "picocolors": "^1.1.1"
48
49
  },
49
50
  "devDependencies": {