Grunt-init mod templates

Discussion in 'Mod Discussions' started by wondible, February 25, 2014.

  1. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I don't know if this qualifies for [REL] - it's a dev tool only.

    I've experimenting with using Grunt-init to stamp out mod templates. I'm deferring to the grunt-init documentation for installation and setup.

    Client

    I started out with a very basic skeleton to get a handle on the template system, and then added all the stuff I did in Gross Economy to get RequireJS and Grunt working. The READMEs have some more specific information. Let me know what your stumbling blocks are and I'll flesh out what I can.

    Server

    Balance Basic - https://github.com/JustinLove/pa_smod_balance_basic

    Copy and pretty-print the JSON files (and the build hotkey file). Has a stub to run a transformation on the JSON while it's copying. This is a one-shot to set up manual editing.

    Balance Grunt - https://github.com/JustinLove/pa_smod_balance_grunt

    Doesn't copy any game files, but sets up a gruntfile that can copy all or a subset of unit files, run transformations. CAUTION: the game will upload node_modules and who knows what else from a mod directory. You should work in a separate directory and use the copy:mod task to make files visible, see README.

    Available Tasks

    - copy:unitFiles - copy json files into the mod, with optional filename regexp
    - copy:build - copy build.js into the mod
    - copy:mod - copy the mod files into server_mods
    - modify:health - process unit files; set up for double health as an example. Expectation is that several modify:X tasks will me made.
    - jsonlint - lint all the mod json files
    - json_schema - partial validation of mod json files format using schema by exterminans https://forums.uberent.com/threads/wip-units-ammo-and-tools-json-validation-schema.60451/
    - default: json_schema, jsonlint

    Transform - https://github.com/JustinLove/pa_smod_transform

    Doesn't copy any game files, but sets up a gruntfile that will copy files from PA and write programmatically modified versions into the mod. CAUTION: the game will upload node_modules and who knows what else from a mod directory. You should work in a separate directory and use the copy:mod task to make files visible, see README.

    Available Tasks

    - copy:mod - copy the mod files into server_mods
    - proc:adv_comfab - Proc: read one or more files from PA and munge into one in the mod. Example is a reduced cost adv. fabrication bot
    - proc:antinuke - restore the builtin first antinuke.
    - default: proc, copy:mod
    Last edited: September 28, 2015
  2. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
  3. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Okay I'm getting what grunt does now.

    I've installed it using npm install -g grunt-cli
    Code:
    ss_economy_dev>grunt
    grunt-cli: The grunt command line interface. (v0.1.13)
    
    Fatal error: Unable to find local grunt.
    
    If you're seeing this message, either a Gruntfile wasn't found or grunt
    hasn't been installed locally to your project. For more information about
    installing and configuring grunt, please see the Getting Started guide:
    
    http://gruntjs.com/getting-started
    
    Tried to run it in gross_economy_dev but it says bad things ?

    If I understand right if I just need to run grunt in that folder no ?
    It should then pick up your gruntfile.js and move the folder to gross_economy_test right ?

    Any Ideas ?
  4. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656

    Never mind found it out :)

    npm install :)
  5. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    So setting this up for hotbuild.
    Expect more questions ...
    What IDE do you use ? Sublime ?
  6. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Okay, something I need to add to readme.

    I use (Mac)Vim. I haven't thought about looking for Grunt plugins for it.
  7. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    @wondible how do you make this work with multiple scenes ?
  8. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    What difficulty are you encountering?
  9. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I just updated the amdclean template to use the scenes key as primary and copy things up during build. It also process each scene, though I'm still cheating and only checking the first item in the array.
  10. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Since Hotbuild has gone "scenes" exclusively, I've done the same with the project templates.
  11. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Guess somebody must start :) When I have more time I'll take a look at the templates, will have some questions for sure.
  12. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
  13. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Man just setting up grunt for hotbuild2
    This thing is awesome :)
    jshint check
    minify css / js
    remove console.logs / debuggers
    make less errors in changing date in modinfo.json

    oh @wondible you have some missing ;'s in your gruntfile :)
  14. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Yeah, my projects aren't as large so I haven't set up the extras yet.

    And I've been leaning towards no-; style lately.
  15. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Why don't you go coffeescript then ?
  16. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Possibly should. 1: compile step (though RequireJS has a filter) 2: debugging (should check on the state of source maps) 3: code sharing
  17. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Should work I think.
    If you get debugging working through sourcemaps, please share :)
  18. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I don't think we need/want that kind of thing. With the exception of PA Stats (even for PA Stats the required bandwidth is not an issue) all mods are loaded directly from local files. A few kbyte don't matter in that kind of scenario and having readable code at all times is a big +.
    Adding this will only make it harder, especially on newbie modders.
    DeathByDenim likes this.
  19. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Yeah I know was just playing around with things :)
  20. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Added a server mod template.

    Balance Basic - https://github.com/JustinLove/pa_smod_balance_basic

    Copy and pretty-print the JSON files (and the build hotkey file). Has a stub to run a transformation on the JSON while it's copying. This is a one-shot to set up manual editing. I'll likely do one that adds some common grunt tasks for linting and transforming later.

Share This Page