Fix for #14201, adds the test helper into the manifest correctly.
This commit is contained in:
parent
2bdb470e45
commit
c857bacafa
|
@ -1,4 +1,7 @@
|
|||
import { HelperFunctionBuiltin } from "../src/helpers/constants"
|
||||
import {
|
||||
HelperFunctionBuiltin,
|
||||
EXTERNAL_FUNCTION_COLLECTIONS,
|
||||
} from "../src/helpers/constants"
|
||||
import { readFileSync, writeFileSync } from "fs"
|
||||
import { marked } from "marked"
|
||||
import { join, dirname } from "path"
|
||||
|
@ -14,21 +17,6 @@ type HelperInfo = {
|
|||
tags?: any[]
|
||||
}
|
||||
|
||||
/**
|
||||
* full list of supported helpers can be found here:
|
||||
* https://github.com/budibase/handlebars-helpers
|
||||
*/
|
||||
|
||||
const COLLECTIONS = [
|
||||
"math",
|
||||
"array",
|
||||
"number",
|
||||
"url",
|
||||
"string",
|
||||
"comparison",
|
||||
"object",
|
||||
"uuid",
|
||||
]
|
||||
const FILENAME = join(__dirname, "..", "src", "manifest.json")
|
||||
const outputJSON: any = {}
|
||||
const ADDED_HELPERS = {
|
||||
|
@ -140,7 +128,7 @@ const excludeFunctions: Record<string, string[]> = { string: ["raw"] }
|
|||
*/
|
||||
function run() {
|
||||
const foundNames: string[] = []
|
||||
for (let collection of COLLECTIONS) {
|
||||
for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) {
|
||||
const collectionFile = readFileSync(
|
||||
`${dirname(
|
||||
require.resolve("@budibase/handlebars-helpers")
|
||||
|
|
|
@ -15,6 +15,22 @@ export const HelperFunctionBuiltin = [
|
|||
"with",
|
||||
]
|
||||
|
||||
/**
|
||||
* full list of supported helpers can be found here:
|
||||
* https://github.com/Budibase/handlebars-helpers
|
||||
*/
|
||||
export const EXTERNAL_FUNCTION_COLLECTIONS = [
|
||||
"math",
|
||||
"array",
|
||||
"number",
|
||||
"url",
|
||||
"string",
|
||||
"comparison",
|
||||
"object",
|
||||
"regex",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
export const HelperFunctionNames = {
|
||||
OBJECT: "object",
|
||||
ALL: "all",
|
||||
|
|
|
@ -2,26 +2,12 @@
|
|||
import helpers from "@budibase/handlebars-helpers"
|
||||
|
||||
import { date, duration } from "./date"
|
||||
import { HelperFunctionBuiltin } from "./constants"
|
||||
import {
|
||||
HelperFunctionBuiltin,
|
||||
EXTERNAL_FUNCTION_COLLECTIONS,
|
||||
} from "./constants"
|
||||
import Handlebars from "handlebars"
|
||||
|
||||
/**
|
||||
* full list of supported helpers can be found here:
|
||||
* https://github.com/Budibase/handlebars-helpers
|
||||
*/
|
||||
|
||||
const EXTERNAL_FUNCTION_COLLECTIONS = [
|
||||
"math",
|
||||
"array",
|
||||
"number",
|
||||
"url",
|
||||
"string",
|
||||
"comparison",
|
||||
"object",
|
||||
"regex",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
const ADDED_HELPERS = {
|
||||
date: date,
|
||||
duration: duration,
|
||||
|
@ -40,7 +26,7 @@ export function registerAll(handlebars: typeof Handlebars) {
|
|||
let hbsHelperInfo = helpers[collection]()
|
||||
for (let entry of Object.entries(hbsHelperInfo)) {
|
||||
const name = entry[0]
|
||||
// skip built in functions and ones seen already
|
||||
// skip built-in functions and ones seen already
|
||||
if (
|
||||
HelperFunctionBuiltin.indexOf(name) !== -1 ||
|
||||
externalNames.indexOf(name) !== -1
|
||||
|
|
|
@ -1312,6 +1312,26 @@
|
|||
"requiresBlock": false
|
||||
}
|
||||
},
|
||||
"regex": {
|
||||
"toRegex": {
|
||||
"args": [
|
||||
"str"
|
||||
],
|
||||
"numArgs": 1,
|
||||
"example": "{{toRegex 'foo'}} -> /foo/",
|
||||
"description": "<p>Convert the given string to a regular expression.</p>\n",
|
||||
"requiresBlock": false
|
||||
},
|
||||
"test": {
|
||||
"args": [
|
||||
"str"
|
||||
],
|
||||
"numArgs": 1,
|
||||
"example": "{{test 'foobar' (toRegex 'foo')}} -> true",
|
||||
"description": "<p>Returns true if the given <code>str</code> matches the given regex. A regex can be passed on the context, or using the <a href=\"#toregex\">toRegex</a> helper as a subexpression.</p>\n",
|
||||
"requiresBlock": false
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"uuid": {
|
||||
"args": [],
|
||||
|
|
Loading…
Reference in New Issue