create-yeow 0.2.48 → 0.2.50
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/bin/index.js +24 -20
- package/package.json +1 -1
- package/templates/default/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { mkdirSync, writeFileSync, readFileSync, existsSync, cpSync, rmSync } fr
|
|
|
3
3
|
import { resolve, dirname } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { createInterface } from 'readline';
|
|
6
|
+
import { emitKeypressEvents } from 'readline';
|
|
6
7
|
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const argv = process.argv.slice(2);
|
|
@@ -23,37 +24,40 @@ async function prompt(q, def) {
|
|
|
23
24
|
|
|
24
25
|
async function selectLanguage() {
|
|
25
26
|
const modes = ['JavaScript', 'TypeScript'];
|
|
26
|
-
let idx = 0;
|
|
27
|
-
_(`\n ${c.C}Language${c.r}
|
|
27
|
+
let idx = 0;
|
|
28
|
+
_(`\n ${c.C}Language${c.r} ${c.d}press Tab to switch · Enter to confirm${c.r}\n`);
|
|
29
|
+
const render = () => {
|
|
30
|
+
_('\x1b[1A\x1b[2K\r');
|
|
31
|
+
_(' ' + modes.map((m, i) => i === idx
|
|
32
|
+
? ` ${c.g}${c.b}▸ ${m} ◂${c.r} `
|
|
33
|
+
: ` ${c.d} ${m} ${c.r} `
|
|
34
|
+
).join('') + '\n');
|
|
35
|
+
};
|
|
36
|
+
render();
|
|
28
37
|
return new Promise(resolve => {
|
|
29
|
-
|
|
30
|
-
process.stdin.setRawMode(true);
|
|
38
|
+
emitKeypressEvents(process.stdin);
|
|
39
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
31
40
|
process.stdin.resume();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (key === '\t') {
|
|
41
|
+
const onKey = (str, key) => {
|
|
42
|
+
if (key.name === 'tab') {
|
|
35
43
|
idx = (idx + 1) % modes.length;
|
|
36
44
|
render();
|
|
37
|
-
} else if (key === '
|
|
38
|
-
process.stdin.
|
|
45
|
+
} else if (key.name === 'return' || key.name === 'enter') {
|
|
46
|
+
process.stdin.removeListener('keypress', onKey);
|
|
47
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
39
48
|
process.stdin.pause();
|
|
40
|
-
|
|
49
|
+
_('\x1b[1A\x1b[2K\r');
|
|
41
50
|
_(` ${c.g}→${c.r} ${modes[idx]}\n`);
|
|
42
51
|
resolve(modes[idx] === 'TypeScript');
|
|
43
|
-
} else if (key === '
|
|
52
|
+
} else if (key.name === 'escape' || (key.ctrl && key.name === 'c')) {
|
|
44
53
|
process.exit(0);
|
|
45
54
|
}
|
|
46
|
-
});
|
|
47
|
-
const render = () => {
|
|
48
|
-
// Move up one line and clear
|
|
49
|
-
_('\x1b[1A\x1b[2K\r');
|
|
50
|
-
_(' ' + modes.map((m, i) => i === idx ? `${c.g}${c.b} ${m} ${c.r}` : `${c.d} ${m} ${c.r}`).join(''));
|
|
51
55
|
};
|
|
52
|
-
|
|
56
|
+
process.stdin.on('keypress', onKey);
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
_(`\n ${c.b}${c.B}Yeow
|
|
60
|
+
_(`\n ${c.b}${c.B}Yeow v${c.r} ${c.d}— plugin scaffolding${c.r}\n\n`);
|
|
57
61
|
if (yes) _(` ${c.d}non-interactive mode${c.r}\n`);
|
|
58
62
|
|
|
59
63
|
let name, author, desc, useTs, enableTypeCheck;
|
|
@@ -61,7 +65,7 @@ if (yes) {
|
|
|
61
65
|
name = val('--name=') || 'my-yeow-plugin';
|
|
62
66
|
author = val('--author=') || '';
|
|
63
67
|
desc = val('--desc=') || 'A Yeow plugin';
|
|
64
|
-
useTs = flag('--ts')
|
|
68
|
+
useTs = flag('--ts');
|
|
65
69
|
enableTypeCheck = useTs && !flag('--no-typecheck');
|
|
66
70
|
} else {
|
|
67
71
|
name = await prompt('Project name', 'my-yeow-plugin');
|
|
@@ -111,6 +115,6 @@ _(` npm install\n`);
|
|
|
111
115
|
_(` npm run dev${c.d} # start dev server${c.r}\n`);
|
|
112
116
|
_(` npm run build${c.d} # build plugin JAR${c.r}\n`);
|
|
113
117
|
if (useTs && enableTypeCheck) {
|
|
114
|
-
_(` ${c.d}(typecheck enabled, set "typecheck"
|
|
118
|
+
_(` ${c.d}(typecheck enabled, set "typecheck" false in yeow.config.json to disable)${c.r}\n`);
|
|
115
119
|
}
|
|
116
120
|
_('\n');
|
package/package.json
CHANGED