Merge remote-tracking branch 'origin/master' into fix/pc-fixes
This commit is contained in:
commit
cf6c9c16b8
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.16.0",
|
"version": "2.16.1",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -23,7 +23,7 @@ const getCloudfrontSignParams = () => {
|
||||||
return {
|
return {
|
||||||
keypairId: env.CLOUDFRONT_PUBLIC_KEY_ID!,
|
keypairId: env.CLOUDFRONT_PUBLIC_KEY_ID!,
|
||||||
privateKeyString: getPrivateKey(),
|
privateKeyString: getPrivateKey(),
|
||||||
expireTime: new Date().getTime() + 1000 * 60 * 60, // 1 hour
|
expireTime: new Date().getTime() + 1000 * 60 * 60 * 24, // 1 day
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,10 @@
|
||||||
})
|
})
|
||||||
$: filteredHelpers = helpers?.filter(helper => {
|
$: filteredHelpers = helpers?.filter(helper => {
|
||||||
return (
|
return (
|
||||||
!search ||
|
(!search ||
|
||||||
helper.label.match(searchRgx) ||
|
helper.label.match(searchRgx) ||
|
||||||
helper.description.match(searchRgx)
|
helper.description.match(searchRgx)) &&
|
||||||
|
(mode.name !== "javascript" || helper.allowsJs)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getManifest } from "@budibase/string-templates"
|
import { getManifest, helpersToRemoveForJs } from "@budibase/string-templates"
|
||||||
|
|
||||||
export function handlebarsCompletions() {
|
export function handlebarsCompletions() {
|
||||||
const manifest = getManifest()
|
const manifest = getManifest()
|
||||||
|
@ -11,6 +11,9 @@ export function handlebarsCompletions() {
|
||||||
label: helperName,
|
label: helperName,
|
||||||
displayText: helperName,
|
displayText: helperName,
|
||||||
description: helperConfig.description,
|
description: helperConfig.description,
|
||||||
|
allowsJs:
|
||||||
|
!helperConfig.requiresBlock &&
|
||||||
|
!helpersToRemoveForJs.includes(helperName),
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { getHelperList } = require("../helpers")
|
const { getJsHelperList } = require("../helpers")
|
||||||
|
|
||||||
function getLayers(fullBlock) {
|
function getLayers(fullBlock) {
|
||||||
let layers = []
|
let layers = []
|
||||||
|
@ -109,7 +109,7 @@ module.exports.convertHBSBlock = (block, blockNumber) => {
|
||||||
const layers = getLayers(block)
|
const layers = getLayers(block)
|
||||||
|
|
||||||
let value = null
|
let value = null
|
||||||
const list = getHelperList()
|
const list = getJsHelperList()
|
||||||
for (let layer of layers) {
|
for (let layer of layers) {
|
||||||
const parts = splitBySpace(layer)
|
const parts = splitBySpace(layer)
|
||||||
if (value || parts.length > 1 || list[parts[0]]) {
|
if (value || parts.length > 1 || list[parts[0]]) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ const {
|
||||||
HelperFunctionBuiltin,
|
HelperFunctionBuiltin,
|
||||||
LITERAL_MARKER,
|
LITERAL_MARKER,
|
||||||
} = require("./constants")
|
} = require("./constants")
|
||||||
const { getHelperList } = require("./list")
|
const { getJsHelperList } = require("./list")
|
||||||
|
|
||||||
const HTML_SWAPS = {
|
const HTML_SWAPS = {
|
||||||
"<": "<",
|
"<": "<",
|
||||||
|
@ -97,4 +97,4 @@ module.exports.unregisterAll = handlebars => {
|
||||||
externalHandlebars.unregisterAll(handlebars)
|
externalHandlebars.unregisterAll(handlebars)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getHelperList = getHelperList
|
module.exports.getJsHelperList = getJsHelperList
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { atob } = require("../utilities")
|
const { atob } = require("../utilities")
|
||||||
const cloneDeep = require("lodash.clonedeep")
|
const cloneDeep = require("lodash.clonedeep")
|
||||||
const { LITERAL_MARKER } = require("../helpers/constants")
|
const { LITERAL_MARKER } = require("../helpers/constants")
|
||||||
const { getHelperList } = require("./list")
|
const { getJsHelperList } = require("./list")
|
||||||
|
|
||||||
// The method of executing JS scripts depends on the bundle being built.
|
// The method of executing JS scripts depends on the bundle being built.
|
||||||
// This setter is used in the entrypoint (either index.cjs or index.mjs).
|
// This setter is used in the entrypoint (either index.cjs or index.mjs).
|
||||||
|
@ -49,7 +49,7 @@ module.exports.processJS = (handlebars, context) => {
|
||||||
// app context.
|
// app context.
|
||||||
const sandboxContext = {
|
const sandboxContext = {
|
||||||
$: path => getContextValue(path, cloneDeep(context)),
|
$: path => getContextValue(path, cloneDeep(context)),
|
||||||
helpers: getHelperList(),
|
helpers: getJsHelperList(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a sandbox with our context and run the JS
|
// Create a sandbox with our context and run the JS
|
||||||
|
|
|
@ -3,9 +3,10 @@ const helperList = require("@budibase/handlebars-helpers")
|
||||||
|
|
||||||
let helpers = undefined
|
let helpers = undefined
|
||||||
|
|
||||||
const helpersToRemove = ["sortBy"]
|
const helpersToRemoveForJs = ["sortBy"]
|
||||||
|
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
|
||||||
|
|
||||||
module.exports.getHelperList = () => {
|
module.exports.getJsHelperList = () => {
|
||||||
if (helpers) {
|
if (helpers) {
|
||||||
return helpers
|
return helpers
|
||||||
}
|
}
|
||||||
|
@ -25,7 +26,7 @@ module.exports.getHelperList = () => {
|
||||||
helpers[key] = externalHandlebars.addedHelpers[key]
|
helpers[key] = externalHandlebars.addedHelpers[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const toRemove of helpersToRemove) {
|
for (const toRemove of helpersToRemoveForJs) {
|
||||||
delete helpers[toRemove]
|
delete helpers[toRemove]
|
||||||
}
|
}
|
||||||
Object.freeze(helpers)
|
Object.freeze(helpers)
|
||||||
|
|
|
@ -20,6 +20,7 @@ module.exports.findHBSBlocks = templates.findHBSBlocks
|
||||||
module.exports.convertToJS = templates.convertToJS
|
module.exports.convertToJS = templates.convertToJS
|
||||||
module.exports.setJSRunner = templates.setJSRunner
|
module.exports.setJSRunner = templates.setJSRunner
|
||||||
module.exports.FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
|
module.exports.FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
|
||||||
|
module.exports.helpersToRemoveForJs = templates.helpersToRemoveForJs
|
||||||
|
|
||||||
if (!process.env.NO_JS) {
|
if (!process.env.NO_JS) {
|
||||||
const { VM } = require("vm2")
|
const { VM } = require("vm2")
|
||||||
|
|
|
@ -10,6 +10,7 @@ const {
|
||||||
} = require("./utilities")
|
} = require("./utilities")
|
||||||
const { convertHBSBlock } = require("./conversion")
|
const { convertHBSBlock } = require("./conversion")
|
||||||
const javascript = require("./helpers/javascript")
|
const javascript = require("./helpers/javascript")
|
||||||
|
const { helpersToRemoveForJs } = require("./helpers/list")
|
||||||
|
|
||||||
const hbsInstance = handlebars.create()
|
const hbsInstance = handlebars.create()
|
||||||
registerAll(hbsInstance)
|
registerAll(hbsInstance)
|
||||||
|
@ -394,3 +395,4 @@ module.exports.convertToJS = hbs => {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.FIND_ANY_HBS_REGEX = FIND_ANY_HBS_REGEX
|
module.exports.FIND_ANY_HBS_REGEX = FIND_ANY_HBS_REGEX
|
||||||
|
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
|
||||||
|
|
|
@ -21,6 +21,7 @@ export const findHBSBlocks = templates.findHBSBlocks
|
||||||
export const convertToJS = templates.convertToJS
|
export const convertToJS = templates.convertToJS
|
||||||
export const setJSRunner = templates.setJSRunner
|
export const setJSRunner = templates.setJSRunner
|
||||||
export const FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
|
export const FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
|
||||||
|
export const helpersToRemoveForJs = templates.helpersToRemoveForJs
|
||||||
|
|
||||||
if (process && !process.env.NO_JS) {
|
if (process && !process.env.NO_JS) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,7 +24,7 @@ const {
|
||||||
} = require("../src/index.cjs")
|
} = require("../src/index.cjs")
|
||||||
|
|
||||||
const tk = require("timekeeper")
|
const tk = require("timekeeper")
|
||||||
const { getHelperList } = require("../src/helpers")
|
const { getJsHelperList } = require("../src/helpers")
|
||||||
|
|
||||||
tk.freeze("2021-01-21T12:00:00")
|
tk.freeze("2021-01-21T12:00:00")
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ describe("manifest", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("can be parsed and run as js", () => {
|
describe("can be parsed and run as js", () => {
|
||||||
const jsHelpers = getHelperList()
|
const jsHelpers = getJsHelperList()
|
||||||
const jsExamples = Object.keys(examples).reduce((acc, v) => {
|
const jsExamples = Object.keys(examples).reduce((acc, v) => {
|
||||||
acc[v] = examples[v].filter(([key]) => jsHelpers[key])
|
acc[v] = examples[v].filter(([key]) => jsHelpers[key])
|
||||||
return acc
|
return acc
|
||||||
|
|
Loading…
Reference in New Issue