Giter Club home page Giter Club logo

easol-canvas's Introduction

Easol Canvas

This gem is used to validate themes built for the Easol platform.

Usage

Installation

You can install the gem globally with the following and the canvas command will be available:

gem install easol-canvas
cd my_easol_theme
canvas lint

Alternatively, you can add it to a Gemfile in your project and run the command using bundle exec:

cd my_easol_theme
bundle exec canvas lint

The canvas lint command

When called inside the root of a theme directory, the canvas lint command will run various validation checks, such as the following:

  1. RequiredFilesCheck
    • Checks that the required files exist (e.g. templates/product/index.html).
  2. ValidHtmlCheck
    • Validates all .html files contain valid HTML.
  3. ValidLiquidCheck
    • Validates all .html files contain valid Liquid.
  4. ValidJsonCheck
    • Validates all .json files contain valid JSON.
  5. ValidSassCheck
    • Validates all .css, .scss and .sass files contain valid Sass.
  6. ValidBlockSchemasCheck
    • Validates the schema defined in each block.
  7. ValidMenuSchemaCheck
    • Validates the schema defined in each menu.
  8. ValidFooterSchemaCheck
    • Validates the schema defined in each footer.
  9. ValidCustomTypesCheck
    • Validates each custom type defined within the /types directory.

Set up a GitHub check on a theme repo

There is a canvas-linter-action, which can be used inside an Easol theme repo to run validations on each push. Here’s an example where it is was set up in alchemist.

Follow the instructions in the README to set up this action inside your theme project.

Developing the gem locally

Running automated tests

You can run the tests within the repo with the following:

bundle
bin/rspec

How to test locally in a theme repo

Direct call

This approach is generally quicker than installing the gem (see below). Please use the built gem for final testing.

Within a theme repo, call the executable of the gem directly, for example:

cd alchemist_theme
../canvas/bin/canvas lint

Installing the gem

  1. Clone the easolhq/canvas repo locally.

  2. Build the gem inside the canvas directory to create a .gem file.

    cd canvas
    gem build
    
  3. Install the local version of the gem (make sure this is called inside the canvas directory, gem install will look for a .gem file and use that instead of installing from rubygems if it exists).

    cd canvas
    gem install easol-canvas
    
  4. Now you can use the gem within a theme repo.

    cd alchemist_theme
    canvas lint
    

How to test locally within Rails

  1. Clone the easolhq/canvas repo locally.

  2. Build the gem inside the canvas directory to create a .gem file.

    cd canvas
    gem build
    
  3. Add the gem to the Gemfile in your Rails app and specify the local path.

    gem "easol-canvas", path: "/path/to/canvas"
  4. You can now reference the validators inside Rails, e.g.

    require "canvas"
    
    ...
    
    Canvas::Validator::BlockSchema.new(schema: block_schema)

Publishing

How to publish a new version of the gem

  1. Implement your code changes.
  2. Bump the version in the code:
    1. bundle exec gem bump --version [minor|major|patch]
    2. Commit these changes.
  3. Push changes, wait for PR to be approved, then merge to main.
  4. Pull the latest from main
  5. Tag the latest version via git:
    bundle exec gem tag
    
  6. Push created tag with git push --follow-tags which will trigger Github actions responsible for publishing new version of the gem to rubygems.org repository
  7. On major version changes, update the version lock in the canvas-linter-action repo.

easol-canvas's People

Contributors

ianmooney avatar kylebyrne avatar lluzak avatar sldblog avatar tomchipchase avatar sgerrand avatar eballantine avatar ryanmacg avatar catalinatudor avatar noon-ng avatar geoffreymm avatar theocodes avatar

Stargazers

Ben Lavon avatar

Watchers

John Henderson avatar  avatar  avatar  avatar  avatar  avatar Ben Lavon avatar Gabor Mikes avatar James Christie avatar  avatar Brandon avatar

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.