creatium 0.0.6 → 0.1.0
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 +2 -2
- package/README.md +557 -78
- package/dist/main.d.mts +187 -23
- package/dist/main.d.ts +187 -23
- package/dist/main.mjs +304 -117
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,12 +19,22 @@ Build your create-bins quickly and easily
|
|
|
19
19
|
- [🔑 Installation](#-installation)
|
|
20
20
|
- [🤔 What is it Creatium?](#-what-is-it-creatium)
|
|
21
21
|
- [🚀 Usage](#-usage)
|
|
22
|
-
- [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
- [Simple use case](#simple-use-case)
|
|
23
|
+
- [Project structure](#project-structure)
|
|
24
|
+
- [src/core.js](#srccorejs)
|
|
25
|
+
- [src/bin.js](#srcbinjs)
|
|
26
|
+
- [src/lib.js](#srclibjs)
|
|
27
|
+
- [package.json](#packagejson)
|
|
28
|
+
- [Data (templates)](#data-templates)
|
|
29
|
+
- [Execute](#execute)
|
|
30
|
+
- [Advanced use case](#advanced-use-case)
|
|
31
|
+
- [Project structure](#project-structure)
|
|
32
|
+
- [src/core.js](#srccorejs)
|
|
33
|
+
- [src/bin.js](#srcbinjs)
|
|
34
|
+
- [src/lib.js](#srclibjs)
|
|
35
|
+
- [package.json](#packagejson)
|
|
36
|
+
- [Data (templates & partials)](#data-templates--partials)
|
|
37
|
+
- [Execute](#execute)
|
|
28
38
|
- [Api documentation](#api-documentation)
|
|
29
39
|
- [Classes](#classes)
|
|
30
40
|
- [Creatium](#creatium)
|
|
@@ -36,12 +46,12 @@ Build your create-bins quickly and easily
|
|
|
36
46
|
- [CreateTemplateOpts](#createtemplateopts)
|
|
37
47
|
- [Variables](#variables)
|
|
38
48
|
- [env](#env)
|
|
39
|
-
- [IDE](#ide)
|
|
40
49
|
- [INSTALLER](#installer)
|
|
41
50
|
- [OPTION](#option)
|
|
42
51
|
- [prompt](#prompt)
|
|
43
52
|
- [style](#style)
|
|
44
53
|
- [sys](#sys)
|
|
54
|
+
- [TEXT\_EDITOR](#text_editor)
|
|
45
55
|
- [👨💻 Development](#-development)
|
|
46
56
|
- [☕ Donate](#-donate)
|
|
47
57
|
- [📜 License](#-license)
|
|
@@ -74,24 +84,34 @@ Creatium is a CLI and Library for creating project templates.
|
|
|
74
84
|
|
|
75
85
|
Create a cli and a library project with `creatium`
|
|
76
86
|
|
|
77
|
-
Simple
|
|
87
|
+
### Simple use case
|
|
78
88
|
|
|
79
|
-
|
|
89
|
+
Recommended for most use cases.
|
|
90
|
+
|
|
91
|
+
Below we show a practical example.
|
|
92
|
+
|
|
93
|
+
> {my-library-name} refers to the name of your library. Change it to the name of your library.
|
|
94
|
+
|
|
95
|
+
#### Project structure
|
|
80
96
|
|
|
81
97
|
Create a project with the following structure:
|
|
82
98
|
|
|
83
|
-
```
|
|
99
|
+
```text
|
|
100
|
+
📂 data
|
|
101
|
+
├── 📂 templates
|
|
102
|
+
│ ├── 📂 js-project
|
|
103
|
+
│ │ └── ... (files, folders...)
|
|
104
|
+
│ └── 📂 ts-project
|
|
105
|
+
│ └── ... (files, folders...)
|
|
84
106
|
📂 src
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
📂 templates
|
|
89
|
-
└── 📂 js-project
|
|
90
|
-
└── 📂 ts-project
|
|
107
|
+
├── bin.js
|
|
108
|
+
├── lib.js
|
|
109
|
+
├── core.js
|
|
91
110
|
📄 package.json
|
|
111
|
+
│
|
|
92
112
|
```
|
|
93
113
|
|
|
94
|
-
|
|
114
|
+
#### src/core.js
|
|
95
115
|
|
|
96
116
|
Create a new instance of `creatium` and export it as `core`
|
|
97
117
|
|
|
@@ -103,10 +123,10 @@ import { version } from './package.json'
|
|
|
103
123
|
import { Creatium } from 'creatium'
|
|
104
124
|
|
|
105
125
|
const currentDir = join( dirname( fileURLToPath( import.meta.url ) ) )
|
|
106
|
-
const templatesDir = join( currentDir, '..', 'templates' )
|
|
126
|
+
const templatesDir = join( currentDir, '..', 'data','templates' ) // absolute path for `templates` folder
|
|
107
127
|
|
|
108
128
|
export const core = new Creatium( {
|
|
109
|
-
name: '
|
|
129
|
+
name: '{my-library-name}', // recomended use the name of your package.json becasue it will be used by updater function
|
|
110
130
|
version,
|
|
111
131
|
templates : {
|
|
112
132
|
js : {
|
|
@@ -121,23 +141,25 @@ export const core = new Creatium( {
|
|
|
121
141
|
} )
|
|
122
142
|
```
|
|
123
143
|
|
|
124
|
-
|
|
144
|
+
#### src/bin.js
|
|
125
145
|
|
|
126
146
|
Create a bin file and call the `cli` method of the `core` instance.
|
|
127
147
|
|
|
128
148
|
```javascript
|
|
129
149
|
|
|
150
|
+
#!/usr/bin/env node
|
|
151
|
+
|
|
130
152
|
// create cli
|
|
131
|
-
import { core } from './
|
|
153
|
+
import { core } from './core.js'
|
|
132
154
|
await core.cli()
|
|
133
155
|
```
|
|
134
156
|
|
|
135
|
-
|
|
157
|
+
#### src/lib.js
|
|
136
158
|
|
|
137
159
|
Create a library file and export the `create` function for use outside.
|
|
138
160
|
|
|
139
161
|
```javascript
|
|
140
|
-
import { core } from './
|
|
162
|
+
import { core } from './core.js'
|
|
141
163
|
|
|
142
164
|
/**
|
|
143
165
|
* Create project template.
|
|
@@ -151,7 +173,268 @@ export const create = async ( params ) => {
|
|
|
151
173
|
}
|
|
152
174
|
```
|
|
153
175
|
|
|
154
|
-
|
|
176
|
+
#### package.json
|
|
177
|
+
|
|
178
|
+
Create a package.json file with the following structure:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"name": "create-{my-library-name}",
|
|
183
|
+
"version": "0.0.1",
|
|
184
|
+
"type": "module",
|
|
185
|
+
"main": "src/lib.js",
|
|
186
|
+
"module": "src/lib.js",
|
|
187
|
+
"bin": {
|
|
188
|
+
"create-{my-library-name}": "src/bin.js"
|
|
189
|
+
},
|
|
190
|
+
"scripts": {
|
|
191
|
+
"dev": "node src/bin.js",
|
|
192
|
+
},
|
|
193
|
+
"files": [
|
|
194
|
+
"src",
|
|
195
|
+
"data",
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Data (templates)
|
|
201
|
+
|
|
202
|
+
Create a data folder with your `templates`.
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
📂 data
|
|
206
|
+
├── 📂 templates
|
|
207
|
+
│ ├── 📂 js-project
|
|
208
|
+
│ │ └── ... (files, folders...)
|
|
209
|
+
│ ├── 📂 ts-project
|
|
210
|
+
│ │ └── ... (files, folders...)
|
|
211
|
+
│
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Execute
|
|
215
|
+
|
|
216
|
+
Once the package is published you can use it with:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm create {my-library-name}
|
|
220
|
+
# or
|
|
221
|
+
pnpm create {my-library-name}
|
|
222
|
+
# or
|
|
223
|
+
yarn create {my-library-name}
|
|
224
|
+
# or
|
|
225
|
+
bun create {my-library-name}
|
|
226
|
+
# or
|
|
227
|
+
deno create {my-library-name}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Advanced use case
|
|
231
|
+
|
|
232
|
+
You can use the `CreatiumCore` class to create a fully customized __cli__ and __user prompt__.
|
|
233
|
+
|
|
234
|
+
This class is the one that the main `Creatium` class uses to function.
|
|
235
|
+
|
|
236
|
+
Below we show a practical example.
|
|
237
|
+
|
|
238
|
+
> {my-library-name} refers to the name of your library. Change it to the name of your library.
|
|
239
|
+
|
|
240
|
+
#### Project structure
|
|
241
|
+
|
|
242
|
+
Create a project with the following structure:
|
|
243
|
+
|
|
244
|
+
```text
|
|
245
|
+
📂 data
|
|
246
|
+
├── 📂 templates
|
|
247
|
+
│ ├── 📂 js-project
|
|
248
|
+
│ │ └── ... (files, folders...)
|
|
249
|
+
│ ├── 📂 ts-project
|
|
250
|
+
│ │ └── ... (files, folders...)
|
|
251
|
+
│ 📂 partials
|
|
252
|
+
│ ├── 📂 workspace (used in example)
|
|
253
|
+
│ │ └── ... (files, folders...)
|
|
254
|
+
│ └── 📂 .../
|
|
255
|
+
📂 src
|
|
256
|
+
├── bin.js
|
|
257
|
+
├── lib.js
|
|
258
|
+
├── core.js
|
|
259
|
+
📄 package.json
|
|
260
|
+
│
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### src/core.js
|
|
264
|
+
|
|
265
|
+
- Create a new instance of `CreatiumCore` and export it as `core`
|
|
266
|
+
- Create and export `createTemplate` function for use outside in `src/lib.js` and `src/bin.js`
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
import { dirname, join } from 'node:path'
|
|
270
|
+
import { fileURLToPath } from 'node:url'
|
|
271
|
+
import { version } from './package.json'
|
|
272
|
+
import { CreatiumCore } from 'creatium'
|
|
273
|
+
|
|
274
|
+
const currentDir = join( dirname( fileURLToPath( import.meta.url ) ) )
|
|
275
|
+
const dataDir = join( currentDir, '..', 'data' ) // Absolute path for the `data` folder
|
|
276
|
+
const partialsDir = join( dataDir, 'partials' )
|
|
277
|
+
const templatesDir = join( dataDir, 'templates' )
|
|
278
|
+
|
|
279
|
+
export const core = new CreatiumCore( {
|
|
280
|
+
name: '{my-library-name}',
|
|
281
|
+
version,
|
|
282
|
+
updater : true,
|
|
283
|
+
cache : true,
|
|
284
|
+
prompt : {
|
|
285
|
+
output : {
|
|
286
|
+
type : 'output',
|
|
287
|
+
alias : [ 'o' ],
|
|
288
|
+
desc : 'Where do you want create a new project?',
|
|
289
|
+
},
|
|
290
|
+
name : {
|
|
291
|
+
type : 'name',
|
|
292
|
+
alias : [ 'n' ],
|
|
293
|
+
},
|
|
294
|
+
wsFiles : {
|
|
295
|
+
type : 'boolean',
|
|
296
|
+
desc : 'Include workspace files',
|
|
297
|
+
promptMsg : 'Do you want add a workspace files like LICENSE, .npmrc and .gitignore?',
|
|
298
|
+
},
|
|
299
|
+
desc : {
|
|
300
|
+
type : 'text',
|
|
301
|
+
desc : 'Add a description of your project',
|
|
302
|
+
},
|
|
303
|
+
input : {
|
|
304
|
+
type : 'template',
|
|
305
|
+
desc : 'Select template',
|
|
306
|
+
options : {
|
|
307
|
+
js : {
|
|
308
|
+
input : join( templatesDir, 'js-project' ),
|
|
309
|
+
name : 'JavaScript project',
|
|
310
|
+
},
|
|
311
|
+
ts : {
|
|
312
|
+
input : join( templatesDir, 'ts-project' ),
|
|
313
|
+
name : 'TypeScript project',
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
install : {
|
|
318
|
+
type : 'install',
|
|
319
|
+
desc : 'Select package manager',
|
|
320
|
+
onlyOptions : [
|
|
321
|
+
'pnpm',
|
|
322
|
+
'npm',
|
|
323
|
+
'deno',
|
|
324
|
+
], // Only these package managers can be selected
|
|
325
|
+
},
|
|
326
|
+
openEditor : { type: 'openEditor' },
|
|
327
|
+
},
|
|
328
|
+
} )
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Function for create a new project template.
|
|
332
|
+
* @param {Awaited<ReturnType<typeof core.cli>>} params - The values to create the template.
|
|
333
|
+
* @returns {Promise<void>} - A promise that resolves when the template is created.
|
|
334
|
+
*/
|
|
335
|
+
export const createTemplate = async ( params ) => {
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
|
|
339
|
+
const {
|
|
340
|
+
output,
|
|
341
|
+
input,
|
|
342
|
+
install,
|
|
343
|
+
openEditor,
|
|
344
|
+
name,
|
|
345
|
+
wsFiles,
|
|
346
|
+
} = params
|
|
347
|
+
|
|
348
|
+
const { prompt } = core.utils // extract prompt utils and use it for write in prompt line
|
|
349
|
+
|
|
350
|
+
// Copy the workspace partials folder if wsFiles is true.
|
|
351
|
+
// this must be first than the creatium.createTemplate because creatium.createTemplate ends the line process
|
|
352
|
+
// and wsFiles must be override in the creatium.createTemplate function.
|
|
353
|
+
if ( wsFiles ) {
|
|
354
|
+
|
|
355
|
+
await core.copyDir( {
|
|
356
|
+
input : join( partialsDir, 'workspace' ),
|
|
357
|
+
output,
|
|
358
|
+
} )
|
|
359
|
+
|
|
360
|
+
prompt.log.success( 'Added workspace files!' )
|
|
361
|
+
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// example of dynamic pkg json config
|
|
365
|
+
const pkgJSON = {
|
|
366
|
+
name : name,
|
|
367
|
+
description : consts.desc,
|
|
368
|
+
version : '0.0.1',
|
|
369
|
+
license : wsFiles ? 'MIT' : undefined
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
await core.createTemplate( {
|
|
373
|
+
output,
|
|
374
|
+
input,
|
|
375
|
+
install,
|
|
376
|
+
openEditor,
|
|
377
|
+
name,
|
|
378
|
+
// custom parameters for been susbstituted in the template files
|
|
379
|
+
consts : {
|
|
380
|
+
// example of dynamic pkg json config
|
|
381
|
+
pkg : JSON.stringify( pkgJSON, null, 2 ),
|
|
382
|
+
},
|
|
383
|
+
} )
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
catch ( error ) {
|
|
387
|
+
|
|
388
|
+
if ( error instanceof Error ) prompt.log.error( error.message ) // show error message in prompt line
|
|
389
|
+
else console.error( 'Unexpected error:', error )
|
|
390
|
+
|
|
391
|
+
core.cancel() // cancel the process
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### src/bin.js
|
|
400
|
+
|
|
401
|
+
Create a bin file and call the `cli` method of the `core` instance.
|
|
402
|
+
|
|
403
|
+
```javascript
|
|
404
|
+
#!/usr/bin/env node
|
|
405
|
+
|
|
406
|
+
import { core, createTemplate } from './core.js'
|
|
407
|
+
// Run the CLI and obtain the prompt values
|
|
408
|
+
const res = await core.cli()
|
|
409
|
+
// Call to the create function for create the template
|
|
410
|
+
await createTemplate( res )
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
#### src/lib.js
|
|
415
|
+
|
|
416
|
+
Create a library file and export the `create` function for use outside.
|
|
417
|
+
|
|
418
|
+
```javascript
|
|
419
|
+
import { core, createTemplate } from './core.js'
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Create project template.
|
|
423
|
+
* @param {Parameters<typeof core.build>[0]} params - The parameters required for creation.
|
|
424
|
+
* @returns {Promise<Object>} A promise that resolves to the result of the creation process.
|
|
425
|
+
*/
|
|
426
|
+
export const create = async ( params ) => {
|
|
427
|
+
|
|
428
|
+
const res = await core.build( params )
|
|
429
|
+
await createTemplate( res )
|
|
430
|
+
return res
|
|
431
|
+
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
#### package.json
|
|
436
|
+
|
|
437
|
+
Create a package.json file with the following structure:
|
|
155
438
|
|
|
156
439
|
```json
|
|
157
440
|
{
|
|
@@ -161,18 +444,51 @@ export const create = async ( params ) => {
|
|
|
161
444
|
"main": "src/lib.js",
|
|
162
445
|
"module": "src/lib.js",
|
|
163
446
|
"bin": {
|
|
164
|
-
"create-{my-library-name}": "bin.js"
|
|
447
|
+
"create-{my-library-name}": "src/bin.js"
|
|
448
|
+
},
|
|
449
|
+
"scripts": {
|
|
450
|
+
"dev": "node src/bin.js",
|
|
165
451
|
},
|
|
166
452
|
"files": [
|
|
167
453
|
"src",
|
|
168
|
-
"
|
|
454
|
+
"data",
|
|
169
455
|
]
|
|
170
456
|
}
|
|
171
457
|
```
|
|
172
458
|
|
|
173
|
-
|
|
459
|
+
#### Data (templates & partials)
|
|
460
|
+
|
|
461
|
+
Create a data folder with your templates and your partials.
|
|
462
|
+
|
|
463
|
+
```text
|
|
464
|
+
📂 data
|
|
465
|
+
├── 📂 templates
|
|
466
|
+
│ ├── 📂 js-project
|
|
467
|
+
│ │ └── ... (files, folders...)
|
|
468
|
+
│ ├── 📂 ts-project
|
|
469
|
+
│ │ └── ... (files, folders...)
|
|
470
|
+
│ 📂 partials
|
|
471
|
+
│ ├── 📂 workspace (used in example)
|
|
472
|
+
│ │ └── ... (files, folders...)
|
|
473
|
+
│ └── 📂 .../
|
|
474
|
+
│
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
#### Execute
|
|
174
478
|
|
|
175
|
-
|
|
479
|
+
Once the package is published you can use it with:
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
npm create {my-library-name}
|
|
483
|
+
# or
|
|
484
|
+
pnpm create {my-library-name}
|
|
485
|
+
# or
|
|
486
|
+
yarn create {my-library-name}
|
|
487
|
+
# or
|
|
488
|
+
bun create {my-library-name}
|
|
489
|
+
# or
|
|
490
|
+
deno create {my-library-name}
|
|
491
|
+
```
|
|
176
492
|
|
|
177
493
|
|
|
178
494
|
## Api documentation
|
|
@@ -492,9 +808,21 @@ The result of the callback function.
|
|
|
492
808
|
###### cancel()
|
|
493
809
|
|
|
494
810
|
```ts
|
|
495
|
-
cancel(): Promise<void>
|
|
811
|
+
cancel(message?: string): Promise<void>
|
|
496
812
|
```
|
|
497
813
|
|
|
814
|
+
Cancels the current process and exits with code 0.
|
|
815
|
+
|
|
816
|
+
If a `message` is provided, it will be displayed in the console.
|
|
817
|
+
If `onCancel` is set in the config, it will be called with the current data.
|
|
818
|
+
If `onCancel` is not set, a default message will be displayed.
|
|
819
|
+
|
|
820
|
+
###### Parameters
|
|
821
|
+
|
|
822
|
+
| Parameter | Type | Description |
|
|
823
|
+
| ------ | ------ | ------ |
|
|
824
|
+
| `message`? | `string` | The message to display before exiting. |
|
|
825
|
+
|
|
498
826
|
###### Returns
|
|
499
827
|
|
|
500
828
|
`Promise`\<`void`\>
|
|
@@ -534,20 +862,37 @@ await core.cli( { args : process.argv.slice( 4), hideBin : false } )
|
|
|
534
862
|
###### copyDir()
|
|
535
863
|
|
|
536
864
|
```ts
|
|
537
|
-
copyDir(
|
|
865
|
+
copyDir(data: {
|
|
866
|
+
input: string;
|
|
867
|
+
output: string;
|
|
868
|
+
}): Promise<void>
|
|
538
869
|
```
|
|
539
870
|
|
|
871
|
+
Copy a directory from input path to output path.
|
|
872
|
+
|
|
540
873
|
###### Parameters
|
|
541
874
|
|
|
542
|
-
| Parameter | Type |
|
|
543
|
-
| ------ | ------ |
|
|
544
|
-
| `
|
|
545
|
-
| `
|
|
875
|
+
| Parameter | Type | Description |
|
|
876
|
+
| ------ | ------ | ------ |
|
|
877
|
+
| `data` | `object` | Options object with input and output paths. |
|
|
878
|
+
| `data.input` | `string` | The path to the directory to copy. |
|
|
879
|
+
| `data.output` | `string` | The path to the destination directory. |
|
|
546
880
|
|
|
547
881
|
###### Returns
|
|
548
882
|
|
|
549
883
|
`Promise`\<`void`\>
|
|
550
884
|
|
|
885
|
+
- Resolves when the directory has been copied.
|
|
886
|
+
|
|
887
|
+
###### Example
|
|
888
|
+
|
|
889
|
+
```ts
|
|
890
|
+
const copyResult = await core.copyDir({
|
|
891
|
+
input : '/path/to/sourceDir',
|
|
892
|
+
output: '/path/to/destinationDir',
|
|
893
|
+
})
|
|
894
|
+
```
|
|
895
|
+
|
|
551
896
|
###### createTemplate()
|
|
552
897
|
|
|
553
898
|
```ts
|
|
@@ -592,42 +937,89 @@ await core.createTemplate( {
|
|
|
592
937
|
###### getTemplateInput()
|
|
593
938
|
|
|
594
939
|
```ts
|
|
595
|
-
getTemplateInput(input?:
|
|
940
|
+
getTemplateInput(input?: {
|
|
941
|
+
input: string;
|
|
942
|
+
}): Promise<undefined | string>
|
|
596
943
|
```
|
|
597
944
|
|
|
945
|
+
Return the input path of a template by name or path.
|
|
946
|
+
|
|
598
947
|
###### Parameters
|
|
599
948
|
|
|
600
|
-
| Parameter | Type |
|
|
601
|
-
| ------ | ------ |
|
|
602
|
-
| `input`? | `
|
|
949
|
+
| Parameter | Type | Description |
|
|
950
|
+
| ------ | ------ | ------ |
|
|
951
|
+
| `input`? | `object` | The name of the template or the path to the template. |
|
|
952
|
+
| `input.input`? | `string` | - |
|
|
603
953
|
|
|
604
954
|
###### Returns
|
|
605
955
|
|
|
606
956
|
`Promise`\<`undefined` \| `string`\>
|
|
607
957
|
|
|
958
|
+
The input path of the template or undefined if not found.
|
|
959
|
+
|
|
960
|
+
###### Examples
|
|
961
|
+
|
|
962
|
+
```ts
|
|
963
|
+
// with template path
|
|
964
|
+
const input = await core.getTemplateInput( { input : 'my/template/path' } )
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
```ts
|
|
968
|
+
// With template key
|
|
969
|
+
// template key must be specified in the config prompt secction.
|
|
970
|
+
const input = await core.getTemplateInput( { input : 'templateKey' )
|
|
971
|
+
```
|
|
972
|
+
|
|
608
973
|
###### install()
|
|
609
974
|
|
|
610
975
|
```ts
|
|
611
|
-
install(
|
|
976
|
+
install(options?: {
|
|
977
|
+
input: string;
|
|
978
|
+
installer: Installer;
|
|
979
|
+
}): Promise<void>
|
|
612
980
|
```
|
|
613
981
|
|
|
982
|
+
Installs the project with the given package manager.
|
|
983
|
+
|
|
614
984
|
###### Parameters
|
|
615
985
|
|
|
616
|
-
| Parameter | Type |
|
|
617
|
-
| ------ | ------ |
|
|
618
|
-
| `
|
|
619
|
-
| `
|
|
986
|
+
| Parameter | Type | Description |
|
|
987
|
+
| ------ | ------ | ------ |
|
|
988
|
+
| `options`? | `object` | The options to install. |
|
|
989
|
+
| `options.input`? | `string` | The path to the folder. If not provided, the current directory is used. |
|
|
990
|
+
| `options.installer`? | `Installer` | The package manager to use for the installation. |
|
|
620
991
|
|
|
621
992
|
###### Returns
|
|
622
993
|
|
|
623
994
|
`Promise`\<`void`\>
|
|
624
995
|
|
|
996
|
+
###### Example
|
|
997
|
+
|
|
998
|
+
```ts
|
|
999
|
+
await core.install( {
|
|
1000
|
+
installer : 'pnpm',
|
|
1001
|
+
input : 'my/project/path',
|
|
1002
|
+
} )
|
|
1003
|
+
```
|
|
1004
|
+
|
|
625
1005
|
###### intro()
|
|
626
1006
|
|
|
627
1007
|
```ts
|
|
628
|
-
intro(): Promise<void>
|
|
1008
|
+
intro(message?: string): Promise<void>
|
|
629
1009
|
```
|
|
630
1010
|
|
|
1011
|
+
Intro prompt line.
|
|
1012
|
+
|
|
1013
|
+
If the parameter `message` is provided, it will be used as the intro message.
|
|
1014
|
+
If the `intro` option is a function, it will be called with the `this.#data` as the argument.
|
|
1015
|
+
If the `intro` option is undefined, the default intro message will be used.
|
|
1016
|
+
|
|
1017
|
+
###### Parameters
|
|
1018
|
+
|
|
1019
|
+
| Parameter | Type | Description |
|
|
1020
|
+
| ------ | ------ | ------ |
|
|
1021
|
+
| `message`? | `string` | The intro message. |
|
|
1022
|
+
|
|
631
1023
|
###### Returns
|
|
632
1024
|
|
|
633
1025
|
`Promise`\<`void`\>
|
|
@@ -635,26 +1027,53 @@ intro(): Promise<void>
|
|
|
635
1027
|
###### openEditor()
|
|
636
1028
|
|
|
637
1029
|
```ts
|
|
638
|
-
openEditor(
|
|
1030
|
+
openEditor(params: {
|
|
1031
|
+
editor: TextEditor;
|
|
1032
|
+
input: string;
|
|
1033
|
+
}): Promise<void>
|
|
639
1034
|
```
|
|
640
1035
|
|
|
1036
|
+
Open the project in the given editor.
|
|
1037
|
+
|
|
641
1038
|
###### Parameters
|
|
642
1039
|
|
|
643
|
-
| Parameter | Type |
|
|
644
|
-
| ------ | ------ |
|
|
645
|
-
| `
|
|
646
|
-
| `
|
|
1040
|
+
| Parameter | Type | Description |
|
|
1041
|
+
| ------ | ------ | ------ |
|
|
1042
|
+
| `params` | `object` | The parameters for opening the editor. |
|
|
1043
|
+
| `params.editor`? | `TextEditor` | The editor to open the project in. |
|
|
1044
|
+
| `params.input`? | `string` | The input path. If not provided, the current directory is used. |
|
|
647
1045
|
|
|
648
1046
|
###### Returns
|
|
649
1047
|
|
|
650
1048
|
`Promise`\<`void`\>
|
|
651
1049
|
|
|
1050
|
+
###### Example
|
|
1051
|
+
|
|
1052
|
+
```ts
|
|
1053
|
+
await core.openEditor( {
|
|
1054
|
+
editor : 'vscode',
|
|
1055
|
+
input : 'my/project/path',
|
|
1056
|
+
})
|
|
1057
|
+
```
|
|
1058
|
+
|
|
652
1059
|
###### outro()
|
|
653
1060
|
|
|
654
1061
|
```ts
|
|
655
|
-
outro(): Promise<void>
|
|
1062
|
+
outro(message?: string): Promise<void>
|
|
656
1063
|
```
|
|
657
1064
|
|
|
1065
|
+
Outro prompt line.
|
|
1066
|
+
|
|
1067
|
+
If the parameter `message` is provided, it will be used as the outro message.
|
|
1068
|
+
If the `outro` option is a function, it will be called with the `this.#data` as the argument.
|
|
1069
|
+
If the `outro` option is undefined, the default outro message will be used.
|
|
1070
|
+
|
|
1071
|
+
###### Parameters
|
|
1072
|
+
|
|
1073
|
+
| Parameter | Type | Description |
|
|
1074
|
+
| ------ | ------ | ------ |
|
|
1075
|
+
| `message`? | `string` | The outro message. |
|
|
1076
|
+
|
|
658
1077
|
###### Returns
|
|
659
1078
|
|
|
660
1079
|
`Promise`\<`void`\>
|
|
@@ -662,30 +1081,86 @@ outro(): Promise<void>
|
|
|
662
1081
|
###### replacePlaceholders()
|
|
663
1082
|
|
|
664
1083
|
```ts
|
|
665
|
-
replacePlaceholders(
|
|
1084
|
+
replacePlaceholders(args: {
|
|
1085
|
+
input: string;
|
|
1086
|
+
params: Params;
|
|
1087
|
+
}): Promise<void>
|
|
666
1088
|
```
|
|
667
1089
|
|
|
1090
|
+
Replaces placeholders in files within the specified directory.
|
|
1091
|
+
|
|
1092
|
+
This function searches for files in the provided input directory and replaces
|
|
1093
|
+
placeholders within those files using the specified parameters. The placeholders
|
|
1094
|
+
in the content are replaced with values from the `params` object.
|
|
1095
|
+
|
|
668
1096
|
###### Parameters
|
|
669
1097
|
|
|
670
|
-
| Parameter | Type |
|
|
671
|
-
| ------ | ------ |
|
|
672
|
-
| `
|
|
673
|
-
| `
|
|
1098
|
+
| Parameter | Type | Description |
|
|
1099
|
+
| ------ | ------ | ------ |
|
|
1100
|
+
| `args` | `object` | The arguments object. |
|
|
1101
|
+
| `args.input`? | `string` | The directory path containing files with placeholders. |
|
|
1102
|
+
| `args.params`? | `Params` | An object containing key-value pairs for replacing placeholders. |
|
|
674
1103
|
|
|
675
1104
|
###### Returns
|
|
676
1105
|
|
|
677
1106
|
`Promise`\<`void`\>
|
|
678
1107
|
|
|
1108
|
+
A Promise that resolves once all placeholders have been replaced.
|
|
1109
|
+
|
|
1110
|
+
###### Example
|
|
1111
|
+
|
|
1112
|
+
```ts
|
|
1113
|
+
await core.replacePlaceholders( {
|
|
1114
|
+
input : 'my/project/path',
|
|
1115
|
+
params : { placeholder1: 'value1', placeholder2: 'value2' },
|
|
1116
|
+
})
|
|
1117
|
+
```
|
|
1118
|
+
|
|
679
1119
|
###### updateNotify()
|
|
680
1120
|
|
|
681
1121
|
```ts
|
|
682
|
-
updateNotify(
|
|
1122
|
+
updateNotify(opts?: {
|
|
1123
|
+
custom: (info?: UpdateInfo) => Response<void>;
|
|
1124
|
+
opts: NotifyOptions;
|
|
1125
|
+
}): Promise<void>
|
|
683
1126
|
```
|
|
684
1127
|
|
|
1128
|
+
Shows a notification if the current package is outdated.
|
|
1129
|
+
|
|
1130
|
+
**information**: If this 'custom' function is provided, the default
|
|
1131
|
+
notification will not be shown.
|
|
1132
|
+
|
|
1133
|
+
---
|
|
1134
|
+
|
|
1135
|
+
###### Parameters
|
|
1136
|
+
|
|
1137
|
+
| Parameter | Type | Description |
|
|
1138
|
+
| ------ | ------ | ------ |
|
|
1139
|
+
| `opts`? | `object` | Options for the update notification. |
|
|
1140
|
+
| `opts.custom`? | (`info`?: `UpdateInfo`) => `Response`\<`void`\> | A custom function to run with the update |
|
|
1141
|
+
| `opts.opts`? | `NotifyOptions` | Options for the `update-notifier` package. |
|
|
1142
|
+
|
|
685
1143
|
###### Returns
|
|
686
1144
|
|
|
687
1145
|
`Promise`\<`void`\>
|
|
688
1146
|
|
|
1147
|
+
###### Examples
|
|
1148
|
+
|
|
1149
|
+
```ts
|
|
1150
|
+
// With default options. Recommended for most use cases.
|
|
1151
|
+
await core.updateNotify()
|
|
1152
|
+
```
|
|
1153
|
+
|
|
1154
|
+
```ts
|
|
1155
|
+
// With custom options
|
|
1156
|
+
await core.updateNotify({ opts: { ... } })
|
|
1157
|
+
```
|
|
1158
|
+
|
|
1159
|
+
```ts
|
|
1160
|
+
// With custom function
|
|
1161
|
+
await core.updateNotify({ custom: () => {} })
|
|
1162
|
+
```
|
|
1163
|
+
|
|
689
1164
|
##### Properties
|
|
690
1165
|
|
|
691
1166
|
| Property | Type |
|
|
@@ -820,28 +1295,6 @@ Environment functions
|
|
|
820
1295
|
|
|
821
1296
|
***
|
|
822
1297
|
|
|
823
|
-
#### IDE
|
|
824
|
-
|
|
825
|
-
```ts
|
|
826
|
-
const IDE: {
|
|
827
|
-
NONE: 'none';
|
|
828
|
-
SUBLIME: 'subl';
|
|
829
|
-
VSCODE: 'code';
|
|
830
|
-
WEBSTORM: 'webstorm';
|
|
831
|
-
};
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
##### Type declaration
|
|
835
|
-
|
|
836
|
-
| Name | Type | Default value |
|
|
837
|
-
| ------ | ------ | ------ |
|
|
838
|
-
| `NONE` | `"none"` | 'none' |
|
|
839
|
-
| `SUBLIME` | `"subl"` | 'subl' |
|
|
840
|
-
| `VSCODE` | `"code"` | 'code' |
|
|
841
|
-
| `WEBSTORM` | `"webstorm"` | 'webstorm' |
|
|
842
|
-
|
|
843
|
-
***
|
|
844
|
-
|
|
845
1298
|
#### INSTALLER
|
|
846
1299
|
|
|
847
1300
|
```ts
|
|
@@ -855,6 +1308,8 @@ const INSTALLER: {
|
|
|
855
1308
|
};
|
|
856
1309
|
```
|
|
857
1310
|
|
|
1311
|
+
installer values used in `install` option.
|
|
1312
|
+
|
|
858
1313
|
##### Type declaration
|
|
859
1314
|
|
|
860
1315
|
| Name | Type | Default value |
|
|
@@ -1044,6 +1499,30 @@ const sys: __module = _sys;
|
|
|
1044
1499
|
|
|
1045
1500
|
System functions
|
|
1046
1501
|
|
|
1502
|
+
***
|
|
1503
|
+
|
|
1504
|
+
#### TEXT\_EDITOR
|
|
1505
|
+
|
|
1506
|
+
```ts
|
|
1507
|
+
const TEXT_EDITOR: {
|
|
1508
|
+
NONE: 'none';
|
|
1509
|
+
SUBLIME: 'subl';
|
|
1510
|
+
VSCODE: 'code';
|
|
1511
|
+
WEBSTORM: 'webstorm';
|
|
1512
|
+
};
|
|
1513
|
+
```
|
|
1514
|
+
|
|
1515
|
+
Text editor values used in `openEditor` option.
|
|
1516
|
+
|
|
1517
|
+
##### Type declaration
|
|
1518
|
+
|
|
1519
|
+
| Name | Type | Default value |
|
|
1520
|
+
| ------ | ------ | ------ |
|
|
1521
|
+
| `NONE` | `"none"` | 'none' |
|
|
1522
|
+
| `SUBLIME` | `"subl"` | 'subl' |
|
|
1523
|
+
| `VSCODE` | `"code"` | 'code' |
|
|
1524
|
+
| `WEBSTORM` | `"webstorm"` | 'webstorm' |
|
|
1525
|
+
|
|
1047
1526
|
|
|
1048
1527
|
***
|
|
1049
1528
|
|