@adonisjs/assembler 5.9.5 → 6.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/index.d.ts +2 -0
  3. package/build/index.js +2 -0
  4. package/build/src/bundler.d.ts +10 -0
  5. package/build/src/bundler.js +133 -0
  6. package/build/src/dev_server.d.ts +13 -0
  7. package/build/src/dev_server.js +189 -0
  8. package/build/src/run.d.ts +3 -0
  9. package/build/src/run.js +19 -0
  10. package/build/src/types.d.ts +26 -0
  11. package/build/src/watch.d.ts +8 -0
  12. package/build/src/watch.js +18 -0
  13. package/package.json +77 -99
  14. package/build/ace-manifest.json +0 -521
  15. package/build/commands/Build.d.ts +0 -37
  16. package/build/commands/Build.js +0 -138
  17. package/build/commands/Invoke.d.ts +0 -34
  18. package/build/commands/Invoke.js +0 -234
  19. package/build/commands/Make/Base.d.ts +0 -30
  20. package/build/commands/Make/Base.js +0 -75
  21. package/build/commands/Make/Command.d.ts +0 -35
  22. package/build/commands/Make/Command.js +0 -82
  23. package/build/commands/Make/Controller.d.ts +0 -37
  24. package/build/commands/Make/Controller.js +0 -89
  25. package/build/commands/Make/Exception.d.ts +0 -32
  26. package/build/commands/Make/Exception.js +0 -75
  27. package/build/commands/Make/Listener.d.ts +0 -30
  28. package/build/commands/Make/Listener.js +0 -70
  29. package/build/commands/Make/Middleware.d.ts +0 -31
  30. package/build/commands/Make/Middleware.js +0 -87
  31. package/build/commands/Make/PreloadFile.d.ts +0 -38
  32. package/build/commands/Make/PreloadFile.js +0 -157
  33. package/build/commands/Make/Provider.d.ts +0 -31
  34. package/build/commands/Make/Provider.js +0 -114
  35. package/build/commands/Make/Suite.d.ts +0 -41
  36. package/build/commands/Make/Suite.js +0 -120
  37. package/build/commands/Make/Test.d.ts +0 -35
  38. package/build/commands/Make/Test.js +0 -96
  39. package/build/commands/Make/Validator.d.ts +0 -31
  40. package/build/commands/Make/Validator.js +0 -71
  41. package/build/commands/Make/View.d.ts +0 -30
  42. package/build/commands/Make/View.js +0 -70
  43. package/build/commands/Serve.d.ts +0 -33
  44. package/build/commands/Serve.js +0 -112
  45. package/build/commands/Test.d.ts +0 -57
  46. package/build/commands/Test.js +0 -159
  47. package/build/commands/TypeCheck.d.ts +0 -16
  48. package/build/commands/TypeCheck.js +0 -85
  49. package/build/config/paths.d.ts +0 -7
  50. package/build/config/paths.js +0 -18
  51. package/build/register.js +0 -15
  52. package/build/src/AssetsBundler/index.d.ts +0 -76
  53. package/build/src/AssetsBundler/index.js +0 -216
  54. package/build/src/Compiler/index.d.ts +0 -62
  55. package/build/src/Compiler/index.js +0 -287
  56. package/build/src/Contracts/index.d.ts +0 -8
  57. package/build/src/Contracts/index.js +0 -10
  58. package/build/src/DevServer/index.d.ts +0 -70
  59. package/build/src/DevServer/index.js +0 -306
  60. package/build/src/EnvParser/index.d.ts +0 -21
  61. package/build/src/EnvParser/index.js +0 -48
  62. package/build/src/HttpServer/index.d.ts +0 -34
  63. package/build/src/HttpServer/index.js +0 -87
  64. package/build/src/Manifest/index.d.ts +0 -32
  65. package/build/src/Manifest/index.js +0 -88
  66. package/build/src/RcFile/index.d.ts +0 -72
  67. package/build/src/RcFile/index.js +0 -174
  68. package/build/src/Test/index.d.ts +0 -75
  69. package/build/src/Test/index.js +0 -346
  70. package/build/src/Test/process.d.ts +0 -22
  71. package/build/src/Test/process.js +0 -68
  72. package/build/src/Ts/index.d.ts +0 -24
  73. package/build/src/Ts/index.js +0 -55
  74. package/build/src/requireHook/index.d.ts +0 -5
  75. package/build/src/requireHook/index.js +0 -28
  76. package/build/src/requireHook/ioc-transformer.d.ts +0 -6
  77. package/build/src/requireHook/ioc-transformer.js +0 -21
  78. package/build/templates/command.txt +0 -33
  79. package/build/templates/controller.txt +0 -3
  80. package/build/templates/event-listener.txt +0 -3
  81. package/build/templates/exception.txt +0 -15
  82. package/build/templates/middleware.txt +0 -8
  83. package/build/templates/preload-file.txt +0 -9
  84. package/build/templates/provider.txt +0 -40
  85. package/build/templates/resource-controller.txt +0 -17
  86. package/build/templates/self-handle-exception.txt +0 -32
  87. package/build/templates/test-entrypoint.txt +0 -45
  88. package/build/templates/test.txt +0 -5
  89. package/build/templates/tests/bootstrap.txt +0 -69
  90. package/build/templates/tests/functional/hello_world_api.spec.txt +0 -8
  91. package/build/templates/tests/functional/hello_world_slim.spec.txt +0 -8
  92. package/build/templates/tests/functional/hello_world_web.spec.txt +0 -8
  93. package/build/templates/tests-contract.txt +0 -18
  94. package/build/templates/validator.txt +0 -40
  95. package/build/templates/view.txt +0 -0
  96. package/build/templates/webpack.config.txt +0 -214
  97. /package/build/{register.d.ts → src/types.js} +0 -0
@@ -1,34 +0,0 @@
1
- import { BaseCommand } from '@adonisjs/core/build/standalone';
2
- /**
3
- * Configure a package
4
- */
5
- export default class Configure extends BaseCommand {
6
- static commandName: string;
7
- static description: string;
8
- static aliases: string[];
9
- private appType;
10
- /**
11
- * Use yarn when building for production to install dependencies
12
- */
13
- packages: string[];
14
- /**
15
- * Returns package manager for installing dependencies
16
- */
17
- private getPackageManager;
18
- /**
19
- * Configure encore
20
- */
21
- private configureEncore;
22
- /**
23
- * Configure tests
24
- */
25
- private configureTests;
26
- /**
27
- * Configure a give package
28
- */
29
- private configurePackage;
30
- /**
31
- * Invoked automatically by ace
32
- */
33
- run(): Promise<void>;
34
- }
@@ -1,234 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/assembler
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
- return c > 3 && r && Object.defineProperty(target, key, r), r;
15
- };
16
- var __metadata = (this && this.__metadata) || function (k, v) {
17
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- const path_1 = require("path");
21
- const sink_1 = require("@adonisjs/sink");
22
- const standalone_1 = require("@adonisjs/core/build/standalone");
23
- const Manifest_1 = require("../src/Manifest");
24
- /**
25
- * Configure a package
26
- */
27
- class Configure extends standalone_1.BaseCommand {
28
- constructor() {
29
- super(...arguments);
30
- this.appType = process.env['ADONIS_CREATE_APP_BOILERPLATE'] || 'web';
31
- }
32
- /**
33
- * Returns package manager for installing dependencies
34
- */
35
- getPackageManager() {
36
- if (process.env['ADONIS_CREATE_APP_CLIENT']) {
37
- return process.env['ADONIS_CREATE_APP_CLIENT'];
38
- }
39
- return sink_1.utils.getPackageManager(this.application.appRoot);
40
- }
41
- /**
42
- * Configure encore
43
- */
44
- async configureEncore() {
45
- /**
46
- * Create the webpack config file
47
- */
48
- const webpackConfigFile = new sink_1.files.MustacheFile(this.application.appRoot, 'webpack.config.js', (0, path_1.join)(__dirname, '..', 'templates/webpack.config.txt'));
49
- if (!webpackConfigFile.exists()) {
50
- webpackConfigFile.apply({}).commit();
51
- sink_1.logger.action('create').succeeded('webpack.config.js');
52
- }
53
- /**
54
- * Create app.js entrypoint
55
- */
56
- const entryPointFile = new sink_1.files.NewLineFile(this.application.appRoot, 'resources/js/app.js');
57
- if (!entryPointFile.exists()) {
58
- entryPointFile.add('// app entrypoint').commit();
59
- sink_1.logger.action('create').succeeded('resources/js/app.js');
60
- }
61
- /**
62
- * Install Encore
63
- */
64
- const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
65
- pkgFile.install('@symfony/webpack-encore@4.1.1');
66
- pkgFile.install('webpack@^5.72');
67
- pkgFile.install('webpack-cli@^4.9.1');
68
- pkgFile.install('@babel/core@^7.17.0');
69
- pkgFile.install('@babel/preset-env@^7.16.0');
70
- pkgFile.useClient(this.getPackageManager());
71
- const spinner = sink_1.logger.await(sink_1.logger.colors.gray('configure @symfony/webpack-encore'));
72
- try {
73
- const response = await pkgFile.commitAsync();
74
- if (response && response.status === 1) {
75
- spinner.stop();
76
- sink_1.logger.fatal({ message: 'Unable to configure encore', stack: response.stderr.toString() });
77
- }
78
- else {
79
- spinner.stop();
80
- sink_1.logger.success('Configured encore successfully');
81
- }
82
- }
83
- catch (error) {
84
- spinner.stop();
85
- sink_1.logger.fatal(error);
86
- }
87
- }
88
- /**
89
- * Configure tests
90
- */
91
- async configureTests() {
92
- /**
93
- * Create "test.ts" file
94
- */
95
- const testsEntryPointFile = new sink_1.files.MustacheFile(this.application.appRoot, 'test.ts', (0, path_1.join)(__dirname, '..', 'templates/test-entrypoint.txt'));
96
- if (!testsEntryPointFile.exists()) {
97
- testsEntryPointFile.apply({}).commit();
98
- sink_1.logger.action('create').succeeded('test.ts');
99
- }
100
- /**
101
- * Create "tests/bootstrap.ts" file
102
- */
103
- const testsBootstrapFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/bootstrap.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/bootstrap.txt'));
104
- if (!testsBootstrapFile.exists()) {
105
- testsBootstrapFile.apply({}).commit();
106
- sink_1.logger.action('create').succeeded('tests/bootstrap.ts');
107
- }
108
- /**
109
- * Create "tests/functional/hello_world.spec.ts" file
110
- */
111
- const helloWorldTestFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/functional/hello_world.spec.ts', (0, path_1.join)(__dirname, '..', `templates/tests/functional/hello_world_${this.appType}.spec.txt`));
112
- if (!helloWorldTestFile.exists()) {
113
- helloWorldTestFile.apply({}).commit();
114
- sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
115
- }
116
- /**
117
- * Create "contracts/tests.ts" file
118
- */
119
- const testsContractsFile = new sink_1.files.MustacheFile(this.application.appRoot, 'contracts/tests.ts', (0, path_1.join)(__dirname, '..', 'templates/tests-contract.txt'));
120
- if (!testsContractsFile.exists()) {
121
- testsContractsFile.apply({}).commit();
122
- sink_1.logger.action('create').succeeded('contracts/tests.ts');
123
- }
124
- /**
125
- * Update AdonisRc file with test suites
126
- */
127
- const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
128
- rcFile.set('tests', {
129
- suites: [
130
- {
131
- name: 'functional',
132
- files: ['tests/functional/**/*.spec(.ts|.js)'],
133
- timeout: 60 * 1000,
134
- },
135
- ],
136
- });
137
- rcFile.addTestProvider('@japa/preset-adonis/TestsProvider');
138
- rcFile.commit();
139
- sink_1.logger.action('update').succeeded('.adonisrc.json');
140
- /**
141
- * Create ".env.test" file
142
- */
143
- const testEnvFile = new sink_1.files.NewLineFile(this.application.appRoot, '.env.test');
144
- if (!testEnvFile.exists()) {
145
- testEnvFile.add('NODE_ENV=test');
146
- /**
147
- * Set additional .env variables for "web" boilerplate
148
- */
149
- if (this.appType === 'web') {
150
- testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
151
- }
152
- testEnvFile.commit();
153
- sink_1.logger.action('create').succeeded('.env.test');
154
- }
155
- /**
156
- * Update "tsconfig.json"
157
- */
158
- const tsConfig = new sink_1.files.JsonFile(this.application.appRoot, 'tsconfig.json');
159
- const existingTypes = tsConfig.get('compilerOptions.types') || [];
160
- if (!existingTypes.includes('@japa/preset-adonis/build/adonis-typings')) {
161
- existingTypes.push('@japa/preset-adonis/build/adonis-typings');
162
- }
163
- tsConfig.set('compilerOptions.types', existingTypes);
164
- tsConfig.commit();
165
- sink_1.logger.action('update').succeeded('tsconfig.json');
166
- /**
167
- * Set additional .env variables for "web" boilerplate
168
- */
169
- if (this.appType === 'web') {
170
- testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
171
- }
172
- testEnvFile.commit();
173
- sink_1.logger.action('create').succeeded('.env.test');
174
- /**
175
- * Install required dependencies
176
- */
177
- const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
178
- pkgFile.install('@japa/runner');
179
- pkgFile.install('@japa/preset-adonis');
180
- pkgFile.useClient(this.getPackageManager());
181
- const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
182
- try {
183
- const response = await pkgFile.commitAsync();
184
- if (response && response.status === 1) {
185
- spinner.stop();
186
- sink_1.logger.fatal({
187
- message: 'Unable to configure tests runner',
188
- stack: response.stderr.toString(),
189
- });
190
- }
191
- else {
192
- spinner.stop();
193
- sink_1.logger.success('Configured tests runner successfully');
194
- }
195
- }
196
- catch (error) {
197
- spinner.stop();
198
- sink_1.logger.fatal(error);
199
- }
200
- }
201
- /**
202
- * Configure a give package
203
- */
204
- async configurePackage(name) {
205
- if (name === 'encore') {
206
- await this.configureEncore();
207
- return;
208
- }
209
- if (name === 'tests') {
210
- await this.configureTests();
211
- return;
212
- }
213
- await new sink_1.tasks.Instructions(name, this.application.appRoot, this.application, true).execute();
214
- await new Manifest_1.Manifest(this.application.appRoot, this.logger).generate();
215
- }
216
- /**
217
- * Invoked automatically by ace
218
- */
219
- async run() {
220
- for (let name of this.packages) {
221
- await this.configurePackage(name);
222
- }
223
- }
224
- }
225
- Configure.commandName = 'configure';
226
- Configure.description = 'Configure one or more AdonisJS packages';
227
- Configure.aliases = ['invoke'];
228
- __decorate([
229
- standalone_1.args.spread({
230
- description: 'Name of the package(s) you want to configure',
231
- }),
232
- __metadata("design:type", Array)
233
- ], Configure.prototype, "packages", void 0);
234
- exports.default = Configure;
@@ -1,30 +0,0 @@
1
- import { BaseCommand } from '@adonisjs/core/build/standalone';
2
- /**
3
- * Base class to generate framework entities
4
- */
5
- export declare abstract class BaseGenerator extends BaseCommand {
6
- protected abstract resourceName: string;
7
- protected abstract createExact: boolean;
8
- protected abstract getStub(): string;
9
- protected abstract getDestinationPath(): string;
10
- protected suffix?: string;
11
- protected extname: string;
12
- protected form?: 'singular' | 'plural';
13
- protected pattern?: 'camelcase' | 'snakecase' | 'pascalcase';
14
- protected formIgnoreList?: string[];
15
- protected templateData(): any;
16
- /**
17
- * Returns path for a given namespace by replacing the base namespace
18
- * with the defined directories map inside the `.adonisrc.json`
19
- * file
20
- */
21
- protected getPathForNamespace(namespaceFor: string): string | null;
22
- /**
23
- * Returns contents of the rcFile
24
- */
25
- protected hasRcFile(cwd: string): Promise<boolean>;
26
- /**
27
- * Handle command
28
- */
29
- generate(): Promise<import("@adonisjs/ace/build/src/Contracts").GeneratorFileContract | undefined>;
30
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/assembler
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.BaseGenerator = void 0;
12
- const path_1 = require("path");
13
- const fs_extra_1 = require("fs-extra");
14
- const standalone_1 = require("@adonisjs/core/build/standalone");
15
- /**
16
- * Base class to generate framework entities
17
- */
18
- class BaseGenerator extends standalone_1.BaseCommand {
19
- constructor() {
20
- super(...arguments);
21
- this.extname = '.ts';
22
- }
23
- templateData() {
24
- return {};
25
- }
26
- /**
27
- * Returns path for a given namespace by replacing the base namespace
28
- * with the defined directories map inside the `.adonisrc.json`
29
- * file
30
- */
31
- getPathForNamespace(namespaceFor) {
32
- return this.application.resolveNamespaceDirectory(namespaceFor);
33
- }
34
- /**
35
- * Returns contents of the rcFile
36
- */
37
- async hasRcFile(cwd) {
38
- const filePath = (0, path_1.join)(cwd, '.adonisrc.json');
39
- return (0, fs_extra_1.pathExists)(filePath);
40
- }
41
- /**
42
- * Handle command
43
- */
44
- async generate() {
45
- const hasRcFile = await this.hasRcFile(this.application.appRoot);
46
- /**
47
- * Ensure `.adonisrc.json` file exists
48
- */
49
- if (!hasRcFile) {
50
- this.logger.error('Make sure your project root has ".adonisrc.json" file');
51
- return;
52
- }
53
- const transformations = this.createExact
54
- ? {
55
- extname: this.extname,
56
- }
57
- : {
58
- form: this.form,
59
- suffix: this.suffix,
60
- formIgnoreList: this.formIgnoreList,
61
- pattern: this.pattern,
62
- extname: this.extname,
63
- };
64
- const file = this.generator
65
- .addFile(this.resourceName, transformations)
66
- .stub(this.getStub())
67
- .useMustache()
68
- .destinationDir(this.getDestinationPath())
69
- .appRoot(this.application.appRoot)
70
- .apply(this.templateData());
71
- await this.generator.run();
72
- return file;
73
- }
74
- }
75
- exports.BaseGenerator = BaseGenerator;
@@ -1,35 +0,0 @@
1
- import { BaseGenerator } from './Base';
2
- /**
3
- * Command to make a new command
4
- */
5
- export default class MakeCommand extends BaseGenerator {
6
- /**
7
- * Required by BaseGenerator
8
- */
9
- protected pattern: "pascalcase";
10
- protected resourceName: string;
11
- protected createExact: boolean;
12
- /**
13
- * Command meta data
14
- */
15
- static commandName: string;
16
- static description: string;
17
- name: string;
18
- exact: boolean;
19
- /**
20
- * Returns the template stub based upon the `--resource`
21
- * flag value
22
- */
23
- protected getStub(): string;
24
- /**
25
- * Path to the commands directory
26
- */
27
- protected getDestinationPath(): string;
28
- /**
29
- * Passed down to the template.
30
- */
31
- protected templateData(): {
32
- toCommandName: () => (filename: string, render: any) => string;
33
- };
34
- run(): Promise<void>;
35
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/assembler
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
- return c > 3 && r && Object.defineProperty(target, key, r), r;
15
- };
16
- var __metadata = (this && this.__metadata) || function (k, v) {
17
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- const path_1 = require("path");
21
- const standalone_1 = require("@adonisjs/core/build/standalone");
22
- const helpers_1 = require("@poppinss/utils/build/helpers");
23
- const Base_1 = require("./Base");
24
- /**
25
- * Command to make a new command
26
- */
27
- class MakeCommand extends Base_1.BaseGenerator {
28
- constructor() {
29
- super(...arguments);
30
- /**
31
- * Required by BaseGenerator
32
- */
33
- this.pattern = 'pascalcase';
34
- }
35
- /**
36
- * Returns the template stub based upon the `--resource`
37
- * flag value
38
- */
39
- getStub() {
40
- return (0, path_1.join)(__dirname, '..', '..', 'templates', 'command.txt');
41
- }
42
- /**
43
- * Path to the commands directory
44
- */
45
- getDestinationPath() {
46
- return this.application.rcFile.directories.commands || 'commands';
47
- }
48
- /**
49
- * Passed down to the template.
50
- */
51
- templateData() {
52
- return {
53
- toCommandName: () => {
54
- return function (filename, render) {
55
- return helpers_1.string.snakeCase(render(filename)).replace(/_/, ':');
56
- };
57
- },
58
- };
59
- }
60
- async run() {
61
- this.resourceName = this.name;
62
- this.createExact = this.exact;
63
- await super.generate();
64
- }
65
- }
66
- /**
67
- * Command meta data
68
- */
69
- MakeCommand.commandName = 'make:command';
70
- MakeCommand.description = 'Make a new ace command';
71
- __decorate([
72
- standalone_1.args.string({ description: 'Name of the command class' }),
73
- __metadata("design:type", String)
74
- ], MakeCommand.prototype, "name", void 0);
75
- __decorate([
76
- standalone_1.flags.boolean({
77
- description: 'Create the command with the exact name as provided',
78
- alias: 'e',
79
- }),
80
- __metadata("design:type", Boolean)
81
- ], MakeCommand.prototype, "exact", void 0);
82
- exports.default = MakeCommand;
@@ -1,37 +0,0 @@
1
- import { BaseGenerator } from './Base';
2
- /**
3
- * Command to make a new HTTP Controller
4
- */
5
- export default class MakeController extends BaseGenerator {
6
- /**
7
- * Required by BaseGenerator
8
- */
9
- protected suffix: string;
10
- protected form: "plural";
11
- protected pattern: "pascalcase";
12
- protected resourceName: string;
13
- protected createExact: boolean;
14
- /**
15
- * Do not pluralize following controller names
16
- */
17
- protected formIgnoreList: string[];
18
- /**
19
- * Command meta data
20
- */
21
- static commandName: string;
22
- static description: string;
23
- name: string;
24
- resource: boolean;
25
- exact: boolean;
26
- /**
27
- * Returns the template stub based upon the `--resource`
28
- * flag value
29
- */
30
- protected getStub(): string;
31
- /**
32
- * Pull path from the `httpControllers` directory declaration from
33
- * the `.adonisrc.json` file or fallback to `app/Controllers/Http`
34
- */
35
- protected getDestinationPath(): string;
36
- run(): Promise<void>;
37
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/assembler
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
- return c > 3 && r && Object.defineProperty(target, key, r), r;
15
- };
16
- var __metadata = (this && this.__metadata) || function (k, v) {
17
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- const path_1 = require("path");
21
- const standalone_1 = require("@adonisjs/core/build/standalone");
22
- const Base_1 = require("./Base");
23
- /**
24
- * Command to make a new HTTP Controller
25
- */
26
- class MakeController extends Base_1.BaseGenerator {
27
- constructor() {
28
- super(...arguments);
29
- /**
30
- * Required by BaseGenerator
31
- */
32
- this.suffix = 'Controller';
33
- this.form = 'plural';
34
- this.pattern = 'pascalcase';
35
- /**
36
- * Do not pluralize following controller names
37
- */
38
- this.formIgnoreList = [
39
- 'Home',
40
- 'Auth',
41
- 'Login',
42
- 'Authentication',
43
- 'Adonis',
44
- 'Dashboard',
45
- 'Signup',
46
- 'Api',
47
- ];
48
- }
49
- /**
50
- * Returns the template stub based upon the `--resource`
51
- * flag value
52
- */
53
- getStub() {
54
- return (0, path_1.join)(__dirname, '..', '..', 'templates', this.resource ? 'resource-controller.txt' : 'controller.txt');
55
- }
56
- /**
57
- * Pull path from the `httpControllers` directory declaration from
58
- * the `.adonisrc.json` file or fallback to `app/Controllers/Http`
59
- */
60
- getDestinationPath() {
61
- return this.getPathForNamespace('httpControllers') || 'app/Controllers/Http';
62
- }
63
- async run() {
64
- this.resourceName = this.name;
65
- this.createExact = this.exact;
66
- await super.generate();
67
- }
68
- }
69
- /**
70
- * Command meta data
71
- */
72
- MakeController.commandName = 'make:controller';
73
- MakeController.description = 'Make a new HTTP controller';
74
- __decorate([
75
- standalone_1.args.string({ description: 'Name of the controller class' }),
76
- __metadata("design:type", String)
77
- ], MakeController.prototype, "name", void 0);
78
- __decorate([
79
- standalone_1.flags.boolean({ description: 'Add resourceful methods to the controller class', alias: 'r' }),
80
- __metadata("design:type", Boolean)
81
- ], MakeController.prototype, "resource", void 0);
82
- __decorate([
83
- standalone_1.flags.boolean({
84
- description: 'Create the controller with the exact name as provided',
85
- alias: 'e',
86
- }),
87
- __metadata("design:type", Boolean)
88
- ], MakeController.prototype, "exact", void 0);
89
- exports.default = MakeController;
@@ -1,32 +0,0 @@
1
- import { BaseGenerator } from './Base';
2
- /**
3
- * Command to make a new event exceptions class
4
- */
5
- export default class MakeException extends BaseGenerator {
6
- /**
7
- * Required by BaseGenerator
8
- */
9
- protected form: "singular";
10
- protected pattern: "pascalcase";
11
- protected resourceName: string;
12
- protected suffix: string;
13
- protected createExact: boolean;
14
- /**
15
- * Command meta data
16
- */
17
- static commandName: string;
18
- static description: string;
19
- name: string;
20
- selfHandle: boolean;
21
- exact: boolean;
22
- /**
23
- * Returns the template stub
24
- */
25
- protected getStub(): string;
26
- /**
27
- * Pull path from the `exceptions` namespace declaration from
28
- * the `.adonisrc.json` file or fallback to `app/Exceptions`
29
- */
30
- protected getDestinationPath(): string;
31
- run(): Promise<void>;
32
- }