Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,73 @@
name: Deploy to GitHub Pages
name: Deploy Location Plugin to GitHub Pages

on:
push:
branches: [ main ]
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 8

- name: Setup Node
uses: actions/setup-node@v4
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v4
with:
node-version: '20'
cache: 'pnpm'
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Build plugin
run: pnpm build

- name: Setup Pages
uses: actions/configure-pages@v5


- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'

path: ./dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "VITE_DEV=true vite",
"build": "run-p type-check \"build-only {@}\" --",
"build": "vite build && mv dist/landing.html dist/index.html && touch dist/.nojekyll",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
Expand All @@ -15,7 +15,7 @@
},
"dependencies": {
"@heroicons/vue": "^2.2.0",
"@toplocs/plugin-sdk": "github:toplocs/plugin-sdk",
"@toplocs/plugin-sdk": "^1.1.0",
"gun": "^0.2020.1240",
"vite-plugin-top-level-await": "^1.4.4",
"vue": "^3.5.12",
Expand Down
11 changes: 5 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/InfoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const baseUrl = window.location.origin + window.location.pathname.replace(/\/[^/
const isDevelopment = window.location.hostname === 'localhost'

const endpoints = {
plugin: `${baseUrl}/assets/plugin.js`,
plugin: `${baseUrl}/plugin.js`,
landing: baseUrl,
demo: 'https://toplocs.github.io/tribelike/'
}
Expand Down
8 changes: 7 additions & 1 deletion src/gun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import Gun from 'gun' // You can also use 'gun' here
import 'gun/sea' // Optional: for user authentication
import 'gun/lib/unset'; //optional

const gun = Gun(['http://localhost:3000/gun']) as any;
// Use Gun.js peers from environment or default to common peers
const peers = import.meta.env.VITE_GUN_PEERS?.split(',') || [
'https://gun-manhattan.herokuapp.com/gun',
'https://relay.peers.community/gun',
'https://gun-sjc.herokuapp.com/gun'
];
const gun = Gun(peers) as any;

gun.clear = function() {
// Clear localStorage
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import './assets/main.css';
import { createApp } from 'vue';
import App from './App.vue';
import gun from './gun';

const baseUrl = window.location.origin + window.location.pathname.replace(/\/[^/]*$/, '')

/*
const chain = gun.get('location_plugin');
chain.once(data => {
if (!data) {
const node = chain.put({
id: 'location_plugin',
name: 'Location',
url: 'http://localhost:3007/assets/plugin.js',
url: `${baseUrl}/plugin.js`,
});

const paths = gun.get('location_plugin/paths');
Expand Down
37 changes: 28 additions & 9 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,50 @@ import path from 'path';
import vue from '@vitejs/plugin-vue';
import federation from "@originjs/vite-plugin-federation";
import topLevelAwait from 'vite-plugin-top-level-await';
import tailwindcss from 'tailwindcss';
import autoprefixer from 'autoprefixer';

// Plugin configuration - supports both dev and preview modes
export default defineConfig({
base: './',
plugins: [
vue(),
federation({
name: 'location-plugin',
filename: 'plugin.js',
exposes: {
'./Main': './src/views/MainWrapper.vue',
'./Settings': './src/views/SettingsWrapper.vue',
},
shared: ['vue', 'tailwindcss']
name: 'location-plugin',
filename: 'plugin.js',
exposes: {
'./PluginConfig': './src/index.ts',
'./Main': './src/views/MainWrapper.vue',
'./Settings': './src/views/SettingsWrapper.vue',
},
shared: ['vue'],
remotes: {
remoteName: '',
},
}),
topLevelAwait({
promiseExportName: '__tla',
promiseImportName: i => `__tla_${i}`
})
],

css: {
postcss: {
plugins: [
tailwindcss,
autoprefixer,
],
},
},

resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
//port: 3000,

optimizeDeps: {
exclude: ["__federation__"],
},
build: {
outDir: './dist',
Expand Down