Skip to content

chore: update dependencies to latest #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ updates:
ignore:
- dependency-name: eslint
versions:
- "> 5.16.0"
- "> 7.22.0"
9 changes: 2 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [12]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
node-version: 14

- name: Install deps
run: npm install
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
version: 12
version: 14
registry-url: https://registry.npmjs.org/

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: [3.6, 2.7]
node-version: [12]
python-version: [2.7, 3.6]
steps:
- uses: actions/checkout@v2

Expand All @@ -19,10 +18,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up Node ${{ matrix.node-version }}
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
node-version: 14

- name: Check python version
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ __pycache__

#NODE STUFF
package-lock.json
yarn.lock
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

6 changes: 3 additions & 3 deletions lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function cleanup() {
const artifacts = ['.requirements'];
if (this.options.zip) {
if (this.serverless.service.package.individually) {
this.targetFuncs.forEach(f => {
this.targetFuncs.forEach((f) => {
artifacts.push(path.join(f.module, '.requirements.zip'));
artifacts.push(path.join(f.module, 'unzip_requirements.py'));
});
Expand All @@ -25,7 +25,7 @@ function cleanup() {
}

return BbPromise.all(
artifacts.map(artifact =>
artifacts.map((artifact) =>
fse.removeAsync(path.join(this.servicePath, artifact))
)
);
Expand All @@ -47,7 +47,7 @@ function cleanupCache() {
const promises = [];
glob
.sync([path.join(cacheLocation, '*slspyc/')], { mark: true, dot: false })
.forEach(file => {
.forEach((file) => {
promises.push(fse.removeAsync(file));
});
return BbPromise.all(promises);
Expand Down
4 changes: 2 additions & 2 deletions lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function tryBindPath(serverless, bindPath, testFile) {
`${bindPath}:/test`,
'alpine',
'ls',
`/test/${testFile}`
`/test/${testFile}`,
];
try {
if (debug) serverless.cli.log(`Trying bindPath ${bindPath} (${options})`);
Expand Down Expand Up @@ -167,7 +167,7 @@ function getDockerUid(bindPath) {
'stat',
'-c',
'%u',
'/bin/sh'
'/bin/sh',
];
const ps = dockerCommand(options);
return ps.stdout.trim();
Expand Down
26 changes: 13 additions & 13 deletions lib/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ function injectRequirements(requirementsPath, packagePath, options) {

return fse
.readFileAsync(packagePath)
.then(buffer => JSZip.loadAsync(buffer))
.then(zip =>
.then((buffer) => JSZip.loadAsync(buffer))
.then((zip) =>
BbPromise.resolve(
glob.sync([path.join(requirementsPath, '**')], {
mark: true,
dot: true
dot: true,
})
)
.map(file => [file, path.relative(requirementsPath, file)])
.map((file) => [file, path.relative(requirementsPath, file)])
.filter(
([file, relativeFile]) =>
!file.endsWith('/') &&
Expand All @@ -42,7 +42,7 @@ function injectRequirements(requirementsPath, packagePath, options) {
.mapSeries(([file, relativeFile, fileStat]) =>
zipFile(zip, relativeFile, fse.readFileAsync(file), {
unixPermissions: fileStat.mode,
createFolders: false
createFolders: false,
})
)
.then(() => writeZip(zip, packagePath))
Expand All @@ -61,16 +61,16 @@ function moveModuleUp(source, target, module) {

return fse
.readFileAsync(source)
.then(buffer => JSZip.loadAsync(buffer))
.then(sourceZip =>
.then((buffer) => JSZip.loadAsync(buffer))
.then((sourceZip) =>
sourceZip.filter(
file =>
(file) =>
file.startsWith(module + '/') ||
file.startsWith('serverless_sdk/') ||
file.match(/^s_.*\.py/) !== null
)
)
.map(srcZipObj =>
.map((srcZipObj) =>
zipFile(
targetZip,
srcZipObj.name.startsWith(module + '/')
Expand All @@ -96,18 +96,18 @@ function injectAllRequirements(funcArtifact) {

if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
.filter(func =>
.filter((func) =>
(func.runtime || this.serverless.service.provider.runtime).match(
/^python.*/
)
)
.map(func => {
.map((func) => {
if (!get(func, 'module')) {
set(func, ['module'], '.');
}
return func;
})
.map(func => {
.map((func) => {
if (func.module !== '.') {
const artifact = func.package ? func.package.artifact : funcArtifact;
const newArtifact = path.join(
Expand All @@ -122,7 +122,7 @@ function injectAllRequirements(funcArtifact) {
return func;
}
})
.map(func => {
.map((func) => {
return this.options.zip
? func
: injectRequirements(
Expand Down
8 changes: 3 additions & 5 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function createLayers() {
}-${this.serverless.providers.aws.getStage()}-python-requirements`,
description:
'Python requirements generated by serverless-python-requirements.',
compatibleRuntimes: [this.serverless.service.provider.runtime]
compatibleRuntimes: [this.serverless.service.provider.runtime],
},
this.options.layer
);
Expand All @@ -55,11 +55,9 @@ function layerRequirements() {

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

return BbPromise.bind(this)
.then(zipRequirements)
.then(createLayers);
return BbPromise.bind(this).then(zipRequirements).then(createLayers);
}

module.exports = {
layerRequirements
layerRequirements,
};
26 changes: 14 additions & 12 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
checkForAndDeleteMaxCacheVersions,
sha256Path,
getRequirementsWorkingPath,
getUserCachePath
getUserCachePath,
} = require('./shared');

/**
Expand All @@ -22,7 +22,7 @@ const {
* @return {string[][]} a list of valid commands.
*/
function filterCommands(commands) {
return commands.filter(cmd => Boolean(cmd) && cmd.length > 0);
return commands.filter((cmd) => Boolean(cmd) && cmd.length > 0);
}

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ function installRequirements(targetFolder, serverless, options) {
Array.isArray(options.pipCmdExtraArgs) &&
options.pipCmdExtraArgs.length > 0
) {
options.pipCmdExtraArgs.forEach(cmd => {
options.pipCmdExtraArgs.forEach((cmd) => {
const parts = cmd.split(/\s+/, 2);
pipCmd.push(...parts);
});
Expand All @@ -140,9 +140,11 @@ function installRequirements(targetFolder, serverless, options) {
// Check if we're using the legacy --cache-dir command...
if (options.pipCmdExtraArgs.indexOf('--cache-dir') > -1) {
if (options.dockerizePip) {
throw 'Error: You can not use --cache-dir with Docker any more, please\n' +
throw (
'Error: You can not use --cache-dir with Docker any more, please\n' +
' use the new option useDownloadCache instead. Please see:\n' +
' https://github.com/UnitedIncome/serverless-python-requirements#caching';
' https://github.com/UnitedIncome/serverless-python-requirements#caching'
);
} else {
serverless.cli.log('==================================================');
serverless.cli.log(
Expand Down Expand Up @@ -239,7 +241,7 @@ function installRequirements(targetFolder, serverless, options) {

if (options.dockerEnv) {
// Add environment variables to docker run cmd
options.dockerEnv.forEach(function(item) {
options.dockerEnv.forEach(function (item) {
dockerCmd.push('-e', item);
});
}
Expand All @@ -256,7 +258,7 @@ function installRequirements(targetFolder, serverless, options) {
'chown',
'-R',
`${process.getuid()}:${process.getgid()}`,
'/var/task'
'/var/task',
]);
} else {
// Use same user so --cache-dir works
Expand All @@ -274,7 +276,7 @@ function installRequirements(targetFolder, serverless, options) {
'chown',
'-R',
`${process.getuid()}:${process.getgid()}`,
dockerDownloadCacheDir
dockerDownloadCacheDir,
]);
}
}
Expand Down Expand Up @@ -384,7 +386,7 @@ function filterRequirementsFile(source, target, options, serverless) {
const noDeploy = new Set(options.noDeploy || []);
const requirements = getRequirements(source);
var prepend = [];
const filteredRequirements = requirements.filter(req => {
const filteredRequirements = requirements.filter((req) => {
req = req.trim();
if (req.startsWith('#')) {
// Skip comments
Expand Down Expand Up @@ -440,7 +442,7 @@ function copyVendors(vendorFolder, targetFolder, serverless) {
`Copying vendor libraries from ${vendorFolder} to ${targetFolder}...`
);

fse.readdirSync(vendorFolder).map(file => {
fse.readdirSync(vendorFolder).map((file) => {
let source = path.join(vendorFolder, file);
let dest = path.join(targetFolder, file);
if (fse.existsSync(dest)) {
Expand Down Expand Up @@ -603,12 +605,12 @@ function installAllRequirements() {
if (this.serverless.service.package.individually) {
let doneModules = [];
this.targetFuncs
.filter(func =>
.filter((func) =>
(func.runtime || this.serverless.service.provider.runtime).match(
/^python.*/
)
)
.map(f => {
.map((f) => {
if (!get(f, 'module')) {
set(f, ['module'], '.');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pipenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function pipfileToRequirements() {
'pipenv',
['lock', '--requirements', '--keep-outdated'],
{
cwd: this.servicePath
cwd: this.servicePath,
}
);
if (res.error) {
Expand Down
6 changes: 3 additions & 3 deletions lib/poetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function pyprojectTomlToRequirements() {
'requirements.txt',
'-o',
'requirements.txt',
'--with-credentials'
'--with-credentials',
],
{
cwd: this.servicePath
cwd: this.servicePath,
}
);
if (res.error) {
Expand All @@ -46,7 +46,7 @@ function pyprojectTomlToRequirements() {
const requirementsContents =
res.stdout.toString().trim() || // As of poetry 1.0.0b1, requirements.txt is printed to standard output when the -o option is not specified.
fse.readFileSync(sourceRequirements, {
encoding: 'utf-8'
encoding: 'utf-8',
});

if (requirementsContents.match(editableFlag)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function checkForAndDeleteMaxCacheVersions(options, serverless) {
// Check if we have too many
if (files.length >= options.staticCacheMaxVersions) {
// Sort by modified time
files.sort(function(a, b) {
files.sort(function (a, b) {
return (
fse.statSync(a).mtime.getTime() - fse.statSync(b).mtime.getTime()
);
Expand Down Expand Up @@ -90,7 +90,7 @@ function getUserCachePath(options) {
// Otherwise, find/use the python-ey appdirs cache location
const dirs = new Appdir({
appName: 'serverless-python-requirements',
appAuthor: 'UnitedIncome'
appAuthor: 'UnitedIncome',
});
return dirs.userCache();
}
Expand All @@ -108,5 +108,5 @@ module.exports = {
checkForAndDeleteMaxCacheVersions,
getRequirementsWorkingPath,
getUserCachePath,
sha256Path
sha256Path,
};
Loading