npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

codebot

v0.0.12

Published

Codebot is a tool to make applications from templates and a model..

Downloads

13

Readme

{--} CodebotJS

This project is under development

Codebot is the easy way to make applications from templates.

The idea is that you need to write the code one time, then use a model.

Think an application, write it as templates and then use to make multiple apps changin the model, if you improve something, change the templates and every app will take the benefit.

Install

npm i --save-dev codebot

Templates

Codebot use ejs as default template engine

If the src is not defined on /path/from/module/codebot.json, the templates will be searched on the /path/from/module/src/ folder

Directives to filenames and folders

directive|usage |description ---------|-----------|----------- # |#layername|layer/folder names @ |@filename |automatic file ! |!filename |injector file (not supported yet) ${} |${target} |dynamics names $this |${$this} |current dynamic name from parent

Modifiers

character|usage |description ---------|----------|----------- l |$l{target}|write the target as lowerCase* u |$u{target}|write the target as upperCase* c |$c{target}|write the target as camelCase* s |$s{target}|write the target as snakeCase* k |$k{target}|write the target as kebabCase* p |$p{target}|write the target as capitalize*

*please see the lodash documentation

Configuration file

// codebot.json
{
  "src": "the_source/",
  "ignore": [ "some_file/expression" ]
}

NOTE: you can set the config into the package.json like

{
  "name": "my-awesome-template",
  ....
  "codebot": {
    "src": "the_source/"
  }
  ....
}

Usage

import codebot from 'codebot';

let model = {
  foo: 'bar'
};

let ops = {
  modules: [
    '/path/from/templates/module1',
    'path/from/templates/module2'
  ],
  output: '/path/to/',
  model: model
};

codebot(ops)
  .then(results => {
    // all tamplates are processed

    // show the trees
    results.modules.forEach( m => {
      console.log(m.toString(true, 'source-tree'));
    });
    console.log('');
    results.modules.forEach( m => {
      console.log(m.toString(true, 'output-tree'));
    });
  })
  .catch(err => {
    console.log(err);
  });

The inject file example (not supported yet)

the transpiler match a full line with the codebot:inject thing

  // !some.js
  // inject:codebot
  console.log($this.name);
  // endinject
  // !some.html
  <!-- inject:codebot -->
  <h1><%= $this.title %></h1>
  <!-- endinject -->

Usage with gulp

npm i --save-dev gulp-codebot
var codebot = require('gulp-codebot');

var modules = [
  '/path/from/templates/module1',
  '/path/from/templates/module2'
];

gulp.src('./model.json')
    .pipe(codebot({ modules: modules }))
    .pipe(gulp.dest('./src'));

Example

//model.json
{
  layer: {
    'app': './client/app',
    'routes': './server/routes'
  },
  target: {
    'actor': { 
      plurals: 'actors',
      view: {
        'add': {/*view stuff*/}
      }
    },
    'director': { 
      plurals: 'directors',
      view: {
        'add': {/*view stuff*/}
      }
    },
    'movie': { 
      plurals: 'movies',
      view: {
        'add': {/*view stuff*/},
        'edit': {/*view stuff*/},
        'search': {/*view stuff*/},
      }
    }
  }
}

Templates example

// /path/from/angular/src/
- #app
  - ${target}
    - @${$current}.controller.js
    - @${$current.view}.html
    - !config.js
  - @app.config.js
  - app.js
// /path/from/api/src/
- #routes
  - @${target.plurals}.js

The output

./client/app/actor/actor.controller.js       // writed every time
./client/app/actor/config.js                 // writed/injected every time
./client/app/actor/add.html                  // writed every time

./client/app/director/director.controller.js // writed every time
./client/app/director/config.js              // writed if the output is not exists
./client/app/director/add.html               // writed every time

./client/app/movie/movie.controller.js       // writed every time
./client/app/movie/config.js                 // writed if the output is not exists
./client/app/movie/add.html                  // writed every time
./client/app/movie/edit.html                 // writed every time
./client/app/movie/search.html               // writed every time

./client/app/app.config.js                   // writed every time
./client/app/app.js                          // writed if the output is not exists

./server/routes/actors.js                    // writed every time
./server/routes/directors.js                 // writed every time
./server/routes/movies.js                    // writed every time

License

MIT © Delmo