UNPKG

tiddlywiki-plugin-dev

Version:

[![](https://img.shields.io/badge/Join-TiddlyWiki_CN-blue)](https://github.com/tiddly-gittly)

75 lines (74 loc) 4.36 kB
#!/usr/bin/env node "use strict"; var _commander = require("commander"); var _init = require("./init"); var _dev = require("./dev"); var _test = require("./test"); var _new = require("./new"); var _build = require("./build"); var _publish = require("./publish"); _commander.program.name('tiddlywiki-plugin-dev').description('Tiddlywiki plugin development tool, working with https://github.com/tiddly-gittly/Modern.TiddlyDev'); _commander.program.command('dev').description('Start a TiddlyWiki server with your plugin(s) for test. It will always watch the file changes in the plugin folder(s) and refresh the browser page automatically.').option('--wiki <wiki-path>', 'Path of your wiki to publish', './wiki').option('--src <src-path>', 'Root path of developing plugins', './src').option('--write-wiki', 'Write back changes from browser to the wiki. (If without this, wiki is readonly)').option('--lan', 'Listen on 0.0.0.0, so it can be open on mobile phone on same lan wifi (If without this, wiki is on `127.0.0.1`, which can only open on the local machine)').option('--exclude <exclude-filter>', 'Filter to exclude publishing plugins. e.g. [prefix[$:/plugins/aaa/]]', undefined).action(async ({ wiki, exclude, src, writeWiki, lan }) => { await (0, _dev.runDev)(wiki, src, { writeWiki, excludeFilter: exclude, lan }); }); _commander.program.command('test').description('Run tests using Jasmine plugin. And works simillar to dev.').option('--wiki <wiki-path>', 'Path of your wiki to publish', './wiki').option('--src <src-path>', 'Root path of developing plugins', './src').option('--exclude <exclude-filter>', 'Filter to exclude publishing plugins. e.g. [prefix[$:/plugins/aaa/]]', undefined).action(async ({ wiki, exclude, src }) => { await (0, _test.runTest)(wiki, src, exclude); }); _commander.program.command('build').description('Build plugins for Modern.TiddlyDev').option('--library', 'whether to build plugin library files', false).option('--output <output>', 'set output directory', 'dist').option('--wiki <wiki-path>', 'Path of your wiki to publish', './wiki').option('--src <src-path>', 'Root path of developing plugins', './src').option('--exclude <exclude-filter>', 'Filter to exclude publishing plugins. e.g. [prefix[$:/plugins/aaa/]]', undefined).action(async ({ library, output, src, wiki, exclude }) => { if (library) { await (0, _build.buildLibrary)(output, exclude, src, wiki); } else { await (0, _build.build)(output, exclude, src); } // eslint-disable-next-line no-process-exit process.exit(0); }); _commander.program.command('new').description('Create a new plugin').option('--src <src-path>', 'Root path of developing plugins', './src').action(async ({ src }) => { await (0, _new.createPlugin)(src); }); _commander.program.command('init').description('Create a Modern.TiddlyDev project').argument('<project>', 'Direction name of project').option('--repo <github-url>', 'Magic for China mainland user', undefined).option('--npm <npm-url>', 'Magic for China mainland user', undefined).action(async (project, { repo, npm }) => { await (0, _init.init)(project, repo || 'https://github.com/tiddly-gittly/Modern.TiddlyDev.git', npm); }); _commander.program.command('publish').description('Publish wiki').argument('[dist]', 'Destination folder to publish', 'dist').option('-e, --exclude <exclude-filter>', 'Filter to exclude publishing tiddlers', '-[is[draft]]').option('--exclude-plugin <exclude-plugin-filter>', 'Filter to exclude publishing plugins. e.g. [prefix[$:/plugins/aaa/]]', undefined).option('--offline', 'Generate single wiki file', false).option('--src <src-path>', 'Root path of developing plugins', './src').option('--html <html-file>', 'File name of generated index html file', 'index.html').option('--no-library', 'Do not generate plugin library', true).option('--wiki <wiki-path>', 'Path of your wiki to publish', './wiki').action(async (dist, { offline, exclude, excludePlugin, library, html, wiki, src }) => { if (offline) { await (0, _publish.publishOfflineHTML)(wiki, dist, html, exclude, library, src, excludePlugin); } else { await (0, _publish.publishOnlineHTML)(wiki, dist, html, exclude, library, src, excludePlugin); } // eslint-disable-next-line no-process-exit process.exit(0); }); _commander.program.parse();