Giter VIP home page Giter VIP logo

tic-bundle's Introduction

tic-bundle logo

license GPLv3 npm ci

tic-bundle

Simple CLI tool for bundling TIC-80 cartridge code. Supports any language!

Content

Installation

// Yarn
yarn add tic-bundle --dev

// Npm
npm i tic-bundle --save-dev

Example

Config

{
  "files": ["ui.js", "main.js"],
  "assets": ["assets.js"]
}

Input

src/main.js

function TIC() {

};

// <TILES>
// 000:0100000010100000010000000000000000000000000000000000000000000000
// </TILES>

src/ui.js

function ui() {
  return 'ui';
};

src/assets.js

// script: js

// <TILES>
// 000:0100000010100000010000000000000000000000000000000000000000000000
// </TILES>

Output

build.js

// script: js

function ui() {
  return 'ui';
};

function TIC() {

};

// <TILES>
// 000:0100000010100000010000000000000000000000000000000000000000000000
// </TILES>

CLI

package.json

{
  "scripts": {
    "watch": "tic-bundle"
  }
}

CLI options

  • -r / --root - Root folder
  • -w / --wait - Wait interval
  • -c / --config - Path to config file
  • -o / --output - Bundled file output path
  • -n / --name - Bundle file name
  • -f / --file - Bundle file extension
  • -s / --script - Language
  • -b / --build - Build

Configuration

tic-bundle supports config files. By default, tic-bundle looks for a .ticbundle.js file in the current directory, but an alternative location can be specified using -c <file> or --config <file>.

The specificity is as folows:

  • .ticbundle.js
  • .ticbundle.json
  • CLI
  • Default config

Default config

{
  root: 'src',
  wait: 200,
  metadata: {
    title: null,
    author: null,
    desc: null,
    script: 'js',
    input: null,
    saveid: null
  },
  output: {
    path: './',
    extension: 'js',
    name: 'build'
  },
  files: [],
  assets: [],
  after: null
}

Options

  • root (default src) - Folder to watch.
  • wait (default 200) - Chokidar awaitWriteFinish.stabilityThreshold
  • metadata - Cartridge metadata
  • metadata.title - The name of the cart.
  • metadata.author - The name of the developer.
  • metadata.description - Optional description of the game.
  • metadata.script (default js) - Used scripting language.
  • metadata.input - Selects gamepad, mouse or keyboard input source.
  • metadata.saveid - Allows save data to be shared within multiple games on a copy of TIC.
  • output.path (default ./) - Bundled file output path.
  • output.extension (default js) - Bundle file output extension
  • output.name (default build) - Bundled file name.
  • files - Files to bundle. Asset data will be stripped (graphics data, sprite data, etc.) Files will be ordered by index (top first, bottom last).
  • assets - Assets to bundle. Code data will be stripped. Assets will be ordered by index (top first, bottom last) and are always places below files.
  • after - Run after generating the bundle, this can be used to further modify the bundle.

Babel

after can be used to transform the bundled code. A common use-case for js is transforming ES6 syntax to ES5.

Example

.ticbundle.js

module.exports = {
  after: bundle => {
    const { code } = require('@babel/standalone').transform(bundle, {
      plugins: [require('@babel/plugin-transform-arrow-functions')]
    });
    
    return  code;
  }
};

Donating

ko-fi

tic-bundle's People

Contributors

chronodave avatar dependabot[bot] avatar kyratech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tic-bundle's Issues

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

Hi, probably me being dim but I'm getting this error when running npm run watch.

.ticbundle.json

{
   "root":"src",
   "wait":200,
   "metadata":{
      "title":"foo",
      "author":"[email protected]",
      "desc":"foo",
      "script":"wren",
      "input":null,
      "saveid":null
   },
   "output":{
      "path":"./",
      "extension":"wren",
      "name":"build"
   },
   "files":[
      "bundle.wren",
      "player.wren"
   ],
   "after":null
}

package.json

{
  "scripts": {
    "watch": "tic-bundle"
  },
  "devDependencies": {
    "tic-bundle": "^3.2.0"
  }
}

error:

> watch
> tic-bundle

node:internal/validators:119
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at Object.resolve (node:path:167:9)
    at Object.<anonymous> (C:\Users\Neil\AppData\Roaming\com.nesbox.tic\TIC-80\tests\wren\tic-bundle\node_modules\tic-bundle\bin.js:24:19)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Sprite / map data is overwritten each time the output is generated.

I started using tic-bundle recently. I'm using TIC-80 version 0.90.1724 Pro on MacOS. My settings can be seen here.

It works as described, which is great, but I strugge to find a practicable workflow.

Whenever I change one of the input source files in my IDE (in this case, VS Code), tic-bundle re-creates the output file as expected. When I change tiles / map / etc. within TIC-80, and save the changes, they are saved to the lua file, which tic-bundle consideres to be the output file. Next time I make a change in VS Code, tic-bundle overrides the output file, so all changes I made to my sprites / maps / etc. are gone.

I think when re-generating the output file, tic-bundle should recognize the existing ressource comments, and not overwrite them. I'm talkin about these lines:

-- <TILES>
-- 001:3333333434333333333433333333333333333343334333333333433343333333
-- 002:9999999999999989998999999999999999999989999999999899989999999999
-- 003:eeeeedeeeeeefdeeeeeffdeeddddddddeedeeeeeefdeeeeeffdeeeeedddddddd
-- 005:65665566776476763773473737333433343333433343343434334f334f333333
...

Is there some option that I missed, or does tic-bundle assume another workflow?

Add new metadata tags

Around version 1.0 of TIC80, the metadata tags site, license, and version tags were added. Also, menu was added, but I feel that should go in it own separate object within the configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.