roc
Version:
Build modern web applications easily
126 lines (106 loc) • 5.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _validators = require('../validation/validators');
var _converters = require('../converters');
var _init = require('../commands/init');
var _init2 = _interopRequireDefault(_init);
var _markdownCommands2 = require('../commands/markdown-commands');
var _markdownCommands3 = _interopRequireDefault(_markdownCommands2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _require = require('../../package.json');
const name = _require.name;
const initOptions = [{
name: 'list',
shortname: 'l',
validation: _validators.isBoolean,
description: 'List the available versions of a template.'
}, {
name: 'force',
shortname: 'f',
validation: _validators.isBoolean,
description: 'Ignore non empty directory warning.'
}];
const initArguments = [{
name: 'template',
validation: _validators.isPath,
description: 'The template to use. Matches Github structure with Username/Repo or a local zip file.'
}, {
name: 'version',
validation: _validators.isString,
description: 'The version to use.'
}];
const roc = {
name,
config: {
commands: {
init: _init2.default,
'new': _init2.default,
'markdown-commands': _ref => {
let packageConfig = _ref.packageConfig;
let metaObject = _ref.metaObject;
let cliName = _ref.info.name;
let settingsLink = _ref.parsedArguments.arguments['settings-link'];
let hideCommands = _ref.parsedOptions.options['hide-commands'];
console.log((0, _markdownCommands3.default)(cliName, packageConfig, metaObject, settingsLink, hideCommands));
}
}
},
meta: {
commands: {
'init': {
description: 'Init a new project.',
/* eslint-disable max-len */
help: `
Used to init new projects using special templates. If no template is given a prompt will ask for one.
The templates are fetched from Github and it's easy to create new ones.`,
markdown: `
The __init__ command can be used to initiate a new Roc project and currently expects that it's run inside an empty directory. As can be seen above it takes two optional arguments, template and version. If no template is given a prompt will be shown with the possible alternatives that exists. Currently these alternatives are coded into Roc and matches \`web-app\` and \`web-app-react\`.
__template__
Template can either be a short name for a specific template, currently it accepts \`web-app\` and \`web-app-react\` that will be converted internally to \`rocjs/roc-template-web-app\` and \`rocjs/roc-template-web-app-react\`. As can be seen here the actual template reference is a Github repo and can be anything matching that pattern \`USERNAME/PROJECT\`.
The template can also point to a local zip file (ending in \`.zip\`) of a template repository. This is useful if the template is on a private repo or not on GitHub.
It will also expect that the template has a folder named \`template\` and that inside of it there is \`package.json\` file with at least one dependency to a Roc module following the pattern \`roc-package-*\` or that it has a \`roc.config.js\` file (this file is then expected to have some [packages](/docs/config/packages.md) defined but this is not checked immediately).
__version__
Versions should match a tag on the Github repo and will default to master if none exists. When giving an input on the command line Roc will automatically add \`v\` in front of versions that starts with a number to match Github default that have versions tags that start with \`v\` like \`v1.0.0\`. \`master\` is also always available as an option.`,
/* eslint-enable */
options: initOptions,
arguments: initArguments
},
'new': {
description: 'Create a new project.',
help: `
Alias for "init" that always will try to create a new directory.`,
options: initOptions,
arguments: [].concat({
name: 'name',
validation: _validators.isString,
description: 'Name for a new directory to create the project in.',
required: true
}, initArguments)
},
'markdown-commands': {
description: 'Create markdown documentation for the commands.',
arguments: [{
name: 'settings-link',
validation: _validators.isString,
description: 'A link that should be used when generation to link to the settings location.'
}],
options: [{
name: 'hide-commands',
default: [],
validation: (0, _validators.isArray)(_validators.isString),
converter: _converters.toArray,
description: 'A list of commands that should be hidden form the generated markdown.'
}]
}
}
}
};
/**
* Roc object
*
* @returns {rocObject} - The rocObject used by the base cli.
*/
exports.default = roc;
//# sourceMappingURL=index.js.map