md-hopper 1.0.0-alpha.6 → 1.0.0-alpha.8

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 tablePlugin from 'inquirer-table-input';
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,33 +11,30 @@ 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-input', tablePlugin);
15
- return inquirer.prompt([
16
- {
17
- type: 'table-input',
18
- name: 'links',
19
- message: 'GENERATE LINKS PATH SETTINGS',
20
- infoMessage: `Edit setting.`,
21
- hideInfoWhenKeyPressed: false,
22
- freezeColumns: 1,
23
- decimalPoint: '.',
24
- decimalPlaces: 2,
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
  },
40
- ]);
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([question]);
41
38
  };
42
39
  const getQuestionParam = (settings, path, md, prefixExp) => {
43
40
  const detail = getLinkedMdDetail(md);
@@ -55,7 +52,7 @@ const writeMd = (md, values) => {
55
52
  for (const params of PARAMS) {
56
53
  const PARAM = params.toUpperCase();
57
54
  md = removeParam(md, PARAM);
58
- const value = getValue(params, values[params]);
55
+ const value = values[params];
59
56
  if (value) {
60
57
  comments.push(getParamsComment({ [PARAM]: `${value}` }));
61
58
  }
@@ -94,14 +91,6 @@ const getGenerateId = (id, settings, path, prefixExp) => {
94
91
  return id;
95
92
  }
96
93
  };
97
- const getValue = (key, value) => {
98
- switch (key) {
99
- case 'lock':
100
- return value === 'true';
101
- default:
102
- return value;
103
- }
104
- };
105
94
  const generateLinks = async (settings, fullPath) => {
106
95
  const { depth } = settings;
107
96
  const execDir = getExecDir();
@@ -116,6 +105,7 @@ const generateLinks = async (settings, fullPath) => {
116
105
  questions.push(getQuestionParam(settings, path, md, prefixExp));
117
106
  }
118
107
  const { links } = await getAnswers(questions);
108
+ console.log(links);
119
109
  for (const result of links.result) {
120
110
  writeMd(readFileSync(result.path, 'utf-8'), result);
121
111
  }
@@ -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/dist/cli/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-hopper",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.8",
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-table-input": "^0.0.3",
71
+ "inquirer-plugins": "^1.0.0-alpha.3",
72
72
  "marked": "^12.0.2",
73
73
  "minimatch": "^9.0.4",
74
74
  "my-gadgetry": "^1.2.5",