agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
229 stars 54 forks source link

Added --ignore-scripts #83

Closed Shereef closed 2 years ago

Shereef commented 2 years ago

Some repos like one of mine has a postinstall script in my package.json and causes it to throw exceptions

this small change fixes that

Please review and thanks!

Shereef commented 2 years ago

@agutoli Please consider looking at this soon as it gets annoying having to make this change manually to my node_modules folder every deploy

Thanks!

agutoli commented 2 years ago

I've implemented something a bit different which should solve your problem as well. Could you check this PR, please?

https://github.com/agutoli/serverless-layers/pull/84/files


custom:
  serverless-layers:
    packageManagerExtraArgs: '--ignore-scripts --option a --option b...'
agutoli commented 2 years ago

I've created a new version serverless-layers@2.5.2-beta.0 in case you want to test this approach.

Shereef commented 2 years ago

It doesn't work for me

[ LayersPlugin ]: => default
... ○ Downloading package.json from bucket...
... ○ Comparing package.json dependencies...
... ○  Changes identified ! Re-installing...
... ∅ [warning] ".npmrc" file does not exists!
... ∅ [warning] "yarn.lock" file does not exists!

✖ Stack daysmart-booking-service-sandbox failed to deploy (2s)
Environment: darwin, node 14.18.2, framework 3.1.1 (local), plugin 6.0.0, SDK 4.3.1
Credentials: Local, "sandbox" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: Command failed: npm 
    at checkExecSyncError (child_process.js:790:11)
    at execSync (child_process.js:863:15)
    at /Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:86:41
    at handleSubProcessSync (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:30:36)
    at childProcess.execSync (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/cli-progress-footer/lib/private/cli-progress-footer/disable-props.js:85:11)
    at Dependencies._callee$ (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/serverless-layers/lib/package/Dependencies.js:80:26)
    at tryCatch (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:294:22)
    at Generator.next (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:119:21)
    at asyncGeneratorStep (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at Dependencies.<anonymous> (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)
    at Dependencies.run (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/serverless-layers/lib/package/Dependencies.js:96:21)
    at Dependencies._callee2$ (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/serverless-layers/lib/package/Dependencies.js:194:29)
    at tryCatch (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:294:22)
    at Generator.next (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/regenerator-runtime/runtime.js:119:21)
    at asyncGeneratorStep (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/Users/shereef.marzouk/Dev/daysmart-booking/service/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

I installed: "serverless-layers": "^2.5.2-beta.0",

Shereef commented 2 years ago

There is another branch generously introduced by the author that does this better

Closing this PR