Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function generateComponents() {
// loop through the icons meta array
for (const icon of icons) {
const className = icon.moduleName;
const selectorName = param(icon.moduleName);
const rawSvg = toString(icon.descriptor);
const outputPath = icon.outputOptions.file
.replace('es', 'ts')
.replace('.js', '.ts');
// try to write out the component
try {
await fs.ensureDir(dirname(outputPath));
await fs.writeFile(
outputPath,
componentTemplate(
selectorName,
className,
rawSvg,
icon.descriptor.attrs
)
);
}
if ( params.hasOwnProperty( 'silent' ) === true ) {
silent = params.silent;
}
if ( !silent ) {
var charm = require('charm')();
charm.pipe(process.stdout);
charm.reset();
}
paramsArr = [];
for ( name in params ) {
if ( params.hasOwnProperty(name) === true && name !== 'silent' ) {
cc_name = changeCase.param( name );
paramsArr.push( '-' + cc_name );
paramsArr.push( params[name] );
}
}
if( _.isString(input) === false || _.isString(output) === false ) {
throw new TypeError( 'Input and output file names must be strings' );
}
cwd = process.cwd();
inputPath = path.resolve( cwd, input );
input = path.relative( SRC_FOLDER, inputPath );
output = path.relative( SRC_FOLDER, output );
var word2vecProc = spawn( './word2vec', ['-train', input, '-output', output ].concat(paramsArr), { cwd: SRC_FOLDER } );
this.root = path.join(shell.pwd(), this.name);
this.rubyVersion = shell.env['RUBY_VERSION'];
this.rvmString = 'rvm ' + this.rubyVersion + '@' + this.name + ' do ';
this.configRepo = false;
done();
} else {
var prompts = [
{
type : 'input',
name : 'name',
message: 'Enter app name:',
default: shift.param(this.options.argv.original[0]) || null
},
{
type : 'checkbox',
name : 'parts',
message: 'Choose parts to install:',
choices: [
{
name : 'Node App',
value : 'app',
checked: true
},
{
name : 'Rails API',
value : 'api',
checked: true
}
type,
fieldName,
router,
models,
link,
handleError,
}: {
schema: GraphQLSchema;
type: GraphQLObjectType;
fieldName: string;
router: express.Router;
models: string[];
link: ApolloLink;
handleError?: ErrorHandler;
}) {
const path = `/${changeCase.param(fieldName)}`;
const operation = getOperationType(type, schema);
const methodMap = {
query: 'get',
mutation: 'post',
subscription: undefined,
};
if (!operation) {
throw new Error(`Type '${type}' is not a query, mutation or subscription`);
}
const method = methodMap[operation];
if (!method) {
throw new Error('Subscription is not supported yet');
}
static toPartialControllerName(name) {
return `_${ changeCase.param(name) }.js`;
}
static toHTMLFileName(name) {
return `${ changeCase.param(name) }.html`;
}
template: \`
<p>Component <code><ibm-icon-${param(
icon.moduleName
)}></ibm-icon-${param(icon.moduleName)}></code></p>
<p>Directive <code><svg ibmIcon${pascal(
icon.moduleName
)}></svg></code></p>
<svg></svg>
\`
}))
.add("${icon.moduleName} with label", () => ({
template: \`
<svg></svg>
\`
}))
.add("${icon.moduleName} with title", () => ({
template: \`
<svg title="icon title"></svg>
\`
}))
.add("${icon.moduleName} with class on the SVG", () => ({
template: \`
import changeCase from 'change-case';
export default {
camelCase: changeCase.camel,
snakeCase: changeCase.snake,
dotCase: changeCase.dot,
pathCase: changeCase.path,
lowerCase: changeCase.lower,
upperCase: changeCase.upper,
sentenceCase: changeCase.sentence,
constantCase: changeCase.constant,
titleCase: changeCase.title,
dashCase: changeCase.param,
kabobCase: changeCase.param,
kebabCase: changeCase.param,
properCase: changeCase.pascal,
pascalCase: changeCase.pascal
};
this.prompt(prompts, function (props) {
function installPart(part) {
return props.parts.indexOf(part) !== -1;
}
this.name = shift.param(props.name);
this.appName = this.name + '-app';
this.apiName = this.name + '-api';
this.installApp = installPart('app');
this.installApi = installPart('api');
this.root = path.join(shell.pwd(), this.name);
this.rubyVersion = shell.env['RUBY_VERSION'];
this.rvmString = 'rvm ' + this.rubyVersion + '@' + this.name + ' do ';
this.configRepo = props.configRepo;
done();
}.bind(this));
funcs.set('kebab', (_: Context, v: string) => cc.param(v));
funcs.set('constant', (_: Context, v: string) => cc.constant(v));