@gxp-dev/tools 2.0.62 → 2.0.64
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 +32 -31
- package/bin/gx-devtools.js +74 -54
- package/bin/lib/cli.js +23 -21
- package/bin/lib/commands/add-dependency.js +366 -325
- package/bin/lib/commands/assets.js +137 -139
- package/bin/lib/commands/build.js +169 -174
- package/bin/lib/commands/datastore.js +181 -183
- package/bin/lib/commands/dev.js +127 -131
- package/bin/lib/commands/extensions.js +147 -149
- package/bin/lib/commands/extract-config.js +73 -67
- package/bin/lib/commands/index.js +12 -12
- package/bin/lib/commands/init.js +342 -240
- package/bin/lib/commands/publish.js +69 -75
- package/bin/lib/commands/socket.js +69 -69
- package/bin/lib/commands/ssl.js +14 -14
- package/bin/lib/constants.js +10 -24
- package/bin/lib/tui/App.tsx +761 -705
- package/bin/lib/tui/components/AIPanel.tsx +191 -171
- package/bin/lib/tui/components/CommandInput.tsx +394 -343
- package/bin/lib/tui/components/GeminiPanel.tsx +175 -151
- package/bin/lib/tui/components/Header.tsx +23 -21
- package/bin/lib/tui/components/LogPanel.tsx +244 -220
- package/bin/lib/tui/components/TabBar.tsx +50 -48
- package/bin/lib/tui/components/WelcomeScreen.tsx +126 -71
- package/bin/lib/tui/index.tsx +37 -39
- package/bin/lib/tui/services/AIService.ts +518 -462
- package/bin/lib/tui/services/ExtensionService.ts +140 -129
- package/bin/lib/tui/services/GeminiService.ts +367 -337
- package/bin/lib/tui/services/ServiceManager.ts +344 -322
- package/bin/lib/tui/services/SocketService.ts +168 -168
- package/bin/lib/tui/services/ViteService.ts +88 -88
- package/bin/lib/tui/services/index.ts +47 -22
- package/bin/lib/utils/ai-scaffold.js +291 -280
- package/bin/lib/utils/extract-config.js +157 -140
- package/bin/lib/utils/files.js +82 -86
- package/bin/lib/utils/index.js +7 -7
- package/bin/lib/utils/paths.js +34 -34
- package/bin/lib/utils/prompts.js +194 -169
- package/bin/lib/utils/ssl.js +79 -81
- package/browser-extensions/README.md +0 -1
- package/browser-extensions/chrome/background.js +244 -237
- package/browser-extensions/chrome/content.js +32 -29
- package/browser-extensions/chrome/devtools.html +7 -7
- package/browser-extensions/chrome/devtools.js +19 -19
- package/browser-extensions/chrome/inspector.js +802 -767
- package/browser-extensions/chrome/manifest.json +71 -63
- package/browser-extensions/chrome/panel.html +674 -636
- package/browser-extensions/chrome/panel.js +722 -712
- package/browser-extensions/chrome/popup.html +586 -543
- package/browser-extensions/chrome/popup.js +282 -244
- package/browser-extensions/chrome/rules.json +1 -1
- package/browser-extensions/chrome/test-chrome.html +216 -136
- package/browser-extensions/chrome/test-mixed-content.html +284 -189
- package/browser-extensions/chrome/test-uri-pattern.html +221 -198
- package/browser-extensions/firefox/README.md +9 -6
- package/browser-extensions/firefox/background.js +221 -218
- package/browser-extensions/firefox/content.js +55 -52
- package/browser-extensions/firefox/debug-errors.html +386 -228
- package/browser-extensions/firefox/debug-https.html +153 -105
- package/browser-extensions/firefox/devtools.html +7 -7
- package/browser-extensions/firefox/devtools.js +23 -20
- package/browser-extensions/firefox/inspector.js +802 -767
- package/browser-extensions/firefox/manifest.json +68 -68
- package/browser-extensions/firefox/panel.html +674 -636
- package/browser-extensions/firefox/panel.js +722 -712
- package/browser-extensions/firefox/popup.html +572 -535
- package/browser-extensions/firefox/popup.js +281 -236
- package/browser-extensions/firefox/test-gramercy.html +170 -125
- package/browser-extensions/firefox/test-imports.html +59 -55
- package/browser-extensions/firefox/test-masking.html +231 -140
- package/browser-extensions/firefox/test-uri-pattern.html +221 -198
- package/dist/tui/App.d.ts +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +154 -150
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/components/AIPanel.d.ts.map +1 -1
- package/dist/tui/components/AIPanel.js +42 -35
- package/dist/tui/components/AIPanel.js.map +1 -1
- package/dist/tui/components/CommandInput.d.ts +1 -1
- package/dist/tui/components/CommandInput.d.ts.map +1 -1
- package/dist/tui/components/CommandInput.js +92 -62
- package/dist/tui/components/CommandInput.js.map +1 -1
- package/dist/tui/components/GeminiPanel.d.ts.map +1 -1
- package/dist/tui/components/GeminiPanel.js +37 -30
- package/dist/tui/components/GeminiPanel.js.map +1 -1
- package/dist/tui/components/Header.d.ts.map +1 -1
- package/dist/tui/components/Header.js +1 -1
- package/dist/tui/components/Header.js.map +1 -1
- package/dist/tui/components/LogPanel.d.ts +1 -1
- package/dist/tui/components/LogPanel.d.ts.map +1 -1
- package/dist/tui/components/LogPanel.js +26 -24
- package/dist/tui/components/LogPanel.js.map +1 -1
- package/dist/tui/components/TabBar.d.ts +2 -2
- package/dist/tui/components/TabBar.d.ts.map +1 -1
- package/dist/tui/components/TabBar.js +11 -11
- package/dist/tui/components/TabBar.js.map +1 -1
- package/dist/tui/components/WelcomeScreen.d.ts.map +1 -1
- package/dist/tui/components/WelcomeScreen.js +6 -6
- package/dist/tui/components/WelcomeScreen.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +8 -8
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/services/AIService.d.ts +2 -2
- package/dist/tui/services/AIService.d.ts.map +1 -1
- package/dist/tui/services/AIService.js +165 -125
- package/dist/tui/services/AIService.js.map +1 -1
- package/dist/tui/services/ExtensionService.d.ts +1 -1
- package/dist/tui/services/ExtensionService.d.ts.map +1 -1
- package/dist/tui/services/ExtensionService.js +33 -26
- package/dist/tui/services/ExtensionService.js.map +1 -1
- package/dist/tui/services/GeminiService.d.ts +1 -1
- package/dist/tui/services/GeminiService.d.ts.map +1 -1
- package/dist/tui/services/GeminiService.js +87 -76
- package/dist/tui/services/GeminiService.js.map +1 -1
- package/dist/tui/services/ServiceManager.d.ts +3 -3
- package/dist/tui/services/ServiceManager.d.ts.map +1 -1
- package/dist/tui/services/ServiceManager.js +72 -58
- package/dist/tui/services/ServiceManager.js.map +1 -1
- package/dist/tui/services/SocketService.d.ts.map +1 -1
- package/dist/tui/services/SocketService.js +32 -32
- package/dist/tui/services/SocketService.js.map +1 -1
- package/dist/tui/services/ViteService.d.ts.map +1 -1
- package/dist/tui/services/ViteService.js +26 -28
- package/dist/tui/services/ViteService.js.map +1 -1
- package/dist/tui/services/index.d.ts +6 -6
- package/dist/tui/services/index.d.ts.map +1 -1
- package/dist/tui/services/index.js +6 -6
- package/dist/tui/services/index.js.map +1 -1
- package/mcp/gxp-api-server.js +83 -81
- package/package.json +109 -93
- package/runtime/PortalContainer.vue +258 -234
- package/runtime/dev-tools/DevToolsModal.vue +153 -155
- package/runtime/dev-tools/LayoutSwitcher.vue +144 -140
- package/runtime/dev-tools/MockDataEditor.vue +456 -433
- package/runtime/dev-tools/SocketSimulator.vue +379 -371
- package/runtime/dev-tools/StoreInspector.vue +517 -455
- package/runtime/dev-tools/index.js +5 -5
- package/runtime/fallback-layouts/PrivateLayout.vue +2 -2
- package/runtime/fallback-layouts/PublicLayout.vue +2 -2
- package/runtime/fallback-layouts/SystemLayout.vue +2 -2
- package/runtime/gxpStringsPlugin.js +159 -134
- package/runtime/index.html +17 -19
- package/runtime/main.js +24 -22
- package/runtime/mock-api/auth-middleware.js +15 -15
- package/runtime/mock-api/image-generator.js +46 -46
- package/runtime/mock-api/index.js +55 -55
- package/runtime/mock-api/response-generator.js +116 -105
- package/runtime/mock-api/route-generator.js +107 -84
- package/runtime/mock-api/socket-triggers.js +94 -93
- package/runtime/mock-api/spec-loader.js +79 -80
- package/runtime/package.json +3 -0
- package/runtime/server.js +68 -68
- package/runtime/stores/gxpPortalConfigStore.js +204 -186
- package/runtime/stores/index.js +2 -2
- package/runtime/vite-inspector-plugin.js +858 -707
- package/runtime/vite-source-tracker-plugin.js +132 -113
- package/runtime/vite.config.js +207 -132
- package/scripts/launch-chrome.js +41 -41
- package/scripts/pack-chrome.js +38 -39
- package/socket-events/AiSessionMessageCreated.json +17 -17
- package/socket-events/SocialStreamPostCreated.json +23 -23
- package/socket-events/SocialStreamPostVariantCompleted.json +22 -22
- package/template/.claude/agents/gxp-developer.md +100 -99
- package/template/.claude/settings.json +7 -7
- package/template/AGENTS.md +30 -23
- package/template/GEMINI.md +20 -20
- package/template/README.md +70 -53
- package/template/app-manifest.json +2 -4
- package/template/configuration.json +10 -10
- package/template/default-styling.css +1 -1
- package/template/index.html +18 -20
- package/template/main.js +24 -22
- package/template/src/DemoPage.vue +415 -362
- package/template/src/Plugin.vue +76 -85
- package/template/src/stores/index.js +3 -3
- package/template/src/stores/test-data.json +164 -172
- package/template/theme-layouts/AdditionalStyling.css +50 -50
- package/template/theme-layouts/PrivateLayout.vue +8 -12
- package/template/theme-layouts/PublicLayout.vue +8 -12
- package/template/theme-layouts/SystemLayout.vue +8 -12
- package/template/vite.extend.js +45 -0
- package/template/vite.config.js +0 -409
|
@@ -4,343 +4,341 @@
|
|
|
4
4
|
* Manages GxP datastore test data and configuration.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const path = require("path")
|
|
8
|
-
const fs = require("fs")
|
|
9
|
-
const shell = require("shelljs")
|
|
7
|
+
const path = require("path")
|
|
8
|
+
const fs = require("fs")
|
|
9
|
+
const shell = require("shelljs")
|
|
10
10
|
const {
|
|
11
11
|
findProjectRoot,
|
|
12
12
|
resolveGxPaths,
|
|
13
13
|
promptUser,
|
|
14
14
|
safeCopyFile,
|
|
15
|
-
} = require("../utils")
|
|
15
|
+
} = require("../utils")
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Datastore commands for managing test data
|
|
19
19
|
*/
|
|
20
20
|
function datastoreCommand(argv) {
|
|
21
|
-
const action = argv.action
|
|
21
|
+
const action = argv.action
|
|
22
22
|
|
|
23
23
|
switch (action) {
|
|
24
24
|
case "list":
|
|
25
|
-
listDatastoreVariables()
|
|
26
|
-
break
|
|
25
|
+
listDatastoreVariables()
|
|
26
|
+
break
|
|
27
27
|
case "add":
|
|
28
|
-
addDatastoreVariable(argv)
|
|
29
|
-
break
|
|
28
|
+
addDatastoreVariable(argv)
|
|
29
|
+
break
|
|
30
30
|
case "scan-strings":
|
|
31
|
-
scanComponentStrings(argv)
|
|
32
|
-
break
|
|
31
|
+
scanComponentStrings(argv)
|
|
32
|
+
break
|
|
33
33
|
case "config":
|
|
34
|
-
switchDatastoreConfig(argv)
|
|
35
|
-
break
|
|
34
|
+
switchDatastoreConfig(argv)
|
|
35
|
+
break
|
|
36
36
|
case "init":
|
|
37
|
-
initDatastoreInExistingProject()
|
|
38
|
-
break
|
|
37
|
+
initDatastoreInExistingProject()
|
|
38
|
+
break
|
|
39
39
|
default:
|
|
40
|
-
console.log("Available datastore commands:")
|
|
41
|
-
console.log(" list - List all store variables")
|
|
42
|
-
console.log(" add - Add a new variable to the store")
|
|
43
|
-
console.log(
|
|
44
|
-
|
|
45
|
-
)
|
|
46
|
-
console.log(" config [name] - Switch between test configurations");
|
|
47
|
-
console.log(" init - Add datastore to existing project");
|
|
40
|
+
console.log("Available datastore commands:")
|
|
41
|
+
console.log(" list - List all store variables")
|
|
42
|
+
console.log(" add - Add a new variable to the store")
|
|
43
|
+
console.log(" scan-strings - Scan components for hardcoded strings")
|
|
44
|
+
console.log(" config [name] - Switch between test configurations")
|
|
45
|
+
console.log(" init - Add datastore to existing project")
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
function listDatastoreVariables() {
|
|
52
|
-
const projectPath = findProjectRoot()
|
|
53
|
-
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
50
|
+
const projectPath = findProjectRoot()
|
|
51
|
+
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
54
52
|
|
|
55
53
|
if (!fs.existsSync(testDataPath)) {
|
|
56
|
-
console.error('❌ No datastore found. Run "gxdev datastore init" first.')
|
|
57
|
-
return
|
|
54
|
+
console.error('❌ No datastore found. Run "gxdev datastore init" first.')
|
|
55
|
+
return
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
try {
|
|
61
|
-
const testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
59
|
+
const testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
62
60
|
|
|
63
|
-
console.log("📊 GxP Datastore Variables:")
|
|
64
|
-
console.log("")
|
|
61
|
+
console.log("📊 GxP Datastore Variables:")
|
|
62
|
+
console.log("")
|
|
65
63
|
|
|
66
64
|
if (testData.pluginVars && Object.keys(testData.pluginVars).length > 0) {
|
|
67
|
-
console.log("🔧 Plugin Variables:")
|
|
65
|
+
console.log("🔧 Plugin Variables:")
|
|
68
66
|
Object.entries(testData.pluginVars).forEach(([key, value]) => {
|
|
69
|
-
console.log(` ${key}: ${JSON.stringify(value)}`)
|
|
70
|
-
})
|
|
71
|
-
console.log("")
|
|
67
|
+
console.log(` ${key}: ${JSON.stringify(value)}`)
|
|
68
|
+
})
|
|
69
|
+
console.log("")
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
if (testData.stringsList && Object.keys(testData.stringsList).length > 0) {
|
|
75
|
-
console.log("📝 Strings:")
|
|
73
|
+
console.log("📝 Strings:")
|
|
76
74
|
Object.entries(testData.stringsList).forEach(([key, value]) => {
|
|
77
|
-
console.log(` ${key}: "${value}"`)
|
|
78
|
-
})
|
|
79
|
-
console.log("")
|
|
75
|
+
console.log(` ${key}: "${value}"`)
|
|
76
|
+
})
|
|
77
|
+
console.log("")
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
if (testData.assetList && Object.keys(testData.assetList).length > 0) {
|
|
83
|
-
console.log("🖼️ Assets:")
|
|
81
|
+
console.log("🖼️ Assets:")
|
|
84
82
|
Object.entries(testData.assetList).forEach(([key, value]) => {
|
|
85
|
-
console.log(` ${key}: ${value}`)
|
|
86
|
-
})
|
|
87
|
-
console.log("")
|
|
83
|
+
console.log(` ${key}: ${value}`)
|
|
84
|
+
})
|
|
85
|
+
console.log("")
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
if (
|
|
91
89
|
testData.dependencyList &&
|
|
92
90
|
Object.keys(testData.dependencyList).length > 0
|
|
93
91
|
) {
|
|
94
|
-
console.log("🔗 Dependencies:")
|
|
92
|
+
console.log("🔗 Dependencies:")
|
|
95
93
|
Object.entries(testData.dependencyList).forEach(([key, value]) => {
|
|
96
|
-
console.log(` ${key}: ${value}`)
|
|
97
|
-
})
|
|
98
|
-
console.log("")
|
|
94
|
+
console.log(` ${key}: ${value}`)
|
|
95
|
+
})
|
|
96
|
+
console.log("")
|
|
99
97
|
}
|
|
100
98
|
} catch (error) {
|
|
101
|
-
console.error("❌ Error reading test data:", error.message)
|
|
99
|
+
console.error("❌ Error reading test data:", error.message)
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
async function addDatastoreVariable(argv) {
|
|
106
104
|
if (argv.type && argv.key && argv.value) {
|
|
107
105
|
// Use provided arguments
|
|
108
|
-
addVariable(argv.type, argv.key, argv.value)
|
|
106
|
+
addVariable(argv.type, argv.key, argv.value)
|
|
109
107
|
} else {
|
|
110
108
|
// Interactive mode
|
|
111
|
-
console.log("Add a new variable to the datastore:")
|
|
112
|
-
console.log("1. string - Text content for UI")
|
|
113
|
-
console.log("2. setting - Configuration variable")
|
|
114
|
-
console.log("3. asset - Asset URL or path")
|
|
115
|
-
console.log("")
|
|
109
|
+
console.log("Add a new variable to the datastore:")
|
|
110
|
+
console.log("1. string - Text content for UI")
|
|
111
|
+
console.log("2. setting - Configuration variable")
|
|
112
|
+
console.log("3. asset - Asset URL or path")
|
|
113
|
+
console.log("")
|
|
116
114
|
|
|
117
115
|
const type = await promptUser(
|
|
118
|
-
"What type of variable? (string/setting/asset): "
|
|
119
|
-
)
|
|
120
|
-
const key = await promptUser("Variable key/name: ")
|
|
121
|
-
const value = await promptUser("Default value: ")
|
|
116
|
+
"What type of variable? (string/setting/asset): ",
|
|
117
|
+
)
|
|
118
|
+
const key = await promptUser("Variable key/name: ")
|
|
119
|
+
const value = await promptUser("Default value: ")
|
|
122
120
|
|
|
123
|
-
addVariable(type, key, value)
|
|
121
|
+
addVariable(type, key, value)
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
function addVariable(type, key, value) {
|
|
128
|
-
const projectPath = findProjectRoot()
|
|
129
|
-
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
126
|
+
const projectPath = findProjectRoot()
|
|
127
|
+
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
130
128
|
|
|
131
129
|
if (!fs.existsSync(testDataPath)) {
|
|
132
130
|
console.error(
|
|
133
|
-
"❌ No datastore found. Initialize project with datastore first."
|
|
134
|
-
)
|
|
135
|
-
return
|
|
131
|
+
"❌ No datastore found. Initialize project with datastore first.",
|
|
132
|
+
)
|
|
133
|
+
return
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
try {
|
|
139
|
-
const testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
137
|
+
const testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
140
138
|
|
|
141
139
|
switch (type.toLowerCase()) {
|
|
142
140
|
case "string":
|
|
143
|
-
testData.stringsList = testData.stringsList || {}
|
|
144
|
-
testData.stringsList[key] = value
|
|
145
|
-
console.log(`✓ Added string: ${key} = "${value}"`)
|
|
146
|
-
break
|
|
141
|
+
testData.stringsList = testData.stringsList || {}
|
|
142
|
+
testData.stringsList[key] = value
|
|
143
|
+
console.log(`✓ Added string: ${key} = "${value}"`)
|
|
144
|
+
break
|
|
147
145
|
case "setting":
|
|
148
|
-
testData.pluginVars = testData.pluginVars || {}
|
|
146
|
+
testData.pluginVars = testData.pluginVars || {}
|
|
149
147
|
// Try to parse as JSON for numbers/booleans, fallback to string
|
|
150
148
|
try {
|
|
151
|
-
testData.pluginVars[key] = JSON.parse(value)
|
|
149
|
+
testData.pluginVars[key] = JSON.parse(value)
|
|
152
150
|
} catch {
|
|
153
|
-
testData.pluginVars[key] = value
|
|
151
|
+
testData.pluginVars[key] = value
|
|
154
152
|
}
|
|
155
153
|
console.log(
|
|
156
154
|
`✓ Added setting: ${key} = ${JSON.stringify(
|
|
157
|
-
testData.pluginVars[key]
|
|
158
|
-
)}
|
|
159
|
-
)
|
|
160
|
-
break
|
|
155
|
+
testData.pluginVars[key],
|
|
156
|
+
)}`,
|
|
157
|
+
)
|
|
158
|
+
break
|
|
161
159
|
case "asset":
|
|
162
|
-
testData.assetList = testData.assetList || {}
|
|
163
|
-
testData.assetList[key] = value
|
|
164
|
-
console.log(`✓ Added asset: ${key} = ${value}`)
|
|
165
|
-
break
|
|
160
|
+
testData.assetList = testData.assetList || {}
|
|
161
|
+
testData.assetList[key] = value
|
|
162
|
+
console.log(`✓ Added asset: ${key} = ${value}`)
|
|
163
|
+
break
|
|
166
164
|
default:
|
|
167
|
-
console.error("❌ Invalid type. Use: string, setting, or asset")
|
|
168
|
-
return
|
|
165
|
+
console.error("❌ Invalid type. Use: string, setting, or asset")
|
|
166
|
+
return
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
fs.writeFileSync(testDataPath, JSON.stringify(testData, null, 2))
|
|
172
|
-
console.log("💾 Datastore updated successfully!")
|
|
169
|
+
fs.writeFileSync(testDataPath, JSON.stringify(testData, null, 2))
|
|
170
|
+
console.log("💾 Datastore updated successfully!")
|
|
173
171
|
} catch (error) {
|
|
174
|
-
console.error("❌ Error updating datastore:", error.message)
|
|
172
|
+
console.error("❌ Error updating datastore:", error.message)
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
178
176
|
async function scanComponentStrings(argv) {
|
|
179
|
-
const projectPath = findProjectRoot()
|
|
177
|
+
const projectPath = findProjectRoot()
|
|
180
178
|
const componentPath =
|
|
181
179
|
argv.component ||
|
|
182
|
-
(await promptUser("Component file path (e.g., src/Plugin.vue): "))
|
|
183
|
-
const fullPath = path.join(projectPath, componentPath)
|
|
180
|
+
(await promptUser("Component file path (e.g., src/Plugin.vue): "))
|
|
181
|
+
const fullPath = path.join(projectPath, componentPath)
|
|
184
182
|
|
|
185
183
|
if (!fs.existsSync(fullPath)) {
|
|
186
|
-
console.error(`❌ Component not found: ${componentPath}`)
|
|
187
|
-
return
|
|
184
|
+
console.error(`❌ Component not found: ${componentPath}`)
|
|
185
|
+
return
|
|
188
186
|
}
|
|
189
187
|
|
|
190
188
|
try {
|
|
191
|
-
const content = fs.readFileSync(fullPath, "utf-8")
|
|
189
|
+
const content = fs.readFileSync(fullPath, "utf-8")
|
|
192
190
|
|
|
193
191
|
// Extract strings from template section
|
|
194
|
-
const templateMatch = content.match(/<template>([\s\S]*?)<\/template>/)
|
|
192
|
+
const templateMatch = content.match(/<template>([\s\S]*?)<\/template>/)
|
|
195
193
|
if (!templateMatch) {
|
|
196
|
-
console.log("❌ No template section found")
|
|
197
|
-
return
|
|
194
|
+
console.log("❌ No template section found")
|
|
195
|
+
return
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
const template = templateMatch[1]
|
|
198
|
+
const template = templateMatch[1]
|
|
201
199
|
|
|
202
200
|
// Find text content within HTML elements (simplified regex)
|
|
203
|
-
const stringMatches = template.match(/>\s*([^<>]+[a-zA-Z][^<>]*)\s*</g)
|
|
201
|
+
const stringMatches = template.match(/>\s*([^<>]+[a-zA-Z][^<>]*)\s*</g)
|
|
204
202
|
|
|
205
203
|
if (!stringMatches || stringMatches.length === 0) {
|
|
206
|
-
console.log("ℹ️ No hardcoded strings found in template")
|
|
207
|
-
return
|
|
204
|
+
console.log("ℹ️ No hardcoded strings found in template")
|
|
205
|
+
return
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
console.log(
|
|
211
|
-
`🔍 Found ${stringMatches.length} potential strings in ${componentPath}
|
|
212
|
-
)
|
|
213
|
-
console.log("")
|
|
209
|
+
`🔍 Found ${stringMatches.length} potential strings in ${componentPath}:`,
|
|
210
|
+
)
|
|
211
|
+
console.log("")
|
|
214
212
|
|
|
215
|
-
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
216
|
-
let testData = {}
|
|
213
|
+
const testDataPath = path.join(projectPath, "src/stores/test-data.json")
|
|
214
|
+
let testData = {}
|
|
217
215
|
|
|
218
216
|
if (fs.existsSync(testDataPath)) {
|
|
219
|
-
testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
217
|
+
testData = JSON.parse(fs.readFileSync(testDataPath, "utf-8"))
|
|
220
218
|
}
|
|
221
219
|
|
|
222
|
-
testData.stringsList = testData.stringsList || {}
|
|
220
|
+
testData.stringsList = testData.stringsList || {}
|
|
223
221
|
|
|
224
222
|
for (const match of stringMatches) {
|
|
225
|
-
const text = match.replace(/>\s*/, "").replace(/\s*</, "").trim()
|
|
223
|
+
const text = match.replace(/>\s*/, "").replace(/\s*</, "").trim()
|
|
226
224
|
|
|
227
225
|
if (text.length > 2 && !text.includes("{{") && !text.includes("v-")) {
|
|
228
226
|
const key = text
|
|
229
227
|
.toLowerCase()
|
|
230
228
|
.replace(/[^a-z0-9\s]/g, "")
|
|
231
229
|
.replace(/\s+/g, "_")
|
|
232
|
-
.substring(0, 30)
|
|
230
|
+
.substring(0, 30)
|
|
233
231
|
|
|
234
232
|
if (!testData.stringsList[key]) {
|
|
235
|
-
const add = await promptUser(`Add "${text}" as "${key}"? (y/N): `)
|
|
233
|
+
const add = await promptUser(`Add "${text}" as "${key}"? (y/N): `)
|
|
236
234
|
if (add.toLowerCase() === "y" || add.toLowerCase() === "yes") {
|
|
237
|
-
testData.stringsList[key] = text
|
|
238
|
-
console.log(`✓ Added: ${key} = "${text}"`)
|
|
235
|
+
testData.stringsList[key] = text
|
|
236
|
+
console.log(`✓ Added: ${key} = "${text}"`)
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
241
|
|
|
244
|
-
fs.writeFileSync(testDataPath, JSON.stringify(testData, null, 2))
|
|
245
|
-
console.log("💾 Scan complete!")
|
|
242
|
+
fs.writeFileSync(testDataPath, JSON.stringify(testData, null, 2))
|
|
243
|
+
console.log("💾 Scan complete!")
|
|
246
244
|
} catch (error) {
|
|
247
|
-
console.error("❌ Error scanning component:", error.message)
|
|
245
|
+
console.error("❌ Error scanning component:", error.message)
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
248
|
|
|
251
249
|
async function switchDatastoreConfig(argv) {
|
|
252
|
-
const projectPath = findProjectRoot()
|
|
253
|
-
const storeDir = path.join(projectPath, "src/Store")
|
|
250
|
+
const projectPath = findProjectRoot()
|
|
251
|
+
const storeDir = path.join(projectPath, "src/Store")
|
|
254
252
|
|
|
255
253
|
if (!fs.existsSync(storeDir)) {
|
|
256
254
|
console.error(
|
|
257
|
-
"❌ No datastore found. Initialize project with datastore first."
|
|
258
|
-
)
|
|
259
|
-
return
|
|
255
|
+
"❌ No datastore found. Initialize project with datastore first.",
|
|
256
|
+
)
|
|
257
|
+
return
|
|
260
258
|
}
|
|
261
259
|
|
|
262
260
|
if (argv.config) {
|
|
263
261
|
// Switch to specified config
|
|
264
|
-
const configPath = path.join(storeDir, `test-data-${argv.config}.json`)
|
|
265
|
-
const defaultPath = path.join(storeDir, "test-data.json")
|
|
262
|
+
const configPath = path.join(storeDir, `test-data-${argv.config}.json`)
|
|
263
|
+
const defaultPath = path.join(storeDir, "test-data.json")
|
|
266
264
|
|
|
267
265
|
if (fs.existsSync(configPath)) {
|
|
268
|
-
fs.copyFileSync(configPath, defaultPath)
|
|
269
|
-
console.log(`✓ Switched to configuration: ${argv.config}`)
|
|
266
|
+
fs.copyFileSync(configPath, defaultPath)
|
|
267
|
+
console.log(`✓ Switched to configuration: ${argv.config}`)
|
|
270
268
|
} else {
|
|
271
|
-
console.error(`❌ Configuration not found: ${argv.config}`)
|
|
269
|
+
console.error(`❌ Configuration not found: ${argv.config}`)
|
|
272
270
|
}
|
|
273
271
|
} else {
|
|
274
272
|
// List available configurations
|
|
275
273
|
const files = fs
|
|
276
274
|
.readdirSync(storeDir)
|
|
277
275
|
.filter((f) => f.startsWith("test-data-") && f.endsWith(".json"))
|
|
278
|
-
.map((f) => f.replace("test-data-", "").replace(".json", ""))
|
|
276
|
+
.map((f) => f.replace("test-data-", "").replace(".json", ""))
|
|
279
277
|
|
|
280
278
|
if (files.length === 0) {
|
|
281
|
-
console.log("ℹ️ No additional configurations found")
|
|
279
|
+
console.log("ℹ️ No additional configurations found")
|
|
282
280
|
console.log(
|
|
283
|
-
"💡 Create a new config: cp src/stores/test-data.json src/stores/test-data-production.json"
|
|
284
|
-
)
|
|
281
|
+
"💡 Create a new config: cp src/stores/test-data.json src/stores/test-data-production.json",
|
|
282
|
+
)
|
|
285
283
|
} else {
|
|
286
|
-
console.log("Available configurations:")
|
|
287
|
-
files.forEach((config) => console.log(` ${config}`))
|
|
288
|
-
console.log("")
|
|
289
|
-
console.log("Switch with: gxdev datastore config <name>")
|
|
284
|
+
console.log("Available configurations:")
|
|
285
|
+
files.forEach((config) => console.log(` ${config}`))
|
|
286
|
+
console.log("")
|
|
287
|
+
console.log("Switch with: gxdev datastore config <name>")
|
|
290
288
|
}
|
|
291
289
|
}
|
|
292
290
|
}
|
|
293
291
|
|
|
294
292
|
async function initDatastoreInExistingProject() {
|
|
295
|
-
const projectPath = findProjectRoot()
|
|
296
|
-
const packageJsonPath = path.join(projectPath, "package.json")
|
|
293
|
+
const projectPath = findProjectRoot()
|
|
294
|
+
const packageJsonPath = path.join(projectPath, "package.json")
|
|
297
295
|
|
|
298
296
|
if (!fs.existsSync(packageJsonPath)) {
|
|
299
297
|
console.error(
|
|
300
|
-
"❌ No package.json found. Make sure you are in a GxP project directory."
|
|
301
|
-
)
|
|
302
|
-
return
|
|
298
|
+
"❌ No package.json found. Make sure you are in a GxP project directory.",
|
|
299
|
+
)
|
|
300
|
+
return
|
|
303
301
|
}
|
|
304
302
|
|
|
305
|
-
const storeDir = path.join(projectPath, "src/stores")
|
|
303
|
+
const storeDir = path.join(projectPath, "src/stores")
|
|
306
304
|
if (fs.existsSync(storeDir)) {
|
|
307
|
-
console.error("❌ Datastore already exists in this project.")
|
|
308
|
-
return
|
|
305
|
+
console.error("❌ Datastore already exists in this project.")
|
|
306
|
+
return
|
|
309
307
|
}
|
|
310
308
|
|
|
311
|
-
console.log("🗃️ Adding GxP Datastore to existing project...")
|
|
309
|
+
console.log("🗃️ Adding GxP Datastore to existing project...")
|
|
312
310
|
|
|
313
311
|
try {
|
|
314
312
|
// Read current package.json
|
|
315
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"))
|
|
313
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"))
|
|
316
314
|
|
|
317
315
|
// Add Pinia and axios dependencies
|
|
318
316
|
if (!packageJson.dependencies) {
|
|
319
|
-
packageJson.dependencies = {}
|
|
317
|
+
packageJson.dependencies = {}
|
|
320
318
|
}
|
|
321
319
|
|
|
322
|
-
packageJson.dependencies.pinia = "^2.1.7"
|
|
323
|
-
packageJson.dependencies.axios = "^1.6.0"
|
|
320
|
+
packageJson.dependencies.pinia = "^2.1.7"
|
|
321
|
+
packageJson.dependencies.axios = "^1.6.0"
|
|
324
322
|
|
|
325
323
|
// Add datastore scripts
|
|
326
324
|
if (!packageJson.scripts) {
|
|
327
|
-
packageJson.scripts = {}
|
|
325
|
+
packageJson.scripts = {}
|
|
328
326
|
}
|
|
329
327
|
|
|
330
|
-
packageJson.scripts["datastore:list"] = "gxdev datastore list"
|
|
331
|
-
packageJson.scripts["datastore:add"] = "gxdev datastore add"
|
|
332
|
-
packageJson.scripts["datastore:scan"] = "gxdev datastore scan-strings"
|
|
333
|
-
packageJson.scripts["datastore:config"] = "gxdev datastore config"
|
|
328
|
+
packageJson.scripts["datastore:list"] = "gxdev datastore list"
|
|
329
|
+
packageJson.scripts["datastore:add"] = "gxdev datastore add"
|
|
330
|
+
packageJson.scripts["datastore:scan"] = "gxdev datastore scan-strings"
|
|
331
|
+
packageJson.scripts["datastore:config"] = "gxdev datastore config"
|
|
334
332
|
|
|
335
333
|
// Write updated package.json
|
|
336
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
337
|
-
console.log("✓ Updated package.json")
|
|
334
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
335
|
+
console.log("✓ Updated package.json")
|
|
338
336
|
|
|
339
337
|
// Create store directory
|
|
340
|
-
fs.mkdirSync(storeDir, { recursive: true })
|
|
338
|
+
fs.mkdirSync(storeDir, { recursive: true })
|
|
341
339
|
|
|
342
340
|
// Copy store files
|
|
343
|
-
const paths = resolveGxPaths()
|
|
341
|
+
const paths = resolveGxPaths()
|
|
344
342
|
const storeFiles = [
|
|
345
343
|
{
|
|
346
344
|
src: "stores/index.js",
|
|
@@ -357,77 +355,77 @@ async function initDatastoreInExistingProject() {
|
|
|
357
355
|
dest: "src/stores/test-data.json",
|
|
358
356
|
desc: "Test data configuration",
|
|
359
357
|
},
|
|
360
|
-
]
|
|
358
|
+
]
|
|
361
359
|
|
|
362
360
|
storeFiles.forEach((file) => {
|
|
363
|
-
const srcPath = path.join(paths.templateDir, file.src)
|
|
364
|
-
const destPath = path.join(projectPath, file.dest)
|
|
365
|
-
safeCopyFile(srcPath, destPath, file.desc)
|
|
366
|
-
})
|
|
361
|
+
const srcPath = path.join(paths.templateDir, file.src)
|
|
362
|
+
const destPath = path.join(projectPath, file.dest)
|
|
363
|
+
safeCopyFile(srcPath, destPath, file.desc)
|
|
364
|
+
})
|
|
367
365
|
|
|
368
366
|
// Update main.js to include Pinia
|
|
369
|
-
const mainJsPath = path.join(projectPath, "main.js")
|
|
367
|
+
const mainJsPath = path.join(projectPath, "main.js")
|
|
370
368
|
if (fs.existsSync(mainJsPath)) {
|
|
371
|
-
let mainJsContent = fs.readFileSync(mainJsPath, "utf-8")
|
|
369
|
+
let mainJsContent = fs.readFileSync(mainJsPath, "utf-8")
|
|
372
370
|
|
|
373
371
|
// Add Pinia import
|
|
374
372
|
if (!mainJsContent.includes("pinia")) {
|
|
375
|
-
const importLine = 'import { pinia } from "./src/stores/index.js";'
|
|
376
|
-
const importIndex = mainJsContent.indexOf("import * as Vue")
|
|
373
|
+
const importLine = 'import { pinia } from "./src/stores/index.js";'
|
|
374
|
+
const importIndex = mainJsContent.indexOf("import * as Vue")
|
|
377
375
|
if (importIndex !== -1) {
|
|
378
376
|
mainJsContent =
|
|
379
377
|
mainJsContent.slice(0, importIndex) +
|
|
380
378
|
importLine +
|
|
381
379
|
"\n" +
|
|
382
|
-
mainJsContent.slice(importIndex)
|
|
380
|
+
mainJsContent.slice(importIndex)
|
|
383
381
|
} else {
|
|
384
|
-
mainJsContent = importLine + "\n" + mainJsContent
|
|
382
|
+
mainJsContent = importLine + "\n" + mainJsContent
|
|
385
383
|
}
|
|
386
384
|
|
|
387
385
|
// Add Pinia use
|
|
388
386
|
if (!mainJsContent.includes("app.use(pinia)")) {
|
|
389
|
-
const useIndex = mainJsContent.indexOf("app.use(GxComponentKit);")
|
|
387
|
+
const useIndex = mainJsContent.indexOf("app.use(GxComponentKit);")
|
|
390
388
|
if (useIndex !== -1) {
|
|
391
|
-
const endOfLine = mainJsContent.indexOf("\n", useIndex)
|
|
389
|
+
const endOfLine = mainJsContent.indexOf("\n", useIndex)
|
|
392
390
|
mainJsContent =
|
|
393
391
|
mainJsContent.slice(0, endOfLine) +
|
|
394
392
|
"\napp.use(pinia);" +
|
|
395
|
-
mainJsContent.slice(endOfLine)
|
|
393
|
+
mainJsContent.slice(endOfLine)
|
|
396
394
|
}
|
|
397
395
|
}
|
|
398
396
|
|
|
399
|
-
fs.writeFileSync(mainJsPath, mainJsContent)
|
|
400
|
-
console.log("✓ Updated main.js")
|
|
397
|
+
fs.writeFileSync(mainJsPath, mainJsContent)
|
|
398
|
+
console.log("✓ Updated main.js")
|
|
401
399
|
}
|
|
402
400
|
}
|
|
403
401
|
|
|
404
402
|
// Install new dependencies
|
|
405
|
-
console.log("📦 Installing dependencies...")
|
|
403
|
+
console.log("📦 Installing dependencies...")
|
|
406
404
|
const result = shell.exec("npm install", {
|
|
407
405
|
cwd: projectPath,
|
|
408
406
|
silent: false,
|
|
409
|
-
})
|
|
407
|
+
})
|
|
410
408
|
|
|
411
409
|
if (result.code === 0) {
|
|
412
|
-
console.log("✅ GxP Datastore added successfully!")
|
|
413
|
-
console.log("")
|
|
414
|
-
console.log("📊 Manage test data with: npm run datastore:add")
|
|
415
|
-
console.log("🔍 Scan components for strings: npm run datastore:scan")
|
|
416
|
-
console.log("📋 List all store variables: npm run datastore:list")
|
|
417
|
-
console.log("")
|
|
418
|
-
console.log("💡 Update your components to use the store:")
|
|
419
|
-
console.log(' import { useGxpStore } from "/src/stores/index.js"')
|
|
420
|
-
console.log(" const gxpStore = useGxpStore()")
|
|
410
|
+
console.log("✅ GxP Datastore added successfully!")
|
|
411
|
+
console.log("")
|
|
412
|
+
console.log("📊 Manage test data with: npm run datastore:add")
|
|
413
|
+
console.log("🔍 Scan components for strings: npm run datastore:scan")
|
|
414
|
+
console.log("📋 List all store variables: npm run datastore:list")
|
|
415
|
+
console.log("")
|
|
416
|
+
console.log("💡 Update your components to use the store:")
|
|
417
|
+
console.log(' import { useGxpStore } from "/src/stores/index.js"')
|
|
418
|
+
console.log(" const gxpStore = useGxpStore()")
|
|
421
419
|
} else {
|
|
422
420
|
console.error(
|
|
423
|
-
'❌ Failed to install dependencies. Please run "npm install" manually.'
|
|
424
|
-
)
|
|
421
|
+
'❌ Failed to install dependencies. Please run "npm install" manually.',
|
|
422
|
+
)
|
|
425
423
|
}
|
|
426
424
|
} catch (error) {
|
|
427
|
-
console.error("❌ Error adding datastore:", error.message)
|
|
425
|
+
console.error("❌ Error adding datastore:", error.message)
|
|
428
426
|
}
|
|
429
427
|
}
|
|
430
428
|
|
|
431
429
|
module.exports = {
|
|
432
430
|
datastoreCommand,
|
|
433
|
-
}
|
|
431
|
+
}
|