md-hopper 1.0.0-alpha.6 → 1.0.0-alpha.7
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, existsSync, writeFileSync } from 'fs';
|
|
2
2
|
import { parse, join } from 'path';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
|
-
import
|
|
4
|
+
import { TablePlugin } from 'inquirer-plugins/table';
|
|
5
5
|
import { v4 as uuid } from 'uuid';
|
|
6
6
|
import { GENERATE_TYPES } from '../../../../_internal/types/configs/generate.js';
|
|
7
7
|
import { success, warn, hop, cyan, bold } from '../../../../_internal/utils/chalk.js';
|
|
@@ -11,32 +11,31 @@ import { getExclude, getInclude } from '../../../../_internal/utils/minimatch.js
|
|
|
11
11
|
import { isDirectory as isDirectoryPath, getExecDir } from '../../../../_internal/utils/path.js';
|
|
12
12
|
const PARAMS = ['id', 'title', 'output', 'lock'];
|
|
13
13
|
const getAnswers = (details) => {
|
|
14
|
-
inquirer.registerPrompt('table
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
selectedColor: warn,
|
|
26
|
-
editableColor: success,
|
|
27
|
-
editingColor: hop,
|
|
28
|
-
columns: [
|
|
29
|
-
{ name: cyan.bold('filepath'), value: 'path' },
|
|
30
|
-
{ name: cyan.bold('id'), value: 'id', editable: 'text' },
|
|
31
|
-
{ name: cyan.bold('title'), value: 'title', editable: 'text' },
|
|
32
|
-
{ name: cyan.bold('output'), value: 'output', editable: 'text' },
|
|
33
|
-
{ name: cyan.bold('lock'), value: 'lock', editable: 'text' },
|
|
34
|
-
],
|
|
35
|
-
rows: details.map(({ path, id, title, output, lock }) => {
|
|
36
|
-
return [bold(path), id, title, output, lock];
|
|
37
|
-
}),
|
|
38
|
-
validate: () => false,
|
|
14
|
+
inquirer.registerPrompt('table', TablePlugin);
|
|
15
|
+
const question = {
|
|
16
|
+
type: 'table',
|
|
17
|
+
name: 'links',
|
|
18
|
+
message: 'GENERATE LINKS PATH SETTINGS',
|
|
19
|
+
description: `Edit setting.`,
|
|
20
|
+
disableColumnIndexes: [0],
|
|
21
|
+
colors: {
|
|
22
|
+
selected: warn,
|
|
23
|
+
editable: success,
|
|
24
|
+
editing: hop,
|
|
39
25
|
},
|
|
26
|
+
columns: [
|
|
27
|
+
{ name: cyan.bold('filepath'), value: 'path', type: 'input' },
|
|
28
|
+
{ name: cyan.bold('id'), value: 'id', type: 'input' },
|
|
29
|
+
{ name: cyan.bold('title'), value: 'title', type: 'input' },
|
|
30
|
+
{ name: cyan.bold('output'), value: 'output', type: 'input' },
|
|
31
|
+
{ name: cyan.bold('lock'), value: 'lock', type: 'confirm' },
|
|
32
|
+
],
|
|
33
|
+
rows: details.map(({ path, id, title, output, lock }) => {
|
|
34
|
+
return [bold(path), id, title, output, lock];
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
return inquirer.prompt([
|
|
38
|
+
question,
|
|
40
39
|
]);
|
|
41
40
|
};
|
|
42
41
|
const getQuestionParam = (settings, path, md, prefixExp) => {
|
|
@@ -55,7 +54,7 @@ const writeMd = (md, values) => {
|
|
|
55
54
|
for (const params of PARAMS) {
|
|
56
55
|
const PARAM = params.toUpperCase();
|
|
57
56
|
md = removeParam(md, PARAM);
|
|
58
|
-
const value =
|
|
57
|
+
const value = values[params];
|
|
59
58
|
if (value) {
|
|
60
59
|
comments.push(getParamsComment({ [PARAM]: `${value}` }));
|
|
61
60
|
}
|
|
@@ -116,6 +115,7 @@ const generateLinks = async (settings, fullPath) => {
|
|
|
116
115
|
questions.push(getQuestionParam(settings, path, md, prefixExp));
|
|
117
116
|
}
|
|
118
117
|
const { links } = await getAnswers(questions);
|
|
118
|
+
console.log(links);
|
|
119
119
|
for (const result of links.result) {
|
|
120
120
|
writeMd(readFileSync(result.path, 'utf-8'), result);
|
|
121
121
|
}
|
|
@@ -4,7 +4,6 @@ import { setCommands } from '../../_internal/utils/command.js';
|
|
|
4
4
|
import { isDirectory } from '../../_internal/utils/fs.js';
|
|
5
5
|
const __dirname = import.meta.dirname;
|
|
6
6
|
const initCommand = async (filename, program) => {
|
|
7
|
-
console.log('initCommand', filename);
|
|
8
7
|
const { COMMANDS, init, getSettings } = await import(`./${filename}/command.js`);
|
|
9
8
|
setCommands(program, COMMANDS, init, getSettings);
|
|
10
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "md-hopper",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"chalk": "^5.3.0",
|
|
69
69
|
"commander": "^12.1.0",
|
|
70
70
|
"inquirer": "^9.2.23",
|
|
71
|
-
"inquirer-
|
|
71
|
+
"inquirer-plugins": "^1.0.0-alpha.2",
|
|
72
72
|
"marked": "^12.0.2",
|
|
73
73
|
"minimatch": "^9.0.4",
|
|
74
74
|
"my-gadgetry": "^1.2.5",
|