@boardgamebuddy/game-pack-cli 0.0.8 → 0.0.9
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/cli.js +18 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -123,8 +123,25 @@ program
|
|
|
123
123
|
fs.writeFileSync(embeddingsPath, embeddings);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// Patch package.json name
|
|
127
|
+
const packJsonPath = path.join(targetDir, 'package.json');
|
|
128
|
+
if (fs.existsSync(packJsonPath)) {
|
|
129
|
+
let packJson = fs.readFileSync(packJsonPath, 'utf8');
|
|
130
|
+
packJson = packJson.replace(/"mygame"/, `"${gameId}"`);
|
|
131
|
+
fs.writeFileSync(packJsonPath, packJson);
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
console.log(`\nCreated game pack: ${gameId}/`);
|
|
127
135
|
console.log(` Display name: ${displayName}`);
|
|
136
|
+
console.log(`\nInstalling dependencies...`);
|
|
137
|
+
|
|
138
|
+
await new Promise((resolve, reject) => {
|
|
139
|
+
const proc = spawn('npm', ['install'], { cwd: targetDir, shell: true, stdio: 'inherit' });
|
|
140
|
+
proc.on('close', (code) => code === 0 ? resolve() : reject(new Error(`npm install failed with code ${code}`)));
|
|
141
|
+
}).catch((err) => {
|
|
142
|
+
console.error(`Warning: ${err.message}`);
|
|
143
|
+
});
|
|
144
|
+
|
|
128
145
|
console.log(`\nNext steps:`);
|
|
129
146
|
console.log(` cd ${gameId}`);
|
|
130
147
|
console.log(` # Edit scorer.ts to implement your scoring logic`);
|
|
@@ -235,7 +252,7 @@ program
|
|
|
235
252
|
console.log('scorer.ts changed — recompiling...');
|
|
236
253
|
const proc = spawn(
|
|
237
254
|
'npx',
|
|
238
|
-
['
|
|
255
|
+
['esbuild', 'scorer.ts', '--bundle', '--platform=node', '--target=es2017', '--outfile=scorer.js'],
|
|
239
256
|
{ cwd: packDir, shell: true }
|
|
240
257
|
);
|
|
241
258
|
|