create-yeow 0.2.47 → 0.2.48
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
CHANGED
|
@@ -21,21 +21,54 @@ async function prompt(q, def) {
|
|
|
21
21
|
return new Promise(r => rl.question(` ${c.C}${q}${hint}: `, a => { rl.close(); r(a.trim() || def); }));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
async function selectLanguage() {
|
|
25
|
+
const modes = ['JavaScript', 'TypeScript'];
|
|
26
|
+
let idx = 0; // JavaScript default
|
|
27
|
+
_(`\n ${c.C}Language${c.r} ${c.d}Tab to switch, Enter to confirm${c.r}\n`);
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
30
|
+
process.stdin.setRawMode(true);
|
|
31
|
+
process.stdin.resume();
|
|
32
|
+
process.stdin.on('data', (buf) => {
|
|
33
|
+
const key = buf.toString();
|
|
34
|
+
if (key === '\t') {
|
|
35
|
+
idx = (idx + 1) % modes.length;
|
|
36
|
+
render();
|
|
37
|
+
} else if (key === '\r' || key === '\n') {
|
|
38
|
+
process.stdin.setRawMode(false);
|
|
39
|
+
process.stdin.pause();
|
|
40
|
+
rl.close();
|
|
41
|
+
_(` ${c.g}→${c.r} ${modes[idx]}\n`);
|
|
42
|
+
resolve(modes[idx] === 'TypeScript');
|
|
43
|
+
} else if (key === '\x03') {
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
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
|
+
};
|
|
52
|
+
render();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
24
56
|
_(`\n ${c.b}${c.B}Yeow v0${c.r} ${c.d}— plugin scaffolding${c.r}\n\n`);
|
|
25
57
|
if (yes) _(` ${c.d}non-interactive mode${c.r}\n`);
|
|
26
58
|
|
|
27
|
-
let name, author, desc, useTs;
|
|
59
|
+
let name, author, desc, useTs, enableTypeCheck;
|
|
28
60
|
if (yes) {
|
|
29
61
|
name = val('--name=') || 'my-yeow-plugin';
|
|
30
62
|
author = val('--author=') || '';
|
|
31
63
|
desc = val('--desc=') || 'A Yeow plugin';
|
|
32
64
|
useTs = flag('--ts') || !flag('--js');
|
|
65
|
+
enableTypeCheck = useTs && !flag('--no-typecheck');
|
|
33
66
|
} else {
|
|
34
67
|
name = await prompt('Project name', 'my-yeow-plugin');
|
|
35
68
|
author = await prompt('Author', '');
|
|
36
69
|
desc = await prompt('Description', 'A Yeow plugin');
|
|
37
|
-
|
|
38
|
-
useTs =
|
|
70
|
+
useTs = await selectLanguage();
|
|
71
|
+
if (useTs) enableTypeCheck = true;
|
|
39
72
|
}
|
|
40
73
|
|
|
41
74
|
const tpl = resolve(__dirname, '..', 'templates', 'default');
|
|
@@ -54,10 +87,12 @@ const pkg = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'));
|
|
|
54
87
|
pkg.name = name.toLowerCase().replace(/[^a-z0-9-]/g,'-').replace(/-+/g,'-').replace(/^-|-$/g,'');
|
|
55
88
|
if (author) pkg.author = author;
|
|
56
89
|
pkg.description = desc;
|
|
90
|
+
|
|
57
91
|
writeFileSync(resolve(dir, 'package.json'), JSON.stringify(pkg, null, 2)+'\n');
|
|
58
92
|
|
|
59
93
|
const cfg = JSON.parse(readFileSync(resolve(dir, 'yeow.config.json'), 'utf-8'));
|
|
60
94
|
cfg.name = name; cfg.author = author; cfg.description = desc;
|
|
95
|
+
if (useTs) cfg.typecheck = enableTypeCheck;
|
|
61
96
|
writeFileSync(resolve(dir, 'yeow.config.json'), JSON.stringify(cfg, null, 4)+'\n');
|
|
62
97
|
|
|
63
98
|
if (!useTs) {
|
|
@@ -69,8 +104,13 @@ if (!useTs) {
|
|
|
69
104
|
rmSync(resolve(dir, 'src', 'index.js'), { force: true });
|
|
70
105
|
}
|
|
71
106
|
|
|
72
|
-
_(
|
|
107
|
+
_('\n');
|
|
108
|
+
ok(`${c.b}Done!${c.r}\n`);
|
|
73
109
|
_(` cd ${name}\n`);
|
|
74
110
|
_(` npm install\n`);
|
|
75
111
|
_(` npm run dev${c.d} # start dev server${c.r}\n`);
|
|
76
|
-
_(` npm run build${c.d} # build plugin JAR${c.r}\n
|
|
112
|
+
_(` npm run build${c.d} # build plugin JAR${c.r}\n`);
|
|
113
|
+
if (useTs && enableTypeCheck) {
|
|
114
|
+
_(` ${c.d}(typecheck enabled, set "typecheck": false in yeow.config.json to disable)${c.r}\n`);
|
|
115
|
+
}
|
|
116
|
+
_('\n');
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -3,11 +3,24 @@ import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync, readdirSy
|
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import AdmZip from 'adm-zip';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
6
7
|
|
|
7
8
|
const root = resolve(fileURLToPath(import.meta.url), '..', '..');
|
|
8
9
|
const cfg = JSON.parse(readFileSync(resolve(root, 'yeow.config.json'), 'utf-8'));
|
|
9
10
|
const { name, version } = cfg;
|
|
10
|
-
const
|
|
11
|
+
const isTs = existsSync(resolve(root, 'src', 'index.ts'));
|
|
12
|
+
const entry = isTs ? 'src/index.ts' : 'src/index.js';
|
|
13
|
+
|
|
14
|
+
// Optional type check for TypeScript projects
|
|
15
|
+
if (isTs && cfg.typecheck !== false) {
|
|
16
|
+
try {
|
|
17
|
+
execSync('npx -p typescript tsc --noEmit', { cwd: root, stdio: 'pipe' });
|
|
18
|
+
console.log(' ✓ Type check passed');
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(' ✗ Type check failed — run with typecheck=false or set "typecheck": false in yeow.config.json');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
11
24
|
|
|
12
25
|
const outDir = resolve(root, 'dist', '.yeow');
|
|
13
26
|
mkdirSync(outDir, { recursive: true });
|