view tasks.py @ 137:a8939c717015

still trying to get build right, but there are other update bugs too
author drewp@bigasterisk.com
date Sat, 06 May 2023 15:34:40 -0700
parents a6490559ce73
children 845ba03729f9
line wrap: on
line source

import os
from invoke import task  # pytype: disable=import-error


@task
def setup_js(ctx):
    if 0:  # only reasonable on bang,but dash tries to rebuild it
        ctx.run('pnpm install --dir=$PWD')


@task(pre=[setup_js])
def serve_demo(ctx):
    ctx.run('webfsd -Fp 8021')


@task(pre=[setup_js])
def build(ctx):
    ctx.run(f'pnpm run build', pty=True)


@task(pre=[setup_js])
def build_forever(ctx):
    ctx.run(f'pnpm run build_forever', pty=True)


@task(pre=[setup_js])
def test(ctx):
    ctx.run(f'pnpm run test', pty=True)


@task(pre=[setup_js])
def test_forever(ctx):
    ctx.run(f'pnpm run test_forever', pty=True)


@task
def release(ctx):
    ctx.run('pnpm whoami --registry https://bigasterisk.com/js')
    diffs = ctx.run('hg status')
    if diffs.stdout.strip():
        print(" ^^ commit these diffs first")
        return
    v = ctx.run('pnpm version minor').stdout.strip()
    ctx.run(f'hg commit --message "release {v}"')
    build(ctx)
    install_to_bigasterisk_lib(ctx, 'streamed-graph.*',
                               f'lib/streamed-graph/{v}/')
    # this fails with ENEEDAUTH:
    #ctx.run(f'pnpm publish --registry https://bigasterisk.com/js', pty=True)


def install_to_bigasterisk_lib(ctx, distFile, libPath):
    filesRoot = '/my/site/homepage/newsrc/files'
    outdir = f'{filesRoot}/{libPath}'
    ctx.run(f'mkdir -p {outdir}')
    ctx.run(f'cp dist/{distFile} {outdir}')
    print('rebuild bigasterisk:')
    ctx.run('cd /my/site/homepage; inv build')
    ctx.run(
        "curl -s -o/dev/null -w '%{url_effective} %{http_code} bytes=%{size_download}\n' "
        + "https://bigasterisk.com/" + libPath + distFile,
        pty=True)


@task
def dev(ctx):
    ctx.run('pnpm dev')


@task
def deps(ctx):
    ctx.run(
        'node_modules/.bin/depcruise --config .dependency-cruiser.js -T dot src | dot -Tsvg > deps.svg'
    )
    print(f"browse to file://{os.path.abspath('deps.svg')}")