Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor: function () {
// Calling the super constructor is important so our generator is correctly set up
helpers.NamedBase.apply(this, arguments);
this.log(
'Creating route to module ' + chalk.green(this.name) + ' using '
+ chalk.green((this.config.get('uirouter') && 'UI Router') || 'Angular Router')
);
this.choices = {
name: changeCase.camelCase(this.name),
namePascalCase: changeCase.pascalCase(this.name),
nameParamCase: changeCase.paramCase(this.name)
};
},
Config.prototype.extend = function (array, value, conf) {
conf = conf || this.conf;
var propName = null;
// Last property in hierarchy
if (array && array.length === 1) {
conf[changeCase.camelCase(array[0])] = value;
} else if (array && array.length > 1) {
propName = array[0];
propName = changeCase.camelCase(propName);
// if object is not on conf. hierarchy
if (array[0] && conf[propName] === undefined) {
conf[propName] = {};
}
this.extend(array.slice(1), value, conf[propName]);
}
};
private transformLwcTagName(tag: string) {
const namespace = tag.split('-')[0];
const name = tag
.split('-')
.slice(1)
.join('-');
return {
namespace,
name: changeCase.camelCase(name),
};
}
private transformLwcTagToAura(tag: string, tagInfo: any): TagInfo {
let className = file[localName];
if (className == null) {
if (isComponent(localName)) {
className =
componentName === localName
? polarisComponentName
: subcomponentClassName(polarisComponentName, localName);
} else if (SUBCOMPONENT_VARIATION_SELECTOR.test(localName)) {
const [subcomponent, variation] = localName.split('-');
const subcomponentName = subcomponentClassName(
polarisComponentName,
subcomponent,
);
className = variationClassName(subcomponentName, camelCase(variation));
} else {
className = variationClassName(
polarisComponentName,
camelCase(localName),
);
}
}
file[localName] = className;
cache.files[filePath] = file;
return className;
};
return string.split(';').reduce((acc, declaration) => {
const [property, value] = declaration.split(':').map(s => s.trim());
return {
...acc,
[camelCase(property)]: value,
};
}, {});
}
function replacePlaceholders (text, nameParts) {
const scene = nameParts[0]
const componentPath = nameParts.slice(1).join('/')
const componentString = nameParts.slice(1).join('-')
return text.split('$$CapitalScene$$').join(changeCase.pascalCase(scene))
.split('$$dash-scene$$').join(changeCase.paramCase(scene))
.split('$$camelScene$$').join(changeCase.camelCase(scene))
.split('$$CapitalComponent$$').join(changeCase.pascalCase(componentString))
.split('$$camelComponent$$').join(changeCase.camelCase(componentString))
.split('$$path-component$$').join(componentPath)
.split('$$dash-component$$').join(componentString)
}
}).then(answer => {
let dirPath = './services';
fs.ensureDirSync(dirPath);
let filePath = path.format({dir: dirPath, base: changeCase.camelCase(answer.name) + '.js'});
this.fs.copyTpl(this.templatePath('service.ejs'), filePath, {
serviceName: answer.name,
methodName: changeCase.camelCase(answer.name) + 'Method'
});
});
},
propertyFromVariant(variant: Variant): Variant & Property & Struct {
const structName = this.structNameForVariant(variant);
return Object.assign(variant, {
propertyName: camelCase(structName),
typeName: structName + '?',
structName,
});
}
prompting: function () {
this.log('Creating a controller: ' + chalk.green(this.name) + '...');
this.choices.moduleName = changeCase.camelCase(this.options.moduleName);
var done = this.async();
var customModules = _.filter(helpers.getAllAngularModules(this.config.get('clientSideFolder') + this.config.get('appSubFolder') + 'app.module.js'), function (m) {
return _.startsWith(m, this.config.get('appName') + '.') && m !== (this.config.get('appName') + '.core');
}, this).sort();
if (!customModules.length) {
this.env.error(chalk.red("There are no features in this app. Please generate a feature before generating a controller. \nFor example, 'ae feature myFeature'."));
} else {
var prompts = [
{
type: 'list',
name: 'moduleName',
message: 'Which module does this controller belong in?',
choices: customModules
}];
propertyFromInputField(field: GraphQLInputField) {
return Object.assign(
{},
{
propertyName: camelCase(field.name),
typeName: this.typeNameFromGraphQLType(field.type),
isOptional: !(field.type instanceof GraphQLNonNull),
description: field.description || null,
name: field.name,
}
);
}