export const addModuleToState = (pathToAppActions: string, moduleName: string): void => { try { let file = fs.readFileSync(pathToAppActions, 'utf-8'); getAST(file); file = insertAt( file, findAstNodes(sourceFile, ts.SyntaxKind.ObjectLiteralExpression, true).pop().end + 1, `\n ${lowerFirst(moduleName)}: {\n ...${upperFirst(moduleName)}DefaultState,\n },`, ); const interfaces: ts.Node[] = findAstNodes(sourceFile, ts.SyntaxKind.InterfaceDeclaration, true); file = insertAt( file, interfaces.shift().end - 2, `\n ${lowerFirst(moduleName)}?: I${upperFirst(moduleName)}State;`, ); file = insertAt( file, findAstNodes(sourceFile, ts.SyntaxKind.ImportDeclaration, true).pop().end, `\nimport { ${upperFirst(moduleName)}DefaultState, I${upperFirst(moduleName)}State } from './${lowerFirst(moduleName)}/state';`, ); fs.writeFileSync(pathToAppActions, file, { encoding: 'utf-8' }); } catch (e) { throw new Error(e); } };
(async function init() { for (const commandPath of commandsPath) { const className = upperFirst(camelCase(commandPath.replace(/\./g, '-'))); if ( process.env.NODE_ENV !== 'production' && filter && `${filter}.command` !== commandPath ) { continue; } const classInterface = (await import(`./commands/${commandPath}`))[ className ]; const commandObject = new classInterface(); try { yargs.command(commandObject); } catch (e) { console.log('ERROR ON COMMAND'); console.log(e); } } yargs .demandCommand(1) .strict() .help('h') .alias('v', 'version').argv; })();
.map((response:any) => { var result = response.json(), name = result.name; result.img = 'http://img.pokemondb.net/artwork/' + name + '.jpg'; result.name = upperFirst(name); cache.pokemon.set(id, result); return result; });
public async welcomeOAuth(requestState: RequestState, user: UserDocument): Promise<SentMessageInfo> { const strategyNames: { [key: string]: string } = { github: 'GitHub', google: 'Google', gameex: 'GameEx', }; return this.sendEmail(requestState, user, 'Welcome to VPDB!', 'welcome-oauth', { user, profileUrl: settings.webUri('/profile/settings'), strategy: strategyNames[user.provider] || upperFirst(user.provider), }); }
constructor(private config: IComponentGenConfig) { const className = upperFirst(camelCase(config.name)); let path = `${Vesta.directories.components}/${config.path}`; mkdir(path); if (this.config.hasStyle) { genSass(className, path); } if (config.model) { path = `${path}/${className}`; } }
addProperty(layoutElements: {}[], property: {}, name: string, path: string) { if (property['type'] == 'object') { let sublayout: {} = { 'type': 'Group', 'label': _.upperFirst(name), 'elements': [] }; _.forEach(property['properties'], (subproperty: any, subname: string) => { this.addProperty(sublayout['elements'], subproperty, subname, path + name + '/properties/'); }); layoutElements.push(sublayout); } else { let control: {} = { 'type': 'Control', 'label': _.upperFirst(name), 'scope': { '$ref': path + name } }; layoutElements.push(control); } }
export const addModuleToRoutes = (pathToAppRoutes: string, moduleName: string): void => { try { let file = fs.readFileSync(pathToAppRoutes, 'utf-8'); getAST(file); file = insertAt( file, findAstNodes(sourceFile, ts.SyntaxKind.ArrayLiteralExpression, true).pop().end - 4, ` ...${upperFirst(moduleName)}Routes,\n`, ); file = insertAt( file, findAstNodes(sourceFile, ts.SyntaxKind.ImportDeclaration, true).pop().end, `\nimport { ${upperFirst(moduleName)}Routes } from './${lowerFirst(moduleName)}/routes';`, ); fs.writeFileSync(pathToAppRoutes, file, { encoding: 'utf-8' }); } catch (e) { throw new Error(e); } };
export const addModuleToStore = (pathToAppActions: string, moduleName: string): void => { try { let file = fs.readFileSync(pathToAppActions, 'utf-8'); getAST(file); file = insertAt( file, sourceFile.endOfFileToken.end, `store.registerModule(['${lowerFirst(moduleName)}'], ${upperFirst(moduleName)}Module, { preserveState: true });\n`, ); file = insertAt( file, findAstNodes(sourceFile, ts.SyntaxKind.ImportDeclaration, true).pop().end, `\nimport { ${upperFirst(moduleName)}Module } from './${lowerFirst(moduleName)}/module';`, ); fs.writeFileSync(pathToAppActions, file, { encoding: 'utf-8' }); } catch (e) { throw new Error(e); } };
public validate( _pipeline: IPipeline, stage: IStage | ITrigger, validationConfig: IServiceFieldValidatorConfig, ): string { const serviceInput: ICloudFoundryServiceManifestSource = get(stage, 'manifest'); if (sourceType(serviceInput, get(stage, 'userProvided')) !== validationConfig.manifestSource) { return null; } const manifestSource: any = get(serviceInput, sourceStruct(serviceInput)); const content: any = get(manifestSource, validationConfig.fieldName); const fieldLabel = validationConfig.fieldLabel || upperFirst(validationConfig.fieldName); return content ? null : `<strong>${fieldLabel}</strong> is a required field for the Deploy Service stage.`; }
return this.$q.all(promises).then(results => { let status = 'success'; let message = ''; for (let i = 0; i < results.length; i++) { if (results[i].status !== 'success') { status = results[i].status; } message += `${i + 1}. ${results[i].message} `; } return { status: status, message: message, title: _.upperFirst(status), }; });