# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        TorstenDittmann OmniaWrite 1.3.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                omniawrite
revision            0

homepage            https://www.omniawrite.com/

description         OmniaWrite is a text editor engineered for creative \
                    writing.

long_description    OmniaWrite is a next-generation plain text editor \
                    engineered for creative writing. It is perfect for \
                    writing novels, lyrics, poems, essays, drafts and \
                    screenplays. Writing a good story is one of the most \
                    challenging things in life. But for many it is a dream \
                    worth pursuing. OmniaWrite doesn't help you create a \
                    novel out of nothing, but is a faithful companion at \
                    every step of your projects. Organisation, environment \
                    for concentrated work, export to all common file formats \
                    and much more.

categories          editors
license             Apache-2

maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  ea352c17848bd668d0f928fe5efde5787f2dd401 \
                    sha256  b161dd9771ff1daa093ccaf4ba55133688c8b4bc6a7e0a1a5305636dc64f8a52 \
                    size    1714655

depends_build       port:yarn

use_configure       no

build.env-append    CSC_IDENTITY_AUTO_DISCOVERY=false

post-extract {
    # Change the electron-builder target to build just the app bundle, and not
    # the .pkg file.
    reinplace "s|--macos pkg|--macos dir|g" ${worksrcpath}/package.json
}

build {
    # Set up JS dependencies
    system -W ${worksrcpath} "yarn --frozen-lockfile"

    # Build project
    system -W ${worksrcpath} "yarn run build"
    system -W ${worksrcpath} "yarn run svelte-build"
    system -W ${worksrcpath} "yarn run prepare:license"

    # Build electron app
    system -W ${worksrcpath} \
        "${build.env} yarn run electron-builder --mac --dir"
}

destroot {
    copy ${worksrcpath}/dist/mac/OmniaWrite.app ${destroot}${applications_dir}/
}

github.livecheck.regex {([0-9.]+)}
