Start adopting Yarn workspaces (#985)

* Start adopting Yarn workspaces

My plan is to move the existing package into a workspace and then split
out the things that really ought to be their own packages. For example,
the demo site and the experiments really ought to be separate.

Fix lint command

* Use workspaces in CI

* Fix deploy for monorepo
This commit is contained in:
Jordan Eldredge 2020-05-17 22:12:17 -07:00 committed by GitHub
parent 50b25433fc
commit 975d712662
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
634 changed files with 3747 additions and 4198 deletions

View file

@ -1,40 +0,0 @@
const puppeteer = require("puppeteer");
// const DATA_URI = /url\([^)]+\)/g;
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// TODO: allow the skin to be passed in via the CLI.
try {
await page.goto(
'http://localhost:8080/#{"skinUrl":"/skins/base-2.91.wsz"}'
);
} catch (e) {
console.error(
"Error connecting to localhost:8080. Are you running the dev server?",
"\n\n",
e
);
await browser.close();
return;
}
// TODO: Wait for node to be ready
await new Promise((resolve) => setTimeout(resolve, 500));
try {
const css = await page.evaluate(
() => document.getElementById("webamp-skin").innerText
);
console.log(css);
} catch (e) {
console.error("Hit an error, putting a screenshot in ./error.png");
page.screenshot({ path: "./error.png" });
throw e;
} finally {
await browser.close();
}
// TODO: Extract non-CSS stuff
// TODO: Write to stdout
})();

View file

@ -1,9 +0,0 @@
const fs = require("fs");
const path = require("path");
const { parser } = require("winamp-eqf");
const presetsPath = path.join(__dirname, "../presets/winamp.q1");
const content = fs.readFileSync(presetsPath);
const presetObjects = parser(content);
console.log(JSON.stringify(presetObjects, null, " "));

View file

@ -1,37 +0,0 @@
const postcss = require("postcss");
const dataUriToBuffer = require("data-uri-to-buffer");
const imagemin = require("imagemin");
const imageminOptipng = require("imagemin-optipng");
const DATA_URL_REGEX = new RegExp(/url\((data:image\/png;base64,.+)\)/gi);
const DATA_URL_PROPS_REGEX = /^(background(?:-image)?)|(content)|(cursor)/;
async function optimizeDataUri(dataUri) {
const buffer = dataUriToBuffer(dataUri);
const optimized = await imagemin.buffer(buffer, {
use: [imageminOptipng()],
});
return `data:image/png;base64,${optimized.toString("base64")}`;
}
module.exports = postcss.plugin("postcss-optimize-data-uri-pngs", () => {
return async function (css) {
// walkDecls does not let us work async, so we collect the async work we
// need to do here, and await it at the end
const promisesFactories = [];
css.walkDecls(DATA_URL_PROPS_REGEX, (decl) => {
let matches;
// WTF JavaScript. This is the worst API for iterating RegEx matches.
while ((matches = DATA_URL_REGEX.exec(decl.value))) {
const [, dataUri] = matches;
promisesFactories.push(async () => {
decl.value = decl.value.replace(
dataUri,
await optimizeDataUri(dataUri)
);
});
}
});
await Promise.all(promisesFactories.map((p) => p()));
};
});

View file

@ -1,11 +0,0 @@
const fs = require("fs");
const postcss = require("postcss");
const plugin = require("./postcss-optimize-data-uri-pngs");
const css = fs.readFileSync("./css/base-skin.css", "utf8");
// This seems to timeout a lot in CI
it.skip("does something", async () => {
const result = await postcss([plugin({})]).process(css);
expect(result.css.length).toBeLessThan(css.length);
});