Browse Source

make work

master
peter 2 years ago
parent
commit
fb86ed1978

+ 0
- 5
package-lock.json View File

@@ -3964,11 +3964,6 @@
3964 3964
           "requires": {
3965 3965
             "ms": "^2.1.1"
3966 3966
           }
3967
-        },
3968
-        "ms": {
3969
-          "version": "2.1.2",
3970
-          "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
3971
-          "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
3972 3967
         }
3973 3968
       }
3974 3969
     },

+ 1
- 0
package.json View File

@@ -39,6 +39,7 @@
39 39
     "rimraf": "^3.0.0",
40 40
     "simple-git": "^1.124.0",
41 41
     "spawn-sync": "^2.0.0",
42
+    "sqlite3": "^4.1.0",
42 43
     "trash": "^6.0.0",
43 44
     "uuid": "^3.3.2"
44 45
   },

+ 1
- 5
src/backend/FrontblockAdmin.ts View File

@@ -3,8 +3,7 @@
3 3
 import * as Logger from 'log4js'
4 4
 import * as Knex from 'knex'
5 5
 import { FrontblockApiClient, FrontblockApiConf } from 'frontblock';
6
-import { socketioRPC, rpcHooker, ExtendedRpcInfo } from 'frontblock-generic/RPC';
7
-import { ApiClientBase, AdminBase } from 'frontblock-generic/Admin';
6
+import { AdminBase } from 'frontblock-generic/Admin';
8 7
 import express = require('express');
9 8
 import http = require('http');
10 9
 import bsock = require('bsock');
@@ -173,9 +172,6 @@ export class FrontblockAdmin extends AdminBase<AdminConf>{
173 172
     }
174 173
 }
175 174
 
176
-new FrontblockAdmin()
177
-
178
-
179 175
 process.on( 'SIGINT', function() {
180 176
     logger.info( "Gracefully shutting down from SIGINT (Ctrl-C)" );
181 177
     // some other closing procedures go here

+ 25
- 0
src/backend/Main.ts View File

@@ -0,0 +1,25 @@
1
+import * as Logger from 'log4js'
2
+
3
+var exec = require('child-process-promise').exec;
4
+
5
+Logger.configure({
6
+    appenders: 
7
+    {
8
+    "admin": { type: 'stdout' },
9
+    //app: { type: 'file', filename: 'application.log' }
10
+    },
11
+    categories: 
12
+    {
13
+    default: { appenders: [ 'admin' ], level: 'debug' }
14
+    }
15
+})
16
+const logger = Logger.getLogger("admin") 
17
+
18
+
19
+logger.info("Checking npm dependencies...")
20
+exec("npm i --prefix ./plugins knex@0.19.2 sqlite3@4.1.0").then(process => {
21
+    logger.debug(process.stdout)    
22
+    const admin = require("./FrontblockAdmin").FrontblockAdmin
23
+    new admin()
24
+})
25
+

+ 12
- 2
src/backend/UpdateManger.ts View File

@@ -41,7 +41,7 @@ export class UpdateManager extends Plugin{
41 41
     exportRPCs(): socketioRPC[] {
42 42
         return [{
43 43
             name: 'installPlugin',
44
-            func: async (name:string, force = false) => { },
44
+            func: async (name:string, force = false) => {return await this.installPlugin(name, force)},
45 45
             type: 'call',
46 46
             visibility: 'private'
47 47
         },{
@@ -86,19 +86,29 @@ export class UpdateManager extends Plugin{
86 86
         logger.info(res.stdout)
87 87
 */      
88 88
 
89
+        /*
89 90
         const extensions = [
90 91
             new NPMExtension("sqlite3", "./plugins", "4.1.0"),
91 92
             new NPMExtension("frontblock", "./plugins", "latest")
92 93
 
93 94
         ]
95
+        */
94 96
 
95
-
97
+       const extensions:NPMExtension[] = []
96 98
 
97 99
         await Promise.all(extensions.map(e => e.install()))
98 100
         const status = await Promise.all(extensions.map(e => e.status()))
99 101
         console.log(status)
100 102
     }
101 103
 
104
+    async installPlugin(name: string, force:boolean = false):Promise<RepoFolderStatus>{
105
+        logger.warn("Cloning fb-dist/"+name+".git into ./plugins/"+name+" ..."+(force?" USING FORCE!":""))
106
+        this.pluginUpdaters[name] = new GitUpdater("./plugins/"+name)
107
+        const status = await this.pluginUpdaters[name].cloneRepo("https://gitea.frontblock.me/fb-dist/"+name.toLowerCase()+".git", force)
108
+        return status
109
+    }
110
+
111
+
102 112
     async updateAdmin(force:boolean = false){
103 113
         this.adminUpdater = new GitUpdater("./dist")
104 114
         let status = await this.adminUpdater.getStatus()

+ 16
- 2
src/backend/webpack.prod.js View File

@@ -19,15 +19,29 @@ module.exports = [{
19 19
     __dirname: false,
20 20
     Buffer: true,
21 21
   },
22
+
23
+  
24
+  resolve: {
25
+    // Add `.ts` and `.tsx` as a resolvable extension.
26
+
27
+    extensions: [".ts", ".tsx", ".js"]
28
+  },
29
+  module: {
30
+    rules: [
31
+      { test: /\.ts?$/, loader: "ts-loader" }
32
+    ]
33
+  },
34
+
22 35
   externals:{
23
-    sqlite3: 'sqlite3',
36
+    knex: "../plugins/node_modules/knex"
24 37
   },
25 38
   optimization: {
26 39
     minimize: false
27 40
   },
28
-  entry: path.resolve(__dirname, '../../lib/FrontblockAdmin.js'),
41
+  entry: path.resolve(__dirname, 'Main.ts'),
29 42
   output: {
30 43
       path: path.resolve(__dirname, '../../dist'),
31 44
       filename: 'FrontblockAdmin.js',
45
+      libraryTarget: 'commonjs',
32 46
   }
33 47
 }]

+ 2685
- 0
testrepo/testfolder/package-lock.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save