@yeow/create-yeow 0.1.3 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeow/create-yeow",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Scaffold a Yeow plugin project",
5
5
  "bin": {
6
6
  "create-yeow": "./bin/index.js"
@@ -44,7 +44,7 @@ async function promptProxy(devConfig) {
44
44
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
45
45
  const answer = await new Promise((resolve) => {
46
46
  const hint = currentProxy ? ` (current: ${c.cyan}${currentProxy}${c.reset})` : '';
47
- log(` ${c.yellow}Configure proxy to download PaperMC server JAR`);
47
+ console.log(` ${c.yellow}Configure proxy to download PaperMC server JAR`);
48
48
  rl.question(` ${c.yellow}Proxy address${c.reset}${hint} [blank to skip]: `, (val) => {
49
49
  rl.close();
50
50
  resolve(val);
@@ -231,7 +231,7 @@ function handleCtrlC() {
231
231
  ctrlCTimer = setTimeout(() => { ctrlCPressCount = 0; ctrlCTimer = null; }, DOUBLE_CTRL_C_WINDOW);
232
232
  }
233
233
 
234
- function startHotReloadWatcher() {
234
+ function startHotReloadWatcher(yeowConfig) {
235
235
  const srcDir = path.resolve(__dirname, '../src');
236
236
  if (!fs.existsSync(srcDir)) return;
237
237
 
@@ -245,7 +245,14 @@ function startHotReloadWatcher() {
245
245
  logInfo('Source file changed, rebuilding...');
246
246
  try {
247
247
  execSync('node .yeow/build.js', { stdio: 'pipe', cwd: path.resolve(__dirname, '..') });
248
- logOk('Hot reload file updated');
248
+
249
+ const compiledPath = path.resolve(__dirname, '../dist/.yeow/main.js');
250
+ if (fs.existsSync(compiledPath)) {
251
+ const devDir = path.join(SERVER_DIR, 'plugins', 'Yeow-Dev', yeowConfig.plugin.name);
252
+ fs.mkdirSync(devDir, { recursive: true });
253
+ fs.writeFileSync(path.join(devDir, 'main.js'), fs.readFileSync(compiledPath));
254
+ logOk('Hot reload file updated');
255
+ }
249
256
  } catch (e) {
250
257
  logFail('Build failed: ' + e.message);
251
258
  }
@@ -317,7 +324,7 @@ async function main() {
317
324
  console.log(` ${c.info} Local address: ${c.bold}${c.cyan}127.0.0.1:${devConfig.port}${c.reset}`);
318
325
  console.log(` ${c.dim} Server directory: ${path.relative(process.cwd(), SERVER_DIR)}${c.reset}`);
319
326
 
320
- startHotReloadWatcher();
327
+ startHotReloadWatcher(yeowConfig);
321
328
  startServer(devConfig);
322
329
  }
323
330
 
@@ -44,7 +44,7 @@ async function promptProxy(devConfig) {
44
44
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
45
45
  const answer = await new Promise((resolve) => {
46
46
  const hint = currentProxy ? ` (current: ${c.cyan}${currentProxy}${c.reset})` : '';
47
- log(` ${c.yellow}Configure proxy to download PaperMC server JAR`);
47
+ console.log(` ${c.yellow}Configure proxy to download PaperMC server JAR`);
48
48
  rl.question(` ${c.yellow}Proxy address${c.reset}${hint} [blank to skip]: `, (val) => {
49
49
  rl.close();
50
50
  resolve(val);
@@ -231,13 +231,13 @@ function handleCtrlC() {
231
231
  ctrlCTimer = setTimeout(() => { ctrlCPressCount = 0; ctrlCTimer = null; }, DOUBLE_CTRL_C_WINDOW);
232
232
  }
233
233
 
234
- function startHotReloadWatcher() {
234
+ function startHotReloadWatcher(yeowConfig) {
235
235
  const srcDir = path.resolve(__dirname, '../src');
236
236
  if (!fs.existsSync(srcDir)) return;
237
237
 
238
238
  let debounceTimer = null;
239
239
  srcWatcher = fs.watch(srcDir, { recursive: true }, (eventType, filename) => {
240
- if (!filename || !filename.endsWith('.js')) return;
240
+ if (!filename || !filename.endsWith('.ts')) return;
241
241
  if (isCompiling) return;
242
242
  if (debounceTimer) clearTimeout(debounceTimer);
243
243
  debounceTimer = setTimeout(async () => {
@@ -245,7 +245,14 @@ function startHotReloadWatcher() {
245
245
  logInfo('Source file changed, rebuilding...');
246
246
  try {
247
247
  execSync('node .yeow/build.js', { stdio: 'pipe', cwd: path.resolve(__dirname, '..') });
248
- logOk('Hot reload file updated');
248
+
249
+ const compiledPath = path.resolve(__dirname, '../dist/.yeow/main.js');
250
+ if (fs.existsSync(compiledPath)) {
251
+ const devDir = path.join(SERVER_DIR, 'plugins', 'Yeow-Dev', yeowConfig.plugin.name);
252
+ fs.mkdirSync(devDir, { recursive: true });
253
+ fs.writeFileSync(path.join(devDir, 'main.js'), fs.readFileSync(compiledPath));
254
+ logOk('Hot reload file updated');
255
+ }
249
256
  } catch (e) {
250
257
  logFail('Build failed: ' + e.message);
251
258
  }
@@ -317,7 +324,7 @@ async function main() {
317
324
  console.log(` ${c.info} Local address: ${c.bold}${c.cyan}127.0.0.1:${devConfig.port}${c.reset}`);
318
325
  console.log(` ${c.dim} Server directory: ${path.relative(process.cwd(), SERVER_DIR)}${c.reset}`);
319
326
 
320
- startHotReloadWatcher();
327
+ startHotReloadWatcher(yeowConfig);
321
328
  startServer(devConfig);
322
329
  }
323
330