hytopia 0.1.16 → 0.1.18
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/scripts.js +28 -10
- 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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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