@liascript/exporter 2.4.5--0.10.22 → 2.5.0--0.10.22
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 +153 -1
- package/dist/index.js +1 -1
- package/package.json +5 -4
- package/src/export/pdf.ts +41 -26
- package/src/export/project.ts +474 -0
- package/src/index.ts +60 -4
package/src/index.ts
CHANGED
|
@@ -9,16 +9,18 @@ import * as helper from './export/helper'
|
|
|
9
9
|
import * as IMS from './export/ims'
|
|
10
10
|
import * as ANDROID from './export/android'
|
|
11
11
|
// import * as IOS from './export/ios'
|
|
12
|
+
import * as PROJECT from './export/project'
|
|
12
13
|
|
|
13
14
|
global.XMLHttpRequest = require('xhr2')
|
|
14
15
|
|
|
16
|
+
import YAML from 'yaml'
|
|
15
17
|
const path = require('path')
|
|
16
18
|
const fs = require('fs-extra')
|
|
17
19
|
const argv = require('minimist')(process.argv.slice(2))
|
|
18
20
|
|
|
19
21
|
// -------------------------------Main Execution-------------------------------
|
|
20
22
|
if (argv.v || argv.version) {
|
|
21
|
-
console.log('version: 2.
|
|
23
|
+
console.log('version: 2.5.0--0.10.22')
|
|
22
24
|
} else if (argv.h || argv.help) {
|
|
23
25
|
help()
|
|
24
26
|
} else if (argv.i || argv.input) {
|
|
@@ -29,6 +31,8 @@ if (argv.v || argv.version) {
|
|
|
29
31
|
}
|
|
30
32
|
// ----------------------------------------------------------------------------
|
|
31
33
|
|
|
34
|
+
var collection: any
|
|
35
|
+
|
|
32
36
|
function run(argument) {
|
|
33
37
|
var app = Elm.Worker.init({ flags: { cmd: '' } })
|
|
34
38
|
app.ports.output.subscribe(function (event) {
|
|
@@ -72,6 +76,26 @@ function run(argument) {
|
|
|
72
76
|
ANDROID.exporter(argument, JSON.parse(string))
|
|
73
77
|
break
|
|
74
78
|
}
|
|
79
|
+
case 'project': {
|
|
80
|
+
if (collection) {
|
|
81
|
+
try {
|
|
82
|
+
PROJECT.storeNext(collection, JSON.parse(string).lia)
|
|
83
|
+
|
|
84
|
+
const next = PROJECT.getNext(collection)
|
|
85
|
+
|
|
86
|
+
if (next) {
|
|
87
|
+
console.warn('loading:', next)
|
|
88
|
+
app.ports.input.send(['fulljson', next])
|
|
89
|
+
} else {
|
|
90
|
+
PROJECT.exporter(argument, collection)
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.warn('project export error:', e)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
break
|
|
98
|
+
}
|
|
75
99
|
/*
|
|
76
100
|
case 'ios': {
|
|
77
101
|
IOS.exporter(argument, JSON.parse(string))
|
|
@@ -93,11 +117,21 @@ function run(argument) {
|
|
|
93
117
|
argument.format == 'web' ||
|
|
94
118
|
argument.format == 'ims' ||
|
|
95
119
|
argument.format == 'android' ||
|
|
96
|
-
argument.format == 'ios'
|
|
120
|
+
argument.format == 'ios' ||
|
|
121
|
+
argument.format == 'project'
|
|
97
122
|
? 'fulljson'
|
|
98
123
|
: argument.format
|
|
99
124
|
|
|
100
|
-
if (
|
|
125
|
+
if (argument.format === 'project') {
|
|
126
|
+
const file = fs.readFileSync(argument.input, 'utf8')
|
|
127
|
+
collection = YAML.parse(file)
|
|
128
|
+
|
|
129
|
+
if (collection) {
|
|
130
|
+
const next = PROJECT.getNext(collection)
|
|
131
|
+
console.warn('loading:', next)
|
|
132
|
+
app.ports.input.send([format, next])
|
|
133
|
+
}
|
|
134
|
+
} else if (!helper.isURL(argument.input)) {
|
|
101
135
|
const data = fs.readFileSync(argument.input, 'utf8')
|
|
102
136
|
app.ports.input.send([format, data])
|
|
103
137
|
} else if (argument.format === 'pdf') {
|
|
@@ -260,6 +294,22 @@ function help() {
|
|
|
260
294
|
console.log(
|
|
261
295
|
'--pdf-omitBackground Hides default white background and allows capturing screenshots with transparency. Defaults to true. '
|
|
262
296
|
)
|
|
297
|
+
|
|
298
|
+
console.log('\nProject settings:')
|
|
299
|
+
console.log('')
|
|
300
|
+
console.log(
|
|
301
|
+
'--project-no-meta Disable the generation of meta information for OpenGraph and Twitter-cards.'
|
|
302
|
+
)
|
|
303
|
+
console.log(
|
|
304
|
+
'--project-no-categories Disable the filter for categories/tags.'
|
|
305
|
+
)
|
|
306
|
+
console.log(
|
|
307
|
+
'--project-category-blur Enable this and the categories will be blurred instead of deleted.'
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
console.log(
|
|
311
|
+
'--project-generate-pdf PDFs are automatically generated and added to every card.'
|
|
312
|
+
)
|
|
263
313
|
}
|
|
264
314
|
|
|
265
315
|
function escapeBackslash(path?: string) {
|
|
@@ -302,7 +352,7 @@ function parseArguments() {
|
|
|
302
352
|
'pdf-footerTemplate': argv['pdf-footerTemplate'],
|
|
303
353
|
'pdf-printBackground': argv['pdf-printBackground'],
|
|
304
354
|
'pdf-landscape': argv['pdf-landscape'],
|
|
305
|
-
'pdf-format': argv['pdf-format'],
|
|
355
|
+
'pdf-format': argv['pdf-format'] || 'A4',
|
|
306
356
|
'pdf-width': argv['pdf-width'],
|
|
307
357
|
'pdf-height': argv['pdf-height'],
|
|
308
358
|
'pdf-margin-top': argv['pdf-margin-top'],
|
|
@@ -323,6 +373,12 @@ function parseArguments() {
|
|
|
323
373
|
'android-splash': escapeBackslash(argv['android-splash']),
|
|
324
374
|
'android-splashDuration': argv['android-splashDuration'],
|
|
325
375
|
'android-preview': argv['android-preview'],
|
|
376
|
+
|
|
377
|
+
// project settings
|
|
378
|
+
'project-no-meta': argv['project-no-meta'],
|
|
379
|
+
'project-no-categories': argv['project-no-categories'],
|
|
380
|
+
'project-category-blur': argv['project-category-blur'],
|
|
381
|
+
'project-generate-pdf': argv['project-generate-pdf'],
|
|
326
382
|
}
|
|
327
383
|
|
|
328
384
|
argument.format = argument.format.toLowerCase()
|