diff --git a/README.md b/README.md index 347efa2ed1..18bd2e7945 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@

bud.js

- Frontend build tools combining the best parts of Symfony Encore and Laravel Mix + Configurable, extensible build tools for modern single and multi-page web applications

--- diff --git a/package.json b/package.json index 560e8b546b..d0bc8b35b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bud", "private": true, - "description": "⚡️ Lightning fast frontend build tools combining the best parts of Symfony Encore and Laravel Mix", + "description": "Configurable, extensible build tools for modern single and multi-page web applications", "engines": { "node": "18.16.1", "yarn": "1.22.19", diff --git a/sources/@repo/docs/package.json b/sources/@repo/docs/package.json index 6cc5c4e278..fb568fe419 100644 --- a/sources/@repo/docs/package.json +++ b/sources/@repo/docs/package.json @@ -1,7 +1,7 @@ { "name": "@repo/docs", "private": true, - "description": "A frontend build tooling framework combining the best parts of Symfony Encore and Laravel Mix", + "description": "Configurable, extensible build tools for modern single and multi-page web applications", "engines": { "node": "^16.3.0" }, diff --git a/sources/@repo/markdown-kit/readme/index.ts b/sources/@repo/markdown-kit/readme/index.ts index c1eddb8029..50da324d5a 100644 --- a/sources/@repo/markdown-kit/readme/index.ts +++ b/sources/@repo/markdown-kit/readme/index.ts @@ -3,12 +3,16 @@ import type {GrayMatterFile} from 'gray-matter' import {path, projectConfig} from '@repo/constants' import {Filesystem, json as Json} from '@roots/bud-support/filesystem' import globby from '@roots/bud-support/globby' +import {Logger} from '@roots/bud-support/logger' import matter from 'gray-matter' import {format} from 'prettier' import {templates} from './renderer/index.js' const fs = new Filesystem() +const logger = new Logger({ + logLevel: `info`, +}) type Chunks = Array | Promise> type File = GrayMatterFile @@ -33,9 +37,17 @@ const generateReadme = async (signifier: string) => { path(`sources`, signifier, `docs`, `*.{md,mdx}`), ).then( async files => - await files.sort().reduce(async (files, path) => { - const body = await fs.read(path, `utf8`) - return [...(await files), matter(body)] + await files.sort().reduce(async (accumulator, path, i) => { + logger.log(`writing ${signifier} ${i + 1}/${files.length}`) + const body = await fs.read(path, `utf8`).catch(error => { + logger.error(error.message) + }) + logger.log( + `${signifier} ${i + 1}/${files.length} body is ${ + body.length + } characters`, + ) + return [...(await accumulator), matter(body)] }, Promise.resolve([])), ) @@ -55,7 +67,7 @@ const generateReadme = async (signifier: string) => { await fs.write( path(`sources`, signifier, `README.md`), - format(templates.core(data), {parser: `markdown`}), + await format(templates.core(data), {parser: `markdown`}), ) } @@ -107,5 +119,13 @@ const data = { ...(await getProps(`@roots/bud`)), name: `bud.js`, } -const readme = format(templates.root(data), {parser: `markdown`}) -await fs.write(outputPath, readme) +const body = templates.root(data) +logger.log(`repo readme.md is ${body.length} characters`) +const formatted = await format(templates.root(data), { + parser: `markdown`, +}).catch(error => logger.error(`repo readme.md`, error.message)) +logger.log(formatted) +await fs + .write(outputPath, formatted) + .catch(error => logger.error(`repo readme.md`, error.message)) + .finally(() => logger.log(`Wrote repo readme.md`)) diff --git a/sources/@repo/markdown-kit/readme/renderer/handlebars.ts b/sources/@repo/markdown-kit/readme/renderer/handlebars.ts index fffdcc2e33..d341321125 100644 --- a/sources/@repo/markdown-kit/readme/renderer/handlebars.ts +++ b/sources/@repo/markdown-kit/readme/renderer/handlebars.ts @@ -27,8 +27,8 @@ handlebars.registerHelper(`dotPath`, function (context, options) { return `${options.fn(this).replace(/\./, options.data.root.name)}` }) -handlebars.registerHelper(`raw`, function (options) { - return options.fn(this) +handlebars.registerHelper(`raw`, function (context) { + return context.fn(this) }) export {handlebars, Handlebars} diff --git a/sources/@repo/yarn-plugin-bud/sources/command/docs.build.ts b/sources/@repo/yarn-plugin-bud/sources/command/docs.build.ts index 9d7491c700..85d9da36e9 100644 --- a/sources/@repo/yarn-plugin-bud/sources/command/docs.build.ts +++ b/sources/@repo/yarn-plugin-bud/sources/command/docs.build.ts @@ -52,6 +52,7 @@ export class Docs extends Command { `compiled/cli-examples/index.js`, ]) .catch(this.catch), + this.cli .run([ `workspace`, @@ -61,6 +62,7 @@ export class Docs extends Command { `compiled/releases/index.js`, ]) .catch(this.catch), + this.cli .run([ `workspace`, diff --git a/sources/@roots/bud-support/src/logger/index.ts b/sources/@roots/bud-support/src/logger/index.ts index 5f37abc5a5..35755cc1a7 100644 --- a/sources/@roots/bud-support/src/logger/index.ts +++ b/sources/@roots/bud-support/src/logger/index.ts @@ -27,25 +27,34 @@ class Logger { /** * Class constructor */ - public constructor(public options: SignaleOptions) { - if (args.log === false) this.options.disabled = true - options.logLevel = args.verbose ? `info` : args.log ? `log` : `warn` + public constructor(public options: SignaleOptions = {}) { + if (args.log === false || options?.disabled === true) + this.options.disabled = true if (process.env) { - this.options.secrets = Object.entries(process.env) - .filter( - ( - entry: [string, string | undefined], - ): entry is [string, string] => - !isUndefined(entry[1]) && entry[0].includes(`SECRET`), - ) - .map(([k, v]): string => v) + this.options.secrets = + options?.secrets ?? + Object.entries(process.env) + .filter( + ( + entry: [string, string | undefined], + ): entry is [string, string] => + !isUndefined(entry[1]) && entry[0].includes(`SECRET`), + ) + .map(([k, v]): string => v) } this.instance = new Signale.Signale(this.options) this.instance.config({displayLabel: false}) - if (args.verbose) this.verbose = true - if (args.log) this.enabled = true + + if (args.verbose || this.options.logLevel === `info`) + this.verbose = true + if ( + args.log || + (this.options.logLevel && + [`info`, `log`].includes(this.options.logLevel)) + ) + this.enabled = true if (args.silent) this.enabled = false } diff --git a/sources/@roots/bud-wordpress-theme-json/README.md b/sources/@roots/bud-wordpress-theme-json/README.md index fbaa726d6b..8f04c19b98 100644 --- a/sources/@roots/bud-wordpress-theme-json/README.md +++ b/sources/@roots/bud-wordpress-theme-json/README.md @@ -61,7 +61,7 @@ bud.wptheme theme .set("typography.customFontSizes", true) .set("typography.fontWeight", false) - .merge("spacing.units", ["px", "%", "em"]) + .merge("spacing.units", ["px", "%", "em"]), ) .enable(); ``` diff --git a/sources/@roots/bud/README.md b/sources/@roots/bud/README.md index 53a173b07e..d2fe8aacb6 100644 --- a/sources/@roots/bud/README.md +++ b/sources/@roots/bud/README.md @@ -9,7 +9,7 @@

@roots/bud

- Frontend build tools combining the best parts of Symfony Encore and Laravel Mix + Configurable, extensible build tools for modern single and multi-page web applications

--- diff --git a/sources/@roots/bud/package.json b/sources/@roots/bud/package.json index 266fe92f19..97d65ecbd9 100644 --- a/sources/@roots/bud/package.json +++ b/sources/@roots/bud/package.json @@ -1,7 +1,7 @@ { "name": "@roots/bud", "version": "0.0.0", - "description": "Frontend build tools combining the best parts of Symfony Encore and Laravel Mix", + "description": "Configurable, extensible build tools for modern single and multi-page web applications", "engines": { "node": ">=16.0.0" }, diff --git a/sources/create-bud-app/src/tasks/write.bud.config.ts b/sources/create-bud-app/src/tasks/write.bud.config.ts index 85d8bac81b..bb03e9b924 100644 --- a/sources/create-bud-app/src/tasks/write.bud.config.ts +++ b/sources/create-bud-app/src/tasks/write.bud.config.ts @@ -40,7 +40,7 @@ export default async function writeConfigTask(command: CreateCommand) { await command.fs.write( `bud.config.ts`, - formatSource(result, {parser: `typescript`}), + await formatSource(result, {parser: `typescript`}), ) spinner.succeed() diff --git a/sources/create-bud-app/src/tasks/write.eslint.config.ts b/sources/create-bud-app/src/tasks/write.eslint.config.ts index edc869b67f..5682433e1d 100644 --- a/sources/create-bud-app/src/tasks/write.eslint.config.ts +++ b/sources/create-bud-app/src/tasks/write.eslint.config.ts @@ -19,36 +19,36 @@ export default async function writeStylelintConfigTask( ) } - try { - const configExtends = [`@roots/eslint-config`] + const configExtends = [`@roots/eslint-config`] - /** babel syntax */ - command.support.includes(`babel`) && - configExtends.push(`@roots/eslint-config/babel`) + /** babel syntax */ + command.support.includes(`babel`) && + configExtends.push(`@roots/eslint-config/babel`) - /** ts syntax */ - ;(command.support.includes(`typescript`) || - command.support.includes(`swc`)) && - configExtends.push(`@roots/eslint-config/typescript`) + /** ts syntax */ + ;(command.support.includes(`typescript`) || + command.support.includes(`swc`)) && + configExtends.push(`@roots/eslint-config/typescript`) - /** react syntax */ - command.support.includes(`react`) && - configExtends.push(`@roots/eslint-config/react`) + /** react syntax */ + command.support.includes(`react`) && + configExtends.push(`@roots/eslint-config/react`) - /** wordpress rules */ - command.support.includes(`wordpress`) && - configExtends.push(`@roots/eslint-config/wordpress`) + /** wordpress rules */ + command.support.includes(`wordpress`) && + configExtends.push(`@roots/eslint-config/wordpress`) - const source = await command.fs.read( - join(command.createRoot, `templates`, `eslint.config.js.hbs`), - `utf8`, - ) + const source = await command.fs.read( + join(command.createRoot, `templates`, `eslint.config.js.hbs`), + `utf8`, + ) + try { const template = templateEngine.compile(source) const result = template({extends: configExtends}) - await command.fs.write(`eslint.config.js`, formatSource(result)) + await command.fs.write(`eslint.config.js`, await formatSource(result)) } catch (error) { spinner.fail() throw error diff --git a/sources/create-bud-app/src/tasks/write.prettier.config.ts b/sources/create-bud-app/src/tasks/write.prettier.config.ts index 4a150fed1b..2b173103d6 100644 --- a/sources/create-bud-app/src/tasks/write.prettier.config.ts +++ b/sources/create-bud-app/src/tasks/write.prettier.config.ts @@ -29,7 +29,7 @@ export default async function writeStylelintConfigTask( const result = template({}) try { - await command.fs.write(`.prettierrc.cjs`, formatSource(result)) + await command.fs.write(`.prettierrc.cjs`, await formatSource(result)) } catch (error) { spinner.fail() throw error diff --git a/sources/create-bud-app/src/tasks/write.stylelint.config.ts b/sources/create-bud-app/src/tasks/write.stylelint.config.ts index 17177b62c5..8ee7be294e 100644 --- a/sources/create-bud-app/src/tasks/write.stylelint.config.ts +++ b/sources/create-bud-app/src/tasks/write.stylelint.config.ts @@ -45,7 +45,10 @@ export default async function writeStylelintConfigTask( const result = template({extends: configExtends}) - await command.fs.write(`stylelint.config.cjs`, formatSource(result)) + await command.fs.write( + `stylelint.config.cjs`, + await formatSource(result), + ) } catch (error) { spinner.fail() throw error diff --git a/sources/create-bud-app/src/tasks/write.tsconfig.ts b/sources/create-bud-app/src/tasks/write.tsconfig.ts index 668ef33c63..30210885bc 100644 --- a/sources/create-bud-app/src/tasks/write.tsconfig.ts +++ b/sources/create-bud-app/src/tasks/write.tsconfig.ts @@ -51,7 +51,7 @@ export default async function writeTsConfig(command: CreateCommand) { await command.fs.write( `tsconfig.json`, - formatSource(source, {parser: `json`}), + await formatSource(source, {parser: `json`}), ) } catch (error) { spinner.fail() diff --git a/sources/create-bud-app/src/utilities/formatSource.ts b/sources/create-bud-app/src/utilities/formatSource.ts index bb96cd0368..5401f14de2 100644 --- a/sources/create-bud-app/src/utilities/formatSource.ts +++ b/sources/create-bud-app/src/utilities/formatSource.ts @@ -2,8 +2,8 @@ import type {Options} from 'prettier' import {format} from 'prettier' -export default (code: string, options: Partial = {}) => { - return format(code, { +export default async (code: string, options: Partial = {}) => { + return await format(code, { bracketSpacing: false, parser: `babel`, printWidth: 75,