88 *
99 * The artifact is identified by the "gutenberg.sha" value in the root
1010 * package.json, which is used as the OCI image tag for the gutenberg-build
11- * package on GHCR .
11+ * package on GitHub Container Registry .
1212 *
1313 * @package WordPress
1414 */
@@ -22,9 +22,6 @@ const rootDir = path.resolve( __dirname, '../..' );
2222const gutenbergDir = path . join ( rootDir , 'gutenberg' ) ;
2323const packageJsonPath = path . join ( rootDir , 'package.json' ) ;
2424
25- // GHCR configuration
26- const GHCR_REPO = 'desrosj/gutenberg/gutenberg-build' ;
27-
2825/**
2926 * Execute a command, streaming stdio directly so progress is visible.
3027 *
@@ -68,23 +65,31 @@ function exec( command, args, options = {} ) {
6865
6966/**
7067 * Main execution function.
68+ *
69+ * @param {boolean } force - Whether to force a fresh download even if the gutenberg directory exists.
7170 */
72- async function main ( ) {
71+ async function main ( force ) {
7372 console . log ( '🔍 Checking Gutenberg configuration...' ) ;
7473
75- // Read Gutenberg SHA from package.json.
76- let sha ;
74+ // Read Gutenberg configuration from package.json.
75+ let sha , ghcrRepo ;
7776 try {
7877 const packageJson = JSON . parse (
7978 fs . readFileSync ( packageJsonPath , 'utf8' )
8079 ) ;
8180 sha = packageJson . gutenberg ?. sha ;
81+ ghcrRepo = packageJson . gutenberg ?. ghcrRepo ;
8282
8383 if ( ! sha ) {
8484 throw new Error ( 'Missing "gutenberg.sha" in package.json' ) ;
8585 }
8686
87+ if ( ! ghcrRepo ) {
88+ throw new Error ( 'Missing "gutenberg.ghcrRepo" in package.json' ) ;
89+ }
90+
8791 console . log ( ` SHA: ${ sha } ` ) ;
92+ console . log ( ` GHCR repository: ${ ghcrRepo } ` ) ;
8893 } catch ( error ) {
8994 console . error ( '❌ Error reading package.json:' , error . message ) ;
9095 process . exit ( 1 ) ;
@@ -100,7 +105,7 @@ async function main() {
100105 const tokenJson = await exec ( 'curl' , [
101106 '--silent' ,
102107 '--fail' ,
103- `https://ghcr.io/token?scope=repository:${ GHCR_REPO } :pull&service=ghcr.io` ,
108+ `https://ghcr.io/token?scope=repository:${ ghcrRepo } :pull&service=ghcr.io` ,
104109 ] , { captureOutput : true } ) ;
105110 token = JSON . parse ( tokenJson ) . token ;
106111 if ( ! token ) {
@@ -121,7 +126,7 @@ async function main() {
121126 '--fail' ,
122127 '--header' , `Authorization: Bearer ${ token } ` ,
123128 '--header' , 'Accept: application/vnd.oci.image.manifest.v1+json' ,
124- `https://ghcr.io/v2/${ GHCR_REPO } /manifests/${ sha } ` ,
129+ `https://ghcr.io/v2/${ ghcrRepo } /manifests/${ sha } ` ,
125130 ] , { captureOutput : true } ) ;
126131 const manifest = JSON . parse ( manifestJson ) ;
127132 digest = manifest ?. layers ?. [ 0 ] ?. digest ;
@@ -142,7 +147,7 @@ async function main() {
142147 '--location' ,
143148 '--header' , `Authorization: Bearer ${ token } ` ,
144149 '--output' , zipPath ,
145- `https://ghcr.io/v2/${ GHCR_REPO } /blobs/${ digest } ` ,
150+ `https://ghcr.io/v2/${ ghcrRepo } /blobs/${ digest } ` ,
146151 ] ) ;
147152 console . log ( '✅ Download complete' ) ;
148153 } catch ( error ) {
0 commit comments