Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function currentLayer(newLayerName, layerName) {
// UpperCase
let name = newLayerName.replace(/%\*u%/gi, changeCase.upperCase(layerName))
// LowerCase
name = name.replace(/%\*l%/gi, changeCase.lowerCase(layerName))
// Title Case
name = name.replace(/%\*t%/gi, toTitleCase(layerName))
// UpperCase First
name = name.replace(/%\*uf%/gi, changeCase.upperCaseFirst(layerName))
// Camel Case
name = name.replace(/%\*c%/gi, changeCase.camelCase(layerName))
// Param Case
name = name.replace(/%\*pc%/gi, changeCase.paramCase(layerName))
// Layername
name = name.replace(/%\*/g, layerName)
return name
}
function currentLayer(newLayerName, layerName) {
// UpperCase
let name = newLayerName.replace(/%\*u%/gi, changeCase.upperCase(layerName));
// LowerCase
name = name.replace(/%\*l%/gi, changeCase.lowerCase(layerName));
// Title Case
name = name.replace(/%\*t%/gi, toTitleCase(layerName));
// name = name.replace(/%\*t%/gi, changeCase.titleCase(layerName))
// UpperCase First
name = name.replace(/%\*uf%/gi, changeCase.upperCaseFirst(layerName));
// Camel Case
name = name.replace(/%\*c%/gi, changeCase.camelCase(layerName));
// Layername
name = name.replace(/%\*/g, layerName);
return name;
}
function compileTag(tag: Tag, options: Options) : Widget {
// use the configured class name if we set it in the tagClasses option
const originalName = tag.name
for(let tagName of Object.keys(options.tagClasses)) {
if(tag.name == tagName) tag.name = options.tagClasses[tagName]
}
// start building a widget with params
const widgetClass = upperCaseFirst(camelCase(tag.name))
const params: Param[] = []
let generics: string[]
let pugLine: number
let pugColumn: number
// process the tag attributes, transforming them into widget params
if(tag.attribs) {
for(const attr in tag.attribs) {
let type: 'expression' | 'literal' | 'closure'
let name: string
if(attr.startsWith(':')) {
type = 'expression'
name = attr.substring(1)
} else if(attr.startsWith('@')) {
type = 'closure'
name = attr.substring(1)
function currentLayer(newLayerName, layerName) {
// UpperCase
let name = newLayerName.replace(/%\*u%/gi, changeCase.upperCase(layerName))
// LowerCase
name = name.replace(/%\*l%/gi, changeCase.lowerCase(layerName))
// Title Case
name = name.replace(/%\*t%/gi, toTitleCase(layerName))
// name = name.replace(/%\*t%/gi, changeCase.titleCase(layerName))
// UpperCase First
name = name.replace(/%\*uf%/gi, changeCase.upperCaseFirst(layerName))
// Camel Case
name = name.replace(/%\*c%/gi, changeCase.camelCase(layerName))
// Layername
name = name.replace(/%\*/g, layerName)
return name
}
export function transformWidget(widget: Widget, options: Options): Widget {
if(widget.originalName) {
const split = widget.originalName.split(':')
if(split.length == 2) {
widget.name = upperCaseFirst(camelCase(split[0]))
if(!widget.params) widget.params = []
widget.params.push({
class: 'param',
type: 'literal',
name: 'constructor',
value: split[1],
resolved: true
})
}
}
applyOnDescendants(widget, descendant=>transformWidget(descendant, options))
return widget
}
function run(componentName) {
if (!componentName) {
throw new Error(`
Please supply a component name!
'npm run add-component -- YourComponentName'
`);
} else if (!changeCase.upperCaseFirst(componentName)) {
throw new Error(`
Custom React components need to be in PascalCase.
You provided ${componentName}.
Please capitalize the first letter!
`);
}
const componentDirectory = path.join(
__dirname,
'../../src/components',
componentName
);
createDirectory(componentDirectory);
const className = changeCase.paramCase(componentName);
function templateConfigToString(config) {
var out = [];
for (var key in config) {
out.push(chalk.bold(changeCase.upperCaseFirst(key)) + ': ' + config[key]);
}
return out.join('\n') + '\n';
}
update: function (el, binding, vnode) {
const value = vnode.data.model.value
vnode.data.model.callback(upperCaseFirst(value))
}
})
function run(componentName) {
if (!componentName) {
throw new Error(`
Please supply a component name!
'npm run add-component -- YourComponentName'
`);
} else if (!changeCase.upperCaseFirst(componentName)) {
throw new Error(`
Custom React components need to be in PascalCase.
You provided ${componentName}.
Please capitalize the first letter!
`);
}
const componentDirectory = path.join(
__dirname,
'../../src/components',
componentName
);
createDirectory(componentDirectory);
const className = changeCase.paramCase(componentName);