Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Options
--eslint <boolean> Enable/disable eslint setup
--prettier <boolean> Enable/disable prettier setup
--encore <boolean> Enable/disable encore setup
--test <boolean> Enable/disable japa setup
--debug <boolean> Turn on the debug mode
```

Expand Down Expand Up @@ -102,6 +103,14 @@ Configure encore
npm init adonis-ts-app hello-world -- --encore
```

#### test

Configure [Japa](https://japa.dev/) ( our testing framework ) and its preset for AdonisJS

```sh
npm init adonis-ts-app hello-world -- --test
```

#### debug

Debug the project creation process. This flag will use the verbose output for better debugging experience.
Expand Down
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export async function runTasks(args: string[]) {
*/
const argv = getops(args, {
string: ['boilerplate', 'name'],
boolean: ['eslint', 'debug', 'prettier', 'encore'],
boolean: ['eslint', 'debug', 'prettier', 'test', 'encore'],
default: {
eslint: null,
debug: false,
test: true,
prettier: null,
encore: null,
},
Expand Down Expand Up @@ -64,6 +65,7 @@ export async function runTasks(args: string[]) {
boilerplate: argv.boilerplate,
eslint: argv.eslint,
prettier: argv.prettier,
test: argv.test,
encore: argv.encore,
})

Expand Down
3 changes: 3 additions & 0 deletions src/Chalk/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ ${logger.colors.green('--prettier')} ${logger.colors.dim(
${logger.colors.green('--encore')} ${logger.colors.dim(
'<boolean>'
)} ${logger.colors.dim('Enable/disable encore setup')}
${logger.colors.green('--test')} ${logger.colors.dim(
'<boolean>'
)} ${logger.colors.dim('Enable/disable japa setup')}
${logger.colors.green('--debug')} ${logger.colors.dim(
'<boolean>'
)} ${logger.colors.dim('Turn on the debug mode')}`
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export type CliState = {
eslint: boolean
prettier: boolean
encore: boolean
test: boolean
pkg: files.PackageJsonFile
}
18 changes: 18 additions & 0 deletions src/Helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function getState(
prettier?: boolean
client: SupportedPackageManager
encore?: boolean
test?: boolean
}
): Promise<CliState> {
/**
Expand Down Expand Up @@ -102,6 +103,22 @@ export async function getState(
}
}

/**
* Prompt for installing Japa and its preset for AdonisJS.
*/
if (options.test === null) {
try {
options.test = await getPrompt().confirm(
'Setup Japa ( testing framework ) and its preset for AdonisJS?',
{
default: true,
}
)
} catch (_) {
process.exit(1)
}
}

/**
* Prompt for Webpack encore. We only do it during the web
* boilerplate. For others, a user can define it using
Expand Down Expand Up @@ -152,6 +169,7 @@ export async function getState(
client: options.client,
encore: options.encore!,
debug: !!options.debug,
test: options.test!,
}
}

Expand Down
12 changes: 10 additions & 2 deletions tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { CliState } from '../src/Contracts'
/**
* An array of tasks to be executed in chronological order
*/
export const tasks = function ({ encore }: CliState) {
export const tasks = function ({ encore, test }: CliState) {
return [
{
title: 'Scaffold project',
Expand All @@ -45,8 +45,16 @@ export const tasks = function ({ encore }: CliState) {
},
{
title: 'Configure installed packages',
actions: [configurePackages, configureTests, generateManifest, formatSource],
actions: [configurePackages, generateManifest, formatSource],
},
...(test
? [
{
title: 'Configure tests',
actions: [configureTests],
},
]
: []),
...(encore
? [
{
Expand Down