@kdcloudjs/cli 0.0.4 → 0.0.5
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/src/actions/debug/index.js +30 -25
- package/src/commands/debug.js +1 -0
package/package.json
CHANGED
|
@@ -50,38 +50,43 @@ module.exports = async function debug(options = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// 3. Get Form IDs
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
let formId = options.formid
|
|
54
|
+
|
|
55
|
+
if (!formId) {
|
|
56
|
+
const pagesDir = path.join(root, 'app/pages')
|
|
57
|
+
const pageFiles = walk(pagesDir)
|
|
58
|
+
const forms = []
|
|
59
|
+
|
|
60
|
+
for (const file of pageFiles) {
|
|
61
|
+
const id = getFormId(file)
|
|
62
|
+
if (id) {
|
|
63
|
+
forms.push({
|
|
64
|
+
title: id,
|
|
65
|
+
value: id
|
|
66
|
+
})
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
|
-
}
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
if (forms.length === 0) {
|
|
71
|
+
error('No pages found in app/pages')
|
|
72
|
+
return
|
|
73
|
+
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// 4. Select Form
|
|
76
|
+
const response = await safePrompts({
|
|
77
|
+
type: 'select',
|
|
78
|
+
name: 'formId',
|
|
79
|
+
message: 'Select a form to debug',
|
|
80
|
+
choices: forms
|
|
81
|
+
})
|
|
79
82
|
|
|
80
|
-
|
|
83
|
+
if (!response.formId) return
|
|
84
|
+
formId = response.formId
|
|
85
|
+
}
|
|
81
86
|
|
|
82
87
|
// 5. Construct URL
|
|
83
88
|
const targetUrl = new URL(env.url)
|
|
84
|
-
targetUrl.searchParams.append('formId',
|
|
89
|
+
targetUrl.searchParams.append('formId', formId)
|
|
85
90
|
targetUrl.searchParams.append('kdkwc_cdn', 'http://localhost:3333')
|
|
86
91
|
const finalUrl = targetUrl.toString()
|
|
87
92
|
|
package/src/commands/debug.js
CHANGED
|
@@ -3,6 +3,7 @@ module.exports = function registerDebug(program) {
|
|
|
3
3
|
.command('debug')
|
|
4
4
|
.description('debug project')
|
|
5
5
|
.option('-e, --target-env <env>', 'specified target environment')
|
|
6
|
+
.option('-f, --formid <formId>', 'specified form id to debug')
|
|
6
7
|
.action((options) =>
|
|
7
8
|
require('../actions/debug')(options)
|
|
8
9
|
)
|