md-hopper 1.0.0-alpha.5 → 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.
package/README.md CHANGED
@@ -2,16 +2,30 @@
2
2
 
3
3
  # MD HOPPER
4
4
 
5
- This Package Link md files in same repository.
5
+ md-hopper is a tool that recursively processes README.md files, starting from a specified README.md file and adding links to other README.md files nested within its directories to the parent README.md file.
6
+ This helps consolidate dispersed README files into a single, easily manageable document.
6
7
 
7
- # Commands
8
+ ## Installation
9
+
10
+ ```bash
11
+ $ npm i -g md-hopper
12
+ ```
13
+
14
+ or
15
+
16
+ ```bash
17
+ $ npm i md-hopper
18
+ ```
19
+
20
+ ## Commands
8
21
 
9
22
  <!-- MD_HOPPER: LINK_NEXT_LINE:
10
23
  id: link-command
11
24
  inline: true
12
25
  -->
13
26
 
14
- - [generate][md_hopper:link-command]
27
+ ### [LINK][md_hopper:link-command]
28
+
15
29
  <!-- MD_HOPPER: BEFORE_GENERATE_LINK (6/4/2024, 10:23:14 AM): - [generate][md_hopper:generate-command] -->
16
30
 
17
31
  <!-- MD_HOPPER: BEGIN_DEFINE_LINKS: -->
@@ -7,7 +7,7 @@ export declare class CommandClass<CommandOptions extends Record<string, any>, Md
7
7
  private args;
8
8
  private getSettingFnc;
9
9
  constructor(program: Program, getSettingFnc: SettingsFnc<CommandOptions, MdSettings>);
10
- init(options: CommandOptions, settings: MdSettings): Promise<this>;
10
+ init(options: CommandOptions, settings: MdSettings): this;
11
11
  command(command: string): this;
12
12
  help(helpTxt: string): this;
13
13
  before(before: Action, ...args: any[]): this;
@@ -7,7 +7,7 @@ export class CommandClass {
7
7
  this.program = program;
8
8
  this.getSettingFnc = getSettingFnc;
9
9
  }
10
- async init(options, settings) {
10
+ init(options, settings) {
11
11
  this.args = {
12
12
  options,
13
13
  settings,
@@ -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,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-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
  },
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 = getValue(params, values[params]);
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
  }
@@ -1,10 +1,18 @@
1
+ import { readdirSync } from 'fs';
2
+ import { join } from 'path';
1
3
  import { setCommands } from '../../_internal/utils/command.js';
4
+ import { isDirectory } from '../../_internal/utils/fs.js';
5
+ const __dirname = import.meta.dirname;
2
6
  const initCommand = async (filename, program) => {
3
7
  const { COMMANDS, init, getSettings } = await import(`./${filename}/command.js`);
4
8
  setCommands(program, COMMANDS, init, getSettings);
5
9
  };
6
10
  export const init = async (program) => {
7
- await initCommand('generate', program);
8
- await initCommand('help', program);
9
- await initCommand('link', program);
11
+ const list = readdirSync(join(__dirname));
12
+ for (const dir of list) {
13
+ if (!isDirectory(join(__dirname, dir))) {
14
+ continue;
15
+ }
16
+ await initCommand(dir, program);
17
+ }
10
18
  };
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.5",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -60,7 +60,7 @@
60
60
  "engines": {
61
61
  "node": ">=19.0.0"
62
62
  },
63
- "license": "ISC",
63
+ "license": "MIT",
64
64
  "dependencies": {
65
65
  "@actions/core": "^1.10.1",
66
66
  "@actions/exec": "^1.1.1",
@@ -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.2",
72
72
  "marked": "^12.0.2",
73
73
  "minimatch": "^9.0.4",
74
74
  "my-gadgetry": "^1.2.5",