@canopycanopycanopy/b-ber-cli 3.0.8-nav-memo.4 → 3.0.8-next.101
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/README.md +24 -54
- package/dist/index.d.ts +1 -0
- package/dist/index.js +366 -11
- package/package.json +17 -20
- package/dist/app.js +0 -32
- package/dist/commands/build.js +0 -94
- package/dist/commands/check.js +0 -27
- package/dist/commands/cover.js +0 -19
- package/dist/commands/deploy.js +0 -27
- package/dist/commands/generate.js +0 -32
- package/dist/commands/index.js +0 -70
- package/dist/commands/new.js +0 -82
- package/dist/commands/opf.js +0 -18
- package/dist/commands/serve.js +0 -39
- package/dist/commands/theme.js +0 -33
- package/dist/commands/xml.js +0 -18
- package/dist/lib/config-options.js +0 -102
package/README.md
CHANGED
|
@@ -1,57 +1,27 @@
|
|
|
1
1
|
# `@canopycanopycanopy/b-ber-cli`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
#### `new`
|
|
28
|
-
|
|
29
|
-
The `new` command initiates a new project.
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
$ bber new <name>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
#### `generate`
|
|
36
|
-
|
|
37
|
-
The `generate` command creates a new chapter.
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
$ bber generate <title> [type]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
#### `serve`
|
|
44
|
-
|
|
45
|
-
The `serve` command previews a publication's contents in a browser.
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
$ bber serve <type>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### `build`
|
|
52
|
-
|
|
53
|
-
The `build` command creates an EPUB, Mobi, PDF, or all file formats.
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
$ bber build [type]
|
|
3
|
+
`b-ber-cli` is the command-line entry point for the b-ber build framework. It installs a `bber` binary that accepts commands to scaffold new projects, generate chapters, build output in multiple formats (EPUB, Mobi, PDF, reader, web), preview output in a browser, manage themes, generate cover images, deploy builds to S3, and validate project Markdown. Commands are parsed with yargs; each command delegates its work to `@canopycanopycanopy/b-ber-tasks`.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Command | Syntax | Description |
|
|
8
|
+
| ---------- | --------------------------------------------------- | ------------------------------------------------------------- |
|
|
9
|
+
| `new` | `bber new <name>` | Scaffold a new b-ber project |
|
|
10
|
+
| `generate` | `bber generate <title> [type]` | Create a new chapter (frontmatter, bodymatter, or backmatter) |
|
|
11
|
+
| `build` | `bber build [epub\|mobi\|pdf\|reader\|sample\|web]` | Build one or all output formats |
|
|
12
|
+
| `serve` | `bber serve [reader\|web]` | Preview a build in the browser |
|
|
13
|
+
| `check` | `bber check [project]` | Validate project Markdown |
|
|
14
|
+
| `cover` | `bber cover` | Generate a project cover image |
|
|
15
|
+
| `theme` | `bber theme <set\|list> [name]` | Set or list available themes |
|
|
16
|
+
| `deploy` | `bber deploy [builds...]` | Upload builds to Amazon S3 |
|
|
17
|
+
| `opf` | `bber opf` | Generate the OPF package document |
|
|
18
|
+
|
|
19
|
+
Most commands accept a `--config <path>` flag pointing to a JSON or YAML file that extends the base project configuration.
|
|
20
|
+
|
|
21
|
+
## Dev
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm test # jest unit tests (tests in __tests__/commands/)
|
|
25
|
+
npm run build # compile src/ → dist/ with Babel
|
|
26
|
+
npm start # run via babel-node without compiling
|
|
57
27
|
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,368 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _canopycanopycanopy_b_ber_lib_State = require("@canopycanopycanopy/b-ber-lib/State");
|
|
25
|
+
_canopycanopycanopy_b_ber_lib_State = __toESM(_canopycanopycanopy_b_ber_lib_State);
|
|
26
|
+
let yargs = require("yargs");
|
|
27
|
+
yargs = __toESM(yargs);
|
|
28
|
+
let _canopycanopycanopy_b_ber_lib_utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
29
|
+
let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
|
|
30
|
+
_canopycanopycanopy_b_ber_logger = __toESM(_canopycanopycanopy_b_ber_logger);
|
|
31
|
+
let _canopycanopycanopy_b_ber_shapes_sequences_create_build_sequence = require("@canopycanopycanopy/b-ber-shapes-sequences/create-build-sequence");
|
|
32
|
+
_canopycanopycanopy_b_ber_shapes_sequences_create_build_sequence = __toESM(_canopycanopycanopy_b_ber_shapes_sequences_create_build_sequence);
|
|
33
|
+
let _canopycanopycanopy_b_ber_shapes_sequences_sequences = require("@canopycanopycanopy/b-ber-shapes-sequences/sequences");
|
|
34
|
+
_canopycanopycanopy_b_ber_shapes_sequences_sequences = __toESM(_canopycanopycanopy_b_ber_shapes_sequences_sequences);
|
|
35
|
+
let _canopycanopycanopy_b_ber_tasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
36
|
+
let _canopycanopycanopy_b_ber_templates_Project = require("@canopycanopycanopy/b-ber-templates/Project");
|
|
37
|
+
_canopycanopycanopy_b_ber_templates_Project = __toESM(_canopycanopycanopy_b_ber_templates_Project);
|
|
38
|
+
let path = require("path");
|
|
39
|
+
path = __toESM(path);
|
|
40
|
+
let _canopycanopycanopy_b_ber_lib_YamlAdaptor = require("@canopycanopycanopy/b-ber-lib/YamlAdaptor");
|
|
41
|
+
_canopycanopycanopy_b_ber_lib_YamlAdaptor = __toESM(_canopycanopycanopy_b_ber_lib_YamlAdaptor);
|
|
42
|
+
let fs_extra = require("fs-extra");
|
|
43
|
+
fs_extra = __toESM(fs_extra);
|
|
44
|
+
let _canopycanopycanopy_b_ber_lib_Theme = require("@canopycanopycanopy/b-ber-lib/Theme");
|
|
45
|
+
_canopycanopycanopy_b_ber_lib_Theme = __toESM(_canopycanopycanopy_b_ber_lib_Theme);
|
|
46
|
+
//#region package.json
|
|
47
|
+
var version = "3.0.8-next.101+b6a7f323";
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/lib/config-options.ts
|
|
50
|
+
function withConfigOptions(yargs) {
|
|
51
|
+
return yargs.option("env", {
|
|
52
|
+
describe: "The default build environment",
|
|
53
|
+
type: "string"
|
|
54
|
+
}).option("theme", {
|
|
55
|
+
describe: "Default theme name",
|
|
56
|
+
type: "string"
|
|
57
|
+
}).option("src", {
|
|
58
|
+
describe: "The name of the source directory",
|
|
59
|
+
type: "string"
|
|
60
|
+
}).option("dist", {
|
|
61
|
+
describe: "The name of the dist directory",
|
|
62
|
+
type: "string"
|
|
63
|
+
}).option("cache", {
|
|
64
|
+
describe: "Whether to enable caching",
|
|
65
|
+
type: "boolean"
|
|
66
|
+
}).option("themes_directory", {
|
|
67
|
+
describe: "Relative or absolute path to the directory for third-party themes",
|
|
68
|
+
type: "string"
|
|
69
|
+
}).option("ignore", {
|
|
70
|
+
describe: "Array of files or folders to ignore during the build",
|
|
71
|
+
type: "array"
|
|
72
|
+
}).option("base_path", {
|
|
73
|
+
describe: "Base path appended to the URL for the reader build",
|
|
74
|
+
type: "string"
|
|
75
|
+
}).option("remote_url", {
|
|
76
|
+
describe: "URL at which the reader build will be made public",
|
|
77
|
+
type: "string"
|
|
78
|
+
}).option("reader_url", {
|
|
79
|
+
describe: "URL that hosts the assets for the reader reader build",
|
|
80
|
+
type: "string"
|
|
81
|
+
}).option("base_url", {
|
|
82
|
+
describe: "URL to map assets for the web build",
|
|
83
|
+
type: "string"
|
|
84
|
+
}).option("bucket_url", {
|
|
85
|
+
describe: "The S3 bucket URL where the remote project will be deployed to if hosting on S3",
|
|
86
|
+
type: "string"
|
|
87
|
+
}).option("private", {
|
|
88
|
+
describe: "If the web and reader builds should be discoverable by search engines",
|
|
89
|
+
type: "boolean"
|
|
90
|
+
}).option("remote_javascripts", {
|
|
91
|
+
describe: "Remotely hosted JavaScript files for the reader",
|
|
92
|
+
type: "array"
|
|
93
|
+
}).option("remote_stylesheets", {
|
|
94
|
+
describe: "Remotely hosted stylesheets files for the reader",
|
|
95
|
+
type: "array"
|
|
96
|
+
}).option("config", {
|
|
97
|
+
describe: "Path to a JSON or YAML configuration file that will extend the base configuration",
|
|
98
|
+
type: "string"
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const blacklistedConfigOptions = new Set([
|
|
102
|
+
"ibooks_specified_fonts",
|
|
103
|
+
"autoprefixer_options",
|
|
104
|
+
"downloads",
|
|
105
|
+
"ui_options"
|
|
106
|
+
]);
|
|
107
|
+
const parseConfigFile = async (configFile) => {
|
|
108
|
+
const ext = path.default.extname(configFile);
|
|
109
|
+
const configPath = path.default.resolve(process.cwd(), configFile);
|
|
110
|
+
if (!await fs_extra.default.pathExists(configPath)) _canopycanopycanopy_b_ber_logger.default.error(`Could not find config at [${configPath}]`);
|
|
111
|
+
if (/^\.(?:ya?ml|json)/i.test(ext) === false) _canopycanopycanopy_b_ber_logger.default.error("Config file must have a .json or .yaml/.yml file extension");
|
|
112
|
+
const contents = (await fs_extra.default.readFile(configPath)).toString();
|
|
113
|
+
if (/^\.ya?ml/i.test(ext)) return _canopycanopycanopy_b_ber_lib_YamlAdaptor.default.parse(contents);
|
|
114
|
+
return JSON.parse(contents);
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/commands/build.ts
|
|
118
|
+
const command$7 = "build [|epub|mobi|pdf|reader|sample|web]";
|
|
119
|
+
const describe$8 = "Build a project";
|
|
120
|
+
const noop = () => {};
|
|
121
|
+
const handler$8 = async (argv) => {
|
|
122
|
+
process.env.NODE_ENV = process.env.NODE_ENV || "development";
|
|
123
|
+
const { _: desiredSequences, $0, config, ...configOptions } = argv;
|
|
124
|
+
const sequence = (0, _canopycanopycanopy_b_ber_shapes_sequences_create_build_sequence.default)(desiredSequences);
|
|
125
|
+
const subSequence = sequence.reduce((a, c) => a.concat(..._canopycanopycanopy_b_ber_shapes_sequences_sequences.default[c]), []);
|
|
126
|
+
let projectConfig = {};
|
|
127
|
+
if (config) projectConfig = await parseConfigFile(config);
|
|
128
|
+
projectConfig = {
|
|
129
|
+
...projectConfig,
|
|
130
|
+
...configOptions
|
|
131
|
+
};
|
|
132
|
+
_canopycanopycanopy_b_ber_lib_State.default.update("sequence", subSequence);
|
|
133
|
+
_canopycanopycanopy_b_ber_logger.default.registerSequence(_canopycanopycanopy_b_ber_lib_State.default, command$7, subSequence);
|
|
134
|
+
const run = (buildTasks) => {
|
|
135
|
+
const build = buildTasks.shift();
|
|
136
|
+
_canopycanopycanopy_b_ber_lib_State.default.reset();
|
|
137
|
+
_canopycanopycanopy_b_ber_lib_State.default.update("build", build);
|
|
138
|
+
for (const [key, val] of Object.entries(projectConfig)) {
|
|
139
|
+
if (!_canopycanopycanopy_b_ber_lib_State.default.has(`config.${key}`)) {
|
|
140
|
+
_canopycanopycanopy_b_ber_logger.default.warn("Invalid configuration option [%s]", key);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (blacklistedConfigOptions.has(key)) {
|
|
144
|
+
_canopycanopycanopy_b_ber_logger.default.warn("Disallowed configuration option [%s]", key);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
_canopycanopycanopy_b_ber_logger.default.notice("Applying configuration option [%s]:[%s]", key, val);
|
|
148
|
+
_canopycanopycanopy_b_ber_lib_State.default.update(`config.${key}`, val);
|
|
149
|
+
}
|
|
150
|
+
return (0, _canopycanopycanopy_b_ber_tasks.serialize)(_canopycanopycanopy_b_ber_shapes_sequences_sequences.default[build]).then(() => {
|
|
151
|
+
if (buildTasks.length) run(buildTasks);
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const projectPath = path.default.resolve(_canopycanopycanopy_b_ber_lib_State.default.srcDir);
|
|
155
|
+
(0, _canopycanopycanopy_b_ber_lib_utils.ensure)({ files: [..._canopycanopycanopy_b_ber_templates_Project.default.javascripts(projectPath), ..._canopycanopycanopy_b_ber_templates_Project.default.stylesheets(projectPath)] }).then(() => run(sequence)).catch(console.error);
|
|
156
|
+
};
|
|
157
|
+
const builder$8 = (yargs) => withConfigOptions(yargs).command("", "Build all formats", noop, handler$8).command("epub", "Build an Epub", noop, handler$8).command("mobi", "Build a Mobi", noop, handler$8).command("pdf", "Build a PDF", noop, handler$8).command("reader", "Build for the b-ber-reader format", noop, handler$8).command("sample", "Build a sample Epub", noop, handler$8).command("web", "Build for web", noop, handler$8).command("xml", "Build for XML", noop, handler$8).help("h").alias("h", "help");
|
|
158
|
+
var build_default = {
|
|
159
|
+
command: command$7,
|
|
160
|
+
describe: describe$8,
|
|
161
|
+
builder: builder$8,
|
|
162
|
+
handler: handler$8
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/commands/check.ts
|
|
166
|
+
const command$6 = "check [project]";
|
|
167
|
+
const describe$7 = "Validate b-ber project Markdown";
|
|
168
|
+
const builder$7 = (yargs) => yargs.positional("project", {
|
|
169
|
+
describe: "Path to the b-ber project",
|
|
170
|
+
type: "string"
|
|
171
|
+
}).help("h").alias("h", "help").fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs)).usage(`\nUsage: $0 check\n\n${describe$7}`);
|
|
172
|
+
const handler$7 = (argv) => {
|
|
173
|
+
(0, _canopycanopycanopy_b_ber_tasks.validate)({ project: argv.project || process.cwd() });
|
|
174
|
+
};
|
|
175
|
+
var check_default = {
|
|
176
|
+
command: command$6,
|
|
177
|
+
describe: describe$7,
|
|
178
|
+
builder: builder$7,
|
|
179
|
+
handler: handler$7
|
|
180
|
+
};
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/commands/cover.ts
|
|
183
|
+
const command$5 = "cover";
|
|
184
|
+
const describe$6 = "Generate a project cover";
|
|
185
|
+
const builder$6 = (yargs) => yargs.fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs)).help("h").alias("h", "help").usage(`\nUsage: $0 cover\n\n${describe$6}`);
|
|
186
|
+
const handler$6 = () => (0, _canopycanopycanopy_b_ber_tasks.cover)();
|
|
187
|
+
var cover_default = {
|
|
188
|
+
command: command$5,
|
|
189
|
+
describe: describe$6,
|
|
190
|
+
builder: builder$6,
|
|
191
|
+
handler: handler$6
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/commands/deploy.ts
|
|
195
|
+
const command$4 = "deploy [builds...]";
|
|
196
|
+
const describe$5 = "Upload a b-ber project to Amazon S3";
|
|
197
|
+
const builder$5 = (yargs) => yargs.option("yes", {
|
|
198
|
+
alias: "y",
|
|
199
|
+
describe: "Skip all confirmation prompts",
|
|
200
|
+
type: "boolean"
|
|
201
|
+
}).positional("builds", {
|
|
202
|
+
describe: "Builds to upload",
|
|
203
|
+
choices: [
|
|
204
|
+
"epub",
|
|
205
|
+
"mobi",
|
|
206
|
+
"reader",
|
|
207
|
+
"web",
|
|
208
|
+
"pdf",
|
|
209
|
+
"xml"
|
|
210
|
+
],
|
|
211
|
+
type: "string"
|
|
212
|
+
}).help("h").alias("h", "help").usage(`\nUsage: $0 deploy\n\n${describe$5}`).fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs));
|
|
213
|
+
var deploy_default = {
|
|
214
|
+
command: command$4,
|
|
215
|
+
describe: describe$5,
|
|
216
|
+
builder: builder$5,
|
|
217
|
+
handler: _canopycanopycanopy_b_ber_tasks.deploy
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/commands/generate.ts
|
|
221
|
+
const command$3 = "generate <title> [type]";
|
|
222
|
+
const describe$4 = "Create a new chapter. Accepts arguments for metadata";
|
|
223
|
+
const builder$4 = (yargs) => yargs.positional("title", {
|
|
224
|
+
describe: "Page title",
|
|
225
|
+
type: "string"
|
|
226
|
+
}).positional("type", {
|
|
227
|
+
describe: "Page type",
|
|
228
|
+
choices: [
|
|
229
|
+
"frontmatter",
|
|
230
|
+
"bodymatter",
|
|
231
|
+
"backmatter"
|
|
232
|
+
],
|
|
233
|
+
type: "string"
|
|
234
|
+
}).help("h").alias("h", "help").usage(`\nUsage: $0 generate\n\n${describe$4}`).fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs));
|
|
235
|
+
const handler$4 = (argv) => (0, _canopycanopycanopy_b_ber_lib_utils.ensure)().then(() => (0, _canopycanopycanopy_b_ber_tasks.generate)({
|
|
236
|
+
title: argv.title,
|
|
237
|
+
type: argv.type
|
|
238
|
+
})).catch(console.error);
|
|
239
|
+
var generate_default = {
|
|
240
|
+
command: command$3,
|
|
241
|
+
describe: describe$4,
|
|
242
|
+
builder: builder$4,
|
|
243
|
+
handler: handler$4
|
|
244
|
+
};
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/commands/new.ts
|
|
247
|
+
const command$2 = "new <name>";
|
|
248
|
+
const describe$3 = "Create a new project";
|
|
249
|
+
const builder$3 = (yargs) => withConfigOptions(yargs.positional("name", {
|
|
250
|
+
describe: "New project name",
|
|
251
|
+
type: "string"
|
|
252
|
+
})).fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs)).help("h").alias("h", "help").usage(`\nUsage: $0 new "My Project"\n\n${describe$3}`);
|
|
253
|
+
const handler$3 = async (argv) => {
|
|
254
|
+
const { _, $0, name, config, ...configOptions } = argv;
|
|
255
|
+
let projectConfig = {};
|
|
256
|
+
if (config) projectConfig = await parseConfigFile(config);
|
|
257
|
+
projectConfig = {
|
|
258
|
+
...projectConfig,
|
|
259
|
+
...configOptions
|
|
260
|
+
};
|
|
261
|
+
for (const [key] of Object.entries(projectConfig)) {
|
|
262
|
+
if (!_canopycanopycanopy_b_ber_lib_State.default.has(`config.${key}`)) {
|
|
263
|
+
_canopycanopycanopy_b_ber_logger.default.warn("Invalid configuration option [%s]", key);
|
|
264
|
+
delete projectConfig[key];
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (blacklistedConfigOptions.has(key)) {
|
|
268
|
+
_canopycanopycanopy_b_ber_logger.default.warn("Disallowed configuration option [%s]", key);
|
|
269
|
+
delete projectConfig[key];
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
new _canopycanopycanopy_b_ber_tasks.init({
|
|
274
|
+
name,
|
|
275
|
+
config: projectConfig
|
|
276
|
+
}).start();
|
|
277
|
+
};
|
|
278
|
+
var new_default = {
|
|
279
|
+
command: command$2,
|
|
280
|
+
describe: describe$3,
|
|
281
|
+
builder: builder$3,
|
|
282
|
+
handler: handler$3
|
|
283
|
+
};
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/commands/opf.ts
|
|
286
|
+
const command$1 = "opf";
|
|
287
|
+
const describe$2 = "Generate the opf";
|
|
288
|
+
const builder$2 = (yargs) => yargs.help("h").alias("h", "help").usage(`\nUsage: $0 opf\n\n${describe$2}`);
|
|
289
|
+
var opf_default = {
|
|
290
|
+
command: command$1,
|
|
291
|
+
describe: describe$2,
|
|
292
|
+
builder: builder$2,
|
|
293
|
+
handler: _canopycanopycanopy_b_ber_tasks.opf
|
|
294
|
+
};
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/commands/serve.ts
|
|
297
|
+
const command = "serve [build] [opts]";
|
|
298
|
+
const describe$1 = "Preview a project in the browser using the `reader` build.";
|
|
299
|
+
const handler$1 = (yargs) => {
|
|
300
|
+
const { external, build } = yargs;
|
|
301
|
+
_canopycanopycanopy_b_ber_logger.default.notice(`Serving [b-ber-${build}]`);
|
|
302
|
+
return (0, _canopycanopycanopy_b_ber_tasks.serve)({
|
|
303
|
+
build,
|
|
304
|
+
external
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
const builder$1 = (yargs) => yargs.positional("build", {
|
|
308
|
+
describe: "Build to preview",
|
|
309
|
+
choices: ["reader", "web"],
|
|
310
|
+
type: "string"
|
|
311
|
+
}).option("external", {
|
|
312
|
+
alias: "e",
|
|
313
|
+
describe: "Serve from an externally accessible URL",
|
|
314
|
+
type: "boolean"
|
|
315
|
+
}).help("h").alias("h", "help").usage(`\nUsage: $0 serve\n\n${describe$1}`).fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs));
|
|
316
|
+
var serve_default = {
|
|
317
|
+
command,
|
|
318
|
+
describe: describe$1,
|
|
319
|
+
builder: builder$1,
|
|
320
|
+
handler: handler$1
|
|
321
|
+
};
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/commands/theme.ts
|
|
324
|
+
const _command = "theme <command> [options]";
|
|
325
|
+
const describe = "Manage a project's theme";
|
|
326
|
+
const handler = (args) => (0, _canopycanopycanopy_b_ber_lib_utils.ensure)().then(() => {
|
|
327
|
+
const { command, options } = args;
|
|
328
|
+
return _canopycanopycanopy_b_ber_lib_Theme.default[command](options);
|
|
329
|
+
}).catch(console.error);
|
|
330
|
+
const builder = (yargs) => yargs.positional("command", {
|
|
331
|
+
describe: "Theme command to execute",
|
|
332
|
+
choices: ["set", "list"],
|
|
333
|
+
type: "string"
|
|
334
|
+
}).positional("options", {
|
|
335
|
+
describe: "Name of the theme to activate",
|
|
336
|
+
type: "string"
|
|
337
|
+
}).help("h").alias("h", "help").usage(`\nUsage: $0 theme\n\n${describe}`).fail((msg, err) => (0, _canopycanopycanopy_b_ber_lib_utils.fail)(msg, err, yargs));
|
|
338
|
+
var theme_default = {
|
|
339
|
+
command: _command,
|
|
340
|
+
describe,
|
|
341
|
+
builder,
|
|
342
|
+
handler
|
|
343
|
+
};
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/app.ts
|
|
346
|
+
const LINE_LENGTH = 70;
|
|
347
|
+
function bber() {
|
|
348
|
+
const showCustomHelp = () => console.log(`
|
|
349
|
+
Usage: bber <command> [options]
|
|
3
350
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
351
|
+
bber new Start a new project
|
|
352
|
+
bber generate Create a new chapter. Accepts arguments for metadata.
|
|
353
|
+
bber serve Preview the publication's contents in a browser
|
|
354
|
+
bber build Create an ePub, mobi, PDF, or all file formats
|
|
355
|
+
bber check Validate a project's markdown
|
|
356
|
+
|
|
357
|
+
For more information on a command, enter bber <command> --help
|
|
358
|
+
|
|
359
|
+
bber version ${_canopycanopycanopy_b_ber_lib_State.default.version}
|
|
360
|
+
`);
|
|
361
|
+
return yargs.default.command(build_default).command(generate_default).command(opf_default).command(theme_default).command(serve_default).command(new_default).command(cover_default).command(deploy_default).command(check_default).help(false).fail(showCustomHelp).demandCommand().wrap(LINE_LENGTH).argv;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/index.ts
|
|
365
|
+
const { argv } = process;
|
|
366
|
+
if (argv.includes("--version") || argv.includes("-v")) console.log(version);
|
|
367
|
+
else bber();
|
|
368
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-cli",
|
|
3
|
-
"version": "3.0.8-
|
|
3
|
+
"version": "3.0.8-next.101+b6a7f323",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"bin": {
|
|
7
8
|
"bber": "dist/index.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
|
-
"prepare:dist": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --ignore **/__tests__/**",
|
|
11
11
|
"clean": "rimraf dist",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --watch src",
|
|
15
|
-
"start": "babel-node --config-file ../../babel.config.js --trace-warnings ./src/index.js",
|
|
12
|
+
"build": "tsdown",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
16
14
|
"test": "jest"
|
|
17
15
|
},
|
|
18
16
|
"author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
|
|
@@ -21,12 +19,11 @@
|
|
|
21
19
|
"access": "public"
|
|
22
20
|
},
|
|
23
21
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@canopycanopycanopy/b-ber-
|
|
26
|
-
"@canopycanopycanopy/b-ber-
|
|
27
|
-
"@canopycanopycanopy/b-ber-
|
|
28
|
-
"@canopycanopycanopy/b-ber-
|
|
29
|
-
"@canopycanopycanopy/b-ber-templates": "3.0.8-nav-memo.4+d47a9aae",
|
|
22
|
+
"@canopycanopycanopy/b-ber-lib": "3.0.8-next.101+b6a7f323",
|
|
23
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.8-next.101+b6a7f323",
|
|
24
|
+
"@canopycanopycanopy/b-ber-shapes-sequences": "3.0.8-next.101+b6a7f323",
|
|
25
|
+
"@canopycanopycanopy/b-ber-tasks": "3.0.8-next.101+b6a7f323",
|
|
26
|
+
"@canopycanopycanopy/b-ber-templates": "3.0.8-next.101+b6a7f323",
|
|
30
27
|
"fs-extra": "^8.1.0",
|
|
31
28
|
"lodash": "^4.17.21",
|
|
32
29
|
"lodash.has": "latest",
|
|
@@ -34,13 +31,13 @@
|
|
|
34
31
|
"yargs": "^13.3.0"
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
34
|
+
"@swc/core": "^1.15.40",
|
|
35
|
+
"@swc/jest": "^0.2.39",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"jest-extended": "^3.2.4",
|
|
38
|
+
"rimraf": "^2.7.1",
|
|
39
|
+
"tsdown": "^0.22.1",
|
|
40
|
+
"typescript": "^6.0.3"
|
|
44
41
|
},
|
|
45
42
|
"files": [
|
|
46
43
|
"dist"
|
|
@@ -59,5 +56,5 @@
|
|
|
59
56
|
"url": "https://maxwellsimmer.com"
|
|
60
57
|
}
|
|
61
58
|
],
|
|
62
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "b6a7f323cd34b837eb49ad96b1062bd6e0af207f"
|
|
63
60
|
}
|
package/dist/app.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
|
4
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
6
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = bber;
|
|
11
|
-
var _yargs = _interopRequireDefault(require("yargs"));
|
|
12
|
-
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
13
|
-
var commands = _interopRequireWildcard(require("./commands"));
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
const LINE_LENGTH = 70;
|
|
17
|
-
function bber() {
|
|
18
|
-
const showCustomHelp = () => console.log(`
|
|
19
|
-
Usage: bber <command> [options]
|
|
20
|
-
|
|
21
|
-
bber new Start a new project
|
|
22
|
-
bber generate Create a new chapter. Accepts arguments for metadata.
|
|
23
|
-
bber serve Preview the publication's contents in a browser
|
|
24
|
-
bber build Create an ePub, mobi, PDF, or all file formats
|
|
25
|
-
bber check Validate a project’s markdown
|
|
26
|
-
|
|
27
|
-
For more information on a command, enter bber <command> --help
|
|
28
|
-
|
|
29
|
-
bber version ${_State.default.version}
|
|
30
|
-
`);
|
|
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;
|
|
32
|
-
}
|
package/dist/commands/build.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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");
|
|
10
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
exports.default = void 0;
|
|
16
|
-
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
17
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
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"));
|
|
21
|
-
var _path = _interopRequireDefault(require("path"));
|
|
22
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
23
|
-
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
24
|
-
var _createBuildSequence = _interopRequireDefault(require("@canopycanopycanopy/b-ber-shapes-sequences/create-build-sequence"));
|
|
25
|
-
var _sequences = _interopRequireDefault(require("@canopycanopycanopy/b-ber-shapes-sequences/sequences"));
|
|
26
|
-
var _Project = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Project"));
|
|
27
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
28
|
-
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
29
|
-
var _configOptions = require("../lib/config-options");
|
|
30
|
-
const _excluded = ["_", "$0", "config"];
|
|
31
|
-
/* eslint-disable no-continue */
|
|
32
|
-
/* eslint-disable no-unused-vars */
|
|
33
|
-
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
35
|
-
// Leading pipe ensures that the `all` command can be run without arguments
|
|
36
|
-
const command = 'build [|epub|mobi|pdf|reader|sample|web]';
|
|
37
|
-
const describe = 'Build a project';
|
|
38
|
-
const noop = () => {};
|
|
39
|
-
const handler = async argv => {
|
|
40
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
41
|
-
const {
|
|
42
|
-
_: desiredSequences,
|
|
43
|
-
$0,
|
|
44
|
-
config
|
|
45
|
-
} = argv,
|
|
46
|
-
configOptions = (0, _objectWithoutProperties2.default)(argv, _excluded);
|
|
47
|
-
const sequence = (0, _createBuildSequence.default)(desiredSequences);
|
|
48
|
-
const subSequence = (0, _reduce.default)(sequence).call(sequence, (a, c) => (0, _concat.default)(a).call(a, ..._sequences.default[c]), []);
|
|
49
|
-
|
|
50
|
-
// Set up the config object that's going to be passed into the `init` function
|
|
51
|
-
let projectConfig = {};
|
|
52
|
-
|
|
53
|
-
// Check if a config files has been specified
|
|
54
|
-
if (config) projectConfig = await (0, _configOptions.parseConfigFile)(config);
|
|
55
|
-
projectConfig = _objectSpread(_objectSpread({}, projectConfig), configOptions);
|
|
56
|
-
_State.default.update('sequence', subSequence);
|
|
57
|
-
_bBerLogger.default.registerSequence(_State.default, command, subSequence);
|
|
58
|
-
const run = buildTasks => {
|
|
59
|
-
const build = buildTasks.shift();
|
|
60
|
-
|
|
61
|
-
// Reset any previous changes to state and update the build type
|
|
62
|
-
_State.default.reset();
|
|
63
|
-
_State.default.update('build', build);
|
|
64
|
-
|
|
65
|
-
// Apply the config options that may have been passed in via CLI flags
|
|
66
|
-
for (const [key, val] of (0, _entries.default)(projectConfig)) {
|
|
67
|
-
if (!_State.default.has(`config.${key}`)) {
|
|
68
|
-
_bBerLogger.default.warn('Invalid configuration option [%s]', key);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (_configOptions.blacklistedConfigOptions.has(key)) {
|
|
72
|
-
_bBerLogger.default.warn('Disallowed configuration option [%s]', key);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
_bBerLogger.default.notice('Applying configuration option [%s]:[%s]', key, val);
|
|
76
|
-
_State.default.update(`config.${key}`, val);
|
|
77
|
-
}
|
|
78
|
-
return (0, _bBerTasks.serialize)(_sequences.default[build]).then(() => {
|
|
79
|
-
if (buildTasks.length) run(buildTasks);
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
const projectPath = _path.default.resolve(_State.default.srcDir);
|
|
83
|
-
const files = [..._Project.default.javascripts(projectPath), ..._Project.default.stylesheets(projectPath)];
|
|
84
|
-
(0, _utils.ensure)({
|
|
85
|
-
files
|
|
86
|
-
}).then(() => run(sequence)).catch(console.error);
|
|
87
|
-
};
|
|
88
|
-
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');
|
|
89
|
-
var _default = exports.default = {
|
|
90
|
-
command,
|
|
91
|
-
describe,
|
|
92
|
-
builder,
|
|
93
|
-
handler
|
|
94
|
-
};
|
package/dist/commands/check.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
10
|
-
const command = 'check [project]';
|
|
11
|
-
const describe = 'Validate b-ber project Markdown';
|
|
12
|
-
const builder = yargs => yargs.positional('project', {
|
|
13
|
-
describe: 'Path to the b-ber project',
|
|
14
|
-
type: 'string'
|
|
15
|
-
}).help('h').alias('h', 'help').fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).usage(`\nUsage: $0 check\n\n${describe}`);
|
|
16
|
-
const handler = argv => {
|
|
17
|
-
const project = argv.project || process.cwd();
|
|
18
|
-
(0, _bBerTasks.validate)({
|
|
19
|
-
project
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var _default = exports.default = {
|
|
23
|
-
command,
|
|
24
|
-
describe,
|
|
25
|
-
builder,
|
|
26
|
-
handler
|
|
27
|
-
};
|
package/dist/commands/cover.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
10
|
-
const command = 'cover';
|
|
11
|
-
const describe = 'Generate a project cover';
|
|
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}`);
|
|
13
|
-
const handler = () => _bBerTasks.cover.init();
|
|
14
|
-
var _default = exports.default = {
|
|
15
|
-
command,
|
|
16
|
-
describe,
|
|
17
|
-
builder,
|
|
18
|
-
handler
|
|
19
|
-
};
|
package/dist/commands/deploy.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
10
|
-
const command = 'deploy [builds...]';
|
|
11
|
-
const describe = 'Upload a b-ber project to Amazon S3';
|
|
12
|
-
const builder = yargs => yargs.option('yes', {
|
|
13
|
-
alias: 'y',
|
|
14
|
-
describe: 'Skip all confirmation prompts',
|
|
15
|
-
type: 'boolean'
|
|
16
|
-
}).positional('builds', {
|
|
17
|
-
describe: 'Builds to upload',
|
|
18
|
-
choices: ['epub', 'mobi', 'reader', 'web', 'pdf', 'xml'],
|
|
19
|
-
type: 'string'
|
|
20
|
-
}).help('h').alias('h', 'help').usage(`\nUsage: $0 deploy\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
|
|
21
|
-
const handler = _bBerTasks.deploy;
|
|
22
|
-
var _default = exports.default = {
|
|
23
|
-
command,
|
|
24
|
-
describe,
|
|
25
|
-
builder,
|
|
26
|
-
handler
|
|
27
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
10
|
-
const command = 'generate <title> [type]';
|
|
11
|
-
const describe = 'Create a new chapter. Accepts arguments for metadata';
|
|
12
|
-
const builder = yargs => yargs.positional('title', {
|
|
13
|
-
describe: 'Page title',
|
|
14
|
-
type: 'string'
|
|
15
|
-
}).positional('type', {
|
|
16
|
-
describe: 'Page type',
|
|
17
|
-
choices: ['frontmatter', 'bodymatter', 'backmatter'],
|
|
18
|
-
type: 'string'
|
|
19
|
-
}).help('h').alias('h', 'help').usage(`\nUsage: $0 generate\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
|
|
20
|
-
const handler = ({
|
|
21
|
-
title,
|
|
22
|
-
type
|
|
23
|
-
}) => (0, _utils.ensure)().then(() => (0, _bBerTasks.generate)({
|
|
24
|
-
title,
|
|
25
|
-
type
|
|
26
|
-
})).catch(console.error);
|
|
27
|
-
var _default = exports.default = {
|
|
28
|
-
command,
|
|
29
|
-
describe,
|
|
30
|
-
builder,
|
|
31
|
-
handler
|
|
32
|
-
};
|
package/dist/commands/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
_Object$defineProperty(exports, "build", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _build.default;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
_Object$defineProperty(exports, "check", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return _check.default;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
_Object$defineProperty(exports, "cover", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _cover.default;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
_Object$defineProperty(exports, "deploy", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _deploy.default;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
_Object$defineProperty(exports, "generate", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _generate.default;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
_Object$defineProperty(exports, "new", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _new.default;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
_Object$defineProperty(exports, "opf", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _opf.default;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
_Object$defineProperty(exports, "serve", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return _serve.default;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
_Object$defineProperty(exports, "theme", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return _theme.default;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
var _build = _interopRequireDefault(require("./build"));
|
|
63
|
-
var _cover = _interopRequireDefault(require("./cover"));
|
|
64
|
-
var _deploy = _interopRequireDefault(require("./deploy"));
|
|
65
|
-
var _generate = _interopRequireDefault(require("./generate"));
|
|
66
|
-
var _new = _interopRequireDefault(require("./new"));
|
|
67
|
-
var _opf = _interopRequireDefault(require("./opf"));
|
|
68
|
-
var _serve = _interopRequireDefault(require("./serve"));
|
|
69
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
70
|
-
var _check = _interopRequireDefault(require("./check"));
|
package/dist/commands/new.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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");
|
|
10
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
exports.default = void 0;
|
|
16
|
-
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
17
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
18
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
19
|
-
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
20
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
21
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
22
|
-
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
23
|
-
var _configOptions = require("../lib/config-options");
|
|
24
|
-
const _excluded = ["_", "$0", "name", "config"];
|
|
25
|
-
/* eslint-disable no-unused-vars */
|
|
26
|
-
/* eslint-disable camelcase */
|
|
27
|
-
/* eslint-disable no-continue */
|
|
28
|
-
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
-
const command = 'new <name>';
|
|
31
|
-
const describe = 'Create a new project';
|
|
32
|
-
const builder = yargs => (0, _configOptions.withConfigOptions)(yargs.positional('name', {
|
|
33
|
-
describe: 'New project name',
|
|
34
|
-
type: 'string'
|
|
35
|
-
})).fail((msg, err) => (0, _utils.fail)(msg, err, yargs)).help('h').alias('h', 'help').usage(`\nUsage: $0 new "My Project"\n\n${describe}`);
|
|
36
|
-
const handler = async argv => {
|
|
37
|
-
// Extract CLI options and get the config file option in case there is one
|
|
38
|
-
const {
|
|
39
|
-
_,
|
|
40
|
-
$0,
|
|
41
|
-
name,
|
|
42
|
-
config
|
|
43
|
-
} = argv,
|
|
44
|
-
configOptions = (0, _objectWithoutProperties2.default)(argv, _excluded);
|
|
45
|
-
|
|
46
|
-
// Set up the config object that's going to be passed into the `init` function
|
|
47
|
-
let projectConfig = {};
|
|
48
|
-
|
|
49
|
-
// Check if a config files has been specified
|
|
50
|
-
if (config) projectConfig = await (0, _configOptions.parseConfigFile)(config);
|
|
51
|
-
|
|
52
|
-
// Override the values specified in the config file with values
|
|
53
|
-
// that have been explicitly provided on the CLI. Allows using the
|
|
54
|
-
// config file as a template that can be overridden, e.g.,
|
|
55
|
-
// bber new foo --config my-generic-conf.yaml --base_path /foo
|
|
56
|
-
projectConfig = _objectSpread(_objectSpread({}, projectConfig), configOptions);
|
|
57
|
-
|
|
58
|
-
// Remove blacklisted and unsupported config options
|
|
59
|
-
for (const [key] of (0, _entries.default)(projectConfig)) {
|
|
60
|
-
if (!_State.default.has(`config.${key}`)) {
|
|
61
|
-
_bBerLogger.default.warn('Invalid configuration option [%s]', key);
|
|
62
|
-
delete projectConfig[key];
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (_configOptions.blacklistedConfigOptions.has(key)) {
|
|
66
|
-
_bBerLogger.default.warn('Disallowed configuration option [%s]', key);
|
|
67
|
-
delete projectConfig[key];
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const initializer = new _bBerTasks.init({
|
|
72
|
-
name,
|
|
73
|
-
config: projectConfig
|
|
74
|
-
});
|
|
75
|
-
initializer.start();
|
|
76
|
-
};
|
|
77
|
-
var _default = exports.default = {
|
|
78
|
-
command,
|
|
79
|
-
describe,
|
|
80
|
-
builder,
|
|
81
|
-
handler
|
|
82
|
-
};
|
package/dist/commands/opf.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
const command = 'opf';
|
|
10
|
-
const describe = 'Generate the opf';
|
|
11
|
-
const builder = yargs => yargs.help('h').alias('h', 'help').usage(`\nUsage: $0 opf\n\n${describe}`);
|
|
12
|
-
const handler = _bBerTasks.opf;
|
|
13
|
-
var _default = exports.default = {
|
|
14
|
-
command,
|
|
15
|
-
describe,
|
|
16
|
-
builder,
|
|
17
|
-
handler
|
|
18
|
-
};
|
package/dist/commands/serve.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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.default = void 0;
|
|
9
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
10
|
-
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
11
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
12
|
-
const command = 'serve [build] [opts]';
|
|
13
|
-
const describe = 'Preview a project in the browser using the `reader` build.';
|
|
14
|
-
const handler = yargs => {
|
|
15
|
-
const {
|
|
16
|
-
external,
|
|
17
|
-
build
|
|
18
|
-
} = yargs;
|
|
19
|
-
_bBerLogger.default.notice(`Serving [b-ber-${build}]`);
|
|
20
|
-
return (0, _bBerTasks.serve)({
|
|
21
|
-
build,
|
|
22
|
-
external
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
const builder = yargs => yargs.positional('build', {
|
|
26
|
-
describe: 'Build to preview',
|
|
27
|
-
choices: ['reader', 'web'],
|
|
28
|
-
type: 'string'
|
|
29
|
-
}).option('external', {
|
|
30
|
-
alias: 'e',
|
|
31
|
-
describe: 'Serve from an externally accessible URL',
|
|
32
|
-
type: 'boolean'
|
|
33
|
-
}).help('h').alias('h', 'help').usage(`\nUsage: $0 serve\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
|
|
34
|
-
var _default = exports.default = {
|
|
35
|
-
command,
|
|
36
|
-
describe,
|
|
37
|
-
builder,
|
|
38
|
-
handler
|
|
39
|
-
};
|
package/dist/commands/theme.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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.default = void 0;
|
|
9
|
-
var _Theme = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/Theme"));
|
|
10
|
-
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
11
|
-
const _command = 'theme <command> [options]';
|
|
12
|
-
const describe = "Manage a project's theme";
|
|
13
|
-
const handler = args => (0, _utils.ensure)().then(() => {
|
|
14
|
-
const {
|
|
15
|
-
command,
|
|
16
|
-
options
|
|
17
|
-
} = args;
|
|
18
|
-
return _Theme.default[command](options);
|
|
19
|
-
}).catch(console.error);
|
|
20
|
-
const builder = yargs => yargs.positional('command', {
|
|
21
|
-
describe: 'Theme command to execute',
|
|
22
|
-
choices: ['set', 'list'],
|
|
23
|
-
type: 'string'
|
|
24
|
-
}).positional('options', {
|
|
25
|
-
describe: 'Name of the theme to activate',
|
|
26
|
-
type: 'string'
|
|
27
|
-
}).help('h').alias('h', 'help').usage(`\nUsage: $0 theme\n\n${describe}`).fail((msg, err) => (0, _utils.fail)(msg, err, yargs));
|
|
28
|
-
var _default = exports.default = {
|
|
29
|
-
command: _command,
|
|
30
|
-
describe,
|
|
31
|
-
builder,
|
|
32
|
-
handler
|
|
33
|
-
};
|
package/dist/commands/xml.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _bBerTasks = require("@canopycanopycanopy/b-ber-tasks");
|
|
9
|
-
const command = 'xml';
|
|
10
|
-
const describe = 'Export a project as an XML document';
|
|
11
|
-
const builder = yargs => yargs.help('h').alias('h', 'help').usage(`\nUsage: $0 xml\n\n${describe}`);
|
|
12
|
-
const handler = _bBerTasks.xml;
|
|
13
|
-
var _default = exports.default = {
|
|
14
|
-
command,
|
|
15
|
-
describe,
|
|
16
|
-
builder,
|
|
17
|
-
handler
|
|
18
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
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
|
-
const blacklistedConfigOptions = exports.blacklistedConfigOptions = new _set.default(['ibooks_specified_fonts', 'autoprefixer_options', 'downloads', 'ui_options']);
|
|
89
|
-
const parseConfigFile = async configFile => {
|
|
90
|
-
const ext = _path.default.extname(configFile);
|
|
91
|
-
const configPath = _path.default.resolve(process.cwd(), configFile);
|
|
92
|
-
if (!(await _fsExtra.default.pathExists(configPath))) {
|
|
93
|
-
_bBerLogger.default.error(`Could not find config at [${configPath}]`);
|
|
94
|
-
}
|
|
95
|
-
if (/^\.(?:ya?ml|json)/i.test(ext) === false) {
|
|
96
|
-
_bBerLogger.default.error('Config file must have a .json or .yaml/.yml file extension');
|
|
97
|
-
}
|
|
98
|
-
const contents = await _fsExtra.default.readFile(configPath);
|
|
99
|
-
if (/^\.ya?ml/i.test(ext)) return _YamlAdaptor.default.parse(contents);
|
|
100
|
-
return JSON.parse(contents);
|
|
101
|
-
};
|
|
102
|
-
exports.parseConfigFile = parseConfigFile;
|