@10stars/config 15.0.10 → 15.0.12

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/.oxfmtrc.json CHANGED
@@ -6,13 +6,7 @@
6
6
  "useTabs": false,
7
7
  "bracketSpacing": true,
8
8
  "experimentalSortImports": {
9
- "groups": [
10
- "builtin",
11
- "external",
12
- "internal",
13
- ["parent", "sibling", "index"],
14
- "side-effect"
15
- ],
9
+ "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"], "side-effect"],
16
10
  "newlinesBetween": true,
17
11
  "order": "asc",
18
12
  "ignoreCase": true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10stars/config",
3
- "version": "15.0.10",
3
+ "version": "15.0.12",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "config": "./src/index.ts"
@@ -2,6 +2,12 @@ import fs from "node:fs/promises"
2
2
  import path from "node:path"
3
3
  import { execSync } from "node:child_process"
4
4
 
5
+ // Strip JSONC comments while preserving strings (regex matches strings first to skip them)
6
+ const stripJsoncComments = (jsonc: string): string =>
7
+ jsonc.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (match) =>
8
+ match.startsWith("/") ? "" : match,
9
+ )
10
+
5
11
  const extensionsJson = {
6
12
  recommendations: ["oxc.oxc-vscode"],
7
13
  unwantedRecommendations: [
@@ -94,18 +100,16 @@ export const setupVSCode = async (cwd: string) => {
94
100
  let existingSettings: Record<string, unknown> = {}
95
101
  try {
96
102
  const existingContent = await fs.readFile(settingsPath, "utf8")
97
- // Strip comments (JSONC support)
98
- const jsonWithoutComments = existingContent.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, "")
99
- existingSettings = JSON.parse(jsonWithoutComments)
100
- } catch {
103
+ existingSettings = JSON.parse(stripJsoncComments(existingContent))
104
+ } catch (error) {
105
+ console.error("Error reading or parsing settings.json:", error)
101
106
  // File doesn't exist or is invalid JSON, start fresh
102
107
  }
103
108
 
104
109
  const sortedSettings: Record<string, unknown> = sortObjectKeys(settingsJson)
105
110
 
106
- // Add serverlessConsole.services last (after sorting) to keep it at the bottom
107
- if (existingSettings["serverlessConsole.services"]) {
108
- sortedSettings["serverlessConsole.services"] = existingSettings["serverlessConsole.services"]
111
+ if (existingSettings.serverlessConsole) {
112
+ sortedSettings.serverlessConsole = existingSettings.serverlessConsole // Add serverlessConsole.services last (after sorting) to keep it at the bottom
109
113
  }
110
114
 
111
115
  await fs.writeFile(settingsPath, JSON.stringify(sortedSettings, null, 2) + "\n")