@canopycanopycanopy/b-ber-cli 1.2.13-react-reader.66 → 1.2.13-react-reader.67
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/commands/build.js +39 -5
- package/dist/commands/new.js +25 -72
- package/dist/lib/config-options.js +90 -0
- package/package.json +6 -6
package/dist/commands/build.js
CHANGED
|
@@ -10,10 +10,14 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
10
10
|
|
|
11
11
|
exports.default = void 0;
|
|
12
12
|
|
|
13
|
+
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
14
|
+
|
|
13
15
|
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
14
16
|
|
|
15
17
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
16
18
|
|
|
19
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
20
|
+
|
|
17
21
|
var _path = _interopRequireDefault(require("path"));
|
|
18
22
|
|
|
19
23
|
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
@@ -30,13 +34,24 @@ var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
|
30
34
|
|
|
31
35
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
var _configOptions = require("../lib/config-options");
|
|
38
|
+
|
|
39
|
+
const _excluded = ["_", "$0"];
|
|
40
|
+
// Leading pipe ensures that the `all` command can be run without arguments
|
|
34
41
|
const command = 'build [|epub|mobi|pdf|reader|sample|web]';
|
|
35
42
|
const describe = 'Build a project';
|
|
36
43
|
|
|
44
|
+
const noop = () => {};
|
|
45
|
+
|
|
37
46
|
const handler = argv => {
|
|
38
47
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
39
|
-
const
|
|
48
|
+
const {
|
|
49
|
+
_: desiredSequences,
|
|
50
|
+
$0
|
|
51
|
+
} = argv,
|
|
52
|
+
configOptions = (0, _objectWithoutProperties2.default)(argv, _excluded);
|
|
53
|
+
const configEntries = (0, _entries.default)(configOptions);
|
|
54
|
+
const sequence = (0, _createBuildSequence.default)(desiredSequences);
|
|
40
55
|
const subSequence = (0, _reduce.default)(sequence).call(sequence, (a, c) => (0, _concat.default)(a).call(a, ..._sequences.default[c]), []);
|
|
41
56
|
|
|
42
57
|
_State.default.update('sequence', subSequence);
|
|
@@ -44,11 +59,30 @@ const handler = argv => {
|
|
|
44
59
|
_bBerLogger.default.registerSequence(_State.default, command, subSequence);
|
|
45
60
|
|
|
46
61
|
const run = buildTasks => {
|
|
47
|
-
const build = buildTasks.shift();
|
|
62
|
+
const build = buildTasks.shift(); // Reset any previous changes to state and update the build type
|
|
48
63
|
|
|
49
64
|
_State.default.reset();
|
|
50
65
|
|
|
51
|
-
_State.default.update('build', build);
|
|
66
|
+
_State.default.update('build', build); // Apply the config options that may have been passed in via CLI flags
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
for (const [key, val] of configEntries) {
|
|
70
|
+
if (!_State.default.has(`config.${key}`)) {
|
|
71
|
+
_bBerLogger.default.warn('Invalid configuration option [%s]', key);
|
|
72
|
+
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (_configOptions.blacklistedConfigOptions.has(key)) {
|
|
77
|
+
_bBerLogger.default.warn('Disallowed configuration option [%s]', key);
|
|
78
|
+
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_bBerLogger.default.notice('Applying configuration option [%s]:[%s]', key, val);
|
|
83
|
+
|
|
84
|
+
_State.default.update(`config.${key}`, val);
|
|
85
|
+
}
|
|
52
86
|
|
|
53
87
|
return (0, _bBerTasks.serialize)(_sequences.default[build]).then(() => {
|
|
54
88
|
if (buildTasks.length) run(buildTasks);
|
|
@@ -63,7 +97,7 @@ const handler = argv => {
|
|
|
63
97
|
}).then(() => run(sequence)).catch(console.error);
|
|
64
98
|
};
|
|
65
99
|
|
|
66
|
-
const builder = yargs => yargs.command('', 'Build all formats',
|
|
100
|
+
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');
|
|
67
101
|
|
|
68
102
|
var _default = {
|
|
69
103
|
command,
|
package/dist/commands/new.js
CHANGED
|
@@ -24,6 +24,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
24
24
|
|
|
25
25
|
exports.default = void 0;
|
|
26
26
|
|
|
27
|
+
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
28
|
+
|
|
27
29
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
28
30
|
|
|
29
31
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
@@ -32,6 +34,8 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
32
34
|
|
|
33
35
|
var _path = _interopRequireDefault(require("path"));
|
|
34
36
|
|
|
37
|
+
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
38
|
+
|
|
35
39
|
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
36
40
|
|
|
37
41
|
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
@@ -40,6 +44,8 @@ var _YamlAdaptor = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib
|
|
|
40
44
|
|
|
41
45
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
42
46
|
|
|
47
|
+
var _configOptions = require("../lib/config-options");
|
|
48
|
+
|
|
43
49
|
const _excluded = ["_", "$0", "name", "config"];
|
|
44
50
|
|
|
45
51
|
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; }
|
|
@@ -49,74 +55,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
49
55
|
const command = 'new <name>';
|
|
50
56
|
const describe = 'Create a new project';
|
|
51
57
|
|
|
52
|
-
const builder = yargs => yargs.positional('name', {
|
|
58
|
+
const builder = yargs => (0, _configOptions.withConfigOptions)(yargs.positional('name', {
|
|
53
59
|
describe: 'New project name',
|
|
54
60
|
type: 'string'
|
|
55
|
-
}).
|
|
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('base_url', {
|
|
96
|
-
describe: 'URL to map assets for the web build',
|
|
97
|
-
type: 'string' // default: '',
|
|
98
|
-
|
|
99
|
-
}).option('bucket_url', {
|
|
100
|
-
describe: 'The S3 bucket URL where the remote project will be deployed to if hosting on S3',
|
|
101
|
-
type: 'string' // default: '',
|
|
102
|
-
|
|
103
|
-
}).option('private', {
|
|
104
|
-
describe: 'If the web and reader builds should be discoverable by search engines',
|
|
105
|
-
type: 'boolean' // default: false,
|
|
106
|
-
|
|
107
|
-
}).option('remote_javascripts', {
|
|
108
|
-
describe: 'Remotely hosted JavaScript files for the reader',
|
|
109
|
-
type: 'array' // default: [],
|
|
110
|
-
|
|
111
|
-
}).option('remote_stylesheets', {
|
|
112
|
-
describe: 'Remotely hosted stylesheets files for the reader',
|
|
113
|
-
type: 'array' // default: [],
|
|
114
|
-
|
|
115
|
-
}).option('config', {
|
|
116
|
-
describe: 'Path to a JSON or YAML configuration file that will extend the base configuration',
|
|
117
|
-
type: 'string' // default: '',
|
|
118
|
-
|
|
119
|
-
}).fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 new "My Project"\n\n${describe}`);
|
|
61
|
+
})).fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 new "My Project"\n\n${describe}`);
|
|
120
62
|
|
|
121
63
|
const handler = async argv => {
|
|
122
64
|
// Extract CLI options and get the config file option in case there is one
|
|
@@ -156,12 +98,23 @@ const handler = async argv => {
|
|
|
156
98
|
// bber new foo --config my-generic-conf.yaml --base_path /foo
|
|
157
99
|
|
|
158
100
|
|
|
159
|
-
projectConfig = _objectSpread(_objectSpread({}, projectConfig), rest); //
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
101
|
+
projectConfig = _objectSpread(_objectSpread({}, projectConfig), rest); // Remove blacklisted and unsupported config options
|
|
102
|
+
|
|
103
|
+
for (const [key, val] of (0, _entries.default)(projectConfig)) {
|
|
104
|
+
if (!_State.default.has(`config.${key}`)) {
|
|
105
|
+
_bBerLogger.default.warn('Invalid configuration option [%s]', key);
|
|
106
|
+
|
|
107
|
+
delete projectConfig[key];
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (_configOptions.blacklistedConfigOptions.has(key)) {
|
|
112
|
+
_bBerLogger.default.warn('Disallowed configuration option [%s]', key);
|
|
113
|
+
|
|
114
|
+
delete projectConfig[key];
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
165
118
|
|
|
166
119
|
const initializer = new _bBerTasks.init({
|
|
167
120
|
name,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.blacklistedConfigOptions = void 0;
|
|
12
|
+
exports.withConfigOptions = withConfigOptions;
|
|
13
|
+
|
|
14
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
15
|
+
|
|
16
|
+
// Attributes not currently configurable via the CLI:
|
|
17
|
+
// ibooks_specified_fonts always set to `true`
|
|
18
|
+
// autoprefixer_options no JSON support
|
|
19
|
+
// downloads no JSON support
|
|
20
|
+
// ui_options no JSON support
|
|
21
|
+
function withConfigOptions(yargs) {
|
|
22
|
+
return yargs.option('env', {
|
|
23
|
+
describe: 'The default build environment',
|
|
24
|
+
type: 'string' // default: 'development',
|
|
25
|
+
|
|
26
|
+
}).option('theme', {
|
|
27
|
+
describe: 'Default theme name',
|
|
28
|
+
type: 'string' // default: 'b-ber-theme-serif',
|
|
29
|
+
|
|
30
|
+
}).option('src', {
|
|
31
|
+
describe: 'The name of the source directory',
|
|
32
|
+
type: 'string' // default: 'src',
|
|
33
|
+
|
|
34
|
+
}).option('dist', {
|
|
35
|
+
describe: 'The name of the dist directory',
|
|
36
|
+
type: 'string' // default: 'dist',
|
|
37
|
+
|
|
38
|
+
}).option('cache', {
|
|
39
|
+
describe: 'Whether to enable caching',
|
|
40
|
+
type: 'boolean' // default: false,
|
|
41
|
+
|
|
42
|
+
}).option('themes_directory', {
|
|
43
|
+
describe: 'Relative or absolute path to the directory for third-party themes',
|
|
44
|
+
type: 'string' // default: './themes',
|
|
45
|
+
|
|
46
|
+
}).option('ignore', {
|
|
47
|
+
describe: 'Array of files or folders to ignore during the build',
|
|
48
|
+
type: 'array' // default: [],
|
|
49
|
+
|
|
50
|
+
}).option('base_path', {
|
|
51
|
+
describe: 'Base path appended to the URL for the reader build',
|
|
52
|
+
type: 'string' // default: '/',
|
|
53
|
+
|
|
54
|
+
}).option('remote_url', {
|
|
55
|
+
describe: 'URL at which the reader build will be made public',
|
|
56
|
+
type: 'string' // default: 'http://localhost:4000/',
|
|
57
|
+
|
|
58
|
+
}).option('reader_url', {
|
|
59
|
+
describe: 'URL that hosts the assets for the reader reader build',
|
|
60
|
+
type: 'string' // default: 'http://localhost:4000/project-reader',
|
|
61
|
+
|
|
62
|
+
}).option('base_url', {
|
|
63
|
+
describe: 'URL to map assets for the web build',
|
|
64
|
+
type: 'string' // default: '',
|
|
65
|
+
|
|
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' // default: '',
|
|
69
|
+
|
|
70
|
+
}).option('private', {
|
|
71
|
+
describe: 'If the web and reader builds should be discoverable by search engines',
|
|
72
|
+
type: 'boolean' // default: false,
|
|
73
|
+
|
|
74
|
+
}).option('remote_javascripts', {
|
|
75
|
+
describe: 'Remotely hosted JavaScript files for the reader',
|
|
76
|
+
type: 'array' // default: [],
|
|
77
|
+
|
|
78
|
+
}).option('remote_stylesheets', {
|
|
79
|
+
describe: 'Remotely hosted stylesheets files for the reader',
|
|
80
|
+
type: 'array' // default: [],
|
|
81
|
+
|
|
82
|
+
}).option('config', {
|
|
83
|
+
describe: 'Path to a JSON or YAML configuration file that will extend the base configuration',
|
|
84
|
+
type: 'string' // default: '',
|
|
85
|
+
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const blacklistedConfigOptions = new _set.default(['ibooks_specified_fonts', 'autoprefixer_options', 'downloads', 'ui_options']);
|
|
90
|
+
exports.blacklistedConfigOptions = blacklistedConfigOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-cli",
|
|
3
|
-
"version": "1.2.13-react-reader.
|
|
3
|
+
"version": "1.2.13-react-reader.67+b2fdc973",
|
|
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.
|
|
25
|
+
"@canopycanopycanopy/b-ber-lib": "1.2.13-react-reader.67+b2fdc973",
|
|
26
26
|
"@canopycanopycanopy/b-ber-logger": "1.2.12",
|
|
27
|
-
"@canopycanopycanopy/b-ber-shapes-sequences": "1.2.
|
|
28
|
-
"@canopycanopycanopy/b-ber-tasks": "1.2.13-react-reader.
|
|
29
|
-
"@canopycanopycanopy/b-ber-templates": "1.2.
|
|
27
|
+
"@canopycanopycanopy/b-ber-shapes-sequences": "1.2.13-react-reader.67+b2fdc973",
|
|
28
|
+
"@canopycanopycanopy/b-ber-tasks": "1.2.13-react-reader.67+b2fdc973",
|
|
29
|
+
"@canopycanopycanopy/b-ber-templates": "1.2.13-react-reader.67+b2fdc973",
|
|
30
30
|
"fs-extra": "^8.1.0",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
32
|
"lodash.has": "latest",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"url": "https://maxwellsimmer.com"
|
|
60
60
|
}
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "b2fdc9731696088030fca0cb8e6ceaa69338ed14"
|
|
63
63
|
}
|