[Release] v0.2.0

This commit is contained in:
Patryk Rzucidlo (PTKDev)
2023-02-11 01:11:16 +01:00
parent abbcd24b5f
commit 770dea9257
81 changed files with 18255 additions and 701 deletions

27
.all-contributorsrc Normal file
View File

@@ -0,0 +1,27 @@
{
"projectName": "ptkdev/sveltekit-electron-adapter",
"projectOwner": "ptkdev",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": true,
"contributors": [
{
"login": "ptkdev",
"name": "Patryk Rzucidło",
"avatar_url": "https://avatars1.githubusercontent.com/u/442844?v=4",
"profile": "https://ptk.dev",
"contributions": [
"code",
"translation",
"doc",
"bug"
]
}
],
"contributorsPerLine": 6,
"commitConvention": "none"
}

325
.all-shieldsrc Normal file
View File

@@ -0,0 +1,325 @@
{
"files": [
"README.md",
"CHANGELOG.md"
],
"shields": [
{
"id": "header-badges",
"badges": [
{
"url": "https://github.com/ptkdev/sveltekit-electron-adapter/blob/main/CHANGELOG.md",
"color": "lightgray",
"label": "version",
"message": "v{{version}}",
"title": "v{{version}}",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://www.npmjs.com/package/@ptkdev/sveltekit-electron-adapter",
"color": "#CC3534",
"label": "npm",
"logo": "npm",
"style": "flat",
"custom": "/npm/v/@ptkdev/sveltekit-electron-adapter?color=CC3534&logo=npm",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/sveltekit-electron-adapter/blob/main/LICENSE.md",
"color": "brightgreen",
"label": "license",
"message": "{{license}}",
"title": "License: {{license}}",
"style": "flat",
"logo": "license",
"platform": "shields"
},
{
"url": "https://www.typescriptlang.org/",
"color": "blue",
"label": "language",
"message": "typescript",
"title": "Language: TypeScript",
"style": "flat",
"logo": "typescript",
"platform": "shields"
},
{
"url": "https://grammy.dev/",
"color": "#009dca",
"label": "powered by",
"message": "grammy",
"title": "Framework: Grammy",
"style": "flat",
"logo": "telegram",
"platform": "shields"
},
{
"url": "https://github.com/tc39/ecma262",
"color": "#F7DF1E",
"label": "ES",
"message": "9",
"title": "ECMAScript: 2019",
"style": "flat",
"logo": "javascript",
"platform": "shields"
},
{
"url": "https://discord.ptkdev.io",
"server_id": "383373985666301975",
"title": "Discord Server",
"platform": "discord"
}
]
},
{
"id": "sponsors-badges",
"badges": [
{
"url": "https://www.paypal.me/ptkdev",
"color": "#005EA6",
"label": "donate",
"message": "paypal",
"title": "Donate Paypal",
"style": "for-the-badge",
"logo": "paypal",
"platform": "shields"
},
{
"url": "https://ko-fi.com/ptkdev",
"color": "#29abe0",
"label": "donate",
"message": "ko-fi",
"title": "Donate Ko-Fi",
"style": "for-the-badge",
"logo": "ko-fi",
"platform": "shields"
},
{
"url": "https://github.com/sponsors/ptkdev",
"color": "#ea4aaa",
"label": "donate",
"message": "sponsors",
"title": "Donate GitHub Sponsors",
"style": "for-the-badge",
"logo": "github",
"platform": "shields"
},
{
"url": "https://www.patreon.com/join/ptkdev",
"color": "#F87668",
"label": "donate",
"message": "patreon",
"title": "Donate Patreon",
"style": "for-the-badge",
"logo": "patreon",
"platform": "shields"
},
{
"url": "https://ptk.dev/img/icons/menu/bitcoin_wallet.png",
"color": "#E38B29",
"label": "BTC",
"message": "35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH",
"title": "Donate Bitcoin",
"style": "flat-square",
"logo": "bitcoin",
"platform": "shields"
},
{
"url": "https://ptk.dev/img/icons/menu/ethereum_wallet.png",
"color": "#4E8EE9",
"label": "ETH",
"message": "0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc",
"title": "Donate Ethereum",
"style": "flat-square",
"logo": "ethereum",
"platform": "shields"
}
]
},
{
"id": "projects-badges1",
"badges": [
{
"url": "https://ptk.dev/",
"color": "#3498db",
"label": "💻 My",
"message": "Portfolio",
"style": "flat",
"logo": "",
"platform": "shields"
}
]
},
{
"id": "projects-badges2",
"badges": [
{
"url": "https://github.com/ptkdev/ptkdev-logger",
"color": "#9b59b6",
"label": "🦒 Tools",
"message": "Node Logger",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/all-shields-cli",
"color": "#9b59b6",
"label": "🦌 Tools",
"message": "All Shields CLI",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/chrome-extension-aspectratio219",
"color": "#9b59b6",
"label": "🖥️ Tools",
"message": "Aspect Ratio 21:9",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://availableon.badge.ptkdev.io/",
"color": "#9b59b6",
"label": "🛡 Tools",
"message": "Badges: Available on",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/json-token-replace",
"color": "#9b59b6",
"label": "🐾 Tools",
"message": "JSON Token Replace",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/eslint-plugin-snakecasejs",
"color": "#9b59b6",
"label": "🐍 Tools",
"message": "ESLint: snakecasejs",
"style": "flat",
"logo": "",
"platform": "shields"
}
]
},
{
"id": "projects-badges3",
"badges": [
{
"url": "https://github.com/ptkdev-components/webcomponent-instagram-widget",
"color": "#e74c3c",
"label": "📸 WebComponent",
"message": "Instagram Widget",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev-components/webcomponent-patreon-box",
"color": "#e74c3c",
"label": "👑 WebComponent",
"message": "My Patreon Box",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev-components/webcomponent-carousel-slideshow",
"color": "#e74c3c",
"label": "🏞 WebComponent",
"message": "Carousel Slideshow",
"style": "flat",
"logo": "",
"platform": "shields"
}
]
},
{
"id": "projects-badges4",
"badges": [
{
"url": "https://github.com/ptkdev/vscode-theme-dark-blood",
"color": "#f1c40f",
"label": "🎨 Themes",
"message": "VSCode",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://t.me/gamebookchatbot",
"color": "#34495e",
"label": "📚 Bot",
"message": "GameBookChat",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev?q=svelte",
"color": "#f368e0",
"label": "👔 Boilerplate",
"message": "Svelte",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev?q=webcomponent",
"color": "#f368e0",
"label": "👔 Boilerplate",
"message": "WebComponents",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev?q=bot",
"color": "#f368e0",
"label": "👔 Boilerplate",
"message": "BOT",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev?q=node",
"color": "#f368e0",
"label": "👔 Boilerplate",
"message": "Node",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://meingifs.pics/",
"color": "#2ecc71",
"label": "💅 App",
"message": "Me in Gifs",
"style": "flat",
"logo": "",
"platform": "shields"
},
{
"url": "https://github.com/ptkdev/ptkdev-stickers#-install-free",
"color": "#2ecc71",
"label": "📱 App",
"message": "Stickers",
"style": "flat",
"logo": "",
"platform": "shields"
}
]
}
]
}

19
.editorconfig Normal file
View File

@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
[*.py]
indent_style = space
indent_size = 4
[*.yml]
indent_style = space
indent_size = 4

2
.eslintignore Normal file
View File

@@ -0,0 +1,2 @@
/dist
/examples

104
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,104 @@
module.exports = {
"env": {
"es6": true,
"node": true,
"browser": false,
"jest/globals": true
},
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2019
},
"plugins": ["jsdoc", "jest", "@typescript-eslint"],
"globals": {
"fetch": false
},
"settings": {
"jsdoc": {
"tagNamePreference": {
"returns": "return"
}
}
},
"rules": {
"no-multi-spaces": [
"error",
{
"ignoreEOLComments": true,
"exceptions": {
"VariableDeclarator": true
}
}
],
"block-spacing": ["error", "always"],
"array-bracket-spacing": ["error", "never"],
"space-in-parens": ["error", "never"],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"key-spacing": [
"error",
{
"afterColon": true,
"beforeColon": false
}
],
"quotes": [
"error",
"double",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"semi": ["error", "always"],
"no-console": ["warn"],
"no-constant-condition": ["warn"],
"curly": ["error", "all"],
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": false
}
],
"keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"object-curly-spacing": ["error", "always"],
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
"spaced-comment": [2, "always"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": "off",
"prefer-template": "error",
"no-useless-concat": "error",
"linebreak-style": ["error", "unix"],
"eol-last": ["error", "always"],
"template-curly-spacing": ["error", "never"],
"no-multiple-empty-lines": "off",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns": 1,
"jsdoc/require-returns-description": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/require-returns-check": 1,
"jsdoc/require-hyphen-before-param-description": 1
}
};

146
.gitattributes vendored Normal file
View File

@@ -0,0 +1,146 @@
## AUTO-DETECT
* text=auto
## SOURCE CODE
*.bat text eol=crlf
*.css text eol=lf
*.html text diff=html eol=lf
*.ini text eol=crlf
*.js text eol=lf
*.json text eol=lf
*.php text diff=php eol=lf
*.py text diff=python eol=lf
*.rb text diff=ruby
*.sass text eol=lf
*.scss text eol=lf
*.sh text eol=lf
*.sql text eol=lf
*.ts text eol=lf
*.vue text eol=lf
*.svelte text eol=lf
*.xml text eol=lf
*.xhtml text diff=html eol=lf
## DOCKER
*.dockerignore text eol=lf
Dockerfile text eol=lf
## DOCUMENTATION
*.md text eol=lf
*.txt text eol=lf
AUTHORS text eol=lf
CHANGELOG text eol=lf
CHANGES text eol=lf
CONTRIBUTING text eol=lf
COPYING text eol=lf
INSTALL text eol=lf
license text eol=lf
LICENSE text eol=lf
NEWS text eol=lf
README text eol=lf
TODO text eol=lf
## TEMPLATES
*.dot text eol=lf
*.tpl text eol=lf
*.twig text eol=lf
## LINTERS
.csslintrc text eol=lf
.eslintrc text eol=lf
.htmlhintrc text eol=lf
.jscsrc text eol=lf
.jshintrc text eol=lf
.jshintignore text eol=lf
.stylelintrc text eol=lf
.npmignore text eol=lf
## CONFIGS
*.bowerrc text eol=lf
*.cnf text eol=lf
*.conf text eol=lf
*.config text eol=lf
.babelrc text eol=lf
.browserslistrc text eol=lf
.editorconfig text eol=lf
.env text eol=lf
.gitattributes text eol=lf
.gitconfig text eol=lf
.htaccess text eol=lf
*.lock text eol=lf
*.npmignore text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
browserslist text eol=lf
Makefile text eol=lf
makefile text eol=lf
## GRAPHICS
*.ai binary
*.bmp binary
*.eps binary
*.gif binary
*.ico binary
*.jng binary
*.jp2 binary
*.jpg binary
*.jpeg binary
*.jpx binary
*.jxr binary
*.pdf binary
*.png binary
*.psb binary
*.psd binary
*.svg text
*.svgz binary
*.tif binary
*.tiff binary
*.wbmp binary
*.webp binary
## AUDIO
*.kar binary
*.m4a binary
*.mid binary
*.midi binary
*.mp3 binary
*.ogg binary
*.ra binary
## VIDEO
*.3gpp binary
*.3gp binary
*.as binary
*.asf binary
*.asx binary
*.fla binary
*.flv binary
*.m4v binary
*.mng binary
*.mov binary
*.mp4 binary
*.mpeg binary
*.mpg binary
*.ogv binary
*.swc binary
*.swf binary
*.webm binary
## ARCHIVES
*.7z binary
*.gz binary
*.jar binary
*.rar binary
*.tar binary
*.zip binary
## FONTS
*.ttf binary
*.eot binary
*.otf binary
*.woff binary
*.woff2 binary
## EXECUTABLES
*.exe binary
*.pyc binary

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
github: [ptkdev]
patreon: ptkdev
ko_fi: ptkdev

46
.github/ISSUE_TEMPLATE/bug_report.md vendored Executable file
View File

@@ -0,0 +1,46 @@
---
name: 🐛 Bug report
about: Create a report to help us improve (low priority)
---
<!-- Please search existing issues to avoid creating duplicates, remember before the title text add tag: [Bug report] -->
### Versions
<!-- Replace or update the values below with your own: -->
- **App Version:** v1.0.0
- **Node Version:** v13.0.0
- **Operating System:** Windows 10
- **Browser:** Google Chrome v80
### Expected Behavior
<!-- Please describe below this line the program's expected behavior. -->
### Actual Behavior
<!-- Please describe below this line the program's actual behavior. Please include any stack traces
or log output in the back ticks below. -->
### Steps to Reproduce
<!-- Please describe below this line the steps for reproduce this issue, are numbered below. Include as
much detail as possible. -->
1. ...
2. ...
3. ...
### Screenshots (Optional)
<!-- If the error is graphical in nature it is helpful to provide a screenshot below this line. -->
<!--
PAID SUPPORT :
If you need paid support with hight priority donate correct tier on:
- https://github.com/sponsors/ptkdev
- https://www.patreon.com/join/ptkdev
Please send me an email (support@ptkdev.io) before donation, i try provide correct price quotation for your bug or new feature.
-->

23
.github/ISSUE_TEMPLATE/feature_request.md vendored Executable file
View File

@@ -0,0 +1,23 @@
---
name: 💫 Feature request
about: Suggest an idea or new feature for this project (low priority)
---
<!-- Please search existing issues to avoid creating duplicates, remember before the title text add tag: [Feature request] -->
### Feature description
<!-- Describe below this line the feature you'd like -->
### Feature motivation
<!-- Why do you want this? Write motivation below this line -->
<!--
PAID SUPPORT :
If you need paid support with hight priority donate correct tier on:
- https://github.com/sponsors/ptkdev
- https://www.patreon.com/join/ptkdev
Please send me an email (support@ptkdev.io) before donation, i try provide correct price quotation for your bug or new feature.
-->

13
.github/ISSUE_TEMPLATE/paid_support.md vendored Executable file
View File

@@ -0,0 +1,13 @@
---
name: 🎖 Paid support
about: If you need paid support with hight priority donate correct tier on github.com/sponsors/ptkdev or patreon.com/join/ptkdev and send email to support@ptkdev.io
---
## PAID SUPPORT
If you need paid support with hight priority donate correct tier on:
- https://github.com/sponsors/ptkdev
- https://www.patreon.com/join/ptkdev
Please send me an email (support@ptkdev.io) before donation, i try provide correct price quotation for your bug or new feature.

10
.github/ISSUE_TEMPLATE/question.md vendored Executable file
View File

@@ -0,0 +1,10 @@
---
name: 🗨 Question
about: Ask a question (we recommended use 💬 discussion tab and open questions on repository forum)
---
<!-- Please search existing issues to avoid creating duplicates, remember before the title text add tag: [Q] -->
### Question
<!-- Describe below this line the question -->

BIN
.github/assets/logo.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
.github/assets/screenshot.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

BIN
.github/assets/social_discord.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
.github/assets/social_telegram.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
.github/assets/social_twitter.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

35
.github/workflows/beta.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Release Beta
on:
push:
branches:
- beta
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release Beta]')"
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: git config --global user.name 'Patryk Rzucidlo (@PTKDev)'
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd beta
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release Beta] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git fetch --all && git checkout nightly
- run: npm run github-workflow-next-version -- --cmd nightly-next
- run: npm run pre-commit
- id: nextnightly
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release Nightly] v${{ steps.nextnightly.outputs.pkgversion }}" && git push

47
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
name: Release Stable
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release]')"
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: git config --global user.name 'Patryk Rzucidlo (@PTKDev)'
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd main
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: npm publish --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%B %d, %Y')"
- run: npm run github-workflow-changelog
- id: changelog
run: chmod +x ./scripts/changelog_release.sh && ./scripts/changelog_release.sh
- name: Release snapshot
id: release-snapshot
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.pkgjson.outputs.pkgversion }}
release_name: v${{ steps.pkgjson.outputs.pkgversion }}
body: |
### CHANGELOG: v${{ steps.pkgjson.outputs.pkgversion }} (${{ steps.date.outputs.date }})${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false

30
.github/workflows/nightly.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Release Nightly
on:
schedule:
- cron: "30 23 * * *"
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release Nightly]')"
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN }}
ref: nightly
- uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: git config --global user.name 'Patryk Rzucidlo (@PTKDev)'
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd nightly
- run: npm run pkg-upgrade
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release Nightly] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: npm publish --tag nightly
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

21
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Try Release
on:
push:
branches:
- nightly
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN }}
ref: nightly
- uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: git config --global user.name 'Patryk Rzucidlo (@PTKDev)'
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run release

137
.gitignore vendored
View File

@@ -1,4 +1,135 @@
######################################################################################
# License: MIT - http://opensource.org/licenses/MIT #
# Author: Patryk Rzucidło (@ptkdev) <support@ptkdev.io> https://ptk.dev #
# Original: octocat - https://github.com/octocat #
# Latest version: https://github.com/ptkdev/dotfiles #
######################################################################################
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Eclipse #
###########
.classpath
.project
.settings
.idea
.idea/
.metadata
*.iml
*.ipr
proguard/
# Logs and databases #
######################
logs/*.log
logs/screenshots/*.png
logs/screenshots/*.jpg
examples/*.log
examples/*.json
databases/*.db
databases/*.sql
databases/*.json
*.log
*.sql
*.sqlite
*.lock
yarn-debug.log
yarn-error.log
# OS generated files #
######################
.DS_Store
node_modules
.svelte-kit
build
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Python #
##########
*.pyc
*.pyo
# KDE/Linux generated files #
#############################
.directory
# Backup generated files #
##########################
*~
*.swp
*.bak
*#
# Android #
###########
*.apk
*.ap_
*.dex
bin/
gen/
.gradle/
build/
local.properties
# Vagrant #
###########
/.vagrant
# PHP #
#######
./config.php
phpunit.xml
/vendor
composer.phar
/bower_components
# Runtime data #
################
pids
*.pid
*.seed
*.pid.lock
*.eslintcache
# NodeJS #
##########
npm-debug.log
/node_modules
# Husky #
/.husky/_/
# SvelteKit #
#######
/.svelte-kit
# App #
#######
.env
/app/configs/config.js
/app/configs/config.ts
/app/configs/config.json
/app/configs/version.json
/app/configs/version.json
/dist
/build

0
.gitmodules vendored Normal file
View File

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run pre-commit

7
.npmignore Normal file
View File

@@ -0,0 +1,7 @@
**/*
!/extra/**/*
!*.d.ts
!index.js
!platforms.js
!*.md
!*.json

4
.prettierignore Normal file
View File

@@ -0,0 +1,4 @@
/dist
/build
/node_modules
package-lock.json

9
.prettierrc Normal file
View File

@@ -0,0 +1,9 @@
{
"bracketSpacing": true,
"printWidth": 120,
"semi": true,
"singleQuote": false,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": true
}

10
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"recommendations": [
"svelte.svelte-vscode",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"gruntfuggly.todo-tree",
"nickdodd79.gulptasks",
"pkief.material-icon-theme"
]
}

80
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 30000,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "svelte"],
"eslint.options": {
"extensinons": [".ts", ".js", ".tsx", ".jsx", ".svelte"]
},
"todo-tree.highlights.customHighlight": {
"TODO": {
"foreground": "black",
"background": "#82AAFF",
"icon": "tag",
"iconColour": "#82AAFF",
"gutterIcon": true
},
"BUG": {
"foreground": "white",
"background": "#AC4142",
"icon": "bug",
"iconColour": "#AC4142",
"gutterIcon": true
},
"FIXME": {
"foreground": "black",
"background": "#FFCC00",
"iconColour": "#FFCC00",
"icon": "alert",
"gutterIcon": true
}
},
"todo-tree.highlights.defaultHighlight": {
"type": "text-and-comment"
},
"material-icon-theme.folders.associations": {
"wordpress": "wordpress",
"modules": "App",
"desktop": "Container",
"dist-desktop": "Dist",
"dist-client": "Dist",
"dist-mobile": "Dist",
"webcomponent": "Middleware",
"webcomponents": "Middleware",
"interfaces": "Include",
"interface": "Include",
"logger": "Log",
"mode": "Class",
"types": "Typescript",
"ISSUE_TEMPLATE": "Template"
}
}

View File

@@ -1,3 +1,15 @@
## 0.1.0
# v0.2.0 (February 11, 2023)
- First release
- New Options: `viewport`
- New Options: `policy`
- Fix: HTML Regex
<!-- all-shields/sponsors-badges:START -->
[![Donate Paypal](https://img.shields.io/badge/donate-paypal-005EA6.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/ptkdev) [![Donate Ko-Fi](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ptkdev) [![Donate GitHub Sponsors](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?style=for-the-badge&logo=github)](https://github.com/sponsors/ptkdev) [![Donate Patreon](https://img.shields.io/badge/donate-patreon-F87668.svg?style=for-the-badge&logo=patreon)](https://www.patreon.com/join/ptkdev) [![Donate Bitcoin](https://img.shields.io/badge/BTC-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?style=flat-square&logo=bitcoin)](https://ptk.dev/img/icons/menu/bitcoin_wallet.png) [![Donate Ethereum](https://img.shields.io/badge/ETH-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?style=flat-square&logo=ethereum)](https://ptk.dev/img/icons/menu/ethereum_wallet.png)
<!-- all-shields/sponsors-badges:END -->
# v0.1.0 (February 06, 2023)
- First release

View File

@@ -1,7 +0,0 @@
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.

68
LICENSE.md Executable file
View File

@@ -0,0 +1,68 @@
## MIT License
> Code and Contributions
Copyright (c) 2021 Patryk Rzucidło (PTKDev) and [these people](https://github.com/sveltejs/kit/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.
##### https://choosealicense.com/licenses/mit/
## Creative Commons BY-NC 4.0 License
> Images, assets and logos
Copyleft (c) 2022 Patryk Rzucidło (PTKDev)
#### You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
#### Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that - suggests the licensor endorses you or your use.
- NonCommercial — You may not use the material for commercial purposes.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
##### https://creativecommons.org/licenses/by-nc/4.0/
## Creative Commons BY 4.0 License
> Documentation and Translations
Copyleft (c) 2022 Patryk Rzucidło (PTKDev)
#### You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
#### Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
##### https://creativecommons.org/licenses/by/4.0/

164
README.md Normal file → Executable file
View File

@@ -1,9 +1,167 @@
# @ptkdev/sveltekit-electron-adapter
[![sveltekit-electron-adapter logo](https://raw.githubusercontent.com/ptkdev/sveltekit-electron-adapter/main/.github/assets/logo.png)](https://github.com/ptkdev/sveltekit-electron-adapter)
# 🤖 sveltekit-electron-adapter
<!-- all-shields/header-badges:START -->
[![v0.2.0](https://img.shields.io/badge/version-v0.2.0-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev/sveltekit-electron-adapter/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/sveltekit-electron-adapter?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/sveltekit-electron-adapter) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev/sveltekit-electron-adapter/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Framework: Grammy](https://img.shields.io/badge/powered%20by-grammy-009dca.svg?style=flat&logo=telegram)](https://grammy.dev/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
<!-- all-shields/header-badges:END -->
[Adapter](https://kit.svelte.dev/docs/adapters) for SvelteKit apps that prerenders your entire site as a collection of static files for use with [Electron](https://electronjs.org). Create your desktop apps with SvelteKit and Electron.
This is a fork of official [sveltekit-static-adapter](https://kit.svelte.dev/docs/adapter-static)
## License
## 🎁 Support: Donate
[MIT](LICENSE)
> This project is **free**, **open source** and I try to provide excellent **free support**. Why donate? I work on this project several hours in my spare time and try to keep it up to date and working. **THANK YOU!**
<!-- all-shields/sponsors-badges:START -->
[![Donate Paypal](https://img.shields.io/badge/donate-paypal-005EA6.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/ptkdev) [![Donate Ko-Fi](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ptkdev) [![Donate GitHub Sponsors](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?style=for-the-badge&logo=github)](https://github.com/sponsors/ptkdev) [![Donate Patreon](https://img.shields.io/badge/donate-patreon-F87668.svg?style=for-the-badge&logo=patreon)](https://www.patreon.com/join/ptkdev) [![Donate Bitcoin](https://img.shields.io/badge/BTC-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?style=flat-square&logo=bitcoin)](https://ptk.dev/img/icons/menu/bitcoin_wallet.png) [![Donate Ethereum](https://img.shields.io/badge/ETH-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?style=flat-square&logo=ethereum)](https://ptk.dev/img/icons/menu/ethereum_wallet.png)
<!-- all-shields/sponsors-badges:END -->
## 📎 Menu
- 💡 [Features](#-features)
- 👔 [Screenshot](#-screenshot)
- 🚀 [Setup](#-setup)
- 🧰 [Options](#-options)
- 📚 [Documentation](#-documentation)
- 👨‍💻 [Contributing](#-contributing)
- 🐛 [Known Bugs](https://github.com/ptkdev/sveltekit-electron-adapter/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
- 🍻 Community:
- <img src="https://raw.githubusercontent.com/ptkdev/sveltekit-electron-adapter/main/.github/assets/social_telegram.png" height="18px"> Telegram ([🇬🇧 English](http://t.me/ptkdev_support) | [🇮🇹 Italian](http://t.me/ptkdev_support_italian))
## 💡 Features
- [✔️] Easy to use
- [✔️] MIT License
- [✔️] Make desktop apps with svelte kit and electron
## 👔 Screenshot
[![sveltekit-electron-adapter](https://raw.githubusercontent.com/ptkdev/sveltekit-electron-adapter/main/.github/assets/screenshot.png)](https://raw.githubusercontent.com/ptkdev/sveltekit-electron-adapter/main/.github/assets/screenshot.png)
## 🚀 Setup
1. Create [new SvelteKit Project](https://kit.svelte.dev/docs/creating-a-project)
2. Install this adapter `npm install @ptkdev/sveltekit-electron-adapter --save-dev`
3. Edit `svelte.config.js` and replace default adapter with electron-adapter:
```js
import adapter from "@ptkdev/sveltekit-electron-adapter";
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
strict: true,
}),
},
};
```
4. Run `npm run build` (⚠️ IMPORTANT: Only pages with `export const prerender = true;` are supported)
5. Create [new Electron Forge Project](https://www.electronforge.io/)
6. Copy `build` content from sveltekit project and paste in `src` folder of electron forge project
7. Run Electron project with `npm run start` or generate binary with `npm run make`
I make a boilerplate that "automate" this process, but is working in progress: check [this repo](https://github.com/ptkdev-boilerplate/svelte-electron-boilerplate).
## 🧰 Options
The `adatper({ options })` parameters list:
| Parameter | Description | Values | Default value | Available since |
| ----------- | --------------------------------------------------------------- | ------ | ----------------------------------------------------------- | --------------- |
| pages | See official [docs](https://kit.svelte.dev/docs/adapter-static) | | | |
| assets | See official [docs](https://kit.svelte.dev/docs/adapter-static) | | | |
| fallback | See official [docs](https://kit.svelte.dev/docs/adapter-static) | | | |
| precompress | See official [docs](https://kit.svelte.dev/docs/adapter-static) | | | |
| strict | See official [docs](https://kit.svelte.dev/docs/adapter-static) | | | |
| policy | Set meta-tag `content-security-policy` | String | `default-src 'self'; script-src 'self'` | v0.2.0 |
| viewport | Set meta-tag `viewport` | String | `width=device-width, initial-scale=1.0, viewport-fit=cover` | v0.2.0 |
#### Example:
```js
const config = {
kit: {
adapter: adapter({
strict: true,
policy: "",
viewport: `width=device-width`,
}),
},
};
```
## 📚 Documentation
Run `npm run docs`
## 👑 Backers and Sponsors
Thanks to all our backers! 🙏 Donate 3$ or more on [paypal](https://www.paypal.me/ptkdev), [ko-fi](https://ko-fi.com/ptkdev), [github](https://github.com/sponsors/ptkdev) or [patreon](https://www.patreon.com/join/ptkdev) and send me [email](mailto:support@ptkdev.io) with your avatar and url.
[![](https://api.ptkdev.io/backers/sponsor1.png?)](https://api.ptkdev.io/backers/sponsor1.html) [![](https://api.ptkdev.io/backers/sponsor2.png?)](https://api.ptkdev.io/backers/sponsor2.html) [![](https://api.ptkdev.io/backers/sponsor-kofi1.png?)](https://api.ptkdev.io/backers/sponsor-kofi1.html) [![](https://api.ptkdev.io/backers/sponsor-kofi2.png?)](https://api.ptkdev.io/backers/sponsor-kofi2.html) [![](https://api.ptkdev.io/backers/sponsor-kofi3.png?)](https://api.ptkdev.io/backers/sponsor-kofi3.html) [![](https://api.ptkdev.io/backers/sponsor3.png?)](https://api.ptkdev.io/backers/sponsor3.html) [![](https://api.ptkdev.io/backers/sponsor4.png?)](https://api.ptkdev.io/backers/sponsor4.html) [![](https://api.ptkdev.io/backers/sponsor5.png?)](https://api.ptkdev.io/backers/sponsor5.html) [![](https://api.ptkdev.io/backers/sponsor6.png?)](https://api.ptkdev.io/backers/sponsor6.html) [![](https://api.ptkdev.io/backers/sponsor7.png?)](https://api.ptkdev.io/backers/sponsor7.html) [![](https://api.ptkdev.io/backers/sponsor8.png?)](https://api.ptkdev.io/backers/sponsor8.html) [![](https://api.ptkdev.io/backers/sponsor9.png?)](https://api.ptkdev.io/backers/sponsor9.html) [![](https://api.ptkdev.io/backers/sponsor10.png?)](https://api.ptkdev.io/backers/sponsor10.html) [![](https://api.ptkdev.io/backers/sponsor11.png?)](https://api.ptkdev.io/backers/sponsor11.html) [![](https://api.ptkdev.io/backers/sponsor12.png?)](https://api.ptkdev.io/backers/sponsor12.html) [![](https://api.ptkdev.io/backers/sponsor13.png?)](https://api.ptkdev.io/backers/sponsor13.html) [![](https://api.ptkdev.io/backers/sponsor14.png?)](https://api.ptkdev.io/backers/sponsor14.html) [![](https://api.ptkdev.io/backers/sponsor15.png?)](https://api.ptkdev.io/backers/sponsor15.html) [![](https://api.ptkdev.io/backers/backer1.png?)](https://api.ptkdev.io/backers/backer1.html) [![](https://api.ptkdev.io/backers/backer2.png?)](https://api.ptkdev.io/backers/backer2.html) [![](https://api.ptkdev.io/backers/backer3.png?)](https://api.ptkdev.io/backers/backer3.html) [![](https://api.ptkdev.io/backers/backer4.png?)](https://api.ptkdev.io/backers/backer4.html) [![](https://api.ptkdev.io/backers/backer5.png?)](https://api.ptkdev.io/backers/backer5.html) [![](https://api.ptkdev.io/backers/backer6.png?)](https://api.ptkdev.io/backers/backer6.html) [![](https://api.ptkdev.io/backers/backer7.png?)](https://api.ptkdev.io/backers/backer7.html) [![](https://api.ptkdev.io/backers/backer8.png?)](https://api.ptkdev.io/backers/backer8.html) [![](https://api.ptkdev.io/backers/backer9.png?)](https://api.ptkdev.io/backers/backer9.html) [![](https://api.ptkdev.io/backers/backer10.png?)](https://api.ptkdev.io/backers/backer10.html) [![](https://api.ptkdev.io/backers/backer11.png?)](https://api.ptkdev.io/backers/backer11.html) [![](https://api.ptkdev.io/backers/backer12.png?)](https://api.ptkdev.io/backers/backer12.html) [![](https://api.ptkdev.io/backers/backer13.png?)](https://api.ptkdev.io/backers/backer13.html) [![](https://api.ptkdev.io/backers/backer14.png?)](https://api.ptkdev.io/backers/backer14.html) [![](https://api.ptkdev.io/backers/backer15.png?)](https://api.ptkdev.io/backers/backer15.html) [![](https://api.ptkdev.io/backers/backer16.png?)](https://api.ptkdev.io/backers/backer16.html) [![](https://api.ptkdev.io/backers/backer17.png?)](https://api.ptkdev.io/backers/backer17.html) [![](https://api.ptkdev.io/backers/backer18.png?)](https://api.ptkdev.io/backers/backer18.html) [![](https://api.ptkdev.io/backers/backer19.png?)](https://api.ptkdev.io/backers/backer19.html) [![](https://api.ptkdev.io/backers/backer20.png?)](https://api.ptkdev.io/backers/backer20.html) [![](https://api.ptkdev.io/backers/backer21.png?)](https://api.ptkdev.io/backers/backer21.html) [![](https://api.ptkdev.io/backers/backer22.png?)](https://api.ptkdev.io/backers/backer22.html) [![](https://api.ptkdev.io/backers/backer23.png?)](https://api.ptkdev.io/backers/backer23.html) [![](https://api.ptkdev.io/backers/backer24.png?)](https://api.ptkdev.io/backers/backer24.html) [![](https://api.ptkdev.io/backers/backer25.png?)](https://api.ptkdev.io/backers/backer25.html) [![](https://api.ptkdev.io/backers/backer26.png?)](https://api.ptkdev.io/backers/backer26.html) [![](https://api.ptkdev.io/backers/backer27.png?)](https://api.ptkdev.io/backers/backer27.html) [![](https://api.ptkdev.io/backers/backer28.png?)](https://api.ptkdev.io/backers/backer28.html) [![](https://api.ptkdev.io/backers/backer29.png?)](https://api.ptkdev.io/backers/backer29.html)
## 👨‍💻 Contributing
I ❤️ contributions! I will happily accept your pull request! (**IMPORTANT**: Only to nightly branch!) Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file.
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="16.66%"><a href="https://ptk.dev"><img src="https://avatars1.githubusercontent.com/u/442844?v=4?s=100" width="100px;" alt="Patryk Rzucidło"/><br /><sub><b>Patryk Rzucidło</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev/sveltekit-electron-adapter/commits?author=ptkdev" title="Code">💻</a> <a href="#translation-ptkdev" title="Translation">🌍</a> <a href="https://github.com/ptkdev/ptkdev/sveltekit-electron-adapter/commits?author=ptkdev" title="Documentation">📖</a> <a href="https://github.com/ptkdev/ptkdev/sveltekit-electron-adapter/issues?q=author%3Aptkdev" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
> 💰 In the future, if the donations allow it, I would like to share some of the success with those who helped me the most. For me open source is share of code, share development knowledges and share donations!
## 🦄 Other Projects
<!-- all-shields/projects-badges1:START -->
[![](https://img.shields.io/badge/%F0%9F%92%BB%20My-Portfolio-3498db.svg?style=flat&logo=)](https://ptk.dev/)
<!-- all-shields/projects-badges1:END -->
<!-- all-shields/projects-badges2:START -->
[![](https://img.shields.io/badge/%F0%9F%A6%92%20Tools-Node%20Logger-9b59b6.svg?style=flat&logo=)](https://github.com/ptkdev/ptkdev-logger) [![](https://img.shields.io/badge/%F0%9F%A6%8C%20Tools-All%20Shields%20CLI-9b59b6.svg?style=flat&logo=)](https://github.com/ptkdev/all-shields-cli) [![](https://img.shields.io/badge/%F0%9F%96%A5%EF%B8%8F%20Tools-Aspect%20Ratio%2021%3A9-9b59b6.svg?style=flat&logo=)](https://github.com/ptkdev/chrome-extension-aspectratio219) [![](https://img.shields.io/badge/%F0%9F%9B%A1%20Tools-Badges%3A%20Available%20on-9b59b6.svg?style=flat&logo=)](https://availableon.badge.ptkdev.io/) [![](https://img.shields.io/badge/%F0%9F%90%BE%20Tools-JSON%20Token%20Replace-9b59b6.svg?style=flat&logo=)](https://github.com/ptkdev/json-token-replace) [![](https://img.shields.io/badge/%F0%9F%90%8D%20Tools-ESLint%3A%20snakecasejs-9b59b6.svg?style=flat&logo=)](https://github.com/ptkdev/eslint-plugin-snakecasejs)
<!-- all-shields/projects-badges2:END -->
<!-- all-shields/projects-badges3:START -->
[![](https://img.shields.io/badge/%F0%9F%93%B8%20WebComponent-Instagram%20Widget-e74c3c.svg?style=flat&logo=)](https://github.com/ptkdev-components/webcomponent-instagram-widget) [![](https://img.shields.io/badge/%F0%9F%91%91%20WebComponent-My%20Patreon%20Box-e74c3c.svg?style=flat&logo=)](https://github.com/ptkdev-components/webcomponent-patreon-box) [![](https://img.shields.io/badge/%F0%9F%8F%9E%20WebComponent-Carousel%20Slideshow-e74c3c.svg?style=flat&logo=)](https://github.com/ptkdev-components/webcomponent-carousel-slideshow)
<!-- all-shields/projects-badges3:END -->
<!-- all-shields/projects-badges4:START -->
[![](https://img.shields.io/badge/%F0%9F%8E%A8%20Themes-VSCode-f1c40f.svg?style=flat&logo=)](https://github.com/ptkdev/vscode-theme-dark-blood) [![](https://img.shields.io/badge/%F0%9F%93%9A%20Bot-GameBookChat-34495e.svg?style=flat&logo=)](https://t.me/gamebookchatbot) [![](https://img.shields.io/badge/%F0%9F%91%94%20Boilerplate-Svelte-f368e0.svg?style=flat&logo=)](https://github.com/ptkdev?q=svelte) [![](https://img.shields.io/badge/%F0%9F%91%94%20Boilerplate-WebComponents-f368e0.svg?style=flat&logo=)](https://github.com/ptkdev?q=webcomponent) [![](https://img.shields.io/badge/%F0%9F%91%94%20Boilerplate-BOT-f368e0.svg?style=flat&logo=)](https://github.com/ptkdev?q=bot) [![](https://img.shields.io/badge/%F0%9F%91%94%20Boilerplate-Node-f368e0.svg?style=flat&logo=)](https://github.com/ptkdev?q=node) [![](https://img.shields.io/badge/%F0%9F%92%85%20App-Me%20in%20Gifs-2ecc71.svg?style=flat&logo=)](https://meingifs.pics/) [![](https://img.shields.io/badge/%F0%9F%93%B1%20App-Stickers-2ecc71.svg?style=flat&logo=)](https://github.com/ptkdev/ptkdev-stickers#-install-free)
<!-- all-shields/projects-badges4:END -->
## 💫 License
- Code and Contributions have **MIT License**
- Images and logos have **CC BY-NC 4.0 License**
- Documentations and Translations have **CC BY 4.0 License**
###### Copyleft (c) 2022 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)>

View File

@@ -1,13 +1,13 @@
import { Adapter } from "@sveltejs/kit";
export interface AdapterOptions {
pages?: string;
assets?: string;
fallback?: string;
precompress?: boolean;
strict?: boolean;
policy?: string;
viewport?: string;
pages?: string;
assets?: string;
fallback?: string;
precompress?: boolean;
strict?: boolean;
policy?: string;
viewport?: string;
}
export default function plugin(options?: AdapterOptions): Adapter;

175
app/adapter/index.js Normal file
View File

@@ -0,0 +1,175 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import path from "path";
import glob from "tiny-glob";
import replace from "replace-in-file";
import { platforms } from "./platforms.js";
/** @type {import('.').default} */
export default function (options) {
return {
name: "@ptkdev/sveltekit-electron-adapter",
async adapt(builder) {
if (!options?.fallback) {
/** @type {string[]} */
const dynamic_routes = [];
// this is a bit of a hack — it allows us to know whether there are dynamic
// (i.e. prerender = false/'auto') routes without having dedicated API
// surface area for it
builder.createEntries((route) => {
dynamic_routes.push(route.id);
return {
id: "",
filter: () => false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
complete: () => {},
};
});
if (dynamic_routes.length > 0 && options?.strict !== false) {
const prefix = path.relative(".", builder.config.kit.files.routes);
const has_param_routes = dynamic_routes.some((route) => route.includes("["));
const config_option =
has_param_routes || JSON.stringify(builder.config.kit.prerender.entries) !== '["*"]'
? ` - adjust the \`prerender.entries\` config option ${
has_param_routes
? "(routes with parameters are not part of entry points by default)"
: ""
} — see https://kit.svelte.dev/docs/configuration#prerender for more info.`
: "";
builder.log.error(
`@ptkdev/sveltekit-electron-adapter: all routes must be fully prerenderable, but found the following routes that are dynamic:
${dynamic_routes.map((id) => ` - ${path.posix.join(prefix, id)}`).join("\n")}
You have the following options:
- set the \`fallback\` option — see https://github.com/sveltejs/kit/tree/master/packages/adapter-static#spa-mode for more info.
- add \`export const prerender = true\` to your root \`+layout.js/.ts\` or \`+layout.server.js/.ts\` file. This will try to prerender all pages.
- add \`export const prerender = true\` to any \`+server.js/ts\` files that are not fetched by page \`load\` functions.
${config_option}
- pass \`strict: false\` to \`adapter-static\` to ignore this error. Only do this if you are sure you don't need the routes in question in your final app, as they will be unavailable. See https://github.com/sveltejs/kit/tree/master/packages/adapter-static#strict for more info.
If this doesn't help, you may need to use a different adapter. @ptkdev/sveltekit-electron-adapter can only be used for sites that don't need a server for dynamic rendering, and can run on just a static file server.
See https://kit.svelte.dev/docs/page-options#prerender for more details`,
);
throw new Error("Encountered dynamic routes");
}
}
const platform = platforms.find((platform) => platform.test());
if (platform) {
if (options) {
builder.log.warn(
`Detected ${platform.name}. Please remove adapter-static options to enable zero-config mode`,
);
} else {
builder.log.info(`Detected ${platform.name}, using zero-config mode`);
}
}
const {
pages = "build",
assets = pages,
fallback,
precompress,
} = options ?? platform?.defaults ?? /** @type {import('./index').AdapterOptions} */ ({});
builder.rimraf(assets);
builder.rimraf(pages);
builder.writeClient(assets);
builder.writePrerendered(pages);
const HTML_pages = await glob("**/*.html", {
cwd: pages,
dot: true,
absolute: true,
filesOnly: true,
});
HTML_pages.forEach(async (path) => {
let href = path.split("/").pop();
let regex_input = new RegExp(`href="/${href.replace(".html", "")}"`, "g");
let regex_replace = `href="${`./${href}`}"`;
if (href === "index.html") {
regex_input = new RegExp(`href="/"`, "g");
regex_replace = `href="./index.html"`;
}
await replace.sync({
files: [`${pages}/**/*.html`],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
});
let regex_input = new RegExp(`http-equiv="content-security-policy" content=""`, "g");
const policy = "default-src 'self'; script-src 'self'";
let regex_replace = `http-equiv="content-security-policy" content="${
options?.policy ? options.policy : policy
}"`;
await replace.sync({
files: [`${pages}/**/*.html`],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
const HTML_assets = await glob("_app/**/*", {
cwd: pages,
dot: true,
absolute: false,
filesOnly: true,
});
HTML_assets.forEach(async () => {
let regex_input = new RegExp(`[^.](/_app/immutable)`, "g");
let regex_replace = `./_app/immutable`;
await replace.sync({
files: [`${pages}/**/*`],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
});
regex_input = new RegExp(`name="viewport" content="width=device-width"`, "g");
const viewport = "width=device-width, initial-scale=1.0, viewport-fit=cover";
regex_replace = `name="viewport" content="${options?.viewport ? options.viewport : viewport}"`;
await replace.sync({
files: [`${pages}/**/*.html`],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
if (fallback) {
builder.generateFallback(path.join(pages, fallback));
}
if (precompress) {
builder.log.minor("Compressing assets and pages");
if (pages === assets) {
await builder.compress(assets);
} else {
await Promise.all([builder.compress(assets), builder.compress(pages)]);
}
}
if (pages === assets) {
builder.log(`Wrote site to "${pages}"`);
} else {
builder.log(`Wrote pages to "${pages}" and assets to "${assets}"`);
}
if (!options) {
platform?.done(builder);
}
},
};
}

View File

@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from "fs";
/**
* @typedef {{
@@ -22,17 +22,17 @@ function static_vercel_config(builder) {
prerendered_redirects.push({
src,
headers: {
Location: redirect.location
Location: redirect.location,
},
status: redirect.status
status: redirect.status,
});
}
for (const [path, page] of builder.prerendered.pages) {
if (path.endsWith('/') && path !== '/') {
if (path.endsWith("/") && path !== "/") {
prerendered_redirects.push(
{ src: path, dest: path.slice(0, -1) },
{ src: path.slice(0, -1), status: 308, headers: { Location: path } }
{ src: path.slice(0, -1), status: 308, headers: { Location: path } },
);
overrides[page.file] = { path: path.slice(1, -1) };
@@ -48,28 +48,28 @@ function static_vercel_config(builder) {
{
src: `/${builder.getAppPath()}/immutable/.+`,
headers: {
'cache-control': 'public, immutable, max-age=31536000'
}
"cache-control": "public, immutable, max-age=31536000",
},
},
{
handle: 'filesystem'
}
handle: "filesystem",
},
],
overrides
overrides,
};
}
/** @type {Platform[]} */
export const platforms = [
{
name: 'Vercel',
name: "Vercel",
test: () => !!process.env.VERCEL,
defaults: {
pages: '.vercel/output/static'
pages: ".vercel/output/static",
},
done: (builder) => {
const config = static_vercel_config(builder);
fs.writeFileSync('.vercel/output/config.json', JSON.stringify(config, null, ' '));
}
}
fs.writeFileSync(".vercel/output/config.json", JSON.stringify(config, null, " "));
},
},
];

191
index.js
View File

@@ -1,191 +0,0 @@
import path from "path";
import glob from "tiny-glob";
import replace from "replace-in-file";
import { platforms } from "./platforms.js";
/** @type {import('.').default} */
export default function (options) {
return {
name: "@ptkdev/sveltekit-electron-adapter",
async adapt(builder) {
if (!options?.fallback) {
/** @type {string[]} */
const dynamic_routes = [];
// this is a bit of a hack — it allows us to know whether there are dynamic
// (i.e. prerender = false/'auto') routes without having dedicated API
// surface area for it
builder.createEntries((route) => {
dynamic_routes.push(route.id);
return {
id: "",
filter: () => false,
complete: () => {},
};
});
if (dynamic_routes.length > 0 && options?.strict !== false) {
const prefix = path.relative(".", builder.config.kit.files.routes);
const has_param_routes = dynamic_routes.some((route) =>
route.includes("[")
);
const config_option =
has_param_routes ||
JSON.stringify(builder.config.kit.prerender.entries) !== '["*"]'
? ` - adjust the \`prerender.entries\` config option ${
has_param_routes
? "(routes with parameters are not part of entry points by default)"
: ""
} — see https://kit.svelte.dev/docs/configuration#prerender for more info.`
: "";
builder.log.error(
`@ptkdev/sveltekit-electron-adapter: all routes must be fully prerenderable, but found the following routes that are dynamic:
${dynamic_routes.map((id) => ` - ${path.posix.join(prefix, id)}`).join("\n")}
You have the following options:
- set the \`fallback\` option — see https://github.com/sveltejs/kit/tree/master/packages/adapter-static#spa-mode for more info.
- add \`export const prerender = true\` to your root \`+layout.js/.ts\` or \`+layout.server.js/.ts\` file. This will try to prerender all pages.
- add \`export const prerender = true\` to any \`+server.js/ts\` files that are not fetched by page \`load\` functions.
${config_option}
- pass \`strict: false\` to \`adapter-static\` to ignore this error. Only do this if you are sure you don't need the routes in question in your final app, as they will be unavailable. See https://github.com/sveltejs/kit/tree/master/packages/adapter-static#strict for more info.
If this doesn't help, you may need to use a different adapter. @ptkdev/sveltekit-electron-adapter can only be used for sites that don't need a server for dynamic rendering, and can run on just a static file server.
See https://kit.svelte.dev/docs/page-options#prerender for more details`
);
throw new Error("Encountered dynamic routes");
}
}
const platform = platforms.find((platform) => platform.test());
if (platform) {
if (options) {
builder.log.warn(
`Detected ${platform.name}. Please remove adapter-static options to enable zero-config mode`
);
} else {
builder.log.info(`Detected ${platform.name}, using zero-config mode`);
}
}
const {
pages = "build",
assets = pages,
fallback,
precompress,
} = options ??
platform?.defaults ??
/** @type {import('./index').AdapterOptions} */ ({});
builder.rimraf(assets);
builder.rimraf(pages);
builder.writeClient(assets);
builder.writePrerendered(pages);
const HTML_pages = await glob("**/*.html", {
cwd: pages,
dot: true,
absolute: true,
filesOnly: true,
});
HTML_pages.forEach(async (path) => {
let href = path.split("/").pop();
let regex_input = new RegExp(
`href="/${href.replace(".html", "")}"`,
"g"
);
let regex_replace = `href="${"./" + href}"`;
if (href === "index.html") {
regex_input = new RegExp(`href="/"`, "g");
regex_replace = `href="./index.html"`;
}
await replace.sync({
files: [pages + "/**/*.html"],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
});
let regex_input = new RegExp(
`http-equiv="content-security-policy" content=""`,
"g"
);
const policy = "";
let regex_replace = `http-equiv="content-security-policy" content="${
options?.policy ? options.policy : policy
}"`;
await replace.sync({
files: [pages + "/**/*.html"],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
const HTML_assets = await glob("_app/**/*", {
cwd: pages,
dot: true,
absolute: false,
filesOnly: true,
});
HTML_assets.forEach(async () => {
let regex_input = new RegExp(`[^.](/_app/immutable)`, "g");
let regex_replace = `./_app/immutable`;
await replace.sync({
files: [pages + "/**/*"],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
});
regex_input = new RegExp(
`name="viewport" content="width=device-width"`,
"g"
);
const viewport =
"width=device-width, initial-scale=1.0, viewport-fit=cover";
regex_replace = `name="viewport" content="${
options?.viewport ? options.viewport : viewport
}"`;
await replace.sync({
files: [pages + "/**/*.html"],
// @ts-ignore
processor: (input) => input.replace(regex_input, regex_replace),
});
if (fallback) {
builder.generateFallback(path.join(pages, fallback));
}
if (precompress) {
builder.log.minor("Compressing assets and pages");
if (pages === assets) {
await builder.compress(assets);
} else {
await Promise.all([
builder.compress(assets),
builder.compress(pages),
]);
}
}
if (pages === assets) {
builder.log(`Wrote site to "${pages}"`);
} else {
builder.log(`Wrote pages to "${pages}" and assets to "${assets}"`);
}
if (!options) platform?.done(builder);
},
};
}

9
jest.config.js Normal file
View File

@@ -0,0 +1,9 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
},
},
};

0
logs/.empty Normal file
View File

16452
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,9 @@
{
"name": "@ptkdev/sveltekit-electron-adapter",
"version": "0.1.0",
"repository": {
"type": "git",
"url": "https://github.com/ptkdev/sveltekit-electron-adapter"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"homepage": "https://github.com/ptkdev/sveltekit-electron-adapter",
"displayName": "SvelteKit Adapter for Desktop Apps with Electron",
"description": "Adapter for SvelteKit apps that prerenders your entire site as a collection of static files for use with Electron",
"version": "0.2.0",
"main": "./index.js",
"type": "module",
"exports": {
".": {
@@ -19,30 +13,95 @@
"./package.json": "./package.json"
},
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts",
"platforms.js"
],
"publishConfig": {
"access": "public"
},
"author": "Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)",
"license": "MIT",
"license-docs": "CC BY 4.0",
"license-translations": "CC BY 4.0",
"license-images": "CC BY-NC 4.0",
"homepage": "https://github.com/ptkdev/sveltekit-electron-adapter",
"repository": {
"type": "git",
"url": "https://github.com/ptkdev/sveltekit-electron-adapter.git"
},
"bugs": {
"url": "https://github.com/ptkdev/sveltekit-electron-adapter/issues"
},
"engines": {
"node": ">=14.0.0"
},
"scripts": {
"lint": "prettier --check . --config .prettierrc --ignore-path .gitignore",
"check": "tsc",
"format": "pnpm lint --write",
"test": "uvu test test.js"
"build": "cp ./app/**/* . -r",
"release": "npm run build",
"test": "jest app",
"docs": "git submodule update --recursive && markserv ./README.md",
"lint": "npm run lint-prettify && eslint . --cache --ext .ts,.js",
"lint-fix": "npm run lint-prettify && eslint . --cache --ext .ts,.js --fix",
"lint-prettify": "prettier --write --ignore-unknown '**/*.{md,json,ts,js}'",
"git-set-upstream": "git remote add upstream git@github.com:ptkdev/sveltekit-electron-adapter.git && git fetch upstream",
"git-pull-upstream": "git pull upstream main && git pull upstream beta && git pull upstream nightly",
"git-pull": "git pull --recursive",
"git-hash": "ts-node scripts/githash.ts",
"git-ignore-reset": "git rm -r --cached . && git add . && git commit -m \"[Fix] Removing all files in .gitignore\"",
"github-workflow-next-version": "ts-node scripts/version.ts",
"github-workflow-changelog": "ts-node scripts/changelog_release.ts",
"npm-publish-main": "git checkout main && npm publish",
"npm-publish-beta": "git checkout beta && npm publish --tag beta",
"npm-publish-nightly": "git checkout nightly && npm publish --tag nightly",
"contributors-generate": "all-contributors generate",
"all-shields-generate": "all-shields-generate",
"pre-commit": "npm run contributors-generate && npm run all-shields-generate && npm run lint-fix",
"pkg-clean": "rm -rf node_modules package-lock.json && npm install && npm install eslint@7 @types/yargs@16 --save-dev && husky install",
"pkg-update": "npm update",
"pkg-upgrade": "npx --yes npm-check-updates -u && npm install && npm install eslint@7 @types/yargs@16 --save-dev && husky install"
},
"dependencies": {
"replace-in-file": "^6.3.5",
"tiny-glob": "^0.2.9"
},
"devDependencies": {
"@types/node": "^16.18.6",
"@ptkdev/all-shields-cli": "^2.0.2",
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"@types/shelljs": "^0.8.11",
"@types/yargs": "^16.0.5",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"all-contributors-cli": "^6.24.0",
"eslint": "^7.32.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsdoc": "^39.8.0",
"husky": "^8.0.3",
"jest": "^29.4.2",
"json": "^11.0.0",
"markserv": "^1.17.4",
"prettier": "^2.8.4",
"shelljs": "^0.8.5",
"sirv": "^2.0.2",
"svelte": "^3.55.1",
"typescript": "^4.9.4",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-patch": "^2.1.0",
"typescript": "^4.9.5",
"typescript-transform-paths": "^3.4.6",
"uvu": "^0.5.6",
"vite": "^4.0.4"
"vite": "^4.1.1",
"yargs": "^17.6.2"
},
"peerDependencies": {
"@sveltejs/kit": "^1.0.0"
}
}
},
"keywords": [
"ptkdev",
"svelte",
"sveltekit",
"electron",
"electronjs",
"electron forge",
"sveltekit adapter",
"sveltekit electron",
"sveltekit electron forge"
]
}

31
scripts/changelog.ts Normal file
View File

@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* Reset CHANGELOG
* =====================
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as fs from "fs";
declare const __dirname: string;
const changelog = `# v1.0.0 (${new Date().toLocaleString("en-us", {
month: "long",
year: "numeric",
day: "numeric",
})})
- First release
<!-- all-shields/sponsors-badges:START -->
<!-- all-shields/sponsors-badges:END -->
`;
fs.unlinkSync(`${__dirname}/../CHANGELOG.md`);
fs.writeFileSync(`${__dirname}/../CHANGELOG.md`, `${changelog}`, {
encoding: "utf8",
});

6
scripts/changelog_release.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
CHANGELOG=$(cat ./CHANGELOG_RELEASE.txt)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo ::set-output name=changelog::$CHANGELOG

View File

@@ -0,0 +1,31 @@
/**
* Version
* =====================
* Increment package.json version
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import Logger from "@ptkdev/logger";
const logger = new Logger();
if (fs.existsSync("./CHANGELOG.md")) {
fs.readFile("./CHANGELOG.md", "utf8", (error, data) => {
if (error) {
logger.error(JSON.stringify(error));
}
const changelog = data.match(/\n([\s\S]*)-->\n/gm);
changelog?.forEach((c) => {
fs.writeFile("./CHANGELOG_RELEASE.txt", c, function writeJSON(error) {
if (error) {
logger.error(JSON.stringify(error));
}
});
});
});
}

20
scripts/configs.ts Normal file
View File

@@ -0,0 +1,20 @@
/**
* Check configs.js
* =====================
* Check if configs/config.js exist, if don't exist rename .tpl
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
declare const __dirname: string;
const path = `${__dirname}/../app/configs/config.js`;
if (!fs.existsSync(path)) {
shell.cp("-Rf", `${__dirname}/../app/configs/config.js.tpl`, path);
}

25
scripts/debug.ts Normal file
View File

@@ -0,0 +1,25 @@
/**
* Disable debug
* =====================
* Check if configs/config.js has debug to off
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
import { argv } from "yargs";
declare const __dirname: string;
const path = `${__dirname}/../app/configs/config.js`;
if (fs.existsSync(path)) {
if (argv.enable) {
shell.sed("-i", 'debug: "disabled"', 'debug: "enabled"', path);
} else {
shell.sed("-i", 'debug: "enabled"', 'debug: "disabled"', path);
}
}

33
scripts/githash.ts Normal file
View File

@@ -0,0 +1,33 @@
import Logger from "@ptkdev/logger";
import fs from "fs";
import path from "path";
import { execSync } from "child_process";
import semver from "../package.json";
const gitdotfile = `${__dirname}/../.git/config`;
const logger = new Logger();
let branch = "";
let hash = "";
const execSyncWrapper = (command: string) => {
let stdout = "";
try {
stdout = execSync(command).toString().trim();
} catch (error) {
logger.error(JSON.stringify(error));
}
return stdout;
};
if (fs.existsSync(gitdotfile)) {
branch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
hash = execSyncWrapper("git rev-parse --short=7 HEAD");
}
const obj = {
semver: semver.version.split("-")[0],
branch,
hash,
};
fs.writeFileSync(path.resolve("app/configs", "version.json"), JSON.stringify(obj, null, "\t"));

23
scripts/init.ts Normal file
View File

@@ -0,0 +1,23 @@
/**
* Init
* =====================
* Configure telegram token and username
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
import { argv } from "yargs";
declare const __dirname: string;
console.log(argv, argv._[0]);
const path = `${__dirname}/../app/configs/config.js`;
if (fs.existsSync(path)) {
shell.sed("-i", "BOT_USERNAME", `${argv._[0]}`, path);
shell.sed("-i", "BOT_TOKEN", `${argv._[1]}`, path);
}

16
scripts/rmdist.ts Normal file
View File

@@ -0,0 +1,16 @@
/**
* Delete dist folder
* =====================
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as shell from "shelljs";
declare const __dirname: string;
const path = `${__dirname}/../dist`;
shell.rm("-Rf", path);

3
scripts/version.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
PACKAGE_VERSION=$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
echo ::set-output name=pkgversion::$PACKAGE_VERSION

54
scripts/version.ts Normal file
View File

@@ -0,0 +1,54 @@
/**
* Version
* =====================
* Increment package.json version
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import Logger from "@ptkdev/logger";
import { argv } from "yargs";
import pkg from "../package.json";
const logger = new Logger();
const version = pkg.version.split(".");
let next_version, patch;
switch (argv.cmd) {
case "nightly":
next_version = `${version[0]}.${version[1]}.${version[2]}.${Number(version[3]) + 1}`;
break;
case "nightly-next":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0]) + 1}-nightly.0`;
break;
case "beta":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0])}-beta.1`;
break;
case "main":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0])}`;
break;
default:
next_version = "0.0.0";
break;
}
pkg.version = next_version;
if (fs.existsSync("./package.json")) {
fs.writeFile("./package.json", JSON.stringify(pkg), function writeJSON(error) {
if (error) {
logger.error(JSON.stringify(error));
}
});
}

View File

@@ -1,5 +0,0 @@
.DS_Store
node_modules
/.svelte-kit
/build
/functions

View File

@@ -1 +0,0 @@
engine-strict=true

View File

@@ -1,16 +0,0 @@
{
"name": "~TODO~",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"start": "vite start"
},
"devDependencies": {
"@sveltejs/kit": "workspace:^",
"svelte": "^3.55.1",
"vite": "^4.0.4"
},
"type": "module"
}

View File

@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>

View File

@@ -1 +0,0 @@
/// <reference types="@sveltejs/kit" />

View File

@@ -1 +0,0 @@
export const prerender = true;

View File

@@ -1 +0,0 @@
<slot />

View File

@@ -1,5 +0,0 @@
/** @type {import('./$types').PageLoad} */
export async function load({ fetch }) {
const res = await fetch('/endpoint/implicit.json');
return await res.json();
}

View File

@@ -1,7 +0,0 @@
<script>
/** @type {import('./$types').PageData} */
export let data;
</script>
<h1>This page was prerendered</h1>
<p>answer: {data.answer}</p>

View File

@@ -1,8 +0,0 @@
import { json } from '@sveltejs/kit';
export const prerender = true;
/** @type {import('./$types').RequestHandler} */
export function GET() {
return json({ answer: 42 });
}

View File

@@ -1,9 +0,0 @@
import { json } from '@sveltejs/kit';
// no export const prerender here, it should be prerendered by virtue
// of being fetched from a prerendered page
/** @type {import('./$types').RequestHandler} */
export function GET() {
return json({ answer: 42 });
}

View File

@@ -1,10 +0,0 @@
import adapter from '../../../index.js';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
}
};
export default config;

View File

@@ -1,11 +0,0 @@
import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
plugins: [sveltekit()]
};
export default config;

View File

@@ -1,5 +0,0 @@
.DS_Store
node_modules
/.svelte-kit
/build
/functions

View File

@@ -1 +0,0 @@
engine-strict=true

View File

@@ -1,36 +0,0 @@
# create-svelte
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```bash
# create a new project in the current directory
npm init svelte
# create a new project in my-app
npm init svelte my-app
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```bash
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. Then:
```bash
npm run build
```
> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.

View File

@@ -1,4 +0,0 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}

View File

@@ -1,18 +0,0 @@
{
"name": "~TODO~",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"start": "sirv -s 200.html build"
},
"devDependencies": {
"@sveltejs/adapter-node": "workspace:^",
"@sveltejs/kit": "workspace:^",
"sirv-cli": "^2.0.2",
"svelte": "^3.55.1",
"vite": "^4.0.4"
},
"type": "module"
}

View File

@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>

View File

@@ -1,5 +0,0 @@
<script>
import { page } from '$app/stores';
</script>
<h1>{$page.status}</h1>

View File

@@ -1,6 +0,0 @@
<nav>
<a href="/">home</a>
<a href="/about">about</a>
</nav>
<slot></slot>

View File

@@ -1 +0,0 @@
<h1>This page was not prerendered</h1>

View File

@@ -1 +0,0 @@
export const prerender = true;

View File

@@ -1 +0,0 @@
<h1>This page was prerendered</h1>

View File

@@ -1 +0,0 @@
<h1>the fallback page was rendered</h1>

View File

@@ -1,12 +0,0 @@
import adapter from '../../../index.js';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({
fallback: '200.html'
})
}
};
export default config;

View File

@@ -1,11 +0,0 @@
import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
plugins: [sveltekit()]
};
export default config;

View File

@@ -1,50 +0,0 @@
import fs from 'fs';
import * as assert from 'uvu/assert';
import { run } from './utils.js';
run('prerendered', (test) => {
test('generates HTML files', ({ cwd }) => {
assert.ok(fs.existsSync(`${cwd}/build/index.html`));
});
test('prerenders a page', async ({ base, page }) => {
await page.goto(base);
assert.equal(await page.textContent('h1'), 'This page was prerendered');
assert.equal(await page.textContent('p'), 'answer: 42');
});
test('prerenders an unreferenced endpoint with explicit `prerender` setting', async ({ cwd }) => {
assert.ok(fs.existsSync(`${cwd}/build/endpoint/explicit.json`));
});
test('prerenders a referenced endpoint with implicit `prerender` setting', async ({ cwd }) => {
assert.ok(fs.existsSync(`${cwd}/build/endpoint/implicit.json`));
});
});
run('spa', (test) => {
test('generates a fallback page', async ({ base, cwd, page }) => {
assert.ok(fs.existsSync(`${cwd}/build/200.html`));
await page.goto(`${base}/fallback/a/b/c`);
assert.equal(await page.textContent('h1'), 'the fallback page was rendered');
});
test('does not prerender pages without prerender=true', ({ cwd }) => {
assert.ok(!fs.existsSync(`${cwd}/build/index.html`));
});
test('prerenders page with prerender=true', ({ cwd }) => {
assert.ok(fs.existsSync(`${cwd}/build/about.html`));
});
test('renders content in fallback page when JS runs', async ({ base, page }) => {
await page.goto(base);
assert.equal(await page.textContent('h1'), 'This page was not prerendered');
});
test('renders error page for missing page', async ({ base, page }) => {
await page.goto(`${base}/nosuchpage`);
assert.equal(await page.textContent('h1'), '404');
});
});

View File

@@ -1,122 +0,0 @@
import { execSync } from 'child_process';
import fs from 'fs';
import http from 'http';
import { fileURLToPath } from 'url';
import sirv from 'sirv';
import { chromium, webkit, firefox } from 'playwright';
import * as uvu from 'uvu';
const known_browsers = {
chromium: chromium,
firefox: firefox,
webkit: webkit
};
const test_browser_name = /** @type {keyof typeof } */ (process.env.KIT_E2E_BROWSER ?? 'chromium');
const test_browser = known_browsers[test_browser_name];
if (!test_browser) {
throw new Error(
`invalid test browser specified: KIT_E2E_BROWSER=${
process.env.KIT_E2E_BROWSER
}. Allowed values: ${Object.keys().join(', ')}`
);
}
/**
* @typedef {{
* cwd: string;
* server: import('http').Server;
* base: string;
* browser: import('playwright-chromium').Browser;
* page: import('playwright-chromium').Page;
* }} TestContext
*/
/**
* @param {string} app
* @param {(test: import('uvu').Test<TestContext>) => void} callback
*/
export function run(app, callback) {
/** @type {import('uvu').Test<TestContext>} */
const suite = uvu.suite(app);
suite.before(async (context) => {
try {
const cwd = fileURLToPath(new URL(`apps/${app}`, import.meta.url));
rimraf(`${cwd}/build`);
try {
execSync(`npm run build`, { cwd, stdio: 'pipe' });
console.log(`✅ build successful`);
} catch (e) {
console.error(`❌ failed to build ${app}`);
console.error(`---\nstdout:\n${e.stdout}`);
console.error(`---\nstderr:\n${e.stderr}`);
console.groupEnd();
}
context.cwd = cwd;
const handler = sirv(`${cwd}/build`, {
single: '200.html'
});
context.server = await create_server(context.port, handler);
const { port } = /** @type {import('net').AddressInfo} */ (context.server.address());
if (!port) {
throw new Error(
`Could not find port from server ${JSON.stringify(context.server.address())}`
);
}
context.port = port;
context.base = `http://localhost:${context.port}`;
context.browser = await test_browser.launch();
context.page = await context.browser.newPage();
} catch (e) {
// TODO remove unnecessary try-catch https://github.com/lukeed/uvu/pull/61
console.error(e);
}
});
suite.after(async (context) => {
if (context.browser) {
try {
await context.browser.close();
} catch (e) {
console.error('failed to close test browser', e);
}
}
if (context.server) {
try {
await context.server.close();
} catch (e) {
console.error('failed to close test server', e);
}
}
});
callback(suite);
suite.run();
}
/**
* @param {number} port
* @param {(req: http.IncomingMessage, res: http.ServerResponse) => void} handler
* @returns {Promise<http.Server>}
*/
function create_server(port, handler) {
return new Promise((fulfil) => {
const server = http.createServer(handler);
server.listen(port, () => {
fulfil(server);
});
});
}
/** @param {string} path */
function rimraf(path) {
(fs.rmSync || fs.rmdirSync)(path, { recursive: true, force: true });
}

View File

@@ -8,10 +8,7 @@
"target": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../kit/types/index"]
}
"baseUrl": "."
},
"include": ["index.js"]
"include": ["app/adapter/index.js", "index.js"]
}