Well, no, my little watchful static build engine called Chops is not even actually out. It’s not published, it’s not documented, it’s not even a proper NPM module. I use it via npm link and that gives npm (or Yarn) a fit of recursion.

Sure, the first milestone is done: Chops builds most of this blog. Takes markdown and jade (I refuse to call it pug because fuck the whole story) and creates html and xml for the rss. Styles and assets are still built with gulp, which is a little inconvenient.

But beside that, everything sucks. I mean, here’s an excerpt from my build script:

Chops.src('**/*', {cwd: Path.join(cfg.rootDir, cfg.sources.contents.path)})
    /* necessary defaults */
    .convert(page =>    Object.assign({
                            date: new Date(),
                            published: true,
                            title: 'Untitled'
                        }, page))
    /* category defaults to folder */
    .convert(page =>    Object.assign({}, page, {
        category:   page.category
                    || page.path && (page.path.dir)
                    || ''
    /* processing yfm */
    .convert(page =>    {
        const yfm = fm(page.content);
        return yfm.body
            ? Object.assign({}, page, yfm.attributes, {content: yfm.body})
            : page;
    /* markdown conversion */
    .convert(page =>    Object.assign({}, page, {
        content: md.render(page.content)
    /* excerpts */
    .convert(page => Object.assign({}, page, {
        excerpt: page.excerpt || u.extract1stHtmlParagraph(page.content)
    /* destination url */
    .convert(page =>    Object.assign({}, page, {
        url: pageUrlPlusFile(page)
    .render(templates, page => page.template || 'post')
    .write(Path.join(cfg.rootDir, 'build'))

Yeah, this is supposed to be a pretty low-level api that needs some nice wrapper, but that verbosity is only the tip of the iceberg.

Firstly, that low-level monster is as fragile as Golem, having too little runtime checks for its own safe functioning. It lets the user overwrite necessary data and can happily shit files outside of destination dir.

There’s no tests, nor is there a lot of places I want to test without refactoring them first. Things are too coupled and the whole design is dubious. I think I’m gonna have to modularize (and write tests for) the most obvious parts, and then localize the most dubious ones to make refactoring easier.

Man, does the above sounds like I’m an architect of a huge-ass project. Not the case. Here’s a report from sloc run against the typescript source:

---------- Result ------------

            Physical :  1326
              Source :  918
             Comment :  224
 Single-line comment :  94
       Block comment :  130
               Mixed :  44
               Empty :  228
               To Do :  2

Number of files read :  15


Furthermore. It’s nigh undebuggable. It’s all very nice and ambitious of me to think up an engine that watches for content/template changes and automatically rebuilds all the dependants, including the feeds, but catching bugs on that mama is a bitch. I’m going to need to log some history on the events themselves as, I presume, is customary in these circumstances.

And that’s still not the whole engine. Even the low-level api lacks much needed features, like the non-watch mode, for one.

Here I was a year ago, thinking I’d just do this one little project real quick and go on to do some frontend. Welp, back to work with me.