@hszrdm/create-commerce 1.10.0 → 1.10.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/README.md CHANGED
@@ -73,6 +73,12 @@ reproducible production change requests.
73
73
  The updater synchronizes the canonical backend and storefront dependencies,
74
74
  their scripts and shared template files, generated deployment utilities, PM2
75
75
  configuration, and regenerates the **full transitive** `package-lock.json`.
76
+ It also synchronizes the Core's **root npm `overrides`** (Lodash, GraphQL
77
+ Tools and Nodemailer security pins), because npm uses overrides only from the
78
+ customer project's root manifest. Customer-only overrides are preserved; a
79
+ modified Core-managed override reports a conflict rather than being overwritten.
80
+ Use `npm audit --omit=dev --audit-level=high` after the lockfile refresh and
81
+ review any remaining Medusa transitive vulnerabilities before production.
76
82
  It preserves customer-only package dependencies, routes, application code,
77
83
  customized files, and secret-bearing `.env*` files. Nothing modifies the
78
84
  database, running PM2 processes, or the live deployment during this operation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hszrdm/create-commerce",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Create a complete HSZRDM Commerce webshop project.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/cli.mjs CHANGED
@@ -12,7 +12,7 @@ import { dirname, join, resolve } from "node:path"
12
12
  import { fileURLToPath } from "node:url"
13
13
  import { createInterface } from "node:readline/promises"
14
14
  import { stdin as input, stdout as output } from "node:process"
15
- import { generatedRootScripts, writeGeneratedManifest, upgradeFromArgs, renderEcosystemConfig } from "./upgrade.mjs"
15
+ import { generatedRootScripts, generatedRootOverrides, writeGeneratedManifest, upgradeFromArgs, renderEcosystemConfig } from "./upgrade.mjs"
16
16
 
17
17
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
18
18
  const packageVersion = clean(
@@ -230,6 +230,7 @@ function configureProject(root, settings) {
230
230
  engines: { node: "22.x" },
231
231
  workspaces: ["backend", "storefront"],
232
232
  scripts: generatedRootScripts(),
233
+ overrides: generatedRootOverrides(),
233
234
  }
234
235
  writeJson(join(root, "package.json"), rootPackage)
235
236
  mkdirSync(join(root, "scripts"), { recursive: true })
package/src/upgrade.mjs CHANGED
@@ -67,6 +67,16 @@ export function renderEcosystemConfig(settings) {
67
67
  `
68
68
  }
69
69
 
70
+ // Root-level npm overrides are required to secure the full transitive dependency
71
+ // graph. npm does not inherit overrides from @hszrdm/core's package.json.
72
+ export function generatedRootOverrides() {
73
+ return {
74
+ "lodash": "4.18.1",
75
+ "@graphql-tools/utils": "12.1.0",
76
+ "nodemailer": "10.3.1",
77
+ }
78
+ }
79
+
70
80
  export function generatedRootScripts() {
71
81
  return {
72
82
  "dev:backend": "npm --workspace backend run dev",
@@ -139,6 +149,13 @@ function managedPackageState(root) {
139
149
  result[path] = {
140
150
  scripts: { ...(p.scripts || {}) },
141
151
  deps: packageDeps(p),
152
+ ...(path === "package.json" ? {
153
+ // Only Core-owned pins are part of the managed baseline. Customer-only
154
+ // overrides are never owned by this generator.
155
+ overrides: Object.fromEntries(Object.keys(generatedRootOverrides())
156
+ .filter((key) => Object.prototype.hasOwnProperty.call(p.overrides || {}, key))
157
+ .map((key) => [key, p.overrides[key]])),
158
+ } : {}),
142
159
  }
143
160
  }
144
161
  return result
@@ -158,7 +175,7 @@ export function writeGeneratedManifest(root, version) {
158
175
  }
159
176
 
160
177
  function expectedPackage(path, version) {
161
- if (path === "package.json") return { scripts: generatedRootScripts() }
178
+ if (path === "package.json") return { scripts: generatedRootScripts(), overrides: generatedRootOverrides() }
162
179
  const packagePath = join(PACKAGE_ROOT, "templates", path)
163
180
  const pkg = readJson(packagePath)
164
181
  if (path === "backend/package.json") {
@@ -260,6 +277,25 @@ export function planUpgrade(root, version) {
260
277
  else conflicts.push(path + ":obsolete " + group + "." + key)
261
278
  }
262
279
  }
280
+ // Root npm overrides are the only reliable way to pin deeply nested
281
+ // vulnerable dependencies in generated customer shops.
282
+ if (path === "package.json") {
283
+ merged.overrides ||= {}
284
+ for (const [key, nextValue] of Object.entries(desired.overrides || {})) {
285
+ const currentValue = current.overrides?.[key]
286
+ const oldValue = base?.overrides?.[key]
287
+ // A pre-existing override with no Core-owned baseline is a customer
288
+ // choice, not a safe value to silently replace. If Core previously
289
+ // owned the key, update only when its value is still unchanged.
290
+ if (currentValue !== undefined && currentValue !== nextValue &&
291
+ (oldValue === undefined || currentValue !== oldValue)) {
292
+ conflicts.push(path + ":overrides." + key)
293
+ } else merged.overrides[key] = nextValue
294
+ }
295
+ // Do not auto-remove a key merely because it appeared in an older
296
+ // manifest: historical manifests may include unrelated customer pins.
297
+ // Unknown/custom overrides must always survive Core upgrades.
298
+ }
263
299
  const oldContent = readFileSync(join(root, path), "utf8")
264
300
  if (json(merged) !== oldContent) changes.push({ kind: "json", path, content: json(merged) })
265
301
  packages[path] = {
@@ -267,6 +303,9 @@ export function planUpgrade(root, version) {
267
303
  deps: Object.fromEntries(["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"].map(k => [
268
304
  k, Object.fromEntries(Object.keys(desired[k] || {}).map(dep => [dep, merged[k][dep]])),
269
305
  ])),
306
+ ...(path === "package.json" ? {
307
+ overrides: Object.fromEntries(Object.keys(desired.overrides || {}).map(key => [key, merged.overrides[key]])),
308
+ } : {}),
270
309
  }
271
310
  }
272
311
 
@@ -12,6 +12,7 @@
12
12
  "start": "medusa start",
13
13
  "typecheck": "npm run env:verify && npm run prepare:project && tsc --noEmit",
14
14
  "core:init": "npm run prepare:project && medusa exec ./src/scripts/core-init.ts",
15
+ "integrations:sync": "npm run prepare:project && medusa exec ./src/scripts/sync-integration-runtime.ts",
15
16
  "core:backup": "node ./scripts/core-backup.mjs --project-dir .",
16
17
  "core:restore": "node ./scripts/core-restore.mjs --project-dir .",
17
18
  "storefront:key": "npm run prepare:project && medusa exec ./src/scripts/create-storefront-key.ts",
@@ -22,7 +23,7 @@
22
23
  "start:prod": "cd .medusa/server && medusa start"
23
24
  },
24
25
  "dependencies": {
25
- "@hszrdm/core": "1.10.0",
26
+ "@hszrdm/core": "1.10.1",
26
27
  "@medusajs/admin-sdk": "2.22.2",
27
28
  "@medusajs/cli": "2.22.2",
28
29
  "@medusajs/draft-order": "2.22.2",
@@ -128,6 +128,9 @@ if (action === "deploy") {
128
128
  npm(["ci"])
129
129
  backup()
130
130
  npm(["run", "db:migrate"])
131
+ // Runtime credentials originate from this deployment\x27s Admin DB, never .env.
132
+ // Regenerate the scoped encrypted cache before PM2 starts the new version.
133
+ npm(["--prefix", backendDir, "run", "integrations:sync"])
131
134
  if (target === "dev") {
132
135
  devServer()
133
136
  } else {
@@ -0,0 +1 @@
1
+ export { default } from "@hszrdm/core/scripts/sync-integration-runtime"