Skip to content

Commit

Permalink
Support nextjs app/pages router
Browse files Browse the repository at this point in the history
  • Loading branch information
polarker committed Oct 16, 2024
1 parent cd19e81 commit 98fddaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cli/cli_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function buildErrorOutput(error: Error, isDebug: boolean): string {
return isDebug ? debugMsg : error.message
}

const templateTypes = ['base', 'react', 'nextjs']
const templateTypes = ['base', 'react', 'nextjs', 'nextjs-app', 'nextjs-pages']

program
.command('init')
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/scripts/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import fsExtra from 'fs-extra'
import path from 'path'
import { execSync } from 'child_process'

function prepareNextJs(_packageRoot: string, projectRoot: string) {
function prepareNextJs(templateType: string, _packageRoot: string, projectRoot: string) {
console.log('Creating the Nextjs app')
execSync(`npx create-next-app ${projectRoot} --example https://github.com/alephium/nextjs-template --typescript`)
const prefix = templateType === 'nextjs' ? 'nextjs-app' : templateType
execSync(`npx create-next-app ${projectRoot} --example https://github.com/alephium/${prefix}-dapp-template --typescript`)

Check failure on line 27 in packages/cli/scripts/create-project.ts

View workflow job for this annotation

GitHub Actions / build (20)

Replace ``npx·create-next-app·${projectRoot}·--example·https://github.com/alephium/${prefix}-dapp-template·--typescript`` with `⏎····`npx·create-next-app·${projectRoot}·--example·https://github.com/alephium/${prefix}-dapp-template·--typescript`⏎··`

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
execSync('npm install && npm run prettier', { cwd: projectRoot })
console.log()
}
Expand All @@ -48,10 +49,14 @@ export function createProject(templateType: string, packageRoot: string, project
gitClone('https://github.com/alephium/react-dapp-template.git', projectRoot)
break
case 'nextjs':
prepareNextJs(packageRoot, projectRoot)
case 'nextjs-app':
case 'nextjs-pages':
prepareNextJs(templateType, packageRoot, projectRoot)
break
default:
console.error(`Invalid template type ${templateType}, expect one of base, react, nextjs`)
console.error(
`Invalid template type ${templateType}, expect one of base, react, nextjs, nextjs-app, nextjs-pages`
)
process.exit(1)
}

Expand Down

0 comments on commit 98fddaa

Please sign in to comment.