fix
This commit is contained in:
parent
3ef8db58b9
commit
be6a9e36af
|
|
@ -1,5 +1,6 @@
|
||||||
import { Database } from "bun:sqlite";
|
import { Database } from "bun:sqlite";
|
||||||
import admin from "firebase-admin";
|
import admin from "firebase-admin";
|
||||||
|
import { listAsync } from "fs-jetpack";
|
||||||
import { apiContext } from "service-srv";
|
import { apiContext } from "service-srv";
|
||||||
|
|
||||||
import { dir } from "utils/dir";
|
import { dir } from "utils/dir";
|
||||||
|
|
@ -14,12 +15,17 @@ export const _ = {
|
||||||
| { type: "send"; id: string; body: string; title: string; data?: any }
|
| { type: "send"; id: string; body: string; title: string; data?: any }
|
||||||
) {
|
) {
|
||||||
const { req } = apiContext(this);
|
const { req } = apiContext(this);
|
||||||
|
|
||||||
|
if (action === "list") {
|
||||||
|
return await listAsync(dir("public"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!g.firebaseInit) {
|
if (!g.firebaseInit) {
|
||||||
g.firebaseInit = true;
|
g.firebaseInit = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
g.firebase = admin.initializeApp({
|
g.firebase = admin.initializeApp({
|
||||||
credential: admin.credential.cert(dir("firebase-admin.json")),
|
credential: admin.credential.cert(dir("public/firebase-admin.json")),
|
||||||
});
|
});
|
||||||
g.notif = {
|
g.notif = {
|
||||||
db: new Database(dir(`${g.datadir}/notif.sqlite`)),
|
db: new Database(dir(`${g.datadir}/notif.sqlite`)),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
dirAsync,
|
dirAsync,
|
||||||
|
exists,
|
||||||
existsAsync,
|
existsAsync,
|
||||||
read,
|
read,
|
||||||
removeAsync,
|
removeAsync,
|
||||||
|
|
@ -37,6 +38,15 @@ export const deploy = {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (g.deploy.gz) {
|
if (g.deploy.gz) {
|
||||||
|
if (exists(dir("public"))) {
|
||||||
|
await removeAsync(dir("public"));
|
||||||
|
if (g.deploy.gz.public) {
|
||||||
|
await dirAsync(dir("public"));
|
||||||
|
for (const [k, v] of Object.entries(g.deploy.gz.public)) {
|
||||||
|
await writeAsync(dir(`public/${k}`), v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const page of g.deploy.gz.layouts) {
|
for (const page of g.deploy.gz.layouts) {
|
||||||
if (page.is_default_layout) {
|
if (page.is_default_layout) {
|
||||||
g.deploy.layout = page.content_tree;
|
g.deploy.layout = page.content_tree;
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,9 @@ export const g = global as unknown as {
|
||||||
gz: null | {
|
gz: null | {
|
||||||
layouts: SinglePage[];
|
layouts: SinglePage[];
|
||||||
pages: SinglePage[];
|
pages: SinglePage[];
|
||||||
site: {};
|
site: any;
|
||||||
comps: { id: string; content_tree: true }[];
|
comps: { id: string; content_tree: true }[];
|
||||||
|
public: Record<string, any>;
|
||||||
code: {
|
code: {
|
||||||
server: Record<string, string>;
|
server: Record<string, string>;
|
||||||
site: Record<string, string>;
|
site: Record<string, string>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue