From 72da9c0f20e981c62320bd3a286a0f7f6b946c1b Mon Sep 17 00:00:00 2001 From: redonkulus Date: Mon, 14 Mar 2022 15:44:15 -0700 Subject: [PATCH] refactor(site): pull pure files from npm install --- .github/workflows/deploy.yml | 2 -- package.json | 3 +-- site/lib/pure.js | 12 +++++++----- site/package-lock.json | 5 +++++ site/package.json | 6 ++++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 847817f..8355f21 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,8 +28,6 @@ jobs: npm ci git config --global user.name "${GH_NAME}" git config --global user.email "${GH_EMAIL}" - npm run prepare - cp -rf ./build/ ./site/static/css/pure/ cd site npm install npm run deploy diff --git a/package.json b/package.json index f97af28..4716dbd 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,7 @@ "scripts": { "lint": "eslint . --ext .js", "prepare": "grunt release", - "site:build": "npm run pretest && cd site && npm install && npm run build", - "site:start": "cd site && npm run start", + "start": "cd site && npm install && npm run start", "test": "grunt test && tap test/*.js --no-coverage" }, "files": [ diff --git a/site/lib/pure.js b/site/lib/pure.js index bf53050..56ecf8c 100644 --- a/site/lib/pure.js +++ b/site/lib/pure.js @@ -2,10 +2,12 @@ const crypto = require('crypto'); const fs = require('fs'); const gzip = require('gzip-size'); const path = require('path'); -const { version } = require('../../package.json'); -const pureDir = path.resolve(__dirname, '..', 'static', 'css', 'pure'); -const pureMin = fs.readFileSync(path.resolve(pureDir, 'pure-min.css'), 'utf8'); +// load pure package metadata +const pureDir = path.dirname(require.resolve('purecss')); +const { version } = require(path.resolve(pureDir, 'package.json')); +const pureFiles = path.resolve(pureDir, 'build'); +const pureMin = fs.readFileSync(path.resolve(pureFiles, 'pure-min.css'), 'utf8'); // use pure-min.css to determine site integrity hash const sriHash = crypto.createHash('sha384').update(pureMin, 'utf8').digest('base64'); @@ -15,7 +17,7 @@ module.exports.PURE_DOWNLOAD_SNIPPET = `