.then(function () { newConfig.server = _.merge({}, { port: port }, (newConfig.server || {})); if (newConfig.url) { newConfig.url = url.format(_.extend({}, url.parse(newConfig.url), { port: newConfig.server.port, host: null })); } else { newConfig.url = url.format(_.extend({}, url.parse(config.get('url')), { port: newConfig.server.port, host: null })); } newConfig.logging = { level: 'fatal', transports: ['stdout'], rotation: false }; /** * We never use the root content folder. * The tests fixtures provide the same folder structure (data, themes etc.) */ if (!newConfig.paths) { newConfig.paths = { contentPath: contentFolderForTests }; fs.ensureDirSync(contentFolderForTests); fs.ensureDirSync(path.join(contentFolderForTests, 'data')); fs.ensureDirSync(path.join(contentFolderForTests, 'themes')); fs.ensureDirSync(path.join(contentFolderForTests, 'images')); fs.ensureDirSync(path.join(contentFolderForTests, 'logs')); fs.ensureDirSync(path.join(contentFolderForTests, 'adapters')); fs.copySync(path.join(__dirname, 'fixtures', 'themes', 'casper'), path.join(contentFolderForTests, 'themes', 'casper')); } var newConfigFile = path.join(config.get('paths').appRoot, 'config.' + config.get('env') + '.json'); return new Promise(function (resolve, reject) { fs.writeFile(newConfigFile, JSON.stringify(newConfig), function (err) { if (err) { return reject(err); } // setup process environment for the forked Ghost to use the new config file var env = _.clone(process.env), baseKill, child, pingTries = 0, pingCheck, pingStop = function () { if (pingCheck) { clearInterval(pingCheck); pingCheck = undefined; return true; } return false; }; env.NODE_ENV = config.get('env'); child = cp.fork(path.join(config.get('paths').appRoot, 'index.js'), {env: env}); // return the port to make it easier to do requests child.port = newConfig.server.port; // periodic check until forked Ghost is running and is listening on the port pingCheck = setInterval(function () { var socket = net.connect(newConfig.server.port); socket.on('connect', function () { socket.end(); if (pingStop()) { resolve(child); } }); socket.on('error', function (err) { /*jshint unused:false*/ pingTries = pingTries + 1; // continue checking if (pingTries >= 100 && pingStop()) { child.kill(); reject(new Error('Timed out waiting for child process')); } }); }, 200); child.on('exit', function (code, signal) { /*jshint unused:false*/ child.exited = true; fs.unlink(newConfigFile, function () { // swallow any errors -- file may not exist if fork() failed }); if (pingStop()) { reject(new Error('Child process exit code: ' + code)); } }); // override kill() to have an async callback baseKill = child.kill; child.kill = function (signal, cb) { if (typeof signal === 'function') { cb = signal; signal = undefined; } if (cb) { child.on('exit', function () { cb(); }); } if (child.exited) { process.nextTick(cb); } else { baseKill.apply(child, [signal]); } }; }); }); });
.then(function (_invite) { should.not.exist(_invite); return models.User.findOne({ email: invite.get('email') }, _.merge({include: ['roles']}, context.internal)); })
module.exports = function(grunt) { var _ = require('lodash'); var path = require('path'); var pretty = require('pretty'); var mySlug = require('speakingurl').createSlug(); var resource_count = { resource_count: _.flatten(_.map(grunt.file.expand(['data/*.yml', '!data/people.yml']), function(filepath) { var data = grunt.file.readYAML(filepath); return Object.keys(data).length; })).reduce(function(a, b) { return a + b }) }; // @todo: merge with same var defined in _config.yml var tool_types = ['node', 'grunt', 'gulp', 'broccoli']; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), site: _.merge(grunt.file.readYAML('_config.yml'), resource_count), // --------------------------------------------------------------------- // Assemble // --------------------------------------------------------------------- assemble: { options: { engine: 'swig', flatten: true, site: '<%= site %>', assets: '<%= site.assets %>', data: '<%= site.data %>/*.{json,yml}', partials: '<%= site.partials %>', layoutdir: '<%= site.layouts %>', layout: '<%= site.layout %>', helpers: ['<%= site.helpers %>/*.js', '<%= site.helpers %>/filters/*.js'], plugins: ['assemble-contrib-permalinks'], }, // ----------------------------------------------------------------- // Site pages // ----------------------------------------------------------------- site: { options: { permalinks: { structure: ':section/:slug:ext', }, }, src: '<%= site.pages %>/*.swig', dest: '<%= site.dest %>/' }, // ----------------------------------------------------------------- // People pages // ----------------------------------------------------------------- people: { options: { pages: _.flatten(_.map(grunt.file.readYAML('data/people.yml'), function(data) { return { filename: mySlug(data.name), data: data, content: grunt.file.read('templates/partials/person.swig') } })), permalinks: { structure: ':basename/index:ext', }, }, src: '!*', dest: '<%= site.dest %>/people/' }, // ----------------------------------------------------------------- // Category pages // ----------------------------------------------------------------- category_pages: { options: { pages: _.flatten(_.map(grunt.file.readYAML('data/articles.yml'), function(data) { return { filename: mySlug(data.category), data: data, content: grunt.file.read('templates/partials/category.swig') } })), permalinks: { structure: ':basename/index:ext', }, }, src: '!*', dest: '<%= site.dest %>/articles/topic/' }, // ----------------------------------------------------------------- // Tool categories // ----------------------------------------------------------------- tool_categories: { options: { pages: _.flatten(_.map(tool_types, function(cat) { var data = grunt.file.readYAML('data/tools.yml'); var catItems = _.filter(data, function(d) { return _.has(d, cat); }); return { filename: mySlug(cat), data: {items: catItems}, content: grunt.file.read('templates/partials/tool_category.swig'), } })), permalinks: { structure: ':basename/index:ext', }, }, src: '!*', dest: '<%= site.dest %>/tools/' } }, // --------------------------------------------------------------------- // Compass // --------------------------------------------------------------------- compass: { site: { options: { bundleExec: true, relativeAssets: false, require: ['compass-normalize', 'breakpoint'], sassDir: '<%= site.sass %>', cssDir: '<%= site.dist_css %>', imagesDir: '<%= site.dist_img %>', httpImagesPath: '<%= site.img %>', }, }, }, // --------------------------------------------------------------------- // Clean // --------------------------------------------------------------------- clean: { site: ['<%= site.dest %>/**/*', '!<%= site.dest %>/.{git,gitignore}'], }, // --------------------------------------------------------------------- // Watch // --------------------------------------------------------------------- watch: { server: { options: { livereload: true, }, files: ['<%= site.dest %>/**/*'] }, assemble: { files: ['<%= site.data %>/*.{json,yml}', '<%= site.templates %>/**/*.swig'], tasks: ['assemble'], }, sass: { files: ['<%= site.sass %>/**/*.scss'], tasks: ['compass', 'autoprefixer'] }, images: { files: ['<%= site.theme_img %>/**'], tasks: ['imagemin','copy:images'] }, js: { files: ['<%= site.theme_js %>/**'], tasks: ['copy:js'] } }, // --------------------------------------------------------------------- // Copy // --------------------------------------------------------------------- copy: { images: { expand: true, flatten: true, src: '<%= site.theme_img %>/**', dest: '<%= site.dist_img %>/', }, js: { expand: true, flatten: true, src: '<%= site.theme_js %>/**', dest: '<%= site.dist_js %>/', }, cname: { expand: true, flatten: true, src: 'CNAME', dest: '<%= site.dest %>/', } }, // --------------------------------------------------------------------- // Connect // --------------------------------------------------------------------- connect: { server: { options: { port: 8000, base: '<%= site.dest %>', livereload: true, //keepalive: true, } } }, // --------------------------------------------------------------------- // Imagemin // --------------------------------------------------------------------- imagemin: { dist: { files: [{ expand: true, cwd: '<%= site.theme_img %>', src: ['**/*.{png,jpg,gif}'], dest: '<%= site.theme_img %>' }] } }, // --------------------------------------------------------------------- // Webp // --------------------------------------------------------------------- webp: { avatars: { expand: true, cwd: '<%= site.theme_img %>/avatars/', src: '*.jpg', dest: '<%= site.theme_img %>/avatars/' }, books: { expand: true, cwd: '<%= site.theme_img %>/book_covers/', src: '*.png', dest: '<%= site.theme_img %>/book_covers/' }, sponsor: { expand: true, cwd: '<%= site.theme_img %>/sponsor/', src: '*.jpg', dest: '<%= site.theme_img %>/sponsor/' }, }, // --------------------------------------------------------------------- // Autoprefixer // --------------------------------------------------------------------- autoprefixer: { options: { browsers: ['last 2 versions'] }, dist: { src: '<%= site.dist_css %>/style.css', dest: '<%= site.dist_css %>/style.css' } }, // --------------------------------------------------------------------- // Pixel to Rem // --------------------------------------------------------------------- px_to_rem: { dist: { options: { base: 16, }, files: { '<%= site.dist_css %>/style.css': ['<%= site.dist_css %>/style.css'] } } }, // --------------------------------------------------------------------- // unCSS // --------------------------------------------------------------------- uncss: { dist: { options: { ignore: ['.js', '.js .categories.is-active', '.btn-is-active', '.article-list.is-hidden'], stylesheets: ['assets/css/style.css'], htmlroot: '<%= site.dest %>', }, files: { '<%= site.dist_css %>/style.css': [ '<%= site.dest %>/index.html', '<%= site.dest %>/people/index.html', '<%= site.dest %>/articles/index.html', '<%= site.dest %>/tools/index.html', '<%= site.dest %>/talks-and-slides/index.html', '<%= site.dest %>/books/index.html', '<%= site.dest %>/people/addy-osmani/index.html' ] } } }, // --------------------------------------------------------------------- // CSSmin // --------------------------------------------------------------------- cssmin: { dist: { options: { report: 'gzip', keepSpecialComments: 0, }, files: { '<%= site.dest %>/assets/css/style.css': '<%= site.dest %>/assets/css/style.css' } } }, // --------------------------------------------------------------------- // Uglify // --------------------------------------------------------------------- uglify: { dist: { files: [{ expand: true, cwd: '<%= site.theme_js %>', src: '**/*.js', dest: '<%= site.dist_js %>' }] } }, // --------------------------------------------------------------------- // htmlbuild (embed CSS) // --------------------------------------------------------------------- htmlbuild: { dist: { expand: true, cwd: '<%= site.dest %>', src: '**/*.html', dest: '<%= site.dest %>/', ext: '.html', options: { styles: { test: '<%= site.dist_css %>/style.css' }, } } }, // --------------------------------------------------------------------- // Minify HTML // --------------------------------------------------------------------- htmlmin: { dist: { options: { removeComments: true, collapseWhitespace: true }, files: [{ expand: true, cwd: '<%= site.dest %>', src: '**/*.html', dest: '<%= site.dest %>' }] }, }, // --------------------------------------------------------------------- // Github Pages // --------------------------------------------------------------------- 'gh-pages': { options: { }, 'gh-pages': { options: { base: '<%= site.dest %>', message: 'New version', }, src: ['**/*'] }, }, }); grunt.loadNpmTasks('assemble'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-imagemin'); grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-compass'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-autoprefixer'); grunt.loadNpmTasks('grunt-html-build'); grunt.loadNpmTasks('grunt-px-to-rem'); grunt.loadNpmTasks('grunt-gh-pages'); grunt.loadNpmTasks('grunt-uncss'); grunt.loadNpmTasks('grunt-verb'); grunt.loadNpmTasks('grunt-webp'); // --------------------------------------------------------------------- // Build task // --------------------------------------------------------------------- grunt.registerTask('build', [ 'clean', 'assemble', 'webp', 'imagemin', 'copy:images', 'compass', 'autoprefixer', 'px_to_rem', 'uncss', 'cssmin', 'uglify', 'htmlbuild', 'htmlmin' ]); // --------------------------------------------------------------------- // Deploy to Github Pages task // --------------------------------------------------------------------- grunt.registerTask('deploy', [ 'build', 'copy:cname', 'gh-pages' ]); // --------------------------------------------------------------------- // Default development task // --------------------------------------------------------------------- grunt.registerTask('default', [ 'clean', 'assemble', 'copy:images', 'copy:js', 'compass', 'autoprefixer', 'px_to_rem', 'connect', 'watch', ]); };
.then((item) => _.merge(item, extra))
_.each(sails.middleware.controllers, function eachController (controller, controllerId) { if ( !_.isObject(controller) || _.isArray(controller) ) return; // Get globalId for use in errors/warnings var globalId = sails.controllers[controllerId].globalId; // Determine blueprint configuration for this controller var config = _.merge({}, sails.config.blueprints, controller._config || {}); // Validate blueprint config for this controller if ( config.prefix ) { if ( !_(config.prefix).isString() ) { sails.after('lifted', function () { sails.log.blank(); sails.log.warn(util.format('Ignoring invalid blueprint prefix configured for controller `%s`.', globalId)); sails.log.warn('`prefix` should be a string, e.g. "/api/v1".'); STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); }); return; } if ( !config.prefix.match(/^\//) ) { var originalPrefix = config.prefix; sails.after('lifted', function () { sails.log.blank(); sails.log.warn(util.format('Invalid blueprint prefix ("%s") configured for controller `%s` (should start with a `/`).', originalPrefix, globalId)); sails.log.warn(util.format('For now, assuming you meant: "%s".', config.prefix)); STRINGFILE.logMoreInfoLink(STRINGFILE.get('links.docs.config.blueprints'), sails.log.warn); }); config.prefix = '/' + config.prefix; } } // Determine the names of the controller's user-defined actions // IMPORTANT: Use `sails.controllers` instead of `sails.middleware.controllers` // (since `sails.middleware.controllers` will have blueprints already mixed-in, // and we want the explicit actions defined in the app) var actions = Object.keys(sails.controllers[controllerId]); // Determine base route var baseRoute = config.prefix + '/' + controllerId; if (config.pluralize) { baseRoute = pluralize(baseRoute); } // Build route options for blueprint var routeOpts = config; // Bind "actions" and "index" shadow routes for each action _.each(actions, function eachActionID (actionId) { var opts = _.merge({ action: actionId, controller: controllerId }, routeOpts); // Bind a route based on the action name, if `actions` shadows enabled if (config.actions) { var actionRoute = baseRoute + '/' + actionId.toLowerCase() + '/:id?'; sails.log.silly('Binding action ('+actionId.toLowerCase()+') blueprint/shadow route for controller:',controllerId); sails.router.bind(actionRoute, controller[actionId.toLowerCase()], null, opts); } // Bind base route to index action, if `index` shadows are not disabled if (config.index !== false && actionId.match(/^index$/i)) { sails.log.silly('Binding index blueprint/shadow route for controller:',controllerId); sails.router.bind(baseRoute, controller.index, null, opts); } }); // Determine the model connected to this controller either by: // -> explicit configuration // -> on the controller // -> on the routes config // -> or implicitly by globalId // -> or implicitly by controller id var routeConfig = sails.router.explicitRoutes[controllerId] || {}; var modelFromGlobalId = sails.util.findWhere(sails.models, {globalId: globalId}); var modelId = config.model || routeConfig.model || (modelFromGlobalId && modelFromGlobalId.identity) || controllerId; // If the orm hook is enabled, it has already been loaded by this time, // so just double-check to see if the attached model exists in `sails.models` // before trying to attach any CRUD blueprint actions to the controller. if (sails.hooks.orm && sails.models && sails.models[modelId]) { // If a model with matching identity exists, // extend route options with the id of the model. routeOpts.model = modelId; var Model = sails.models[modelId]; // Bind convenience functions for readability below: // Given an action id like "find" or "create", returns the appropriate // blueprint action (or explicit controller action if the controller // overrode the blueprint CRUD action.) var _getAction = _.partial(_getMiddlewareForShadowRoute, controllerId); // Returns a customized version of the route template as a string. var _getRoute = _.partialRight(util.format,baseRoute); // Mix in the known associations for this model to the route options. routeOpts = _.merge({ associations: _.cloneDeep(Model.associations) }, routeOpts); // Bind URL-bar "shortcuts" // (NOTE: in a future release, these may be superceded by embedding actions in generated controllers // and relying on action blueprints instead.) if ( config.shortcuts ) { sails.log.silly('Binding shortcut blueprint/shadow routes for model ', modelId, ' on controller:', controllerId); sails.router.bind( _getRoute('%s/find/:id?'), _getAction('find'), null, routeOpts ); sails.router.bind( _getRoute('%s/create'), _getAction('create'), null, routeOpts ); sails.router.bind( _getRoute('%s/update/:id'), _getAction('update'), null, routeOpts ); sails.router.bind( _getRoute('%s/destroy/:id?'), _getAction('destroy'), null, routeOpts ); // Bind add/remove "shortcuts" for each `collection` associations _(Model.associations).where({type: 'collection'}).forEach(function (association) { var alias = association.alias; var _getAssocRoute = _.partialRight(util.format, baseRoute, alias); var opts = _.merge({ alias: alias }, routeOpts); sails.log.silly('Binding "shortcuts" to association blueprint `'+alias+'` for',controllerId); sails.router.bind( _getAssocRoute('%s/:id/%s/add'), _getAction('add'), null, opts ); sails.router.bind( _getAssocRoute('%s/:id/%s/remove'), _getAction('remove'), null, opts ); }); } // Bind "rest" blueprint/shadow routes if ( config.rest ) { sails.log.silly('Binding RESTful blueprint/shadow routes for model+controller:',controllerId); sails.router.bind( _getRoute('get %s/:id?'), _getAction('find'), null, routeOpts ); sails.router.bind( _getRoute('post %s'), _getAction('create'), null, routeOpts ); sails.router.bind( _getRoute('put %s/:id'), _getAction('update'), null, routeOpts ); sails.router.bind( _getRoute('delete %s/:id?'), _getAction('destroy'), null, routeOpts ); // Bind "rest" blueprint/shadow routes based on known associations in our model's schema // Bind add/remove for each `collection` associations // and populate for both `collection` and `model` associations _(Model.associations).forEach(function (association) { var alias = association.alias; var _getAssocRoute = _.partialRight(util.format, baseRoute, alias); var opts = _.merge({ alias: alias }, routeOpts); sails.log.silly('Binding RESTful association blueprint `'+alias+'` for',controllerId); sails.router.bind( _getAssocRoute('get %s/:id/%s/:childid?'), _getAction('populate'), null, opts ); sails.router.bind( _getAssocRoute('post %s/:id/%s'), _getAction('add'), null, opts ); sails.router.bind( _getAssocRoute('delete %s/:id/%s'), _getAction('remove'), null, opts ); }); } } });
if (!v._hasfc) { v.analyzer.setFunctionConstructors(newValue); } }); return proto; } }; libraries = Object.create(proto); _.merge(libraries, { object: new PObject(), builtIn: new BuiltIn(), window: new Window(), // popular angular: new Angular(), // mine // t3: new Generic({ global: 't3' }), // huge three: new Generic({ global: 'THREE', rendereachtime: true }) }); // console.log(libraries); // win max level initially is 0 // libraries.win.preRender = function () { // libraries.win.getObjects().empty(); // libraries.win.analyzeObjects([window], 0); // };
addOptions (options) { _.merge(this.options, options) }
functionObj.events.forEach(event => { if (event.stream) { let EventSourceArn; let BatchSize = 10; let StartingPosition = 'TRIM_HORIZON'; let Enabled = 'True'; // TODO validate arn syntax if (typeof event.stream === 'object') { if (!event.stream.arn) { const errorMessage = [ `Missing "arn" property for stream event in function "${functionName}"`, ' The correct syntax is: stream: <StreamArn>', ' OR an object with an "arn" property.', ' Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Error(errorMessage); } if (typeof event.stream.arn !== 'string') { // for dynamic arns (GetAtt/ImportValue) if (!event.stream.type) { const errorMessage = [ `Missing "type" property for stream event in function "${functionName}"`, ' If the "arn" property on a stream is a complex type (such as Fn::GetAtt)', ' then a "type" must be provided for the stream, either "kinesis" or,', ' "dynamodb". Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Error(errorMessage); } if (Object.keys(event.stream.arn).length !== 1 || !(_.has(event.stream.arn, 'Fn::ImportValue') || _.has(event.stream.arn, 'Fn::GetAtt') || _.has(event.stream.arn, 'Fn::Join'))) { const errorMessage = [ `Bad dynamic ARN property on stream event in function "${functionName}"`, ' If you use a dynamic "arn" (such as with Fn::GetAtt, Fn::Join', ' or Fn::ImportValue) there must only be one key (either Fn::GetAtt, Fn::Join', ' or Fn::ImportValue) in the arn object. Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Error(errorMessage); } } EventSourceArn = event.stream.arn; BatchSize = event.stream.batchSize || BatchSize; StartingPosition = event.stream.startingPosition || StartingPosition; if (typeof event.stream.enabled !== 'undefined') { Enabled = event.stream.enabled ? 'True' : 'False'; } } else if (typeof event.stream === 'string') { EventSourceArn = event.stream; } else { const errorMessage = [ `Stream event of function "${functionName}" is not an object nor a string`, ' The correct syntax is: stream: <StreamArn>', ' OR an object with an "arn" property.', ' Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Error(errorMessage); } const streamType = event.stream.type || EventSourceArn.split(':')[2]; const streamName = (function () { if (EventSourceArn['Fn::GetAtt']) { return EventSourceArn['Fn::GetAtt'][0]; } else if (EventSourceArn['Fn::ImportValue']) { return EventSourceArn['Fn::ImportValue']; } else if (EventSourceArn['Fn::Join']) { // [0] is the used delimiter, [1] is the array with values const name = EventSourceArn['Fn::Join'][1].slice(-1).pop(); if (name.split('/').length) { return name.split('/').pop(); } return name; } return EventSourceArn.split('/')[1]; }()); const lambdaLogicalId = this.provider.naming .getLambdaLogicalId(functionName); const streamLogicalId = this.provider.naming .getStreamLogicalId(functionName, streamType, streamName); const funcRole = functionObj.role || this.serverless.service.provider.role; let dependsOn = '"IamRoleLambdaExecution"'; if (funcRole) { if ( // check whether the custom role is an ARN typeof funcRole === 'string' && funcRole.indexOf(':') !== -1 ) { dependsOn = '[]'; } else if ( // otherwise, check if we have an in-service reference to a role ARN typeof funcRole === 'object' && 'Fn::GetAtt' in funcRole && Array.isArray(funcRole['Fn::GetAtt']) && funcRole['Fn::GetAtt'].length === 2 && typeof funcRole['Fn::GetAtt'][0] === 'string' && typeof funcRole['Fn::GetAtt'][1] === 'string' && funcRole['Fn::GetAtt'][1] === 'Arn' ) { dependsOn = `"${funcRole['Fn::GetAtt'][0]}"`; } else if ( // otherwise, check if we have an import typeof funcRole === 'object' && 'Fn::ImportValue' in funcRole ) { dependsOn = '[]'; } else if (typeof funcRole === 'string') { dependsOn = `"${funcRole}"`; } } const streamTemplate = ` { "Type": "AWS::Lambda::EventSourceMapping", "DependsOn": ${dependsOn}, "Properties": { "BatchSize": ${BatchSize}, "EventSourceArn": ${JSON.stringify(EventSourceArn)}, "FunctionName": { "Fn::GetAtt": [ "${lambdaLogicalId}", "Arn" ] }, "StartingPosition": "${StartingPosition}", "Enabled": "${Enabled}" } } `; // add event source ARNs to PolicyDocument statements if (streamType === 'dynamodb') { dynamodbStreamStatement.Resource.push(EventSourceArn); } else if (streamType === 'kinesis') { kinesisStreamStatement.Resource.push(EventSourceArn); } else { const errorMessage = [ `Stream event of function '${functionName}' had unsupported stream type of`, ` '${streamType}'. Valid stream event source types include 'dynamodb' and`, ' \'kinesis\'. Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Properties .Policies[0] .PolicyDocument .Error(errorMessage); } const newStreamObject = { [streamLogicalId]: JSON.parse(streamTemplate), }; _.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources, newStreamObject); } });
module.exports = function(grunt) { grunt.loadNpmTasks('grunt-open'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-webpack'); grunt.loadNpmTasks('grunt-scaffold'); grunt.loadTasks("./node_modules/brixo-framework/grunt-tasks"); // Brixo Framework - default tasks configuration var brixoGrunt = require('brixo-framework/config/gruntfile.js')(grunt); // configure tasks entry points brixoGrunt.configItems('elements'); brixoGrunt.configItems('components'); brixoGrunt.configItems('modules'); var brixoUi = grunt.file.exists('node_modules/brixo-ui'); if(brixoUi) { brixoGrunt.configItems('node_modules/brixo-ui/styleguide'); } var projectGrunt = { open: _.merge(brixoGrunt.open, { start: { path : 'http://localhost:8090/' } }), jshint: { all: { src: ['gruntfile.js', 'components/**/*.js*', 'elements/**/*.js*', 'styleguide/**/*.js*'], jshintrc: true } }, karma: _.merge(brixoGrunt.karma, { // override karma configurations here }), webpack: _.merge(brixoGrunt.webpack, { // override webpack configurations here }), "webpack-dev-server": _.merge(brixoGrunt["webpack-dev-server"], { // override webpack dev server configurations here }), scaffold: require('brixo-framework/scaffolding/scaffold.config.js')(grunt, brixoGrunt.configItem), styleguide: { options: (function() { if(!brixoUi) { return {}; } return { root: 'node_modules/brixo-ui/', folders: ['elements'] } })() }, }; grunt.initConfig(projectGrunt); grunt.registerTask('default', ['open:start', 'webpack-dev-server:start']); };
column_blob: function (name, options) { return _.merge({ name: name, type: 'mediumblob' }, options || {}); },
column_varchar_500: function (name, options) { return _.merge({ name: name, type: 'varchar(500)' }, options || {}); },
column_text: function (name, options) { return _.merge({ name: name, type: 'mediumtext' }, options || {}); },
Channel.prototype.update = function (data) { _.merge(this.data, data); };
cache.get(NS, uuid, function(err, obj) { _.merge(res.locals.flash, obj); callback(); });
.then(tasks => { return _.merge(project, tasks); });
function(conf, callback){ conf = _.merge(conf,obj); return io.Config.save(conf,callback); }],
var merge = function(dest, source) { _.merge(dest,source,arrayMerge); return stripNulls(dest); }
_.forEach(results, value => { AST = _.merge(AST, value); });
.then(answersParam => { let answers = Object.assign({}, answersParam, { projectName }); // 复制文件前的自定义行为 if ( kitConfig.beforeInstallCopy && _.isFunction(kitConfig.beforeInstallCopy) ) { kitConfig.beforeInstallCopy.bind(this)( answers, folderPath, files ); } let newFiles = files.filter(item => { return !this.ignoreFiles.includes(item); }); newFiles.forEach(item => { let srcFiles = path.join(kitPath, item); let destFile = path.join(folderPath, item); if (this.fs.existsSync(srcFiles)) { this.fs.copySync(srcFiles, destFile); } }); if (answers.webserver) { this.fs.ensureFileSync( path.join(folderPath, 'config/steamer.config.js') ); this.fs.writeFileSync( path.join(folderPath, 'config/steamer.config.js'), 'module.exports = ' + JSON.stringify(answers, null, 4) ); } // 复制文件后的自定义行为 if ( kitConfig.afterInstallCopy && _.isFunction(kitConfig.afterInstallCopy) ) { kitConfig.afterInstallCopy.bind(this)(answers, folderPath); } if (isSteamerKit) { createPluginConfig.bind(this)( { kit: kit, version: ver }, folderPath ); } // 替换项目名称 if (projectName) { const oldPkgJson = this.getPkgJson.bind(this)(folderPath); let pkgJson = _.merge({}, oldPkgJson, { name: projectName }); this.fs.writeFileSync( path.join(folderPath, 'package.json'), JSON.stringify(pkgJson, null, 4), 'utf-8' ); } // beforeInstall 自定义行为 if ( kitConfig.beforeInstallDep && _.isFunction(kitConfig.beforeInstallDep) ) { kitConfig.beforeInstallDep.bind(this)(answers, folderPath); } // 安装项目node_modules包 this.spawn.sync(this.config.NPM, ['install'], { stdio: 'inherit', cwd: folderPath }); // afterInstall 自定义行为 if ( kitConfig.afterInstallDep && _.isFunction(kitConfig.afterInstallDep) ) { kitConfig.afterInstallDep.bind(this)(answers, folderPath); } this.success(`The project is initiated success in ${folderPath}`); })
var zowiMovementsFront = _.merge(_.clone(StatementBloq, true), { name: 'zowiMovementsFront', bloqClass: 'bloq-zowi-movements-front', content: [ [{ alias: 'text', value: 'bloq-zowi-movements-simple-walk-v1' }, { id: 'DIR', alias: 'staticDropdown', options: [{ label: 'bloq-zowi-movements-forward', value: 'FORWARD' }, { label: 'bloq-zowi-movements-backward', value: 'BACKWARD' }] }, { id: 'STEPS', alias: 'numberInput', value: 4 }, { alias: 'text', value: 'bloq-zowi-movements-speed' }, { id: 'SPEED', alias: 'staticDropdown', options: [{ label: 'bloq-zowi-movements-speed-small', value: 'LOW_SPEED' }, { label: 'bloq-zowi-movements-speed-medium', value: 'MEDIUM_SPEED' }, { label: 'bloq-zowi-movements-speed-high', value: 'HIGH_SPEED' }] }, { alias: 'text', value: 'bloq-zowi-movements-endtext' }] ], code: 'zowi.walk({STEPS},{SPEED},{DIR});', arduino: { includes: ['BitbloqZowi.h', 'BitbloqUS.h', 'BitbloqBatteryReader.h', 'BitbloqLedMatrix.h', 'Servo.h', 'BitbloqOscillator.h', 'EEPROM.h' ], needInstanceOf: [{ name: 'zowi', type: 'Zowi' }], setupExtraCode: 'zowi.init();', code: 'zowi.walk({STEPS},{SPEED},{DIR});' } });
module.exports = _.merge(_.cloneDeep(require("../services/baseModel")), { attributes: { username: { type: "string", required: true, unique: true }, firstName: { type: "string", required: true }, lastName: { type: "string", required: true }, email: { type: "email", required: true, unique: true }, admin: { type: "boolean", defaultsTo: false }, password: { type: "string", required: false }, language: { type: "string", defaultsTo: "fi", required: true }, momentFormatDate: { type: "string", defaultsTo: "L", required: true }, momentFormatTime: { type: "string", defaultsTo: "LT", required: true }, momentFormatDateTime: { type: "string", defaultsTo: "L LT", required: true }, momentTimezone: { type: "string", defaultsTo: "Europe/Mariehamn", required: true }, taskTemplateChangeLimit: { type: "integer", defaultsTo: 6, required: true }, boardSettingHideDoneStories: { type: "boolean", defaultsTo: false, required: true }, sessionId: { type: "string", defaultsTo: "" }, // Dynamic data attributes // Computed user fullName string fullName: function() { return this.lastName + " " + this.firstName; }, // Gravatar image url gravatarImage: function(size) { size = size || 25; return gravatar.url(this.email, {s: size, r: "pg", d: "mm"}, true); }, // Override toJSON instance method to remove password value toJSON: function() { var obj = this.toObject(); delete obj.password; delete obj.sessionId; return obj; }, // Validate password validPassword: function(password, callback) { var obj = this.toObject(); if (callback) { return bcrypt.compare(password, obj.password, callback); } else { return bcrypt.compareSync(password, obj.password); } } }, // Life cycle callbacks /** * Before create callback. * * @param {sails.model.user} values * @param {Function} next */ beforeCreate: function(values, next) { hashPassword(values, next); }, /** * Before update callback. * * @param {sails.model.user} values * @param {Function} next */ beforeUpdate: function(values, next) { if (values.id) { DataService.getUser(values.id, function(error, user) { if (!error) { // User try to make himself an administrator user, no-way-hose :D if (values.admin && !user.admin) { values.admin = false; } if (values.password) { return hashPassword(values, next); } else { values.password = user.password; } } return next(error); }); } else { next(); } }, /** * After create callback. * * @param {sails.model.user} values * @param {Function} next */ afterCreate: function(values, next) { HistoryService.write("User", values); next(); }, /** * After update callback. * * @param {sails.model.user} values * @param {Function} next */ afterUpdate: function(values, next) { HistoryService.write("User", values); next(); }, /** * Before destroy callback. * * @param {{}} terms * @param {Function} next */ beforeDestroy: function(terms, next) { DataService.getUser(terms, function(error, user) { if (!error) { HistoryService.remove("User", user.id); } next(error); }); } });
const updateDocPromise = (doc) => { const members = _.filter(doc._source.members, single => single.id !== member.id); // eslint-disable-line no-underscore-dangle return Promise.resolve(_.merge(doc._source, { members })); // eslint-disable-line no-underscore-dangle };
var heroin = require('heroin-js'); var _ = require('lodash'); var base = require('./base'); var prod = { name: 'training-tomek' }; var prod_merged = _.merge(base.base, prod); base.configurator(prod_merged);
const members = _.map(doc._source.members, (single) => { // eslint-disable-line no-underscore-dangle if (single.id === data.original.id) { return _.merge(single, payload); } return single; });
.then(function (_invite) { invite = _invite; invite.toJSON().role_id.should.eql(testUtils.DataGenerator.Content.roles[0].id); return models.Invite.edit({status: 'sent'}, _.merge({}, {id: invite.id}, context.internal)); })
mongo: { options: { db: { safe: true } } }, files_root_path: process.cwd() + "/.tmp", max_results_in_page: 20 }; // Export the config object based on the NODE_ENV // ============================================== var config = _.merge( all, require('./' + process.env.NODE_ENV + '.js') || {}); // TODO: this method need to be moved var setup_file_directories = function() { // upload paths config.uploads_uri = "/uploads"; config.product_photo_uri = config.uploads_uri + '/photos/products'; config.uploads_path = config.files_root_path + config.uploads_uri; config.product_photo_path = config.files_root_path + config.product_photo_uri; config.themes_path = config.files_root_path + "/themes"; config.log_files_root_path = config.files_root_path + "/logs";
// Server port port: process.env.PORT || 9000, // Server IP ip: process.env.IP || '0.0.0.0', // Should we populate the DB with sample data? seedDB: false, // Secret for session, you will want to change this and make it an environment variable secrets: { session: 'infovis-secret' }, // MongoDB connection options mongo: { options: { db: { safe: true } } } }; // Export the config object based on the NODE_ENV // ============================================== module.exports = _.merge( all, require('./shared'), require('./' + process.env.NODE_ENV + '.js') || {});
assertions.forEach((assert) => { assert.expectation(Tooltip.getPosition( merge({}, baseParams, assert.params) )); });
updateConfig(config) { this._config = _.merge(this._config, config || {}); }
// MIT License, Copyright 2016, Jaco Greeff <*****@*****.**> import React from 'react'; import ReactDOM from 'react-dom'; import { defaults as chartjsDefaults } from 'react-chartjs-2'; import { merge } from 'lodash'; import Application from './application'; import Store from './store'; import '../assets/fonts/font-awesome-4.7.0/css/font-awesome.css'; import '../assets/fonts/Roboto/font.css'; import '../assets/images/vote.jpg'; import './index.css'; import './index.html'; merge(chartjsDefaults, { global: { defaultFontSize: 16 } }); const store = new Store(); ReactDOM.render( <Application store={ store } />, document.querySelector('#container') );