coralite 0.8.1 → 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/bin/coralite.js +20 -10
- package/changelog.md +849 -79
- 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 -640
- package/lib/plugin.js +44 -0
- package/lib/type-helper.js +10 -0
- package/lib/utils.js +27 -2
- package/package.json +8 -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/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 { getPkg,
|
|
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,18 +51,19 @@ 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
69
|
process.stdout.write(PAD + `${kleur.bold('- Path:')} ${document.item.path.pathname}\n`)
|
|
@@ -63,8 +73,8 @@ if (options.dryRun) {
|
|
|
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 =
|
|
76
|
+
for (let i = 0; i < collection.length; i++) {
|
|
77
|
+
const document = collection[i]
|
|
68
78
|
const dir = join(output, document.item.path.dirname)
|
|
69
79
|
|
|
70
80
|
if (!existsSync(dir)) {
|