Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serverless-build-plugin

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-build-plugin - npm Package Compare versions

Comparing version 0.0.1-alpha to 0.0.1-alpha.2

lib/FileBuild.js

2

index.js
require('babel-register') // FIXME: testing only
module.exports = require('./lib/ServerlessBuild')
module.exports = require('./lib/ServerlessBuildPlugin')

@@ -13,4 +13,5 @@ import Promise from 'bluebird'

export default class ModuleBundler {
constructor(plugin) {
this.plugin = plugin
constructor(plugin, artifact) {
this.plugin = plugin
this.artifact = artifact
}

@@ -21,15 +22,12 @@

*
* @param {Yazl} artifactZip - Instance of Yazl
* @param {Array} whiteList
* @param {Array} includes
* [ "bluebird", ... ]
*/
async bundle(artifactZip, { whiteList = [] } = {}) {
console.inspect({ whiteList })
async bundle({ includes = [], excludes = [] }) {
console.inspect({ includes })
const { ignoredModules } = this.plugin.config
includes = includes.filter((packageName) => excludes.indexOf(packageName) > -1)
whiteList = whiteList.filter((packageName) => ignoredModules.indexOf(packageName) > -1)
const modules = await this._resolveDependencies(this.plugin.serverless.config.servicePath, { includes })
const modules = await this._resolveDependencies(this.plugin.serverless.config.servicePath, { whiteList })
await Promise.map(modules, async ({ packagePath, relativePath }) => {

@@ -46,3 +44,3 @@ console.inspect(`Adding module ${relativePath}...`)

artifactZip.addFile(filePath, zipPath, this.plugin.config.zip)
this.artifact.addFile(filePath, zipPath, this.plugin.config.zip)
next()

@@ -56,3 +54,3 @@ }

return artifactZip
return this.artifact
}

@@ -66,3 +64,3 @@

*/
async _resolveDependencies(initialPackageDir, { whiteList } = {}) {
async _resolveDependencies(initialPackageDir, { includes } = {}) {
const resolvedDeps = []

@@ -83,3 +81,3 @@ const cache = {}

for ( let packageName in dependencies ) {
if ( whiteList && whiteList.indexOf(packageName) === -1 ) continue
if ( includes && includes.indexOf(packageName) === -1 ) continue

@@ -86,0 +84,0 @@ const mainFile = await requireResolve(packageName, { basedir: packageDir })

import Promise from 'bluebird'
import path, { sep } from 'path'
import path from 'path'
import fs from 'fs-extra'

@@ -14,4 +14,5 @@ import { typeOf } from 'lutils'

export default class SourceBundler {
constructor(plugin) {
this.plugin = plugin
constructor(plugin, artifact) {
this.plugin = plugin
this.artifact = artifact
}

@@ -23,7 +24,7 @@

*
* @param {Yazl} artifactZip - Instance of Yazl
* @param {Yazl} artifact - Instance of Yazl
* @param {Array} whiteList
* [ "bluebird", ... ]
*/
async bundle(artifactZip, { ignores = [], includes = [], transforms } = []) {
async bundle({ excludes = [], includes = [], transforms }) {
const { servicePath } = this.plugin.serverless.config

@@ -49,4 +50,4 @@

if ( ignores.length ) {
const isIgnored = ignores.some(testPattern)
if ( excludes.length ) {
const isIgnored = excludes.some(testPattern)

@@ -68,3 +69,3 @@ if ( isIgnored ) {

// artifactZip.addFile(filePath, zipPath, this.plugin.config.zip)
// this.artifact.addFile(filePath, zipPath, this.plugin.config.zip)
next()

@@ -77,3 +78,3 @@ }

return artifactZip
return this.artifact
}

@@ -83,3 +84,3 @@

* Finds both .serverless-include and .serverless-ignore files
* Generates a concatenated ignores and includes list.
* Generates a concatenated excludes and includes list.
*

@@ -92,3 +93,3 @@ * All pathing is resolved to the servicePath, so that "*" in <servicePath>/lib/.serverless-ignore

* includes: [ "./lib/**", ... ],
* ignores: [ ".git", "*", ... ]
* excludes: [ ".git", "*", ... ]
* }

@@ -98,3 +99,3 @@ */

const includes = []
const ignores = []
const excludes = []

@@ -123,3 +124,3 @@ const parseFile = async (filePath) => {

const lines = await parseFile(filePath)
ignores.push(...lines)
excludes.push(...lines)
} else

@@ -135,7 +136,7 @@ if ( name === '.serverless-include' ) {

console.log({ includes, ignores })
console.log({ includes, excludes })
return { includes, ignores }
return { includes, excludes }
}
}

@@ -15,8 +15,9 @@ import Promise from 'bluebird'

async build(config) {
const {
service: { functions = [] },
config: { servicePath }
} = this.plugin.serverless
const { servicePath } = this.plugin.serverless.config
// TODO: review the below with multi fn
const { functions } = this.plugin
// TODO: make this build on a single function basis with one entry in order to
// allow for each function to dictate build methods
let entryPoints = []

@@ -26,2 +27,3 @@ for ( let fnName in functions ) {

.split('.').join('/')
if ( entryPoints.indexOf(entry) < 0 ) entryPoints.push(entry)

@@ -28,0 +30,0 @@ }

{
"name": "serverless-build-plugin",
"version": "0.0.1-alpha",
"main": "./index",
"name" : "serverless-build-plugin",
"version" : "0.0.1-alpha.2",
"main" : "./index",
"dependencies": {

@@ -13,7 +14,9 @@ "is-stream" : "~1.1.0",

"minimatch" : "~3.0.3",
"js-yaml" : "~3.6.1",
"lutils" : "^1.1.0"
},
"devDependencies": {
"eslint" : "~2.7.0",
"babel-eslint" : "~6.0.2",
"eslint" : "~2.7.0",
"babel-eslint" : "~6.0.2",

@@ -41,3 +44,8 @@ "nyc" : "~6.2.1",

"webpack" : "~2.1.0-beta.20"
},
"respository": {
"type" : "git",
"url" : "https://github.com/nfour/serverless-build-plugin"
}
}
# SERVERLESS BUILD PLUGIN
`*** WARNING ***` This is a development release, do not use outside of experimentation.
This plugin is intended to add flexibility to the serverless build process for serverless 1.0.

@@ -3,0 +6,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc