@canopycanopycanopy/b-ber-cli 1.2.16 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
3
4
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
- var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
6
-
5
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
6
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
8
-
9
7
  _Object$defineProperty(exports, "__esModule", {
10
8
  value: true
11
9
  });
12
-
13
10
  exports.default = bber;
14
-
15
11
  var _yargs = _interopRequireDefault(require("yargs"));
16
-
17
12
  var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
18
-
19
13
  var commands = _interopRequireWildcard(require("./commands"));
20
-
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
16
  const LINE_LENGTH = 70;
22
-
23
17
  function bber() {
24
18
  const showCustomHelp = () => console.log(`
25
19
  Usage: bber <command> [options]
@@ -34,6 +28,5 @@ function bber() {
34
28
 
35
29
  bber version ${_State.default.version}
36
30
  `);
37
-
38
31
  return _yargs.default.command(commands.build).command(commands.generate).command(commands.opf).command(commands.theme).command(commands.serve).command(commands.new).command(commands.cover).command(commands.deploy).command(commands.check).help(false).fail(showCustomHelp).demandCommand().wrap(LINE_LENGTH).argv;
39
32
  }
@@ -1,70 +1,89 @@
1
1
  "use strict";
2
2
 
3
+ var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
+ var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
+ var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
3
10
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
11
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
12
  _Object$defineProperty(exports, "__esModule", {
8
13
  value: true
9
14
  });
10
-
11
15
  exports.default = void 0;
12
-
13
16
  var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
14
-
15
17
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
16
-
18
+ var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
19
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
20
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
17
21
  var _path = _interopRequireDefault(require("path"));
18
-
19
22
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
20
-
21
23
  var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
22
-
23
24
  var _createBuildSequence = _interopRequireDefault(require("@canopycanopycanopy/b-ber-shapes-sequences/create-build-sequence"));
24
-
25
25
  var _sequences = _interopRequireDefault(require("@canopycanopycanopy/b-ber-shapes-sequences/sequences"));
26
-
27
26
  var _Project = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Project"));
28
-
29
27
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
30
-
31
28
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
32
-
33
- // note leading pipe - to ensure we can run the `all` command without arguments
29
+ var _configOptions = require("../lib/config-options");
30
+ const _excluded = ["_", "$0", "config"];
31
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
+ // Leading pipe ensures that the `all` command can be run without arguments
34
34
  const command = 'build [|epub|mobi|pdf|reader|sample|web]';
35
35
  const describe = 'Build a project';
36
-
37
- const handler = argv => {
36
+ const noop = () => {};
37
+ const handler = async argv => {
38
38
  process.env.NODE_ENV = process.env.NODE_ENV || 'development';
39
- const sequence = (0, _createBuildSequence.default)(argv);
39
+ const {
40
+ _: desiredSequences,
41
+ $0,
42
+ config
43
+ } = argv,
44
+ configOptions = (0, _objectWithoutProperties2.default)(argv, _excluded);
45
+ const sequence = (0, _createBuildSequence.default)(desiredSequences);
40
46
  const subSequence = (0, _reduce.default)(sequence).call(sequence, (a, c) => (0, _concat.default)(a).call(a, ..._sequences.default[c]), []);
41
47
 
42
- _State.default.update('sequence', subSequence);
48
+ // Set up the config object that's going to be passed into the `init` function
49
+ let projectConfig = {};
43
50
 
51
+ // Check if a config files has been specified
52
+ if (config) projectConfig = await (0, _configOptions.parseConfigFile)(config);
53
+ projectConfig = _objectSpread(_objectSpread({}, projectConfig), configOptions);
54
+ _State.default.update('sequence', subSequence);
44
55
  _bBerLogger.default.registerSequence(_State.default, command, subSequence);
45
-
46
56
  const run = buildTasks => {
47
57
  const build = buildTasks.shift();
48
58
 
59
+ // Reset any previous changes to state and update the build type
49
60
  _State.default.reset();
50
-
51
61
  _State.default.update('build', build);
52
62
 
63
+ // Apply the config options that may have been passed in via CLI flags
64
+ for (const [key, val] of (0, _entries.default)(projectConfig)) {
65
+ if (!_State.default.has(`config.${key}`)) {
66
+ _bBerLogger.default.warn('Invalid configuration option [%s]', key);
67
+ continue;
68
+ }
69
+ if (_configOptions.blacklistedConfigOptions.has(key)) {
70
+ _bBerLogger.default.warn('Disallowed configuration option [%s]', key);
71
+ continue;
72
+ }
73
+ _bBerLogger.default.notice('Applying configuration option [%s]:[%s]', key, val);
74
+ _State.default.update(`config.${key}`, val);
75
+ }
53
76
  return (0, _bBerTasks.serialize)(_sequences.default[build]).then(() => {
54
77
  if (buildTasks.length) run(buildTasks);
55
78
  });
56
79
  };
57
-
58
80
  const projectPath = _path.default.resolve(_State.default.srcDir);
59
-
60
81
  const files = [..._Project.default.javascripts(projectPath), ..._Project.default.stylesheets(projectPath)];
61
82
  (0, _utils.ensure)({
62
83
  files
63
84
  }).then(() => run(sequence)).catch(console.error);
64
85
  };
65
-
66
- const builder = yargs => yargs.command('', 'Build all formats', () => {}, handler).command('epub', 'Build an Epub', () => {}, handler).command('mobi', 'Build a Mobi', () => {}, handler).command('pdf', 'Build a PDF', () => {}, handler).command('reader', 'Build for the b-ber-reader format', () => {}, handler).command('sample', 'Build a sample Epub', () => {}, handler).command('web', 'Build for web', () => {}, handler).command('xml', 'Build for XML', () => {}, handler).help('h').alias('h', 'help');
67
-
86
+ const builder = yargs => (0, _configOptions.withConfigOptions)(yargs).command('', 'Build all formats', noop, handler).command('epub', 'Build an Epub', noop, handler).command('mobi', 'Build a Mobi', noop, handler).command('pdf', 'Build a PDF', noop, handler).command('reader', 'Build for the b-ber-reader format', noop, handler).command('sample', 'Build a sample Epub', noop, handler).command('web', 'Build for web', noop, handler).command('xml', 'Build for XML', noop, handler).help('h').alias('h', 'help');
68
87
  var _default = {
69
88
  command,
70
89
  describe,
@@ -1,32 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
14
-
15
10
  const command = 'check [project]';
16
11
  const describe = 'Validate b-ber project Markdown';
17
-
18
12
  const builder = yargs => yargs.positional('project', {
19
13
  describe: 'Path to the b-ber project',
20
14
  type: 'string'
21
15
  }).help('h').alias('h', 'help').fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).usage(`\nUsage: $0 check\n\n${describe}`);
22
-
23
16
  const handler = argv => {
24
17
  const project = argv.project || process.cwd();
25
18
  (0, _bBerTasks.validate)({
26
19
  project
27
20
  });
28
21
  };
29
-
30
22
  var _default = {
31
23
  command,
32
24
  describe,
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
14
-
15
10
  const command = 'cover';
16
11
  const describe = 'Generate a project cover';
17
-
18
12
  const builder = yargs => yargs.fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 cover\n\n${describe}`);
19
-
20
13
  const handler = () => _bBerTasks.cover.init();
21
-
22
14
  var _default = {
23
15
  command,
24
16
  describe,
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
14
-
15
10
  const command = 'deploy [builds...]';
16
11
  const describe = 'Upload a b-ber project to Amazon S3';
17
-
18
12
  const builder = yargs => yargs.option('yes', {
19
13
  alias: 'y',
20
14
  describe: 'Skip all confirmation prompts',
@@ -24,7 +18,6 @@ const builder = yargs => yargs.option('yes', {
24
18
  choices: ['epub', 'mobi', 'reader', 'web', 'pdf', 'xml'],
25
19
  type: 'string'
26
20
  }).help('h').alias('h', 'help').usage(`\nUsage: $0 deploy\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
27
-
28
21
  const handler = _bBerTasks.deploy;
29
22
  var _default = {
30
23
  command,
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
14
-
15
10
  const command = 'generate <title> [type]';
16
11
  const describe = 'Create a new chapter. Accepts arguments for metadata';
17
-
18
12
  const builder = yargs => yargs.positional('title', {
19
13
  describe: 'Page title',
20
14
  type: 'string'
@@ -23,7 +17,6 @@ const builder = yargs => yargs.positional('title', {
23
17
  choices: ['frontmatter', 'bodymatter', 'backmatter'],
24
18
  type: 'string'
25
19
  }).help('h').alias('h', 'help').usage(`\nUsage: $0 generate\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
26
-
27
20
  const handler = ({
28
21
  title,
29
22
  type
@@ -31,7 +24,6 @@ const handler = ({
31
24
  title,
32
25
  type
33
26
  })).catch(console.error);
34
-
35
27
  var _default = {
36
28
  command,
37
29
  describe,
@@ -1,90 +1,70 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  _Object$defineProperty(exports, "build", {
12
9
  enumerable: true,
13
10
  get: function () {
14
11
  return _build.default;
15
12
  }
16
13
  });
17
-
18
14
  _Object$defineProperty(exports, "check", {
19
15
  enumerable: true,
20
16
  get: function () {
21
17
  return _check.default;
22
18
  }
23
19
  });
24
-
25
20
  _Object$defineProperty(exports, "cover", {
26
21
  enumerable: true,
27
22
  get: function () {
28
23
  return _cover.default;
29
24
  }
30
25
  });
31
-
32
26
  _Object$defineProperty(exports, "deploy", {
33
27
  enumerable: true,
34
28
  get: function () {
35
29
  return _deploy.default;
36
30
  }
37
31
  });
38
-
39
32
  _Object$defineProperty(exports, "generate", {
40
33
  enumerable: true,
41
34
  get: function () {
42
35
  return _generate.default;
43
36
  }
44
37
  });
45
-
46
38
  _Object$defineProperty(exports, "new", {
47
39
  enumerable: true,
48
40
  get: function () {
49
41
  return _new.default;
50
42
  }
51
43
  });
52
-
53
44
  _Object$defineProperty(exports, "opf", {
54
45
  enumerable: true,
55
46
  get: function () {
56
47
  return _opf.default;
57
48
  }
58
49
  });
59
-
60
50
  _Object$defineProperty(exports, "serve", {
61
51
  enumerable: true,
62
52
  get: function () {
63
53
  return _serve.default;
64
54
  }
65
55
  });
66
-
67
56
  _Object$defineProperty(exports, "theme", {
68
57
  enumerable: true,
69
58
  get: function () {
70
59
  return _theme.default;
71
60
  }
72
61
  });
73
-
74
62
  var _build = _interopRequireDefault(require("./build"));
75
-
76
63
  var _cover = _interopRequireDefault(require("./cover"));
77
-
78
64
  var _deploy = _interopRequireDefault(require("./deploy"));
79
-
80
65
  var _generate = _interopRequireDefault(require("./generate"));
81
-
82
66
  var _new = _interopRequireDefault(require("./new"));
83
-
84
67
  var _opf = _interopRequireDefault(require("./opf"));
85
-
86
68
  var _serve = _interopRequireDefault(require("./serve"));
87
-
88
69
  var _theme = _interopRequireDefault(require("./theme"));
89
-
90
70
  var _check = _interopRequireDefault(require("./check"));
@@ -1,171 +1,76 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
6
-
7
5
  var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
8
-
9
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
10
-
11
7
  var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
12
-
13
8
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
14
-
15
9
  var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
16
-
17
10
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
18
-
19
11
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
20
-
21
12
  _Object$defineProperty(exports, "__esModule", {
22
13
  value: true
23
14
  });
24
-
25
15
  exports.default = void 0;
26
-
16
+ var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
27
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
28
-
29
18
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
30
-
31
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
32
-
33
- var _path = _interopRequireDefault(require("path"));
34
-
19
+ var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
35
20
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
36
-
37
21
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
38
-
39
- var _YamlAdaptor = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/YamlAdaptor"));
40
-
41
22
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
42
-
23
+ var _configOptions = require("../lib/config-options");
43
24
  const _excluded = ["_", "$0", "name", "config"];
44
-
45
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
46
-
47
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
48
-
25
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
49
27
  const command = 'new <name>';
50
28
  const describe = 'Create a new project';
51
-
52
- const builder = yargs => yargs.positional('name', {
29
+ const builder = yargs => (0, _configOptions.withConfigOptions)(yargs.positional('name', {
53
30
  describe: 'New project name',
54
31
  type: 'string'
55
- }).option('env', {
56
- describe: 'The default build environment',
57
- type: 'string' // default: 'development',
58
-
59
- }).option('theme', {
60
- describe: 'Default theme name',
61
- type: 'string' // default: 'b-ber-theme-serif',
62
-
63
- }).option('src', {
64
- describe: 'The name of the source directory',
65
- type: 'string' // default: 'src',
66
-
67
- }).option('dist', {
68
- describe: 'The name of the dist directory',
69
- type: 'string' // default: 'dist',
70
-
71
- }).option('cache', {
72
- describe: 'Whether to enable caching',
73
- type: 'boolean' // default: false,
74
-
75
- }).option('themes_directory', {
76
- describe: 'Relative or absolute path to the directory for third-party themes',
77
- type: 'string' // default: './themes',
78
-
79
- }).option('ignore', {
80
- describe: 'Array of files or folders to ignore during the build',
81
- type: 'array' // default: [],
82
-
83
- }).option('base_path', {
84
- describe: 'Base path appended to the URL for the reader build',
85
- type: 'string' // default: '/',
86
-
87
- }).option('remote_url', {
88
- describe: 'URL at which the reader build will be made public',
89
- type: 'string' // default: 'http://localhost:4000/',
90
-
91
- }).option('reader_url', {
92
- describe: 'URL that hosts the assets for the reader reader build',
93
- type: 'string' // default: 'http://localhost:4000/project-reader',
94
-
95
- }).option('bucket_url', {
96
- describe: 'The S3 bucket URL where the remote project will be deployed to if hosting on S3',
97
- type: 'string' // default: '',
98
-
99
- }).option('private', {
100
- describe: 'If the web and reader builds should be discoverable by search engines',
101
- type: 'boolean' // default: false,
102
-
103
- }).option('remote_javascripts', {
104
- describe: 'Remotely hosted JavaScript files for the reader',
105
- type: 'array' // default: [],
106
-
107
- }).option('remote_stylesheets', {
108
- describe: 'Remotely hosted stylesheets files for the reader',
109
- type: 'array' // default: [],
110
-
111
- }).option('config', {
112
- describe: 'Path to a JSON or YAML configuration file that will extend the base configuration',
113
- type: 'string' // default: '',
114
-
115
- }).fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 new "My Project"\n\n${describe}`);
116
-
32
+ })).fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 new "My Project"\n\n${describe}`);
117
33
  const handler = async argv => {
118
34
  // Extract CLI options and get the config file option in case there is one
119
35
  const {
120
- _,
121
- $0,
122
- name,
123
- config
124
- } = argv,
125
- rest = (0, _objectWithoutProperties2.default)(argv, _excluded); // Set up the config object that's going to be passed into the `init` function
36
+ _,
37
+ $0,
38
+ name,
39
+ config
40
+ } = argv,
41
+ configOptions = (0, _objectWithoutProperties2.default)(argv, _excluded);
126
42
 
127
- let projectConfig = {}; // Check if a config files has been specified
43
+ // Set up the config object that's going to be passed into the `init` function
44
+ let projectConfig = {};
128
45
 
129
- if (config) {
130
- const ext = _path.default.extname(config);
46
+ // Check if a config files has been specified
47
+ if (config) projectConfig = await (0, _configOptions.parseConfigFile)(config);
131
48
 
132
- const configPath = _path.default.resolve(process.cwd(), config);
133
-
134
- if (!(await _fsExtra.default.pathExists(config))) {
135
- _bBerLogger.default.error('Could not find config at %s', configPath);
136
- }
137
-
138
- if (/^\.(?:ya?ml|json)/i.test(ext) === false) {
139
- _bBerLogger.default.error('Config file must have a .json or .yaml/.yml file extension');
140
- }
141
-
142
- const contents = await _fsExtra.default.readFile(config);
143
-
144
- if (/^\.ya?ml/i.test(ext)) {
145
- projectConfig = _YamlAdaptor.default.parse(contents);
146
- } else {
147
- projectConfig = JSON.parse(contents);
148
- }
149
- } // Override the values specified in the config file with values
49
+ // Override the values specified in the config file with values
150
50
  // that have been explicitly provided on the CLI. Allows using the
151
51
  // config file as a template that can be overridden, e.g.,
152
52
  // bber new foo --config my-generic-conf.yaml --base_path /foo
153
-
154
-
155
- projectConfig = _objectSpread(_objectSpread({}, projectConfig), rest); // Attributes not currently configurable via the CLI:
156
- // ibooks_specified_fonts
157
- // autoprefixer_options
158
- // base_url
159
- // downloads
160
- // ui_options
161
-
53
+ projectConfig = _objectSpread(_objectSpread({}, projectConfig), configOptions);
54
+
55
+ // Remove blacklisted and unsupported config options
56
+ for (const [key] of (0, _entries.default)(projectConfig)) {
57
+ if (!_State.default.has(`config.${key}`)) {
58
+ _bBerLogger.default.warn('Invalid configuration option [%s]', key);
59
+ delete projectConfig[key];
60
+ continue;
61
+ }
62
+ if (_configOptions.blacklistedConfigOptions.has(key)) {
63
+ _bBerLogger.default.warn('Disallowed configuration option [%s]', key);
64
+ delete projectConfig[key];
65
+ continue;
66
+ }
67
+ }
162
68
  const initializer = new _bBerTasks.init({
163
69
  name,
164
70
  config: projectConfig
165
71
  });
166
72
  initializer.start();
167
73
  };
168
-
169
74
  var _default = {
170
75
  command,
171
76
  describe,
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  const command = 'opf';
14
10
  const describe = 'Generate the opf';
15
-
16
11
  const builder = yargs => yargs.help('h').alias('h', 'help').usage(`\nUsage: $0 opf\n\n${describe}`);
17
-
18
12
  const handler = _bBerTasks.opf;
19
13
  var _default = {
20
14
  command,
@@ -1,38 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
14
-
15
10
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
16
-
17
11
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
18
-
19
12
  const command = 'serve [build] [opts]';
20
13
  const describe = 'Preview a project in the browser using the `reader` build.';
21
-
22
14
  const handler = yargs => {
23
15
  const {
24
16
  external,
25
17
  build
26
18
  } = yargs;
27
-
28
19
  _bBerLogger.default.notice(`Serving [b-ber-${build}]`);
29
-
30
20
  return (0, _bBerTasks.serve)({
31
21
  build,
32
22
  external
33
23
  });
34
24
  };
35
-
36
25
  const builder = yargs => yargs.positional('build', {
37
26
  describe: 'Build to preview',
38
27
  choices: ['reader', 'web'],
@@ -42,7 +31,6 @@ const builder = yargs => yargs.positional('build', {
42
31
  describe: 'Serve from an externally accessible URL',
43
32
  type: 'boolean'
44
33
  }).help('h').alias('h', 'help').usage(`\nUsage: $0 serve\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
45
-
46
34
  var _default = {
47
35
  command,
48
36
  describe,
@@ -1,22 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _Theme = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/Theme"));
14
-
15
10
  var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
16
-
17
11
  const _command = 'theme <command> [options]';
18
12
  const describe = "Manage a project's theme";
19
-
20
13
  const handler = args => (0, _utils.ensure)().then(() => {
21
14
  const {
22
15
  command,
@@ -24,7 +17,6 @@ const handler = args => (0, _utils.ensure)().then(() => {
24
17
  } = args;
25
18
  return _Theme.default[command](options);
26
19
  }).catch(console.error);
27
-
28
20
  const builder = yargs => yargs.positional('command', {
29
21
  describe: 'Theme command to execute',
30
22
  choices: ['set', 'list'],
@@ -33,7 +25,6 @@ const builder = yargs => yargs.positional('command', {
33
25
  describe: 'Name of the theme to activate',
34
26
  type: 'string'
35
27
  }).help('h').alias('h', 'help').usage(`\nUsage: $0 theme\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
36
-
37
28
  var _default = {
38
29
  command: _command,
39
30
  describe,
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
4
  _Object$defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
-
9
7
  exports.default = void 0;
10
-
11
8
  var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
12
-
13
9
  const command = 'xml';
14
10
  const describe = 'Export a project as an XML document';
15
-
16
11
  const builder = yargs => yargs.help('h').alias('h', 'help').usage(`\nUsage: $0 xml\n\n${describe}`);
17
-
18
12
  const handler = _bBerTasks.xml;
19
13
  var _default = {
20
14
  command,
package/dist/index.js CHANGED
@@ -2,18 +2,12 @@
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
-
6
5
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
7
-
8
6
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
-
10
7
  var _context;
11
-
12
8
  if ((0, _indexOf.default)(_context = process.argv).call(_context, '--version') > -1) {
13
9
  console.log(_fsExtra.default.readJSONSync(require.resolve('../package.json')).version);
14
10
  } else {
15
11
  const bber = require('./app').default; // eslint-disable-line global-require
16
-
17
-
18
12
  bber();
19
13
  }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.parseConfigFile = exports.blacklistedConfigOptions = void 0;
9
+ exports.withConfigOptions = withConfigOptions;
10
+ var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
11
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
12
+ var _path = _interopRequireDefault(require("path"));
13
+ var _YamlAdaptor = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/YamlAdaptor"));
14
+ var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
15
+ // Attributes not currently configurable via the CLI:
16
+ // ibooks_specified_fonts always set to `true`
17
+ // autoprefixer_options no JSON support
18
+ // downloads no JSON support
19
+ // ui_options no JSON support
20
+
21
+ function withConfigOptions(yargs) {
22
+ return yargs.option('env', {
23
+ describe: 'The default build environment',
24
+ type: 'string'
25
+ // default: 'development',
26
+ }).option('theme', {
27
+ describe: 'Default theme name',
28
+ type: 'string'
29
+ // default: 'b-ber-theme-serif',
30
+ }).option('src', {
31
+ describe: 'The name of the source directory',
32
+ type: 'string'
33
+ // default: 'src',
34
+ }).option('dist', {
35
+ describe: 'The name of the dist directory',
36
+ type: 'string'
37
+ // default: 'dist',
38
+ }).option('cache', {
39
+ describe: 'Whether to enable caching',
40
+ type: 'boolean'
41
+ // default: false,
42
+ }).option('themes_directory', {
43
+ describe: 'Relative or absolute path to the directory for third-party themes',
44
+ type: 'string'
45
+ // default: './themes',
46
+ }).option('ignore', {
47
+ describe: 'Array of files or folders to ignore during the build',
48
+ type: 'array'
49
+ // default: [],
50
+ }).option('base_path', {
51
+ describe: 'Base path appended to the URL for the reader build',
52
+ type: 'string'
53
+ // default: '/',
54
+ }).option('remote_url', {
55
+ describe: 'URL at which the reader build will be made public',
56
+ type: 'string'
57
+ // default: 'http://localhost:4000/',
58
+ }).option('reader_url', {
59
+ describe: 'URL that hosts the assets for the reader reader build',
60
+ type: 'string'
61
+ // default: 'http://localhost:4000/project-reader',
62
+ }).option('base_url', {
63
+ describe: 'URL to map assets for the web build',
64
+ type: 'string'
65
+ // default: '',
66
+ }).option('bucket_url', {
67
+ describe: 'The S3 bucket URL where the remote project will be deployed to if hosting on S3',
68
+ type: 'string'
69
+ // default: '',
70
+ }).option('private', {
71
+ describe: 'If the web and reader builds should be discoverable by search engines',
72
+ type: 'boolean'
73
+ // default: false,
74
+ }).option('remote_javascripts', {
75
+ describe: 'Remotely hosted JavaScript files for the reader',
76
+ type: 'array'
77
+ // default: [],
78
+ }).option('remote_stylesheets', {
79
+ describe: 'Remotely hosted stylesheets files for the reader',
80
+ type: 'array'
81
+ // default: [],
82
+ }).option('config', {
83
+ describe: 'Path to a JSON or YAML configuration file that will extend the base configuration',
84
+ type: 'string'
85
+ // default: '',
86
+ });
87
+ }
88
+
89
+ const blacklistedConfigOptions = new _set.default(['ibooks_specified_fonts', 'autoprefixer_options', 'downloads', 'ui_options']);
90
+ exports.blacklistedConfigOptions = blacklistedConfigOptions;
91
+ const parseConfigFile = async configFile => {
92
+ const ext = _path.default.extname(configFile);
93
+ const configPath = _path.default.resolve(process.cwd(), configFile);
94
+ if (!(await _fsExtra.default.pathExists(configPath))) {
95
+ _bBerLogger.default.error(`Could not find config at [${configPath}]`);
96
+ }
97
+ if (/^\.(?:ya?ml|json)/i.test(ext) === false) {
98
+ _bBerLogger.default.error('Config file must have a .json or .yaml/.yml file extension');
99
+ }
100
+ const contents = await _fsExtra.default.readFile(configPath);
101
+ if (/^\.ya?ml/i.test(ext)) return _YamlAdaptor.default.parse(contents);
102
+ return JSON.parse(contents);
103
+ };
104
+ exports.parseConfigFile = parseConfigFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-cli",
3
- "version": "1.2.16",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@babel/runtime-corejs3": "^7.10.5",
25
- "@canopycanopycanopy/b-ber-lib": "1.2.16",
26
- "@canopycanopycanopy/b-ber-logger": "1.2.16",
27
- "@canopycanopycanopy/b-ber-shapes-sequences": "1.2.16",
28
- "@canopycanopycanopy/b-ber-tasks": "1.2.16",
29
- "@canopycanopycanopy/b-ber-templates": "1.2.16",
25
+ "@canopycanopycanopy/b-ber-lib": "2.0.2",
26
+ "@canopycanopycanopy/b-ber-logger": "2.0.2",
27
+ "@canopycanopycanopy/b-ber-shapes-sequences": "2.0.2",
28
+ "@canopycanopycanopy/b-ber-tasks": "2.0.2",
29
+ "@canopycanopycanopy/b-ber-templates": "2.0.2",
30
30
  "fs-extra": "^8.1.0",
31
31
  "lodash": "^4.17.21",
32
32
  "lodash.has": "latest",
@@ -38,8 +38,9 @@
38
38
  "@babel/core": "^7.10.5",
39
39
  "@babel/node": "^7.8.7",
40
40
  "@babel/preset-env": "^7.10.4",
41
+ "browserslist": "^4.17.4",
41
42
  "jest": "^26.6.3",
42
- "rimraf": "^2.6.3"
43
+ "rimraf": "^2.7.1"
43
44
  },
44
45
  "files": [
45
46
  "dist"
@@ -58,5 +59,5 @@
58
59
  "url": "https://maxwellsimmer.com"
59
60
  }
60
61
  ],
61
- "gitHead": "b4d9c563beb349a32c19e0f65447f7c7dbc8ea52"
62
+ "gitHead": "9b13185f21f602f8a2bf3a4cf503b1fd644d6432"
62
63
  }