@@ -3,6 +3,7 @@ import registryJson from "./extensions.json";
3
3
import crypto from "node:crypto" ;
4
4
import path from "node:path" ;
5
5
import * as core from "@actions/core" ;
6
+ import semver from "semver" ;
6
7
7
8
function warning ( message : string ) {
8
9
core . warning ( message , { file : "extensions.json" } ) ;
@@ -14,10 +15,16 @@ function error(message: string) {
14
15
}
15
16
16
17
/**
17
- * SHA sums of extensions that are known to be uncompressed. For these we will only log a warning.
18
+ * We require newly submitted extensions to use at least this version of create-foxglove-extension.
19
+ *
20
+ * 1.0.3: fixed a bug where packaged extensions were not compressed
21
+ */
22
+ const createFoxgloveExtensionMinVersion = "1.0.3" ;
23
+ /**
24
+ * SHA sums of extensions that are exempt from the version check. For these we will only log a warning.
18
25
* For other (newer) ones it will be an error if compression is not used.
19
26
*/
20
- const knownUncompressedExtensionsSHAs = [
27
+ const exemptExtensionsSHAs = [
21
28
"fa2b11af8ed7c420ca6e541196bca608661c0c1a81cd1f768c565c72a55a63c8" ,
22
29
"ac07f5f84b96ad1139b4d66b685b864cf5713081e198e63fccef7a0546dd1ab2" ,
23
30
"1193589eb2779a1224328defca4e2ca378ef786474be1842ac43b674b9535d82" ,
@@ -84,25 +91,6 @@ async function validateExtension(extension: (typeof registryJson)[number]) {
84
91
}
85
92
86
93
const zip = await JSZip . loadAsync ( foxeContent , { checkCRC32 : true } ) ;
87
- let uncompressedFiles = [ ] ;
88
- let anyFilesAreCompressed = false ;
89
- for ( const [ path , zipObj ] of Object . entries ( zip . files ) ) {
90
- if ( zipObj . dir ) continue ;
91
- if ( zipObj . options . compression === "DEFLATE" ) {
92
- anyFilesAreCompressed = true ;
93
- } else {
94
- uncompressedFiles . push ( path ) ;
95
- }
96
- }
97
- if ( uncompressedFiles . length > 0 ) {
98
- ( knownUncompressedExtensionsSHAs . includes ( extension . sha256sum )
99
- ? warning
100
- : error ) (
101
- `${ extension . id } : the following files are stored without compression: ${
102
- anyFilesAreCompressed ? uncompressedFiles . join ( ", " ) : "(all files)"
103
- } `
104
- ) ;
105
- }
106
94
107
95
const packageJsonContent = await zip . file ( "package.json" ) ?. async ( "string" ) ;
108
96
if ( ! packageJsonContent ) {
@@ -115,6 +103,36 @@ async function validateExtension(extension: (typeof registryJson)[number]) {
115
103
return ;
116
104
}
117
105
106
+ const createFoxgloveExtensionRange =
107
+ packageJson . devDependencies ?. [ "create-foxglove-extension" ] ??
108
+ packageJson . devDependencies ?. [ "@foxglove/fox" ] ;
109
+ if ( ! createFoxgloveExtensionRange ) {
110
+ error (
111
+ `${ extension . id } : Invalid package.json: expected create-foxglove-extension in devDependencies`
112
+ ) ;
113
+ return ;
114
+ }
115
+ const actualMinVersion = semver . minVersion ( createFoxgloveExtensionRange ) ;
116
+ if ( ! actualMinVersion ) {
117
+ error (
118
+ `${ extension . id } : Invalid package.json: unable to determine min version of create-foxglove-extension`
119
+ ) ;
120
+ return ;
121
+ }
122
+ if ( ! semver . gte ( actualMinVersion , createFoxgloveExtensionMinVersion ) ) {
123
+ const message = `${ extension . id } : must use create-foxglove-extension ${ createFoxgloveExtensionMinVersion } , found ${ createFoxgloveExtensionRange } ` ;
124
+ if ( exemptExtensionsSHAs . includes ( extension . sha256sum ) ) {
125
+ warning ( message ) ;
126
+ } else {
127
+ error ( message ) ;
128
+ return ;
129
+ }
130
+ } else if ( exemptExtensionsSHAs . includes ( extension . sha256sum ) ) {
131
+ error (
132
+ `The following SHA should be removed from exemptExtensionsSHAs: ${ extension . sha256sum } `
133
+ ) ;
134
+ }
135
+
118
136
const mainPath = packageJson . main ;
119
137
if ( typeof mainPath !== "string" ) {
120
138
error ( `${ extension . id } : Invalid package.json: missing "main" field` ) ;
@@ -138,12 +156,12 @@ async function validateExtension(extension: (typeof registryJson)[number]) {
138
156
}
139
157
140
158
async function main ( ) {
141
- const unusedSHAs = knownUncompressedExtensionsSHAs . filter (
159
+ const unusedSHAs = exemptExtensionsSHAs . filter (
142
160
( sha ) => ! registryJson . find ( ( ext ) => ext . sha256sum === sha )
143
161
) ;
144
162
for ( const sha of unusedSHAs ) {
145
163
error (
146
- `The following SHA should be removed from knownUncompressedExtensionsSHAs : ${ sha } `
164
+ `The following SHA should be removed from exemptExtensionSHAs : ${ sha } `
147
165
) ;
148
166
}
149
167
0 commit comments