Skip to content

Commit 75dbbbf

Browse files
committed
feat: 更新插件结构
1 parent a0791ea commit 75dbbbf

File tree

6 files changed

+51
-29
lines changed

6 files changed

+51
-29
lines changed

.github/workflows/deploy.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ jobs:
6464
- name: Build Project
6565
run: yarn build
6666

67-
# 11. 上传至 Aliyun OSS
67+
# 11. 读取 package.json 中的 Plugin ID 及 Version
68+
- name: Extract Plugin ID and Version
69+
run: |
70+
PLUGIN_ID=$(jq -r '.plugin.id' package.json)
71+
VERSION=$(jq -r '.version' package.json)
72+
echo "PLUGIN_ID=$PLUGIN_ID" >> $GITHUB_ENV
73+
echo "::notice::Plugin ID is $PLUGIN_ID"
74+
echo "VERSION=$VERSION" >> $GITHUB_ENV
75+
echo "::notice::Version is $VERSION"
76+
77+
# 12. 上传至 Aliyun OSS
6878
- name: Upload to Aliyun OSS
6979
env:
7080
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
@@ -73,4 +83,8 @@ jobs:
7383
OSS_REGION: ${{ secrets.OSS_REGION }}
7484
OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
7585
run: |
76-
ossutil cp -r ./dist/ oss://${OSS_BUCKET}/oflow/plugins/template-drawer/ --force
86+
echo "::notice::Uploading to oss://${OSS_BUCKET}/oflow/plugins/${PLUGIN_ID}/v${VERSION}/"
87+
ossutil cp -r ./dist/ oss://${OSS_BUCKET}/oflow/plugins/${PLUGIN_ID}/v${VERSION}/ --force
88+
echo ""
89+
echo "::notice::Uploading to oss://${OSS_BUCKET}/oflow/plugins/${PLUGIN_ID}/latest/"
90+
ossutil cp -r ./dist/ oss://${OSS_BUCKET}/oflow/plugins/${PLUGIN_ID}/latest/ --force

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
"name": "ofp-template-drawer",
33
"version": "1.0.0",
44
"description": "",
5+
"plugin": {
6+
"id": "",
7+
"type": "DRAWER",
8+
"theme": "BLUE",
9+
"port": {
10+
"dev": 8080,
11+
"debug": 8081
12+
}
13+
},
514
"main": "dist/index.js",
615
"types": "dist/index.d.ts",
716
"scripts": {

scripts/commit.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ const { execSync } = require('child_process')
55
const path = require('path')
66
const fs = require('fs')
77

8+
const packageJson = require('../package.json');
9+
810
const PROJECT_PATH = path.resolve(__dirname, '../')
9-
const ACTIONS_URL = 'https://github.com/O-FLOW/ofp-template-drawer/actions'
11+
const ACTIONS_URL = 'https://github.com/O-FLOW/' + packageJson.name + '/actions'
1012

1113
function checkPackageJson(projectPath) {
1214
if (!fs.existsSync(path.join(projectPath, 'package.json'))) {

src/api.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import {
4646
RsModelServiceApi,
4747
RsEnvironmentServiceApi,
4848
UseBase,
49+
EasyPropertyAnimationApi,
50+
RsServiceApi,
4951
} from "oflow-interface";
5052
import type { FunctionComponent } from "react";
5153

@@ -78,12 +80,16 @@ export let lightAnimation: LightAnimationApi
7880
export let shadowAnimation: ShadowAnimationApi
7981
export let skyboxAnimation: SkyboxAnimationApi
8082

83+
export let easyPropertyAnimation: EasyPropertyAnimationApi
84+
8185
export let rsSelectionService: RsSelectionServiceApi
8286

8387
export let rsNodeService: RsNodeServiceApi
8488
export let rsModelService: RsModelServiceApi
8589
export let rsEnvironmentService: RsEnvironmentServiceApi
8690

91+
export let rsService: RsServiceApi
92+
8793
export let syncService: SyncServiceApi
8894
export let historyService: HistoryServiceApi
8995

@@ -177,12 +183,16 @@ export function loadApi() {
177183
shadowAnimation = api.services.engine.animation.shadowAnimation
178184
skyboxAnimation = api.services.engine.animation.skyboxAnimation
179185

186+
easyPropertyAnimation = api.services.engine.animation.easyPropertyAnimation
187+
180188
rsSelectionService = api.services.engine.operate.rsSelectionService
181189

182190
rsNodeService = api.services.engine.render.rsNodeService
183191
rsModelService = api.services.engine.render.rsModelService
184192
rsEnvironmentService = api.services.engine.render.rsEnvironmentService
185193

194+
rsService = api.services.engine.rsService
195+
186196
syncService = api.services.sync.syncService
187197
historyService = api.services.sync.historyService
188198
rvGlobalService = api.services.sync.rvGlobalService

src/plugin.tsx

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,30 @@
1+
import packageJson from '../package.json'
12
import {IconPluginPosition, PluginType, ThemeColor} from 'oflow-interface'
23
import {DrawerPlugin} from "oflow-interface";
34
import {loadApi} from "./api";
45
import React from 'react';
56
import Drawer from "./drawer/drawer";
6-
import {proxy} from "valtio";
77

88

99
export default class Plugin implements DrawerPlugin {
1010

11-
id: string = ''
12-
name: string = ''
13-
version: string = '0.0.1'
14-
description = ''
11+
id: string = packageJson.plugin.id
12+
name: string = packageJson.name
13+
version: string = packageJson.version
14+
description = packageJson.description
1515

16-
type: PluginType = PluginType.DRAWER
17-
theme: ThemeColor = ThemeColor.BLUE
16+
type: PluginType = packageJson.plugin.type as PluginType
17+
theme: ThemeColor = packageJson.plugin.theme as ThemeColor
1818

19-
data = proxy({
20-
21-
})
22-
23-
async onInstall() {
24-
loadApi()
25-
}
26-
async onEnable() {
27-
28-
}
29-
async onDisable() {
30-
31-
}
32-
async onUninstall() {
33-
34-
}
19+
loadApi = loadApi
3520

3621
weight = 50
3722
title = ''
3823
tip = ''
3924
position = IconPluginPosition.TOP_LEFT
4025
group = ''
4126
label = ''
42-
color = ThemeColor.BLUE
27+
color = packageJson.plugin.theme as ThemeColor
4328
open = false
4429

4530
icon = () => {

webpack.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ const path = require('path')
22
const webpack = require('webpack')
33
const WebSocket = require('ws')
44

5+
const packageJson = require('./package.json');
6+
57
class CompilationNotifierPlugin {
68
apply(compiler) {
79
let wss
810

911
compiler.hooks.compile.tap('CompilationNotifierPlugin', () => {
1012
if (wss) return;
11-
wss = new WebSocket.Server({ port: 8081 })
13+
wss = new WebSocket.Server({ port: packageJson.plugin.port.debug })
1214
console.log('\nCompilation NotifierPlugin Websocket Started.\n')
1315
})
1416

@@ -96,7 +98,7 @@ module.exports = {
9698
static: {
9799
directory: path.join(__dirname, 'dist'),
98100
},
99-
port: 8080,
101+
port: packageJson.plugin.port.dev,
100102
hot: false,
101103
watchFiles: ['src/**/*'],
102104
liveReload: false,

0 commit comments

Comments
 (0)