Skip to content

Commit

Permalink
chore(create-robo): removed built-in colyseus template
Browse files Browse the repository at this point in the history
This is best done as a template considering how complex it can be. We already have the `--template` flag for this.
  • Loading branch information
Pkmmte committed May 26, 2024
1 parent 07e6e75 commit aeed55e
Show file tree
Hide file tree
Showing 27 changed files with 6 additions and 1,071 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-cooks-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-robo': minor
---

chore: removed built-in colyseus template
38 changes: 1 addition & 37 deletions packages/create-robo/src/robo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
Indent,
ExecOptions,
Space,
COLYSEUS_CONFIG
} from './utils.js'
import { RepoInfo, downloadAndExtractRepo, getRepoInfo, hasRepo } from './templates.js'
import retry from 'async-retry'
Expand Down Expand Up @@ -67,12 +66,6 @@ const optionalFeatures = [
value: 'prettier',
checked: true
},
{
name: `${chalk.bold('Colyseus')} - Multiplayer Framework for Node.js.`,
short: 'Colyseus',
value: 'colyseus',
checked: false
},
{
name: `${chalk.bold('ESLint')} ${Recommended} - Keeps your code clean and consistent.`,
short: 'ESLint',
Expand Down Expand Up @@ -376,12 +369,6 @@ export default class Robo {
this._spinner.stop(false)
logger.log(Indent, chalk.red(` Could not install plugins!`))
}

// If Colyseus is selected, override the /config/plugins/robojs/server.mjs file
if (this._selectedFeatures.includes('colyseus')) {
logger.debug(`Overriding Colyseus server config file...`)
await fs.writeFile(path.join(this._workingDir, 'config', 'plugins', 'robojs', 'server.mjs'), COLYSEUS_CONFIG)
}
}

async downloadTemplate(url: string) {
Expand Down Expand Up @@ -454,15 +441,6 @@ export default class Robo {
}
}

// Colyseus is only available for activities
if (!this._isApp) {
const index = features.findIndex((f) => f.value === 'colyseus')

if (index >= 0) {
features.splice(index, 1)
}
}

// Sorry, plugin developers don't get Extensionless as an option
if (this._isPlugin) {
const index = features.findIndex((f) => f.value === 'extensionless')
Expand Down Expand Up @@ -601,18 +579,6 @@ export default class Robo {
devDependencies.push('eslint-plugin-react-hooks')
}

// Colyseus requires more dependencies
if (features.includes('colyseus')) {
dependencies.push('@colyseus/core')
dependencies.push('@colyseus/monitor')
dependencies.push('@colyseus/schema')
dependencies.push('@colyseus/ws-transport')
dependencies.push('@robojs/server')
dependencies.push('colyseus.js')
dependencies.push('express')
devDependencies.push('@types/express')
}

// Generate customized documentation
if (this._isPlugin) {
logger.debug(`Generating plugin documentation...`)
Expand Down Expand Up @@ -837,9 +803,7 @@ export default class Robo {
}

private getTemplate(): string {
if (this._isApp && this._selectedFeatures.includes('react') && this._selectedFeatures.includes('colyseus')) {
return this._useTypeScript ? '../templates/activity-ts-colyseus-react' : '../templates/activity-ts-colyseus-react'
} else if (this._isApp && this._selectedFeatures.includes('react')) {
if (this._isApp && this._selectedFeatures.includes('react')) {
return this._useTypeScript ? '../templates/app-ts-react' : '../templates/app-js-react'
} else if (this._isApp) {
return this._useTypeScript ? '../templates/app-ts' : '../templates/app-js'
Expand Down
7 changes: 0 additions & 7 deletions packages/create-robo/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ export const Space = ' '.repeat(8)

export const IS_WINDOWS = /^win/.test(process.platform)

export const COLYSEUS_CONFIG = `// @ts-check
import { ColyseusServerEngine } from '../../../.robo/build/core/server.js'
export default {
engine: new ColyseusServerEngine()
}\n`

export const PRETTIER_CONFIG = `export default {
printWidth: 120,
semi: false,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit aeed55e

Please sign in to comment.