Git Product home page Git Product logo

serverless-ignore's Introduction

serverless-ignore

serverless npm npm

Serverless plugin to ignore files like a .gitignore

Why

  • Remove long list of hardcoded exclude files from serverless.yml
  • Better managing between different serverless.yml (just add a different .slsignore)
  • Same approach of .gitignore

Install

npm install --save-dev serverless-ignore

Note:

  • for serverless version < 2 use version ^0.1.6

Usage

Add serverless-ignore to your plugins list (serverless.yml)

plugins:
  - serverless-ignore

Add a .slsignore in your root folder with a .gitignore-like syntax with all the files you want to ignore

Example:

# it works like a .gitignore
# for sls
README.md
*.log

# ignore aws-sdk
node_modules/aws-sdk/*

.env.example
.git/*
__tests__/*

serverless-ignore's People

Contributors

nya1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zodman ilyasmez

serverless-ignore's Issues

Ignore negations not implemented

In the code the negations are skipped. This misses a critical feature in an ignore file: how to ignore all except some.

Use case: I want to drop everything in the locutus module except the datetime files I'm interested in:

node_modules/locutus/**
!node_modules/locutus/php/datetime/**/*.js

Since the current code skips all negated patterns I wind up not having anything in the locutus folder.

The following works in the serverless.yaml file, per the documentation:

package:
  patterns:
    - "!node_modules/locutus/**"
    - "node_modules/locutus/php/datetime/**/*.js"

Thus there's a workaround: handle most ignores in the .slsignore file, but anything you need negations for use the serverless.yaml file.

Cannot read property 'file' of undefined

I've added the plugin as described in the README, but whenever I try to deploy, I get this error:

Serverless Ignore Error --------------------------------------
    Cannot read property 'file' of undefined

And the deployment is done with the files I put in . slsignore


Steps to reproduce:

1- Install the plugin.
2- Add a custom variable to your serverless.yml and make sure ignore is not there.
3- Create a .slsignore file with some files to ignore.
4- Run serverless deploy

You should see the error above in your console and your files won't be ignored.

node_modules folder been uploaded even if its in slsignore

The folder of node modules is uploaded even if its in the slsignore.
My sls ignore is like below:

node_modules/*
package.json
package-lock.json
script.py
Notas.txt

my package.json is like below:

{
    "devDependencies": {
      "serverless-python-requirements": "^5.4.0",
      "mfa-serverless-plugin": "^0.0.5",
      "serverless-ignore": "^0.2.1",
      "serverless-plugin-scripts": "^1.0.2"
  }
}

Im not understanding why the folder its been uploaded even that its ignored, also .github and .slsignore files are uploaded too. My node version is: 16.14.2

.slsignore file getting bundled in sls deploy zip file

I'm trying out your plugin and noticed that it is ignoring the file as what my terminal shows

Serverless: SERVERLESS-IGNORE: Loaded .slsignore
Serverless:      - ./bucket/*
Serverless:      - ./frontend/*
Serverless:      - ./object/deleteObject.js
Serverless:      - ./object/deleteObjects.js
Serverless:      - ./object/getObject-presignedURL.js
Serverless:      - ./object/getObjectTorrent.js
Serverless:      - ./object/listObjects.js

but what I'm noticing is that the these files are ending up in getting bundled in sls deploy zip file. So I want to know is anything wrong on my part or it ignores loading these files in lambda but does gets them deployed?

sls deploy -v no longer working

After installing serverless-ignore, adding serverless-ignore to my plugins, and adding a .slsignore my code no longer deploys to aws cloudformation when i run sls deploy -v. I receive no errors literally nothing happens. After commenting out that plugin everything works as expected. I'm on version 2.48.0.

image (1)

Warning: The command you entered did not catch on any hooks when I try to deploy the plugin

I have the following serverless.yml file :

service: zendesk

frameworkVersion: "2"

provider:
  name: aws
  runtime: python3.8
  stage: "dev"
  region: eu-west-1
  lambdaHashingVersion: 20201221

functions:
  collections-next14days:
    handler: col14d.main
  deliveries-next14days:
    handler: del14d.main
  add-comment:
    handler: add-comment.main
  tag-first-comment:
    handler: tag-first-comment.main
  tag-last-reply:
    handler: tag-last-reply.main
  create-ticket:
    handler: create-ticket.main
  create-ticket-w-attachement:
    handler: create-ticket-w-attach.main
  create-viagra-ticket:
    handler: create-viagra-ticket.main
  create-stripe-order-ticket:
    handler: create-stripe-order-ticket.main

plugins:
  - serverless-python-requirements
  # - serverless-ignore

custom:
  test: true
  stages:
    - dev
    - prod

All is working well and I can deploy via serverless deploy but as soon as I install serverless-ignore (via npm --save-dev) and add it in the .yml file in my list of plugins I get the following log at deploy :

Serverless: Deprecation warning: Detected ".env" files. In the next major release variables from ".env" files will be automatically loaded into the serverless build process. Set "useDotenv: true" to adopt that behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
user: thomas zendesk on  master [✘!?] via ⬢ v14.17.0 via 🐍 v3.8.6 (venv) via  13GiB/23GiB | 0B/4GiB on ☁️  (eu-west-1) took 2s 
🕙[ 18:55 ] ➜ SLS_DEBUG=* serverless deploy
Serverless: Deprecation warning: Detected ".env" files. In the next major release variables from ".env" files will be automatically loaded into the serverless build process. Set "useDotenv: true" to adopt that behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command deploy
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
Serverless: Load command requirements:cleanCache
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Skipping variables resolution with old resolver (new resolver reported no more variables to resolve)
Serverless: Invoke deploy
Serverless: Warning: The command you entered did not catch on any hooks

As soon as I comment out - serverless-ignore I can deploy just as expected.

.slsignore file not detected

According to the documentation I have my .slsignore file in the root of the project, however the plugin is not able to detect that file.
Also in plugins is added the same plugin of the yml file.

The error I receive is:

Serverless Ignore Error --------------------------------------   ENOENT: no such file or directory, open '.slsignore'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.