Skip to content

Commit 2242c47

Browse files
authored
Merge branch 'master' into patch-1
2 parents 1ac00ad + 1e280d4 commit 2242c47

24 files changed

+229
-172
lines changed

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "10:00"
8+
open-pull-requests-limit: 10
9+
ignore:
10+
- dependency-name: eslint
11+
versions:
12+
- "> 7.22.0"

.github/workflows/lint.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
runs-on: ${{ matrix.os }}
8-
strategy:
9-
fail-fast: false
10-
matrix:
11-
os: [ubuntu-latest]
12-
node-version: [12]
7+
runs-on: ubuntu-latest
138
steps:
149
- uses: actions/checkout@v2
1510

1611
- name: Set up Node ${{ matrix.node-version }}
1712
uses: actions/setup-node@v1
1813
with:
19-
node-version: ${{ matrix.node-version }}
14+
node-version: 14
2015

2116
- name: Install deps
2217
run: npm install

.github/workflows/publish.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ jobs:
66
publish-npm:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v1
10-
- uses: actions/setup-node@v1
9+
- uses: actions/checkout@v2
10+
11+
- uses: actions/setup-node@v2
1112
with:
12-
version: 12
13+
version: 14
1314
registry-url: https://registry.npmjs.org/
15+
1416
- run: npm publish
1517
env:
1618
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/test.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
os: [ubuntu-latest, windows-latest, macOS-latest]
12-
python-version: [3.6, 2.7]
13-
node-version: [12]
12+
python-version: [2.7, 3.6]
1413
steps:
1514
- uses: actions/checkout@v2
1615

@@ -19,10 +18,10 @@ jobs:
1918
with:
2019
python-version: ${{ matrix.python-version }}
2120

22-
- name: Set up Node ${{ matrix.node-version }}
21+
- name: Set up Node
2322
uses: actions/setup-node@v1
2423
with:
25-
node-version: ${{ matrix.node-version }}
24+
node-version: 14
2625

2726
- name: Check python version
2827
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ __pycache__
4545

4646
#NODE STUFF
4747
package-lock.json
48+
yarn.lock

.tool-versions

-2
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ custom:
105105
## :sparkles::pencil::sparkles: Poetry support
106106

107107
If you include a `pyproject.toml` and have `poetry` installed instead of a `requirements.txt` this will use
108-
`poetry export --without-hashes -f requirements.txt -o requirements.txt` to generate them. It is fully compatible with all options such as `zip` and
108+
`poetry export --without-hashes -f requirements.txt -o requirements.txt --with-credentials` to generate them. It is fully compatible with all options such as `zip` and
109109
`dockerizePip`. If you don't want this plugin to generate it for you, set the following option:
110110

111111
```yaml

index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ class ServerlessPythonRequirements {
151151
.then(cleanup)
152152
.then(removeVendorHelper);
153153

154+
const setupArtifactPathCapturing = () => {
155+
// Reference:
156+
// https://github.com/serverless/serverless/blob/9591d5a232c641155613d23b0f88ca05ea51b436/lib/plugins/package/lib/packageService.js#L139
157+
// The packageService#packageFunction does set artifact path back to the function config.
158+
// As long as the function config's "package" attribute wasn't undefined, we can still use it
159+
// later to access the artifact path.
160+
for (const functionName in this.serverless.service.functions) {
161+
if (!serverless.service.functions[functionName].package) {
162+
serverless.service.functions[functionName].package = {};
163+
}
164+
}
165+
};
166+
154167
const before = () => {
155168
if (!isFunctionRuntimePython(arguments)) {
156169
return;
@@ -160,7 +173,8 @@ class ServerlessPythonRequirements {
160173
.then(pyprojectTomlToRequirements)
161174
.then(addVendorHelper)
162175
.then(installAllRequirements)
163-
.then(packRequirements);
176+
.then(packRequirements)
177+
.then(setupArtifactPathCapturing);
164178
};
165179

166180
const after = () => {

lib/clean.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function cleanup() {
1414
const artifacts = ['.requirements'];
1515
if (this.options.zip) {
1616
if (this.serverless.service.package.individually) {
17-
this.targetFuncs.forEach(f => {
17+
this.targetFuncs.forEach((f) => {
1818
artifacts.push(path.join(f.module, '.requirements.zip'));
1919
artifacts.push(path.join(f.module, 'unzip_requirements.py'));
2020
});
@@ -25,7 +25,7 @@ function cleanup() {
2525
}
2626

2727
return BbPromise.all(
28-
artifacts.map(artifact =>
28+
artifacts.map((artifact) =>
2929
fse.removeAsync(path.join(this.servicePath, artifact))
3030
)
3131
);
@@ -47,7 +47,7 @@ function cleanupCache() {
4747
const promises = [];
4848
glob
4949
.sync([path.join(cacheLocation, '*slspyc/')], { mark: true, dot: false })
50-
.forEach(file => {
50+
.forEach((file) => {
5151
promises.push(fse.removeAsync(file));
5252
});
5353
return BbPromise.all(promises);

lib/docker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function tryBindPath(serverless, bindPath, testFile) {
8181
`${bindPath}:/test`,
8282
'alpine',
8383
'ls',
84-
`/test/${testFile}`
84+
`/test/${testFile}`,
8585
];
8686
try {
8787
if (debug) serverless.cli.log(`Trying bindPath ${bindPath} (${options})`);
@@ -167,7 +167,7 @@ function getDockerUid(bindPath) {
167167
'stat',
168168
'-c',
169169
'%u',
170-
'/bin/sh'
170+
'/bin/sh',
171171
];
172172
const ps = dockerCommand(options);
173173
return ps.stdout.trim();

lib/inject.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ function injectRequirements(requirementsPath, packagePath, options) {
2121

2222
return fse
2323
.readFileAsync(packagePath)
24-
.then(buffer => JSZip.loadAsync(buffer))
25-
.then(zip =>
24+
.then((buffer) => JSZip.loadAsync(buffer))
25+
.then((zip) =>
2626
BbPromise.resolve(
2727
glob.sync([path.join(requirementsPath, '**')], {
2828
mark: true,
29-
dot: true
29+
dot: true,
3030
})
3131
)
32-
.map(file => [file, path.relative(requirementsPath, file)])
32+
.map((file) => [file, path.relative(requirementsPath, file)])
3333
.filter(
3434
([file, relativeFile]) =>
3535
!file.endsWith('/') &&
@@ -42,7 +42,7 @@ function injectRequirements(requirementsPath, packagePath, options) {
4242
.mapSeries(([file, relativeFile, fileStat]) =>
4343
zipFile(zip, relativeFile, fse.readFileAsync(file), {
4444
unixPermissions: fileStat.mode,
45-
createFolders: false
45+
createFolders: false,
4646
})
4747
)
4848
.then(() => writeZip(zip, packagePath))
@@ -61,16 +61,16 @@ function moveModuleUp(source, target, module) {
6161

6262
return fse
6363
.readFileAsync(source)
64-
.then(buffer => JSZip.loadAsync(buffer))
65-
.then(sourceZip =>
64+
.then((buffer) => JSZip.loadAsync(buffer))
65+
.then((sourceZip) =>
6666
sourceZip.filter(
67-
file =>
67+
(file) =>
6868
file.startsWith(module + '/') ||
6969
file.startsWith('serverless_sdk/') ||
7070
file.match(/^s_.*\.py/) !== null
7171
)
7272
)
73-
.map(srcZipObj =>
73+
.map((srcZipObj) =>
7474
zipFile(
7575
targetZip,
7676
srcZipObj.name.startsWith(module + '/')
@@ -96,18 +96,18 @@ function injectAllRequirements(funcArtifact) {
9696

9797
if (this.serverless.service.package.individually) {
9898
return BbPromise.resolve(this.targetFuncs)
99-
.filter(func =>
99+
.filter((func) =>
100100
(func.runtime || this.serverless.service.provider.runtime).match(
101101
/^python.*/
102102
)
103103
)
104-
.map(func => {
104+
.map((func) => {
105105
if (!get(func, 'module')) {
106106
set(func, ['module'], '.');
107107
}
108108
return func;
109109
})
110-
.map(func => {
110+
.map((func) => {
111111
if (func.module !== '.') {
112112
const artifact = func.package ? func.package.artifact : funcArtifact;
113113
const newArtifact = path.join(
@@ -122,7 +122,7 @@ function injectAllRequirements(funcArtifact) {
122122
return func;
123123
}
124124
})
125-
.map(func => {
125+
.map((func) => {
126126
return this.options.zip
127127
? func
128128
: injectRequirements(

lib/layer.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function createLayers() {
3636
}-${this.serverless.providers.aws.getStage()}-python-requirements`,
3737
description:
3838
'Python requirements generated by serverless-python-requirements.',
39-
compatibleRuntimes: [this.serverless.service.provider.runtime]
39+
compatibleRuntimes: [this.serverless.service.provider.runtime],
4040
},
4141
this.options.layer
4242
);
@@ -55,11 +55,9 @@ function layerRequirements() {
5555

5656
this.serverless.cli.log('Packaging Python Requirements Lambda Layer...');
5757

58-
return BbPromise.bind(this)
59-
.then(zipRequirements)
60-
.then(createLayers);
58+
return BbPromise.bind(this).then(zipRequirements).then(createLayers);
6159
}
6260

6361
module.exports = {
64-
layerRequirements
62+
layerRequirements,
6563
};

0 commit comments

Comments
 (0)