@nanotoolkit/create-game 0.1.16 → 0.1.17
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/package.json +3 -3
- package/src/index.js +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanotoolkit/create-game",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"node": ">=18"
|
|
17
17
|
},
|
|
18
18
|
"pinnedVersions": {
|
|
19
|
-
"@nanotoolkit/game-sdk": "0.1.
|
|
20
|
-
"@nanotoolkit/game-cli": "0.1.
|
|
19
|
+
"@nanotoolkit/game-sdk": "0.1.10",
|
|
20
|
+
"@nanotoolkit/game-cli": "0.1.10"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public",
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
copyFileSync,
|
|
8
8
|
statSync,
|
|
9
9
|
} from 'node:fs';
|
|
10
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
10
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
import { createInterface } from 'node:readline/promises';
|
|
13
13
|
import { stdin, stdout } from 'node:process';
|
|
@@ -32,7 +32,12 @@ function parseArgs(argv) {
|
|
|
32
32
|
else if (a.startsWith('--title=')) opts.title = a.slice('--title='.length);
|
|
33
33
|
else if (a === '--provider') opts.provider = argv[++i];
|
|
34
34
|
else if (a.startsWith('--provider=')) opts.provider = a.slice('--provider='.length);
|
|
35
|
-
else if (a === '--
|
|
35
|
+
else if (a === '--dir' || a.startsWith('--dir=')) {
|
|
36
|
+
const value = a === '--dir' ? argv[++i] : a.slice('--dir='.length);
|
|
37
|
+
if (!value || (a === '--dir' && value.startsWith('--')))
|
|
38
|
+
throw new Error('invalid option --dir: missing value');
|
|
39
|
+
opts.dir = value;
|
|
40
|
+
} else if (a === '--rule-type') opts.ruleType = argv[++i];
|
|
36
41
|
else if (a === '--flow-type') opts.flowType = argv[++i];
|
|
37
42
|
else if (a.startsWith('-')) throw new Error(`invalid option: ${a}`);
|
|
38
43
|
else opts._.push(a);
|
|
@@ -51,6 +56,7 @@ function printHelp() {
|
|
|
51
56
|
' --flow-type <value>',
|
|
52
57
|
' --title <value>',
|
|
53
58
|
' --provider <value>',
|
|
59
|
+
' --dir <path>',
|
|
54
60
|
].join('\n'),
|
|
55
61
|
);
|
|
56
62
|
}
|
|
@@ -159,7 +165,7 @@ export async function run(argv) {
|
|
|
159
165
|
console.error('create-game: invalid ruleType/flowType');
|
|
160
166
|
return 2;
|
|
161
167
|
}
|
|
162
|
-
const target = resolve(process.cwd(), bundleId);
|
|
168
|
+
const target = resolve(process.cwd(), opts.dir ?? bundleId);
|
|
163
169
|
if (existsSync(target) && (statSync(target).isFile() || readdirSync(target).length > 0)) {
|
|
164
170
|
console.error(`create-game: directory not empty: ${target}`);
|
|
165
171
|
return 2;
|
|
@@ -184,8 +190,9 @@ export async function run(argv) {
|
|
|
184
190
|
const pm = agent.startsWith('pnpm') ? 'pnpm' : agent.startsWith('yarn') ? 'yarn' : 'npm';
|
|
185
191
|
const installCmd = pm === 'npm' ? 'npm install' : pm;
|
|
186
192
|
const devCmd = pm === 'npm' ? 'npm run dev' : `${pm} dev`;
|
|
193
|
+
const cdPath = (relative(process.cwd(), target) || '.').replace(/'/g, "'\\''");
|
|
187
194
|
console.log(
|
|
188
|
-
[`created ${basename(target)}/`, '', ` cd ${
|
|
195
|
+
[`created ${basename(target)}/`, '', ` cd -- '${cdPath}'`, ` ${installCmd}`, ` ${devCmd}`].join(
|
|
189
196
|
'\n',
|
|
190
197
|
),
|
|
191
198
|
);
|