creatium 0.1.17 → 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/LICENSE +21 -676
- package/README.md +6 -10
- package/dist/index.d.mts +881 -0
- package/dist/index.d.ts +881 -0
- package/dist/{main.mjs → index.mjs} +330 -1080
- package/dist/shared/creatium.v0AbQ44Q.mjs +5912 -0
- package/dist/utils.d.mts +1013 -0
- package/dist/utils.d.ts +1013 -0
- package/dist/utils.mjs +2 -0
- package/package.json +17 -29
- package/dist/main.cjs +0 -2061
- package/dist/main.d.cts +0 -1672
- package/dist/main.d.mts +0 -1672
- package/dist/main.d.ts +0 -1672
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
import { Prettify, color, prompt, line, ObjectValues, Response, ContentInput, ObjectToArray, copyDir, replacePlaceholders, getPaths } from './utils.js';
|
|
2
|
+
import { ClippiumData } from 'clippium';
|
|
3
|
+
import '@visulima/boxen';
|
|
4
|
+
import 'cli-table3';
|
|
5
|
+
import 'columnify';
|
|
6
|
+
import '@clack/prompts';
|
|
7
|
+
import 'fs';
|
|
8
|
+
import 'node:fs/promises';
|
|
9
|
+
import 'tiny-glob';
|
|
10
|
+
import 'node:os';
|
|
11
|
+
import 'node:process';
|
|
12
|
+
import 'deepmerge-ts';
|
|
13
|
+
import 'node:url';
|
|
14
|
+
|
|
15
|
+
type Option = NonNullable<ClippiumData['flags']>[number];
|
|
16
|
+
type OptionsUtils = {
|
|
17
|
+
color: typeof color;
|
|
18
|
+
prompt: typeof prompt;
|
|
19
|
+
line: typeof line;
|
|
20
|
+
};
|
|
21
|
+
type OptionSuper = {
|
|
22
|
+
/** Key of the option */
|
|
23
|
+
/** Description of the option */
|
|
24
|
+
desc: string;
|
|
25
|
+
};
|
|
26
|
+
type OptionCommon = OptionSuper & {
|
|
27
|
+
/**
|
|
28
|
+
* If is not set. Desc value will be used
|
|
29
|
+
*/
|
|
30
|
+
promptMsg?: string;
|
|
31
|
+
/** Alias of the option */
|
|
32
|
+
alias?: string[];
|
|
33
|
+
};
|
|
34
|
+
type OptionCommonWithPlaceholder<V> = Prettify<OptionCommon & {
|
|
35
|
+
/**
|
|
36
|
+
* Value that will be used as placeholder in prompt.
|
|
37
|
+
*/
|
|
38
|
+
placeholderValue?: V;
|
|
39
|
+
}>;
|
|
40
|
+
type CliOption = Option;
|
|
41
|
+
/**
|
|
42
|
+
* Core interface
|
|
43
|
+
*
|
|
44
|
+
* @template V
|
|
45
|
+
*/
|
|
46
|
+
type CoreInterface<V = string> = {
|
|
47
|
+
/**
|
|
48
|
+
* Validate value.
|
|
49
|
+
*
|
|
50
|
+
* Used to validate initial value in prompt method
|
|
51
|
+
*/
|
|
52
|
+
validateInitialValue: (data: {
|
|
53
|
+
/** Show success message */
|
|
54
|
+
showSuccess?: boolean;
|
|
55
|
+
/** Show error message */
|
|
56
|
+
showError?: boolean;
|
|
57
|
+
}) => Promise<V | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Method to set the cli option
|
|
60
|
+
*
|
|
61
|
+
* @returns {Promise<CliOption | undefined>}
|
|
62
|
+
*/
|
|
63
|
+
cmd: () => Promise<CliOption | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Method to set the prompt for the option
|
|
66
|
+
*
|
|
67
|
+
* @returns {Promise<V>}
|
|
68
|
+
*/
|
|
69
|
+
prompt: () => Promise<V>;
|
|
70
|
+
};
|
|
71
|
+
declare class Core<Config extends OptionSuper = OptionCommon, V = string> {
|
|
72
|
+
config: Prettify<Config>;
|
|
73
|
+
_utils: OptionsUtils;
|
|
74
|
+
/** On cancel callback */
|
|
75
|
+
_onCancel: () => Promise<void>;
|
|
76
|
+
/** After the prompt is set */
|
|
77
|
+
afterPrompt: (<V>(value: V) => Promise<V>) | undefined;
|
|
78
|
+
/** Enable debug MODE */
|
|
79
|
+
debugMode: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Set initial value.
|
|
82
|
+
* For example if you want to prioritize a cli flag.
|
|
83
|
+
*
|
|
84
|
+
* @default undefined
|
|
85
|
+
*/
|
|
86
|
+
initialValue: V | undefined;
|
|
87
|
+
protected _type: {
|
|
88
|
+
readonly string: "string";
|
|
89
|
+
readonly number: "number";
|
|
90
|
+
readonly boolean: "boolean";
|
|
91
|
+
readonly array: "array";
|
|
92
|
+
readonly choices: "choices";
|
|
93
|
+
};
|
|
94
|
+
constructor(config: Prettify<Config>, _utils: OptionsUtils);
|
|
95
|
+
protected _text: {
|
|
96
|
+
initialValueSuccess: (t: string, v: string) => string;
|
|
97
|
+
initialValueError: (v?: string) => string;
|
|
98
|
+
};
|
|
99
|
+
getPromptHooked(): Promise<any>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type Value$5 = string | number;
|
|
103
|
+
type OptionSelect<V extends Value$5 = Value$5> = OptionCommonWithPlaceholder<V> & {
|
|
104
|
+
/** Set the options of select */
|
|
105
|
+
options: {
|
|
106
|
+
[key in V]: {
|
|
107
|
+
/** Visible name of the option */
|
|
108
|
+
name: string;
|
|
109
|
+
/** Description of the option. Used in cli prompt */
|
|
110
|
+
desc?: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
declare class Select<V extends Value$5 = Value$5> extends Core<OptionSelect<V>, V> implements CoreInterface<Value$5> {
|
|
115
|
+
cmd(): Promise<CliOption>;
|
|
116
|
+
validateInitialValue(data?: {
|
|
117
|
+
showSuccess?: boolean;
|
|
118
|
+
showError?: boolean;
|
|
119
|
+
}): Promise<V | undefined>;
|
|
120
|
+
prompt(): Promise<string>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare const SELECT_BASE_OPTS: {
|
|
124
|
+
readonly NONE: "none";
|
|
125
|
+
};
|
|
126
|
+
type OptionNone = typeof SELECT_BASE_OPTS['NONE'];
|
|
127
|
+
type OptionsValue = {
|
|
128
|
+
/** Visible name of the option */
|
|
129
|
+
name?: string;
|
|
130
|
+
/** Description of the option. Used in cli prompt */
|
|
131
|
+
desc?: string;
|
|
132
|
+
};
|
|
133
|
+
type SelectBaseOptions<Value extends string = string> = Partial<Omit<OptionSelect<Value>, 'options'>> & {
|
|
134
|
+
/**
|
|
135
|
+
* Select only specific options by key.
|
|
136
|
+
*
|
|
137
|
+
* Minimum 2 option.
|
|
138
|
+
*
|
|
139
|
+
* @example ['yarn', 'pnpm']
|
|
140
|
+
*/
|
|
141
|
+
onlyOptions?: [Exclude<Value, OptionNone>, Exclude<Value, OptionNone>, ...Exclude<Value, OptionNone>[]];
|
|
142
|
+
/** Change the options values by key */
|
|
143
|
+
options?: {
|
|
144
|
+
[key in Value]?: OptionsValue;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** Text editor values used in `openEditor` option. */
|
|
149
|
+
declare const TEXT_EDITOR: {
|
|
150
|
+
readonly VSCODE: "code";
|
|
151
|
+
readonly SUBLIME: "subl";
|
|
152
|
+
readonly WEBSTORM: "webstorm";
|
|
153
|
+
readonly NONE: "none";
|
|
154
|
+
};
|
|
155
|
+
type TextEditor = ObjectValues<typeof TEXT_EDITOR>;
|
|
156
|
+
type OptionEditor = SelectBaseOptions<TextEditor>;
|
|
157
|
+
declare class Editor extends Select<TextEditor> {
|
|
158
|
+
_utils: OptionsUtils;
|
|
159
|
+
constructor(config: OptionEditor, _utils: OptionsUtils);
|
|
160
|
+
validateInitialValue(data?: {
|
|
161
|
+
showSuccess?: boolean;
|
|
162
|
+
showError?: boolean;
|
|
163
|
+
}): Promise<TextEditor | undefined>;
|
|
164
|
+
prompt(): Promise<TextEditor>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** installer values used in `install` option. */
|
|
168
|
+
declare const INSTALLER: {
|
|
169
|
+
readonly NONE: "none";
|
|
170
|
+
readonly DENO: "deno";
|
|
171
|
+
readonly BUN: "bun";
|
|
172
|
+
readonly NPM: "npm";
|
|
173
|
+
readonly PNPM: "pnpm";
|
|
174
|
+
readonly YARN: "yarn";
|
|
175
|
+
};
|
|
176
|
+
type Installer = ObjectValues<typeof INSTALLER>;
|
|
177
|
+
type OptionInstall = SelectBaseOptions<Installer>;
|
|
178
|
+
declare class Install extends Select<Installer> {
|
|
179
|
+
_utils: OptionsUtils;
|
|
180
|
+
constructor(config: OptionInstall, _utils: OptionsUtils);
|
|
181
|
+
validateInitialValue(data?: {
|
|
182
|
+
showSuccess?: boolean;
|
|
183
|
+
showError?: boolean;
|
|
184
|
+
}): Promise<Installer | undefined>;
|
|
185
|
+
prompt(): Promise<Installer>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Object of the CREATIUM types */
|
|
189
|
+
declare const OPTION: {
|
|
190
|
+
readonly array: "array";
|
|
191
|
+
readonly select: "select";
|
|
192
|
+
readonly multiselect: "multiselect";
|
|
193
|
+
readonly boolean: "boolean";
|
|
194
|
+
readonly number: "number";
|
|
195
|
+
readonly text: "text";
|
|
196
|
+
readonly void: "void";
|
|
197
|
+
readonly output: "output";
|
|
198
|
+
readonly name: "name";
|
|
199
|
+
readonly template: "template";
|
|
200
|
+
readonly install: "install";
|
|
201
|
+
readonly openEditor: "openEditor";
|
|
202
|
+
readonly path: "path";
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
type Value$4 = string[];
|
|
206
|
+
type OptionArray = OptionCommonWithPlaceholder<Value$4> & {
|
|
207
|
+
/**
|
|
208
|
+
* Separator for value strings.
|
|
209
|
+
*
|
|
210
|
+
* @default ','
|
|
211
|
+
*/
|
|
212
|
+
separator?: string;
|
|
213
|
+
};
|
|
214
|
+
declare class Array extends Core<OptionArray, Value$4> implements CoreInterface<Value$4> {
|
|
215
|
+
#private;
|
|
216
|
+
cmd(): Promise<CliOption>;
|
|
217
|
+
validateInitialValue(data?: {
|
|
218
|
+
showSuccess?: boolean;
|
|
219
|
+
showError?: boolean;
|
|
220
|
+
}): Promise<string[] | undefined>;
|
|
221
|
+
prompt(): Promise<string[]>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
type Value$3 = boolean;
|
|
225
|
+
type OptionBoolean = OptionCommonWithPlaceholder<Value$3>;
|
|
226
|
+
declare class Boolean extends Core<OptionBoolean, Value$3> implements CoreInterface<Value$3> {
|
|
227
|
+
cmd(): Promise<CliOption>;
|
|
228
|
+
validateInitialValue(data?: {
|
|
229
|
+
showSuccess?: boolean;
|
|
230
|
+
showError?: boolean;
|
|
231
|
+
}): Promise<boolean | undefined>;
|
|
232
|
+
prompt(): Promise<boolean>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
type Value$2 = string;
|
|
236
|
+
type OptionMultiselect<V extends Value$2 = Value$2> = OptionCommonWithPlaceholder<V[]> & {
|
|
237
|
+
/** Set the options of multiselect */
|
|
238
|
+
options: {
|
|
239
|
+
[key in V]: {
|
|
240
|
+
/** Visible name of the option */
|
|
241
|
+
name: string;
|
|
242
|
+
/** Description of the option. Used in cli prompt */
|
|
243
|
+
desc?: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
declare class Multiselect<V extends Value$2 = Value$2> extends Core<OptionMultiselect<V>, V[]> implements CoreInterface<V[]> {
|
|
248
|
+
cmd(): Promise<CliOption>;
|
|
249
|
+
validateInitialValue(data?: {
|
|
250
|
+
showSuccess?: boolean;
|
|
251
|
+
showError?: boolean;
|
|
252
|
+
}): Promise<V[] | undefined>;
|
|
253
|
+
prompt(): Promise<string[]>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
type Value$1 = number;
|
|
257
|
+
type OptionNumber = OptionCommonWithPlaceholder<Value$1>;
|
|
258
|
+
declare class Number extends Core<OptionNumber, Value$1> implements CoreInterface<Value$1> {
|
|
259
|
+
cmd(): Promise<CliOption>;
|
|
260
|
+
validateInitialValue(data?: {
|
|
261
|
+
showSuccess?: boolean;
|
|
262
|
+
showError?: boolean;
|
|
263
|
+
}): Promise<number | undefined>;
|
|
264
|
+
prompt(): Promise<number>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
type Value = string;
|
|
268
|
+
type OptionText = OptionCommonWithPlaceholder<Value>;
|
|
269
|
+
declare class Text extends Core<OptionText, Value> implements CoreInterface<Value> {
|
|
270
|
+
cmd(): Promise<CliOption>;
|
|
271
|
+
validateInitialValue(data?: {
|
|
272
|
+
showSuccess?: boolean;
|
|
273
|
+
showError?: boolean;
|
|
274
|
+
}): Promise<string | undefined>;
|
|
275
|
+
prompt(): Promise<string>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
type OptionVoid = OptionSuper & {
|
|
279
|
+
fn: () => Response<void>;
|
|
280
|
+
};
|
|
281
|
+
declare class Void extends Core<OptionVoid, void> implements CoreInterface<void> {
|
|
282
|
+
cmd(): Promise<undefined>;
|
|
283
|
+
validateInitialValue(): Promise<undefined>;
|
|
284
|
+
prompt(): Promise<void>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
type OptionName = Partial<Name['config']>;
|
|
288
|
+
declare class Name extends Text {
|
|
289
|
+
_utils: OptionsUtils;
|
|
290
|
+
constructor(config: OptionName, _utils: OptionsUtils);
|
|
291
|
+
validateInitialValue(data?: {
|
|
292
|
+
showSuccess?: boolean;
|
|
293
|
+
showError?: boolean;
|
|
294
|
+
}): Promise<string | undefined>;
|
|
295
|
+
prompt(): Promise<string>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
declare const PATH_TYPE: {
|
|
299
|
+
folder: string;
|
|
300
|
+
file: string;
|
|
301
|
+
};
|
|
302
|
+
type PathType = typeof PATH_TYPE[keyof typeof PATH_TYPE];
|
|
303
|
+
type OptionPath = Partial<Path['config']> & {
|
|
304
|
+
/**
|
|
305
|
+
* Set path type
|
|
306
|
+
*
|
|
307
|
+
* @default 'file'
|
|
308
|
+
*/
|
|
309
|
+
pathType?: PathType;
|
|
310
|
+
/**
|
|
311
|
+
* Set if you want to check if path exists or not.
|
|
312
|
+
*
|
|
313
|
+
* @default false
|
|
314
|
+
*/
|
|
315
|
+
exists?: boolean;
|
|
316
|
+
};
|
|
317
|
+
declare class Path extends Text {
|
|
318
|
+
#private;
|
|
319
|
+
_utils: OptionsUtils;
|
|
320
|
+
constructor(config: OptionPath, _utils: OptionsUtils);
|
|
321
|
+
validateInitialValue(data?: {
|
|
322
|
+
showSuccess?: boolean;
|
|
323
|
+
showError?: boolean;
|
|
324
|
+
}): Promise<string | undefined>;
|
|
325
|
+
prompt(): Promise<string>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
type OptionOutput = Partial<Omit<Path['config'], 'pathType' | 'exists'>>;
|
|
329
|
+
declare class Output extends Path {
|
|
330
|
+
_utils: OptionsUtils;
|
|
331
|
+
constructor(config: OptionOutput, _utils: OptionsUtils);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
type OptionTemplate = Partial<Omit<Select['config'], 'options'>> & {
|
|
335
|
+
options: {
|
|
336
|
+
[key: string]: {
|
|
337
|
+
/**
|
|
338
|
+
* Input for download
|
|
339
|
+
* Could be an directory or an array of files
|
|
340
|
+
*/
|
|
341
|
+
input: string | ContentInput[];
|
|
342
|
+
/**
|
|
343
|
+
* Name of the template.
|
|
344
|
+
* If not set, the name of the template will be the key of the template
|
|
345
|
+
*/
|
|
346
|
+
name?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Description of the template.
|
|
349
|
+
*/
|
|
350
|
+
desc?: string;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
declare class Template extends Select<keyof OptionTemplate['options']> {
|
|
355
|
+
_utils: OptionsUtils;
|
|
356
|
+
constructor(config: OptionTemplate, _utils: OptionsUtils);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
type Options = {
|
|
360
|
+
/**Array of values*/
|
|
361
|
+
[OPTION.array]: OptionArray;
|
|
362
|
+
/**Single selection option*/
|
|
363
|
+
[OPTION.select]: OptionSelect;
|
|
364
|
+
/**Multiple selection option*/
|
|
365
|
+
[OPTION.multiselect]: OptionMultiselect;
|
|
366
|
+
/**Boolean option (true/false)*/
|
|
367
|
+
[OPTION.boolean]: OptionBoolean;
|
|
368
|
+
/**Numeric input*/
|
|
369
|
+
[OPTION.number]: OptionNumber;
|
|
370
|
+
/**Text input*/
|
|
371
|
+
[OPTION.text]: OptionText;
|
|
372
|
+
/**Void option (no value)*/
|
|
373
|
+
[OPTION.void]: OptionVoid;
|
|
374
|
+
/** Options for path*/
|
|
375
|
+
[OPTION.path]: OptionPath;
|
|
376
|
+
/**Input for download*/
|
|
377
|
+
[OPTION.output]: OptionOutput;
|
|
378
|
+
/**Name of the project
|
|
379
|
+
* @default filename(output)*/
|
|
380
|
+
[OPTION.name]: OptionName;
|
|
381
|
+
/**Templates*/
|
|
382
|
+
[OPTION.template]: OptionTemplate;
|
|
383
|
+
/**Package manager to install dependencies*/
|
|
384
|
+
[OPTION.install]: OptionInstall;
|
|
385
|
+
/** Open project in a text editor if exist */
|
|
386
|
+
[OPTION.openEditor]: OptionEditor;
|
|
387
|
+
};
|
|
388
|
+
type OptionsClasses = {
|
|
389
|
+
/** Class for handling array options */
|
|
390
|
+
[OPTION.array]: typeof Array;
|
|
391
|
+
/** Class for handling select options */
|
|
392
|
+
[OPTION.select]: typeof Select;
|
|
393
|
+
/** Class for handling multiselect options */
|
|
394
|
+
[OPTION.multiselect]: typeof Multiselect;
|
|
395
|
+
/** Class for handling boolean options */
|
|
396
|
+
[OPTION.boolean]: typeof Boolean;
|
|
397
|
+
/** Class for handling number options */
|
|
398
|
+
[OPTION.number]: typeof Number;
|
|
399
|
+
/** Class for handling text options */
|
|
400
|
+
[OPTION.text]: typeof Text;
|
|
401
|
+
/** Class for handling void options */
|
|
402
|
+
[OPTION.void]: typeof Void;
|
|
403
|
+
/** Options for path*/
|
|
404
|
+
[OPTION.path]: typeof Path;
|
|
405
|
+
/** Class for handling output options */
|
|
406
|
+
[OPTION.output]: typeof Output;
|
|
407
|
+
/** Class for handling name options */
|
|
408
|
+
[OPTION.name]: typeof Name;
|
|
409
|
+
/** Class for handling template options */
|
|
410
|
+
[OPTION.template]: typeof Template;
|
|
411
|
+
/** Class for handling install options */
|
|
412
|
+
[OPTION.install]: typeof Install;
|
|
413
|
+
/** Class for handling openEditor options */
|
|
414
|
+
[OPTION.openEditor]: typeof Editor;
|
|
415
|
+
};
|
|
416
|
+
type OptionsParams = Prettify<Record<string, ObjectToArray<Options>[number]>>;
|
|
417
|
+
type GetPromptValue<K extends keyof OptionsClasses> = Prettify<'prompt' extends keyof OptionsClasses[K]['prototype'] ? Awaited<ReturnType<OptionsClasses[K]['prototype']['prompt']>> : never>;
|
|
418
|
+
|
|
419
|
+
type HookParams = {
|
|
420
|
+
/** Values passed to the prompt */
|
|
421
|
+
values?: {
|
|
422
|
+
[x: string]: unknown;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
type CreateTemplateOpts = {
|
|
426
|
+
/** Set the input path or the template key */
|
|
427
|
+
input?: string;
|
|
428
|
+
/** Set the output path */
|
|
429
|
+
output?: string;
|
|
430
|
+
/** Set the name of the template */
|
|
431
|
+
name?: string;
|
|
432
|
+
/** Set the installer */
|
|
433
|
+
install?: Installer;
|
|
434
|
+
/**
|
|
435
|
+
* Open editor
|
|
436
|
+
*/
|
|
437
|
+
openEditor?: TextEditor;
|
|
438
|
+
/**
|
|
439
|
+
* Add consts to use in your templates.
|
|
440
|
+
*
|
|
441
|
+
*/
|
|
442
|
+
consts?: Record<string, string>;
|
|
443
|
+
};
|
|
444
|
+
type ValuesSimple = Prettify<Omit<CreateTemplateOpts, 'consts' | 'input' | 'output'> & Required<Pick<CreateTemplateOpts, 'output' | 'input'>>>;
|
|
445
|
+
type Config = {
|
|
446
|
+
/**
|
|
447
|
+
* Set name of you project
|
|
448
|
+
*/
|
|
449
|
+
name: string;
|
|
450
|
+
/**
|
|
451
|
+
* Set version of you current project
|
|
452
|
+
* Used in for the updater notifications.
|
|
453
|
+
*/
|
|
454
|
+
version: string;
|
|
455
|
+
/**
|
|
456
|
+
* Use cache
|
|
457
|
+
*
|
|
458
|
+
* @default true
|
|
459
|
+
*/
|
|
460
|
+
cache?: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Use updater
|
|
463
|
+
*
|
|
464
|
+
* @default false
|
|
465
|
+
*/
|
|
466
|
+
updater?: boolean;
|
|
467
|
+
/** Set custom function foor when user cancels the process */
|
|
468
|
+
onCancel?: ((data: HookParams) => Response<void>) | false;
|
|
469
|
+
/** Set custom intro */
|
|
470
|
+
intro?: ((data: HookParams) => Response<void>) | false;
|
|
471
|
+
/** Set custom outro */
|
|
472
|
+
outro?: ((data: HookParams) => Response<void>) | false;
|
|
473
|
+
/**
|
|
474
|
+
* Set you prompts config
|
|
475
|
+
*/
|
|
476
|
+
prompt: OptionsParams;
|
|
477
|
+
/**
|
|
478
|
+
* hooks for
|
|
479
|
+
*/
|
|
480
|
+
hooks?: {
|
|
481
|
+
beforePrompt?: <D extends HookParams>(data: D) => Response<D | undefined>;
|
|
482
|
+
afterPrompt?: <D extends HookParams>(data: D) => Response<D | undefined>;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
type ConfigSimple = Prettify<Omit<Config, 'prompt' | 'hooks'> & {
|
|
486
|
+
/** Set your prompt options */
|
|
487
|
+
opts?: {
|
|
488
|
+
/** Active/deactivate the name prompt */
|
|
489
|
+
[OPTION.name]?: boolean;
|
|
490
|
+
/**
|
|
491
|
+
* Active/deactivate the install prompt
|
|
492
|
+
* Also, You can set the installators that you want to use.
|
|
493
|
+
*/
|
|
494
|
+
[OPTION.install]?: false | Options['install']['onlyOptions'];
|
|
495
|
+
/**
|
|
496
|
+
* Active/deactivate the openEditor prompt.
|
|
497
|
+
* Also, You can set the editors that you want to use.
|
|
498
|
+
*/
|
|
499
|
+
[OPTION.openEditor]?: false | Options['openEditor']['onlyOptions'];
|
|
500
|
+
};
|
|
501
|
+
/** Set your template ooptions */
|
|
502
|
+
templates: Options['template']['options'];
|
|
503
|
+
/**
|
|
504
|
+
* Add consts to use in your templates.
|
|
505
|
+
*/
|
|
506
|
+
consts?: CreateTemplateOpts['consts'];
|
|
507
|
+
}>;
|
|
508
|
+
type CliOpts = {
|
|
509
|
+
/**
|
|
510
|
+
* Arguments to pass to the command
|
|
511
|
+
*
|
|
512
|
+
* @default process.argv.slice(2)
|
|
513
|
+
*/
|
|
514
|
+
args?: string[];
|
|
515
|
+
/**
|
|
516
|
+
* Hide the first two arguments
|
|
517
|
+
*
|
|
518
|
+
* @default false
|
|
519
|
+
*/
|
|
520
|
+
hideBin?: boolean;
|
|
521
|
+
};
|
|
522
|
+
type CreateOpts = CliOpts & {
|
|
523
|
+
/**
|
|
524
|
+
* Options for activate cli.
|
|
525
|
+
*
|
|
526
|
+
* @default true
|
|
527
|
+
*/
|
|
528
|
+
activeCli?: boolean;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
type GetPromptValues<C extends Config> = Prettify<{
|
|
532
|
+
[K in keyof C['prompt']]?: Prettify<(C['prompt'][K] extends {
|
|
533
|
+
type: infer T;
|
|
534
|
+
} ? T extends keyof OptionsClasses ? GetPromptValue<T> : never : never)>;
|
|
535
|
+
}>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Customizable class of `Creatium` for create project templates (CLI and Library).
|
|
539
|
+
*
|
|
540
|
+
* @template C
|
|
541
|
+
* @example
|
|
542
|
+
* //////////////// core.js ///////////////////
|
|
543
|
+
*
|
|
544
|
+
* export const core = new CreatiumCore({
|
|
545
|
+
* name: 'My Project',
|
|
546
|
+
* version: '1.0.0',
|
|
547
|
+
* prompts: {
|
|
548
|
+
* ...
|
|
549
|
+
* },
|
|
550
|
+
* ...
|
|
551
|
+
* })
|
|
552
|
+
*
|
|
553
|
+
* //////////////// bin.js ///////////////////
|
|
554
|
+
*
|
|
555
|
+
* import { core } from './core.js'
|
|
556
|
+
* const res = await core.cli()
|
|
557
|
+
* // do something with res...
|
|
558
|
+
* await core.createTemplate( res )
|
|
559
|
+
*
|
|
560
|
+
* //////////////// lib.js ///////////////////
|
|
561
|
+
*
|
|
562
|
+
* import { core } from './core.js'
|
|
563
|
+
* export const create = async (args) => {
|
|
564
|
+
* const res = await core.build( args )
|
|
565
|
+
* // do something with res...
|
|
566
|
+
* await core.createTemplate( res )
|
|
567
|
+
* }
|
|
568
|
+
*/
|
|
569
|
+
declare class CreatiumCore<C extends Config = Config> {
|
|
570
|
+
#private;
|
|
571
|
+
utils: OptionsUtils;
|
|
572
|
+
config: C;
|
|
573
|
+
constructor(config: C);
|
|
574
|
+
/** Force debug mode */
|
|
575
|
+
set debugMode(value: boolean);
|
|
576
|
+
/**
|
|
577
|
+
* Shows a notification if the current package is outdated.
|
|
578
|
+
*
|
|
579
|
+
* **information**: If this 'custom' function is provided, the default
|
|
580
|
+
* notification will not be shown.
|
|
581
|
+
*
|
|
582
|
+
* @returns {Promise<boolean>} - A promise that resolves when the notification has finished.
|
|
583
|
+
*/
|
|
584
|
+
updateNotify(): Promise<boolean>;
|
|
585
|
+
/**
|
|
586
|
+
* Cancels the current process and exits with code 0.
|
|
587
|
+
*
|
|
588
|
+
* If a `message` is provided, it will be displayed in the console.
|
|
589
|
+
* If `onCancel` is set in the config, it will be called with the current data.
|
|
590
|
+
* If `onCancel` is not set, a default message will be displayed.
|
|
591
|
+
*
|
|
592
|
+
* @param {string} [message] - The message to display before exiting.
|
|
593
|
+
*/
|
|
594
|
+
cancel(message?: string): Promise<void>;
|
|
595
|
+
/**
|
|
596
|
+
* Intro prompt line.
|
|
597
|
+
*
|
|
598
|
+
* If the parameter `message` is provided, it will be used as the intro message.
|
|
599
|
+
* If the `intro` option is a function, it will be called with the `this.#data` as the argument.
|
|
600
|
+
* If the `intro` option is undefined, the default intro message will be used.
|
|
601
|
+
*
|
|
602
|
+
* @param {string} [message] - The intro message.
|
|
603
|
+
*/
|
|
604
|
+
intro(message?: string): Promise<void>;
|
|
605
|
+
/**
|
|
606
|
+
* Outro prompt line.
|
|
607
|
+
*
|
|
608
|
+
* If the parameter `message` is provided, it will be used as the outro message.
|
|
609
|
+
* If the `outro` option is a function, it will be called with the `this.#data` as the argument.
|
|
610
|
+
* If the `outro` option is undefined, the default outro message will be used.
|
|
611
|
+
*
|
|
612
|
+
* @param {string} [message] - The outro message.
|
|
613
|
+
*/
|
|
614
|
+
outro(message?: string): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Copy a directory from input path to output path.
|
|
617
|
+
*
|
|
618
|
+
* @param {object} data - Options object with input and output paths.
|
|
619
|
+
* @returns {Promise<void>} - Resolves when the directory has been copied.
|
|
620
|
+
* @example
|
|
621
|
+
*
|
|
622
|
+
* const copyResult = await core.copyDir({
|
|
623
|
+
* input : '/path/to/sourceDir',
|
|
624
|
+
* output: '/path/to/destinationDir',
|
|
625
|
+
* })
|
|
626
|
+
* const copyResult = await copyDir({
|
|
627
|
+
* input : [
|
|
628
|
+
* {
|
|
629
|
+
* name: 'file1.txt',
|
|
630
|
+
* content: 'Hello, world!',
|
|
631
|
+
* },
|
|
632
|
+
* {
|
|
633
|
+
* name: 'file2.txt',
|
|
634
|
+
* content: 'Goodbye, world!',
|
|
635
|
+
* },
|
|
636
|
+
* ],
|
|
637
|
+
* output: '/path/to/destinationDir',
|
|
638
|
+
* })
|
|
639
|
+
*/
|
|
640
|
+
copyDir(data: Parameters<typeof copyDir>[0]): Promise<void>;
|
|
641
|
+
/**
|
|
642
|
+
* Installs the project with the given package manager.
|
|
643
|
+
*
|
|
644
|
+
* @param {object} [options] - The options to install.
|
|
645
|
+
* @param {Installer} [options.installer] - The package manager to use for the installation.
|
|
646
|
+
* @param {string} [options.input] - The path to the folder. If not provided, the current directory is used.
|
|
647
|
+
* @returns {Promise<void>}
|
|
648
|
+
* @example
|
|
649
|
+
* await core.install( {
|
|
650
|
+
* installer : 'pnpm',
|
|
651
|
+
* input : 'my/project/path',
|
|
652
|
+
* } )
|
|
653
|
+
*/
|
|
654
|
+
install({ installer, input, }?: {
|
|
655
|
+
installer?: Installer;
|
|
656
|
+
input?: string;
|
|
657
|
+
}): Promise<void>;
|
|
658
|
+
/**
|
|
659
|
+
* Open the project in the given editor.
|
|
660
|
+
*
|
|
661
|
+
* @param {object} params - The parameters for opening the editor.
|
|
662
|
+
* @param {TextEditor} params.editor - The editor to open the project in.
|
|
663
|
+
* @param {string} params.input - The input path. If not provided, the current directory is used.
|
|
664
|
+
* @returns {Promise<void>}
|
|
665
|
+
* @example
|
|
666
|
+
* await core.openEditor( {
|
|
667
|
+
* editor : 'vscode',
|
|
668
|
+
* input : 'my/project/path',
|
|
669
|
+
* })
|
|
670
|
+
*/
|
|
671
|
+
openEditor({ editor, input, }?: {
|
|
672
|
+
editor?: TextEditor;
|
|
673
|
+
input?: string;
|
|
674
|
+
}): Promise<void>;
|
|
675
|
+
/**
|
|
676
|
+
* Replaces placeholders in files within the specified directory.
|
|
677
|
+
*
|
|
678
|
+
* This function searches for files in the provided input directory and replaces
|
|
679
|
+
* placeholders within those files using the specified parameters. The placeholders
|
|
680
|
+
* in the content are replaced with values from the `params` object.
|
|
681
|
+
*
|
|
682
|
+
* @param {object} args - The arguments object.
|
|
683
|
+
* @param {string} [args.input] - The directory path containing files with placeholders.
|
|
684
|
+
* @param {object} [args.params] - An object containing key-value pairs for replacing placeholders.
|
|
685
|
+
* @returns {Promise<void>} A Promise that resolves once all placeholders have been replaced.
|
|
686
|
+
* @example
|
|
687
|
+
* await core.replacePlaceholders( {
|
|
688
|
+
* input : 'my/project/path',
|
|
689
|
+
* params : { consts: { version: '1.0.0' }, prompt: { name: 'My Project' } },
|
|
690
|
+
* })
|
|
691
|
+
*/
|
|
692
|
+
replacePlaceholders({ input, params, inputOpts, }?: {
|
|
693
|
+
input?: string;
|
|
694
|
+
params?: Parameters<typeof replacePlaceholders>[0]['params'];
|
|
695
|
+
inputOpts?: Parameters<typeof getPaths>[1];
|
|
696
|
+
}): Promise<void>;
|
|
697
|
+
/**
|
|
698
|
+
* Return the input path of a template by name or path.
|
|
699
|
+
*
|
|
700
|
+
* @param {string} [input] - The name of the template or the path to the template.
|
|
701
|
+
* @returns {Promise<string | undefined>} The input path of the template or undefined if not found.
|
|
702
|
+
* @example
|
|
703
|
+
* // with template path
|
|
704
|
+
* const input = await core.getTemplateInput( { input : 'my/template/path' } )
|
|
705
|
+
* @example
|
|
706
|
+
* // With template key
|
|
707
|
+
* // template key must be specified in the config prompt secction.
|
|
708
|
+
* const input = await core.getTemplateInput( { input : 'templateKey' )
|
|
709
|
+
*/
|
|
710
|
+
getTemplateInput({ input }?: {
|
|
711
|
+
input?: string;
|
|
712
|
+
}): Promise<string | undefined>;
|
|
713
|
+
/**
|
|
714
|
+
* Create a new project template.
|
|
715
|
+
*
|
|
716
|
+
* @param {CreateTemplateOpts} values - The values to create the template.
|
|
717
|
+
* @returns {Promise<void>} - A promise that resolves when the template is created.
|
|
718
|
+
* @example
|
|
719
|
+
* // basic usage
|
|
720
|
+
* await core.createTemplate( { input : 'my/template/path', output : 'my/project/path' } )
|
|
721
|
+
* @example
|
|
722
|
+
* // custom usage
|
|
723
|
+
* await core.createTemplate( {
|
|
724
|
+
* input : 'my/template/path',
|
|
725
|
+
* output : 'my/project/path',
|
|
726
|
+
* install : 'pnpm',
|
|
727
|
+
* open : 'vscode',
|
|
728
|
+
* consts : {
|
|
729
|
+
* version : '1.0.0',
|
|
730
|
+
* header : '// Template generated by Creatium. a project from PigeonPosse',
|
|
731
|
+
* },
|
|
732
|
+
* } )
|
|
733
|
+
*/
|
|
734
|
+
createTemplate(values: CreateTemplateOpts): Promise<void>;
|
|
735
|
+
/**
|
|
736
|
+
* Initialize the CLI and executes the callback function passed in the config.
|
|
737
|
+
*
|
|
738
|
+
* @param {GetPromptValues<C>} [values] - The values to override the CLI prompts. If not set, the CLI prompts will be executed.
|
|
739
|
+
* @param {CreateOpts} [opts] - The options to pass to the CLI.
|
|
740
|
+
* @returns The result of the callback function.
|
|
741
|
+
*/
|
|
742
|
+
build(values?: Prettify<GetPromptValues<C>>, opts?: CreateOpts): Promise<{ [K_1 in keyof C["prompt"]]?: ((C["prompt"][K_1] extends {
|
|
743
|
+
type: infer T_2;
|
|
744
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_7 ? { [K_3 in keyof T_7]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never) extends infer T_5 ? { [K_2 in keyof T_5]: (C["prompt"][K_1] extends {
|
|
745
|
+
type: infer T_2;
|
|
746
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_6 ? { [K_3 in keyof T_6]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never)[K_2]; } : never) | undefined; } extends infer T ? { [K in keyof T]: { [K_1 in keyof C["prompt"]]?: ((C["prompt"][K_1] extends {
|
|
747
|
+
type: infer T_2;
|
|
748
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_4 ? { [K_3 in keyof T_4]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never) extends infer T_1 ? { [K_2 in keyof T_1]: (C["prompt"][K_1] extends {
|
|
749
|
+
type: infer T_2;
|
|
750
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_3 ? { [K_3 in keyof T_3]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never)[K_2]; } : never) | undefined; }[K]; } : never>;
|
|
751
|
+
/**
|
|
752
|
+
* Initializes and executes the command-line interface (CLI) process.
|
|
753
|
+
*
|
|
754
|
+
* @param {CliOpts} [props] - Optional CLI options to configure the initialization process.
|
|
755
|
+
* @returns A promise resolving to the prompt values obtained after executing the CLI.
|
|
756
|
+
* @example
|
|
757
|
+
* // simple usage
|
|
758
|
+
* await core.cli()
|
|
759
|
+
* @example
|
|
760
|
+
* // custom usage
|
|
761
|
+
* await core.cli( { args : process.argv.slice( 4), hideBin : false } )
|
|
762
|
+
*/
|
|
763
|
+
cli(props?: CliOpts): Promise<{ [K_1 in keyof C["prompt"]]?: ((C["prompt"][K_1] extends {
|
|
764
|
+
type: infer T_2;
|
|
765
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_7 ? { [K_3 in keyof T_7]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never) extends infer T_5 ? { [K_2 in keyof T_5]: (C["prompt"][K_1] extends {
|
|
766
|
+
type: infer T_2;
|
|
767
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_6 ? { [K_3 in keyof T_6]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never)[K_2]; } : never) | undefined; } extends infer T ? { [K in keyof T]: { [K_1 in keyof C["prompt"]]?: ((C["prompt"][K_1] extends {
|
|
768
|
+
type: infer T_2;
|
|
769
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_4 ? { [K_3 in keyof T_4]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never) extends infer T_1 ? { [K_2 in keyof T_1]: (C["prompt"][K_1] extends {
|
|
770
|
+
type: infer T_2;
|
|
771
|
+
} ? T_2 extends keyof OptionsClasses ? ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never) extends infer T_3 ? { [K_3 in keyof T_3]: ("prompt" extends keyof OptionsClasses[T_2]["prototype"] ? Awaited<ReturnType<OptionsClasses[T_2]["prototype"]["prompt"]>> : never)[K_3]; } : never : never : never)[K_2]; } : never) | undefined; }[K]; } : never>;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Class of `Creatium` for create project templates (CLI and Library).
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* //////////////// core.js ///////////////////
|
|
779
|
+
*
|
|
780
|
+
* import { Creatium } from 'creatium'
|
|
781
|
+
* export const core = new Creatium({
|
|
782
|
+
* name: 'My Project',
|
|
783
|
+
* version: '1.0.0',
|
|
784
|
+
* templates: {
|
|
785
|
+
* ...
|
|
786
|
+
* },
|
|
787
|
+
* })
|
|
788
|
+
*
|
|
789
|
+
* //////////////// bin.js ///////////////////
|
|
790
|
+
*
|
|
791
|
+
* import { core } from './core.js'
|
|
792
|
+
* core.cli()
|
|
793
|
+
*
|
|
794
|
+
* //////////////// lib.js ///////////////////
|
|
795
|
+
*
|
|
796
|
+
* import { core } from './core.js'
|
|
797
|
+
* export const create = core.build
|
|
798
|
+
*/
|
|
799
|
+
declare class Creatium {
|
|
800
|
+
#private;
|
|
801
|
+
protected options: ConfigSimple;
|
|
802
|
+
protected config: {
|
|
803
|
+
prompt: {
|
|
804
|
+
openEditor?: {
|
|
805
|
+
type: "openEditor";
|
|
806
|
+
onlyOptions: ["code" | "subl" | "webstorm", "code" | "subl" | "webstorm", ...("code" | "subl" | "webstorm")[]] | undefined;
|
|
807
|
+
} | undefined;
|
|
808
|
+
install?: {
|
|
809
|
+
type: "install";
|
|
810
|
+
onlyOptions: ["deno" | "bun" | "npm" | "pnpm" | "yarn", "deno" | "bun" | "npm" | "pnpm" | "yarn", ...("deno" | "bun" | "npm" | "pnpm" | "yarn")[]] | undefined;
|
|
811
|
+
} | undefined;
|
|
812
|
+
input: {
|
|
813
|
+
type: "template";
|
|
814
|
+
options: {
|
|
815
|
+
[key: string]: {
|
|
816
|
+
input: string | ContentInput[];
|
|
817
|
+
name?: string;
|
|
818
|
+
desc?: string;
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
name?: {
|
|
823
|
+
type: "name";
|
|
824
|
+
} | undefined;
|
|
825
|
+
output: {
|
|
826
|
+
type: "output";
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
name: string;
|
|
830
|
+
version: string;
|
|
831
|
+
cache?: boolean | undefined;
|
|
832
|
+
updater?: boolean | undefined;
|
|
833
|
+
onCancel?: ((data: HookParams) => Response<void>) | false | undefined;
|
|
834
|
+
intro?: ((data: HookParams) => Response<void>) | false | undefined;
|
|
835
|
+
outro?: ((data: HookParams) => Response<void>) | false | undefined;
|
|
836
|
+
};
|
|
837
|
+
constructor(options: ConfigSimple);
|
|
838
|
+
/**
|
|
839
|
+
* A simplified version of the `build` method from the main class.
|
|
840
|
+
*
|
|
841
|
+
* @param {ValuesSimple} [values] - The values to override the CLI prompts. If not set, the CLI prompts will be executed.
|
|
842
|
+
* @param {CreateOpts} [opts] - The options to pass to the CLI.
|
|
843
|
+
* @returns {Promise<ValuesSimple>} A promise resolving to the prompt values obtained after executing the CLI.
|
|
844
|
+
* @example
|
|
845
|
+
* // simple usage
|
|
846
|
+
* await core.build()
|
|
847
|
+
* @example
|
|
848
|
+
* // custom usage
|
|
849
|
+
* await core.build( { args : process.argv.slice(4), hideBin : false } )
|
|
850
|
+
*/
|
|
851
|
+
build(values?: ValuesSimple, opts?: CreateOpts): Promise<{
|
|
852
|
+
openEditor?: undefined;
|
|
853
|
+
install?: undefined;
|
|
854
|
+
input?: string | undefined;
|
|
855
|
+
name?: undefined;
|
|
856
|
+
output?: string | undefined;
|
|
857
|
+
}>;
|
|
858
|
+
/**
|
|
859
|
+
* A simplified version of the `cli` method from the main class.
|
|
860
|
+
* Initializes and executes the command-line interface (CLI) process.
|
|
861
|
+
*
|
|
862
|
+
* @param {CliOpts} [props] - Optional CLI options to configure the initialization process.
|
|
863
|
+
* @returns {Promise<ValuesSimple>} A promise resolving to the prompt values obtained after executing the CLI.
|
|
864
|
+
* @example
|
|
865
|
+
* // simple usage
|
|
866
|
+
* await core.cli()
|
|
867
|
+
* @example
|
|
868
|
+
* // custom usage
|
|
869
|
+
* await core.cli( { args : process.argv.slice(4), hideBin : false } )
|
|
870
|
+
*/
|
|
871
|
+
cli(props?: CliOpts): Promise<{
|
|
872
|
+
openEditor?: undefined;
|
|
873
|
+
install?: undefined;
|
|
874
|
+
input?: string | undefined;
|
|
875
|
+
name?: undefined;
|
|
876
|
+
output?: string | undefined;
|
|
877
|
+
}>;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
export { Creatium, CreatiumCore, INSTALLER, OPTION, TEXT_EDITOR };
|
|
881
|
+
export type { CliOpts, Config, CreateOpts, CreateTemplateOpts };
|