Merge branch 'master' into feat/update-automation-tests
This commit is contained in:
commit
5ccef12d97
|
@ -5,4 +5,5 @@ package-lock.json
|
|||
release/
|
||||
dist/
|
||||
routify
|
||||
.routify/
|
||||
.routify/
|
||||
.rollup.cache
|
|
@ -4,14 +4,14 @@
|
|||
"license": "GPL-3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"svelte-check": "svelte-check --no-tsconfig",
|
||||
"build": "yarn svelte-check && routify -b && vite build --emptyOutDir",
|
||||
"build": "routify -b && NODE_OPTIONS=\"--max_old_space_size=4096\" vite build --emptyOutDir",
|
||||
"start": "routify -c rollup",
|
||||
"dev": "routify -c dev:vite",
|
||||
"dev:vite": "vite --host 0.0.0.0",
|
||||
"rollup": "rollup -c -w",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest"
|
||||
"test:watch": "vitest",
|
||||
"check:types": "yarn svelte-check"
|
||||
},
|
||||
"jest": {
|
||||
"globals": {
|
||||
|
@ -89,6 +89,7 @@
|
|||
"@babel/plugin-transform-runtime": "^7.13.10",
|
||||
"@babel/preset-env": "^7.13.12",
|
||||
"@rollup/plugin-replace": "^5.0.3",
|
||||
"@rollup/plugin-typescript": "8.3.0",
|
||||
"@roxi/routify": "2.18.12",
|
||||
"@sveltejs/vite-plugin-svelte": "1.4.0",
|
||||
"@testing-library/jest-dom": "6.4.2",
|
||||
|
|
|
@ -8,7 +8,7 @@ import { get } from "svelte/store"
|
|||
import { auth, navigation } from "./stores/portal"
|
||||
|
||||
export const API = createAPIClient({
|
||||
attachHeaders: headers => {
|
||||
attachHeaders: (headers: Record<string, string>) => {
|
||||
// Attach app ID header from store
|
||||
let appId = get(appStore).appId
|
||||
if (appId) {
|
||||
|
@ -16,13 +16,13 @@ export const API = createAPIClient({
|
|||
}
|
||||
|
||||
// Add csrf token if authenticated
|
||||
const user = get(auth).user
|
||||
const user: any = get(auth).user
|
||||
if (user?.csrfToken) {
|
||||
headers["x-csrf-token"] = user.csrfToken
|
||||
}
|
||||
},
|
||||
|
||||
onError: error => {
|
||||
onError: (error: any) => {
|
||||
const { url, message, status, method, handled } = error || {}
|
||||
|
||||
// Log any errors that we haven't manually handled
|
||||
|
@ -45,14 +45,14 @@ export const API = createAPIClient({
|
|||
}
|
||||
}
|
||||
},
|
||||
onMigrationDetected: appId => {
|
||||
onMigrationDetected: (appId: string) => {
|
||||
const updatingUrl = `/builder/app/updating/${appId}`
|
||||
|
||||
if (window.location.pathname === updatingUrl) {
|
||||
return
|
||||
}
|
||||
|
||||
get(navigation).goto(
|
||||
get(navigation)?.goto(
|
||||
`${updatingUrl}?returnUrl=${encodeURIComponent(window.location.pathname)}`
|
||||
)
|
||||
},
|
|
@ -0,0 +1,8 @@
|
|||
declare module "api" {
|
||||
const API: {
|
||||
getPlugins: () => Promise<any>
|
||||
createPlugin: (plugin: object) => Promise<any>
|
||||
uploadPlugin: (plugin: FormData) => Promise<any>
|
||||
deletePlugin: (id: string) => Promise<void>
|
||||
}
|
||||
}
|
|
@ -1,13 +1,20 @@
|
|||
import { writable } from "svelte/store"
|
||||
|
||||
type GotoFuncType = (path: string) => void
|
||||
|
||||
interface Store {
|
||||
initialisated: boolean
|
||||
goto: GotoFuncType
|
||||
}
|
||||
|
||||
export function createNavigationStore() {
|
||||
const store = writable({
|
||||
const store = writable<Store>({
|
||||
initialisated: false,
|
||||
goto: undefined,
|
||||
goto: undefined as any,
|
||||
})
|
||||
const { set, subscribe } = store
|
||||
|
||||
const init = gotoFunc => {
|
||||
const init = (gotoFunc: GotoFuncType) => {
|
||||
if (typeof gotoFunc !== "function") {
|
||||
throw new Error(
|
||||
`gotoFunc must be a function, found a "${typeof gotoFunc}" instead`
|
|
@ -1,16 +1,21 @@
|
|||
import { writable } from "svelte/store"
|
||||
import { PluginSource } from "constants/index"
|
||||
|
||||
import { API } from "api"
|
||||
import { PluginSource } from "constants"
|
||||
|
||||
interface Plugin {
|
||||
_id: string
|
||||
}
|
||||
|
||||
export function createPluginsStore() {
|
||||
const { subscribe, set, update } = writable([])
|
||||
const { subscribe, set, update } = writable<Plugin[]>([])
|
||||
|
||||
async function load() {
|
||||
const plugins = await API.getPlugins()
|
||||
set(plugins)
|
||||
}
|
||||
|
||||
async function deletePlugin(pluginId) {
|
||||
async function deletePlugin(pluginId: string) {
|
||||
await API.deletePlugin(pluginId)
|
||||
update(state => {
|
||||
state = state.filter(existing => existing._id !== pluginId)
|
||||
|
@ -18,8 +23,8 @@ export function createPluginsStore() {
|
|||
})
|
||||
}
|
||||
|
||||
async function createPlugin(source, url, auth = null) {
|
||||
let pluginData = {
|
||||
async function createPlugin(source: string, url: string, auth = null) {
|
||||
let pluginData: any = {
|
||||
source,
|
||||
url,
|
||||
}
|
||||
|
@ -46,7 +51,7 @@ export function createPluginsStore() {
|
|||
})
|
||||
}
|
||||
|
||||
async function uploadPlugin(file) {
|
||||
async function uploadPlugin(file: File) {
|
||||
if (!file) {
|
||||
return
|
||||
}
|
|
@ -9,15 +9,9 @@
|
|||
"noImplicitAny": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true
|
||||
"incremental": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/*.json",
|
||||
"**/*.spec.ts",
|
||||
"**/*.spec.js"
|
||||
]
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["node_modules", "**/*.json", "**/*.spec.ts", "**/*.spec.js"]
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import replace from "@rollup/plugin-replace"
|
|||
import { defineConfig, loadEnv } from "vite"
|
||||
import { viteStaticCopy } from "vite-plugin-static-copy"
|
||||
import path from "path"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
|
||||
const ignoredWarnings = [
|
||||
"unused-export-let",
|
||||
|
@ -35,7 +36,7 @@ export default defineConfig(({ mode }) => {
|
|||
// Copy fonts to an additional path so that svelte's automatic
|
||||
// prefixing of the base URL path can still resolve assets
|
||||
copyFonts("builder/fonts"),
|
||||
]
|
||||
]
|
||||
|
||||
return {
|
||||
test: {
|
||||
|
@ -61,6 +62,7 @@ export default defineConfig(({ mode }) => {
|
|||
sourcemap: !isProduction,
|
||||
},
|
||||
plugins: [
|
||||
typescript({ outDir: "../server/builder/dist" }),
|
||||
svelte({
|
||||
hot: !isProduction,
|
||||
emitCss: true,
|
||||
|
|
Loading…
Reference in New Issue