create-remix-game 1.0.9 ā 1.1.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/dist/cli.js +52 -21
- package/dist/install.js +14 -3
- package/dist/scaffold.js +4 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,29 +6,51 @@ import { initGitRepo } from './git.js';
|
|
|
6
6
|
import { installDependencies, installLatestPackages } from './install.js';
|
|
7
7
|
import { scaffold } from './scaffold.js';
|
|
8
8
|
async function main() {
|
|
9
|
-
console.log(chalk.
|
|
9
|
+
console.log(chalk.greenBright(`
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
āāāāāāāāāāāāāāā āāāāāāāāāāāāāāā
|
|
14
|
+
āā āā āā āā
|
|
15
|
+
āā āā āā āā
|
|
16
|
+
āā āā āā āā
|
|
17
|
+
āā āā āā āā
|
|
18
|
+
āā āā āā āā
|
|
19
|
+
āā āāāāāāāāāāāāāāāāāā āā
|
|
20
|
+
āā āā
|
|
21
|
+
āā āā
|
|
22
|
+
āā āā
|
|
23
|
+
āā āāāā āāāā āā
|
|
24
|
+
āā āāāā āāāā āā
|
|
25
|
+
āā āāāā āāāā āā
|
|
26
|
+
āā āāāā āāāā āā
|
|
27
|
+
āā āā
|
|
28
|
+
āā āā
|
|
29
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
30
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
31
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
32
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
33
|
+
āāāāāāāāāāāāāāāāāāāāāāāā
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
`));
|
|
10
38
|
const args = process.argv.slice(2);
|
|
11
|
-
|
|
39
|
+
const targetDir = args[0];
|
|
12
40
|
// Get project configuration
|
|
13
41
|
const config = await prompts([
|
|
14
42
|
{
|
|
15
|
-
type:
|
|
16
|
-
name: '
|
|
17
|
-
message: '
|
|
18
|
-
initial: '
|
|
43
|
+
type: 'text',
|
|
44
|
+
name: 'gameName',
|
|
45
|
+
message: 'Game name:',
|
|
46
|
+
initial: 'My Remix Game',
|
|
19
47
|
validate: (name) => {
|
|
20
|
-
if (
|
|
21
|
-
return '
|
|
48
|
+
if (!name || name.trim().length === 0) {
|
|
49
|
+
return 'Game name is required';
|
|
22
50
|
}
|
|
23
51
|
return true;
|
|
24
52
|
},
|
|
25
53
|
},
|
|
26
|
-
{
|
|
27
|
-
type: 'text',
|
|
28
|
-
name: 'gameName',
|
|
29
|
-
message: 'Game display name:',
|
|
30
|
-
initial: 'My Remix Game',
|
|
31
|
-
},
|
|
32
54
|
{
|
|
33
55
|
type: 'confirm',
|
|
34
56
|
name: 'multiplayer',
|
|
@@ -63,13 +85,21 @@ async function main() {
|
|
|
63
85
|
console.log('Cancelled');
|
|
64
86
|
process.exit(0);
|
|
65
87
|
}
|
|
66
|
-
|
|
67
|
-
const
|
|
88
|
+
// Generate a safe package name from the game name
|
|
89
|
+
const projectName = targetDir ||
|
|
90
|
+
config.gameName
|
|
91
|
+
.toLowerCase()
|
|
92
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
93
|
+
.replace(/^-+|-+$/g, '');
|
|
94
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
68
95
|
console.log(chalk.cyan(`\nā Creating project in ${projectPath}`));
|
|
69
96
|
// Scaffold the project
|
|
70
|
-
await scaffold(projectPath,
|
|
97
|
+
await scaffold(projectPath, {
|
|
98
|
+
...config,
|
|
99
|
+
projectName,
|
|
100
|
+
});
|
|
71
101
|
// Install dependencies
|
|
72
|
-
console.log(chalk.cyan('
|
|
102
|
+
console.log(chalk.cyan('ā Installing dependencies...'));
|
|
73
103
|
await installDependencies(projectPath, config.packageManager);
|
|
74
104
|
// Install packages that need @latest (0.x versions, etc.)
|
|
75
105
|
await installLatestPackages(projectPath, config.packageManager, ['@farcade/game-sdk@latest']);
|
|
@@ -77,10 +107,11 @@ async function main() {
|
|
|
77
107
|
if (config.initGit) {
|
|
78
108
|
await initGitRepo(projectPath);
|
|
79
109
|
}
|
|
80
|
-
console.log(chalk.bold.green('\n
|
|
110
|
+
console.log(chalk.bold.green('\nš Done!\n'));
|
|
81
111
|
console.log('Get started with:\n');
|
|
82
|
-
console.log(chalk.cyan(` cd ${
|
|
83
|
-
|
|
112
|
+
console.log(chalk.cyan(` cd ${projectName}`));
|
|
113
|
+
const devCommand = config.packageManager === 'npm' ? 'npm run dev' : `${config.packageManager} dev`;
|
|
114
|
+
console.log(chalk.cyan(` ${devCommand}\n`));
|
|
84
115
|
}
|
|
85
116
|
main().catch((error) => {
|
|
86
117
|
console.error(chalk.red('Error creating project:'), error);
|
package/dist/install.js
CHANGED
|
@@ -6,11 +6,17 @@ export async function installDependencies(projectPath, packageManager) {
|
|
|
6
6
|
const args = packageManager === 'yarn' ? [] : ['install'];
|
|
7
7
|
const child = spawn(command, args, {
|
|
8
8
|
cwd: projectPath,
|
|
9
|
-
stdio: '
|
|
9
|
+
stdio: 'pipe',
|
|
10
10
|
shell: true,
|
|
11
11
|
});
|
|
12
|
+
let errorOutput = '';
|
|
13
|
+
child.stderr?.on('data', (data) => {
|
|
14
|
+
errorOutput += data.toString();
|
|
15
|
+
});
|
|
12
16
|
child.on('close', (code) => {
|
|
13
17
|
if (code !== 0) {
|
|
18
|
+
console.error(chalk.red('\nā Installation failed:'));
|
|
19
|
+
console.error(errorOutput);
|
|
14
20
|
reject(new Error(`${packageManager} install failed with code ${code}`));
|
|
15
21
|
}
|
|
16
22
|
else {
|
|
@@ -34,14 +40,19 @@ export async function installLatestPackages(projectPath, packageManager, package
|
|
|
34
40
|
const command = packageManager === 'yarn' ? 'yarn' : packageManager;
|
|
35
41
|
const addCmd = packageManager === 'yarn' ? 'add' : packageManager === 'pnpm' ? 'add' : 'install';
|
|
36
42
|
const args = packageManager === 'yarn' ? [addCmd, '-D', ...packages] : [addCmd, '-D', ...packages];
|
|
37
|
-
console.log(chalk.cyan(`ā Installing latest versions: ${packages.join(', ')}`));
|
|
38
43
|
const child = spawn(command, args, {
|
|
39
44
|
cwd: projectPath,
|
|
40
|
-
stdio: '
|
|
45
|
+
stdio: 'pipe',
|
|
41
46
|
shell: true,
|
|
42
47
|
});
|
|
48
|
+
let errorOutput = '';
|
|
49
|
+
child.stderr?.on('data', (data) => {
|
|
50
|
+
errorOutput += data.toString();
|
|
51
|
+
});
|
|
43
52
|
child.on('close', (code) => {
|
|
44
53
|
if (code !== 0) {
|
|
54
|
+
console.error(chalk.red('\nā Failed to install latest packages:'));
|
|
55
|
+
console.error(errorOutput);
|
|
45
56
|
reject(new Error(`Failed to install ${packages.join(', ')}`));
|
|
46
57
|
}
|
|
47
58
|
else {
|
package/dist/scaffold.js
CHANGED
|
@@ -7,11 +7,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
7
7
|
function getRemixDevVersion() {
|
|
8
8
|
try {
|
|
9
9
|
// Try multiple paths to find remix-dev package.json
|
|
10
|
-
// In production (compiled): __dirname is dist, so go up to packages/remix-game/dist -> packages
|
|
11
|
-
// In dev/test: __dirname is src, so go up to packages/remix-game/src -> packages
|
|
10
|
+
// In production (compiled): __dirname is dist, so go up to packages/create-remix-game/dist -> packages/@insidethesim|remix-dev
|
|
11
|
+
// In dev/test: __dirname is src, so go up to packages/create-remix-game/src -> packages/@insidethesim|remix-dev
|
|
12
12
|
const possiblePaths = [
|
|
13
|
-
path.join(__dirname, '
|
|
14
|
-
path.join(__dirname, '
|
|
13
|
+
path.join(__dirname, '../../@insidethesim|remix-dev/package.json'), // From src or dist
|
|
14
|
+
path.join(__dirname, '../../../@insidethesim|remix-dev/package.json'), // From nested dir
|
|
15
15
|
];
|
|
16
16
|
for (const packageJsonPath of possiblePaths) {
|
|
17
17
|
if (fs.existsSync(packageJsonPath)) {
|
|
@@ -28,7 +28,6 @@ function getRemixDevVersion() {
|
|
|
28
28
|
// Fallback: Use CLI's own version (they're synced, so this works)
|
|
29
29
|
const cliPackageJsonPath = path.join(__dirname, '../package.json');
|
|
30
30
|
const cliPackageJson = JSON.parse(fs.readFileSync(cliPackageJsonPath, 'utf-8'));
|
|
31
|
-
console.warn('Could not read remix-dev version, using CLI version as fallback:', cliPackageJson.version);
|
|
32
31
|
return cliPackageJson.version;
|
|
33
32
|
}
|
|
34
33
|
}
|