add alpha flag to build and remove certain files from it

This commit is contained in:
Cory LaViska
2024-06-18 12:56:55 -04:00
parent dba74b58ba
commit a41c917d17
3 changed files with 26 additions and 3 deletions

View File

@@ -14,9 +14,16 @@ import { getComponents } from './_utils/manifest.js';
import process from 'process';
const packageData = JSON.parse(await readFile('./package.json', 'utf-8'));
const isAlpha = process.argv.includes('--alpha');
const isDeveloping = process.argv.includes('--develop');
export default function (eleventyConfig) {
// NOTE - alpha setting removes certain pages
if (isAlpha) {
eleventyConfig.ignores.add('**/components/page.md');
eleventyConfig.ignores.add('**/experimental/**');
}
// Add template data
eleventyConfig.addGlobalData('package', packageData);

View File

@@ -44,6 +44,8 @@
"scripts": {
"start": "node scripts/build.js --develop",
"build": "node scripts/build.js",
"build:alpha": "node scripts/build.js --alpha",
"start:alpha": "node scripts/build.js --alpha --develop",
"create": "plop --plopfile scripts/plop/plopfile.js",
"prepare": "npm i --ignore-scripts && npx playwright install",
"test": "web-test-runner --group default",

View File

@@ -20,6 +20,7 @@ import process from 'process';
const __dirname = dirname(fileURLToPath(import.meta.url));
const isDeveloping = process.argv.includes('--develop');
const isAlpha = process.argv.includes('--alpha');
const spinner = ora({ text: 'Web Awesome', color: 'cyan' }).start();
const packageData = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf-8'));
const version = JSON.stringify(packageData.version.toString());
@@ -97,7 +98,16 @@ function generateReactWrappers() {
async function generateStyles() {
spinner.start('Copying stylesheets');
await copy(join(rootDir, 'src/themes'), join(distDir, 'themes'), { overwrite: true });
// NOTE - alpha setting omits all stylesheets except for these because we use them in the docs
if (isAlpha) {
await copy(join(rootDir, 'src/themes/applied.css'), join(distDir, 'themes/applied.css'), { overwrite: true });
await copy(join(rootDir, 'src/themes/color_standard.css'), join(distDir, 'themes/color_standard.css'), {
overwrite: true
});
await copy(join(rootDir, 'src/themes/default.css'), join(distDir, 'themes/default.css'), { overwrite: true });
} else {
await copy(join(rootDir, 'src/themes'), join(distDir, 'themes'), { overwrite: true });
}
spinner.succeed();
@@ -107,7 +117,7 @@ async function generateStyles() {
/**
* Runs TypeScript to generate types.
*/
function generateTypes() {
async function generateTypes() {
spinner.start('Running the TypeScript compiler');
try {
@@ -188,8 +198,12 @@ async function regenerateBundle() {
async function generateDocs() {
spinner.start('Writing the docs');
const args = [];
if (isAlpha) args.push('--alpha');
if (isDeveloping) args.push('--develop');
// 11ty
const output = (await runScript(join(__dirname, 'docs.js'), isDeveloping ? ['--develop'] : undefined))
const output = (await runScript(join(__dirname, 'docs.js'), args))
// Cleanup the output
.replace('[11ty]', '')
.replace(' seconds', 's')