create-yeow 0.2.47 → 0.2.49

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,57 @@ 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
- _(`\n ${c.b}${c.B}Yeow v0${c.r} ${c.d}— plugin scaffolding${c.r}\n\n`);
24
+ async function selectLanguage() {
25
+ const modes = ['JavaScript', 'TypeScript'];
26
+ let idx = 0;
27
+ _(`\n ${c.C}Language${c.r} ${c.d}press Tab to switch · Enter to confirm${c.r}\n`);
28
+ const render = () => {
29
+ _('\x1b[1A\x1b[2K\r');
30
+ _(' ' + modes.map((m, i) => i === idx
31
+ ? ` ${c.g}${c.b}▸ ${m} ◂${c.r} `
32
+ : ` ${c.d} ${m} ${c.r} `
33
+ ).join('') + '\n');
34
+ };
35
+ render();
36
+ return new Promise(resolve => {
37
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
38
+ process.stdin.setRawMode(true);
39
+ process.stdin.resume();
40
+ process.stdin.on('data', (buf) => {
41
+ const key = buf.toString();
42
+ if (key === '\t') {
43
+ idx = (idx + 1) % modes.length;
44
+ render();
45
+ } else if (key === '\r' || key === '\n') {
46
+ process.stdin.setRawMode(false);
47
+ process.stdin.pause();
48
+ rl.close();
49
+ _('\x1b[1A\x1b[2K\r');
50
+ _(` ${c.g}→${c.r} ${modes[idx]}\n`);
51
+ resolve(modes[idx] === 'TypeScript');
52
+ } else if (key === '\x03') {
53
+ process.exit(0);
54
+ }
55
+ });
56
+ });
57
+ }
58
+
59
+ _(`\n ${c.b}${c.B}Yeow v${c.r} ${c.d}— plugin scaffolding${c.r}\n\n`);
25
60
  if (yes) _(` ${c.d}non-interactive mode${c.r}\n`);
26
61
 
27
- let name, author, desc, useTs;
62
+ let name, author, desc, useTs, enableTypeCheck;
28
63
  if (yes) {
29
64
  name = val('--name=') || 'my-yeow-plugin';
30
65
  author = val('--author=') || '';
31
66
  desc = val('--desc=') || 'A Yeow plugin';
32
- useTs = flag('--ts') || !flag('--js');
67
+ useTs = flag('--ts');
68
+ enableTypeCheck = useTs && !flag('--no-typecheck');
33
69
  } else {
34
70
  name = await prompt('Project name', 'my-yeow-plugin');
35
71
  author = await prompt('Author', '');
36
72
  desc = await prompt('Description', 'A Yeow plugin');
37
- const lang = await prompt('Language (TS/JS)', 'TS');
38
- useTs = !lang.toLowerCase().startsWith('j');
73
+ useTs = await selectLanguage();
74
+ if (useTs) enableTypeCheck = true;
39
75
  }
40
76
 
41
77
  const tpl = resolve(__dirname, '..', 'templates', 'default');
@@ -54,10 +90,12 @@ const pkg = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'));
54
90
  pkg.name = name.toLowerCase().replace(/[^a-z0-9-]/g,'-').replace(/-+/g,'-').replace(/^-|-$/g,'');
55
91
  if (author) pkg.author = author;
56
92
  pkg.description = desc;
93
+
57
94
  writeFileSync(resolve(dir, 'package.json'), JSON.stringify(pkg, null, 2)+'\n');
58
95
 
59
96
  const cfg = JSON.parse(readFileSync(resolve(dir, 'yeow.config.json'), 'utf-8'));
60
97
  cfg.name = name; cfg.author = author; cfg.description = desc;
98
+ if (useTs) cfg.typecheck = enableTypeCheck;
61
99
  writeFileSync(resolve(dir, 'yeow.config.json'), JSON.stringify(cfg, null, 4)+'\n');
62
100
 
63
101
  if (!useTs) {
@@ -69,8 +107,13 @@ if (!useTs) {
69
107
  rmSync(resolve(dir, 'src', 'index.js'), { force: true });
70
108
  }
71
109
 
72
- _(`\n ${c.g}✓${c.r} ${c.b}Done!${c.r}\n\n`);
110
+ _('\n');
111
+ ok(`${c.b}Done!${c.r}\n`);
73
112
  _(` cd ${name}\n`);
74
113
  _(` npm install\n`);
75
114
  _(` npm run dev${c.d} # start dev server${c.r}\n`);
76
- _(` npm run build${c.d} # build plugin JAR${c.r}\n\n`);
115
+ _(` npm run build${c.d} # build plugin JAR${c.r}\n`);
116
+ if (useTs && enableTypeCheck) {
117
+ _(` ${c.d}(typecheck enabled, set "typecheck" false in yeow.config.json to disable)${c.r}\n`);
118
+ }
119
+ _('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-yeow",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "description": "Scaffold a Yeow plugin project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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 entry = existsSync(resolve(root, 'src', 'index.ts')) ? 'src/index.ts' : 'src/index.js';
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 });
@@ -7,8 +7,8 @@
7
7
  "dev": "node .yeow/dev-server.js"
8
8
  },
9
9
  "dependencies": {
10
- "yeow-api": "^0.2.31",
11
- "yeow-utils": "^0.1.2"
10
+ "yeow-api": "^0.2.34",
11
+ "yeow-utils": "^0.1.4"
12
12
  },
13
13
  "devDependencies": {
14
14
  "esbuild": "^0.25.0",