-
Notifications
You must be signed in to change notification settings - Fork 2
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
init #1
Merged
Merged
init #1
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
ad78fd6
set up project
ivibumblebee b46afb3
set up github
ivibumblebee 332d235
fixed sub parsing
ivibumblebee 38328a8
cleanup
ivibumblebee 6db4aee
set up pr and deploy
ivibumblebee 4f2fb1a
fixed wd
ivibumblebee 0996d6b
updated yarn lock
ivibumblebee ac8e4e8
trying to publish
ivibumblebee cd20b64
fixed publish
ivibumblebee 6c24a52
moved husky
ivibumblebee 3be2282
trigger hooks
ivibumblebee 151b6ca
triggering precommit
ivibumblebee af1feab
triggering precommit
ivibumblebee 7eb06ec
fixed yarn
ivibumblebee 0f5f580
fixed yarn for real
ivibumblebee 7895ae4
first publish
ivibumblebee f0c016b
add login
ivibumblebee 5f3aff4
adding registry
ivibumblebee 20b9378
fixing env name??
ivibumblebee 45d70f5
fixing scope
ivibumblebee b2210a7
fixing yarn lock
ivibumblebee 6802c81
adding npmrc
ivibumblebee 2f8f310
cleanup
ivibumblebee 2cb136f
readme and fix publish
ivibumblebee e927054
fix line
ivibumblebee d09a1f1
Update README.md
ivibumblebee 1417267
cleaned up dependencies
ivibumblebee d88c954
Merge branch 'f/init' of github.com:AES-Outreach/Express-React-PDF in…
ivibumblebee b3d8a9f
put express back in dependencies
ivibumblebee 004770d
pushed readme
ivibumblebee 9de7abd
cleanup
ivibumblebee ac5a913
clean up
ivibumblebee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# check-spelling/check-spelling configuration | ||
|
||
| File | Purpose | Format | Info | | ||
| ---------------------- | --------------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------- | | ||
| [allow.txt](allow.txt) | Add words to the dictionary | one word per line (only letters and `'`s allowed) | [allow](https://github.com/check-spelling/check-spelling/wiki/Configuration#allow) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
isnan | ||
outstem | ||
Templating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Purpose | ||
|
||
What does this pull request hope to accomplish? | ||
|
||
## Screenshot | ||
|
||
UI change? Add a screenshot or a gif! | ||
|
||
## Acceptance Criteria | ||
|
||
- [ ] The user should be able to do ... | ||
- [ ] Something should occur when ... | ||
|
||
## Additional Notes | ||
|
||
Any additional notes for developers to give greater context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Core Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'core/**' | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js 14.15 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.15 | ||
- name: Install dependencies | ||
working-directory: ./core | ||
run: yarn install | ||
- name: Run production build | ||
working-directory: ./core | ||
run: yarn run build | ||
- name: Push to NPM | ||
working-directory: ./core | ||
run: | | ||
npm version "v1.0.${GITHUB_RUN_NUMBER}" | ||
npm publish | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Core Checks | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test-and-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Uses Node.js 14.17 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.17 | ||
- name: Install dependencies | ||
working-directory: ./core | ||
run: yarn install | ||
- name: Run prettier | ||
working-directory: ./core | ||
run: yarn prettier:check | ||
- name: Linter | ||
working-directory: ./core | ||
run: yarn lint | ||
- name: Spell check | ||
working-directory: ./core | ||
run: npx cspell "**/*.{md,js,ts,tsx}" | ||
# - name: Run unit tests | ||
# working-directory: ./core | ||
# run: yarn test | ||
- name: Run production build | ||
working-directory: ./core | ||
run: yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
echo '-----Core Precommit-----' | ||
cd ./core && npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# PDF-Express-Middleware | ||
Middleware express using react-pdf to generate PDF files | ||
|
||
## Project Structure | ||
|
||
#### Core | ||
Core contains the middleware builder and PDF wrapper, as well as the base root context | ||
|
||
#### Prebuilt | ||
Prebuilt contains additional prebuilt middleware that can be used, for example integrating i18Next | ||
## Hooks | ||
To set up precommit hooks with husky, run the following\ | ||
`npm install -g husky`\ | ||
`npx husky install .husky` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
env: { | ||
browser: true, | ||
node: true, | ||
es2021: true, | ||
}, | ||
extends: [], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
}, | ||
plugins: ["react", "no-only-tests", "unused-imports", "prefer-arrow"], | ||
overrides: [ | ||
{ | ||
files: ["*.ts", "*.tsx"], | ||
parserOptions: { | ||
sourceType: "module", | ||
project: ["./tsconfig.test.json"], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:eslint-comments/recommended", | ||
"prettier", // Make sure this is always last | ||
], | ||
rules: { | ||
"no-only-tests/no-only-tests": "error", | ||
"@typescript-eslint/no-shadow": "error", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"eslint-comments/no-unused-disable": "error", | ||
"eslint-comments/no-unlimited-disable": "error", | ||
"eslint-comments/disable-enable-pair": [ | ||
"error", | ||
{ allowWholeFile: true }, | ||
], | ||
"unused-imports/no-unused-imports": "error", | ||
"@typescript-eslint/consistent-type-definitions": "error", | ||
"@typescript-eslint/dot-notation": "error", | ||
"@typescript-eslint/explicit-member-accessibility": [ | ||
"off", | ||
{ | ||
accessibility: "explicit", | ||
}, | ||
], | ||
"@typescript-eslint/no-require-imports": "error", | ||
"id-blacklist": "off", | ||
"id-match": "off", | ||
"@typescript-eslint/no-misused-promises": [ | ||
"error", | ||
{ | ||
checksVoidReturn: false, | ||
}, | ||
], | ||
"no-restricted-properties": [ | ||
2, | ||
{ | ||
object: "translate", | ||
property: "getBrowserLang", | ||
message: "Please use userCurrentLang instead.", | ||
}, | ||
{ | ||
object: "t", | ||
property: "getBrowserLang", | ||
message: "Please use userCurrentLang instead.", | ||
}, | ||
{ | ||
object: "translateService", | ||
property: "getBrowserLang", | ||
message: "Please use userCurrentLang instead.", | ||
}, | ||
], | ||
"no-underscore-dangle": "off", | ||
"@typescript-eslint/member-ordering": "off", | ||
"jsdoc/newline-after-description": "off", | ||
"@typescript-eslint/ban-types": "error", | ||
"no-var": "error", | ||
"no-shadow": "off", | ||
"prefer-arrow/prefer-arrow-functions": "error", | ||
"prefer-const": "error", | ||
"@typescript-eslint/no-unused-expressions": "error", | ||
"use-isnan": "error", | ||
"@typescript-eslint/consistent-type-assertions": "error", | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
// typeLike (class, interface, typeAlias, enum, typeParameter) should use StrictPascalCase | ||
{ selector: ["typeLike"], format: ["PascalCase"] }, | ||
// Destructured variables should have no casing enforced | ||
{ | ||
selector: ["variable"], | ||
modifiers: ["destructured"], | ||
format: null, | ||
}, | ||
// Stand-alone variables should be camelCase or UPPER_CASE | ||
{ | ||
selector: ["variable"], | ||
format: ["camelCase", "UPPER_CASE"], | ||
}, | ||
// Class properties and function parameters are only loosely enforced | ||
{ | ||
selector: ["parameter", "accessor", "typeProperty"], | ||
format: ["PascalCase", "snake_case", "camelCase", "UPPER_CASE"], | ||
leadingUnderscore: "allow", | ||
}, | ||
// Functions must use camelCase | ||
{ | ||
selector: [ | ||
"function", | ||
"variable", | ||
"classMethod", | ||
"typeMethod", | ||
"classProperty", | ||
"typeProperty", | ||
], | ||
// PascalCase is needed here for React components | ||
format: ["camelCase", "PascalCase"], | ||
types: ["function"], // To scope 'parameter', 'classProperty', 'typeProperty' and 'variable' | ||
filter: { regex: "toJSON", match: false }, | ||
}, | ||
], | ||
"@typescript-eslint/consistent-indexed-object-style": [ | ||
"error", | ||
"record", | ||
], | ||
}, | ||
}, | ||
], | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# compiled output | ||
/deps | ||
/dist | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# IDE - VSCode | ||
.vs/* | ||
.vscode/* | ||
.editorconfig | ||
|
||
# misc | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
#Cspell Cache | ||
.cspellcache | ||
|
||
# Betterer Cache | ||
.betterer.cache | ||
|
||
# Yarn Berry | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//registry.npmjs.org/:_authToken=${NPM_TOKEN} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nodeLinker: node-modules | ||
yarnPath: .yarn/releases/yarn-3.3.0.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## Base Root | ||
|
||
For simple usage, a base root context element and it's associated middleware are provided as `BaseRootContext` and `basePDFGenerator` | ||
|
||
### Usage | ||
|
||
**Certificate Element** | ||
|
||
```ts | ||
import React from "react"; | ||
import { Page, View, Text } from "@react-pdf/renderer"; | ||
|
||
export const Certificate = ({ name, age }: CertificateProps) => { | ||
return ( | ||
<Page size="A4" orientation="landscape"> | ||
<View> | ||
<Text> | ||
{name} - {age} | ||
</Text> | ||
</View> | ||
</Page> | ||
); | ||
}; | ||
``` | ||
|
||
**Endpoint** | ||
|
||
```ts | ||
import { ProgramCertificate } from "./template"; | ||
import { basePDFGenerator } from "express-react-pdf"; | ||
|
||
router.get( | ||
"/certificate", | ||
basePDFGenerator(Certificate, (req) => ({ | ||
name: req.query.name, | ||
age: req.query.age, | ||
})) | ||
); | ||
``` | ||
|
||
## Builder | ||
|
||
The `pdfMiddlewareBuilder` can be used to create react-pdf middleware for your express server. This supports defining a new root context, as well as how to extract data from your request to populate your root. | ||
|
||
### Example - Integrating Other Frameworks | ||
|
||
_Note: this will soon be published as a package_ | ||
|
||
Custom root contexts can be defined to integrate other frameworks, for example the i18Next translation library | ||
|
||
**Root Context** | ||
|
||
```ts | ||
export const I18NextRootContext = ({ | ||
translate, | ||
children, | ||
}: I18NextRootContextProps & PropsWithChildren) => { | ||
return ( | ||
<I18nextProvider i18n={translate}> | ||
<Document>{children}</Document> | ||
</I18nextProvider> | ||
); | ||
}; | ||
``` | ||
|
||
**Middleware** | ||
|
||
```ts | ||
export const i18NextPDFMiddleware = pdfMiddlewareBuilder( | ||
I18NextRootContext, | ||
(req) => ({ | ||
translate: req.i18n, | ||
}) | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "0.2", | ||
"ignorePaths": ["./deps"], | ||
"dictionaryDefinitions": [ | ||
{ | ||
"name": "allow", | ||
"path": "../.github/actions/spelling/allow.txt", | ||
"addWords": true | ||
} | ||
], | ||
"dictionaries": ["allow"] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be uncommented or is this because there currently are not tests??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there aren't currently tests, next dev day perhaps