configuration-management 0.1.0 → 0.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configuration-management",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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.",
@@ -28,8 +28,8 @@
28
28
  "./crypto": "./src/system-config-crypto.js",
29
29
  "./shared": "./src/system-config-shared.js",
30
30
  "./oauth1a": "./src/oauth1a.js",
31
- "./web": "./web/src/index.js",
32
- "./web/styles.css": "./web/src/styles/index.css",
31
+ "./web": "./web/index.js",
32
+ "./web/styles.css": "./web/styles.css",
33
33
  "./actions/utils": "./actions/utils.js",
34
34
  "./actions/ext.config.yaml": "./actions/configurations/ext.config.yaml"
35
35
  },
@@ -52,11 +52,11 @@
52
52
  "@adobe/react-spectrum": "^3.30.0",
53
53
  "@adobe/uix-guest": "^0.8.3",
54
54
  "@spectrum-icons/workflow": "^4.2.4",
55
+ "dotenv": "^16.4.5",
55
56
  "react": "^18.2.0",
56
57
  "react-dom": "^18.2.0",
57
58
  "react-error-boundary": "^3.1.4",
58
- "react-router-dom": "^6.8.1",
59
- "dotenv": "^16.4.5"
59
+ "react-router-dom": "^6.8.1"
60
60
  },
61
61
  "dependencies": {
62
62
  "got": "^11.8.5",
@@ -11,6 +11,10 @@ const EXTENSION_POINT = 'commerce/backend-ui/1'
11
11
  const INCLUDE_REL = 'node_modules/configuration-management/actions/configurations/ext.config.yaml'
12
12
  const MARKER = '# configuration-management (auto-linked on npm install)'
13
13
 
14
+ function escapeRe (str) {
15
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
16
+ }
17
+
14
18
  function findProjectRoot (startDir) {
15
19
  let dir = startDir
16
20
  while (dir && dir !== path.dirname(dir)) {
@@ -35,6 +39,10 @@ function alreadyLinked (content) {
35
39
  return content.includes('configuration-management/actions/configurations/ext.config.yaml')
36
40
  }
37
41
 
42
+ function hasExtensionPoint (content) {
43
+ return /^[ \t]*commerce\/backend-ui\/1:/m.test(content)
44
+ }
45
+
38
46
  function buildExtensionBlock () {
39
47
  return [
40
48
  MARKER,
@@ -44,32 +52,58 @@ function buildExtensionBlock () {
44
52
  ].join('\n')
45
53
  }
46
54
 
55
+ /**
56
+ * Update an existing `commerce/backend-ui/1` block in place (never add a duplicate key).
57
+ */
58
+ function updateExistingExtensionBlock (content) {
59
+ const match = content.match(/^([ \t]*)commerce\/backend-ui\/1:/m)
60
+ if (!match) return null
61
+
62
+ const indent = match[1]
63
+ const includeIndent = `${indent} `
64
+ const blockRe = new RegExp(
65
+ `^${escapeRe(indent)}commerce/backend-ui/1:[ \\t]*\\n` +
66
+ `(?:${escapeRe(includeIndent)}\\$include:[^\\n]*\\n)?`,
67
+ 'm'
68
+ )
69
+ const replacement =
70
+ `${indent}${EXTENSION_POINT}:\n${includeIndent}$include: ${INCLUDE_REL}\n`
71
+ const next = content.replace(blockRe, replacement)
72
+ return next !== content ? next : null
73
+ }
74
+
47
75
  function patchAppConfig (content) {
48
76
  if (alreadyLinked(content)) {
49
77
  return { content, changed: false, reason: 'already-linked' }
50
78
  }
51
79
 
52
- if (/^extensions:\s*$/m.test(content) || /^extensions:\n/m.test(content)) {
53
- const injection = [
54
- ` ${EXTENSION_POINT}:`,
55
- ` $include: ${INCLUDE_REL}`
56
- ].join('\n')
57
- const next = content.replace(
58
- /^extensions:\s*\n/m,
59
- `extensions:\n${injection}\n`
60
- )
80
+ if (hasExtensionPoint(content)) {
81
+ const updated = updateExistingExtensionBlock(content)
82
+ if (updated) {
83
+ return { content: updated, changed: true, reason: 'updated-existing-extension' }
84
+ }
85
+ return { content, changed: false, reason: 'extension-exists-unmodified' }
86
+ }
87
+
88
+ if (/^extensions:[ \t]*\n/m.test(content)) {
89
+ const injection = ` ${EXTENSION_POINT}:\n $include: ${INCLUDE_REL}\n`
90
+ const next = content.replace(/^extensions:[ \t]*\n/m, `extensions:\n${injection}`)
61
91
  if (next !== content) {
62
- return { content: next, changed: true, reason: 'merged-into-extensions' }
92
+ return { content: next, changed: true, reason: 'added-under-extensions' }
63
93
  }
64
94
  }
65
95
 
66
- const trimmed = content.replace(/\s+$/, '')
67
- const separator = trimmed.length > 0 ? '\n\n' : ''
68
- return {
69
- content: `${trimmed}${separator}${buildExtensionBlock()}\n`,
70
- changed: true,
71
- reason: 'appended'
96
+ if (!/^extensions:/m.test(content)) {
97
+ const trimmed = content.replace(/\s+$/, '')
98
+ const separator = trimmed.length > 0 ? '\n\n' : ''
99
+ return {
100
+ content: `${trimmed}${separator}${buildExtensionBlock()}\n`,
101
+ changed: true,
102
+ reason: 'appended'
103
+ }
72
104
  }
105
+
106
+ return { content, changed: false, reason: 'no-change' }
73
107
  }
74
108
 
75
109
  function main () {
@@ -91,7 +125,7 @@ function main () {
91
125
  const { content, changed, reason } = patchAppConfig(original)
92
126
 
93
127
  if (!changed) {
94
- console.log(`[configuration-management] app.config.yaml already links actions (${reason}).`)
128
+ console.log(`[configuration-management] app.config.yaml unchanged (${reason}).`)
95
129
  return
96
130
  }
97
131
 
@@ -111,4 +145,10 @@ if (require.main === module) {
111
145
  }
112
146
  }
113
147
 
114
- module.exports = { patchAppConfig, INCLUDE_REL, EXTENSION_POINT }
148
+ module.exports = {
149
+ patchAppConfig,
150
+ INCLUDE_REL,
151
+ EXTENSION_POINT,
152
+ alreadyLinked,
153
+ hasExtensionPoint
154
+ }
package/web/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /*
2
+ Copyright 2025 Adobe. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0
4
+ */
5
+
6
+ // Parcel / App Builder resolve `configuration-management/web` as this file
7
+ // (directory index), without relying on package.json "exports" subpaths.
8
+ export * from './src/index.js'
package/web/styles.css ADDED
@@ -0,0 +1 @@
1
+ @import './src/styles/index.css';