Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored to use scaffolder rather than climate

  • Loading branch information...
commit 5e90a50ef4b040caad40a1b205c8ea240cf2fea8 1 parent 6eb1203
@DamonOehlman authored
View
14 bin/docstar
@@ -1,11 +1,5 @@
#!/usr/bin/env node
-
-var path = require('path'),
- repl = require('climate').repl('docstar>');
-
-// load the actions and run
-repl
- .history()
- .loadActions(path.resolve(__dirname, '../lib/actions'), function() {
- repl.run(process.argv.slice(2).join(' '));
- });
+require('scaffolder')({
+ init: [
+ ]
+});
View
5 lib/actions/build.js
@@ -1,5 +0,0 @@
-var docstar = require('../docstar');
-
-module.exports = function(opts, callback) {
- console.log(opts);
-};
View
34 lib/actions/scaffold.js
@@ -1,34 +0,0 @@
-var events = require('events'),
- debug = require('debug')('docstar'),
- path = require('path'),
- util = require('util'),
- out = require('out');
-
-function _sync(docstar, scaffolder, callback) {
- scaffolder.loadPackageData(function(err, data) {
- if (! err) {
- docstar.tweakConfig({
- copyright: (new Date().getFullYear()) + ', ' + data.author,
- project: data.name,
- version: data.version
- });
- }
-
- callback(err, data);
- });
-};
-
-module.exports = function() {
- var cli = this;
-
- require('../docstar').init(function(err, docstar) {
- if (err) {
- out('!{red}{0}', err);
- }
- else {
- docstar.scaffolder.copy('docs', docstar.path, function() {
- cli.run('quit');
- });
- }
- });
-};
View
34 lib/actions/sync.js
@@ -1,34 +0,0 @@
-var docstar = require('../docstar'),
- events = require('events'),
- debug = require('debug')('docstar'),
- path = require('path'),
- util = require('util');
-
-function _sync(docstar, scaffolder, callback) {
- scaffolder.loadPackageData(function(err, data) {
- if (! err) {
- docstar.tweakConfig({
- copyright: (new Date().getFullYear()) + ', ' + data.author,
- project: data.name,
- version: data.version
- });
- }
-
- callback(err, data);
- });
-};
-
-module.exports = function(opts, callback) {
- var scaffolder = this;
-
- docstar.init(opts, function(err, instance) {
- if (err) {
- scaffolder.out(err);
- }
- else {
- _sync(instance, scaffolder, function() {
-
- });
- }
- });
-};
View
25 lib/actions/config.js → lib/commands/config.js
@@ -3,7 +3,6 @@ var events = require('events'),
pkginfo = require('pkginfo'),
path = require('path'),
util = require('util'),
- out = require('out'),
_ = require('underscore'),
repoTypes = {
github: {
@@ -29,22 +28,22 @@ function ConfigHelper() {
};
-ConfigHelper.prototype.create = function(docstar, repl) {
+ConfigHelper.prototype.create = function(docstar, scaffolder) {
var helper = this;
path.exists(docstar.getConfigPath(), function(exists) {
// TODO: if the file exists, check that the user wants to overwrite
if (exists) {
- out('!{red}There is an existing configuration, please remove before attempting to create a new config.');
+ scaffolder.out('!{red}There is an existing configuration, please remove before attempting to create a new config.');
return;
}
- docstar.scaffolder.copy(
+ scaffolder.copy(
'assets/config',
docstar.path,
function() {
// now call the update method
- helper.sync(docstar, repl);
+ helper.sync(docstar, scaffolder);
}
);
});
@@ -64,12 +63,20 @@ ConfigHelper.prototype.sync = function(docstar, repl) {
copyright: (new Date().getFullYear()) + ', ' + data.author,
project: data.name,
version: data.version
- }, repoData), repl.run.bind(repl, 'quit'));
+ }, repoData));
}
};
-module.exports = function(action) {
- var repl = this;
+// action description
+exports.desc = 'Synchronize the sphinx conf.py with the package.json file';
+
+exports.args = {
+};
+
+// export runner
+exports.run = function(opts, callback) {
+ var scaffolder = this,
+ action = opts.argv.remain[0];
require('../docstar').init(function(err, instance) {
if (err) {
@@ -81,7 +88,7 @@ module.exports = function(action) {
// if the config helper supports the action, then call it
if (typeof helper[action] == 'function') {
- helper[action].call(helper, instance, repl);
+ helper[action].call(helper, instance, scaffolder);
}
else {
out('Do not know how to \'config ' + action + '\'');
View
21 lib/commands/scaffold.js
@@ -0,0 +1,21 @@
+var path = require('path');
+
+// action description
+exports.desc = 'Scaffold base docs';
+
+exports.args = {
+};
+
+// export runner
+exports.run = function(opts, callback) {
+ var scaffolder = this;
+
+ require('../docstar').init(function(err, docstar) {
+ if (err) {
+ scaffolder.out('!{red}{0}', err);
+ }
+ else {
+ scaffolder.copy(path.join('assets', 'docs'), docstar.path, callback);
+ }
+ });
+};
View
30 lib/actions/theme.js → lib/commands/theme.js
@@ -3,14 +3,12 @@ var async = require('async'),
debug = require('debug')('docstar'),
scaffolder = require('scaffolder'),
path = require('path'),
- util = require('util'),
- out = require('out');
+ util = require('util');
function ThemeHelper() {
-
-};
+}
-ThemeHelper.prototype.use = function(docstar, cli, extraArgs) {
+ThemeHelper.prototype.use = function(docstar, scaffolder, extraArgs) {
var theme = extraArgs[0],
helper = this;
@@ -21,22 +19,26 @@ ThemeHelper.prototype.use = function(docstar, cli, extraArgs) {
debug('copying theme to : ' + path.join(docstar.path, '_theme/' + theme));
async.series([
- docstar.scaffolder.copy.bind(docstar.scaffolder, 'assets/themes/' + theme, path.join(docstar.path, '_theme/' + theme)),
+ scaffolder.copy.bind(scaffolder, 'assets/themes/' + theme, path.join(docstar.path, '_theme/' + theme)),
docstar.tweakConfig.bind(docstar, { theme: theme })
],
function(err) {
if (err) {
docstar.error(err);
}
-
- cli.run('quit');
});
};
-module.exports = function(input) {
- var cli = this,
- extraArgs = (input || '').split(/\s/),
- action = extraArgs[0] || 'use';
+// action description
+exports.desc = 'Docstar theme tools';
+
+exports.args = {
+};
+
+// export runner
+exports.run = function(opts, callback) {
+ var scaffolder = this,
+ action = opts.argv.remain[0] || 'use';
require('../docstar').init(function(err, docstar) {
if (err) {
@@ -48,10 +50,10 @@ module.exports = function(input) {
// if the config helper supports the action, then call it
if (typeof helper[action] == 'function') {
- helper[action].call(helper, docstar, cli, extraArgs.slice(1));
+ helper[action].call(helper, docstar, scaffolder, opts.argv.remain.slice(1));
}
else {
- out('Do not know how to \'theme ' + action + '\'');
+ scaffolder.out('Do not know how to \'theme ' + action + '\'');
}
}
});
View
31 lib/docstar.js
@@ -2,7 +2,6 @@ var fs = require('fs'),
path = require('path'),
debug = require('debug')('docstar'),
glob = require('glob'),
- out = require('out'),
SPHINX_CONFIG_FILE = 'conf.py',
tweakRegexes = {
copyright: /^(copyright).*/m,
@@ -21,10 +20,6 @@ function DocStar(docpath) {
debug('docpath set to ' + this.path);
};
-DocStar.prototype.error = function(err) {
- out('!{red}: {0}', err);
-};
-
DocStar.prototype.getConfigPath = function() {
return path.join(this.path, SPHINX_CONFIG_FILE);
};
@@ -65,16 +60,16 @@ DocStar.prototype.tweakConfig = function(updates, callback) {
};
DocStar.prototype.writeConfig = function(data, callback) {
- var configPath = this.getConfigPath();
-
- debug('attempting to write config update to: ' + configPath);
+ var configPath = this.getConfigPath();
+
+ debug('attempting to write config update to: ' + configPath);
fs.writeFile(configPath, data, 'utf8', function(err) {
- debug('updated config file: ' + configPath + (err ? ', err: ' + err : ''));
-
- if (callback) {
- callback(err);
- }
- });
+ debug('updated config file: ' + configPath + (err ? ', err: ' + err : ''));
+
+ if (callback) {
+ callback(err);
+ }
+ });
};
exports.init = function(callback) {
@@ -89,12 +84,8 @@ exports.init = function(callback) {
if (matches.length <= 1) {
var docstar = new DocStar(matches[0] ? path.dirname(matches[0]) : '');
-
- // create the scaffolder
- docstar.scaffolder = require('scaffolder')(module);
- docstar.scaffolder.on('ready', function() {
- callback(null, docstar);
- });
+
+ callback(null, docstar);
}
else {
callback('Too many possible documentation directories, please review');
View
11 package.json
@@ -13,17 +13,16 @@
"docstar": "./bin/docstar"
},
"engines": {
- "node": ">= 0.4.x < 0.7.0"
+ "node": ">= 0.6.x < 0.9.0"
},
"dependencies": {
"async": "0.1.x",
- "climate": "0.2.x",
"debug": "*",
- "scaffolder": "0.4.x",
- "attachmate": "0.1.x",
- "glob": "3.x.x",
- "out": "*",
+ "glob": "3.1.x",
+ "mkdirp": "0.3.x",
+ "ncp": "0.2.x",
"pkginfo": "0.2.x",
+ "scaffolder": "0.6.x",
"underscore": "1.3.x"
},
"devDependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.