GithubHelp home page GithubHelp logo

base16-builder / base16-builder Goto Github PK

View Code? Open in Web Editor NEW
431.0 431.0 41.0 663 KB

:hammer: Base16 Builder is a nimble command-line tool that generates themes for your favourite programs.

License: MIT License

JavaScript 2.20% Shell 0.46% HTML 97.34%

base16-builder's Introduction

Base16 Builder

Gitter PRs Welcome MIT License

Base16 Builder is a nimble command-line tool that generates themes for your favourite programs. See it in action below:

Base16 Builder is easy to use. All you have to do is supply a color scheme, template, and brightness (light or dark). Base16 Builder will use the information you provide to generate a theme and write it to stdout.

Because Base16 Builder writes to stdout, it's possible to pipe the theme anywhere you like. In the above screencast, the theme is piped to a new file called "theme", but this could just as well have been a configuration file like ".Xresources".

You don't have to be savvy with Unix pipelines to enjoy Base16 Builder. If you'd prefer, you can just copy the output with your mouse ☺️.

Features

This project aims to rejuvenate Chris Kempson's original tool by incorporating some fresh features:

Installation

$ npm install --global base16-builder

Make sure to install Node.js before running the above command. We recommended that you install Node.js using nvm (the node version manager) or the pre-built installer for your platform. npm (the node package manager) is bundled and installed automatically with Node.js.

Usage

$ base16-builder --help

  Usage:
    $ base16-builder <-s scheme> <-t template> <-b light|dark>
    $ base16-builder <-s scheme path> <-t template path>

  Options:
    -s, --scheme        Build theme using this color scheme
    -t, --template      Build theme using this template
    -b, --brightness    Build theme using this brightness
    -h, --help          Show this menu

  Commands:
    ls schemes      Opens an offline web page with a list of scheme names and their colors
    ls templates    Writes a list of available templates to the terminal

  Examples:
    $ base16-builder -s oceanicnext -t rxvt-unicode -b dark
    $ base16-builder --scheme oceanicnext --template rxvt-unicode --brightness dark
    $ base16-builder --scheme schemes/customScheme.yml --template templs/customTempl.ejs
    $ base16-builder ls schemes
    $ base16-builder ls templates

Build Status

Windows Linux
Build status Build Status

Attribution

base16-builder's People

Contributors

aloisdg avatar asessa avatar atelierbram avatar ayyess avatar belak avatar claytonpassmore avatar idleberg avatar joshwlewis avatar m1sports20 avatar omar-polo avatar protesilaos avatar sirfz avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

base16-builder's Issues

What do you think of the idea of moving to TypeScript?

Hello,

A quick question, I am asking myself. What do you think of a move to TypeScript?

  • AFAIK, you use Atom who support TypeScript.
  • You are coming from a C# background too, the TS's syntax should easier for both of us.
  • TypeScript is widely use and a popular transpiler.
  • TS support ES6 features with some ES7 feature like async/await.
  • Since we can use it with plain, the migration will be smooth.
  • TS works well with nodejs.
  • A port will be simpler to do now.
  • AFAIK, you dont have a project with it, base16-builder could be the first!

A stackoverflow talk about TypeScript.

Update the gif

Hello,

The demonstration gif is outdated. It would be nice to make another one.
Also, I think the picture could be a bit smaller.

Cheers,

Show a friendly error message when the given template or scheme does not exist

User stories:

  • As a user, I am presented with a friendly error message when a theme I specify doesn't exist.
  • As a user, I am presented with a friendly error message when a template I specify doesn't exist.

Example:

$ base16-builder -t i3wm -s wobble

$ fatal: Could not find a scheme called \"wobble\". It is likely that no template with this 
name exists. For a complete list of templates, see the database: https://goo.gl/ntnS1I
$ base16-builder -t wibble -s oceanicnext

$ fatal: Could not find a template called \"wibble\". It is likely that no template with this 
name exists. For a complete list of templates, see the database: https://goo.gl/fhm4Ct

Possibly upload to AUR

Some people would like to install this tool via AUR instead of npm.

I'm not sure how viable this is because the tool has a dependency on nodejs.

Add tests to ensure that success messages are green and error messages are red

In an attempt to eliminate the possibility of a trivial regression, tests should be included to verify that

  • Success messages are output to the console with a green colour; and,
  • error messages are output to the console with a red colour!

I haven't included these tests as I'm not yet sure how to go about testing this.

The module I use to colourize the output namely, Chalk, does so by emitting ANSI escape codes however, the terminal interprets these ANSI escape codes before I can evaluate them. Hm πŸ˜•.

Add support for VSCode

Hello,

Visual Studio Code support Textmate theme but it could be better with some adjustment.
I am looking for a better support. VSCode is shiped with an implementation of Solarized. It could be nice to use it as a bridge for the port.

Cheers,

Logo

Would anyone be interested in designing a vector logo for use in the readme.md?

In terms of design, I was thinking:

If you have a concept in mind, please bounce them off me before doing too much fine tuning. Aside from that I am pretty happy to give you free reign πŸ‘.

Create a tool to reverse engine a template or a scheme

This issue is directly related to base16-builder. I would love to get a tool to create a template from a theme. Basically, it will replace colors with nunjucks string.

A maths metaphor would be: scheme + template = theme thank to base16-builder and with this tool we could do: theme - scheme = template or theme - template = scheme.

Fix one failing test on master

Hi !

I found a failed test in master:

  27 passed  1 failed

  1. tests β€Ί buildTemplate returns correct result

  t.is(actual, expected)
       |       |        
       |       "\n    OceanicNext\n    https://github.com/voronianski/oceanic-next-color-scheme\n    1B2B34\n    343D46\n    4F5B66\n    65737E\n    A7ADBA\n    C0C5CE\n    CDD3DE\n    D8DEE9\n    EC5f67\n    F99157\n    FAC863\n    99C794\n    5FB3B3\n    6699CC\n    C594C5\n    AB7967\n  "
       "\n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n  "

  AssertionError: '\n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n  ' === '\n    OceanicNext\n    https://github.com/voronianski/oceanic-next-color-scheme\n    1B2B34\n    343D46\n    4F5B66\n    65737E
    Test.fn (tests/tests.js:185:5)

npm ERR! Test failed.  See above for more details.

The branch master must never fail a test.

Document the template convention

Templates need to adhere to a certain convention before base16-builder can detect them.

Whilst I believe that most contributors will be able to deduce this convention by looking at the templates directory, it would also be beneficial to formally document the convention.

Seeing as how this information is most relevant to contributors, I think contributing.md would be a natural home for the so-called specification.

Show a friendly error message when required arguments are not specified

User stories:

  • As a user, I am presented with a friendly error message when I do not specify a template name (-t).
  • As a user, I am presented with a friendly error message when I do not specify a scheme name (-s).

Examples:

$ base16-builder

$ fatal: You need to specify *BOTH* a template and a scheme name e.g.: 
base16-builder -t i3wm -s oceanicnext. If you are still having trouble, please refer to the
documentation for guidance: https://goo.gl/JwwX13
$ base16-builder -s oceanicnext

$ fatal: You need to specify *BOTH* a template and a scheme name e.g.: 
base16-builder -t i3wm -s oceanicnext. If you are still having trouble, please refer to the
documentation for guidance: https://goo.gl/JwwX13
$ base16-builder -t i3wm

$ fatal: You need to specify *BOTH* a template and a scheme name e.g.: 
base16-builder -t i3wm -s oceanicnext. If you are still having trouble, please refer to the
documentation for guidance: https://goo.gl/JwwX13

Add support for group of template

Hello,

For now it could be done easily with bash script who are going to call base16-builder a bunch of time. I think it could be neat to handle this ourself something in this idea:

$ base16-builder -s gooey -t rxvt-unicode,i3wm,i3status,atom,vim

It could be handy when you want to change a complete theme.

If we add this, we are going to need to support an output directory. Afaik, pipes are strong but limited for this case.

I am perfectly ok with the current implementation, it allow to do a script who can take as parameter a dictionary with templateName as key and output as value. This script could be a new project.

Any thought?

Who is the author in a scheme file?

Hello,

In a scheme file we can find the name of an author. Who is he? He can be:

  • The creator of the file.
  • The creator of the scheme.

If I use the solarized theme, the author should be @altercation (scheme creator) or myself (file creator)?

To answer this, we could look at the use. Why should we add the author? What is the benefit of each one?

In another hand, could be use both?

For now, I think we should use the original author.

What do you think?

Add Alfred template

Hello,

Alfred is an effective launcher for Mac. You can learn more about the project on its website.

Inspiration can be taken from my wox template see #59 or from a solarized implementation (1 2 3 4).

Cheers,

Split base16-builder cli from core

Hello,

What would you think to split base16-builder in two projects. One for the core and one for the CLI. If someone, someday, want to create a GUI version or another tool. He could use the core part of base16-builer. In C#, i would ask for switching for one project to a group of projects (a PCL, a CLI, why not a wpf, etc).

Basically, can we add more modularity in base16-builder?

Improve readability of buildPath function

const templPath = await buildPath(templName, false);
const schemePath = await buildPath(schemeName, true);

Problem: It isn't really clear at a glance what the true or false arguments mean.

Solution:

  1. Use an enum
  2. Use named arguments
  3. Create two discrete functions: buildTemplatePath and buildSchemePath that both call buildPath.

How can I run this project?

Edit

Because the subject change during the thread, I moved this issue to #15

Hello,

AFAIK, I cannot use base16-builder like this:

base16-builder -s db/schemes/railscasts.yml -t db/templates/i3wm.nunjucks

It would be nice to add path support.
Something like this (pseudocode)

if arg is path
    read it
elif arg is in db
   read it
else
   print usage

We could also use a specific flag but I find this idea more convenient.

Cheers,

Make "-h" the default output

Hello,

When we run base16-builder without any arguments a "fatal" error is thrown:

fatal: You did not supply valid arguments. Run \'base16-builder -h\' for guidance.

I think it would be better to make the "-h" a default and to print it when no argument is given. It is the choice made by "git" or "npm" for example.

Cheers,

Handle buildTheme exceptions

buildTheme can throw an error if the nunjucks template is invalid. This needs to be handled and a friendly error message should be shown to the user.

Add Wox template

Hello,

Wox is an effective launcher for Windows. You can learn more about the project on its repository.

Right now, I have the support for the dark and the light template (here with the solarized scheme):

dark

light

I created them with wox's theme builder with inspiration from Alfred (1 2 3 4). I chose 0A as accent color but any accent color will fit (I found 0C really convenient too).

Is the path feature broken?

How the path feature works

It'll be impossible to tell if the user wanted a theme from the db or from her local path

Yes and it is a feature. The user must control waht he wants to do. He can choose.

Why?

Lets look inside the function buildPath():

async function buildPath(file, isScheme) {
    const exists = await fs.exists(file);
    if (exists) {
        return file;
    }
    return toRelativePath(isScheme ? `db/schemes/${file}.yml` : `db/templates/${file}.nunjucks`);
}

If the argument file is a path to a file, we use it. If the file is broken, it will be not our problem (at least for now. We should protect the user from himself, but this is a story for another PR).

If the argument file point to nothing, he should be a basic name of a template. Lets look in /db to find a matching one. We got a matched? Awesome! We use it. A file in db, cant be broken. It MUST be valid.

Wait... We reach here? There is a problem... an error somewhere... Lets throw a friendly message to inform the user, print a usage or something and end the script smoothly.

But there is a problem

What happened if the user do something like this?

$ base16-builder -s fooBar -t toto -l dark

We are looking if there is a file called toto if yes we use it, else we look into the db. That's all folks!

What if, we run the script inside /db? An user cant, but a contributor could. Ok, lets protect everybody. For this case it can be handy to change a bit buildPath(). I always said that we checked for an existsting file. This is wrong or at least, no so true. With fs.exists(), we check if a file or a directory exist, not only a file. To prevent this case we can replace fs.exists() with fs.lstat() and stats.isFile(). They is a nice question around this subject on Stack Overflow. Also, here is a link to the docs of fs.stats.

After the edit, we will have:

async function buildPath(file, isScheme) {
    const stats = await fs.lstat(file);
    if (stats.isFile()) {
        return file;
    }
    return toRelativePath(isScheme ? `db/schemes/${file}.yml` : `db/templates/${file}.nunjucks`);
}

What's next?

You said it! πŸ˜„

Allow to use path to test custom theme

Hello,

AFAIK, I cannot use base16-builder like this:

base16-builder -s db/schemes/railscasts.yml -t db/templates/i3wm.nunjucks

It would be nice to add path support.
Something like this (pseudocode)

if arg is path
    read it
elif arg is in db
   read it
else
   print usage

We could also use a specific flag but I find this idea more convenient.

Cheers,

_Move from #14 _

Add more intuitive command-line arguments

User stories:

  • As a user, I am able to specify 1, a scheme name, 2, a theme name, 3, luminosity and optionally, 4, a palette.
  • As a user, if I do not specify luminosity or if I specify an invalid luminosity, I get an error.

Examples:

$ base16-builder -t i3wm -s gooey -l dark

$ set $base00 101218
$ set $base01 1f222d
$ set $base02 252936
....
$ base16-builder --template i3wm --scheme gooey --luminosity dark

$ set $base00 101218
$ set $base01 1f222d
$ set $base02 252936
....
$ base16-builder -t i3wm -s gooey -l light

$ fatal: Could not find a scheme called 'i3wm-light'
$ See 'base16-builder ls-schemes' for a list of available schemes.
$ base16-builder -t i3wm -s gooey -l dark -p 256

$ fatal: Could not find a scheme called 'i3wm-dark-256'
$ See 'base16-builder ls-schemes' for a list of available schemes.
$ base16-builder --template i3wm --scheme gooey --luminosity dark

$ fatal: You did not supply valid arguments. See 'base16-builder -h' for help/examples.

Add more detail to the manual

User stories:

  • As a user, I am presented with a useful man page when I use the --help flag.

Examples:

base16-builder --help

Usage: 
  $ base16-builder [-s <scheme>] [-t <template>]

Options:
  -s, --scheme Build theme using this color scheme
  -t, --template Build theme using this template

Examples:
  $ base16-builder -s oceanicnext -t i3wm
  $ base16-builder --scheme oceanicnext --template i3wm


Should we use two separates flags to handle templates?

Presentation

To works, base16-builder need at least three arguments:

  • a template
  • a scheme
  • a luminosity

We will not talk about luminosity here. Lets focus on template and scheme. Base16-builder ask them to provide a name or a path, so he can mix them and print a result on stdout. Since their logic are exactly equals, we are only going to talk about template. Sorry scheme, I wont miss you. Also, I will rename Base16-Builder "BB16" (acronym for "Builder-Base16"). Base16-builder is a long name and I am lazy.

bb8

BB16 gets the template like this:

  • $> base16-builder -t solarized
  • $> base16-builder -t /path/foo/bar/solarized.nunjucks

In the first command line, we give a name as argument to BB16. In the second command line, we give him a path. BB16 doesn't care. BB16 can eat both. Well, lets look in base16-builder belly. If we give him a path, he will used it, build a theme and print it to stdout. If we give BB16 a string who is not a path to a file, BB16 is going to interpret it as a name. BB16 thinks "How this argument is not a path so it must be a valid name!". He is going to look in his memory (the db folder) to find a template with a matching name. If he find one, he build himself a path to it like before. Then, he does his mix and print the result to stdout.

BB16 is polite. He will always check for input from the user before check in his memory.

If for some dark reasons BB16 cant find a path to a file or a name, he will print an error.

file logic

Problem

Ok. ok. What is the problem?

It is not really a problem. It is a decision to take. @alexbooker and I are not sure about what to do. This issue is here to explain the choice.

Now, we use the flag "-t,--template" to get both the name and the path and later, BB16 split them.

An alternative would be to use two flags: "--template" and "--template-path". The first one will handle name and the second one will handle path.

With two flags, we don't have to use a if to split the logic. The user with split it himself.

I think the current implementation is good enough. @alexbooker wonders whether the second is better or not.

You Choose Your Path by James Wheeler

Solution

Well, I am not going to give a solution. I will just explain my thought.

With the first implementation, the user doesn't have to do the job for us. He will have to choose the right flag for each case. If he wants to use BB16 like the old Base16-builder, he will have an error. To allow him to do this, he will have to change to this new flag "--template-path".

From the code, it might seem better. Less code to write because the user is going to choose between a name and a path (lets forget that this code already exists). We are going to create a new logic for arguments. To work, BB16 must have a template. So we are going to create a if to check if one flag is used, then we must block the other one.

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.