writing() { const generatorName = this.fs.readJSON(this.destinationPath('package.json')).name; this.fs.copyTpl( this.templatePath('index.js'), this.destinationPath(path.join('generators', this.options.name, 'index.js')), { // Escape apostrophes from superb to not conflict with JS strings superb: superb().replace("'", "\\'"), generatorName } ); this.fs.copy( this.templatePath('templates/**'), this.destinationPath(path.join('generators', this.options.name, 'templates')) ); this.fs.copyTpl( this.templatePath('test.js'), this.destinationPath('__tests__/' + this.options.name + '.js'), { name: this.options.name, generatorName } ); }
writing: function () { var generatorName = this.fs.readJSON(this.destinationPath('package.json')).name; this.fs.copyTpl( this.templatePath('index.js'), this.destinationPath(path.join('generators', this.namespace, 'index.js')), { // Escape apostrophes from superb to not conflict with JS strings superb: superb().replace('\'', '\\\''), generatorName: generatorName } ); this.fs.copy( this.templatePath('templates/**'), this.destinationPath(path.join('generators', this.namespace, 'templates')) ); this.fs.copyTpl( this.templatePath('test.js'), this.destinationPath('test/' + this.namespace + '.js'), { namespace: this.namespace, generatorName: generatorName } ); }
writing: function () { if (this.name) { mkdirp(this.props.moduleName); this.destinationRoot(this.destinationPath(this.props.moduleName)); } var tpl = { moduleName: this.props.moduleName, moduleDesc: this.shouldSkipAll ? ('My ' + superb() + ' module') : this.props.moduleDesc, moduleKeywords: (this.props.moduleKeywords || []), moduleVersion: this.props.moduleVersion, moduleLicense: this.props.moduleLicense, moduleTest: this.props.moduleTest, camelModuleName: camelize(this.props.moduleName), githubUsername: this.props.githubUsername, name: this.props.name, email: this.props.email, website: this.props.website, humanizedWebsite: humanizeUrl(this.props.website), npmTestString: this.testFramework.test, npmTddString: this.testFramework.tdd, }; var cpTpl = function (from, to) { this.fs.copyTpl(this.templatePath(from), this.destinationPath(to), tpl); }.bind(this); cpTpl('_index.js', 'index.js'); cpTpl('_package.json', 'package.json'); cpTpl('_README.md', 'README.md'); cpTpl('editorconfig', '.editorconfig'); cpTpl('gitignore', '.gitignore'); cpTpl('gitignore', '.gitignore'); cpTpl('_test-' + this.props.moduleTest + '.js', 'test.js'); return depsObject(this.testFramework.deps) .then(function (devDeps) { this.saveDepsToPkg(devDeps); [ { travis: { config: { after_script: ['npm run coveralls'] } } }, { babel: { config: { plugins: ['add-module-exports'] } } }, { 'eslint-init': { config: { extends: 'airbnb/base', plugins: ['require-path-exists'] } } }, { 'git-init': { commit: this.commitMessage() } }, ].forEach(function (input) { this.composeWith( name(input), { options: R.merge(options(input), { 'skip-install': this.options.perfomant ? true : this.options['skip-install'], }) }, { local: require.resolve('generator-' + name(input)) } ); }.bind(this)); }.bind(this)) .catch(function (err) { throw err; }); },
const replicaCount = (_default = 2) => ( input( 'replicaCount', `How many ${superb()} replicas would you like?`, _default, (x) => validate.number(x) ) )
const gitRepo = (_default = defaults.repoName, prefix = 'Icelandair/') => ( input( 'gitRepo', `Name of ${superb()} git repository? ${prefix}**`, _default, (x) => (x.indexOf(prefix) !== 0 ? `${prefix}${x}` : x), (x) => validate.required(x, 'You have to set a gitRepo') ) )
const projectName = (_default) => ( input( 'projectName', `What's the name of your ${superb()} project?`, getDefaults(_default).projectName, (x) => _s.slugify(x), (x) => validate.dns(x) ) )
fs.writeFile(options.dest + '.css', fileContents, function(err) { if (err) { throw err; } // Write a success message var sup = superb(); sup = sup.charAt(0).toUpperCase() + sup.slice(1) + '!'; console.log(chalk.green(sup + ' CSS combined!\n')); });
prompting: function () { var done = this.async(); /* istanbul ignore if */ if (!this.options['skip-intro']) { // Have Yeoman greet the user. this.log(yosay( 'Welcome to the ' + superb() + ' Java generator!' )); } var prompts = [{ type: 'input' , name: 'title' , message: 'Name your project' , default: this.config.get('title') || this._.titleize(this.determineAppname()) , validate: function (input) { return input ? true : false; } }, { type: 'input' , name: 'description' , message: 'What\'s your project about? (optional)' , default: this.config.get('description') || null }, { type: 'input' , name: 'author' , message: 'What\'s your name?' , default: this.config.get('author') , validate: function (input) { return input ? true : false; } }, { type: 'input' , name: 'email' , message: 'What\'s your email?' , default: this.config.get('email') , validate: function (input) { return validator.isEmail(input); } }, { type: 'input' , name: 'namespace' , message: 'Choose a package namespace (optional)' , default: this.config.get('namespace') || null }]; this.prompt(prompts, function (props) { this.props = props; this.config.set(props); done(); }.bind(this)); },
askFor: function() { var done = this.async(); this.log(yosay( 'Welcome to the ' + superb() + ' spm generator!' )); var prompts = [ { name: 'name', message: 'Project Name', default: this.appname }, { name: 'version', message: 'Project Version', default: '0.1.0' }, { name: 'include', message: 'Include Mode', type: 'list', default: 'standalone', choices: [ 'relative', 'all', 'standalone' ] }, { name: 'dependencies', message: 'Dependencies' }, { name: 'type', message: 'Project Type', type: 'list', default: 'simple', choices: [ 'simple', 'complex' ] } ]; this.prompt(prompts, function (props) { extend(this, props); done(); }.bind(this)); },
}], function (props) { this.moduleName = props.moduleName; this.camelModuleName = _s.camelize(props.moduleName); this.githubUsername = props.githubUsername; this.name = this.user.git.name(); this.email = this.user.git.email(); this.website = props.website; this.humanizedWebsite = humanizeUrl(this.website); this.superb = superb(); this.template('editorconfig', '.editorconfig'); this.template('gitattributes', '.gitattributes'); this.template('gitignore', '.gitignore'); this.template('jshintrc', '.jshintrc'); this.template('travis.yml', '.travis.yml'); this.template('index.js'); this.template('license'); // needed so npm doesn't try to use it and fail this.template('_package.json', 'package.json'); this.template('readme.md'); this.template('test.js'); cb(); }.bind(this));
api.get('/greet', function (request) { 'use strict'; return Promise.resolve(request.queryString.name + ' is ' + superb()); });
#!/usr/bin/env node var superb = require('superb'); var exec = require('child_process').exec; var growl = require('growl'); var superbole = superb(); //console.log("You are " + superbole); exec("say you are " + superbole); growl("You are " + superbole + "!");
generateGroupName: function() { return 'LWS ' + _.startCase(superb()) + ' Site'; },
generateRoleName: function(type) { return 'LWS ' + _.startCase(superb()) + this.getRoleTypeLabel(type); },
api.get('/greet', function (request) { var superb = require('superb'); return request.queryString.name + ' is ' + superb(); });
prompting() { const done = this.async(); // Have Yeoman greet the user. this.log(yosay(`${titleCase(superb())}, let’s create an endpoint …`)); this.endpoint = { name: null, urls: [] }; const prompts = [ { type: 'input', name: 'endpointName', message: 'What should be the name of the endpoint?', when: () => { return !this.endpoint.urls.length; }, validate: helper.validateEndpoint }, { type: 'input', name: 'params', message: 'Please enter URL path params (optional)', validate: helper.validateParams }, { type: 'list', name: 'method', message: 'What should be the accepted method for this request?', choices: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] }, { type: 'list', name: 'responseType', message: 'What would you like to return?', choices: [ 'The content of a file', 'A JavaScript object literal as JSON', 'A file via Content-Disposition: attachment', 'An error object' ], filter: helper.filterResponseType }, { type: 'list', name: 'contentType', message: 'Which content type should it have?', choices: [ 'application/json', 'text/plain', 'text/html' ], filter: helper.filterContentType, when(answers) { return answers.responseType === 'fileContent'; } }, { type: 'input', name: 'response', message: 'Please enter the name of the JSON file', default: 'your-filename.json', when(answers) { return answers.contentType === 'json'; }, validate: helper.validateJson }, { type: 'input', name: 'response', message: 'Please enter the name of the text file', default: 'your-filename.txt', when(answers) { return answers.contentType === 'txt'; }, validate: helper.validateText }, { type: 'input', name: 'response', message: 'Please enter the name of the HTML file', default: 'your-filename.html', when(answers) { return answers.contentType === 'html'; }, validate: helper.validateHtml }, { type: 'input', name: 'response', message: 'Please enter a JavaScript object literal or array', default: '{ status: \'ok\' }', when(answers) { return answers.responseType === 'objectLiteral'; }, validate: helper.validateJsObject }, { type: 'input', name: 'response', message: 'Please enter the name of the file', when(answers) { return answers.responseType === 'fileAttachment'; }, validate: helper.validateFile }, { type: 'input', name: 'statusCode', message: 'Please enter a valid HTTP error status code', default: '400', when(answers) { return answers.responseType === 'error'; }, validate: helper.validateErrorStatusCode }, { type: 'input', name: 'statusCode', message: 'Please enter a valid HTTP status code', default: '200', when(answers) { return answers.responseType !== 'error'; }, validate: helper.validateStatusCode }, { type: 'confirm', name: 'anotherUrl', message: 'Should this endpoint have additional path params (just hit enter for YES)?', default: true } ]; prompting(this); function prompting(that) { that.prompt(prompts).then(props => { that.props = props; if (!that.endpoint.name) { that.endpoint.name = that.props.endpointName; } that.endpoint.urls.push({ params: that.props.params, requests: [{ method: that.props.method, responseType: that.props.responseType, contentType: that.props.contentType, response: that.props.response, statusCode: that.props.statusCode }] }); if (props.anotherUrl) { prompting(that); } else { done(); } }); } }
generateLayoutName: function() { return 'LWS ' + _.startCase(superb()) + ' Page'; },
init() { return this.prompt([{ name: 'moduleName', message: 'What do you want to name your module?', default: this.appname.replace(/\s/g, '-'), filter: x => moduleName.slugify(x) }, { name: 'moduleDescription', message: 'What is your module description?', default: `My ${superb()} module` }, { name: 'githubUsername', message: 'What is your GitHub username?', store: true, validate: x => x.length > 0 ? true : 'You have to provide a username', when: () => !this.options.org }, { name: 'website', message: 'What is the URL of your website?', store: true, validate: x => x.length > 0 ? true : 'You have to provide a website URL', filter: x => normalizeUrl(x) }, { name: 'cli', message: 'Do you need a CLI?', type: 'confirm', default: Boolean(this.options.cli), when: () => this.options.cli === undefined }, { name: 'nyc', message: 'Do you need code coverage?', type: 'confirm', default: Boolean(this.options.coveralls || this.options.coverage), when: () => (this.options.coverage === undefined) && (this.options.coveralls === undefined) }, { name: 'coveralls', message: 'Upload coverage to coveralls.io?', type: 'confirm', default: false, when: x => (x.nyc || this.options.coverage) && (this.options.coveralls === undefined) }]).then(props => { const or = (option, prop) => this.options[option] === undefined ? props[prop || option] : this.options[option]; const cli = or('cli'); const coveralls = or('coveralls'); const nyc = coveralls || or('coverage', 'nyc'); const repoName = moduleName.repoName(props.moduleName); const tpl = { moduleName: props.moduleName, moduleDescription: props.moduleDescription, camelModuleName: _s.camelize(repoName), githubUsername: this.options.org || props.githubUsername, repoName, name: this.user.git.name(), email: this.user.git.email(), website: props.website, humanizedWebsite: humanizeUrl(props.website), cli, nyc, coveralls }; const mv = (from, to) => { this.fs.move(this.destinationPath(from), this.destinationPath(to)); }; this.fs.copyTpl([ `${this.templatePath()}/**`, '!**/cli.js' ], this.destinationPath(), tpl); if (props.cli) { this.fs.copyTpl(this.templatePath('cli.js'), this.destinationPath('cli.js'), tpl); } mv('editorconfig', '.editorconfig'); mv('gitattributes', '.gitattributes'); mv('gitignore', '.gitignore'); mv('travis.yml', '.travis.yml'); mv('_package.json', 'package.json'); }); }
exports.handler = function (event, context) { 'use strict'; context.succeed(superb()); };