Skip to content

Commit

Permalink
neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Jun 8, 2024
1 parent 2215770 commit c469b0f
Show file tree
Hide file tree
Showing 56 changed files with 872 additions and 833 deletions.
33 changes: 16 additions & 17 deletions bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-disable dot-notation */

// @ts-ignore
import { readFile } from 'node:fs/promises'
Expand Down Expand Up @@ -41,47 +40,47 @@ const options = {
type: 'string',
short: 's',
default: 'src',
help: 'path to source directory'
help: 'path to source directory',
},
dest: {
type: 'string',
short: 'd',
default: 'public',
help: 'path to build destination directory'
help: 'path to build destination directory',
},
ignore: {
type: 'string',
short: 'i',
help: 'comma separated gitignore style ignore string'
help: 'comma separated gitignore style ignore string',
},
noEsbuildMeta: {
type: 'boolean',
help: 'skip writing the esbuild metafile to disk'
help: 'skip writing the esbuild metafile to disk',
},
eject: {
type: 'boolean',
short: 'e',
help: 'eject the top bun default layout, style and client into the src flag directory'
help: 'eject the top bun default layout, style and client into the src flag directory',
},
watch: {
type: 'boolean',
short: 'w',
help: 'build, watch and serve the site build'
help: 'build, watch and serve the site build',
},
'watch-only': {
type: 'boolean',
help: 'watch and build the src folder without serving'
help: 'watch and build the src folder without serving',
},
help: {
type: 'boolean',
short: 'h',
help: 'show help'
help: 'show help',
},
version: {
type: 'boolean',
short: 'v',
help: 'show version information'
}
help: 'show version information',
},
}

const { values: argv } = parseArgs({ options })
Expand All @@ -99,7 +98,7 @@ async function run () {
options,
name: pkg.name,
version: pkg.version,
exampleFn: ({ name }) => ' ' + `Example: ${name} --src website --dest public\n`
exampleFn: ({ name }) => ' ' + `Example: ${name} --src website --dest public\n`,
})

process.exit(0)
Expand All @@ -117,7 +116,7 @@ async function run () {
if (argv['eject']) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
})

const localPkg = await packageDirectory({ cwd: src })
Expand Down Expand Up @@ -170,7 +169,7 @@ top-bun eject actions:
await Promise.all([
copyFile(defaultLayoutPath, join(src, targetLayoutPath)),
copyFile(defaultGlobalStylePath, join(src, targetGlobalStylePath)),
copyFile(defaultGlobalClientPath, join(src, targetGlobalClientPath))
copyFile(defaultGlobalClientPath, join(src, targetGlobalClientPath)),
])

await addPackageDependencies(
Expand All @@ -179,8 +178,8 @@ top-bun eject actions:
dependencies: {
'mine.css': mineVersion,
'uhtml-isomorphic': uhtmlVersion,
'highlight.js': highlightVersion
}
'highlight.js': highlightVersion,
},
})

console.log('Done ejecting files!')
Expand Down Expand Up @@ -240,7 +239,7 @@ top-bun eject actions:
}
} else {
const initialResults = await topBun.watch({
serve: !argv['watch-only']
serve: !argv['watch-only'],
})
console.log(tree(generateTreeData(cwd, src, dest, initialResults)))
if (initialResults?.warnings?.length > 0) {
Expand Down
1,352 changes: 696 additions & 656 deletions dependencygraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import neostandard from 'neostandard'

export default neostandard({
ignores: [
'test-cases/build-errors/src/**/*.js',
'test-cases/page-build-errors/src/**/*.js',
],
})
2 changes: 1 addition & 1 deletion examples/basic/src/global.vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

export default async function () {
return {
siteName: 'top-bun basic'
siteName: 'top-bun basic',
}
}
2 changes: 1 addition & 1 deletion examples/basic/src/js-page/loose-assets/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export default async function JSPage () {
}

export const vars = {
title: 'JS Page with loose assets'
title: 'JS Page with loose assets',
}
2 changes: 1 addition & 1 deletion examples/basic/src/js-page/loose-assets/shared-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// when a js page or client bundle imports them.

export default {
shared: 'data'
shared: 'data',
}
4 changes: 2 additions & 2 deletions examples/basic/src/js-page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from 'uhtml-isomorphic'

export default async function JSPage ({
siteName,
title
title,
}) {
return html`
<p>The js page is the only page type that can render the body with the set varibles.</p>
Expand All @@ -25,5 +25,5 @@ export default async function JSPage ({
}

export const vars = {
title: 'JS Page'
title: 'JS Page',
}
2 changes: 1 addition & 1 deletion examples/basic/src/md-page/page.vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// Here we see that the title is overridden from the variables file.

export default {
title: 'Nested Markdown Title From Var File'
title: 'Nested Markdown Title From Var File',
}
4 changes: 2 additions & 2 deletions examples/basic/src/root.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { html, render } from 'uhtml-isomorphic'
export default async function RootLayout ({
vars: {
title,
siteName
siteName,
},
scripts,
styles,
children
children,
}) {
return render(String, html`
<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion examples/nested-dest/global.vars.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
defaultStyle: false,
siteName: 'nested top-bun example'
siteName: 'nested top-bun example',
}
4 changes: 2 additions & 2 deletions examples/string-layouts/src/root.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
export default async function RootLayout ({
vars: {
title,
siteName
siteName,
},
scripts,
styles,
children
children,
}) {
return /* html */`
<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion examples/tonic-components/src/components/hello-world.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class HelloWorld extends Tonic {

const {
greetings,
lang
lang,
} = this.props

return this.html`
Expand Down
2 changes: 1 addition & 1 deletion examples/tonic-components/src/global.vars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default async function () {
return {
siteName: 'Example site with tonic'
siteName: 'Example site with tonic',
}
}
4 changes: 2 additions & 2 deletions examples/tonic-components/src/root.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default async function RootLayout ({
title,
siteName,
scripts,
head
head,
},
styles,
children
children,
}) {
return /* html */`
<!DOCTYPE html>
Expand Down
4 changes: 2 additions & 2 deletions examples/tonic-components/src/ssr-page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import jsdom from 'jsdom'
const { JSDOM } = jsdom

const page = await (new MainComponent({
timestamp: 1611695921286
timestamp: 1611695921286,
})).preRender()

console.log({ page })
Expand All @@ -18,5 +18,5 @@ const head = dom.window.document.querySelector('head')
export default () => `<main-component>${body.innerHTML}</main-component>`

export const vars = {
head: head.innerHTML
head: head.innerHTML,
}
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class TopBun {
* @return {Promise<Results>}
*/
async watch ({
serve
serve,
} = {
serve: true
serve: true,
}) {
if (this.watching) throw new Error('Already watching.')

Expand All @@ -116,7 +116,7 @@ export class TopBun {
this.#browserSyncServer = bs
bs.watch(basename(this.#dest), { ignoreInitial: true }).on('change', bs.reload)
bs.init({
server: this.#dest
server: this.#dest,
})
}

Expand All @@ -142,7 +142,7 @@ export class TopBun {

const watcher = chokidar.watch(`${this.#src}/**/*.+(js|css|html|md)`, {
ignored: anymatch,
persistent: true
persistent: true,
})

this._watcher = watcher
Expand Down
14 changes: 7 additions & 7 deletions lib/build-esbuild/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function buildEsbuild (src, dest, siteData, _opts) {

const browserVars = await resolveVars({
varsPath: siteData?.globalVars?.filepath,
key: 'browser'
key: 'browser',
})

/** @type {{
Expand Down Expand Up @@ -88,12 +88,12 @@ export async function buildEsbuild (src, dest, siteData, _opts) {
target: [
'esnext',
'chrome118',
'safari17'
'safari17',
],
define,
metafile: true,
entryNames: '[dir]/[name]-[hash]',
chunkNames: 'chunks/[ext]/[name]-[hash]'
chunkNames: 'chunks/[ext]/[name]-[hash]',
}

try {
Expand Down Expand Up @@ -180,17 +180,17 @@ export async function buildEsbuild (src, dest, siteData, _opts) {
buildResults,
outputMap,
// @ts-ignore This is fine
buildOpts
}
buildOpts,
},
}
} catch (err) {
return {
type: 'esbuild',
errors: [
new Error('Error building JS+CSS with esbuild', { cause: err })
new Error('Error building JS+CSS with esbuild', { cause: err }),
],
warnings: [],
report: {}
report: {},
}
}
}
Loading

0 comments on commit c469b0f

Please sign in to comment.