configuration-management 0.1.4 → 0.1.6
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 +24 -7
- package/package.json +8 -5
- package/scripts/build-web.js +49 -0
- package/scripts/setup.js +260 -0
- package/scripts/templates/exc-runtime.js +14 -0
- package/scripts/templates/web-src-index.html +16 -0
- package/scripts/templates/web-src-index.js +61 -0
- package/web/dist/index.js +2717 -0
- package/web/index.js +1 -3
- package/scripts/setup-app-config.js +0 -154
- package/web/styles.css +0 -1
package/web/index.js
CHANGED
|
@@ -3,6 +3,4 @@ Copyright 2025 Adobe. All rights reserved.
|
|
|
3
3
|
Licensed under the Apache License, Version 2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
// (directory index), without relying on package.json "exports" subpaths.
|
|
8
|
-
export * from './src/index.js'
|
|
6
|
+
export * from './dist/index.js'
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2025 Adobe. All rights reserved.
|
|
4
|
-
Licensed under the Apache License, Version 2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs')
|
|
8
|
-
const path = require('path')
|
|
9
|
-
|
|
10
|
-
const EXTENSION_POINT = 'commerce/backend-ui/1'
|
|
11
|
-
const INCLUDE_REL = 'node_modules/configuration-management/actions/configurations/ext.config.yaml'
|
|
12
|
-
const MARKER = '# configuration-management (auto-linked on npm install)'
|
|
13
|
-
|
|
14
|
-
function escapeRe (str) {
|
|
15
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function findProjectRoot (startDir) {
|
|
19
|
-
let dir = startDir
|
|
20
|
-
while (dir && dir !== path.dirname(dir)) {
|
|
21
|
-
if (fs.existsSync(path.join(dir, 'app.config.yaml'))) {
|
|
22
|
-
return dir
|
|
23
|
-
}
|
|
24
|
-
dir = path.dirname(dir)
|
|
25
|
-
}
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function resolveProjectRoot () {
|
|
30
|
-
const initCwd = process.env.INIT_CWD
|
|
31
|
-
if (initCwd) {
|
|
32
|
-
const fromInit = findProjectRoot(initCwd)
|
|
33
|
-
if (fromInit) return fromInit
|
|
34
|
-
}
|
|
35
|
-
return findProjectRoot(process.cwd())
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function alreadyLinked (content) {
|
|
39
|
-
return content.includes('configuration-management/actions/configurations/ext.config.yaml')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function hasExtensionPoint (content) {
|
|
43
|
-
return /^[ \t]*commerce\/backend-ui\/1:/m.test(content)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function buildExtensionBlock () {
|
|
47
|
-
return [
|
|
48
|
-
MARKER,
|
|
49
|
-
'extensions:',
|
|
50
|
-
` ${EXTENSION_POINT}:`,
|
|
51
|
-
` $include: ${INCLUDE_REL}`
|
|
52
|
-
].join('\n')
|
|
53
|
-
}
|
|
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
|
-
|
|
75
|
-
function patchAppConfig (content) {
|
|
76
|
-
if (alreadyLinked(content)) {
|
|
77
|
-
return { content, changed: false, reason: 'already-linked' }
|
|
78
|
-
}
|
|
79
|
-
|
|
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}`)
|
|
91
|
-
if (next !== content) {
|
|
92
|
-
return { content: next, changed: true, reason: 'added-under-extensions' }
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
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
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return { content, changed: false, reason: 'no-change' }
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function main () {
|
|
110
|
-
if (process.env.CONFIGURATION_MANAGEMENT_SKIP_SETUP === '1') {
|
|
111
|
-
return
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const projectRoot = resolveProjectRoot()
|
|
115
|
-
if (!projectRoot) {
|
|
116
|
-
console.log(
|
|
117
|
-
'[configuration-management] No app.config.yaml found — skip auto-link. ' +
|
|
118
|
-
'Run `npx configuration-management-setup` after creating your App Builder app.'
|
|
119
|
-
)
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const appConfigPath = path.join(projectRoot, 'app.config.yaml')
|
|
124
|
-
const original = fs.readFileSync(appConfigPath, 'utf8')
|
|
125
|
-
const { content, changed, reason } = patchAppConfig(original)
|
|
126
|
-
|
|
127
|
-
if (!changed) {
|
|
128
|
-
console.log(`[configuration-management] app.config.yaml unchanged (${reason}).`)
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
fs.writeFileSync(appConfigPath, content, 'utf8')
|
|
133
|
-
console.log(
|
|
134
|
-
`[configuration-management] Updated app.config.yaml (${reason}):\n` +
|
|
135
|
-
` $include: ${INCLUDE_REL}`
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (require.main === module) {
|
|
140
|
-
try {
|
|
141
|
-
main()
|
|
142
|
-
} catch (err) {
|
|
143
|
-
console.error('[configuration-management] setup failed:', err.message)
|
|
144
|
-
process.exitCode = 1
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
module.exports = {
|
|
149
|
-
patchAppConfig,
|
|
150
|
-
INCLUDE_REL,
|
|
151
|
-
EXTENSION_POINT,
|
|
152
|
-
alreadyLinked,
|
|
153
|
-
hasExtensionPoint
|
|
154
|
-
}
|
package/web/styles.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import './src/styles/index.css';
|