@inglorious/create-game 1.0.0 → 1.0.2

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/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { execSync } from "child_process"
4
4
  import fs from "fs"
5
+ import ora from "ora"
5
6
  import { EOL } from "os"
6
7
  import path from "path"
7
8
  import prompts from "prompts"
@@ -71,59 +72,56 @@ async function main() {
71
72
  return
72
73
  }
73
74
 
74
- const targetDir = path.join(process.cwd(), projectName)
75
- const templateDir = path.join(templatesRoot, template)
75
+ const spinner = ora(`Creating project "${projectName}"...`).start()
76
76
 
77
- // Create project directory and copy template files
78
- copyDir(templateDir, targetDir)
77
+ try {
78
+ const targetDir = path.join(process.cwd(), projectName)
79
+ const templateDir = path.join(templatesRoot, template)
79
80
 
80
- // Update README.md with project name
81
- const readmePath = path.join(targetDir, "README.md")
82
- if (fs.existsSync(readmePath)) {
83
- let readme = fs.readFileSync(readmePath, "utf-8")
84
- readme = readme.replace(/# my-game/, `# ${projectName}`)
85
- fs.writeFileSync(readmePath, readme)
86
- }
81
+ // Create project directory and copy template files
82
+ copyDir(templateDir, targetDir)
87
83
 
88
- if (template === "minimal") {
89
- console.log(`✅ Created ${projectName} at ${targetDir}`)
90
- console.log(`\nNext steps:`)
91
- console.log(` cd ${projectName}`)
92
- console.log(` Open index.html in your browser`)
93
- } else {
94
- // Update package.json with project name
95
- const pkgPath = path.join(targetDir, "package.json")
96
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"))
97
- pkg.name = projectName
98
-
99
- function getLatestVersion(packageName) {
100
- try {
101
- const version = execSync(`npm view ${packageName} version`, {
102
- encoding: "utf-8",
103
- }).trim()
104
- return `^${version}`
105
- } catch {
106
- return "latest" // fallback
107
- }
84
+ // Update README.md with project name
85
+ const readmePath = path.join(targetDir, "README.md")
86
+ if (fs.existsSync(readmePath)) {
87
+ let readme = fs.readFileSync(readmePath, "utf-8")
88
+ readme = readme.replace(/# my-game/, `# ${projectName}`)
89
+ fs.writeFileSync(readmePath, readme)
108
90
  }
109
91
 
110
- for (const depType of ["dependencies", "devDependencies"]) {
111
- if (pkg[depType]) {
112
- for (const [name, version] of Object.entries(pkg[depType])) {
113
- if (version.startsWith("workspace:")) {
114
- pkg[depType][name] = getLatestVersion(name)
92
+ if (template === "minimal") {
93
+ spinner.succeed(`Created ${projectName} at ${targetDir}`)
94
+ console.log(`\nNext steps:`)
95
+ console.log(` cd ${projectName}`)
96
+ console.log(` Open index.html in your browser`)
97
+ } else {
98
+ // Update package.json with project name
99
+ const pkgPath = path.join(targetDir, "package.json")
100
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"))
101
+ pkg.name = projectName
102
+
103
+ for (const depType of ["dependencies", "devDependencies"]) {
104
+ if (pkg[depType]) {
105
+ for (const [name, version] of Object.entries(pkg[depType])) {
106
+ if (version.startsWith("workspace:")) {
107
+ spinner.text = `Fetching latest version of ${name}...`
108
+ pkg[depType][name] = getLatestVersion(name)
109
+ }
115
110
  }
116
111
  }
117
112
  }
118
- }
119
113
 
120
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, INDENTATION) + EOL)
114
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, INDENTATION) + EOL)
121
115
 
122
- console.log(`✅ Created ${projectName} at ${targetDir}`)
123
- console.log(`\nNext steps:`)
124
- console.log(` cd ${projectName}`)
125
- console.log(` pnpm install`)
126
- console.log(` pnpm dev`)
116
+ spinner.succeed(`Created ${projectName} at ${targetDir}`)
117
+ console.log(`\nNext steps:`)
118
+ console.log(` cd ${projectName}`)
119
+ console.log(` pnpm install`)
120
+ console.log(` pnpm dev`)
121
+ }
122
+ } catch (error) {
123
+ spinner.fail("Operation failed.")
124
+ console.error(error)
127
125
  }
128
126
 
129
127
  function copyDir(src, dest) {
@@ -148,6 +146,18 @@ async function main() {
148
146
  }
149
147
  }
150
148
  }
149
+
150
+ function getLatestVersion(packageName) {
151
+ try {
152
+ const version = execSync(`npm view ${packageName} version`, {
153
+ encoding: "utf-8",
154
+ stdio: "pipe", // Prevent npm view output from cluttering the console
155
+ }).trim()
156
+ return `^${version}`
157
+ } catch {
158
+ return "latest" // fallback
159
+ }
160
+ }
151
161
  }
152
162
 
153
163
  main().catch((e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/create-game",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A scaffolding tool to quickly create a new game with the Inglorious Engine.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -35,11 +35,12 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
+ "ora": "^9.0.0",
38
39
  "prompts": "^2.4.2"
39
40
  },
40
41
  "devDependencies": {
41
42
  "prettier": "^3.6.2",
42
- "@inglorious/eslint-config": "1.0.0"
43
+ "@inglorious/eslint-config": "1.0.1"
43
44
  },
44
45
  "scripts": {
45
46
  "format": "prettier --write '**/*.{js,ijs,ts,its}'",
@@ -6,7 +6,6 @@ body {
6
6
  font-family: "Press Start 2P", system-ui;
7
7
  width: 100vw;
8
8
  height: 100vh;
9
- overflow: hidden;
10
9
  margin: 0;
11
10
  display: flex;
12
11
  flex-direction: column;
@@ -24,7 +23,7 @@ canvas {
24
23
  cursor: none;
25
24
  }
26
25
 
27
- @media (orientation: landscape) {
26
+ @media (orientation: landscape) and (pointer: coarse) and (hover: none) {
28
27
  canvas {
29
28
  width: auto;
30
29
  height: 100vh;
@@ -6,7 +6,6 @@ body {
6
6
  font-family: "Press Start 2P", system-ui;
7
7
  width: 100vw;
8
8
  height: 100vh;
9
- overflow: hidden;
10
9
  margin: 0;
11
10
  display: flex;
12
11
  flex-direction: column;
@@ -24,7 +23,7 @@ canvas {
24
23
  cursor: none;
25
24
  }
26
25
 
27
- @media (orientation: landscape) {
26
+ @media (orientation: landscape) and (pointer: coarse) and (hover: none) {
28
27
  canvas {
29
28
  width: auto;
30
29
  height: 100vh;
@@ -6,7 +6,6 @@ body {
6
6
  font-family: "Press Start 2P", system-ui;
7
7
  width: 100vw;
8
8
  height: 100vh;
9
- overflow: hidden;
10
9
  margin: 0;
11
10
  display: flex;
12
11
  flex-direction: column;
@@ -24,7 +23,7 @@ canvas {
24
23
  cursor: none;
25
24
  }
26
25
 
27
- @media (orientation: landscape) {
26
+ @media (orientation: landscape) and (pointer: coarse) and (hover: none) {
28
27
  canvas {
29
28
  width: auto;
30
29
  height: 100vh;
@@ -5,7 +5,6 @@
5
5
  body {
6
6
  width: 100vw;
7
7
  height: 100vh;
8
- overflow: hidden;
9
8
  margin: 0;
10
9
  display: flex;
11
10
  flex-direction: column;
@@ -20,7 +19,7 @@ canvas {
20
19
  height: auto;
21
20
  cursor: none;
22
21
 
23
- @media (orientation: landscape) {
22
+ @media (orientation: landscape) and (pointer: coarse) and (hover: none) {
24
23
  canvas {
25
24
  width: auto;
26
25
  height: 100vh;
@@ -6,7 +6,6 @@ body {
6
6
  font-family: "Press Start 2P", system-ui;
7
7
  width: 100vw;
8
8
  height: 100vh;
9
- overflow: hidden;
10
9
  margin: 0;
11
10
  display: flex;
12
11
  flex-direction: column;
@@ -24,7 +23,7 @@ canvas {
24
23
  cursor: none;
25
24
  }
26
25
 
27
- @media (orientation: landscape) {
26
+ @media (orientation: landscape) and (pointer: coarse) and (hover: none) {
28
27
  canvas {
29
28
  width: auto;
30
29
  height: 100vh;