Coder Social home page Coder Social logo

rub-cli's Introduction

rub-cli

Extends the grunt commands which come with Adapt Framework.

Support

Supports only Adapt versions >=4

Installation

Please make sure you leave the following files and folders in your development folder:

node_modules (if it's there)
grunt

Then run npm install -g rub-cli grunt-cli

N.B. it is critical to install grunt-cli otherwise the commands may fail silently.

Execute

Run rub dev

$ rub help

Adapt Buildkit (rub-cli)

  Usage: rub [options] [courses...]

  Options:

    -V, version          display version numbers     
    -h, help             display this help text      
    -v, verbose          verbose output
    -f, force            force rebuild
    -F, forceall         force clean then rebuild    
    -p                   number of parallel tasks (2)
    -c, clean            clean output folder
    tracking:insert      add block tracking ids      
    tracking:remove      remove block tracking ids
    tracking:reset       reset block tracking ids
    -j, json             process json
    -M, minify           minify json
    -P, prettify         prettify json
    -b, build            production build (no sourcemaps, with uglify)
    -d, dev              development build (with sourcemaps, no uglify)
    -U, uglify           uglify js
    -z, zip              zip output folders
    -Z, zipaat           zip for import to AAT
    -r, redundantassets  check for redundant assets
    -t, techspec         check assets against techspec
    -C, compress         compress images
    -w, watch            watch for changes
    -s, server           run server environment
    translate:export     export translatable text
    translate:import     import translated text
    -W, wait             wait for keypress

Tech Spec

  1. Run rub techspec
  2. Edit techspec.json
  3. Run rub techspec

Including/excluding plugins

If one (or more) of your modules only uses a subset of the installed plugins, you can specify which should be included by adding the following to the config.json for that module:

"build": {
	"includes": [
		"adapt-contrib-media",
		"adapt-contrib-narrative",
		"adapt-contrib-bookmarking",
		"adapt-contrib-pageLevelProgress",
		"adapt-quicknav"
	]
}

Changing .json file endings

Add to Adapt framework package.json

    "grunt": {
        "options": {
            "jsonext": "txt"
        }
    }

Changing course folder name

Add to Adapt framework package.json

    "grunt": {
        "options": {
            "coursedir": "alternative"
        }
    }

IMSMANIFEST.XML variable replacement

@@course.title
@@course.customName.subAttributeName
@@config.anyOtherName

You can only use variables from config and course.

Tracking Ids

These three commands (tracking:remove, tracking:insert and tracking:remove) will change the src/course if you’re using the Adapt Learning structure, or the builds/moduleName/course/ files otherwise.

Flags vs commands vs options

Commands will typically run at the exclusion of all other non-dependent tasks, such that rub prettify will only perform a json prettification task. Flags now assume a build should happen, such that rub -P will build and prettify, rub -Pz will build, prettify and zip, etc. Options specify a value, such as rub -p=10, to allow 10 parallel tasks.

Migrating from adapt-cli to rub

In order to use rub, your Adapt project's folder structure will require a few changes.

  1. Create a builds folder in the root of your project.
  2. Create a folder inside the builds folder using your module name (e.g. `p101).
  3. Move the contents of the 'src/course' folder into 'builds/p101/course'. Then, remove 'src/course' entirely.
  4. Finally, run rub dev p101 to build.

rub-cli's People

Contributors

oliverfoster avatar moloko avatar dependabot[bot] avatar danielghost avatar swashbuck avatar chris-steele avatar nayankhedkar avatar olivermartinfoster avatar tomgreenfield avatar

Stargazers

Jack Schofield avatar Simon Date avatar

Watchers

James Cloos avatar  avatar Ignacio Cinalli avatar Stuart avatar  avatar  avatar Joseph Replin avatar  avatar Guy Willis avatar

rub-cli's Issues

minification

rub -b doesn't minify adapt.min.js

rub build doesn't either

thought this might solve it but no such luck

Using framework 2.2.5 and latest rub-cli

templates.js needs looking at also

build.includes in config.json causing issues

This has been observed when rub-cli is used with an Authoring Tool export.

Example data from config.json:

"build": {
        "includes": [
            "adapt-contrib-boxMenu",
            "adapt-bsa-theme",
            "adapt-contrib-matching",
            "adapt-contrib-mcq",
            "adapt-summary",
            "adapt-contrib-assessmentResults",
            "adapt-contrib-trickle",
            "adapt-contrib-assessment",
            "adapt-contrib-bookmarking",
            "adapt-contrib-pageLevelProgress",
            "adapt-contrib-resources",
            "adapt-contrib-spoor",
            "adapt-contrib-tutor",
            "adapt-devtools",
            "adapt-certificate",
            "adapt-navigationLogo",
            "adapt-inspector",
            "adapt-search",
            "adapt-overrides",
            "adapt-launchNewWindow",
            "adapt-contrib-languagePicker"
        ]
    }

The following sort of errors occur when attempting to build:

image

Removing the configuration corrects the issue.

Error on rub translate:export

We're having an issue when running command rub translate:export. We get the following errors:

m01: Warning: Cannot read property 'hasOwnProperty' of undefined
m02: Warning: Cannot read property 'hasOwnProperty' of undefined

Here is the results of rub -V:

Adapt Framework v3.2.0
Rub v0.0.38
Node v6.9.5

How can I resolve this issue so I can get the CSV over to the translators?

Zip for AAT upload

It would be great if you could create a command to zip up a course for AAT upload. I've been having problems zipping up the wrong things. Would save a lot of headaches if this could be automated to a command. In particular, having to remove .git folders is a pain.

Fresh install of rub only returns 'Unsupported architecture.'

I very recently did a fresh install of the adapt framework. When trying to run any of my previous projects using rub dev nothing runs, and the only response/report I get is 'Unsupported architecture.' Not sure where to even begin looking to fix this issue.

AAT Builds are failing

AAT Builds are failing.

-Z command is not giving an authoring tool zip it is giving the full folder from root with builds/module/adaptbuild instead of AAT builds generated earlier.

Cannot build with a pre-release version of the framework

Have seen

rub-cli needs an adapt version >=2.0.13, this is 5.6.0-rc.1

and

== Node detected an unhandled rejection! ==
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at Object.join (path.js:375:7)
    at Function.run (C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\grunt.js:8:33)
    at Object.perform (C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\commands\030json.js:109:18)
    at next (C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\tasks.js:106:40)
    at C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\tasks.js:123:7
    at new Promise (<anonymous>)
    at Function.performCommandsOnOutputPaths (C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\tasks.js:92:12)
    at Function.next (C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\tasks.js:75:18)
    at C:\Users\tom.greenfield\AppData\Roaming\nvm\v14.3.0\node_modules\rub-cli\globals\tasks.js:25:20

Might be as simple as including { includePrerelease: true } in the semver function calls.

Add documentation for the pathways from adapt-cli to a builds folder

Please add a section to the readme regarding the pathways from adapt-cli to a builds folder (i.e. using rub-cli instead of grunt). This should cover:

  • Manually creating the 'builds' folder.
  • After running grunt build, moving the new course into the 'builds' folder.
  • Deleting the 'course' folder in 'src'. Otherwise, the 'build' folder will keep being recreated when rub is ran.

Note that this does not apply when using adapt-setup instead of adapt create course. However, it should still be documented.

Thanks.

Open server on course page instead of main folder

Every time f I run rub -s my-course-name, rub opens http://localhost:3001/ and I still have to manually navigate to /builds/my-course-name/index.html in the browser from there.

It would simplify the process and save a lot of time if rub could just open http://localhost:3001/builds/my-course-name/index.html directly in this scenario.

I've changed this locally in commands/070server.js, but it would be useful if this could be the default behavior.

rub -b does not minifiy plugins' libraries

  • Download a standard adapt OS setup via adapt create course rub-cli-test
  • run grunt build
  • Note how files like the following are all minified
    • mediaelement-and-player.js
    • rangeslider.js
    • select2.js
  • now run rub -b
  • note how those files are no longer minified

On an OOTB Adapt build, minifying these files reduces the size of the libraries folder by over 250KB so I think this is worth sorting out

Using offline

If you find yourself with nothing to do, be good for rub-cli to work without the internet.

Localisation/translation import issue with json

Subject of the issue/enhancement/features

Trying to import json file for translation instead of csv, but getting error on import

Your environment

Framework, v5.3.0
Windows 10

Steps to reproduce

Export content to json
Duplicated the en folder in a course within builds folder, and renamed it de (this has the json and images folder in it, but in English)

added a de folder to the languagefiles folder (top level of dev folder) and added in the translated export.json

ran
rub translate:import –targetLang=de –format=json
get error saying that “sorry, the imported file is not valid”

Expected behaviour

Should import the json

Actual behaviour

Get above error

Screenshots (if you can)

attached. (i've blanked out part of the file path
Screenshot 2021-04-13 171128
)

Referencing adaptlearning/adapt_framework#3125

Build issues with Node 12 on Linux

  • Ubuntu 18.04 (using nvm to manage Node)
  • tested Node v12.18.3 and v12.18.4 with npm 6.14.6
  • rub -dF runs through tasks with no errors but does not produce output (js/css etc)

Cannot run rub on upgraded project

A colleague upgrades a project from legacy Rub to new Rub on SVN. Updating my local version doesn't remove the buildkit folder completely because it contains an unversioned node_modules folder.

Attempting to run new Rub leads to

Legacy rub is installed. Please use './rub' to run the legacy version
[Finished in 0.2s]

Please can we make the legacy check more robust.

Line break periodically added to end of JSON files

Periodically, a line break is added to end of course.json. This is a minor annoyance as files get committed to version control when the only change was an extra line break. We have seen this happen in course.json and blocks.json (and maybe others).

Could this be due to team members on different operating systems working on the same files, possibly something with line endings (windows vs. unix)?

Test case

  1. I run rub -ds p101. course.json is not changed.
p101: Processing assets, json, required and libraries...
  p101: Running plugin postcopy scripts...
    p101: No issues found in course/en, your JSON is a-ok!
    Tracking IDs are ok for course/en. The latest tracking ID is 57
  p101: Prettifying...
  p101: Compiling code (dev)...
  p101: Running plugin postbuild scripts...
  Watching for changes...
  1. I make a change to a Less file and save it. Doesn't seem to matter which Less file.
  Starting server...
  Opening http://localhost:3001...
  Changed...
  p101: Compiling code (dev)...
  p101: Running plugin postbuild scripts...
    Error: read ECONNRESET
        at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
     {
      errno: -54,
      code: 'ECONNRESET',
      syscall: 'read'
    }
  Server sending client reload action 'window'
  Watching for changes...
  1. rub immediately thinks something else has changed, so it rebuilds it. I have not made any other changes yet.
  Changed...
  p101: Processing assets, json, required and libraries...
  p101: Running plugin postcopy scripts...
    p101: No issues found in course/en, your JSON is a-ok!
    Tracking IDs are ok for course/en. The latest tracking ID is 57
  Server sending client reload action 'window'
  Watching for changes...
  1. An extra line break is added to the end of course.json
    diff

Support build subfolders

Whilst rub will happily build courses found in a subfolder (e.g. builds/diagnostic/mc-fa) you cannot specify the path to a particular course; you must build all courses.

It would be great to run (as in the example above) rub -dF diagnostic/mc-fa to have only the mc-fa course built.

documentation for flags vs commands

Behaviour is often different depending on when you use a command vs using a flag

For example, rub -s has different behaviour to rub server.

Need to document these.

No error passed through on initial run

After initial setup of folder:

$ rub -ds p101

Patching...
Adapt Buildkit (rub-cli)

  Checking for rub updates...
  Failed to fetch update data.
  p101: Processing assets, json, required and libraries...
    p101: No issues found in course/en, your JSON is a-ok!
    Tracking IDs are ok for course/en. The latest tracking ID is 0
  p101: Prettifying...
  p101: Compiling code (dev)...
    p101: Cache disabled (--disable-cache): false
    Strict mode (config.json:build.strictMode): false
    Cache skipping file: src/plugins.js
    Warning: Task "javascript:dev" failed.
  p101: Cleaning up for production...
  Watching for changes...

  Starting server...
  Opening http://localhost:3001...

When I stop the task and rerun:

$ rub -ds p101

Adapt Buildkit (rub-cli)

  p101: Processing assets, json, required and libraries...
    p101: No issues found in course/en, your JSON is a-ok!
    Tracking IDs are ok for course/en. The latest tracking ID is 0
  p101: Prettifying...
  p101: Compiling code (dev)...
    p101: Cache disabled (--disable-cache): false
    Strict mode (config.json:build.strictMode): false
    Fatal error: NameError: variable @item-text-color is undefined in src/components/adapt-tabs/less/tabs.less on line 21, column 10:
    20          border-radius: 20px 0 0 20px;
    21          color: @item-text-color;
    22          display: block;

  p101: Cleaning up for production...
  Watching for changes...

  Starting server...
  Opening http://localhost:3001...

Could it be related to the patching?

assets folder removed by build tasks

If an assets folder is used for common files (e.g. shared across languages) it is removed when running a build task. I don't think this used to happen.

Some schema globals omitted

That is, any nested properties defined under globals will be omitted.

N.B. I caught this while I was considering this proposal for the CLI.

-f not compiling all files?

I need to investigate this further, but it seems like the force options can cause issues with missing files when compiling. Will update this ticket once I have had a chance to revisit this.

Checking for redundant assets in 0.2

Checking for redundant assets in v0.2 of rub-cli now shows every asset as redundant. We have tested a few different courses without the new grunt course folder config, and got the same results in all of them.

To reproduce:
Run 'rub -r' for a course.

Tested with:
rub-cli: 0.2
AF: 5.13.0, 5.14.0, and 5.19.6

Rub doesn't report missing blocks

I noticed that whilst building a course that when I forgot to delete a block and Rub gave no error about.

Adapt Framework  v5.3.0
Rub              v0.0.43
Node             v12.13.1

rub -b unable to read course.json file

Whenever I run rub -b I get this error message

image

The command still runs but this is all that appears in the build folder

image

It also means that rub -d stops working too. I have to revert to grunt .. comands to make rub -b work again.

Regional language codes not importable

The translate:import command doesn't import as intended if you are attempting to import a language code with a regional sub-language. It seems to be the - glyph that isn't accepted. You are able to import with a simpler language code and change your folder name post-import.

For example:

  • English (Canada) - en-ca
  • Spanish (Mexico) - es-mx
  • Chinese (Taiwan) - zh-tw

rub 0.0.31 always uglifies JSON

doesn't seem to matter what switch I use

Personally I would prefer that it never uglifies the JSON as there's rarely much of a saving in filesize by doing so - and I worry that having it uglified by default (making it pretty much unreadable) would discourage people from using rub -b - which I'd really like to see used more to ensure all the JS is minified.

At the very least, only rub -b should be uglifying JSON; the switches -d, -dw and -P should not

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.