diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ebc1958..b359f98 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,30 +1,30 @@ module.exports = { - root: true, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:svelte/recommended', - 'prettier' - ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] - }, - env: { - browser: true, - es2017: true, - node: true - }, - overrides: [ - { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] + root: true, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:svelte/recommended', + 'prettier', + ], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + parserOptions: { + sourceType: 'module', + ecmaVersion: 2020, + extraFileExtensions: ['.svelte'], + }, + env: { + browser: true, + es2017: true, + node: true, + }, + overrides: [ + { + files: ['*.svelte'], + parser: 'svelte-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser', + }, + }, + ], }; diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yaml similarity index 100% rename from .github/workflows/build-push-docker.yml rename to .github/workflows/build-push-docker.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..ccb0edb --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +name: Continuous Integration + +on: + pull_request: + push: + branches: [main] + +jobs: + prettier: + name: Prettier Check + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Run Prettier + id: prettier-run + uses: rutajdash/prettier-cli-action@v1.0.0 + with: + config_path: ./.prettierrc + prettier_version: "3.1.1" + + # This step only runs if prettier finds errors causing the previous step to fail + # This steps lists the files where errors were found + - name: Prettier Output + if: ${{ failure() }} + shell: bash + run: | + echo "The following files are not formatted:" + echo "${{steps.prettier-run.outputs.prettier_output}}" \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 3897265..680bc55 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,13 +1,2 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example - -# Ignore files for PNPM, NPM and YARN -pnpm-lock.yaml -package-lock.json -yarn.lock +*.yml +*.yaml diff --git a/.prettierrc b/.prettierrc index a77fdde..859f2f9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,9 +1,6 @@ { - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100, - "plugins": ["prettier-plugin-svelte"], - "pluginSearchDirs": ["."], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] + "singleQuote": true, + "tabWidth": 4, + "plugins": ["prettier-plugin-svelte"], + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] } diff --git a/API.md b/API.md index 2950f44..a821951 100644 --- a/API.md +++ b/API.md @@ -8,44 +8,44 @@ #### Body -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| `content` | `string` | Paste content. If encrypted, must be encoded into a string (preferably Base64). | Yes | -| `config` | `object` | Configuration for the paste | No | -| `passwordProtected` | `boolean` | Whether the paste is password protected. | No | -| `initVector` | `string` | Initialization vector for AES encryption. Max length: 64. | No | +| Name | Type | Description | Required | +| ------------------- | --------- | ------------------------------------------------------------------------------- | -------- | +| `content` | `string` | Paste content. If encrypted, must be encoded into a string (preferably Base64). | Yes | +| `config` | `object` | Configuration for the paste | No | +| `passwordProtected` | `boolean` | Whether the paste is password protected. | No | +| `initVector` | `string` | Initialization vector for AES encryption. Max length: 64. | No | **Config Object:** -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| `language` | `string` | Programming language of the paste. Default: `plaintext`. | No | -| `encrypted` | `boolean` | Whether the paste is encrypted. Default: `false`. | No | -| `expiresAfter` | `number` | Time in seconds until the paste expires. | No | -| `burnAfterRead` | `boolean` | Whether the paste is deleted after reading. | No | +| Name | Type | Description | Required | +| --------------- | --------- | -------------------------------------------------------- | -------- | +| `language` | `string` | Programming language of the paste. Default: `plaintext`. | No | +| `encrypted` | `boolean` | Whether the paste is encrypted. Default: `false`. | No | +| `expiresAfter` | `number` | Time in seconds until the paste expires. | No | +| `burnAfterRead` | `boolean` | Whether the paste is deleted after reading. | No | ### Examples ```json { - "content": "i0n3PW6qDUhDaTrzoKg+/ip4qQwu+iq8/fWDVg==", - "config": { - "language": "plaintext", - "encrypted": true, - "expiresAfter": 3600, - "burnAfterRead": false - }, - "passwordProtected": false, - "initVector": "27DIWK00yDiGx001" + "content": "i0n3PW6qDUhDaTrzoKg+/ip4qQwu+iq8/fWDVg==", + "config": { + "language": "plaintext", + "encrypted": true, + "expiresAfter": 3600, + "burnAfterRead": false + }, + "passwordProtected": false, + "initVector": "27DIWK00yDiGx001" } ``` ```json { - "content": "Hello World!", - "config": { - "language": "plaintext" - } + "content": "Hello World!", + "config": { + "language": "plaintext" + } } ``` @@ -57,6 +57,6 @@ #### Query Parameters -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| `key` | `string` | Paste key. | Yes | +| Name | Type | Description | Required | +| ----- | -------- | ----------- | -------- | +| `key` | `string` | Paste key. | Yes | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6304f3..ec02056 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,15 @@ # Contributing When contributing to this repository, please first discuss the change you wish to make via issue, -email, or any other method with the owners of this repository before making a change. +email, or any other method with the owners of this repository before making a change. Please note we have a code of conduct, please follow it in all your interactions with the project. ## Pull Request Process -1. Ensure any install or build dependencies are removed before the end of the layer when doing a +1. Ensure any install or build dependencies are removed before the end of the layer when doing a build. -2. Update the README.md with details of changes to the interface, this includes new environment +2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. 3. Ensure that the code is adhering to the existing code style. @@ -29,22 +29,22 @@ orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ### Our Responsibilities diff --git a/README.md b/README.md index 9333ca1..618d99e 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,18 @@ Well, cause no pastebin I could find had ALL of the following features: - - Modern and minimal UI (This site's design was inspired by bin). - - Optional end-to-end encryption (we're using AES-256-GCM) with optional password protection (using PBKDF2). - - Syntax highlighting (using Prism) that supports 297 languages. - - API support to create and get pastes from command line. - - View raw pastes. Normally, encrypted pastebins do not have this. With this site, you can either get the Base64-encoded encrypted paste, or decrypt it on the server side (even with the password) and get the raw paste. - - Keyboard shortcuts! - - And of course, being fully open-source and easily self-hostable. - - Ability to edit pastes after creation, and a dashboard for viewing all your pastes. - - **NEW** Feature to use custom path names. - - **Comes with a CLI tool to create and read pastes from the command line!** - - ## API Documentation +- Modern and minimal UI (This site's design was inspired by bin). +- Optional end-to-end encryption (we're using AES-256-GCM) with optional password protection (using PBKDF2). +- Syntax highlighting (using Prism) that supports 297 languages. +- API support to create and get pastes from command line. +- View raw pastes. Normally, encrypted pastebins do not have this. With this site, you can either get the Base64-encoded encrypted paste, or decrypt it on the server side (even with the password) and get the raw paste. +- Keyboard shortcuts! +- And of course, being fully open-source and easily self-hostable. +- Ability to edit pastes after creation, and a dashboard for viewing all your pastes. +- **NEW** Feature to use custom path names. +- **Comes with a CLI tool to create and read pastes from the command line!** + +## API Documentation See [API.md](API.md). diff --git a/cli/README.md b/cli/README.md index a78aeb6..db6e548 100644 --- a/cli/README.md +++ b/cli/README.md @@ -43,4 +43,4 @@ options: -h, --help show this help message and exit --password PASSWORD, -p PASSWORD Password to decrypt the paste with. Only needed if password-protected. -``` \ No newline at end of file +``` diff --git a/package.json b/package.json index 7d5a7bc..7b2ba47 100644 --- a/package.json +++ b/package.json @@ -1,54 +1,54 @@ { - "name": "yabin", - "version": "0.2.3", - "private": true, - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --plugin-search-dir . --check . && eslint .", - "format": "prettier --plugin-search-dir . --write .", - "prepare": "svelte-kit sync", - "postinstall": "prisma generate --schema=./src/lib/server/prisma/schema.prisma" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^2.0.0", - "@sveltejs/adapter-node": "^1.2.4", - "@sveltejs/adapter-vercel": "^3.0.3", - "@sveltejs/kit": "^1.5.0", - "@types/node-cron": "^3.0.7", - "@types/nodemailer": "^6.4.11", - "@types/prismjs": "^1.26.0", - "@types/sanitize-html": "^2.9.0", - "@typescript-eslint/eslint-plugin": "^5.45.0", - "@typescript-eslint/parser": "^5.45.0", - "autoprefixer": "^10.4.14", - "eslint": "^8.28.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-svelte": "^2.26.0", - "postcss": "^8.4.31", - "prettier": "^2.8.0", - "prettier-plugin-svelte": "^2.8.1", - "prisma": "^4.15.0", - "svelte": "^3.54.0", - "svelte-check": "^3.0.1", - "svelte-select": "^5.6.1", - "tailwindcss": "^3.3.2", - "tslib": "^2.4.1", - "typescript": "^5.0.0", - "vite": "^4.3.0" - }, - "type": "module", - "dependencies": { - "@prisma/client": "^4.15.0", - "base64-js": "^1.5.1", - "nanoid": "^5.0.1", - "node-cron": "^3.0.2", - "nodemailer": "^6.9.5", - "prism-themes": "^1.9.0", - "prismjs": "^1.29.0", - "sanitize-html": "^2.10.0" - } + "name": "yabin", + "version": "0.2.3", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --plugin-search-dir . --check . && eslint .", + "format": "prettier --write .", + "prepare": "svelte-kit sync", + "postinstall": "prisma generate --schema=./src/lib/server/prisma/schema.prisma" + }, + "devDependencies": { + "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/adapter-node": "^1.2.4", + "@sveltejs/adapter-vercel": "^3.0.3", + "@sveltejs/kit": "^1.5.0", + "@types/node-cron": "^3.0.7", + "@types/nodemailer": "^6.4.11", + "@types/prismjs": "^1.26.0", + "@types/sanitize-html": "^2.9.0", + "@typescript-eslint/eslint-plugin": "^5.45.0", + "@typescript-eslint/parser": "^5.45.0", + "autoprefixer": "^10.4.14", + "eslint": "^8.28.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-svelte": "^2.26.0", + "postcss": "^8.4.31", + "prettier": "3.1.1", + "prettier-plugin-svelte": "3.1.2", + "prisma": "^4.15.0", + "svelte": "^3.54.0", + "svelte-check": "^3.0.1", + "svelte-select": "^5.6.1", + "tailwindcss": "^3.3.2", + "tslib": "^2.4.1", + "typescript": "^5.0.0", + "vite": "^4.3.0" + }, + "type": "module", + "dependencies": { + "@prisma/client": "^4.15.0", + "base64-js": "^1.5.1", + "nanoid": "^5.0.1", + "node-cron": "^3.0.2", + "nodemailer": "^6.9.5", + "prism-themes": "^1.9.0", + "prismjs": "^1.29.0", + "sanitize-html": "^2.10.0" + } } diff --git a/postcss.config.js b/postcss.config.js index 5559af3..67d9d23 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,8 +1,8 @@ export default { - plugins: { - 'postcss-import': {}, - 'tailwindcss/nesting': {}, - tailwindcss: {}, - autoprefixer: {} - } + plugins: { + 'postcss-import': {}, + 'tailwindcss/nesting': {}, + tailwindcss: {}, + autoprefixer: {}, + }, }; diff --git a/src/app.css b/src/app.css index 34cdd8b..11ec768 100644 --- a/src/app.css +++ b/src/app.css @@ -3,19 +3,19 @@ @tailwind utilities; :root { - --color-primary: #e5e1d1; - --color-background: #101419; - --color-dark: rgba(0, 0, 0, 0.7); + --color-primary: #e5e1d1; + --color-background: #101419; + --color-dark: rgba(0, 0, 0, 0.7); } body { - @apply bg-background; - @apply text-primary; + @apply bg-background; + @apply text-primary; } @layer utilities { - input[type='number']::-webkit-inner-spin-button, - input[type='number']::-webkit-outer-spin-button { - @apply appearance-none; - } + input[type='number']::-webkit-inner-spin-button, + input[type='number']::-webkit-outer-spin-button { + @apply appearance-none; + } } diff --git a/src/app.d.ts b/src/app.d.ts index f59b884..addc02a 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,12 +1,12 @@ // See https://kit.svelte.dev/docs/types#app // for information about these interfaces declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface Platform {} - } + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface Platform {} + } } export {}; diff --git a/src/app.html b/src/app.html index e622076..90f3c7a 100644 --- a/src/app.html +++ b/src/app.html @@ -1,23 +1,23 @@ - + +
+ + + + + + +