create-smore-game 0.1.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 +45 -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,16 +71,33 @@ 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",
|
|
83
|
+
);
|
|
84
|
+
writeFile(root, ".env.example", envExample());
|
|
85
|
+
writeFile(
|
|
86
|
+
root,
|
|
87
|
+
"game.json",
|
|
88
|
+
JSON.stringify(
|
|
89
|
+
{
|
|
90
|
+
id: gameId,
|
|
91
|
+
title: projectName,
|
|
92
|
+
description: "",
|
|
93
|
+
minPlayers: 2,
|
|
94
|
+
maxPlayers: 8,
|
|
95
|
+
categories: ["party"],
|
|
96
|
+
version: "0.1.0",
|
|
97
|
+
},
|
|
98
|
+
null,
|
|
99
|
+
2,
|
|
100
|
+
),
|
|
81
101
|
);
|
|
82
102
|
|
|
83
103
|
// Write screen files
|
|
@@ -85,16 +105,26 @@ async function main() {
|
|
|
85
105
|
writeFile(path.join(root, "screen"), filePath, content);
|
|
86
106
|
}
|
|
87
107
|
|
|
88
|
-
// Write
|
|
89
|
-
for (const [filePath, content] of Object.entries(
|
|
90
|
-
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);
|
|
91
121
|
}
|
|
92
122
|
|
|
93
123
|
console.log(`\n Done! Created ${projectName}/\n`);
|
|
94
124
|
console.log(" Next steps:\n");
|
|
95
125
|
console.log(` cd ${projectName}`);
|
|
96
|
-
console.log("
|
|
97
|
-
console.log("
|
|
126
|
+
console.log(" npm install");
|
|
127
|
+
console.log(" npm run dev\n");
|
|
98
128
|
}
|
|
99
129
|
|
|
100
130
|
function writeFile(dir, filePath, content) {
|