File tree Expand file tree Collapse file tree 5 files changed +11
-23
lines changed
Expand file tree Collapse file tree 5 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,6 @@ jobs:
124124 ISSUES=()
125125
126126 for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
127- # 检查必填字段完整性(新结构)
128127 REQUIRED_FIELDS="id name author description category repository license latestVersion versions"
129128 for field in $REQUIRED_FIELDS; do
130129 VALUE=$(node -e "console.log(require('./$file').$field || '')")
Original file line number Diff line number Diff line change @@ -57,30 +57,18 @@ jobs:
5757 - name : Check version immutability
5858 if : steps.changed-files.outputs.any_changed == 'true'
5959 run : |
60- # 检查是否有版本对应的 ZIP 已存在(版本不可变)
6160 for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
6261 PLUGIN_DIR=$(dirname "$file")
6362
64- # 读取 manifest 中的所有版本(支持新旧结构)
6563 VERSIONS=$(node -e "
6664 const fs = require('fs');
6765 const manifest = JSON.parse(fs.readFileSync('$file'));
6866
69- // 新结构:使用 versions 数组
7067 if (Array.isArray(manifest.versions)) {
7168 manifest.versions.forEach(v => console.log(v.version));
7269 }
73- // 旧结构:使用 version 字段
74- else if (manifest.version) {
75- console.log(manifest.version);
76- }
77- // 兜底:使用 latestVersion
78- else if (manifest.latestVersion) {
79- console.log(manifest.latestVersion);
80- }
8170 ")
8271
83- # 检查主分支是否已有这些版本的 ZIP
8472 git fetch origin main:main 2>/dev/null || true
8573
8674 for VERSION in $VERSIONS; do
Original file line number Diff line number Diff line change @@ -132,10 +132,17 @@ async function checkManifestSecurity(manifestPath) {
132132 }
133133 }
134134
135- await checkDistributionUrl ( manifest . distribution . url , isNewPlugin ) ;
136-
137- if ( manifest . distribution . css ) {
138- await checkDistributionUrl ( manifest . distribution . css , isNewPlugin ) ;
135+ if ( Array . isArray ( manifest . versions ) ) {
136+ for ( const version of manifest . versions ) {
137+ if ( version . zipUrl ) {
138+ await checkDistributionUrl ( version . zipUrl , isNewPlugin ) ;
139+ }
140+ }
141+ } else if ( manifest . distribution ?. url ) {
142+ await checkDistributionUrl ( manifest . distribution . url , isNewPlugin ) ;
143+ if ( manifest . distribution . css ) {
144+ await checkDistributionUrl ( manifest . distribution . css , isNewPlugin ) ;
145+ }
139146 }
140147
141148 await scanRepositoryCode ( manifest . repository . url ) ;
Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ function generateRegistry() {
5858 const content = fs . readFileSync ( manifestPath , 'utf-8' ) ;
5959 const manifest = JSON . parse ( content ) ;
6060
61- // 验证新结构
6261 if ( ! manifest . latestVersion ) {
6362 throw new Error ( 'Missing required field: latestVersion' ) ;
6463 }
@@ -68,8 +67,6 @@ function generateRegistry() {
6867
6968 const versions = manifest . versions ;
7069 const latestVersion = manifest . latestVersion ;
71-
72- // 添加插件信息到 registry
7370 const pluginInfo = {
7471 id : manifest . id ,
7572 name : manifest . name ,
Original file line number Diff line number Diff line change @@ -142,14 +142,12 @@ function validateManifest(manifestPath) {
142142
143143 const errors = [ ] ;
144144
145- // 检查必需字段
146145 for ( const field of SCHEMA . required ) {
147146 if ( ! ( field in manifest ) ) {
148147 errors . push ( `Missing required field: ${ field } ` ) ;
149148 }
150149 }
151150
152- // 验证 versions 数组
153151 if ( Array . isArray ( manifest . versions ) ) {
154152 if ( manifest . versions . length === 0 ) {
155153 errors . push ( 'versions array cannot be empty' ) ;
@@ -168,7 +166,6 @@ function validateManifest(manifestPath) {
168166 } ) ;
169167 }
170168
171- // 验证其他字段
172169 for ( const [ field , fieldSchema ] of Object . entries ( SCHEMA . properties ) ) {
173170 if ( field in manifest ) {
174171 errors . push ( ...validateValue ( manifest [ field ] , fieldSchema , field ) ) ;
You can’t perform that action at this time.
0 commit comments