stof 0.8.16

A simple and embeddable data runtime.
Documentation
/*!
 * Project definitions & configurations.
 */
import '@cargo' as Rust;
import pkg '@github' as GitHub;

/// Cargo.toml definition.
Cargo cargo: {
    package: {
        name: 'stof'
        authors: [
            'CJ Cummings <cj@formata.io>'
        ]
        description: 'A simple and embeddable data runtime.'
        license: 'Apache-2.0'
        repository: 'https://github.com/dev-formata-io/stof'
        homepage: 'https://docs.stof.dev'
        keywords: [
            'stof',
            'language',
            'embedded',
            'interpreter',
            'document'
        ]
        categories: [
            'compilers',
            'data-structures',
            'development-tools'
        ]
    }

    Target lib: {
        crate-type: ['cdylib', 'lib']
        bench: false
        doctest: false
    }

    features: {
        default: ['basic']
        basic: ['stof_std', 'system', 'pkg']
        full: ['stof_std', 'system', 'pkg', 'image', 'docx', 'pdf', 'http']

        stof_std: []
        system: []
        pkg: ['dep:zip', 'dep:regex', 'dep:walkdir']
        image: ['dep:image']
        docx: ['dep:docx-rs']
        pdf: ['dep:lopdf', 'image']
        http: ['dep:reqwest', 'dep:tokio']
    }

    dependencies: {
        anyhow: 1.0.94
        base64: 0.22.1
        bincode: 1.3.3
        bytes: {
            version: 1.10.1
            features: ['serde']
        }
        colored: 2.1.0
        docx-rs: {
            version: 0.4.18
            optional: true
        }
        image: {
            version: 0.25.6
            features: ['serde']
            optional: true
        }
        lazy_static: 1.5.0
        markdown: {
            version: 1.0.0
            features: ['serde']
        }
        nanoid: 0.4.0
        lopdf: {
            version: 0.37.0
            features: ['serde']
            optional: true
        }
        regex: {
            version: 1.11.1
            optional: true
        }
        serde: {
            version: 1.0.219
            features: ['derive', 'rc']
        }
        serde_json: 1.0.14
        serde_yaml: 0.9.34
        toml: 0.8.19
        typetag: 0.2.20
        urlencoding: 2.1.3
        walkdir: {
            version: 2.5.0
            optional: true
        }
        zip: {
            version: 4.3.0
            optional: true
        }
        chrono: 0.4.41
        tokio: {
            version: 1.47.1
            features: ['full']
            optional: true
        }
        reqwest: {
            version: 0.12.23
            optional: true
        }
        rustc-hash: 2.1.1
        imbl: {
            version: 6.0.0
            features: ['serde', 'triomphe']
        }
        arcstr: {
            version: 1.2.0
            features: ['serde']
        }
        nom: 8.0.0
        parking_lot: {
            version: 0.12.4
            features: ['serde']
        }
    }
}

/// GitHub.
github: {
    funding: 'dev-formata-io'
    
    #[run]
    workflows: [
        {
            name: 'Rust'
            on: {
                push: {
                    branches: ['main']
                }
                pull_request: {
                    branches: ['main']
                }
            }
            env: {
                CARGO_TERM_COLOR: 'always'
            }
            jobs: {
                build: {
                    runs-on: 'ubuntu-latest'
                    steps: [
                        {
                            uses: 'actions/checkout@v4'
                        },
                        {
                            name: 'Build'
                            run: 'cargo build --verbose'
                        },
                        {
                            name: 'Run tests'
                            run: 'cargo test --verbose -- --nocapture'
                        }
                    ]
                }
            }
        } as GitHub.Workflow
    ]

    #[run]
    /// Generate GitHub FUNDING.yml.
    fn generate_funding_yaml() {
        const object = new { github: self.funding };
        const yaml = stringify('yaml', object);
        drop(object);
        fs.write('.github/FUNDING.yml', yaml);
    }
}

#[cargo]
/// Generate Cargo.toml file.
/// `stof run project.stof -a cargo`
async fn generate_cargo_toml() {
    const out = await Rust.Cargo.generate(self.cargo, 0.8.16, update = false);
    fs.write('Cargo.toml', out);
    pln('Cargo .. ok');
}

#[github]
/// Generate GitHub configurations.
/// `stof run project.stof -a github`
async fn generate_github() {
    self.github.run();
    pln('GitHub .. ok');
}

#[main]
/// Run everything.
/// `stof run project.stof`
fn main() {
    await [
        self.generate_cargo_toml(),
        self.generate_github(),
    ];
    pln('done');
}