create-smore-game 0.2.0 → 0.2.1
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/index.js +30 -15
- package/package.json +1 -1
- package/templates.js +1517 -133
package/index.js
CHANGED
|
@@ -4,13 +4,16 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import prompts from "prompts";
|
|
6
6
|
import {
|
|
7
|
-
pnpmWorkspace,
|
|
8
7
|
rootPackageJson,
|
|
8
|
+
envExample,
|
|
9
9
|
screenReactPhaser,
|
|
10
10
|
screenReact,
|
|
11
11
|
screenVanilla,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
controllerReact,
|
|
13
|
+
controllerVanilla,
|
|
14
|
+
devServer,
|
|
15
|
+
devHarness,
|
|
16
|
+
devControllerPage,
|
|
14
17
|
} from "./templates.js";
|
|
15
18
|
|
|
16
19
|
const args = process.argv.slice(2);
|
|
@@ -31,7 +34,7 @@ async function main() {
|
|
|
31
34
|
{
|
|
32
35
|
type: "select",
|
|
33
36
|
name: "screen",
|
|
34
|
-
message: "Screen (
|
|
37
|
+
message: "Screen (TV) template:",
|
|
35
38
|
choices: [
|
|
36
39
|
{ title: "React + Phaser", value: "react-phaser" },
|
|
37
40
|
{ title: "React only", value: "react" },
|
|
@@ -40,8 +43,8 @@ async function main() {
|
|
|
40
43
|
},
|
|
41
44
|
{
|
|
42
45
|
type: "select",
|
|
43
|
-
name: "
|
|
44
|
-
message: "
|
|
46
|
+
name: "controller",
|
|
47
|
+
message: "Controller (phone) template:",
|
|
45
48
|
choices: [
|
|
46
49
|
{ title: "React", value: "react" },
|
|
47
50
|
{ title: "Vanilla JS", value: "vanilla" },
|
|
@@ -68,27 +71,29 @@ async function main() {
|
|
|
68
71
|
? screenReact(gameId)
|
|
69
72
|
: screenVanilla(gameId);
|
|
70
73
|
|
|
71
|
-
const
|
|
72
|
-
response.
|
|
74
|
+
const controllerFiles =
|
|
75
|
+
response.controller === "react" ? controllerReact(gameId) : controllerVanilla(gameId);
|
|
73
76
|
|
|
74
77
|
// Write root files
|
|
75
78
|
writeFile(root, "package.json", rootPackageJson(projectName));
|
|
76
|
-
writeFile(root, "pnpm-workspace.yaml", pnpmWorkspace);
|
|
77
79
|
writeFile(
|
|
78
80
|
root,
|
|
79
81
|
".gitignore",
|
|
80
|
-
"node_modules\ndist\n*.local\n.DS_Store\n",
|
|
82
|
+
"node_modules\ndist\n*.local\n.DS_Store\n.env\n",
|
|
81
83
|
);
|
|
84
|
+
writeFile(root, ".env.example", envExample());
|
|
82
85
|
writeFile(
|
|
83
86
|
root,
|
|
84
87
|
"game.json",
|
|
85
88
|
JSON.stringify(
|
|
86
89
|
{
|
|
90
|
+
id: gameId,
|
|
87
91
|
title: projectName,
|
|
88
92
|
description: "",
|
|
89
93
|
minPlayers: 2,
|
|
90
94
|
maxPlayers: 8,
|
|
91
95
|
categories: ["party"],
|
|
96
|
+
version: "0.1.0",
|
|
92
97
|
},
|
|
93
98
|
null,
|
|
94
99
|
2,
|
|
@@ -100,16 +105,26 @@ async function main() {
|
|
|
100
105
|
writeFile(path.join(root, "screen"), filePath, content);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
// Write
|
|
104
|
-
for (const [filePath, content] of Object.entries(
|
|
105
|
-
writeFile(path.join(root, "
|
|
108
|
+
// Write controller files
|
|
109
|
+
for (const [filePath, content] of Object.entries(controllerFiles)) {
|
|
110
|
+
writeFile(path.join(root, "controller"), filePath, content);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Write dev server files
|
|
114
|
+
const devFiles = {
|
|
115
|
+
...devServer(gameId),
|
|
116
|
+
...devHarness(gameId),
|
|
117
|
+
...devControllerPage(gameId),
|
|
118
|
+
};
|
|
119
|
+
for (const [filePath, content] of Object.entries(devFiles)) {
|
|
120
|
+
writeFile(root, filePath, content);
|
|
106
121
|
}
|
|
107
122
|
|
|
108
123
|
console.log(`\n Done! Created ${projectName}/\n`);
|
|
109
124
|
console.log(" Next steps:\n");
|
|
110
125
|
console.log(` cd ${projectName}`);
|
|
111
|
-
console.log("
|
|
112
|
-
console.log("
|
|
126
|
+
console.log(" npm install");
|
|
127
|
+
console.log(" npm run dev\n");
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
function writeFile(dir, filePath, content) {
|