Skip to content

Commit 8c1c0c1

Browse files
committed
feat: except --exact flag to disable stub generation transformation
1 parent 96c0c86 commit 8c1c0c1

File tree

12 files changed

+89
-14
lines changed

12 files changed

+89
-14
lines changed

commands/Build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { BaseCommand, flags } from '@adonisjs/core/build/standalone'
1515
*/
1616
export default class Build extends BaseCommand {
1717
public static commandName = 'build'
18-
public static description = 'Compile typescript code to Javascript.'
18+
public static description = 'Compile Typescript code to JavaScript'
1919

2020
/**
2121
* Build for production

commands/Invoke.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ import { Manifest } from '../src/Manifest'
1616
export default class Invoke extends BaseCommand {
1717
public static commandName = 'invoke'
1818
public static description = 'Run post install instructions for a given AdonisJS package'
19+
public static aliases = ['configure']
1920

2021
/**
2122
* Use yarn when building for production to install dependencies
2223
*/
23-
@args.string({ description: 'Name of the package for which to invoke post install instructions' })
24+
@args.string({
25+
description: 'Name of the package for which to invoke the post install instructions',
26+
})
2427
public name: string
2528

2629
/**

commands/Make/Base.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { BaseCommand } from '@adonisjs/core/build/standalone'
1616
*/
1717
export abstract class BaseGenerator extends BaseCommand {
1818
protected abstract resourceName: string
19+
protected abstract createExact: boolean
1920
protected abstract getStub(): string
2021
protected abstract getDestinationPath(): string
2122

@@ -59,14 +60,20 @@ export abstract class BaseGenerator extends BaseCommand {
5960
return
6061
}
6162

63+
const transformations = this.createExact
64+
? {
65+
extname: this.extname,
66+
}
67+
: {
68+
form: this.form,
69+
suffix: this.suffix,
70+
formIgnoreList: this.formIgnoreList,
71+
pattern: this.pattern,
72+
extname: this.extname,
73+
}
74+
6275
const file = this.generator
63-
.addFile(this.resourceName, {
64-
form: this.form,
65-
suffix: this.suffix,
66-
formIgnoreList: this.formIgnoreList,
67-
pattern: this.pattern,
68-
extname: this.extname,
69-
})
76+
.addFile(this.resourceName, transformations)
7077
.stub(this.getStub())
7178
.useMustache()
7279
.destinationDir(this.getDestinationPath())

commands/Make/Command.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { join } from 'path'
11-
import { args } from '@adonisjs/core/build/standalone'
11+
import { args, flags } from '@adonisjs/core/build/standalone'
1212
import { string } from '@poppinss/utils/build/helpers'
1313

1414
import { BaseGenerator } from './Base'
@@ -22,6 +22,7 @@ export default class MakeCommand extends BaseGenerator {
2222
*/
2323
protected pattern = 'pascalcase' as const
2424
protected resourceName: string
25+
protected createExact: boolean
2526

2627
/**
2728
* Command meta data
@@ -32,6 +33,12 @@ export default class MakeCommand extends BaseGenerator {
3233
@args.string({ description: 'Name of the command class' })
3334
public name: string
3435

36+
@flags.boolean({
37+
description: 'Create the command with the exact name as provided',
38+
alias: 'e',
39+
})
40+
public exact: boolean
41+
3542
/**
3643
* Returns the template stub based upon the `--resource`
3744
* flag value
@@ -62,6 +69,7 @@ export default class MakeCommand extends BaseGenerator {
6269

6370
public async run(): Promise<void> {
6471
this.resourceName = this.name
72+
this.createExact = this.exact
6573
await super.generate()
6674
}
6775
}

commands/Make/Controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class MakeController extends BaseGenerator {
2222
protected form = 'plural' as const
2323
protected pattern = 'pascalcase' as const
2424
protected resourceName: string
25+
protected createExact: boolean
2526

2627
/**
2728
* Do not pluralize following controller names
@@ -48,6 +49,12 @@ export default class MakeController extends BaseGenerator {
4849
@flags.boolean({ description: 'Adds resourceful methods to the controller class', alias: 'r' })
4950
public resource: boolean
5051

52+
@flags.boolean({
53+
description: 'Create the controller with the exact name as provided',
54+
alias: 'e',
55+
})
56+
public exact: boolean
57+
5158
/**
5259
* Returns the template stub based upon the `--resource`
5360
* flag value
@@ -72,6 +79,7 @@ export default class MakeController extends BaseGenerator {
7279

7380
public async run() {
7481
this.resourceName = this.name
82+
this.createExact = this.exact
7583
await super.generate()
7684
}
7785
}

commands/Make/Exception.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class MakeException extends BaseGenerator {
2222
protected pattern = 'pascalcase' as const
2323
protected resourceName: string
2424
protected suffix = 'Exception'
25+
protected createExact: boolean
2526

2627
/**
2728
* Command meta data
@@ -35,6 +36,12 @@ export default class MakeException extends BaseGenerator {
3536
@flags.boolean({ description: 'Add handle method to self handle the exception' })
3637
public selfHandle: boolean
3738

39+
@flags.boolean({
40+
description: 'Create the exception with the exact name as provided',
41+
alias: 'e',
42+
})
43+
public exact: boolean
44+
3845
/**
3946
* Returns the template stub
4047
*/
@@ -58,6 +65,7 @@ export default class MakeException extends BaseGenerator {
5865

5966
public async run() {
6067
this.resourceName = this.name
68+
this.createExact = this.exact
6169
await super.generate()
6270
}
6371
}

commands/Make/Listener.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { join } from 'path'
11-
import { args } from '@adonisjs/core/build/standalone'
11+
import { args, flags } from '@adonisjs/core/build/standalone'
1212
import { BaseGenerator } from './Base'
1313

1414
/**
@@ -21,6 +21,7 @@ export default class MakeListener extends BaseGenerator {
2121
protected form = 'singular' as const
2222
protected pattern = 'pascalcase' as const
2323
protected resourceName: string
24+
protected createExact: boolean
2425

2526
/**
2627
* Command meta data
@@ -31,6 +32,12 @@ export default class MakeListener extends BaseGenerator {
3132
@args.string({ description: 'Name of the event listener class' })
3233
public name: string
3334

35+
@flags.boolean({
36+
description: 'Create the listener with the exact name as provided',
37+
alias: 'e',
38+
})
39+
public exact: boolean
40+
3441
/**
3542
* Returns the template stub
3643
*/
@@ -48,6 +55,7 @@ export default class MakeListener extends BaseGenerator {
4855

4956
public async run() {
5057
this.resourceName = this.name
58+
this.createExact = this.exact
5159
await super.generate()
5260
}
5361
}

commands/Make/Middleware.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { join } from 'path'
11-
import { args } from '@adonisjs/core/build/standalone'
11+
import { args, flags } from '@adonisjs/core/build/standalone'
1212
import { BaseGenerator } from './Base'
1313

1414
/**
@@ -22,6 +22,7 @@ export default class MakeMiddleware extends BaseGenerator {
2222
protected form = 'singular' as const
2323
protected pattern = 'pascalcase' as const
2424
protected resourceName: string
25+
protected createExact: boolean
2526

2627
/**
2728
* Command meta data
@@ -32,6 +33,12 @@ export default class MakeMiddleware extends BaseGenerator {
3233
@args.string({ description: 'Name of the middleware class' })
3334
public name: string
3435

36+
@flags.boolean({
37+
description: 'Create the middleware with the exact name as provided',
38+
alias: 'e',
39+
})
40+
public exact: boolean
41+
3542
/**
3643
* Returns the template stub path
3744
*/
@@ -49,6 +56,7 @@ export default class MakeMiddleware extends BaseGenerator {
4956

5057
public async run() {
5158
this.resourceName = this.name
59+
this.createExact = this.exact
5260
await super.generate()
5361
}
5462
}

commands/Make/PreloadFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default class MakePreloadFile extends BaseGenerator {
2121
* Required by BaseGenerator
2222
*/
2323
protected resourceName: string
24+
protected createExact = true
2425

2526
/**
2627
* List of allowed environments

commands/Make/Provider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class MakeProvider extends BaseGenerator {
2424
protected form = 'singular' as const
2525
protected pattern = 'pascalcase' as const
2626
protected resourceName: string
27+
protected createExact: boolean
2728

2829
/**
2930
* Command meta data
@@ -37,6 +38,12 @@ export default class MakeProvider extends BaseGenerator {
3738
@flags.boolean({ description: 'Registers provider under the ace providers array' })
3839
public ace: boolean
3940

41+
@flags.boolean({
42+
description: 'Create the provider with the exact name as provided',
43+
alias: 'e',
44+
})
45+
public exact: boolean
46+
4047
/**
4148
* Returns the template stub path
4249
*/
@@ -53,6 +60,7 @@ export default class MakeProvider extends BaseGenerator {
5360

5461
public async run() {
5562
this.resourceName = this.name
63+
this.createExact = this.exact
5664
const file = await super.generate()
5765

5866
if (!file) {

0 commit comments

Comments
 (0)