mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-22 21:45:56 +03:00
Update packages, rebase server, rebase utilities, formatting updates electron
This commit is contained in:
parent
22d43a23b9
commit
51f96023ad
@ -1,23 +1,23 @@
|
||||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const path = require("path");
|
||||
const fs = require("fs-extra");
|
||||
|
||||
function bootServer() {
|
||||
// TODO(colin): Spin up server on a child process
|
||||
// const { fork } = require('child_process');
|
||||
// const ps = fork(path.join(__dirname, '../', 'index.js'));
|
||||
require(path.join(__dirname, '../', 'index.js'));
|
||||
console.log('server running');
|
||||
require(path.join(__dirname, "../", "index.js"));
|
||||
console.log("server running");
|
||||
}
|
||||
|
||||
function fileOverrides() {
|
||||
fs.copy(
|
||||
path.join(__dirname, './google-protobuf.js'),
|
||||
path.join(__dirname, '../node_modules/google-protbuf/google-protobuf.js'),
|
||||
path.join(__dirname, "./google-protobuf.js"),
|
||||
path.join(__dirname, "../node_modules/google-protbuf/google-protobuf.js"),
|
||||
(err) => {
|
||||
if (err) throw err;
|
||||
console.log('google-protobuf.js was copied to node_modules folder');
|
||||
console.log("google-protobuf.js was copied to node_modules folder");
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -29,7 +29,7 @@ function createWindow() {
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
nodeIntegration: true,
|
||||
experimentalFeatures: true,
|
||||
},
|
||||
@ -37,8 +37,8 @@ function createWindow() {
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL('http://localhost:1337');
|
||||
console.log('window created');
|
||||
mainWindow.loadURL("http://localhost:1337");
|
||||
console.log("window created");
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
@ -49,7 +49,7 @@ app.whenReady().then(() => {
|
||||
bootServer();
|
||||
createWindow();
|
||||
|
||||
app.on('activate', function () {
|
||||
app.on("activate", function () {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
@ -59,8 +59,8 @@ app.whenReady().then(() => {
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
app.on("window-all-closed", function () {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
|
@ -141,7 +141,8 @@ export const refreshLibrary = async ({ state, PG, FFS }) => {
|
||||
|
||||
PG.ffs.watchJobs((job) => {
|
||||
console.log("[ prototype ] job status", job.status);
|
||||
if (job.status === FFS.JobStatus.JOB_STATUS_SUCCESS) {
|
||||
// NOTE(jim): FFS is undefined?
|
||||
if (job.status >= 5) {
|
||||
console.log(
|
||||
"[ prototype ] update file",
|
||||
state.library[i].children[j]
|
||||
|
@ -10,6 +10,7 @@
|
||||
"dev": "node . --unhandled-rejections=strict",
|
||||
"build": "next build",
|
||||
"start": "NODE_ENV=production node . --unhandled-rejections=strict",
|
||||
"build-system": "rollup -c",
|
||||
"electron": "electron ./electron/main.js ",
|
||||
"electronPack": "electron-builder --dir",
|
||||
"electronDist": "electron-builder"
|
||||
@ -59,6 +60,7 @@
|
||||
"ws": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@babel/plugin-transform-runtime": "^7.10.4",
|
||||
"@babel/preset-env": "^7.10.4",
|
||||
"@rollup/plugin-node-resolve": "^8.1.0",
|
||||
|
12
server.js
12
server.js
@ -16,6 +16,7 @@ import next from "next";
|
||||
import bodyParser from "body-parser";
|
||||
import compression from "compression";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import path from "path";
|
||||
|
||||
// TODO(jim): Support multiple desktop applications.
|
||||
let client = null;
|
||||
@ -24,11 +25,10 @@ let state = null;
|
||||
const production = process.env.NODE_ENV === "production";
|
||||
const port = process.env.PORT || 1337;
|
||||
const wsPort = process.env.WS_PORT || 2448;
|
||||
const resetData = process.env.npm_config_reset_data;
|
||||
const app = next({ dev: !production, dir: __dirname, quiet: false });
|
||||
const nextRequestHandler = app.getRequestHandler();
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const setIntervalViewerUpdatesUnsafe = async () => {
|
||||
if (client) {
|
||||
try {
|
||||
@ -71,10 +71,10 @@ app.prepare().then(async () => {
|
||||
};
|
||||
|
||||
try {
|
||||
// TODO(jim): Remove later.
|
||||
// We wipe all of the local data each time you run the application.
|
||||
await Utilities.resetFileSystem();
|
||||
|
||||
// NOTE(daniel): Wipe all of the local data when --reset-data flag is added to npm run dev.
|
||||
if (resetData) {
|
||||
await Utilities.resetFileSystem();
|
||||
}
|
||||
const updates = await Utilities.refresh({ PG: PowerGate });
|
||||
state = await Utilities.updateStateData(state, updates);
|
||||
console.log("[ prototype ] updated without token");
|
||||
|
Loading…
Reference in New Issue
Block a user