update build
This commit is contained in:
+16
-18
@@ -37,25 +37,23 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- echo ${DRONE_BUILD_CREATED}
|
- echo ${DRONE_BUILD_CREATED}
|
||||||
|
|
||||||
- name: archive plugin files
|
- name: deploy static files
|
||||||
image: alpine:3.9
|
image: node:12
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache zip
|
- git config --global user.email "${DRONE_COMMIT_AUTHOR_EMAIL}"
|
||||||
- zip -9r ./plugin.zip *.js
|
- git config --global user.name "${DRONE_COMMIT_AUTHOR}"
|
||||||
when:
|
- git clone https://gitea.frontblock.me/fb-dist/${DRONE_REPO_NAME}.git
|
||||||
event:
|
- cp -r ./lib/* ./${DRONE_REPO_NAME}
|
||||||
- tag
|
- cd ./${DRONE_REPO_NAME}
|
||||||
|
- git add -A
|
||||||
- name: release plugin archive
|
- git commit -m "drone taged as version ${DRONE_TAG}"
|
||||||
image: plugins/gitea-release
|
- git tag ${DRONE_TAG}
|
||||||
settings:
|
- git push https://$GIT_USER:$GIT_PASSWORD@gitea.frontblock.me/fb-dist/${DRONE_REPO_NAME}.git master ${DRONE_TAG}
|
||||||
base_url: https://gitea.frontblock.me
|
environment:
|
||||||
api_key:
|
GIT_USER:
|
||||||
from_secret: release_token
|
from_secret: git_user
|
||||||
files:
|
GIT_PASSWORD:
|
||||||
- plugin.zip
|
from_secret: git_password
|
||||||
checksum:
|
|
||||||
- md5
|
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ FROM node:alpine
|
|||||||
|
|
||||||
WORKDIR /service
|
WORKDIR /service
|
||||||
COPY lib /service/lib
|
COPY lib /service/lib
|
||||||
COPY plugins /service/plugins
|
|
||||||
COPY static /service/static
|
|
||||||
COPY node_modules /service/node_modules
|
COPY node_modules /service/node_modules
|
||||||
|
|
||||||
EXPOSE 8080 20000
|
EXPOSE 8080 20000
|
||||||
|
|||||||
Generated
+84
-4
@@ -347,6 +347,15 @@
|
|||||||
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||||
@@ -2441,6 +2450,17 @@
|
|||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"rimraf": "^2.5.4",
|
"rimraf": "^2.5.4",
|
||||||
"run-queue": "^1.0.0"
|
"run-queue": "^1.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"copy-descriptor": {
|
"copy-descriptor": {
|
||||||
@@ -4575,6 +4595,14 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"natives": "^1.1.0"
|
"natives": "^1.1.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -6978,6 +7006,17 @@
|
|||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"rimraf": "^2.5.4",
|
"rimraf": "^2.5.4",
|
||||||
"run-queue": "^1.0.3"
|
"run-queue": "^1.0.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
@@ -7083,6 +7122,15 @@
|
|||||||
"rimraf": "2"
|
"rimraf": "2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
||||||
@@ -8838,6 +8886,16 @@
|
|||||||
"minimatch": "3.0.3",
|
"minimatch": "3.0.3",
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"rimraf": "2.5.4"
|
"rimraf": "2.5.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz",
|
||||||
|
"integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=",
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redent": {
|
"redent": {
|
||||||
@@ -9091,11 +9149,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"rimraf": {
|
"rimraf": {
|
||||||
"version": "2.5.4",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.0.tgz",
|
||||||
"integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=",
|
"integrity": "sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"glob": "^7.0.5"
|
"glob": "^7.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ripemd160": {
|
"ripemd160": {
|
||||||
@@ -10480,6 +10538,17 @@
|
|||||||
"inherits": "~2.0.0",
|
"inherits": "~2.0.0",
|
||||||
"mkdirp": ">=0.5 0",
|
"mkdirp": ">=0.5 0",
|
||||||
"rimraf": "2"
|
"rimraf": "2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10861,6 +10930,17 @@
|
|||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"rimraf": "^2.4.4",
|
"rimraf": "^2.4.4",
|
||||||
"semver": "^5.3.0"
|
"semver": "^5.3.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"start": "npm run build; node lib/FrontblockAdmin.js",
|
"start": "npm run build; node lib/FrontblockAdmin.js",
|
||||||
"build": "npm run clean; npm run build-backend; npm run build-frontend",
|
"build": "npm run clean; npm run build-backend;",
|
||||||
"build-backend": "tsc; webpack --display-error-details --config src/backend/webpack.prod.js --progress --colors;",
|
"build-backend": "tsc; webpack --display-error-details --config src/backend/webpack.prod.js --progress --colors;",
|
||||||
"build-frontend": "npm run build-dashboard",
|
"build-frontend": "npm run build-dashboard",
|
||||||
"build-dashboard": "git submodule init && git submodule update --merge; cd src/frontend/dashboard; npm i && npm run build; cp -r dist/* ../../../static",
|
"build-dashboard": "git submodule init && git submodule update --merge; cd src/frontend/dashboard; npm i && npm run build; cp -r dist/* ../../../static",
|
||||||
@@ -50,10 +50,12 @@
|
|||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
"rimraf": "^3.0.0",
|
||||||
"rollup": "^0.55.1",
|
"rollup": "^0.55.1",
|
||||||
"rollup-plugin-node-externals": "^2.0.0",
|
"rollup-plugin-node-externals": "^2.0.0",
|
||||||
"rxjs": "^6.5.2",
|
"rxjs": "^6.5.2",
|
||||||
"rxjs-compat": "^6.5.2",
|
"rxjs-compat": "^6.5.2",
|
||||||
|
"simple-git": "^1.124.0",
|
||||||
"socket.io": "^2.2.0",
|
"socket.io": "^2.2.0",
|
||||||
"stream-buffers": "^3.0.2",
|
"stream-buffers": "^3.0.2",
|
||||||
"unzip": "^0.1.11",
|
"unzip": "^0.1.11",
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import express = require('express');
|
|||||||
import http = require('http');
|
import http = require('http');
|
||||||
import bsock = require('bsock');
|
import bsock = require('bsock');
|
||||||
import { FrontblockCherryPicker } from "git-cherrypicker"
|
import { FrontblockCherryPicker } from "git-cherrypicker"
|
||||||
import { basename } from "path"
|
|
||||||
import { promises as fs } from "fs"
|
import { promises as fs } from "fs"
|
||||||
|
import { GitUpdater } from "./GitUpdater";
|
||||||
|
import * as git from "simple-git/promise"
|
||||||
|
|
||||||
const kfs = require("key-file-storage").default('kfs')
|
const kfs = require("key-file-storage").default('kfs')
|
||||||
|
|
||||||
@@ -81,10 +82,23 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
|||||||
return {httpPort: 8080}
|
return {httpPort: 8080}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async updateDashboard(){
|
||||||
|
const dashboard = new GitUpdater("./static")
|
||||||
|
const status = await dashboard.cloneRepo("https://gitea.frontblock.me/fb-dist/dashboard.git", true)
|
||||||
|
console.log(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
private async updatePluginmanager(){
|
||||||
|
const dashboard = new GitUpdater("./plugins/PluginManager")
|
||||||
|
const status = await dashboard.cloneRepo("https://gitea.frontblock.me/fb-dist/pluginmanager.git", true)
|
||||||
|
console.log(status)
|
||||||
|
}
|
||||||
|
|
||||||
private async initialize(){
|
private async initialize(){
|
||||||
await fs.mkdir("plugins/PluginManager", {recursive: true})
|
await this.updateDashboard()
|
||||||
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "Plugin.js")).write("plugins/PluginManager/Plugin.js")
|
|
||||||
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "FrontendPlugin.js")).write("plugins/PluginManager/FrontendPlugin.js")
|
await this.updatePluginmanager()
|
||||||
|
|
||||||
let str = "../plugins/PluginManager/Plugin"
|
let str = "../plugins/PluginManager/Plugin"
|
||||||
const PM = await import(str)
|
const PM = await import(str)
|
||||||
this.pm = new PM.default()
|
this.pm = new PM.default()
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
"use strict";
|
||||||
|
import { assert } from "bsert"
|
||||||
|
import * as git from "simple-git/promise"
|
||||||
|
import * as gyt from "git-describe"
|
||||||
|
import { promises as fs, mkdirSync } from "fs"
|
||||||
|
import * as rimraf from "rimraf"
|
||||||
|
import * as path from "path"
|
||||||
|
|
||||||
|
|
||||||
|
const rmrf = (path:string, options = {}) => {
|
||||||
|
return new Promise((acc, _) => rimraf(path, options, acc))
|
||||||
|
}
|
||||||
|
|
||||||
|
type RepoFolderStatus = {
|
||||||
|
exists: boolean
|
||||||
|
empty: boolean
|
||||||
|
currentTag?: string
|
||||||
|
tags?: string[]
|
||||||
|
latestTag?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GitUpdater{
|
||||||
|
private readonly repo
|
||||||
|
constructor(private readonly folderPath:string){
|
||||||
|
this.folderPath = folderPath;
|
||||||
|
mkdirSync(this.folderPath, { recursive: true });
|
||||||
|
this.repo = git(this.folderPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
async getStatus():Promise<RepoFolderStatus>{
|
||||||
|
try {
|
||||||
|
await fs.access(this.folderPath);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
return { exists: false, empty: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = await fs.readdir(this.folderPath)
|
||||||
|
const empty:boolean = files.length === 0
|
||||||
|
|
||||||
|
await this.repo.fetch("origin", "master", {
|
||||||
|
"--tags": null
|
||||||
|
});
|
||||||
|
const remoteTags = await this.repo.tags();
|
||||||
|
const desc = await gyt.gitDescribe(this.folderPath, { match: "*" });
|
||||||
|
return {
|
||||||
|
exists: true,
|
||||||
|
empty: empty,
|
||||||
|
currentTag: !desc.tag?null:desc.tag,
|
||||||
|
tags: !remoteTags.all?[]:remoteTags.all,
|
||||||
|
latestTag: remoteTags.latest
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async cloneRepo(from:string, force:boolean = false):Promise<RepoFolderStatus> {
|
||||||
|
if(force){
|
||||||
|
await rmrf(this.folderPath)
|
||||||
|
await fs.mkdir(this.folderPath, { recursive: true });
|
||||||
|
}
|
||||||
|
const status = await this.getStatus()
|
||||||
|
assert(status.exists && status.empty)
|
||||||
|
|
||||||
|
await git(this.folderPath).clone(from, path.resolve(this.folderPath));
|
||||||
|
return await this.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkoutTag(tag:string):Promise<RepoFolderStatus> {
|
||||||
|
const status = await this.getStatus()
|
||||||
|
assert(status.exists && status.tags && status.tags.length !== 0)
|
||||||
|
await this.repo.checkout(tag);
|
||||||
|
return await this.getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
(async () => {
|
||||||
|
const staticPath = path.join(__dirname, "..", "static")
|
||||||
|
|
||||||
|
const gl = new GitUpdater(staticPath)
|
||||||
|
let status = await gl.getStatus()
|
||||||
|
console.log(status)
|
||||||
|
|
||||||
|
if(status.empty){
|
||||||
|
status = await gl.cloneRepo("https://gitea.frontblock.me/fb-dist/dashboard.git")
|
||||||
|
console.log(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
status = await gl.checkoutTag(status.latestTag!)
|
||||||
|
console.log(status)
|
||||||
|
})()
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user