From c2df1507b94afd016aa39da0c96de1d5ca34a601 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 17 Feb 2022 13:20:13 -0500 Subject: [PATCH 1/6] Run all smoke tests with the static build --- scripts/smoke/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/smoke/index.js b/scripts/smoke/index.js index c3c545529a4e..322ce0ab5ebf 100644 --- a/scripts/smoke/index.js +++ b/scripts/smoke/index.js @@ -58,6 +58,15 @@ async function run() { process.exit(1); } + // Run with the static build too + try { + await execa('yarn', ['build', '--', '--experimental-static-build'], { cwd: fileURLToPath(directory), stdout: 'inherit', stderr: 'inherit' }); + } catch (err) { + console.log(err); + + process.exit(1); + } + console.log(); } } From f536f22f64b3009f1d1fa82a57a069741f9338b8 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 17 Feb 2022 14:10:09 -0500 Subject: [PATCH 2/6] Use a direct relative path --- examples/with-vite-plugin-pwa/src/pages/index.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-vite-plugin-pwa/src/pages/index.astro b/examples/with-vite-plugin-pwa/src/pages/index.astro index 7fdcc305ee00..bbddf76e71c9 100644 --- a/examples/with-vite-plugin-pwa/src/pages/index.astro +++ b/examples/with-vite-plugin-pwa/src/pages/index.astro @@ -11,6 +11,6 @@

Welcome to Astro

- + From 1f243c8a8b96ea611b027644ede6f9a3cff47a75 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 17 Feb 2022 14:15:50 -0500 Subject: [PATCH 3/6] Always use the static build --- examples/with-vite-plugin-pwa/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json index 19563f813271..73f0b4b739e6 100644 --- a/examples/with-vite-plugin-pwa/package.json +++ b/examples/with-vite-plugin-pwa/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "astro dev", "start": "astro dev", - "build": "astro build", + "build": "astro build --experimental-static-build", "preview": "astro preview" }, "devDependencies": { From e4b7969e57b6da4cd22063ae511c6b7f11155360 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 18 Feb 2022 14:17:51 -0500 Subject: [PATCH 4/6] Use a path that works in both static and regualr build --- examples/with-vite-plugin-pwa/package.json | 2 +- examples/with-vite-plugin-pwa/src/pages/index.astro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json index 73f0b4b739e6..19563f813271 100644 --- a/examples/with-vite-plugin-pwa/package.json +++ b/examples/with-vite-plugin-pwa/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "astro dev", "start": "astro dev", - "build": "astro build --experimental-static-build", + "build": "astro build", "preview": "astro preview" }, "devDependencies": { diff --git a/examples/with-vite-plugin-pwa/src/pages/index.astro b/examples/with-vite-plugin-pwa/src/pages/index.astro index bbddf76e71c9..19ca257001dc 100644 --- a/examples/with-vite-plugin-pwa/src/pages/index.astro +++ b/examples/with-vite-plugin-pwa/src/pages/index.astro @@ -11,6 +11,6 @@

Welcome to Astro

- + From b71b7302835ecef59b3f2aa934e9aa12865cdcde Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 18 Feb 2022 16:24:05 -0500 Subject: [PATCH 5/6] Always download the zip --- scripts/smoke/index.js | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/scripts/smoke/index.js b/scripts/smoke/index.js index 322ce0ab5ebf..47b144b877c1 100644 --- a/scripts/smoke/index.js +++ b/scripts/smoke/index.js @@ -88,42 +88,34 @@ const downloadGithubZip = async (/** @type {GithubOpts} */ opts) => { /** Expected directory when the zip is downloaded. */ const githubDir = new URL(`${opts.name}-${opts.branch}`, scriptDir); - /** Whether the expected directory is already available */ - const hasGithubDir = await fs.stat(githubDir).then( - (stats) => stats.isDirectory(), - () => false - ); + console.log('🤖', 'Downloading', `${opts.org}/${opts.name}#${opts.branch}`); - if (!hasGithubDir) { - console.log('🤖', 'Downloading', `${opts.org}/${opts.name}#${opts.branch}`); + const buffer = await fetchGithubZip(opts); - const buffer = await fetchGithubZip(opts); + console.log('🤖', 'Extracting', `${opts.org}/${opts.name}#${opts.branch}`); - console.log('🤖', 'Extracting', `${opts.org}/${opts.name}#${opts.branch}`); + new Zip(buffer).extractAllTo(fileURLToPath(scriptDir), true); - new Zip(buffer).extractAllTo(fileURLToPath(scriptDir), true); + console.log('🤖', 'Preparing', `${opts.org}/${opts.name}#${opts.branch}`); - console.log('🤖', 'Preparing', `${opts.org}/${opts.name}#${opts.branch}`); + const astroPackage = await readDirectoryPackage(astroDir); - const astroPackage = await readDirectoryPackage(astroDir); + const githubPackage = await readDirectoryPackage(githubDir); - const githubPackage = await readDirectoryPackage(githubDir); - - if ('astro' in Object(githubPackage.dependencies)) { - githubPackage.dependencies['astro'] = astroPackage.version; - } - - if ('astro' in Object(githubPackage.devDependencies)) { - githubPackage.devDependencies['astro'] = astroPackage.version; - } + if ('astro' in Object(githubPackage.dependencies)) { + githubPackage.dependencies['astro'] = astroPackage.version; + } - if ('astro' in Object(githubPackage.peerDependencies)) { - githubPackage.peerDependencies['astro'] = astroPackage.version; - } + if ('astro' in Object(githubPackage.devDependencies)) { + githubPackage.devDependencies['astro'] = astroPackage.version; + } - await writeDirectoryPackage(githubDir, githubPackage); + if ('astro' in Object(githubPackage.peerDependencies)) { + githubPackage.peerDependencies['astro'] = astroPackage.version; } + await writeDirectoryPackage(githubDir, githubPackage); + return githubDir; }; From 79f9d299d75724e6f1834907638812e03594fbfd Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 18 Feb 2022 16:44:13 -0500 Subject: [PATCH 6/6] astro.build only needs to run once --- scripts/smoke/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/smoke/index.js b/scripts/smoke/index.js index 47b144b877c1..6e36731a260c 100644 --- a/scripts/smoke/index.js +++ b/scripts/smoke/index.js @@ -59,6 +59,11 @@ async function run() { } // Run with the static build too + if(directory.pathname.includes('astro.build')) { + // astro.build uses the static build, so rerunning with the flag actually negates it. + continue; + } + try { await execa('yarn', ['build', '--', '--experimental-static-build'], { cwd: fileURLToPath(directory), stdout: 'inherit', stderr: 'inherit' }); } catch (err) {