@liascript/exporter 3.0.0--1.0.3 → 3.0.1--1.0.3
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/assets/capacitor/{index.bfe7363b.js → index.a7f021f7.js} +1 -1
- package/dist/assets/capacitor/index.html +1 -1
- package/dist/assets/capacitor/{jszip.min.f6eda75b.js → jszip.min.43389eb1.js} +1 -1
- package/dist/assets/capacitor/{trystero-ipfs.min.b27a61d7.js → trystero-ipfs.min.f25fe3e7.js} +1 -1
- package/dist/assets/indexeddb/{index.599a57d6.js → index.4aceca2f.js} +1 -1
- package/dist/assets/indexeddb/index.html +1 -1
- package/dist/assets/indexeddb/{jszip.min.63142cc8.js → jszip.min.4fbcc13f.js} +1 -1
- package/dist/assets/scorm2004/{index.7a5820ab.js → index.33bec53a.js} +1 -1
- package/dist/assets/scorm2004/index.html +1 -1
- package/dist/assets/scorm2004/{jszip.min.63142cc8.js → jszip.min.4fbcc13f.js} +1 -1
- package/dist/assets/xapi/{index.018a032a.js → index.f2e89e49.js} +1 -1
- package/dist/assets/xapi/index.html +1 -1
- package/dist/assets/xapi/{jszip.min.eaecf580.js → jszip.min.19c66d77.js} +1 -1
- package/dist/index.js +47 -47
- package/dist/server/presets.json +94 -0
- package/dist/server/presets.yaml +120 -0
- package/dist/server/public/app.js +1 -0
- package/dist/server/public/assets/android.svg +38 -0
- package/dist/server/public/assets/cmi.svg +154 -0
- package/dist/server/public/assets/docx.svg +20 -0
- package/dist/server/public/assets/edX.svg +75 -0
- package/dist/server/public/assets/edx.svg +75 -0
- package/dist/server/public/assets/epub.svg +18 -0
- package/dist/server/public/assets/icon.svg +82 -0
- package/dist/server/public/assets/ilias.png +0 -0
- package/dist/server/public/assets/json.svg +4 -0
- package/dist/server/public/assets/learnworlds.png +0 -0
- package/dist/server/public/assets/moodle.svg +190 -0
- package/dist/server/public/assets/opal.png +0 -0
- package/dist/server/public/assets/openolat.png +0 -0
- package/dist/server/public/assets/pdf.svg +4 -0
- package/dist/server/public/assets/rdf.svg +4 -0
- package/dist/server/public/assets/scorm.png +0 -0
- package/dist/server/public/assets/web.png +0 -0
- package/dist/server/public/assets/xapi.png +0 -0
- package/dist/server/public/i18n.js +1 -0
- package/dist/server/public/index.html +1587 -0
- package/dist/server/public/locales/de.json +247 -0
- package/dist/server/public/locales/en.json +247 -0
- package/dist/server/public/status.html +251 -0
- package/dist/server/public/styles.css +712 -0
- package/package.json +5 -1
- package/.parcelrc +0 -3
- package/DESKTOP_APP_README.md +0 -58
- package/DOCKERHUB_DESCRIPTION.md +0 -52
- package/Dockerfile +0 -129
- package/PLAYSTORE_GUIDE.md +0 -172
- package/action.yml +0 -157
- package/custom.css +0 -10
- package/electron-builder.json +0 -149
- package/src/cli.ts +0 -69
- package/src/colorize.ts +0 -115
- package/src/export/android.ts +0 -419
- package/src/export/docx.ts +0 -1025
- package/src/export/epub.ts +0 -1306
- package/src/export/h5p.ts +0 -390
- package/src/export/helper.ts +0 -360
- package/src/export/ims.ts +0 -191
- package/src/export/pdf.ts +0 -406
- package/src/export/presets.ts +0 -220
- package/src/export/project.ts +0 -829
- package/src/export/rdf.ts +0 -551
- package/src/export/scorm12.ts +0 -167
- package/src/export/scorm2004.ts +0 -140
- package/src/export/web.ts +0 -306
- package/src/export/xapi.ts +0 -424
- package/src/exporter.ts +0 -296
- package/src/index.ts +0 -96
- package/src/parser.ts +0 -373
- package/src/presets.yaml +0 -219
- package/src/types.ts +0 -82
- package/tsconfig.json +0 -24
package/src/export/scorm2004.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as helper from './helper'
|
|
2
|
-
|
|
3
|
-
import * as RDF from './rdf'
|
|
4
|
-
|
|
5
|
-
const scormPackager = require('@liascript/simple-scorm-packager')
|
|
6
|
-
const path = require('path')
|
|
7
|
-
const fs = require('fs-extra')
|
|
8
|
-
|
|
9
|
-
export interface Scorm2004ExportArguments {
|
|
10
|
-
input: string
|
|
11
|
-
readme: string
|
|
12
|
-
output: string
|
|
13
|
-
format: string
|
|
14
|
-
path: string
|
|
15
|
-
key?: string
|
|
16
|
-
style?: string
|
|
17
|
-
'scorm-organization'?: string
|
|
18
|
-
'scorm-masteryScore'?: string
|
|
19
|
-
'scorm-typicalDuration'?: string
|
|
20
|
-
'scorm-iframe'?: boolean
|
|
21
|
-
'scorm-embed'?: string | boolean
|
|
22
|
-
'scorm-alwaysActive'?: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const format = 'scorm2004'
|
|
26
|
-
|
|
27
|
-
export async function exporter(argument: Scorm2004ExportArguments, json: any) {
|
|
28
|
-
// make temp folder
|
|
29
|
-
let tmp = await helper.tmpDir()
|
|
30
|
-
const dirname = helper.dirname()
|
|
31
|
-
|
|
32
|
-
let tmpPath = path.join(tmp, 'pro')
|
|
33
|
-
|
|
34
|
-
// copy assets to temp
|
|
35
|
-
await fs.copy(path.join(dirname, './assets/scorm2004'), tmpPath)
|
|
36
|
-
await fs.copy(path.join(dirname, './assets/common'), tmpPath)
|
|
37
|
-
|
|
38
|
-
let index = fs.readFileSync(path.join(tmpPath, 'index.html'), 'utf8')
|
|
39
|
-
|
|
40
|
-
// change responsive key
|
|
41
|
-
if (argument.key) {
|
|
42
|
-
index = helper.injectResponsivevoice(argument.key, index)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
index = helper.inject('<script src="config.js"></script>', index)
|
|
46
|
-
|
|
47
|
-
let conf =
|
|
48
|
-
'window.config_ = ' +
|
|
49
|
-
JSON.stringify({
|
|
50
|
-
task: json.task,
|
|
51
|
-
quiz: json.quiz,
|
|
52
|
-
survey: json.survey,
|
|
53
|
-
}) +
|
|
54
|
-
';'
|
|
55
|
-
|
|
56
|
-
if (argument['scorm-alwaysActive']) {
|
|
57
|
-
conf += '\n\nwindow["ACTIVE"] = true;'
|
|
58
|
-
|
|
59
|
-
if (argument['scorm-masteryScore']) {
|
|
60
|
-
conf +=
|
|
61
|
-
'\n\nwindow["MASTERY_SCORE"] =' +
|
|
62
|
-
parseFloat(argument['scorm-masteryScore']) / 100
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await helper.writeFile(path.join(tmpPath, 'config.js'), conf)
|
|
67
|
-
|
|
68
|
-
const jsonLD = await RDF.script(argument, json)
|
|
69
|
-
|
|
70
|
-
if (argument['scorm-iframe']) {
|
|
71
|
-
await helper.iframe(
|
|
72
|
-
tmpPath,
|
|
73
|
-
'start.html',
|
|
74
|
-
argument.readme,
|
|
75
|
-
jsonLD,
|
|
76
|
-
argument.style
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (argument['scorm-embed']) {
|
|
81
|
-
index = helper.inject('<script src="course.js"></script>', index, true)
|
|
82
|
-
await helper.writeFile(
|
|
83
|
-
path.join(tmpPath, 'course.js'),
|
|
84
|
-
'window["liascript_course"] = ' + JSON.stringify(argument['scorm-embed'])
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
index = helper.inject(jsonLD, index)
|
|
90
|
-
await helper.writeFile(path.join(tmpPath, 'index.html'), index)
|
|
91
|
-
} catch (e) {
|
|
92
|
-
console.warn(e)
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// copy base path or readme-directory into temp
|
|
97
|
-
await fs.copy(argument.path, tmpPath, {
|
|
98
|
-
filter: helper.filterHidden(argument.path),
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
let config = {
|
|
102
|
-
version: '2004 4th Edition',
|
|
103
|
-
organization: argument['scorm-organization'] || 'LiaScript',
|
|
104
|
-
title: json.lia.str_title,
|
|
105
|
-
language: json.lia.definition.language,
|
|
106
|
-
masteryScore: argument['scorm-masteryScore'] || 0,
|
|
107
|
-
startingPage: argument['scorm-iframe'] ? 'start.html' : 'index.html',
|
|
108
|
-
startingParameters:
|
|
109
|
-
argument['scorm-iframe'] || argument['scorm-embed']
|
|
110
|
-
? undefined
|
|
111
|
-
: argument.readme,
|
|
112
|
-
source: path.join(tmp, 'pro'),
|
|
113
|
-
package: {
|
|
114
|
-
version: json.lia.definition.version,
|
|
115
|
-
appendTimeToOutput: false,
|
|
116
|
-
date: '',
|
|
117
|
-
filename: path.basename(argument.output + '.zip'),
|
|
118
|
-
zip: true,
|
|
119
|
-
name: path.basename(argument.output),
|
|
120
|
-
author: json.lia.definition.author,
|
|
121
|
-
outputFolder: path.dirname(argument.output),
|
|
122
|
-
description: json.lia.comment,
|
|
123
|
-
//keywords: ['scorm', 'test', 'course'],
|
|
124
|
-
typicalDuration: argument['scorm-typicalDuration'] || 'PT0H5M0S',
|
|
125
|
-
//rights: `©${new Date().getFullYear()} My Amazing Company. All right reserved.`,
|
|
126
|
-
vcard: {
|
|
127
|
-
author: json.lia.definition.author,
|
|
128
|
-
org: argument['scorm-organization'] || 'LiaScript',
|
|
129
|
-
//tel: '(000) 000-0000',
|
|
130
|
-
//address: 'my address',
|
|
131
|
-
mail: json.lia.definition.email,
|
|
132
|
-
//url: 'https://mydomain.com'
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
await scormPackager(config, function (msg: string) {
|
|
138
|
-
console.log(msg)
|
|
139
|
-
})
|
|
140
|
-
}
|
package/src/export/web.ts
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import * as helper from './helper'
|
|
2
|
-
import * as RDF from './rdf'
|
|
3
|
-
import * as path from 'path'
|
|
4
|
-
import * as fs from 'fs-extra'
|
|
5
|
-
|
|
6
|
-
// Constants
|
|
7
|
-
const HTML_FILE = 'index.html'
|
|
8
|
-
const START_HTML_FILE = 'start.html'
|
|
9
|
-
const DEFAULT_TITLE_TAG = '<title>Lia</title>'
|
|
10
|
-
const DEFAULT_DESCRIPTION_META =
|
|
11
|
-
'<meta name="description" content="LiaScript is a service for running free and interactive online courses, build with its own Markup-language. So check out the following course ;-)">'
|
|
12
|
-
const TEMP_FOLDER_NAME = 'pro'
|
|
13
|
-
|
|
14
|
-
// Type definitions
|
|
15
|
-
export interface WebExportArguments {
|
|
16
|
-
input: string
|
|
17
|
-
readme: string
|
|
18
|
-
output: string
|
|
19
|
-
format: string
|
|
20
|
-
path: string
|
|
21
|
-
key?: string
|
|
22
|
-
style?: string
|
|
23
|
-
'web-iframe'?: boolean
|
|
24
|
-
'web-indexeddb'?: boolean | string
|
|
25
|
-
'web-zip'?: boolean
|
|
26
|
-
'rdf-format'?: string
|
|
27
|
-
'rdf-preview'?: string
|
|
28
|
-
'rdf-url'?: string
|
|
29
|
-
'rdf-type'?: string
|
|
30
|
-
'rdf-template'?: string
|
|
31
|
-
'rdf-license'?: string
|
|
32
|
-
'rdf-educationalLevel'?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface LiaDefinition {
|
|
36
|
-
macro?: {
|
|
37
|
-
comment?: string
|
|
38
|
-
}
|
|
39
|
-
logo?: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface LiaJson {
|
|
43
|
-
lia: {
|
|
44
|
-
str_title: string
|
|
45
|
-
definition: LiaDefinition
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface ExportError {
|
|
50
|
-
step: string
|
|
51
|
-
error: Error | unknown
|
|
52
|
-
critical: boolean
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const format = 'web'
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Exports a LiaScript course as a web application
|
|
59
|
-
* @param argument - Export configuration parameters
|
|
60
|
-
* @param json - Parsed LiaScript JSON data
|
|
61
|
-
* @throws {Error} If critical operations fail
|
|
62
|
-
*/
|
|
63
|
-
export async function exporter(
|
|
64
|
-
argument: WebExportArguments,
|
|
65
|
-
json: LiaJson,
|
|
66
|
-
): Promise<void> {
|
|
67
|
-
const errors: ExportError[] = []
|
|
68
|
-
let tempPath: string | null = null
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
// make temp folder
|
|
72
|
-
const tmp = (await helper.tmpDir()) as string
|
|
73
|
-
const dirname = helper.dirname()
|
|
74
|
-
tempPath = path.join(tmp, TEMP_FOLDER_NAME)
|
|
75
|
-
|
|
76
|
-
// Copy assets to temp
|
|
77
|
-
await copyAssets(dirname, tempPath, argument['web-indexeddb'])
|
|
78
|
-
|
|
79
|
-
// Copy base path or readme-directory into temp
|
|
80
|
-
await fs.copy(argument.path, tempPath)
|
|
81
|
-
|
|
82
|
-
// Rename the readme if necessary and update argument
|
|
83
|
-
const readmePath = await handleReadmeRename(
|
|
84
|
-
tempPath,
|
|
85
|
-
argument.readme,
|
|
86
|
-
argument['web-indexeddb'],
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
// Read and process index.html
|
|
90
|
-
let indexContent = await fs.readFile(path.join(tempPath, HTML_FILE), 'utf8')
|
|
91
|
-
|
|
92
|
-
// Inject ResponsiveVoice key if provided
|
|
93
|
-
if (argument.key) {
|
|
94
|
-
indexContent = helper.injectResponsivevoice(argument.key, indexContent)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Add default course URL
|
|
98
|
-
indexContent = injectDefaultCourse(indexContent, readmePath)
|
|
99
|
-
|
|
100
|
-
// Update metadata (title, description, logo)
|
|
101
|
-
indexContent = updateMetadata(indexContent, json, errors)
|
|
102
|
-
|
|
103
|
-
// Generate RDF metadata
|
|
104
|
-
const jsonLD = await RDF.script(argument, json)
|
|
105
|
-
|
|
106
|
-
// Write final output
|
|
107
|
-
await writeOutput(
|
|
108
|
-
tempPath,
|
|
109
|
-
indexContent,
|
|
110
|
-
readmePath,
|
|
111
|
-
jsonLD,
|
|
112
|
-
argument,
|
|
113
|
-
errors,
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
// Move or zip the output
|
|
117
|
-
await finalizeOutput(tempPath, argument)
|
|
118
|
-
|
|
119
|
-
// Report any non-critical errors
|
|
120
|
-
if (errors.length > 0) {
|
|
121
|
-
console.warn(`Export completed with ${errors.length} warning(s):`)
|
|
122
|
-
errors.forEach((err) => {
|
|
123
|
-
console.warn(` - ${err.step}: ${err.error}`)
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
} catch (error) {
|
|
127
|
-
// Clean up temp directory on critical error
|
|
128
|
-
if (tempPath) {
|
|
129
|
-
try {
|
|
130
|
-
await fs.remove(tempPath)
|
|
131
|
-
} catch (cleanupError) {
|
|
132
|
-
console.warn('Failed to clean up temporary directory:', cleanupError)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
throw new Error(
|
|
136
|
-
`Web export failed: ${
|
|
137
|
-
error instanceof Error ? error.message : String(error)
|
|
138
|
-
}`,
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Copy required assets to the temporary directory
|
|
145
|
-
*/
|
|
146
|
-
async function copyAssets(
|
|
147
|
-
dirname: string,
|
|
148
|
-
tmpPath: string,
|
|
149
|
-
useIndexedDB?: boolean | string,
|
|
150
|
-
): Promise<void> {
|
|
151
|
-
const assetsDir = useIndexedDB ? './assets/indexeddb' : './assets/web'
|
|
152
|
-
|
|
153
|
-
await fs.copy(path.join(dirname, assetsDir), tmpPath)
|
|
154
|
-
await fs.copy(path.join(dirname, './assets/common'), tmpPath)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Handle readme file renaming for IndexedDB mode
|
|
159
|
-
* @returns The final readme path (relative or renamed)
|
|
160
|
-
*/
|
|
161
|
-
async function handleReadmeRename(
|
|
162
|
-
tmpPath: string,
|
|
163
|
-
readmePath: string,
|
|
164
|
-
webIndexedDB?: boolean | string,
|
|
165
|
-
): Promise<string> {
|
|
166
|
-
if (webIndexedDB === undefined) {
|
|
167
|
-
return readmePath
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const newReadmeName =
|
|
171
|
-
(typeof webIndexedDB === 'string' ? webIndexedDB : helper.random(20)) +
|
|
172
|
-
'.md'
|
|
173
|
-
|
|
174
|
-
const oldPath = path.join(tmpPath, readmePath)
|
|
175
|
-
const newPath = path.join(path.dirname(oldPath), newReadmeName)
|
|
176
|
-
|
|
177
|
-
await fs.move(oldPath, newPath)
|
|
178
|
-
|
|
179
|
-
// Return the updated readme path (replace basename)
|
|
180
|
-
return readmePath.replace(path.basename(readmePath), newReadmeName)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Inject default course URL into index.html
|
|
185
|
-
*/
|
|
186
|
-
function injectDefaultCourse(indexContent: string, readmePath: string): string {
|
|
187
|
-
const script = `<script>
|
|
188
|
-
if (!window.LIA) {
|
|
189
|
-
window.LIA = {}
|
|
190
|
-
}
|
|
191
|
-
window.LIA.defaultCourseURL = "${path.basename(readmePath)}"
|
|
192
|
-
</script>`
|
|
193
|
-
|
|
194
|
-
return helper.inject(script, indexContent)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Update HTML metadata (title, description, logo)
|
|
199
|
-
*/
|
|
200
|
-
function updateMetadata(
|
|
201
|
-
indexContent: string,
|
|
202
|
-
json: LiaJson,
|
|
203
|
-
errors: ExportError[],
|
|
204
|
-
): string {
|
|
205
|
-
let updatedContent = indexContent
|
|
206
|
-
|
|
207
|
-
// Update title
|
|
208
|
-
try {
|
|
209
|
-
const title = json.lia?.str_title
|
|
210
|
-
if (title) {
|
|
211
|
-
updatedContent = updatedContent.replace(
|
|
212
|
-
DEFAULT_TITLE_TAG,
|
|
213
|
-
`<title>${title}</title><meta property="og:title" content="${title}"> <meta name="twitter:title" content="${title}">`,
|
|
214
|
-
)
|
|
215
|
-
console.log('updating title ...')
|
|
216
|
-
}
|
|
217
|
-
} catch (error) {
|
|
218
|
-
errors.push({ step: 'Update title', error, critical: false })
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Update description
|
|
222
|
-
try {
|
|
223
|
-
const description = json.lia?.definition?.macro?.comment
|
|
224
|
-
if (description) {
|
|
225
|
-
updatedContent = updatedContent.replace(
|
|
226
|
-
DEFAULT_DESCRIPTION_META,
|
|
227
|
-
`<meta name="description" content="${description}"><meta property="og:description" content="${description}"><meta name="twitter:description" content="${description}">`,
|
|
228
|
-
)
|
|
229
|
-
console.log('updating description ...')
|
|
230
|
-
}
|
|
231
|
-
} catch (error) {
|
|
232
|
-
errors.push({ step: 'Update description', error, critical: false })
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Update logo
|
|
236
|
-
try {
|
|
237
|
-
const logo = json.lia?.definition?.logo
|
|
238
|
-
if (logo) {
|
|
239
|
-
updatedContent = helper.inject(
|
|
240
|
-
`<meta property="og:image" content="${logo}"><meta name="twitter:image" content="${logo}">`,
|
|
241
|
-
updatedContent,
|
|
242
|
-
)
|
|
243
|
-
console.log('updating logo ...')
|
|
244
|
-
}
|
|
245
|
-
} catch (error) {
|
|
246
|
-
errors.push({ step: 'Update logo', error, critical: false })
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return updatedContent
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Write the final output (iframe or regular)
|
|
254
|
-
*/
|
|
255
|
-
async function writeOutput(
|
|
256
|
-
tmpPath: string,
|
|
257
|
-
indexContent: string,
|
|
258
|
-
readmePath: string,
|
|
259
|
-
jsonLD: string,
|
|
260
|
-
argument: WebExportArguments,
|
|
261
|
-
errors: ExportError[],
|
|
262
|
-
): Promise<void> {
|
|
263
|
-
try {
|
|
264
|
-
if (argument['web-iframe']) {
|
|
265
|
-
await helper.writeFile(path.join(tmpPath, START_HTML_FILE), indexContent)
|
|
266
|
-
await helper.iframe(
|
|
267
|
-
tmpPath,
|
|
268
|
-
HTML_FILE,
|
|
269
|
-
readmePath,
|
|
270
|
-
jsonLD,
|
|
271
|
-
argument.style,
|
|
272
|
-
START_HTML_FILE,
|
|
273
|
-
)
|
|
274
|
-
} else {
|
|
275
|
-
indexContent = helper.inject(jsonLD, indexContent)
|
|
276
|
-
indexContent = helper.prettify(indexContent)
|
|
277
|
-
|
|
278
|
-
await helper.writeFile(path.join(tmpPath, HTML_FILE), indexContent)
|
|
279
|
-
}
|
|
280
|
-
} catch (error) {
|
|
281
|
-
errors.push({ step: 'Write output', error, critical: true })
|
|
282
|
-
throw error
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Finalize output by creating zip or moving directory
|
|
288
|
-
*/
|
|
289
|
-
async function finalizeOutput(
|
|
290
|
-
tmpPath: string,
|
|
291
|
-
argument: WebExportArguments,
|
|
292
|
-
): Promise<void> {
|
|
293
|
-
if (argument['web-zip']) {
|
|
294
|
-
await helper.zip(tmpPath, argument.output)
|
|
295
|
-
} else {
|
|
296
|
-
// Ensure output directory exists before copying
|
|
297
|
-
await fs.ensureDir(argument.output)
|
|
298
|
-
|
|
299
|
-
// Copy with filter, then remove temp
|
|
300
|
-
await fs.copy(tmpPath, argument.output, {
|
|
301
|
-
filter: helper.filterHidden(tmpPath),
|
|
302
|
-
overwrite: true,
|
|
303
|
-
})
|
|
304
|
-
await fs.remove(tmpPath)
|
|
305
|
-
}
|
|
306
|
-
}
|