@adobedjangir/commerce-admin-management 0.0.13 → 0.0.14
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/package.json +1 -1
- package/scripts/setup.js +101 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobedjangir/commerce-admin-management",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Schema-driven system configuration for Adobe Commerce App Builder sync apps. Magento-style scoped config in Adobe App Builder Database (ABDB) with encryption, Commerce REST helpers, and React Admin UI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Adobe Inc.",
|
package/scripts/setup.js
CHANGED
|
@@ -496,6 +496,93 @@ function stripExcshellSourceDir (projectRoot) {
|
|
|
496
496
|
return { changed, reason: changed ? 'removed' : 'absent' }
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Bump the host's package.json so the React 18 / Spectrum 4 stack we
|
|
501
|
+
* depend on is satisfied without the consumer running a long
|
|
502
|
+
* `npm install --save react@^18 …` chant. We declare these as peers (to
|
|
503
|
+
* avoid shipping duplicate React copies) but a fresh `aio app init` host
|
|
504
|
+
* still pins React 16 — so we patch the host's declared versions here.
|
|
505
|
+
*
|
|
506
|
+
* Strategy:
|
|
507
|
+
* - Only touch entries that are MISSING or pin a version below our floor.
|
|
508
|
+
* - Leave entries already satisfying the floor alone (don't downgrade).
|
|
509
|
+
* - We mutate package.json only; the next `npm install` actually applies
|
|
510
|
+
* the upgrade. We don't re-shell-out to npm from a postinstall — that
|
|
511
|
+
* causes recursive installs and is fragile in workspaces / monorepos.
|
|
512
|
+
*/
|
|
513
|
+
const REQUIRED_HOST_DEPS = {
|
|
514
|
+
// React + DOM — package code uses createRoot/react-dom/client (React 18+).
|
|
515
|
+
'react': '^18.3.1',
|
|
516
|
+
'react-dom': '^18.3.1',
|
|
517
|
+
// React-error-boundary v4 dropped the default export the older versions
|
|
518
|
+
// shipped; we use named imports so v4 is the floor.
|
|
519
|
+
'react-error-boundary': '^4.0.0',
|
|
520
|
+
'react-router-dom': '^6.26.2',
|
|
521
|
+
// Adobe Spectrum trio — must be React-18 compatible.
|
|
522
|
+
'@adobe/react-spectrum': '^3.47.0',
|
|
523
|
+
'@spectrum-icons/workflow': '^4.2.4',
|
|
524
|
+
'@spectrum-icons/ui': '^3.7.1',
|
|
525
|
+
// Adobe app runtime + helpers used by the bootstrap and actions.
|
|
526
|
+
'@adobe/exc-app': '^1.6.0',
|
|
527
|
+
'@adobe/uix-guest': '^0.8.3',
|
|
528
|
+
'@adobe/aio-sdk': '^6.0.0'
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Parse a semver-ish version specifier ("^18.3.1", ">=3.0.0", "16.14.0",
|
|
532
|
+
// "16.14.0 || >=18") and return the lowest concrete major.minor.patch it
|
|
533
|
+
// could resolve to. Returns null for non-numeric specs we can't reason
|
|
534
|
+
// about (workspace:*, file:..., git URLs) — those we leave alone.
|
|
535
|
+
function lowestVersion (spec) {
|
|
536
|
+
if (!spec || typeof spec !== 'string') return null
|
|
537
|
+
const s = spec.split('||')[0].trim() // take the first range in an OR list
|
|
538
|
+
const m = s.match(/(\d+)\.(\d+)\.(\d+)/)
|
|
539
|
+
if (!m) return null
|
|
540
|
+
return { major: +m[1], minor: +m[2], patch: +m[3] }
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function compareVersions (a, b) {
|
|
544
|
+
if (a.major !== b.major) return a.major - b.major
|
|
545
|
+
if (a.minor !== b.minor) return a.minor - b.minor
|
|
546
|
+
return a.patch - b.patch
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function satisfiesFloor (currentSpec, floorSpec) {
|
|
550
|
+
const cur = lowestVersion(currentSpec)
|
|
551
|
+
const min = lowestVersion(floorSpec)
|
|
552
|
+
if (!cur || !min) return false
|
|
553
|
+
return compareVersions(cur, min) >= 0
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function ensureHostDeps (projectRoot) {
|
|
557
|
+
const pkgPath = path.join(projectRoot, 'package.json')
|
|
558
|
+
if (!fs.existsSync(pkgPath)) {
|
|
559
|
+
return { changed: false, reason: 'no-package-json' }
|
|
560
|
+
}
|
|
561
|
+
let pkg
|
|
562
|
+
try { pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) } catch (_) {
|
|
563
|
+
return { changed: false, reason: 'unreadable-package-json' }
|
|
564
|
+
}
|
|
565
|
+
pkg.dependencies = pkg.dependencies || {}
|
|
566
|
+
|
|
567
|
+
const bumped = []
|
|
568
|
+
for (const [name, floor] of Object.entries(REQUIRED_HOST_DEPS)) {
|
|
569
|
+
const declared = pkg.dependencies[name] || (pkg.devDependencies && pkg.devDependencies[name])
|
|
570
|
+
if (declared && satisfiesFloor(declared, floor)) continue
|
|
571
|
+
// Move it to dependencies (out of devDependencies if it was there) and
|
|
572
|
+
// set to the floor.
|
|
573
|
+
pkg.dependencies[name] = floor
|
|
574
|
+
if (pkg.devDependencies && pkg.devDependencies[name]) {
|
|
575
|
+
delete pkg.devDependencies[name]
|
|
576
|
+
}
|
|
577
|
+
bumped.push({ name, was: declared || '(missing)', now: floor })
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (bumped.length === 0) return { changed: false, reason: 'already-satisfies' }
|
|
581
|
+
|
|
582
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
|
|
583
|
+
return { changed: true, bumped }
|
|
584
|
+
}
|
|
585
|
+
|
|
499
586
|
function setupAppConfig (projectRoot) {
|
|
500
587
|
const appConfigPath = path.join(projectRoot, 'app.config.yaml')
|
|
501
588
|
if (!fs.existsSync(appConfigPath)) {
|
|
@@ -539,6 +626,20 @@ function main () {
|
|
|
539
626
|
console.log('[@adobedjangir/commerce-admin-management] removed src/dx-excshell-1/ (replaced by commerce/backend-ui/1)')
|
|
540
627
|
}
|
|
541
628
|
|
|
629
|
+
// Bump host package.json so React-18 + Spectrum-4 peers are satisfied
|
|
630
|
+
// without the consumer running a long `npm install --save react@^18 ...`
|
|
631
|
+
// chant. They still need to run `npm install` once more for npm to
|
|
632
|
+
// resolve the new versions — we can't safely re-shell-out to npm from
|
|
633
|
+
// inside a postinstall.
|
|
634
|
+
const deps = ensureHostDeps(projectRoot)
|
|
635
|
+
if (deps.changed) {
|
|
636
|
+
console.log('[@adobedjangir/commerce-admin-management] bumped host package.json:')
|
|
637
|
+
for (const b of deps.bumped) {
|
|
638
|
+
console.log(` • ${b.name}: ${b.was} → ${b.now}`)
|
|
639
|
+
}
|
|
640
|
+
console.log('[@adobedjangir/commerce-admin-management] run `npm install` once more to apply the upgrades.')
|
|
641
|
+
}
|
|
642
|
+
|
|
542
643
|
const app = setupAppConfig(projectRoot)
|
|
543
644
|
if (app.changed) {
|
|
544
645
|
console.log(
|