md-hopper 1.0.0-alpha.9 → 1.0.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/README.md +1 -1
- package/dist/{_internal → lib/_internal}/types/command.d.ts +1 -0
- package/dist/lib/_internal/types/command.d.ts.map +1 -0
- package/dist/lib/_internal/types/configs/__generate.d.ts +42 -0
- package/dist/lib/_internal/types/configs/__generate.d.ts.map +1 -0
- package/dist/lib/_internal/types/configs/__generate.js +155 -0
- package/dist/lib/_internal/types/configs/_generate.d.ts +40 -0
- package/dist/lib/_internal/types/configs/_generate.d.ts.map +1 -0
- package/dist/lib/_internal/types/configs/_generate.js +176 -0
- package/dist/{_internal → lib/_internal}/types/configs/generate.d.ts +3 -7
- package/dist/lib/_internal/types/configs/generate.d.ts.map +1 -0
- package/dist/lib/_internal/types/configs/generate.js +153 -0
- package/dist/{_internal → lib/_internal}/types/configs/help.d.ts +1 -0
- package/dist/lib/_internal/types/configs/help.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/types/configs/links.d.ts +1 -0
- package/dist/lib/_internal/types/configs/links.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/types/configs.d.ts +1 -0
- package/dist/lib/_internal/types/configs.d.ts.map +1 -0
- package/dist/lib/_internal/types/inquirer.d.ts +20 -0
- package/dist/lib/_internal/types/inquirer.d.ts.map +1 -0
- package/dist/lib/_internal/types/inquirer.js +1 -0
- package/dist/{_internal → lib/_internal}/types/md.d.ts +1 -0
- package/dist/lib/_internal/types/md.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/types/process.d.ts +1 -0
- package/dist/lib/_internal/types/process.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/chalk.d.ts +1 -0
- package/dist/lib/_internal/utils/chalk.d.ts.map +1 -0
- package/dist/lib/_internal/utils/command.d.ts +76 -0
- package/dist/lib/_internal/utils/command.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/command.js +52 -0
- package/dist/{_internal → lib/_internal}/utils/configs.d.ts +1 -0
- package/dist/lib/_internal/utils/configs.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/fs.d.ts +2 -1
- package/dist/lib/_internal/utils/fs.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/link.d.ts +1 -0
- package/dist/lib/_internal/utils/link.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/link.js +1 -0
- package/dist/{_internal → lib/_internal}/utils/log.d.ts +1 -0
- package/dist/lib/_internal/utils/log.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/md/lexer.d.ts +1 -0
- package/dist/lib/_internal/utils/md/lexer.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/md/line.d.ts +1 -0
- package/dist/lib/_internal/utils/md/line.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/md.d.ts +1 -0
- package/dist/lib/_internal/utils/md.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/minimatch.d.ts +1 -0
- package/dist/lib/_internal/utils/minimatch.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/path-match.d.ts +1 -0
- package/dist/lib/_internal/utils/path-match.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/path.d.ts +13 -1
- package/dist/lib/_internal/utils/path.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/path.js +29 -3
- package/dist/{_internal → lib/_internal}/utils/process.d.ts +1 -0
- package/dist/lib/_internal/utils/process.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/utils/process.js +5 -1
- package/dist/{_internal → lib/_internal}/utils/type-check.d.ts +1 -0
- package/dist/lib/_internal/utils/type-check.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/generate/action.d.ts +1 -0
- package/dist/lib/cli/commands/generate/action.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/generate/actions/link.d.ts +1 -0
- package/dist/lib/cli/commands/generate/actions/link.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/generate/actions/link.js +14 -16
- package/dist/{cli → lib/cli}/commands/generate/actions/rc.d.ts +1 -0
- package/dist/lib/cli/commands/generate/actions/rc.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/generate/command.d.ts +1 -0
- package/dist/lib/cli/commands/generate/command.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/generate/command.js +15 -24
- package/dist/{cli → lib/cli}/commands/help/action.d.ts +1 -0
- package/dist/lib/cli/commands/help/action.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/help/action.js +1 -0
- package/dist/{cli → lib/cli}/commands/help/command.d.ts +1 -0
- package/dist/lib/cli/commands/help/command.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/help/command.js +1 -1
- package/dist/{cli → lib/cli}/commands/index.d.ts +1 -0
- package/dist/lib/cli/commands/index.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/index.js +2 -1
- package/dist/{cli → lib/cli}/commands/link/action.d.ts +1 -0
- package/dist/lib/cli/commands/link/action.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/commands/link/command.d.ts +1 -0
- package/dist/lib/cli/commands/link/command.d.ts.map +1 -0
- package/dist/lib/cli/commands/link/command.js +22 -0
- package/dist/lib/cli/index.d.ts +3 -0
- package/dist/lib/cli/index.d.ts.map +1 -0
- package/dist/{cli → lib/cli}/index.js +2 -0
- package/dist/package.json +50 -0
- package/package.json +31 -92
- package/cli/commands/generate/action/package.json +0 -6
- package/cli/commands/generate/actions/link/package.json +0 -6
- package/cli/commands/generate/actions/rc/package.json +0 -6
- package/cli/commands/generate/command/package.json +0 -6
- package/cli/commands/help/action/package.json +0 -6
- package/cli/commands/help/command/package.json +0 -6
- package/cli/commands/index/package.json +0 -6
- package/cli/commands/link/README.md/package.json +0 -6
- package/cli/commands/link/action/package.json +0 -6
- package/cli/commands/link/command/package.json +0 -6
- package/cli/index/package.json +0 -6
- package/dist/_internal/types/configs/generate.js +0 -131
- package/dist/_internal/utils/command.d.ts +0 -20
- package/dist/cli/commands/link/command.js +0 -21
- package/dist/cli/index.d.ts +0 -2
- /package/dist/{_internal → lib/_internal}/types/command.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/configs/help.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/configs/links.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/configs.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/md.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/process.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/chalk.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/configs.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/fs.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/log.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/md/lexer.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/md/line.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/md.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/minimatch.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/path-match.js +0 -0
- /package/dist/{_internal → lib/_internal}/utils/type-check.js +0 -0
- /package/dist/{cli → lib/cli}/commands/generate/action.js +0 -0
- /package/dist/{cli → lib/cli}/commands/generate/actions/rc.js +0 -0
- /package/dist/{cli → lib/cli}/commands/link/action.js +0 -0
package/README.md
CHANGED
|
@@ -30,6 +30,6 @@ inline: true
|
|
|
30
30
|
|
|
31
31
|
<!-- MD_HOPPER: BEGIN_DEFINE_LINKS: -->
|
|
32
32
|
|
|
33
|
-
[md_hopper:link-command]: ./src/cli/commands/link/README.md 'LINK COMMAND'
|
|
33
|
+
[md_hopper:link-command]: ./src/lib/cli/commands/link/README.md 'LINK COMMAND'
|
|
34
34
|
|
|
35
35
|
<!-- MD_HOPPER: END_DEFINE_LINKS: -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/types/command.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;AAE5C,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IAEV,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,MAAM,WAAW,SAAS,CAAC,cAAc,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3G,OAAO,EAAE,cAAc,CAAA;IACvB,QAAQ,EAAE,UAAU,CAAA;CACrB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Answers } from '../inquirer.js';
|
|
2
|
+
export declare const TYPES: {
|
|
3
|
+
readonly rc: "rc";
|
|
4
|
+
readonly link: "link";
|
|
5
|
+
};
|
|
6
|
+
export type Type = (typeof TYPES)[keyof typeof TYPES];
|
|
7
|
+
export interface CommandOptions {
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
type?: Type;
|
|
10
|
+
include?: string;
|
|
11
|
+
exclude?: string;
|
|
12
|
+
filenames?: string;
|
|
13
|
+
input?: string;
|
|
14
|
+
output?: string;
|
|
15
|
+
idGen?: GenerateType;
|
|
16
|
+
depth?: number;
|
|
17
|
+
id?: string;
|
|
18
|
+
lock?: boolean;
|
|
19
|
+
skipHidden?: boolean;
|
|
20
|
+
title?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface MdSettings {
|
|
23
|
+
include: string[];
|
|
24
|
+
exclude: string[];
|
|
25
|
+
filenames: string[];
|
|
26
|
+
skipHidden: boolean;
|
|
27
|
+
input: string;
|
|
28
|
+
output: string;
|
|
29
|
+
idGen: GenerateType;
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
lock: boolean;
|
|
33
|
+
depth: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const GENERATE_TYPES: Readonly<{
|
|
36
|
+
readonly path: "path";
|
|
37
|
+
readonly random: "random";
|
|
38
|
+
readonly manual: "manual";
|
|
39
|
+
}>;
|
|
40
|
+
export type GenerateType = (typeof GENERATE_TYPES)[keyof typeof GENERATE_TYPES];
|
|
41
|
+
export declare const QUESTIONS: (options: CommandOptions) => Record<string, Promise<Answers>>;
|
|
42
|
+
//# sourceMappingURL=__generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__generate.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/types/configs/__generate.ts"],"names":[],"mappings":"AACA,OAAO,EAA6D,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAQvG,eAAO,MAAM,KAAK;;;CAGR,CAAA;AAEV,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAErD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,YAAY,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAyFD,eAAO,MAAM,cAAc;;;;EAIhB,CAAA;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA;AA4E/E,eAAO,MAAM,SAAS,YAAa,cAAc,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAGjF,CAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { input, confirm, number, select } from '@inquirer/prompts';
|
|
2
|
+
import { isNumber } from 'my-gadgetry/type-check';
|
|
3
|
+
/* eslint-disable import/no-restricted-paths */
|
|
4
|
+
import { DEFAULT_MD_FILENAME } from '../../utils/configs.js';
|
|
5
|
+
import { isDirectory } from '../../utils/path.js';
|
|
6
|
+
/* eslint-enable import/no-restricted-paths */
|
|
7
|
+
export const TYPES = {
|
|
8
|
+
rc: 'rc',
|
|
9
|
+
link: 'link',
|
|
10
|
+
};
|
|
11
|
+
const INPUT_QUESTION_PARAMS = {
|
|
12
|
+
message: 'Please put path from current dir with filename? ex: "./{path}/{filename}.md"',
|
|
13
|
+
};
|
|
14
|
+
const INPUT_QUESTION = {
|
|
15
|
+
name: 'input',
|
|
16
|
+
question: input(INPUT_QUESTION_PARAMS)
|
|
17
|
+
};
|
|
18
|
+
const SKIP_HIDDEN_QUESTION = {
|
|
19
|
+
name: 'skipHidden',
|
|
20
|
+
question: confirm({
|
|
21
|
+
message: 'skip search hidden file? default Yes.',
|
|
22
|
+
default: true,
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
const INCLUDE_QUESTION = {
|
|
26
|
+
name: 'include',
|
|
27
|
+
question: input({
|
|
28
|
+
message: 'include pattern minimatch list with comma. ex: xxx,xxx',
|
|
29
|
+
default: '',
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
const EXCLUDE_QUESTION = {
|
|
33
|
+
name: 'exclude',
|
|
34
|
+
question: input({
|
|
35
|
+
message: 'exclude pattern minimatch list with comma. ex: xxx,xxx',
|
|
36
|
+
default: '',
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
const FILENAMES_QUESTION = {
|
|
40
|
+
name: 'filenames',
|
|
41
|
+
question: input({
|
|
42
|
+
message: 'search filenames with comma. (default: README.md) ex: README.md,CHANGELOG.md',
|
|
43
|
+
default: DEFAULT_MD_FILENAME,
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
const OUTPUT_QUESTION = {
|
|
47
|
+
name: 'output',
|
|
48
|
+
question: input({
|
|
49
|
+
message: 'output filename. (default: same name as read, means update file) ex: README_GENERATE.md',
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
const DEPTH_QUESTION = {
|
|
53
|
+
name: 'depth',
|
|
54
|
+
question: number({
|
|
55
|
+
message: 'search depth number. more than 0. (if all put 0)',
|
|
56
|
+
validate: input => {
|
|
57
|
+
return isNumber(input, true) && input >= 0;
|
|
58
|
+
},
|
|
59
|
+
default: 0,
|
|
60
|
+
}),
|
|
61
|
+
filter: input => {
|
|
62
|
+
return input >= 0 ? Number(input) : '';
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const DIR_QUESTIONS = [SKIP_HIDDEN_QUESTION, INCLUDE_QUESTION, EXCLUDE_QUESTION, FILENAMES_QUESTION, DEPTH_QUESTION];
|
|
66
|
+
const RC_QUESTIONS = async (_options) => {
|
|
67
|
+
const answers = {
|
|
68
|
+
[INPUT_QUESTION.name]: await input({
|
|
69
|
+
...INPUT_QUESTION_PARAMS,
|
|
70
|
+
validate: input => {
|
|
71
|
+
return !!input;
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
await setQuestions([
|
|
76
|
+
SKIP_HIDDEN_QUESTION,
|
|
77
|
+
INCLUDE_QUESTION,
|
|
78
|
+
EXCLUDE_QUESTION,
|
|
79
|
+
FILENAMES_QUESTION,
|
|
80
|
+
OUTPUT_QUESTION,
|
|
81
|
+
DEPTH_QUESTION,
|
|
82
|
+
], answers);
|
|
83
|
+
return answers;
|
|
84
|
+
};
|
|
85
|
+
export const GENERATE_TYPES = Object.freeze({
|
|
86
|
+
path: 'path',
|
|
87
|
+
random: 'random',
|
|
88
|
+
manual: 'manual',
|
|
89
|
+
});
|
|
90
|
+
const GENERATE_TYPE_CHOICES = Object.freeze([
|
|
91
|
+
{ name: 'auto generate with directory path', short: 'dir path', value: GENERATE_TYPES.path },
|
|
92
|
+
{ name: 'auto generate with uuid', short: 'random', value: GENERATE_TYPES.random },
|
|
93
|
+
{ name: 'generate yourself', short: 'manually', value: GENERATE_TYPES.manual },
|
|
94
|
+
]);
|
|
95
|
+
const setDirQuestions = async (inputPath, options, answers) => {
|
|
96
|
+
if (isInputPathDirectory(inputPath, options)) {
|
|
97
|
+
await setQuestions(DIR_QUESTIONS, answers);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const setFileQuestions = async (inputPath, options, answers) => {
|
|
101
|
+
if (!isInputPathDirectory(inputPath, options)) {
|
|
102
|
+
await setQuestions(FILE_QUESTIONS, answers);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const FILE_QUESTIONS = [
|
|
106
|
+
{
|
|
107
|
+
name: 'title',
|
|
108
|
+
question: input({ message: 'title name. (default: auto detect title)', })
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'lock',
|
|
112
|
+
question: confirm({ message: 'is locked? if true not link this file. (default: false)', default: false })
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
const isInputPathDirectory = (path, options) => isDirectory(path || options.input || '');
|
|
116
|
+
const getIdGenQuestions = (path, options) => {
|
|
117
|
+
if (isInputPathDirectory(path, options)) {
|
|
118
|
+
return GENERATE_TYPE_CHOICES.filter(({ value }) => [GENERATE_TYPES.path, GENERATE_TYPES.random].includes(value));
|
|
119
|
+
}
|
|
120
|
+
return GENERATE_TYPE_CHOICES;
|
|
121
|
+
};
|
|
122
|
+
const setQuestions = async (questions, answers) => {
|
|
123
|
+
for (const question of questions) {
|
|
124
|
+
answers[question.name] = await question.question;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const LINK_QUESTIONS = async (options) => {
|
|
128
|
+
const inputPath = await input({
|
|
129
|
+
message: 'Please put path from current dir with filename? (default: ".") ex: "./{path}/{filename}.md"',
|
|
130
|
+
default: '.',
|
|
131
|
+
});
|
|
132
|
+
const answers = {
|
|
133
|
+
[INPUT_QUESTION.name]: inputPath
|
|
134
|
+
};
|
|
135
|
+
answers['idGen'] = await select({
|
|
136
|
+
message: `Choose generate type (default: ${GENERATE_TYPE_CHOICES[0].short})`,
|
|
137
|
+
default: 0,
|
|
138
|
+
choices: getIdGenQuestions(inputPath, options)
|
|
139
|
+
});
|
|
140
|
+
if (answers.idGen === GENERATE_TYPES.manual) {
|
|
141
|
+
answers['id'] = await input({
|
|
142
|
+
message: 'type id',
|
|
143
|
+
validate: input => {
|
|
144
|
+
return !!input;
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
await setDirQuestions(inputPath, options, answers);
|
|
149
|
+
await setFileQuestions(inputPath, options, answers);
|
|
150
|
+
return answers;
|
|
151
|
+
};
|
|
152
|
+
export const QUESTIONS = (options) => ({
|
|
153
|
+
[TYPES.rc]: RC_QUESTIONS(options),
|
|
154
|
+
[TYPES.link]: LINK_QUESTIONS(options),
|
|
155
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const TYPES: {
|
|
2
|
+
readonly rc: "rc";
|
|
3
|
+
readonly link: "link";
|
|
4
|
+
};
|
|
5
|
+
export type Type = (typeof TYPES)[keyof typeof TYPES];
|
|
6
|
+
export interface CommandOptions {
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
type?: Type;
|
|
9
|
+
include?: string;
|
|
10
|
+
exclude?: string;
|
|
11
|
+
filenames?: string;
|
|
12
|
+
input?: string;
|
|
13
|
+
output?: string;
|
|
14
|
+
idGen?: GenerateType;
|
|
15
|
+
depth?: number;
|
|
16
|
+
id?: string;
|
|
17
|
+
lock?: boolean;
|
|
18
|
+
skipHidden?: boolean;
|
|
19
|
+
title?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MdSettings {
|
|
22
|
+
include: string[];
|
|
23
|
+
exclude: string[];
|
|
24
|
+
filenames: string[];
|
|
25
|
+
skipHidden: boolean;
|
|
26
|
+
input: string;
|
|
27
|
+
output: string;
|
|
28
|
+
idGen: GenerateType;
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
lock: boolean;
|
|
32
|
+
depth: number;
|
|
33
|
+
}
|
|
34
|
+
export declare const GENERATE_TYPES: Readonly<{
|
|
35
|
+
readonly path: "path";
|
|
36
|
+
readonly random: "random";
|
|
37
|
+
readonly manual: "manual";
|
|
38
|
+
}>;
|
|
39
|
+
export type GenerateType = (typeof GENERATE_TYPES)[keyof typeof GENERATE_TYPES];
|
|
40
|
+
//# sourceMappingURL=_generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_generate.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/types/configs/_generate.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,KAAK;;;CAGR,CAAA;AAEV,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAErD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,YAAY,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAyFD,eAAO,MAAM,cAAc;;;;EAIhB,CAAA;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// import { input, confirm , number, select } from '@inquirer/prompts'
|
|
2
|
+
// import { InputQuestion, ConfirmQuestion, NumberQuestion, Questions, Answers } from '../inquirer.js'
|
|
3
|
+
// import { isNumber } from 'my-gadgetry/type-check'
|
|
4
|
+
/* eslint-disable import/no-restricted-paths */
|
|
5
|
+
// import { DEFAULT_MD_FILENAME } from '../../utils/configs.js'
|
|
6
|
+
// import { isDirectory } from '../../utils/path.js'
|
|
7
|
+
/* eslint-enable import/no-restricted-paths */
|
|
8
|
+
export const TYPES = {
|
|
9
|
+
rc: 'rc',
|
|
10
|
+
link: 'link',
|
|
11
|
+
};
|
|
12
|
+
// const INPUT_QUESTION_PARAMS = {
|
|
13
|
+
// message: 'Please put path from current dir with filename? ex: "./{path}/{filename}.md"',
|
|
14
|
+
// }
|
|
15
|
+
// const INPUT_QUESTION: InputQuestion = {
|
|
16
|
+
// name: 'input',
|
|
17
|
+
// question: input(INPUT_QUESTION_PARAMS)
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// const SKIP_HIDDEN_QUESTION: ConfirmQuestion = {
|
|
21
|
+
// name: 'skipHidden',
|
|
22
|
+
// question: confirm({
|
|
23
|
+
// message: 'skip search hidden file? default Yes.',
|
|
24
|
+
// default: true,
|
|
25
|
+
// })
|
|
26
|
+
// }
|
|
27
|
+
//
|
|
28
|
+
// const INCLUDE_QUESTION: InputQuestion = {
|
|
29
|
+
// name: 'include',
|
|
30
|
+
// question: input({
|
|
31
|
+
// message: 'include pattern minimatch list with comma. ex: xxx,xxx',
|
|
32
|
+
// default: '',
|
|
33
|
+
// })
|
|
34
|
+
// }
|
|
35
|
+
//
|
|
36
|
+
// const EXCLUDE_QUESTION: InputQuestion = {
|
|
37
|
+
// name: 'exclude',
|
|
38
|
+
// question: input({
|
|
39
|
+
// message: 'exclude pattern minimatch list with comma. ex: xxx,xxx',
|
|
40
|
+
// default: '',
|
|
41
|
+
// })
|
|
42
|
+
// }
|
|
43
|
+
//
|
|
44
|
+
// const FILENAMES_QUESTION: InputQuestion = {
|
|
45
|
+
// name: 'filenames',
|
|
46
|
+
// question: input({
|
|
47
|
+
// message: 'search filenames with comma. (default: README.md) ex: README.md,CHANGELOG.md',
|
|
48
|
+
// default: DEFAULT_MD_FILENAME,
|
|
49
|
+
// })
|
|
50
|
+
// }
|
|
51
|
+
//
|
|
52
|
+
// const OUTPUT_QUESTION: InputQuestion = {
|
|
53
|
+
// name: 'output',
|
|
54
|
+
// question: input({
|
|
55
|
+
// message: 'output filename. (default: same name as read, means update file) ex: README_GENERATE.md',
|
|
56
|
+
// })
|
|
57
|
+
// }
|
|
58
|
+
//
|
|
59
|
+
// const DEPTH_QUESTION: NumberQuestion = {
|
|
60
|
+
// name: 'depth',
|
|
61
|
+
// question: number({
|
|
62
|
+
// message: 'search depth number. more than 0. (if all put 0)',
|
|
63
|
+
// validate: input => {
|
|
64
|
+
// return isNumber(input, true) && (input as number) >= 0
|
|
65
|
+
// },
|
|
66
|
+
// default: 0,
|
|
67
|
+
// }),
|
|
68
|
+
// filter: input => {
|
|
69
|
+
// return input >= 0 ? Number(input) : ''
|
|
70
|
+
// },
|
|
71
|
+
// }
|
|
72
|
+
// const DIR_QUESTIONS = [SKIP_HIDDEN_QUESTION, INCLUDE_QUESTION, EXCLUDE_QUESTION, FILENAMES_QUESTION, DEPTH_QUESTION]
|
|
73
|
+
//
|
|
74
|
+
// const RC_QUESTIONS = async (_options: CommandOptions): Promise<Answers> => {
|
|
75
|
+
// const answers: Answers = {
|
|
76
|
+
// [INPUT_QUESTION.name]: await input({
|
|
77
|
+
// ...INPUT_QUESTION_PARAMS,
|
|
78
|
+
// validate: input => {
|
|
79
|
+
// return !!input
|
|
80
|
+
// }
|
|
81
|
+
// })
|
|
82
|
+
// }
|
|
83
|
+
// await setQuestions(
|
|
84
|
+
// [
|
|
85
|
+
// SKIP_HIDDEN_QUESTION,
|
|
86
|
+
// INCLUDE_QUESTION,
|
|
87
|
+
// EXCLUDE_QUESTION,
|
|
88
|
+
// FILENAMES_QUESTION,
|
|
89
|
+
// OUTPUT_QUESTION,
|
|
90
|
+
// DEPTH_QUESTION,
|
|
91
|
+
// ],
|
|
92
|
+
// answers
|
|
93
|
+
// )
|
|
94
|
+
// return answers
|
|
95
|
+
// }
|
|
96
|
+
export const GENERATE_TYPES = Object.freeze({
|
|
97
|
+
path: 'path',
|
|
98
|
+
random: 'random',
|
|
99
|
+
manual: 'manual',
|
|
100
|
+
});
|
|
101
|
+
// const GENERATE_TYPE_CHOICES = Object.freeze([
|
|
102
|
+
// { name: 'auto generate with directory path', short: 'dir path', value: GENERATE_TYPES.path },
|
|
103
|
+
// { name: 'auto generate with uuid', short: 'random', value: GENERATE_TYPES.random },
|
|
104
|
+
// { name: 'generate yourself', short: 'manually', value: GENERATE_TYPES.manual },
|
|
105
|
+
// ] as const)
|
|
106
|
+
//
|
|
107
|
+
// const setDirQuestions = async (inputPath: string, options: CommandOptions, answers: Answers) => {
|
|
108
|
+
// if (isInputPathDirectory(inputPath, options)) {
|
|
109
|
+
// await setQuestions(DIR_QUESTIONS, answers)
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
//
|
|
113
|
+
// const setFileQuestions = async (inputPath: string, options: CommandOptions, answers: Answers) => {
|
|
114
|
+
// if (!isInputPathDirectory(inputPath, options)) {
|
|
115
|
+
// await setQuestions(FILE_QUESTIONS, answers)
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
//
|
|
119
|
+
// const FILE_QUESTIONS: Questions = [
|
|
120
|
+
// {
|
|
121
|
+
// name: 'title',
|
|
122
|
+
// question: input({ message: 'title name. (default: auto detect title)', })
|
|
123
|
+
// },
|
|
124
|
+
// {
|
|
125
|
+
// name: 'lock',
|
|
126
|
+
// question: confirm({ message: 'is locked? if true not link this file. (default: false)', default: false })
|
|
127
|
+
// }
|
|
128
|
+
// ]
|
|
129
|
+
//
|
|
130
|
+
//
|
|
131
|
+
// const isInputPathDirectory = (path: string, options: CommandOptions) => isDirectory(path || options.input || '')
|
|
132
|
+
//
|
|
133
|
+
// const getIdGenQuestions = (path: string, options: CommandOptions) => {
|
|
134
|
+
// if (isInputPathDirectory(path, options)) {
|
|
135
|
+
// return GENERATE_TYPE_CHOICES.filter(({ value }) =>
|
|
136
|
+
// ([GENERATE_TYPES.path, GENERATE_TYPES.random] as string[]).includes(value)
|
|
137
|
+
// )
|
|
138
|
+
// }
|
|
139
|
+
// return GENERATE_TYPE_CHOICES
|
|
140
|
+
// }
|
|
141
|
+
//
|
|
142
|
+
// const setQuestions = async (questions: Questions, answers: Answers) => {
|
|
143
|
+
// for (const question of questions) {
|
|
144
|
+
// answers[question.name] = await question.question
|
|
145
|
+
// }
|
|
146
|
+
// }
|
|
147
|
+
// const LINK_QUESTIONS = async (options: CommandOptions): Promise<Answers> => {
|
|
148
|
+
// const inputPath = await input({
|
|
149
|
+
// message: 'Please put path from current dir with filename? (default: ".") ex: "./{path}/{filename}.md"',
|
|
150
|
+
// default: '.',
|
|
151
|
+
// })
|
|
152
|
+
// const answers: Answers = {
|
|
153
|
+
// [INPUT_QUESTION.name]: inputPath
|
|
154
|
+
// }
|
|
155
|
+
//
|
|
156
|
+
// answers['idGen'] = await select({
|
|
157
|
+
// message: `Choose generate type (default: ${GENERATE_TYPE_CHOICES[0].short})`,
|
|
158
|
+
// default: 0,
|
|
159
|
+
// choices: getIdGenQuestions(inputPath, options)
|
|
160
|
+
// })
|
|
161
|
+
// if (answers.idGen === GENERATE_TYPES.manual) {
|
|
162
|
+
// answers['id'] = await input({
|
|
163
|
+
// message: 'type id',
|
|
164
|
+
// validate: input => {
|
|
165
|
+
// return !!input
|
|
166
|
+
// },
|
|
167
|
+
// })
|
|
168
|
+
// }
|
|
169
|
+
// await setDirQuestions(inputPath, options, answers)
|
|
170
|
+
// await setFileQuestions(inputPath, options, answers)
|
|
171
|
+
// return answers
|
|
172
|
+
// }
|
|
173
|
+
// export const QUESTIONS = (options: CommandOptions): Record<string, Promise<Answers>> => ({
|
|
174
|
+
// [TYPES.rc]: RC_QUESTIONS(options),
|
|
175
|
+
// [TYPES.link]: LINK_QUESTIONS(options),
|
|
176
|
+
// })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Answers } from '../inquirer.js';
|
|
2
2
|
export declare const TYPES: {
|
|
3
3
|
readonly rc: "rc";
|
|
4
4
|
readonly link: "link";
|
|
@@ -32,15 +32,11 @@ export interface MdSettings {
|
|
|
32
32
|
lock: boolean;
|
|
33
33
|
depth: number;
|
|
34
34
|
}
|
|
35
|
-
export declare const RC_QUESTIONS: (_options: CommandOptions) => ReadonlyArray<DistinctQuestion>;
|
|
36
35
|
export declare const GENERATE_TYPES: Readonly<{
|
|
37
36
|
readonly path: "path";
|
|
38
37
|
readonly random: "random";
|
|
39
38
|
readonly manual: "manual";
|
|
40
39
|
}>;
|
|
41
40
|
export type GenerateType = (typeof GENERATE_TYPES)[keyof typeof GENERATE_TYPES];
|
|
42
|
-
export declare const
|
|
43
|
-
|
|
44
|
-
rc: readonly DistinctQuestion[];
|
|
45
|
-
link: readonly DistinctQuestion[];
|
|
46
|
-
};
|
|
41
|
+
export declare const QUESTIONS: (options: CommandOptions) => Record<string, () => Promise<Answers>>;
|
|
42
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/types/configs/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAA6D,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAMvG,eAAO,MAAM,KAAK;;;CAGR,CAAA;AAEV,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAErD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,YAAY,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAyFD,eAAO,MAAM,cAAc;;;;EAIhB,CAAA;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA;AA4E/E,eAAO,MAAM,SAAS,YAAa,cAAc,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAGvF,CAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { input, confirm, number, select } from '@inquirer/prompts';
|
|
2
|
+
import { isNumber } from 'my-gadgetry/type-check';
|
|
3
|
+
import { DEFAULT_MD_FILENAME } from '../../utils/configs.js';
|
|
4
|
+
import { isDirectory } from '../../utils/path.js';
|
|
5
|
+
export const TYPES = {
|
|
6
|
+
rc: 'rc',
|
|
7
|
+
link: 'link',
|
|
8
|
+
};
|
|
9
|
+
const INPUT_QUESTION_PARAMS = {
|
|
10
|
+
message: 'Please put path from current dir with filename? ex: "./{path}/{filename}.md"',
|
|
11
|
+
};
|
|
12
|
+
const INPUT_QUESTION = {
|
|
13
|
+
name: 'input',
|
|
14
|
+
question: () => input(INPUT_QUESTION_PARAMS)
|
|
15
|
+
};
|
|
16
|
+
const SKIP_HIDDEN_QUESTION = {
|
|
17
|
+
name: 'skipHidden',
|
|
18
|
+
question: () => confirm({
|
|
19
|
+
message: 'skip search hidden file? default Yes.',
|
|
20
|
+
default: true,
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
const INCLUDE_QUESTION = {
|
|
24
|
+
name: 'include',
|
|
25
|
+
question: () => input({
|
|
26
|
+
message: 'include pattern minimatch list with comma. ex: xxx,xxx',
|
|
27
|
+
default: '',
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
const EXCLUDE_QUESTION = {
|
|
31
|
+
name: 'exclude',
|
|
32
|
+
question: () => input({
|
|
33
|
+
message: 'exclude pattern minimatch list with comma. ex: xxx,xxx',
|
|
34
|
+
default: '',
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
const FILENAMES_QUESTION = {
|
|
38
|
+
name: 'filenames',
|
|
39
|
+
question: () => input({
|
|
40
|
+
message: 'search filenames with comma. (default: README.md) ex: README.md,CHANGELOG.md',
|
|
41
|
+
default: DEFAULT_MD_FILENAME,
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
const OUTPUT_QUESTION = {
|
|
45
|
+
name: 'output',
|
|
46
|
+
question: () => input({
|
|
47
|
+
message: 'output filename. (default: same name as read, means update file) ex: README_GENERATE.md',
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
const DEPTH_QUESTION = {
|
|
51
|
+
name: 'depth',
|
|
52
|
+
question: () => number({
|
|
53
|
+
message: 'search depth number. more than 0. (if all put 0)',
|
|
54
|
+
validate: input => {
|
|
55
|
+
return isNumber(input, true) && input >= 0;
|
|
56
|
+
},
|
|
57
|
+
default: 0,
|
|
58
|
+
}),
|
|
59
|
+
filter: input => {
|
|
60
|
+
return input >= 0 ? Number(input) : '';
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const DIR_QUESTIONS = [SKIP_HIDDEN_QUESTION, INCLUDE_QUESTION, EXCLUDE_QUESTION, FILENAMES_QUESTION, DEPTH_QUESTION];
|
|
64
|
+
const RC_QUESTIONS = (_options) => async () => {
|
|
65
|
+
const answers = {
|
|
66
|
+
[INPUT_QUESTION.name]: await input({
|
|
67
|
+
...INPUT_QUESTION_PARAMS,
|
|
68
|
+
validate: input => {
|
|
69
|
+
return !!input;
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
await setQuestions([
|
|
74
|
+
SKIP_HIDDEN_QUESTION,
|
|
75
|
+
INCLUDE_QUESTION,
|
|
76
|
+
EXCLUDE_QUESTION,
|
|
77
|
+
FILENAMES_QUESTION,
|
|
78
|
+
OUTPUT_QUESTION,
|
|
79
|
+
DEPTH_QUESTION,
|
|
80
|
+
], answers);
|
|
81
|
+
return answers;
|
|
82
|
+
};
|
|
83
|
+
export const GENERATE_TYPES = Object.freeze({
|
|
84
|
+
path: 'path',
|
|
85
|
+
random: 'random',
|
|
86
|
+
manual: 'manual',
|
|
87
|
+
});
|
|
88
|
+
const GENERATE_TYPE_CHOICES = Object.freeze([
|
|
89
|
+
{ name: 'auto generate with directory path', short: 'dir path', value: GENERATE_TYPES.path },
|
|
90
|
+
{ name: 'auto generate with uuid', short: 'random', value: GENERATE_TYPES.random },
|
|
91
|
+
{ name: 'generate yourself', short: 'manually', value: GENERATE_TYPES.manual },
|
|
92
|
+
]);
|
|
93
|
+
const setDirQuestions = async (inputPath, options, answers) => {
|
|
94
|
+
if (isInputPathDirectory(inputPath, options)) {
|
|
95
|
+
await setQuestions(DIR_QUESTIONS, answers);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const setFileQuestions = async (inputPath, options, answers) => {
|
|
99
|
+
if (!isInputPathDirectory(inputPath, options)) {
|
|
100
|
+
await setQuestions(FILE_QUESTIONS, answers);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const FILE_QUESTIONS = [
|
|
104
|
+
{
|
|
105
|
+
name: 'title',
|
|
106
|
+
question: () => input({ message: 'title name. (default: auto detect title)', })
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'lock',
|
|
110
|
+
question: () => confirm({ message: 'is locked? if true not link this file. (default: false)', default: false })
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
const isInputPathDirectory = (path, options) => isDirectory(path || options.input || '');
|
|
114
|
+
const getIdGenQuestions = (path, options) => {
|
|
115
|
+
if (isInputPathDirectory(path, options)) {
|
|
116
|
+
return GENERATE_TYPE_CHOICES.filter(({ value }) => [GENERATE_TYPES.path, GENERATE_TYPES.random].includes(value));
|
|
117
|
+
}
|
|
118
|
+
return GENERATE_TYPE_CHOICES;
|
|
119
|
+
};
|
|
120
|
+
const setQuestions = async (questions, answers) => {
|
|
121
|
+
for (const { name, question } of questions) {
|
|
122
|
+
answers[name] = await question();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const LINK_QUESTIONS = (options) => async () => {
|
|
126
|
+
const inputPath = await input({
|
|
127
|
+
message: 'Please put path from current dir with filename? (default: ".") ex: "./{path}/{filename}.md"',
|
|
128
|
+
default: '.',
|
|
129
|
+
});
|
|
130
|
+
const answers = {
|
|
131
|
+
[INPUT_QUESTION.name]: inputPath
|
|
132
|
+
};
|
|
133
|
+
answers['idGen'] = await select({
|
|
134
|
+
message: `Choose generate type (default: ${GENERATE_TYPE_CHOICES[0].short})`,
|
|
135
|
+
default: 0,
|
|
136
|
+
choices: getIdGenQuestions(inputPath, options)
|
|
137
|
+
});
|
|
138
|
+
if (answers.idGen === GENERATE_TYPES.manual) {
|
|
139
|
+
answers['id'] = await input({
|
|
140
|
+
message: 'type id',
|
|
141
|
+
validate: input => {
|
|
142
|
+
return !!input;
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
await setDirQuestions(inputPath, options, answers);
|
|
147
|
+
await setFileQuestions(inputPath, options, answers);
|
|
148
|
+
return answers;
|
|
149
|
+
};
|
|
150
|
+
export const QUESTIONS = (options) => ({
|
|
151
|
+
[TYPES.rc]: RC_QUESTIONS(options),
|
|
152
|
+
[TYPES.link]: LINK_QUESTIONS(options),
|
|
153
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/types/configs/help.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAEjD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/types/configs/links.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/types/configs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { input, confirm, number, rawlist, select } from '@inquirer/prompts';
|
|
2
|
+
type Types = typeof input | typeof confirm | typeof number | typeof rawlist | typeof select;
|
|
3
|
+
interface Question<Q extends Types> {
|
|
4
|
+
name: string;
|
|
5
|
+
question: () => ReturnType<Q>;
|
|
6
|
+
filter?: (...args: any[]) => any;
|
|
7
|
+
}
|
|
8
|
+
export type InputQuestion = Question<typeof input>;
|
|
9
|
+
export type ConfirmQuestion = Question<typeof confirm>;
|
|
10
|
+
export type NumberQuestion = Question<typeof number>;
|
|
11
|
+
export type RawListQuestion = Question<typeof rawlist>;
|
|
12
|
+
export type SelectQuestion = Question<typeof select>;
|
|
13
|
+
export type Questions = ReadonlyArray<InputQuestion | ConfirmQuestion | NumberQuestion | RawListQuestion | SelectQuestion>;
|
|
14
|
+
type AwaitedReturn<T> = T extends Promise<infer U> ? U : never;
|
|
15
|
+
export type Answer<Q extends Types> = AwaitedReturn<ReturnType<Q>>;
|
|
16
|
+
export interface Answers {
|
|
17
|
+
[name: string]: Answer<Types>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=inquirer.d.ts.map
|