@chriswiegman/hugo-tools 0.2.0 → 0.2.2
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/CHANGELOG.md +18 -0
- package/README.md +12 -1
- package/package.json +6 -5
- package/src/add-tags.js +103 -100
- package/src/book.mjs +643 -542
- package/src/book.test.mjs +660 -566
- package/src/config-init.js +9 -9
- package/src/config.js +22 -20
- package/src/draft.js +44 -42
- package/src/draft.test.mjs +32 -27
- package/src/extract-tags.js +184 -173
- package/src/extract-tags.test.mjs +56 -43
- package/src/pick-image.js +111 -97
- package/src/pick-image.test.mjs +57 -46
- package/src/publish.js +363 -317
- package/src/publish.test.mjs +242 -201
- package/src/vscode.js +68 -65
package/src/vscode.js
CHANGED
|
@@ -20,86 +20,89 @@ const { requireHugoSite, vscodeDir } = require('./config');
|
|
|
20
20
|
const { main: extractTags } = require('./extract-tags');
|
|
21
21
|
|
|
22
22
|
const TASKS = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
23
|
+
'version': '2.0.0',
|
|
24
|
+
'tasks': [
|
|
25
|
+
{
|
|
26
|
+
'label': 'Create Draft',
|
|
27
|
+
'type': 'shell',
|
|
28
|
+
'command': 'npx draft',
|
|
29
|
+
'problemMatcher': [],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
'label': 'Add Tags',
|
|
33
|
+
'type': 'shell',
|
|
34
|
+
'command': 'npx add-tags',
|
|
35
|
+
'problemMatcher': [],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
'label': 'Publish Draft (now)',
|
|
39
|
+
'type': 'shell',
|
|
40
|
+
'command': 'output=$(npx publish "${relativeFile}" now); echo "$output"; newFile=$(echo "$output" | grep -oE \'content/[^ ]+\\.md\'); [ -n "$newFile" ] && code -r "${workspaceFolder}/$newFile"',
|
|
41
|
+
'problemMatcher': [],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
'label': 'Publish Draft (later)',
|
|
45
|
+
'type': 'shell',
|
|
46
|
+
'command': 'read -p "Publish date (YYYY-MM-DD): " d; output=$(npx publish "${relativeFile}" later "$d"); echo "$output"; newFile=$(echo "$output" | grep -oE \'content/[^ ]+\\.md\'); [ -n "$newFile" ] && code -r "${workspaceFolder}/$newFile"',
|
|
47
|
+
'problemMatcher': [],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
'label': 'Pick Image',
|
|
51
|
+
'type': 'shell',
|
|
52
|
+
'command': 'read -p \'Image path: \' img; npx pick-image "$img" "${relativeFile}"',
|
|
53
|
+
'problemMatcher': [],
|
|
54
|
+
'presentation': {
|
|
55
|
+
'focus': true,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const EXTENSIONS = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
recommendations: [
|
|
63
|
+
'chriswiegman.cw-markdown-word-count',
|
|
64
|
+
'streetsidesoftware.code-spell-checker',
|
|
65
|
+
],
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
const SETTINGS = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
'[markdown]': {
|
|
70
|
+
'editor.quickSuggestions': {
|
|
71
|
+
comments: false,
|
|
72
|
+
other: false,
|
|
73
|
+
strings: true,
|
|
74
|
+
},
|
|
75
|
+
'editor.snippetSuggestions': 'top',
|
|
76
|
+
'editor.suggest.showSnippets': true,
|
|
77
|
+
'editor.wordBasedSuggestions': 'off',
|
|
78
|
+
},
|
|
79
|
+
'workbench.editor.closeOnFileDelete': true,
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
function writeIfAbsent(filePath, content) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
const rel = path.relative(process.cwd(), filePath);
|
|
84
|
+
|
|
85
|
+
if (fs.existsSync(filePath)) {
|
|
86
|
+
console.log(` skipped ${rel} (already exists)`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
91
|
+
console.log(` created ${rel}`);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
function main() {
|
|
93
|
-
|
|
95
|
+
requireHugoSite();
|
|
96
|
+
|
|
97
|
+
const dir = path.join(process.cwd(), vscodeDir);
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
99
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
writeIfAbsent(path.join(dir, 'tasks.json'), JSON.stringify(TASKS, null, 2) + '\n');
|
|
102
|
+
writeIfAbsent(path.join(dir, 'extensions.json'), JSON.stringify(EXTENSIONS, null, 2) + '\n');
|
|
103
|
+
writeIfAbsent(path.join(dir, 'settings.json'), JSON.stringify(SETTINGS, null, 2) + '\n');
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
extractTags();
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
main();
|