Validation and parsing for Scratch projects
Find a file
Karishma Chadha 7f8672dfbc refactor($lib): Add callback wrapper around JSZip promise-based interface. Refactor m
Refactor unpack and main exported function to return optional zip, if originally provided, in
addition to the validated project.

BREAKING CHANGE: Change to main api to return originally provided zip (or null if string was
provided) along with validated project, in a 2-element array.
2018-03-23 09:37:48 -04:00
lib refactor($lib): Add callback wrapper around JSZip promise-based interface. Refactor m 2018-03-23 09:37:48 -04:00
test feat(unpack): Unpacker can now take string as input. 2018-02-26 15:42:12 -05:00
.eslintrc Initial WIP commit with streaming parser 2016-03-15 10:31:35 -04:00
.gitignore Initial WIP commit with streaming parser 2016-03-15 10:31:35 -04:00
.travis.yml Configure semantic-release 2017-03-21 15:42:32 -04:00
index.js refactor($lib): Add callback wrapper around JSZip promise-based interface. Refactor m 2018-03-23 09:37:48 -04:00
LICENSE Add license and trademark files for release 2016-09-19 10:16:16 -04:00
Makefile Initial functioning parser 2016-03-18 19:51:40 -04:00
package.json Merge pull request from LLK/develop 2018-03-01 14:33:28 -05:00
README.md Remove linter working from copy/paste 2017-03-21 16:24:45 -04:00
TRADEMARK Add license and trademark files for release 2016-09-19 10:16:16 -04:00

scratch-parser

Parser for Scratch projects

Build Status dependencies Status devDependencies Status

Overview

The Scratch Parser is a Node.js module that parses and validates Scratch projects. Internally, this utility is used for validation of Scratch projects as well as for extracting metadata from projects for research and search purposes.

API

Installation

npm install scratch-parser

Basic Use

var fs = require('fs');
var parser = require('scratch-parser');

var buffer = fs.readFileSync('/path/to/project.sb2');
parser(buffer, function (err, project) {
    if (err) // handle the error
    // do something interesting
});

Metadata

The scratch-parser module will append metadata about the project should validation and parsing be successful. The _meta object includes:

Key Attributes
scripts count
blocks count, unique, list, frequency
sprites count
variables count
lists count
costumes count, list, hash
sounds count, list, hash
extensions count, list
comments count

"Info"

In addition to the _meta data described above, Scratch projects include an attribute called info that may include the following:

Key Description
flashVersion Installed version of Adobe Flash
swfVersion Version of the Scratch editor used to create the project
userAgent User agent used to create the project
savedExtensions Array of Scratch Extensions used in the project

Testing

Running the Test Suite

npm test

Code Coverage Report

make coverage

Performance Benchmarks / Stress Testing

make benchmark

Committing

This project uses semantic release to ensure version bumps follow semver so that projects using the config don't break unexpectedly.

In order to automatically determine the type of version bump necessary, semantic release expects commit messages to be formatted following conventional-changelog.

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

subject and body are your familiar commit subject and body. footer is where you would include BREAKING CHANGE and ISSUES FIXED sections if applicable.

type is one of:

  • fix: A bug fix Causes a patch release (0.0.x)
  • feat: A new feature Causes a minor release (0.x.0)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance May or may not cause a minor release. It's not clear.
  • test: Adding missing tests or correcting existing tests
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

Use the commitizen CLI to make commits formatted in this way:

npm install -g commitizen
npm install

Now you're ready to make commits using git cz.

Breaking changes

If you're committing a change that will require changes to existing code, ensure your commit specifies a breaking change. In your commit body, prefix the changes with "BREAKING CHANGE: " This will cause a major version bump so downstream projects must choose to upgrade the config and will not break the build unexpectedly.