update build
This commit is contained in:
+16
-18
@@ -37,25 +37,23 @@ steps:
|
||||
commands:
|
||||
- echo ${DRONE_BUILD_CREATED}
|
||||
|
||||
- name: archive plugin files
|
||||
image: alpine:3.9
|
||||
- name: deploy static files
|
||||
image: node:12
|
||||
commands:
|
||||
- apk add --no-cache zip
|
||||
- zip -9r ./plugin.zip *.js
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: release plugin archive
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
base_url: https://gitea.frontblock.me
|
||||
api_key:
|
||||
from_secret: release_token
|
||||
files:
|
||||
- plugin.zip
|
||||
checksum:
|
||||
- md5
|
||||
- git config --global user.email "${DRONE_COMMIT_AUTHOR_EMAIL}"
|
||||
- git config --global user.name "${DRONE_COMMIT_AUTHOR}"
|
||||
- git clone https://gitea.frontblock.me/fb-dist/${DRONE_REPO_NAME}.git
|
||||
- cp -r ./lib/* ./${DRONE_REPO_NAME}
|
||||
- cd ./${DRONE_REPO_NAME}
|
||||
- git add -A
|
||||
- git commit -m "drone taged as version ${DRONE_TAG}"
|
||||
- git tag ${DRONE_TAG}
|
||||
- git push https://$GIT_USER:$GIT_PASSWORD@gitea.frontblock.me/fb-dist/${DRONE_REPO_NAME}.git master ${DRONE_TAG}
|
||||
environment:
|
||||
GIT_USER:
|
||||
from_secret: git_user
|
||||
GIT_PASSWORD:
|
||||
from_secret: git_password
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
@@ -2,8 +2,6 @@ FROM node:alpine
|
||||
|
||||
WORKDIR /service
|
||||
COPY lib /service/lib
|
||||
COPY plugins /service/plugins
|
||||
COPY static /service/static
|
||||
COPY node_modules /service/node_modules
|
||||
|
||||
EXPOSE 8080 20000
|
||||
|
||||
Generated
+84
-4
@@ -347,6 +347,15 @@
|
||||
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
||||
"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": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||
@@ -2441,6 +2450,17 @@
|
||||
"mkdirp": "^0.5.1",
|
||||
"rimraf": "^2.5.4",
|
||||
"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": {
|
||||
@@ -4575,6 +4595,14 @@
|
||||
"requires": {
|
||||
"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",
|
||||
"rimraf": "^2.5.4",
|
||||
"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": {
|
||||
@@ -7083,6 +7122,15 @@
|
||||
"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": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
||||
@@ -8838,6 +8886,16 @@
|
||||
"minimatch": "3.0.3",
|
||||
"mkdirp": "0.5.1",
|
||||
"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": {
|
||||
@@ -9091,11 +9149,11 @@
|
||||
"dev": true
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.5.4",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz",
|
||||
"integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.0.tgz",
|
||||
"integrity": "sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==",
|
||||
"requires": {
|
||||
"glob": "^7.0.5"
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"ripemd160": {
|
||||
@@ -10480,6 +10538,17 @@
|
||||
"inherits": "~2.0.0",
|
||||
"mkdirp": ">=0.5 0",
|
||||
"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",
|
||||
"rimraf": "^2.4.4",
|
||||
"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": {
|
||||
|
||||
+3
-1
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"tsc": "tsc",
|
||||
"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-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",
|
||||
@@ -50,10 +50,12 @@
|
||||
"minimist": "^1.2.0",
|
||||
"node-fetch": "^2.6.0",
|
||||
"path": "^0.12.7",
|
||||
"rimraf": "^3.0.0",
|
||||
"rollup": "^0.55.1",
|
||||
"rollup-plugin-node-externals": "^2.0.0",
|
||||
"rxjs": "^6.5.2",
|
||||
"rxjs-compat": "^6.5.2",
|
||||
"simple-git": "^1.124.0",
|
||||
"socket.io": "^2.2.0",
|
||||
"stream-buffers": "^3.0.2",
|
||||
"unzip": "^0.1.11",
|
||||
|
||||
@@ -7,8 +7,9 @@ import express = require('express');
|
||||
import http = require('http');
|
||||
import bsock = require('bsock');
|
||||
import { FrontblockCherryPicker } from "git-cherrypicker"
|
||||
import { basename } from "path"
|
||||
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')
|
||||
|
||||
@@ -81,10 +82,23 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
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(){
|
||||
await fs.mkdir("plugins/PluginManager", {recursive: true})
|
||||
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.updateDashboard()
|
||||
|
||||
await this.updatePluginmanager()
|
||||
|
||||
let str = "../plugins/PluginManager/Plugin"
|
||||
const PM = await import(str)
|
||||
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