Skip to content

Commit

Permalink
Initial refactor commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoHD404 committed Jul 18, 2021
1 parent c16150a commit 75939e1
Show file tree
Hide file tree
Showing 22 changed files with 4,397 additions and 1,904 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: CodeQL

on:
push:
branches: [ main, dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main, dev ]
schedule:
- cron: '18 3 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
50 changes: 50 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/

.vscode/
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Environment management
.direnv/
.envrc
.vscode

# Testing configuration
.travis.yml
Expand Down
3 changes: 0 additions & 3 deletions .prettierrc.json

This file was deleted.

10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

132 changes: 4 additions & 128 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,136 +1,12 @@
# Changelog

## Unreleased - 1.1.0-dev.2
## [1.0.0] - 2021-07-18 - Forked From vercel-package-installer

### Added
- Supported runtime Python 3.8
-

### Changed
- Upgraded builder packages
- Upgraded handler packages
- Moved all `@now/` prefixed build utilities to `@vercel/` prefix
- Renamed package to `vercel-python-wsgi`
-

### Removed
- Runtime Python 2.7 (no longer supported by Vercel)


## [1.0.11] - 2019-11-03 - Upgrade eslint-utils & werkzeug

### Changed
- Upgraded packages


## [1.0.10] - 2019-08-08 - Python 3.6 fix

### Changed
- Updated runtime and binary checking for new Zeit container
- Upgraded dependencies


## [1.0.9] - 2019-04-26 - Python 2.7 support

### Added
- Added a runtime validation step to interrupt the build if the user has
configured an unsupported runtime.
- Added a warning if the python version implied by `runtime` is not available in
the build environment. Falls back to a system python.
- Tests for Python 2.7.
- Updated requirements discussion in `README.md` to be consistent with revised
requirements handling.


## [1.0.8] - 2019-04-16 - Organization migration

### Changed
- Migrated NPM and GitHub repositories to updated organization
- Updated readme to match new repository


## [1.0.7] - 2019-03-14 - Fixes for multi-value headers

### Changed
- Fixed url unquoting of query strings in the handler
- Fixed base64 encoding of responses in the handler (now passing `encoding` in
the return dictionary).
- Fixed multi-value cookie handling (now passing multi-value cookies as a list
of values for each key).


## [1.0.6] - 2019-03-14 - Fixes for base64 encoded bodies

### Changed
- Fixed base64 handling in the handler. Request bodies were previously being
passed on to the application without decoding, but with padding stripped
(preventing decoding by the application).


## [1.0.5] - 2019-03-13 - Fixes for querystrings and empty response bodies

### Changed
- Handler is now installed as a python package instead of being copied into the
project source.
- Querystring handling has been corrected.
- Empty return body handling has been patched to match Now's requirement of a
`body` object on the response. An empty body is returned if no body is
supplied by the application.


## [1.0.4] - 2019-03-13 - Ensure logging configuration

### Added
- Logging is now configured with `logging.basicConfig()` in `handler.py` to
ensure logging is initialized at the module level.


## [1.0.3] - 2019-03-10

### Changed
- Fixed typo in `index.js` which was appearing in logs


## [1.0.2] - 2019-03-10 - Selectable runtime

### Added
- Configuration option `runtime` can now be used to set the lambda runtime,
e.g., `python3.6`. *The build environment is not affected, beware of
issues building in Python 3.5 and running and other versions.*

### Changed
- Improved builder log output (`log.js`)
- Consolidated pip activities to `pip.js`

### Removed
- No longer installs `Werkzeug` every time. Projects will need to include
`Werkzeug` as a dependency in their project `requirements.txt`. If a
`requirements.txt` file is not found, the builder will install `Werkzeug`
assuming the project has no other dependencies.


## [1.0.1] - 2019-03-03 - Fix logging

### Added
- Stubbed testing with a single GET request test and test configuration

### Changed
- Removed `print` calls from `now_python_wsgi.handler.handler()` to prevent
printing sensitive data to longs (e.g., passwords passed in the body of a
request).


## 1.0.0 - 2019-03-02 - Getting started!
We're just getting started. This establishes a tidy repository ready for the
world.


[1.0.11]: https://github.com/ardnt/now-python-wsgi/compage/v1.0.10...v1.0.11
[1.0.10]: https://github.com/ardnt/now-python-wsgi/compare/v1.0.9...v1.0.10
[1.0.9]: https://github.com/ardnt/now-python-wsgi/compare/v1.0.8...v1.0.9
[1.0.8]: https://github.com/ardnt/now-python-wsgi/compare/v1.0.7...v1.0.8
[1.0.7]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/ardent-co/now-python-wsgi/compare/v1.0.0...v1.0.1
-
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 The Ardent Company
Copyright (c) 2021 PotatoHD404

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# vercel-python-wsgi
*A Vercel builder for Python WSGI applications*

[![NPM version](https://img.shields.io/npm/v/@ardnt/vercel-python-wsgi.svg)](https://www.npmjs.com/package/@ardnt/vercel-python-wsgi)
[![Build Status](https://www.travis-ci.com/ardnt/vercel-python-wsgi.svg?branch=main)](https://www.travis-ci.com/ardnt/vercel-python-wsgi)
[![License](https://img.shields.io/npm/l/@ardnt/vercel-python-wsgi)](https://github.com/ardnt/vercel-python-wsgi/blob/master/LICENSE)
[![NPM version](https://img.shields.io/npm/v/@PotatoHD404/vercel-package-installer.svg)](https://www.npmjs.com/package/@PotatoHD404/vercel-package-installer)
[![Build Status](https://www.travis-ci.com/PotatoHD404/vercel-package-installer.svg?branch=main)](https://www.travis-ci.com/PotatoHD404/vercel-package-installer)
[![License](https://img.shields.io/npm/l/@PotatoHD404/vercel-package-installer)](https://github.com/PotatoHD404/vercel-package-installer/blob/master/LICENSE)

## Quickstart

Expand All @@ -19,7 +19,7 @@ Add a `vercel.json` file to the root of your application:
{
"builds": [{
"src": "index.py",
"use": "@ardnt/vercel-python-wsgi",
"use": "@PotatoHD404/vercel-package-installer",
"config": { "maxLambdaSize": "15mb" }
}]
}
Expand All @@ -30,7 +30,7 @@ This configuration is doing a few things in the `"builds"` part:
1. `"src": "index.py"`
This tells Now that there is one entrypoint to build for. `index.py` is a
file we'll create shortly.
2. `"use": "@ardnt/vercel-python-wsgi"`
2. `"use": "@PotatoHD404/vercel-package-installer"`
Tell Now to use this builder when deploying your application
3. `"config": { "maxLambdaSize": "15mb" }`
Bump up the maximum size of the built application to accommodate some larger
Expand Down Expand Up @@ -124,7 +124,7 @@ configuration:
{
"builds": [{
"src": "index.py",
"use": "@ardnt/vercel-python-wsgi"
"use": "@PotatoHD404/vercel-package-installer"
}],
"routes" : [{
"src" : "/(.*)", "dest":"/"
Expand All @@ -144,7 +144,7 @@ then you can configure it as the entrypoint and adjust routes accordingly:
{
"builds": [{
"src": "vercel_app/wsgi.py",
"use": "@ardnt/vercel-python-wsgi"
"use": "@PotatoHD404/vercel-package-installer"
}],
"routes" : [{
"src" : "/(.*)", "dest":"/vercel_app/wsgi.py"
Expand Down
2 changes: 1 addition & 1 deletion build-utils/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { createWriteStream } = require('fs');
const fetch = require('node-fetch');
const path = require('path');

const getWritableDirectory = require('@vercel/build-utils/fs/get-writable-directory.js'); // eslint-disable-line import/no-extraneous-dependencies
const getWritableDirectory = require('@vercel/build-utils/fs/get-writable-directory'); // eslint-disable-line import/no-extraneous-dependencies


async function file(url, fileName) {
Expand Down
Loading

0 comments on commit 75939e1

Please sign in to comment.