0.0.8 • Published 5 years ago

@rappopo/cuk v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@rappopo/cuk

Donate

Rappopo CUK Core Loaders.

It loads all installed packages, assign & merge all configs, and prepare all functions to become callable throughout all packages.

Please do not send pull request for now, API isn't stable yet! Any pull requests will be ignored & silently rejected!!

Setup

Invoke this command in your CUK project directory:

$ npm install --save @rappopo/cuk-core

And put all your function helpers in ./cuks/core/helper

Function Helper

A function helper needs to be written according to the following rules:

  • One function per file
  • Use folders to categorize your helpers
  • CUK Core will generate camel cased name based on relative file path to the functions folder above
  • You can call those function helpers later from anywhere like this:
const { helper } = cuk.pkg.core.lib
helper('<camelCasedName>')(<arguments>)

To call a package helper from your project, prepend its name with <package-id>:, e.g.:

const { helper } = cuk.pkg.core.lib
let merged = helper('core:merge')({}, { key: 'value' })

Tutorial

$ cd <project>/cuks/core/helper
$ mkdir -p my/secret
$ cd my/secret
$ nano function.js

And enter the following content:

'use strict'

module.exports = function (cuk) {
  return (name) => {
    console.log(name)
  }
}

Save it, run your project. You can now call your helper like this:

...
const { helper } = cuk.pkg.core.lib
helper('mySecretFunction')('Hello!')
...

Links

Donation

  • Donate
  • Bitcoin 16HVCkdaNMvw3YdBYGHbtt3K5bmpRmH74Y

License

MIT