create-appraisejs 0.2.0-alpha.4 → 0.2.0-alpha.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
CHANGED
|
Binary file
|
|
@@ -214,14 +214,9 @@ class AutomationProjectionService {
|
|
|
214
214
|
select: { id: true },
|
|
215
215
|
})
|
|
216
216
|
|
|
217
|
-
const templateStepGroups = await prisma.templateStepGroup.findMany({
|
|
218
|
-
select: { id: true },
|
|
219
|
-
})
|
|
220
|
-
|
|
221
217
|
await Promise.all([
|
|
222
218
|
this.syncEnvironments(),
|
|
223
219
|
...locatorGroups.map(locatorGroup => this.syncLocatorGroup(locatorGroup.id)),
|
|
224
|
-
...templateStepGroups.map(group => this.syncTemplateStepGroup(group.id)),
|
|
225
220
|
])
|
|
226
221
|
|
|
227
222
|
await this.regenerateAllFeatures()
|
|
@@ -10,29 +10,53 @@ import {
|
|
|
10
10
|
} from '@/lib/automation/paths'
|
|
11
11
|
|
|
12
12
|
const RUNTIME_IMPORT = '../../../packages/cucumber-runtime/src/index.js'
|
|
13
|
-
const REQUIRED_RUNTIME_IMPORT =
|
|
14
|
-
`import { When, Then, CustomWorld, expect, SelectorName, resolveLocator, getEnvironment, generateRandomData, RandomDataType } from '${RUNTIME_IMPORT}';\n\n`
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const REQUIRED_RUNTIME_IMPORT =
|
|
14
|
+
`import { When, Then, CustomWorld, expect, SelectorName, resolveLocator, getEnvironment, generateRandomData, RandomDataType } from '${RUNTIME_IMPORT}';\n\n`
|
|
15
|
+
|
|
16
|
+
function generateStepJSDoc(templateStep: Pick<TemplateStep, 'name' | 'description' | 'icon'>): string {
|
|
17
|
+
const lines = ['/**']
|
|
18
|
+
lines.push(` * @name ${templateStep.name}`)
|
|
19
|
+
if (templateStep.description) {
|
|
20
|
+
lines.push(` * @description ${templateStep.description}`)
|
|
21
|
+
}
|
|
22
|
+
lines.push(` * @icon ${templateStep.icon}`)
|
|
23
|
+
lines.push(' */')
|
|
24
|
+
return lines.join('\n')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function stripLeadingJSDoc(functionDefinition: string): string {
|
|
28
|
+
return functionDefinition.replace(/^\s*\/\*\*[\s\S]*?\*\/\s*/u, '').trim()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function generateStepDefinition(templateStep: TemplateStep): string | null {
|
|
32
|
+
const functionDefinition = templateStep.functionDefinition?.trim()
|
|
33
|
+
if (!functionDefinition) {
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return `${generateStepJSDoc(templateStep)}\n${stripLeadingJSDoc(functionDefinition)}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function sanitizeFileName(groupName: string): string {
|
|
41
|
+
return groupName
|
|
18
42
|
.toLowerCase()
|
|
19
43
|
.trim()
|
|
20
44
|
.replace(/\s+/g, '_')
|
|
21
45
|
.replace(/[^a-z0-9_]/g, '')
|
|
22
46
|
}
|
|
23
47
|
|
|
24
|
-
export function generateFileContent(templateSteps: TemplateStep[]): string {
|
|
25
|
-
if (!templateSteps || templateSteps.length === 0) {
|
|
26
|
-
return REQUIRED_RUNTIME_IMPORT + '// This file is generated automatically. Add template steps to this group to generate content.'
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const functionDefinitions = templateSteps
|
|
30
|
-
.map(
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.join('\n\n')
|
|
33
|
-
|
|
34
|
-
return REQUIRED_RUNTIME_IMPORT + functionDefinitions
|
|
35
|
-
}
|
|
48
|
+
export function generateFileContent(templateSteps: TemplateStep[]): string {
|
|
49
|
+
if (!templateSteps || templateSteps.length === 0) {
|
|
50
|
+
return REQUIRED_RUNTIME_IMPORT + '// This file is generated automatically. Add template steps to this group to generate content.'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const functionDefinitions = templateSteps
|
|
54
|
+
.map(generateStepDefinition)
|
|
55
|
+
.filter((definition): definition is string => Boolean(definition))
|
|
56
|
+
.join('\n\n')
|
|
57
|
+
|
|
58
|
+
return REQUIRED_RUNTIME_IMPORT + functionDefinitions
|
|
59
|
+
}
|
|
36
60
|
|
|
37
61
|
export async function formatFileContent(content: string): Promise<string> {
|
|
38
62
|
try {
|