Compare commits

..

1 Commits

5 changed files with 1088 additions and 971 deletions

@ -230,4 +230,3 @@ The hypothetical commands `show w' and `show c' should show the appropriate part
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.

@ -1,3 +1,3 @@
# webby
A small static website builder written in typescript for learning purposes.
A small static website builder written in javascript for learning purposes.

1964
package-lock.json generated

File diff suppressed because it is too large Load Diff

73
src/bin.mts Normal file

@ -0,0 +1,73 @@
#!/usr/bin/env node
import type { WebbyAsyncOptions } from './index.js'
import { loadPackageJson } from 'package-json-from-dist'
const { version } = loadPackageJson(import.meta.url)
const runHelpForUsage = () => console.error('run `webby --help` for usage information')
export const help = `webby version ${version}
Usage: webby <path to webby.conf.js file>
Builds your website with the information from the webby.conf.js file.
Options:
-h --help Display this usage info
--version Display version
`
import { parse, relative, resolve } from 'path'
const cwd = process.cwd()
const main = async (...args: string[]) => {
if (process.env.__WEBBY_TESTING_BIN_FAIL__ === '1') {
throw new Error('simulated Webby failure')
}
const opt: WebbyAsyncOptions = {}
const paths: string[] = []
/*
let impl: (
path: string | string[],
opt?: WebbyAsyncOptions,
) => Promise<boolean> = webby
*/
for (const arg of args) {
if (arg === '-h' || arg === '--help') {
console.log(help)
return 0
} else if (arg === '--version') {
console.log(version)
return 0
} else {
console.error(`unknown option: ${arg}`)
runHelpForUsage()
return 1
}
}
if (!paths.length) {
console.error('webby: must provide a path to build')
runHelpForUsage()
return 1
}
return 0
}
main.help = help
main.version = version
export default main
if (process.env.__TESTING_WEBBY_BIN__ !== '1') {
const args = process.argv.slice(2)
main(...args).then(
code => process.exit(code),
er => {
console.error(er)
process.exit(1)
},
)
}

@ -1 +1,18 @@
console.log("This is Webby - A small static website builder written in TypeScript for learning purposes.")
import { Dirent, Stats } from 'fs'
import { GlobOptions } from 'glob'
export interface WebbyAsyncOptions {
preserveRoot?: boolean
tmp?: string
maxRetries?: number
retryDelay?: number
backoff?: number
maxBackoff?: number
signal?: AbortSignal
glob?: boolean | GlobOptions
filter?:
| ((path: string, ent: Dirent | Stats) => boolean)
| ((path: string, ent: Dirent | Stats) => Promise<boolean>)
}
//console.log("This is Webby - A small static website builder written in TypeScript for learning purposes.")