apollo-elements/apollo-elements

View on GitHub
patches/@rocket+cli+0.10.2.patch

Summary

Maintainability
Test Coverage
diff --git a/node_modules/@rocket/cli/src/RocketBuild.js b/node_modules/@rocket/cli/src/RocketBuild.js
index edc0bf7..76418bc 100755
--- a/node_modules/@rocket/cli/src/RocketBuild.js
+++ b/node_modules/@rocket/cli/src/RocketBuild.js
@@ -22,6 +22,9 @@ async function buildAndWrite(config) {
   } else {
     await bundle.write(config.output);
   }
+  while(!bundle.closed)
+    await bundle.close();
+  return bundle;
 }
 
 async function productionBuild(config) {
diff --git a/node_modules/@rocket/cli/src/RocketCli.js b/node_modules/@rocket/cli/src/RocketCli.js
index a6153b6..91a20de 100644
--- a/node_modules/@rocket/cli/src/RocketCli.js
+++ b/node_modules/@rocket/cli/src/RocketCli.js
@@ -92,6 +92,10 @@ export class RocketCli {
         type: String,
         description: 'Location of Rocket configuration',
       },
+      {
+        name: 'incremental',
+        type: Boolean,
+      }
     ];
     const options = commandLineArgs(mainDefinitions, {
       stopAtFirstUnknown: true,
@@ -100,8 +104,10 @@ export class RocketCli {
     this.subArgv = options._unknown || [];
     this.argvConfig = {
       command: options.command,
+      incremental: options.incremental,
       configFile: options['config-file'],
     };
+
     this.__isSetup = false;
   }
 
@@ -114,12 +120,16 @@ export class RocketCli {
       await this.mergePresets();
 
       const elev = new RocketEleventy(_inputDirCwdRelative, outputDevDir, this);
+
+      elev.setIncrementalBuild(this.argvConfig.incremental);
+
       // 11ty always wants a relative path to cwd - why?
       const rel = path.relative(process.cwd(), path.join(__dirname));
       const relCwdPathToConfig = path.join(rel, 'shared', '.eleventy.cjs');
 
       const config = new TemplateConfig(null, relCwdPathToConfig);
       elev.config = config.getConfig();
+
       /** @type {*} */
       (elev).resetConfig();
       elev.setConfigPathOverride(relCwdPathToConfig);
diff --git a/node_modules/@rocket/cli/src/RocketLint.js b/node_modules/@rocket/cli/src/RocketLint.js
index 60879ad..253d103 100755
--- a/node_modules/@rocket/cli/src/RocketLint.js
+++ b/node_modules/@rocket/cli/src/RocketLint.js
@@ -36,6 +36,7 @@ export class RocketLint {
   async lintCommand() {
     if (this.config.lintExecutesEleventyBefore) {
       await this.eleventy.write();
+
       // updated will trigger linting
     } else {
       await this.__lint();
@@ -56,6 +57,16 @@ export class RocketLint {
       continueOnError: true,
     });
 
+  // START APOLLOELEMENTS HACK
+    const { cp } = await import('fs/promises');
+    await cp(
+      new URL('../../../../docs/_merged_assets/', import.meta.url),
+      new URL('../../../../_site/_merged_assets/', import.meta.url), {
+        recursive: true,
+      }
+    );
+  // END APOLLOELEMENTS HACK
+
     const { errors, message } = await checkLinks.run();
     if (errors.length > 0) {
       if (this.config.command === 'start') {
diff --git a/node_modules/@rocket/cli/src/getPuppeteerBrowser.js b/node_modules/@rocket/cli/src/getPuppeteerBrowser.js
new file mode 100644
index 0000000..d37b81e
--- /dev/null
+++ b/node_modules/@rocket/cli/src/getPuppeteerBrowser.js
@@ -0,0 +1,8 @@
+import puppeteer from 'puppeteer';
+
+export async function getPuppeteerBrowser() {
+  return puppeteer.launch({
+    headless: true,
+    args: ['--no-sandbox', '--font-render-hinting=none']
+  });
+}
diff --git a/node_modules/@rocket/cli/src/normalizeConfig.js b/node_modules/@rocket/cli/src/normalizeConfig.js
index 7d81de6..4fc25d4 100644
--- a/node_modules/@rocket/cli/src/normalizeConfig.js
+++ b/node_modules/@rocket/cli/src/normalizeConfig.js
@@ -15,6 +15,7 @@ import { readConfig } from '@web/config-loader';
 import { RocketStart } from './RocketStart.js';
 import { RocketBuild } from './RocketBuild.js';
 import { RocketLint } from './RocketLint.js';
+import { getPuppeteerBrowser } from './getPuppeteerBrowser.js';
 
 import { fileURLToPath } from 'url';
 
@@ -51,6 +52,7 @@ export async function normalizeConfig(inConfig) {
     setupEleventyComputedConfig: [],
     setupCliPlugins: [],
     eleventy: () => {},
+    incremental: false,
     command: 'help',
     watch: true,
     createSocialMediaImages: true,
@@ -63,6 +65,8 @@ export async function normalizeConfig(inConfig) {
 
     ...inConfig,
 
+    puppeteerBrowser: inConfig.puppeteerBrowser ?? await getPuppeteerBrowser(),
+
     /** @type{RocketCliOptions['before11ty'][]} */
     __before11tyFunctions: [],
 
diff --git a/node_modules/@rocket/cli/src/shared/.eleventy.cjs b/node_modules/@rocket/cli/src/shared/.eleventy.cjs
index 77484cd..e5f922e 100644
--- a/node_modules/@rocket/cli/src/shared/.eleventy.cjs
+++ b/node_modules/@rocket/cli/src/shared/.eleventy.cjs
@@ -20,6 +20,10 @@ const defaultSetupUnifiedPlugins = [
 module.exports = function (eleventyConfig) {
   const config = getComputedConfig();
 
+  eleventyConfig.on('afterBuild', async () => {
+    await config.puppeteerBrowser?.close?.();
+  });
+
   const { pathPrefix, _inputDirCwdRelative, outputDevDir } = config;
 
   let metaPlugins = [