Skip to content

Commit e341d69

Browse files
committed
fix start for example
1 parent 0096877 commit e341d69

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

example/epicshop/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"type": "module",
3-
"scripts": {
4-
"start": "epicshop start"
5-
},
63
"dependencies": {
74
"@epic-web/workshop-app": "file:../../packages/workshop-app",
85
"@epic-web/workshop-cli": "file:../../packages/workshop-cli",

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
},
3232
"type": "module",
3333
"scripts": {
34-
"start": "npm run --prefix ./epicshop start",
35-
"dev": "npm run --prefix ./epicshop start",
34+
"start": "npx --prefix ./epicshop epicshop start",
35+
"dev": "npx --prefix ./epicshop epicshop start",
3636
"setup": "node ./epicshop/setup.js",
3737
"setup:custom": "node ./epicshop/setup-custom.js",
3838
"lint": "eslint .",

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"prestart": "npm run build -s",
1010
"go": "cross-env NODE_ENV=development EPICSHOP_CONTEXT_CWD=$PWD/packages/example tsx watch $@",
1111
"start": "cross-env NODE_ENV=production npm --prefix example run start",
12-
"predev": "npm run build -s",
1312
"dev": "npm --prefix example run start",
1413
"test": "nx test",
1514
"format": "nx format:write",

packages/workshop-app/server/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ import { type ServerBuild } from 'react-router'
2323
import sourceMapSupport from 'source-map-support'
2424
import { type WebSocket, WebSocketServer } from 'ws'
2525

26+
// if we exit early with an error, log the error...
27+
closeWithGrace(({ err, manual }) => {
28+
if (manual) return
29+
if (err) console.error(err.stack)
30+
})
31+
2632
const MODE = process.env.NODE_ENV ?? 'development'
2733

2834
void initApps()
@@ -189,9 +195,10 @@ const server = app.listen(portToUse, async () => {
189195
`
190196
${chalk.bold('Local:')} ${chalk.cyan(localUrl)}
191197
${lanUrl ? `${chalk.bold('On Your Network:')} ${chalk.cyan(lanUrl)}` : ''}
192-
${chalk.bold('Press Ctrl+C to stop')}
193198
`.trim(),
194199
)
200+
// give it another line
201+
console.log('')
195202

196203
if (
197204
process.env.EPICSHOP_DEPLOYED !== 'true' &&

packages/workshop-cli/src/cli.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ async function startCommand() {
3333
const parentToken = crypto.randomBytes(32).toString('hex')
3434

3535
const childCommand = isProd ? 'node ./start.js' : 'npm run dev'
36+
const EPICSHOP_CONTEXT_CWD = process.env.EPICSHOP_CONTEXT_CWD ?? process.cwd()
3637
const childEnv: NodeJS.ProcessEnv = {
3738
...process.env,
38-
EPICSHOP_CONTEXT_CWD: process.env.EPICSHOP_CONTEXT_CWD ?? process.cwd(),
39+
EPICSHOP_CONTEXT_CWD: EPICSHOP_CONTEXT_CWD,
3940
EPICSHOP_PARENT_PORT: String(parentPort),
4041
EPICSHOP_PARENT_TOKEN: parentToken,
4142
}
@@ -175,7 +176,7 @@ async function startCommand() {
175176

176177
child = spawn(childCommand, [], {
177178
shell: true,
178-
cwd: appDir,
179+
cwd: EPICSHOP_CONTEXT_CWD,
179180
// Capture stdout for port detection
180181
stdio: ['pipe', 'pipe', 'inherit'],
181182
env: childEnv,
@@ -214,7 +215,7 @@ async function startCommand() {
214215

215216
if (process.stdin.isTTY && !isDeployed) {
216217
console.log(chalk.bold.cyan('Supported keys:'))
217-
console.log(supportedKeys.join('\n\t'))
218+
console.log(` ${supportedKeys.join('\n ')}\n`)
218219
process.stdin.setRawMode(true)
219220
process.stdin.resume()
220221
process.stdin.setEncoding('utf8')
@@ -385,7 +386,7 @@ const cli = yargs(hideBin(process.argv))
385386
.epilogue(
386387
`
387388
${chalk.bold('Interactive keys (available during start command):')}
388-
${supportedKeys.join('\n\t')}
389+
${supportedKeys.join('\n ')}
389390
390391
For more information, visit: https://github.com/epicweb-dev/epicshop
391392
`,

0 commit comments

Comments
 (0)