@develit-io/backend-sdk 5.7.0 → 5.8.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.
package/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ const consola = require('consola');
10
10
  const fs = require('fs');
11
11
  const crypto$1 = require('node:crypto');
12
12
  const path = require('path');
13
+ const main_js = require('jsonc-parser/lib/esm/main.js');
13
14
  const superjson = require('superjson');
14
15
 
15
16
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -241,11 +242,11 @@ const getDatabaseIdFromWrangler = () => {
241
242
  try {
242
243
  const wranglerPath = path__default.resolve("./wrangler.jsonc");
243
244
  const wranglerContent = fs__default.readFileSync(wranglerPath, "utf-8");
244
- const cleanContent = wranglerContent.replace(
245
- /\/\*[\s\S]*?\*\/|\/\/.*$/gm,
246
- ""
247
- );
248
- const config = JSON.parse(cleanContent);
245
+ const errors = [];
246
+ const config = main_js.parse(wranglerContent, errors, { allowTrailingComma: true });
247
+ if (errors.length) {
248
+ throw new Error("Invalid JSONC in wrangler.jsonc");
249
+ }
249
250
  const environment = process.env.ENVIRONMENT || "localhost";
250
251
  let databaseId;
251
252
  if (environment !== "localhost" && config.env?.[environment]) {
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@ import { consola } from 'consola';
8
8
  import fs from 'fs';
9
9
  import crypto$1 from 'node:crypto';
10
10
  import path from 'path';
11
+ import { parse } from 'jsonc-parser/lib/esm/main.js';
11
12
  import superjson from 'superjson';
12
13
 
13
14
  const base = {
@@ -219,11 +220,11 @@ const getDatabaseIdFromWrangler = () => {
219
220
  try {
220
221
  const wranglerPath = path.resolve("./wrangler.jsonc");
221
222
  const wranglerContent = fs.readFileSync(wranglerPath, "utf-8");
222
- const cleanContent = wranglerContent.replace(
223
- /\/\*[\s\S]*?\*\/|\/\/.*$/gm,
224
- ""
225
- );
226
- const config = JSON.parse(cleanContent);
223
+ const errors = [];
224
+ const config = parse(wranglerContent, errors, { allowTrailingComma: true });
225
+ if (errors.length) {
226
+ throw new Error("Invalid JSONC in wrangler.jsonc");
227
+ }
227
228
  const environment = process.env.ENVIRONMENT || "localhost";
228
229
  let databaseId;
229
230
  if (environment !== "localhost" && config.env?.[environment]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "5.7.0",
3
+ "version": "5.8.1",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",
@@ -11,6 +11,8 @@
11
11
  "lint": "biome check",
12
12
  "lint:fix": "biome check --fix",
13
13
  "build": "unbuild",
14
+ "test": "vitest",
15
+ "test:unit": "vitest test/unit",
14
16
  "changelogen": "bunx changelogen@latest --bump",
15
17
  "release": "bun run build && bunx changelogen@latest --release --push && npm publish --access public"
16
18
  },
@@ -31,9 +33,13 @@
31
33
  "drizzle-orm": "^0.44.3",
32
34
  "h3": "^1.15.3",
33
35
  "http-status-codes": "2.3.0",
36
+ "jsonc-parser": "^3.3.1",
34
37
  "superjson": "^2.2.2"
35
38
  },
36
39
  "peerDependencies": {
37
40
  "zod": "^4.0.11"
41
+ },
42
+ "devDependencies": {
43
+ "vitest": "^1.6.0"
38
44
  }
39
45
  }