coralite 0.8.0 → 0.9.0
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/.woodpecker/test-e2e.yml +3 -0
- package/.woodpecker/test-script.yml +3 -0
- package/bin/coralite.js +24 -16
- package/changelog.md +977 -184
- package/lib/collection.js +205 -0
- package/lib/coralite.js +722 -154
- package/lib/html.js +102 -0
- package/lib/index.js +5 -6
- package/lib/loader.js +25 -0
- package/lib/parse.js +25 -638
- package/lib/plugin.js +44 -0
- package/lib/type-helper.js +10 -0
- package/lib/utils.js +26 -28
- package/package.json +13 -4
- package/plugins/define-component.js +199 -0
- package/plugins/index.js +1 -0
- package/types/index.js +68 -41
- package/lib/get-html.js +0 -92
- package/lib/get-pkg.js +0 -22
- package/lib/html-module.js +0 -395
- package/scripts/changelog.sh +0 -6
package/.woodpecker/test-e2e.yml
CHANGED
package/bin/coralite.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node --experimental-vm-modules --experimental-import-meta-resolve
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getPkg, Coralite } from '#lib'
|
|
4
4
|
import { Command } from 'commander'
|
|
5
5
|
import { join } from 'node:path'
|
|
6
6
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
|
7
7
|
import kleur from 'kleur'
|
|
8
|
+
import { loadConfig } from '../lib/loader.js'
|
|
8
9
|
|
|
9
10
|
// Remove all Node warnings before doing anything else
|
|
10
11
|
process.removeAllListeners('warning')
|
|
11
12
|
|
|
12
13
|
const pkg = await getPkg()
|
|
13
14
|
const program = new Command()
|
|
15
|
+
const config = await loadConfig()
|
|
14
16
|
|
|
15
17
|
program
|
|
16
18
|
.name(pkg.name)
|
|
@@ -32,6 +34,13 @@ const pages = options.pages
|
|
|
32
34
|
const output = options.output
|
|
33
35
|
const ignoreByAttribute = []
|
|
34
36
|
|
|
37
|
+
const coraliteOptions = {
|
|
38
|
+
templates: options.templates,
|
|
39
|
+
pages,
|
|
40
|
+
ignoreByAttribute,
|
|
41
|
+
plugins: []
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
for (let i = 0; i < options.ignoreAttribute.length; i++) {
|
|
36
45
|
const pair = options.ignoreAttribute[i].split('=')
|
|
37
46
|
|
|
@@ -42,38 +51,37 @@ for (let i = 0; i < options.ignoreAttribute.length; i++) {
|
|
|
42
51
|
ignoreByAttribute.push(pair)
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
if (config && config.plugins) {
|
|
55
|
+
coraliteOptions.plugins = coraliteOptions.plugins.concat(config.plugins)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const coralite = new Coralite(coraliteOptions)
|
|
59
|
+
const collection = await coralite.compile()
|
|
50
60
|
|
|
51
61
|
if (options.dryRun) {
|
|
52
62
|
const PAD = ' '
|
|
53
63
|
const border = '─'.repeat(Math.min(process.stdout.columns, 36) / 2)
|
|
54
64
|
|
|
55
|
-
for (let i = 0; i <
|
|
56
|
-
const document =
|
|
65
|
+
for (let i = 0; i < collection.length; i++) {
|
|
66
|
+
const document = collection[i]
|
|
57
67
|
|
|
58
68
|
process.stdout.write('\n' + PAD + kleur.green('Document is ready!\n\n'))
|
|
59
|
-
process.stdout.write(PAD + `${kleur.bold('- Path:')} ${
|
|
60
|
-
process.stdout.write(PAD + `${kleur.bold('- Built in:')}
|
|
69
|
+
process.stdout.write(PAD + `${kleur.bold('- Path:')} ${document.item.path.pathname}\n`)
|
|
70
|
+
process.stdout.write(PAD + `${kleur.bold('- Built in:')} ${Math.floor(document.duration)}ms\n\n`)
|
|
61
71
|
process.stdout.write(border + kleur.inverse(' Content start ') + border + '\n\n')
|
|
62
72
|
process.stdout.write(document.html)
|
|
63
73
|
process.stdout.write('\n\n' + border + kleur.inverse(' Content end ') + border + '\n')
|
|
64
74
|
}
|
|
65
75
|
} else {
|
|
66
|
-
for (let i = 0; i <
|
|
67
|
-
const document =
|
|
68
|
-
|
|
69
|
-
const subDir = getSubDirectory(pages, document.item.parentPath)
|
|
70
|
-
const dir = join(output, subDir)
|
|
76
|
+
for (let i = 0; i < collection.length; i++) {
|
|
77
|
+
const document = collection[i]
|
|
78
|
+
const dir = join(output, document.item.path.dirname)
|
|
71
79
|
|
|
72
80
|
if (!existsSync(dir)) {
|
|
73
81
|
// create directory
|
|
74
82
|
mkdirSync(dir)
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
writeFileSync(join(
|
|
85
|
+
writeFileSync(join(output, document.item.path.pathname), document.html)
|
|
78
86
|
}
|
|
79
87
|
}
|