UNPKG

script-chain

Version:
1,410 lines (417 loc) 12.9 kB
# [script-chain](https://github.com/fliphub/fliphub#readme) *0.0.8* > fluent script building ### src/deps.js #### prefixer(prefix, names) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | prefix | `string` | prefix names if they don't already contain this, usually bound so it will be curried |   | | names | `string` `Array.<string>` | names to prefix |   | ##### Returns - `Array.<string>` prefixed strings #### real(input) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | input | `any` | any value |   | ##### Returns - `boolean` is real ### src/Flag.js #### new Flag() ##### Returns - `Void` #### Flag.init(parent) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `any` | |   | ##### Returns - `Flag` #### Flag.constructor(parent) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `any` | |   | ##### Returns - `Void` #### Flag.shouldStringify() ##### Returns - `boolean` ### src/index.js #### Boss() ##### Returns - `Void` ### src/Remember.js #### ObjChain() ##### Returns - `Void` #### new Remember() ##### Returns - `Void` #### Remember.progressBar(str) update a progress bar with averages ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | str | `string` | JSON.stringify(args) |   | ##### Returns - `Remember` #### Remember.start(args, progress) hash the args, check if it exists, store result ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | args | `Object` `string` | unique hash / name |   | | progress | `boolean` | |   | ##### Returns - `Remember` #### Remember.finish(args[, result]) hash the args, check if it exists, store result ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | args | `Object` | stringifiable hash to use as key for remembering |   | | result | `Object` | data, currently unused | *Optional* | ##### Returns - `Remember` @chainable ### src/Script.js #### ChainedMap() ##### Returns - `Void` #### new Script() ##### Returns - `Void` #### Script.constructor(parent) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `ScriptChain` | |   | ##### Returns - `Void` #### Script.add(name) returns to Scripts to add a new Script ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | |   | ##### Returns - `Scripts` chain back to parent for a new Script #### Script.doubleDash(arg) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | arg | `string` | |   | ##### Returns - `Script` @chainable #### Script.prefix(prefix) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | prefix | `string` | |   | ##### Returns - `Script` @chainable #### Script.flagIndex(index) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | index | | |   | ##### Returns - `Script` @chainable #### Script.file(file) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | file | `string` | path to file to exec |   | ##### Returns - `Script` @chainable #### Script.npm(npm) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | npm | `string` | npm script to execute |   | ##### Examples ```javascript input: .npm('diggity').env('magic').flag('env.zoolala', 'aoao').arg('-e') output: run-script diggy -- --env.zoolala=aoao -e ``` ##### Returns - `Script` @chainable #### Script.node([harmony=true]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | harmony=true | `boolean` | use harmony | *Optional* | ##### Returns - `Script` @chainable #### Script.bin(bin) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | bin | `string` | |   | ##### Returns - `Script` @chainable #### Script.raw(raw) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | raw | `string` | raw script to concat to the chain |   | ##### Returns - `Script` @chainable #### Script.stdout([stdout='stdout']) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | stdout='stdout' | `string` | | *Optional* | ##### Returns - `Script` @chainable #### Script.currentGroup() ##### Returns - `Array.<Flag|null>` #### Script.goToGroup([index]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | index | `number` | if blank, goes to last | *Optional* | ##### Returns - `Script` @chainable #### Script.group() ##### Returns - `Script` @chainable #### Script.addToGroup(flag[, index, group]) adds a flag to a specific group, defaults to current ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | flag | `Flag` | |   | | index | `number` | | *Optional* | | group | `number` | | *Optional* | ##### Returns - `Script` @chainable #### Script._addFlag([index, group]) *private method* ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | index | `number` | | *Optional* | | group | `number` | | *Optional* | ##### Returns - `Flag` #### Script.flag(name[, value]) use `arg` for no `--` if value === OFF, it is an arg with no value ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | |   | | value | `string` | | *Optional* | ##### Returns - `Script` @chainable #### Script.arg(name[, value, index, group]) if value === OFF, it is an arg with no value ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | |   | | value | `string` | | *Optional* | | index | `number` | | *Optional* | | group | `number` | | *Optional* | ##### Returns - `Script` @chainable #### Script.globFlag(name, apps[, dash=true]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | flag name |   | | apps | `string` `Array.<string>` | string names to use |   | | dash=true | `boolean` `string` | add `-` before it | *Optional* | ##### Returns - `Script` @chainable (Flag as current) #### Script.globArg(name, apps[, stringify]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | |   | | apps | `string` `Array.<string>` `boolean` | boolean when stringify |   | | stringify | `boolean` `string` | | *Optional* | ##### Returns - `Script` @chainable (Flag as current) #### Script.globEnv(env, apps) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string` | |   | | apps | `string` `Array.<string>` | |   | ##### Returns - `Script` @chainable (Flag as current) #### Script.globEnvAndFlag(env, apps, opts) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string` | |   | | apps | `string` `Array.<string>` | |   | | opts | `Object` | {dash: boolean, prefix: boolean} |   | ##### Returns - `Script` @chainable (Flag as current) #### Script.envArg(env) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string.<production, development, any>` | |   | ##### Returns - `Script` @chainable #### Script.envDefine(env, prop) to pass along to child_processes ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string.<production, development, any>` | |   | | prop | `string` | |   | ##### Returns - `Script` @chainable (Flag as current) #### Script.env(env) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string.<production, development, any>` | |   | ##### Returns - `Script` @chainable (Flag as current) #### Script.envs(env) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string` | |   | ##### Returns - `Script` @chainable (Flag as current) #### Script.lerna() ##### Returns - `Script` @chainable #### this.log([level='info']) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | level='info' | `string` | | *Optional* | ##### Returns - `Script` @chainable #### this.lernaEnv(env) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | env | `string` | |   | ##### Returns - `Script` @chainable #### this.scope(scope) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | scope | `string` | |   | ##### Returns - `Script` @chainable #### toArray([reduce]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | reduce | `boolean` | return as joined (should move to toStr) | *Optional* | ##### Returns - `Array.<string>` #### toString() ##### Returns - `string` #### toCmd() ##### Returns - `Object` ### src/ScriptChain.js #### ChainedMap() ##### Returns - `Void` #### new ScriptChain() ##### Examples ```javascript input scripts .add() .npm('diggy') .env('magic') .flag('env.zoolala', 'aoao') .arg('-e') ``` ```javascript output `${env} ${lerna} exec ${lernaLog} ${scoped} -- node ${binPath}` ``` ##### Returns - `Void` #### ScriptChain.init([parent]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `ScriptChain` `Chainable` `any` | | *Optional* | ##### Returns - `ScriptChain` #### ScriptChain.constructor([parent]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `ScriptChain` `Chainable` `any` | | *Optional* | ##### Returns - `Void` #### ScriptChain.env(name, value) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | |   | | value | `string` | |   | ##### Returns - `ScriptChain` @chainable #### ScriptChain.stdout([stdout]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | stdout | `string` | | *Optional* | ##### Returns - `ScriptChain` @chainable #### ScriptChain.add() ##### Returns - `Void` #### ScriptChain.toString() ##### Returns - `Void` #### ScriptChain.toCmd() ##### Returns - `Void` #### ScriptChain.run() ##### Returns - `Promise.all` execa promise of all commands ### src/ScriptPermutator.js #### toarr() ##### Returns - `Void` #### new ScriptPermutator() ##### Returns - `Void` ### src/Scripts.js #### ChainedMap() ##### Returns - `Void` #### new Scripts() ##### Returns - `Void` #### Scripts.constructor(parent) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | parent | `Chainable` | |   | ##### Returns - `Void` #### Scripts.add([name]) start/add/name a script ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | name | `string` | | *Optional* | ##### Returns - `Script` #### Scripts.toCmd() ##### Returns - `Array` #### Scripts.toString() ##### Returns - `Array` !!! *Documentation generated with [doxdox](https://github.com/neogeek/doxdox).*