generated from avior/template-web-astro
change some defaults
This commit is contained in:
parent
de3a4fb281
commit
ac0977b84b
@ -1,17 +0,0 @@
|
||||
# build output
|
||||
dist/
|
||||
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
13
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
13
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
fix: # <!-- Indiquez le numéro de tâche lié à cette PR --->
|
||||
|
||||
## Checklist pré-merge
|
||||
|
||||
- [ ] je suis sur la bonne branche
|
||||
- [ ] J'ai bien nommé ma PR
|
||||
- [ ] Les différents Tests sont au vert
|
||||
- [ ] Le styling de mon code est correct
|
||||
- [ ] J'ai assigné 1-2 reviewers pour mon travail
|
||||
|
||||
## Résumé du changement fais
|
||||
|
||||
<!-- Fournir des images si les changements sont graphiques ! --->
|
7
.github/renovate.json
vendored
Normal file
7
.github/renovate.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
],
|
||||
"dependencyDashboardApproval": true
|
||||
}
|
35
.github/workflows/build_and_check.yml
vendored
35
.github/workflows/build_and_check.yml
vendored
@ -1,35 +0,0 @@
|
||||
name: Build, check & Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Check
|
||||
run: npm run check
|
||||
|
||||
- name: Prepare Tests
|
||||
run: npm run install:test
|
||||
|
||||
- name: Test
|
||||
run : npm run test
|
71
.github/workflows/build_docker.yml
vendored
71
.github/workflows/build_docker.yml
vendored
@ -1,71 +0,0 @@
|
||||
name: Build Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build_docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_NAME }}
|
||||
# ghcr.io/${{ env.IMAGE_NAME }}
|
||||
# git.example.com/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=edge
|
||||
type=ref,event=pr
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=semver,pattern=latest
|
||||
|
||||
# - name: Login to a private registry
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# registry: git.example.com
|
||||
# username: ${{ secrets.REGISTRY_USER }}
|
||||
# password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
# - name: Login to the Docker Hub
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# username: ${{ secrets.DOCKER_USER }}
|
||||
# password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
# - name: Login to the Github Packages
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# registry: ghcr.io
|
||||
# username: ${{ github.actor }}
|
||||
# password: ${{ secrets.GITHUB_PACKAGES_TOKEN }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push the project
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: ./Dockerfile
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
44
.github/workflows/delete_packages.yml
vendored
44
.github/workflows/delete_packages.yml
vendored
@ -1,44 +0,0 @@
|
||||
name: Delete Packages
|
||||
|
||||
on:
|
||||
# Run when a PR is closed/merged
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
# Run when a branch is deleted
|
||||
delete:
|
||||
|
||||
# Config
|
||||
env:
|
||||
TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||
GROUP: avior
|
||||
TYPE: container
|
||||
PACKAGE: ifremer-loop
|
||||
|
||||
|
||||
jobs:
|
||||
pull_request:
|
||||
name: Delete the package on a closed Pull Request
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.action == 'close' }}
|
||||
steps:
|
||||
- name: Delete package
|
||||
run: |
|
||||
curl --fail -X 'DELETE' "https://git.dzeio.com/api/v1/packages/${GROUP}/${TYPE}/${PACKAGE}/${VERSION}" -H 'accept: application/json' -H "Authorization: token ${TOKEN}"
|
||||
env:
|
||||
VERSION: pr-${{ github.event.number }}-head
|
||||
branch:
|
||||
runs-on: ubuntu-latest
|
||||
name: Delete the package on a deleted branch
|
||||
if: ${{ github.event_name == 'delete' }}
|
||||
steps:
|
||||
- name: Delete package
|
||||
run: |
|
||||
curl --fail -X 'DELETE' "https://git.dzeio.com/api/v1/packages/${GROUP}/${TYPE}/${PACKAGE}/${VERSION}" -H 'accept: application/json' -H "Authorization: token ${TOKEN}"
|
||||
env:
|
||||
TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||
GROUP: avior
|
||||
TYPE: container
|
||||
PACKAGE: ifremer-loop
|
||||
VERSION: branch-${{ github.event.ref }}
|
||||
|
89
.github/workflows/tests.yml
vendored
Normal file
89
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
env:
|
||||
REPO_NAME: template-desktop
|
||||
|
||||
jobs:
|
||||
static-code-checks:
|
||||
name: Static code checks
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup BunJS
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: run Astro and TypeScript checks
|
||||
run: bun run check
|
||||
run:
|
||||
name: Unit tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup BunJS
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
# - name: Prepare Tests
|
||||
# run: npm run install:test
|
||||
|
||||
- name: Test
|
||||
# run : npm run test
|
||||
run: bun run test:unit
|
||||
secrets-scanner:
|
||||
name: Secrets Scanning
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Secret Scanning
|
||||
uses: onboardbase/securelog-scan@main
|
||||
with:
|
||||
exclude: "node_modules,dist" # Comma-separated list of folders to exclude (optional)
|
||||
commits: 100 # Number of recent commits to scan (optional)
|
||||
changed: "true" # Set to "false" to scan entire repository instead of just files that was changed (optional)
|
||||
mask: "true" # that is mask secret value e.g sk_******
|
||||
verify: "true" # that is verify potential secrets against their service provider
|
||||
|
||||
sonarqube:
|
||||
name: SonarQube
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Disabling shallow clone is recommended for improving relevancy of reporting
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup BunJS
|
||||
uses: oven-sh/setup-bun@v2
|
||||
|
||||
- name: Install project dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Run coverage
|
||||
run: bun run test:unit
|
||||
continue-on-error: true # continue on error as we still want reporting to be done
|
||||
|
||||
- name: Scan repository
|
||||
uses: Aviortheking/sonarqube-action@v5.1.0
|
||||
with:
|
||||
host: ${{ secrets.SONARQUBE_HOST }}
|
||||
login: ${{ secrets.SONARQUBE_TOKEN }}
|
||||
projectKey: ${{ env.REPO_NAME }}
|
||||
args: >
|
||||
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
|
53
Dockerfile
53
Dockerfile
@ -1,53 +0,0 @@
|
||||
# This Dockerfile allows you to run AstroJS in server mode
|
||||
|
||||
#########
|
||||
# Build #
|
||||
#########
|
||||
FROM docker.io/node:20-alpine as BUILD_IMAGE
|
||||
|
||||
# run as non root user
|
||||
USER node
|
||||
|
||||
# go to user repository
|
||||
WORKDIR /home/node
|
||||
|
||||
# Add package json
|
||||
ADD --chown=node:node package.json package-lock.json ./
|
||||
|
||||
# install dependencies from package lock
|
||||
RUN npm ci
|
||||
|
||||
# Add project files
|
||||
ADD --chown=node:node . .
|
||||
|
||||
# build
|
||||
RUN npm run build
|
||||
|
||||
# remove dev deps
|
||||
RUN npm prune --omit=dev
|
||||
|
||||
##############
|
||||
# Production #
|
||||
##############
|
||||
FROM docker.io/node:20-alpine as PROD_IMAGE
|
||||
|
||||
# inform software to be in production
|
||||
ENV NODE_ENV=production
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
# run as non root user
|
||||
USER node
|
||||
|
||||
# go to work folder
|
||||
WORKDIR /home/node
|
||||
|
||||
# copy from build image
|
||||
COPY --chown=node:node --from=BUILD_IMAGE /home/node/node_modules ./node_modules
|
||||
COPY --chown=node:node --from=BUILD_IMAGE /home/node/dist ./dist
|
||||
COPY --chown=node:node --from=BUILD_IMAGE /home/node/package.json /home/node/.env* ./
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# run it !
|
||||
CMD ["npm", "run", "start"]
|
@ -1,38 +0,0 @@
|
||||
# This Dockerfile allows you to run Astro in a static container (no server side)
|
||||
|
||||
#########
|
||||
# Build #
|
||||
#########
|
||||
FROM docker.io/node:20-alpine as BUILD_IMAGE
|
||||
|
||||
# run as non root user
|
||||
USER node
|
||||
|
||||
# go to user repository
|
||||
WORKDIR /home/node
|
||||
|
||||
# Add package json
|
||||
ADD --chown=node:node package.json package-lock.json ./
|
||||
|
||||
# install dependencies from package lock
|
||||
RUN npm ci
|
||||
|
||||
# Add project files
|
||||
ADD --chown=node:node . .
|
||||
|
||||
# build
|
||||
RUN npm run build
|
||||
|
||||
##############
|
||||
# Production #
|
||||
##############
|
||||
FROM docker.io/nginx:1-alpine
|
||||
|
||||
# go to NGINX folder
|
||||
WORKDIR /usr/share/nginx/html
|
||||
|
||||
# Copy the nginx config
|
||||
ADD ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy dist fro mthe build image
|
||||
COPY --from=BUILD_IMAGE /home/node/dist ./
|
@ -1,6 +1,6 @@
|
||||
import { defineConfig } from 'astro/config'
|
||||
import tailwind from "@astrojs/tailwind"
|
||||
import svelte from '@astrojs/svelte'
|
||||
import tailwind from "@astrojs/tailwind"
|
||||
import { defineConfig } from 'astro/config'
|
||||
import routing from './hooks/routing'
|
||||
|
||||
// const faviconHook = {
|
||||
@ -74,7 +74,5 @@ export default defineConfig({
|
||||
// produce sourcemaps for debug builds
|
||||
sourcemap: !isProd,
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
})
|
@ -14,7 +14,7 @@ import { objectLoop } from '@dzeio/object-util'
|
||||
*
|
||||
* @returns the URL formatted with the params
|
||||
*/
|
||||
export function formatRoute<T extends string>(url: T, params?: Record<string, string | number>): string {
|
||||
export function formatRoute<T extends string>(url: T, params?: Record<string, string | number | undefined>, skipEncoding = false): string {
|
||||
let result: string = url
|
||||
|
||||
// early return if there are no params
|
||||
@ -26,11 +26,16 @@ export function formatRoute<T extends string>(url: T, params?: Record<string, st
|
||||
let externalQueries = ''
|
||||
|
||||
// loop through the parameters
|
||||
objectLoop(params, (value, key) => {
|
||||
objectLoop(params, (value = '', key) => {
|
||||
const search = \`[\${key}]\`
|
||||
value = encodeURI(value.toString())
|
||||
if (!skipEncoding) {
|
||||
value = encodeURI(value.toString())
|
||||
key = encodeURI(key)
|
||||
} else {
|
||||
value = value.toString()
|
||||
}
|
||||
if (!result.includes(search)) {
|
||||
externalQueries += \`\${encodeURI(key)}=\${value}&\`
|
||||
externalQueries += \`\${key}=\${value}&\`
|
||||
} else {
|
||||
result = result.replace(search, value)
|
||||
}
|
||||
@ -51,10 +56,11 @@ export function formatRoute<T extends string>(url: T, params?: Record<string, st
|
||||
*/
|
||||
async function updateRoutes(output: string, routes: Array<string>) {
|
||||
let file = baseFile
|
||||
file += `\n\nexport type Routes = ${routes.map((it) => `'${it}'`).join(' | ')}`
|
||||
const routesStr = routes.map((it) => `'${it}'`).join(' | ')
|
||||
file += `\n\nexport type Routes = ${routesStr}`
|
||||
|
||||
file += '\n\nexport default function route(route: Routes, query?: Record<string, string | number>) {'
|
||||
file += '\n\treturn formatRoute(route, query)'
|
||||
file += '\n\nexport default function route(route: Routes, query?: Record<string, string | number | undefined>, skipEncoding = false) {'
|
||||
file += '\n\treturn formatRoute(route, query, skipEncoding)'
|
||||
file += '\n}\n'
|
||||
|
||||
await fs.writeFile(output, file)
|
||||
@ -100,7 +106,7 @@ async function getFiles(path: string): Promise<Array<string>> {
|
||||
const dir = await fs.readdir(path)
|
||||
let files: Array<string> = []
|
||||
for (const file of dir) {
|
||||
if (file.startsWith('_')) continue
|
||||
if (file.startsWith('_')) { continue }
|
||||
const filePath = path + '/' + file
|
||||
if ((await fs.stat(filePath)).isDirectory()) {
|
||||
files = files.concat(await getFiles(filePath))
|
||||
@ -154,11 +160,11 @@ const integration: () => AstroIntegration = () => ({
|
||||
|
||||
// ignore files starting with '_'
|
||||
const filename = path.slice(path.lastIndexOf('/') + 1)
|
||||
if (filename.startsWith('_')) return
|
||||
if (filename.startsWith('_')) { return }
|
||||
|
||||
let removeExtension = true
|
||||
let folder = pagesFolder
|
||||
if(path.startsWith(publicFolder)) {
|
||||
if (path.startsWith(publicFolder)) {
|
||||
removeExtension = false
|
||||
folder = publicFolder
|
||||
} else if (!path.startsWith(folder)) {
|
||||
@ -178,7 +184,7 @@ const integration: () => AstroIntegration = () => ({
|
||||
path = path.replace(/\\/g, '/')
|
||||
let removeExtension = true
|
||||
let folder = pagesFolder
|
||||
if(path.startsWith(publicFolder)) {
|
||||
if (path.startsWith(publicFolder)) {
|
||||
removeExtension = false
|
||||
folder = publicFolder
|
||||
}
|
||||
|
74
nginx.conf
74
nginx.conf
@ -1,74 +0,0 @@
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 3000;
|
||||
listen [::]:3000;
|
||||
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
error_page 404 /404.html;
|
||||
error_page 500 502 503 504 /500.html;
|
||||
|
||||
# Security headers (note: temporarely unvailable "prefetch-src 'self'; ")
|
||||
add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data: 'self'; font-src 'self'; connect-src 'self'; base-uri 'self';";
|
||||
add_header X-Frame-Options "DENY";
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
add_header Referrer-Policy "no-referrer";
|
||||
add_header Permissions-Policy "geolocation=(), microphone=(), interest-cohort=()";
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
|
||||
add_header X-Download-Options "noopen";
|
||||
|
||||
location / {
|
||||
try_files $uri $uri.html $uri/index.html /$uri /$uri/index.html /index.html;
|
||||
}
|
||||
|
||||
# Plausible script
|
||||
location /js/script.js {
|
||||
# Change this if you use a different variant of the script
|
||||
proxy_pass https://plausible.io/js/script.js;
|
||||
proxy_set_header Host plausible.io;
|
||||
|
||||
# Tiny, negligible performance improvement. Very optional.
|
||||
proxy_buffering on;
|
||||
}
|
||||
|
||||
# Plausible script
|
||||
location /api/event {
|
||||
proxy_pass https://plausible.io/api/event;
|
||||
proxy_set_header Host plausible.io;
|
||||
proxy_buffering on;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
|
||||
# Media: images, icons, video, audio, HTC
|
||||
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webp|webm|htc|woff2|woff)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# CSS and Javascript
|
||||
location ~* \.(?:css|js)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
}
|
8391
package-lock.json
generated
8391
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"dev": "tauri dev",
|
||||
"front:dev": "astro dev",
|
||||
"start": "node ./dist/server/entry.mjs",
|
||||
"start": "bun ./dist/server/entry.mjs",
|
||||
"front:build": "astro build",
|
||||
"build": "tauri build",
|
||||
"check": "npm run check:astro && npm run check:typescript",
|
||||
|
22
src-tauri/Cargo.lock
generated
22
src-tauri/Cargo.lock
generated
@ -540,17 +540,6 @@ dependencies = [
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "desktop"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-shell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@ -1172,6 +1161,17 @@ dependencies = [
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gwaleen-desktop"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-shell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "desktop"
|
||||
name = "gwaleen-desktop"
|
||||
version = "0.0.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
@ -7,20 +7,22 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
# The `_lib` suffix may seem redundant but it is necessary
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "gwaleen_desktop_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri = { version = "2", features = ["macos-private-api"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
tauri-plugin-shell = "2"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
# DO NOT REMOVE!!
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
[profile.release]
|
||||
panic = "abort" # Strip expensive panic clean-up logic
|
||||
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
|
||||
@ -29,7 +31,3 @@ opt-level = "s" # Optimize for binary size
|
||||
# can also use this one if it's smaller
|
||||
# opt-level = "z" # Optimize for binary size
|
||||
strip = true # Automatically strip symbols from the binary.
|
||||
|
||||
[lib]
|
||||
name = "app_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
12
src-tauri/capabilities/default.json
Normal file
12
src-tauri/capabilities/default.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"local": true,
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default"
|
||||
]
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"identifier": "migrated",
|
||||
"description": "permissions that were migrated from v1",
|
||||
"local": true,
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"shell:allow-open",
|
||||
"shell:default"
|
||||
]
|
||||
}
|
@ -1 +1 @@
|
||||
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","shell:allow-open","shell:default"]}}
|
||||
{"default":{"identifier":"default","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["core:default"]}}
|
@ -1,4 +1,14 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
// your code here
|
||||
tauri::Builder::default()
|
||||
// .plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
@ -1,82 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use std::fs;
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct File {
|
||||
filename: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct FileList {
|
||||
path: String,
|
||||
list: Vec<File>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn list_files(path: &str) -> Result<FileList, String> {
|
||||
let run = || -> Result<Vec<File>, ()> {
|
||||
let paths = fs::read_dir(path).unwrap();
|
||||
let mut final_string: String = String::new();
|
||||
let mut arr = Vec::new();
|
||||
for (idx, path) in paths.enumerate() {
|
||||
if idx > 0 {
|
||||
final_string.push(',');
|
||||
}
|
||||
arr.push(File {
|
||||
filename: path.unwrap().path().display().to_string(),
|
||||
});
|
||||
// final_string.push_str(path.unwrap().path().display().to_string().as_str())
|
||||
}
|
||||
Ok(arr)
|
||||
};
|
||||
let list = run();
|
||||
|
||||
if list.is_err() {
|
||||
Err("Error".to_owned())
|
||||
} else {
|
||||
Ok(FileList {
|
||||
path: fs::canonicalize(path)
|
||||
.unwrap()
|
||||
.display()
|
||||
.to_string()
|
||||
.to_owned(),
|
||||
list: list.unwrap(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_file(path: &str) -> Result<String, String> {
|
||||
let run = || -> Result<String, String> {
|
||||
let content = fs::read(path);
|
||||
if content.is_err() {
|
||||
return Err("Error".to_owned());
|
||||
}
|
||||
Ok(String::from_utf8(content.unwrap())
|
||||
.unwrap_or("error decoding file content :(".to_owned()))
|
||||
};
|
||||
let res = run();
|
||||
|
||||
if res.is_err() {
|
||||
Err("Error".to_owned())
|
||||
} else {
|
||||
Ok(res.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
app_lib::run();
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![greet, list_files, get_file])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
gwaleen_desktop_lib::run()
|
||||
}
|
||||
|
@ -1,10 +1,39 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "gwaleen-desktop",
|
||||
"version": "0.0.0",
|
||||
"identifier": "com.gwaleen.desktop",
|
||||
"build": {
|
||||
"beforeDevCommand": "bun run front:dev",
|
||||
"devUrl": "http://localhost:3000",
|
||||
"beforeBuildCommand": "bun run front:build",
|
||||
"frontendDist": "../dist",
|
||||
"devUrl": "http://localhost:3000"
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"enableGTKAppId": true,
|
||||
"macOSPrivateApi": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "gwaleen-desktop",
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"resizable": true,
|
||||
"fullscreen": false,
|
||||
"decorations": false,
|
||||
"transparent": true,
|
||||
"visible": true,
|
||||
"alwaysOnTop": true,
|
||||
"skipTaskbar": false,
|
||||
"center": true,
|
||||
"minimizable": true,
|
||||
"maximizable": true,
|
||||
"closable": true,
|
||||
"titleBarStyle": "Visible"
|
||||
}
|
||||
]
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
@ -16,23 +45,5 @@
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
},
|
||||
"productName": "gwaleen-desktop",
|
||||
"mainBinaryName": "gwaleen-desktop",
|
||||
"version": "0.0.0",
|
||||
"identifier": "com.gwaleen.desktop",
|
||||
"plugins": {},
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "gwaleen-desktop",
|
||||
"width": 800,
|
||||
"height": 600,
|
||||
"useHttpsScheme": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ export interface Props extends ButtonProps {}
|
||||
---
|
||||
|
||||
<Platform>
|
||||
<Linux slot="linux">Linux <slot /></Linux>
|
||||
<Windows slot="windows">Windows <slot /></Windows>
|
||||
<Linux slot="linux" {...Astro.props}><slot /></Linux>
|
||||
<Windows slot="windows" {...Astro.props}><slot /></Windows>
|
||||
</Platform>
|
||||
|
@ -24,20 +24,6 @@ const classes = [
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply px-4 py-2 rounded-md bg-gray-200 text-gray-900 shadow-sm border border-gray-300 hover:bg-gray-300 active:bg-gray-400 transition duration-150;
|
||||
font-weight: 500;
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
.button.outline {
|
||||
@apply px-4 py-2 rounded-md border border-gray-500 text-gray-800 bg-transparent hover:bg-gray-100 active:bg-gray-200 transition duration-150;
|
||||
font-weight: 500;
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
.button.ghost {
|
||||
@apply px-4 py-2 rounded-md text-gray-700 hover:bg-gray-100 active:bg-gray-200 transition duration-150;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
font-weight: 500;
|
||||
font-family: system-ui, sans-serif;
|
||||
@apply bg-gray-100 text-gray-900 font-medium border border-gray-300 rounded-md px-4 py-2 shadow-sm hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none;
|
||||
}
|
||||
</style>
|
||||
|
@ -23,15 +23,11 @@ const classes = [
|
||||
)}
|
||||
|
||||
<style>
|
||||
.button {
|
||||
@apply px-4 py-2 rounded-xl bg-white/60 text-gray-900 shadow-md backdrop-blur border border-gray-300 hover:bg-white/80 hover:shadow-lg active:bg-white/90 transition duration-150;
|
||||
font-weight: 500;
|
||||
font-family: system-ui, sans-serif;
|
||||
.button:not(.outline) {
|
||||
@apply px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-700 active:bg-blue-800 text-white shadow-md transition-all duration-150 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-2;
|
||||
}
|
||||
.button.outline {
|
||||
@apply px-4 py-2 rounded-xl border border-blue-500 text-blue-600 bg-transparent hover:bg-blue-50 active:bg-blue-100 transition duration-150;
|
||||
font-weight: 500;
|
||||
font-family: system-ui, sans-serif;
|
||||
@apply px-4 py-2 rounded-xl border border-blue-600 text-blue-600 hover:bg-blue-50 active:bg-blue-100 shadow-sm transition-all duration-150 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-2;
|
||||
}
|
||||
.button.ghost {
|
||||
@apply px-4 py-2 rounded-xl text-gray-700 hover:bg-gray-100 active:bg-gray-200 transition duration-150;
|
||||
|
@ -1,29 +1,11 @@
|
||||
---
|
||||
import Footer from 'components/layouts/Footer.astro'
|
||||
import Base, { type Props as BaseProps } from './Base.astro'
|
||||
import Header from 'components/layouts/Header.astro'
|
||||
import { Mail, Phone } from 'lucide-astro'
|
||||
import { Github } from 'simple-icons-astro'
|
||||
|
||||
export interface Props extends BaseProps {
|
||||
/**
|
||||
* remove the default top padding top allow the content to overflow with the header
|
||||
*/
|
||||
hasHero?: boolean
|
||||
}
|
||||
---
|
||||
|
||||
<Base {...Astro.props}>
|
||||
<slot slot="head" name="head" />
|
||||
<Header />
|
||||
<div class:list={{'pt-24': !Astro.props.hasHero}}>
|
||||
<slot />
|
||||
</div>
|
||||
<Footer links={[
|
||||
{href: 'https://www.avior.me', display: 'About'}
|
||||
]} socials={[
|
||||
{href: 'mailto:contact@example.com', target: '', icon: Mail},
|
||||
{href: 'tel:+33601020304', target: '', icon: Phone},
|
||||
{href: 'https://github.com/dzeiocom', icon: Github},
|
||||
]} />
|
||||
<slot />
|
||||
</Base>
|
||||
|
@ -1,10 +1,7 @@
|
||||
export function getPlatformStyle() {
|
||||
|
||||
}
|
||||
type Platform = 'linux' | 'windows'
|
||||
|
||||
export function getCurrentPlatform(): Platform {
|
||||
return 'windows'
|
||||
// return 'windows'
|
||||
const current = import.meta.env.TAURI_ENV_PLATFORM
|
||||
console.log(import.meta.env)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user