Repository: guybedford/chomp Branch: main Commit: 0164c9f72473 Files: 33 Total size: 278.1 KB Directory structure: gitextract__re7x5ob/ ├── .github/ │ └── workflows/ │ ├── release.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── Cargo.toml ├── LICENSE ├── README.md ├── chompfile.toml ├── docs/ │ ├── chompfile.md │ ├── cli.md │ ├── extensions.md │ └── task.md ├── node-chomp/ │ ├── README.md │ ├── index.js │ └── package.json ├── src/ │ ├── ansi_windows.rs │ ├── chompfile.rs │ ├── engines/ │ │ ├── cmd.rs │ │ ├── deno.rs │ │ ├── mod.rs │ │ └── node.rs │ ├── extensions.rs │ ├── http_client.rs │ ├── main.rs │ ├── server.rs │ └── task.rs └── test/ ├── chompfile.toml ├── fixtures/ │ ├── app.js │ ├── many/ │ │ ├── one/ │ │ │ └── config.yml │ │ └── two/ │ │ └── config.yml │ └── src/ │ ├── app.ts │ └── dep.ts └── unit/ └── ok-node.mjs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/release.yml ================================================ on: push: tags: '*' name: Create Release jobs: publish-crate: name: Publish to crates.io runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - run: cargo login ${CRATES_IO_TOKEN} env: CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - run: cargo build --release --locked - name: publish chomp run: cargo publish create-github-release: name: Create GitHub Release needs: publish-crate runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Create Release Notes uses: actions/github-script@v4.0.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | await github.request(`POST /repos/${{ github.repository }}/releases`, { tag_name: "${{ github.ref }}", generate_release_notes: true }); build: name: Build assets for ${{ matrix.os }} needs: create-github-release runs-on: ${{ matrix.os }} strategy: matrix: name: [ linux, windows, macos ] include: - name: linux os: ubuntu-latest artifact_name: chomp asset_name: chomp-linux asset_extension: .tar.gz - name: windows os: windows-latest artifact_name: chomp.exe asset_name: chomp-windows asset_extension: .zip - name: macos os: macos-latest artifact_name: chomp asset_name: chomp-macos asset_extension: .tar.gz steps: - uses: actions/checkout@v1 - name: Set env run: | RELEASE_VERSION=$(echo ${GITHUB_REF:10}) echo "asset_name=${{ matrix.asset_name }}-${RELEASE_VERSION}${{ matrix.asset_extension }}" >> $GITHUB_ENV shell: bash - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - name: Build run: cargo build --release --locked - name: Archive release shell: bash run: | cp "target/release/${{ matrix.artifact_name }}" "${{ matrix.artifact_name }}" if [ "${{ matrix.os }}" = "windows-latest" ]; then 7z a "${asset_name}" "${{ matrix.artifact_name }}" else tar czf "${asset_name}" "${{ matrix.artifact_name }}" fi - name: Upload binaries to release uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: chomp*${{ matrix.asset_extension }} file_glob: true tag: ${{ github.ref }} ================================================ FILE: .github/workflows/test.yml ================================================ name: Test on: push: branches: [ main ] pull_request: branches: [ main ] env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 jobs: build-ubuntu: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build run: cargo build --verbose - name: Set PATH run: echo "$(pwd)/target/debug:$PATH" >> $GITHUB_PATH - uses: actions/checkout@v3 with: repository: 'guybedford/chomp-extensions' path: 'chomp-extensions' - name: Run Core Tests run: chomp -c test/chompfile.toml test env: CHOMP_CORE: ../chomp-extensions - name: Run Template Tests run: chomp -c chomp-extensions/chompfile.toml test build-windows: runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: Install latest stable uses: actions-rs/toolchain@v1 with: toolchain: stable override: true components: cargo - name: Build run: cargo build --verbose - name: Set PATH run: echo echo "$(pwd)/target/debug" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - uses: actions/checkout@v3 with: repository: 'guybedford/chomp-extensions' path: 'chomp-extensions' - name: Run Core Tests run: chomp -c test/chompfile.toml test env: CHOMP_CORE: ../chomp-extensions - name: Run Template Tests run: chomp -c chomp-extensions/chompfile.toml test ================================================ FILE: .gitignore ================================================ node_modules target test/package.json package-lock.json sandbox test/output vendor ================================================ FILE: .gitmodules ================================================ ================================================ FILE: Cargo.toml ================================================ [package] name = "chompbuild" version = "0.3.0" authors = ["Guy Bedford "] edition = "2021" license = "Apache-2.0" repository = "https://github.com/guybedford/chomp/" homepage = "https://chompbuild.com/" keywords = ["make", "task", "runner", "javascript", "web"] categories = ["command-line-utilities", "development-tools", "web-programming"] readme = "README.md" description = "Make-like parallel task runner with a JS extension system" [[bin]] name = "chomp" path = "src/main.rs" [target.'cfg(target_os="windows")'.dependencies.winapi] version = "0.3" features = ["consoleapi", "errhandlingapi", "fileapi", "handleapi"] [dependencies] anyhow = "1" async-recursion = "1" capturing-glob = "0" base64 = "0.22" clap = "4" convert_case = "0.11" derivative = "2" dirs = "6" futures = "0" hyper = { version = "1", features = ["client", "http1", "http2"] } hyper-tls = "0.6" hyper-util = { version = "0.1", features = ["client-legacy", "tokio", "http1", "http2"] } http-body-util = "0.1" bytes = "1" lazy_static = "1" mime_guess = "2" notify = "8" notify-debouncer-mini = "0.7" num_cpus = "1" percent-encoding = "2" regex = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" serde_v8 = "0.181.0" sha2 = "0.11" tokio = { version = "1", features = ["full"] } tokio-stream = "0.1" tokio-util = "0.7" toml = "0.8" uuid = { version = "1", features = ["v4"] } v8 = "0.89" warp = { version = "0.4", features = ["server", "websocket"] } directories = "6" pathdiff = "0" ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # CHOMP [![Crates.io](https://img.shields.io/badge/crates.io-chompbuild-green.svg)](https://crates.io/crates/chompbuild) [![Discord](https://img.shields.io/badge/chat-on%20discord-green.svg?logo=discord)](https://discord.gg/5E9zrhguTy) Chomp is a frontend task runner with advanced features focused on _ease-of-use_ and _not getting in the way_! 1. An advanced task runner with a single command! 1. Easily adapt existing projects / task systems - no need for a rewrite. 1. You enable and manage advanced task runner features with single-line updates. Chomp is a great option for frontend projects where the goal is getting advanced task runner features (like smart caching) without complexity and overhead. ## One-line migration from npm scripts Chomp can import a project's established `package.json` scripts without breaking them, as it supports the same features: ```bash chomp --init --import-scripts ``` Now you can run your npm scripts using Chomp! > i.e `npm run ` becomes `chomp ` and behaves the same, and you can opt in to further features as needed. The only difference is, with Chomp — it's faster. And, with a few more tweaks, you can enable smart caching, parallelism, and more! ## What features does Chomp provide? Chomp is an advanced task runner. It provides features similar to [turbo](https://turbo.build/repo) and [nx](https://nx.dev/) but focuses on ease of use, *not monorepos. It's based on the same principles as traditional make files. ### Parallelism Chomp [runs tasks in parallel](./docs/task.md#serial-dependencies), based on an extecuted task's dependencies! ### Watch/Serve Chomp [watches any task](./docs/task.md#watched-rebuilds) by including a `--watch` or `--serve` option! Read more about the power of [`--watch`](./docs/task.md#watched-rebuilds) and [`--serve`](./docs/task.md#static-server). ### A JS extension system Chomp has a [JS extension system](./docs/extensions.md) that allows you to extend Chomp with your own custom tasks ### Smart caching Chomp [caches tasks](./docs/task.md#task-caching) based on task dependencies like other tasks or updated files. You don't have to worry about it! > \*Chomp works for monrepos but it's architected for ease of use and not getting in the way first. ## Install If you use [Cargo](https://rustup.rs/), run: ``` cargo install chompbuild ``` If you don't use Cargo, run: ``` npm install -g chomp ``` > Note: npm scripts add over 100ms to the script run time. Common platform binaries are also available for [all releases](https://github.com/guybedford/chomp/releases). To quickly set up Chomp in a GitHub Actions CI workflow, see the [Chomp GitHub Action](https://github.com/guybedford/chomp-action). ## Documentation * [CLI Usage](https://github.com/guybedford/chomp/blob/main/docs/cli.md) * [Chompfile Definitions](https://github.com/guybedford/chomp/blob/main/docs/chompfile.md) * [Task Definitions](https://github.com/guybedford/chomp/blob/main/docs/task.md) * [Extensions](https://github.com/guybedford/chomp/blob/main/docs/extensions.md) ## Getting Started ### Migrating from npm Scripts To convert an existing project using npm `"scripts"` to Chomp, run: ```sh $ chomp --init --import-scripts √ chompfile.toml created with 2 package.json script tasks imported. ``` or the shorter version: ```sh $ chomp -Ii √ chompfile.toml created with 2 package.json script tasks imported. ``` Then use `chomp ` instead of `npm run `, and enjoy the new features of task dependence, incremental builds, and parallelism! ### Hello World `chomp` works against a [`chompfile.toml`](https://github.com/guybedford/chomp/blob/main/docs/chompfile.md) [TOML configuration](https://toml.io/) in the same directory as the `chomp` command is run. Chomp builds up tasks as trees of files which depend on other files, then runs those tasks with [maximum parallelism](https://github.com/guybedford/chomp/blob/main/docs/task.md#task-dependence). For example, here's a task called `hello` which builds `hello.txt` based on the contents of `name.txt`, which itself is built by another command: chompfile.toml ```toml version = 0.1 [[task]] target = 'name.txt' run = ''' echo "No name.txt, writing one." echo "World" > name.txt ''' [[task]] name = 'hello' target = 'hello.txt' dep = 'name.txt' run = ''' echo "Hello $(cat name.txt)" > hello.txt ''' ``` with this file saved, the hello command will run all dependency commands before executing its own command: ```sh $ chomp hello 🞂 name.txt No name.txt, writing one. √ name.txt [4.4739ms] 🞂 hello.txt √ hello.txt [5.8352ms] $ cat hello.txt Hello World ``` Finally it populates the `hello.txt` file with the combined output. Subsequent runs use the mtime of the target files to determine what needs to be rerun. Rerunning the `hello` command will see that the `hello.txt` target is defined, and that the `name.txt` dependency didn't change, so it will skip running the command again: ```sh chomp hello ● name.txt [cached] ● hello.txt [cached] ``` Changing the contents of `name.txt` will then invalidate the `hello.txt` target only, not rerunning the `name.txt` command: ```sh $ echo "Chomp" > name.txt $ chomp hello ● name.txt [cached] hello.txt invalidated by name.txt 🞂 hello.txt √ hello.txt [5.7243ms] $ cat hello.txt Hello Chomp ``` The [`deps`](https://github.com/guybedford/chomp/blob/main/docs/task.md#task-dependence) array can be defined for targets, whose targets will then be run first with [invalidation based on target / deps mtime comparisons](https://github.com/guybedford/chomp/blob/main/docs/task.md#task-caching) per the standard Makefile approach. Powershell is used on Windows, while Bash is used on POSIX systems. Since both `echo` and `>` are defined on both systems, the examples above work cross-platform (Powershell is automatically put into UTF-8 mode for `>` to work similarly). Note that `&&` and `||` are not supported in Powershell, so multiline scripts and `;` are preferred instead. #### JS Tasks Alternatively we can use `engine = 'node'` or `engine = 'deno'` to write JavaScript in the `run` function instead: chompfile.toml ```toml version = 0.1 [[task]] target = 'name.txt' engine = 'node' run = ''' import { writeFile } from 'fs/promises'; console.log("No name.txt, writing one."); await writeFile(process.env.TARGET, 'World'); ''' [[task]] name = 'hello' target = 'hello.txt' deps = ['name.txt'] engine = 'node' run = ''' import { readFile, writeFile } from 'fs/promises'; const name = (await readFile(process.env.DEP, 'utf8')).trim(); await writeFile(process.env.TARGET, `Hello ${name}`); ''' ``` Tasks are run with maximum parallelism as permitted by the task graph, which can be controlled via the [`-j` flag](https://github.com/guybedford/chomp/blob/main/docs/cli.md#jobs) to limit the number of simultaneous executions. Using the [`--watch` flag](https://github.com/guybedford/chomp/blob/main/docs/cli.md#watch) watches all dependencies and applies incremental rebuilds over invalidations only. Or, using `chomp hello --serve` runs a [static file server](https://github.com/guybedford/chomp/blob/main/docs/task.md#static-server) with watched rebuilds. See the [task documentation](https://github.com/guybedford/chomp/blob/main/docs/task.md) for further details. #### Monorepos There is no first-class monorepo support in chomp, but some simple techniques can achieve the same result. For example, consider a monorepo where `packages/[pkgname]/chompfile.toml` defines per-package tasks. A base-level `chompfile.toml` could run the `test` task of all the sub-packages with the following `chompfile.toml`: ```toml [[task]] name = 'test' dep = 'packages/#/chompfile.toml' run = 'chomp -c $DEP test' ``` `chomp test` will then use [task interpolation](https://github.com/guybedford/chomp/blob/main/docs/task.md#task-interpolation) to run the multiple sub-package test tasks in parallel. A similar approach can also be used for a [basic unit testing](https://github.com/guybedford/chomp/blob/main/docs/task.md#testing). By adding [`serial = 'true'`](https://github.com/guybedford/chomp/blob/main/docs/task.md#serial-dependencies), the interpolation can be made to run in series rather than in parallel. Cross-project dependencies are [not currently supported](https://github.com/guybedford/chomp/issues/119). Instead, if `packages/a/chompfile.toml`'s build task depends on `packages/b/chompfile.toml`'s build task to run first, then `packages/a/chompfile.toml` might look like: ```toml [[task]] name = 'build' run = 'cargo build' dep = 'build:deps' [[task]] name = 'build:deps' run = 'chomp -c ../a build' ``` This would still be fast, so long as `packages/a/chompfile.toml`'s `build` task has its targets and dependencies properly configured to do zero work if the all target mtimes are greater than their dependencies. ### Extensions Extensions are able to register task templates for use in Chompfiles. Extensions are loaded using the `extensions` list, which can be any local or remote JS file: ```toml version = 0.1 extensions = [ "./local.js", "https://remote.com/extension.js" ] ``` A core extensions library is provided with useful templates for the JS ecosystem, with the short protocol `chomp:ext`, a shorthand for the `@chompbuild/extensions` package contents. A simple example is included below. _See the [@chompbuild/extensions package](https://github.com/guybedford/chomp-extensions) for extension descriptions and examples._ #### Example: TypeScript with SWC To compile TypeScript with the SWC template: ```toml version = 0.1 extensions = ['chomp@0.1:swc'] [[task]] name = 'build:typescript' template = 'swc' target = 'lib/##.js' deps = ['src/##.ts'] ``` In the above, all `src/**/*.ts` files will be globbed, have SWC run on them, and output into `lib/[file].js` along with their source maps. The `##` and `#` interpolation syntax is special because, unlike glob dependencies (which are also supported), there must be a 1:1 relationship between a dependency and its target. Only non-existent files, or files whose `src` mtimes are invalidated will be rebuilt. If SWC itself is updated, all files that depend on it will be re-built. Specific files or patterns can be built directly by name as well, skipping all other build work: ```sh chomp lib/main.js lib/dep.js 🞂 lib/dep.js 🞂 lib/app.js √ lib/dep.js [317.2838ms] √ lib/app.js [310.0831ms] ``` Patterns are also supported for building tasks by name or filename (the below two commands are equivalent): ```sh $ chomp lib/*.js $ chomp :build:* ``` To remove the template magic, run `chomp --eject` to convert the `chompfile.toml` into its untemplated form: ```sh $ chomp --eject √ chompfile.toml template tasks ejected ``` Resulting in the updated _chompfile.toml_: ```toml version = 0.1 [[task]] name = 'build:typescript' target = 'lib/##.js' dep = 'src/##.ts' stdio = 'stderr-only' run = 'node ./node_modules/@swc/cli/bin/swc.js $DEP -o $TARGET --no-swcrc --source-maps -C jsc.parser.syntax=typescript -C jsc.parser.importAssertions=true -C jsc.parser.topLevelAwait=true -C jsc.parser.importMeta=true -C jsc.parser.privateMethod=true -C jsc.parser.dynamicImport=true -C jsc.target=es2016 -C jsc.experimental.keepImportAssertions=true' ``` # License Apache-2.0 ================================================ FILE: chompfile.toml ================================================ version = 0.1 default-task = 'build' [[task]] name = 'build' deps = ['src/**/*.rs'] run = 'cargo build' [[task]] name = 'build:release' deps = ['src/**/*.rs'] run = 'cargo build --release --locked' [[task]] name = 'test' dep = 'build' cwd = 'test' run = '../target/debug/chomp test' [[task]] name = 'install' serial = true dep = 'build' run = 'cp ./target/[dD]ebug/chomp* ~/bin/' [[task]] name = 'inline-version' deps = ['Cargo.toml'] targets = ['src/main.rs', 'node-chomp/package.json'] engine = 'node' run = ''' import { readFileSync, writeFileSync } from 'fs'; const toml = readFileSync('Cargo.toml', 'utf8'); const [, version] = toml.match(/version\s*=\s*\"(\d+\.\d+\.\d+)\"/); const main = readFileSync('src/main.rs', 'utf8'); writeFileSync('src/main.rs', main.replace(/let version = "\d+.\d+.\d+/g, `let version = "${version}`)); const pjson = JSON.parse(readFileSync('node-chomp/package.json', 'utf8')); pjson.version = version; writeFileSync('node-chomp/package.json', JSON.stringify(pjson, null, 2)); ''' ================================================ FILE: docs/chompfile.md ================================================ # Chompfile Chomp projects are defined by a `chompfile.toml`, with Chompfiles defined using the [TOML configuration format](https://toml.io/). The default Chompfile is `chompfile.toml`, located in the same directory as the `chomp` binary is being run from. Custom configuration can be used via `chomp -c custom.toml` or `chomp -c ./nested/chompfile.toml`. All paths within a Chompfile are relative to the Chompfile itself regardless of the invocation CWD. ## Example To create a new Chomp project, create a new file called `chompfile.toml` and add the following lines: chompfile.toml ```toml version = 0.1 [[task]] name = 'build' run = 'echo "Chomp Chomp"' ``` In the command line, type `chomp build` or just `chomp` (_"build"_ is the default task when none is given): ```sh $ chomp 🞂 :build Chomp Chomp √ :build [6.3661ms] ``` to get the runner output. Every Chompfile must start with the `version = 0.1` version number, at least until the project stabilizes. See the [task documentation](tasks.md) for defining tasks. ## Chompfile Definitions The Chompfile supports the following definitions: chompfile.toml ```toml # Every Chompfile must start with the Chompfile version, currently 0.1 version = 0.1 # The default task name to run when `chomp` is run without any CLI arguments default_task = "test" # List of Chomp Extensions to load extensions = ["extension-path"] # Environment variables for all runs [env] ENV_VAR = "value" # Default environment variables to only set if not already for all runs [env-default] DEFAULT_VAR = "value" # Static server options for `chomp --serve` [server] # Static server root path, relative to the Chomp file root = "public" # Static server port port = 1010 # Default template options by registered template name # When multiple tasks use the same template, this avoids duplicated `[template-options]` at the task level [template-options.