hytopia 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/bin/scripts.js +28 -10
  2. package/package.json +1 -1
package/bin/scripts.js CHANGED
@@ -6,6 +6,14 @@ const path = require('path');
6
6
 
7
7
  (async () => {
8
8
  const command = process.argv[2];
9
+ const flags = {};
10
+ for (let i = 3; i < process.argv.length; i += 2) {
11
+ if (i % 2 === 1) { // Odd indices are flags
12
+ const flag = process.argv[i].replace('--', '');
13
+ const value = process.argv[i + 1];
14
+ flags[flag] = value;
15
+ }
16
+ }
9
17
 
10
18
  /**
11
19
  * Init command
@@ -17,17 +25,27 @@ const path = require('path');
17
25
  * `bunx hytopia init my-project-name`
18
26
  */
19
27
  if (command === 'init') {
20
- const srcDir = path.join(__dirname, '..', 'boilerplate');
21
28
  const destDir = process.cwd();
22
-
23
- // Initialize project
24
- console.log('🔧 Initializing project');
25
- execSync('bun init --yes');
26
- execSync('bun add hytopia');
27
-
28
- // Copy boilerplate
29
- console.log(`🖨️ Copying boilerplate to ${destDir}`);
30
- fs.cpSync(srcDir, destDir, { recursive: true });
29
+
30
+ if (flags.template) {
31
+ console.log(`🔧 Initializing project with examples template ${flags.template}`);
32
+
33
+ const templateDir = path.join(__dirname, '..', 'examples', flags.template);
34
+
35
+ if (!fs.existsSync(templateDir)) {
36
+ console.error(`Examples template ${flags.template} does not exist in the examples directory, could not initialize project!`);
37
+ return;
38
+ }
39
+
40
+ fs.cpSync(templateDir, destDir, { recursive: true });
41
+ execSync('bun install');
42
+ } else {
43
+ console.log('🔧 Initializing project');
44
+ execSync('bun init --yes');
45
+ execSync('bun add hytopia');
46
+
47
+ fs.cpSync(srcDir, destDir, { recursive: true });
48
+ }
31
49
 
32
50
  // Done, lfg!
33
51
  console.log('🚀 Hytopia project initialized successfully!');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create multiplayer games on the HYTOPIA platform using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {