@adonisjs/assembler 5.9.0 → 5.9.2

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 (65) hide show
  1. package/build/commands/Build.d.ts +37 -37
  2. package/build/commands/Build.js +138 -138
  3. package/build/commands/Invoke.d.ts +34 -34
  4. package/build/commands/Invoke.js +221 -221
  5. package/build/commands/Make/Base.d.ts +30 -30
  6. package/build/commands/Make/Base.js +75 -75
  7. package/build/commands/Make/Command.d.ts +35 -35
  8. package/build/commands/Make/Command.js +82 -82
  9. package/build/commands/Make/Controller.d.ts +37 -37
  10. package/build/commands/Make/Controller.js +89 -89
  11. package/build/commands/Make/Exception.d.ts +32 -32
  12. package/build/commands/Make/Exception.js +75 -75
  13. package/build/commands/Make/Listener.d.ts +30 -30
  14. package/build/commands/Make/Listener.js +70 -70
  15. package/build/commands/Make/Middleware.d.ts +31 -31
  16. package/build/commands/Make/Middleware.js +87 -87
  17. package/build/commands/Make/PreloadFile.d.ts +38 -38
  18. package/build/commands/Make/PreloadFile.js +157 -157
  19. package/build/commands/Make/Provider.d.ts +31 -31
  20. package/build/commands/Make/Provider.js +114 -114
  21. package/build/commands/Make/Suite.d.ts +41 -41
  22. package/build/commands/Make/Suite.js +120 -120
  23. package/build/commands/Make/Test.d.ts +35 -35
  24. package/build/commands/Make/Test.js +96 -96
  25. package/build/commands/Make/Validator.d.ts +31 -31
  26. package/build/commands/Make/Validator.js +71 -71
  27. package/build/commands/Make/View.d.ts +30 -30
  28. package/build/commands/Make/View.js +70 -70
  29. package/build/commands/Serve.d.ts +33 -33
  30. package/build/commands/Serve.js +112 -112
  31. package/build/commands/Test.d.ts +57 -57
  32. package/build/commands/Test.js +159 -159
  33. package/build/commands/TypeCheck.d.ts +16 -16
  34. package/build/commands/TypeCheck.js +85 -85
  35. package/build/config/paths.d.ts +7 -7
  36. package/build/config/paths.js +18 -18
  37. package/build/register.d.ts +1 -1
  38. package/build/register.js +15 -15
  39. package/build/src/AssetsBundler/index.d.ts +76 -76
  40. package/build/src/AssetsBundler/index.js +216 -216
  41. package/build/src/Compiler/index.d.ts +62 -62
  42. package/build/src/Compiler/index.js +287 -287
  43. package/build/src/Contracts/index.d.ts +8 -8
  44. package/build/src/Contracts/index.js +10 -10
  45. package/build/src/DevServer/index.d.ts +70 -70
  46. package/build/src/DevServer/index.js +306 -306
  47. package/build/src/EnvParser/index.d.ts +23 -23
  48. package/build/src/EnvParser/index.js +52 -52
  49. package/build/src/HttpServer/index.d.ts +34 -34
  50. package/build/src/HttpServer/index.js +87 -87
  51. package/build/src/Manifest/index.d.ts +32 -32
  52. package/build/src/Manifest/index.js +88 -88
  53. package/build/src/RcFile/index.d.ts +72 -72
  54. package/build/src/RcFile/index.js +174 -174
  55. package/build/src/Test/index.d.ts +75 -75
  56. package/build/src/Test/index.js +346 -346
  57. package/build/src/Test/process.d.ts +22 -22
  58. package/build/src/Test/process.js +68 -68
  59. package/build/src/Ts/index.d.ts +24 -24
  60. package/build/src/Ts/index.js +55 -55
  61. package/build/src/requireHook/index.d.ts +5 -5
  62. package/build/src/requireHook/index.js +28 -28
  63. package/build/src/requireHook/ioc-transformer.d.ts +6 -6
  64. package/build/src/requireHook/ioc-transformer.js +21 -21
  65. package/package.json +1 -1
@@ -1,221 +1,221 @@
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');
66
- pkgFile.install('webpack');
67
- pkgFile.install('webpack-cli');
68
- pkgFile.install('@babel/core');
69
- pkgFile.install('@babel/preset-env');
70
- pkgFile.useClient(this.getPackageManager());
71
- const spinner = sink_1.logger.await(sink_1.logger.colors.gray('configure @symfony/webpack-encore'));
72
- try {
73
- await pkgFile.commitAsync();
74
- spinner.update('Configured');
75
- spinner.stop();
76
- }
77
- catch (error) {
78
- spinner.update('Unable to install the package');
79
- spinner.stop();
80
- sink_1.logger.fatal(error);
81
- }
82
- }
83
- /**
84
- * Configure tests
85
- */
86
- async configureTests() {
87
- /**
88
- * Create "test.ts" file
89
- */
90
- const testsEntryPointFile = new sink_1.files.MustacheFile(this.application.appRoot, 'test.ts', (0, path_1.join)(__dirname, '..', 'templates/test-entrypoint.txt'));
91
- if (!testsEntryPointFile.exists()) {
92
- testsEntryPointFile.apply({}).commit();
93
- sink_1.logger.action('create').succeeded('test.ts');
94
- }
95
- /**
96
- * Create "tests/bootstrap.ts" file
97
- */
98
- const testsBootstrapFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/bootstrap.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/bootstrap.txt'));
99
- if (!testsBootstrapFile.exists()) {
100
- testsBootstrapFile.apply({}).commit();
101
- sink_1.logger.action('create').succeeded('tests/bootstrap.ts');
102
- }
103
- /**
104
- * Create "tests/functional/hello_world.spec.ts" file
105
- */
106
- 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`));
107
- if (!helloWorldTestFile.exists()) {
108
- helloWorldTestFile.apply({}).commit();
109
- sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
110
- }
111
- /**
112
- * Create "contracts/tests.ts" file
113
- */
114
- const testsContractsFile = new sink_1.files.MustacheFile(this.application.appRoot, 'contracts/tests.ts', (0, path_1.join)(__dirname, '..', 'templates/tests-contract.txt'));
115
- if (!testsContractsFile.exists()) {
116
- testsContractsFile.apply({}).commit();
117
- sink_1.logger.action('create').succeeded('contracts/tests.ts');
118
- }
119
- /**
120
- * Update AdonisRc file with test suites
121
- */
122
- const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
123
- rcFile.set('tests', {
124
- suites: [
125
- {
126
- name: 'functional',
127
- files: ['tests/functional/**/*.spec(.ts|.js)'],
128
- timeout: 60 * 1000,
129
- },
130
- ],
131
- });
132
- rcFile.addTestProvider('@japa/preset-adonis/TestsProvider');
133
- rcFile.commit();
134
- sink_1.logger.action('update').succeeded('.adonisrc.json');
135
- /**
136
- * Create ".env.test" file
137
- */
138
- const testEnvFile = new sink_1.files.NewLineFile(this.application.appRoot, '.env.test');
139
- if (!testEnvFile.exists()) {
140
- testEnvFile.add('NODE_ENV=test');
141
- /**
142
- * Set additional .env variables for "web" boilerplate
143
- */
144
- if (this.appType === 'web') {
145
- testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
146
- }
147
- testEnvFile.commit();
148
- sink_1.logger.action('create').succeeded('.env.test');
149
- }
150
- /**
151
- * Update "tsconfig.json"
152
- */
153
- const tsConfig = new sink_1.files.JsonFile(this.application.appRoot, 'tsconfig.json');
154
- const existingTypes = tsConfig.get('compilerOptions.types') || [];
155
- if (!existingTypes.includes('@japa/preset-adonis/build/adonis-typings')) {
156
- existingTypes.push('@japa/preset-adonis/build/adonis-typings');
157
- }
158
- tsConfig.set('compilerOptions.types', existingTypes);
159
- tsConfig.commit();
160
- sink_1.logger.action('update').succeeded('tsconfig.json');
161
- /**
162
- * Set additional .env variables for "web" boilerplate
163
- */
164
- if (this.appType === 'web') {
165
- testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
166
- }
167
- testEnvFile.commit();
168
- sink_1.logger.action('create').succeeded('.env.test');
169
- /**
170
- * Install required dependencies
171
- */
172
- const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
173
- pkgFile.install('@japa/runner');
174
- pkgFile.install('@japa/preset-adonis');
175
- pkgFile.useClient(this.getPackageManager());
176
- const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
177
- try {
178
- await pkgFile.commitAsync();
179
- spinner.update('Installed');
180
- spinner.stop();
181
- }
182
- catch (error) {
183
- spinner.update('Unable to install packages');
184
- spinner.stop();
185
- sink_1.logger.fatal(error);
186
- }
187
- }
188
- /**
189
- * Configure a give package
190
- */
191
- async configurePackage(name) {
192
- if (name === 'encore') {
193
- await this.configureEncore();
194
- return;
195
- }
196
- if (name === 'tests') {
197
- await this.configureTests();
198
- return;
199
- }
200
- await new sink_1.tasks.Instructions(name, this.application.appRoot, this.application, true).execute();
201
- await new Manifest_1.Manifest(this.application.appRoot, this.logger).generate();
202
- }
203
- /**
204
- * Invoked automatically by ace
205
- */
206
- async run() {
207
- for (let name of this.packages) {
208
- await this.configurePackage(name);
209
- }
210
- }
211
- }
212
- Configure.commandName = 'configure';
213
- Configure.description = 'Configure one or more AdonisJS packages';
214
- Configure.aliases = ['invoke'];
215
- __decorate([
216
- standalone_1.args.spread({
217
- description: 'Name of the package(s) you want to configure',
218
- }),
219
- __metadata("design:type", Array)
220
- ], Configure.prototype, "packages", void 0);
221
- exports.default = Configure;
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');
66
+ pkgFile.install('webpack');
67
+ pkgFile.install('webpack-cli');
68
+ pkgFile.install('@babel/core');
69
+ pkgFile.install('@babel/preset-env');
70
+ pkgFile.useClient(this.getPackageManager());
71
+ const spinner = sink_1.logger.await(sink_1.logger.colors.gray('configure @symfony/webpack-encore'));
72
+ try {
73
+ await pkgFile.commitAsync();
74
+ spinner.update('Configured');
75
+ spinner.stop();
76
+ }
77
+ catch (error) {
78
+ spinner.update('Unable to install the package');
79
+ spinner.stop();
80
+ sink_1.logger.fatal(error);
81
+ }
82
+ }
83
+ /**
84
+ * Configure tests
85
+ */
86
+ async configureTests() {
87
+ /**
88
+ * Create "test.ts" file
89
+ */
90
+ const testsEntryPointFile = new sink_1.files.MustacheFile(this.application.appRoot, 'test.ts', (0, path_1.join)(__dirname, '..', 'templates/test-entrypoint.txt'));
91
+ if (!testsEntryPointFile.exists()) {
92
+ testsEntryPointFile.apply({}).commit();
93
+ sink_1.logger.action('create').succeeded('test.ts');
94
+ }
95
+ /**
96
+ * Create "tests/bootstrap.ts" file
97
+ */
98
+ const testsBootstrapFile = new sink_1.files.MustacheFile(this.application.appRoot, 'tests/bootstrap.ts', (0, path_1.join)(__dirname, '..', 'templates/tests/bootstrap.txt'));
99
+ if (!testsBootstrapFile.exists()) {
100
+ testsBootstrapFile.apply({}).commit();
101
+ sink_1.logger.action('create').succeeded('tests/bootstrap.ts');
102
+ }
103
+ /**
104
+ * Create "tests/functional/hello_world.spec.ts" file
105
+ */
106
+ 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`));
107
+ if (!helloWorldTestFile.exists()) {
108
+ helloWorldTestFile.apply({}).commit();
109
+ sink_1.logger.action('create').succeeded('tests/functional/hello_world.spec.ts');
110
+ }
111
+ /**
112
+ * Create "contracts/tests.ts" file
113
+ */
114
+ const testsContractsFile = new sink_1.files.MustacheFile(this.application.appRoot, 'contracts/tests.ts', (0, path_1.join)(__dirname, '..', 'templates/tests-contract.txt'));
115
+ if (!testsContractsFile.exists()) {
116
+ testsContractsFile.apply({}).commit();
117
+ sink_1.logger.action('create').succeeded('contracts/tests.ts');
118
+ }
119
+ /**
120
+ * Update AdonisRc file with test suites
121
+ */
122
+ const rcFile = new sink_1.files.AdonisRcFile(this.application.appRoot);
123
+ rcFile.set('tests', {
124
+ suites: [
125
+ {
126
+ name: 'functional',
127
+ files: ['tests/functional/**/*.spec(.ts|.js)'],
128
+ timeout: 60 * 1000,
129
+ },
130
+ ],
131
+ });
132
+ rcFile.addTestProvider('@japa/preset-adonis/TestsProvider');
133
+ rcFile.commit();
134
+ sink_1.logger.action('update').succeeded('.adonisrc.json');
135
+ /**
136
+ * Create ".env.test" file
137
+ */
138
+ const testEnvFile = new sink_1.files.NewLineFile(this.application.appRoot, '.env.test');
139
+ if (!testEnvFile.exists()) {
140
+ testEnvFile.add('NODE_ENV=test');
141
+ /**
142
+ * Set additional .env variables for "web" boilerplate
143
+ */
144
+ if (this.appType === 'web') {
145
+ testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
146
+ }
147
+ testEnvFile.commit();
148
+ sink_1.logger.action('create').succeeded('.env.test');
149
+ }
150
+ /**
151
+ * Update "tsconfig.json"
152
+ */
153
+ const tsConfig = new sink_1.files.JsonFile(this.application.appRoot, 'tsconfig.json');
154
+ const existingTypes = tsConfig.get('compilerOptions.types') || [];
155
+ if (!existingTypes.includes('@japa/preset-adonis/build/adonis-typings')) {
156
+ existingTypes.push('@japa/preset-adonis/build/adonis-typings');
157
+ }
158
+ tsConfig.set('compilerOptions.types', existingTypes);
159
+ tsConfig.commit();
160
+ sink_1.logger.action('update').succeeded('tsconfig.json');
161
+ /**
162
+ * Set additional .env variables for "web" boilerplate
163
+ */
164
+ if (this.appType === 'web') {
165
+ testEnvFile.add(['ASSETS_DRIVER=fake', 'SESSION_DRIVER=memory']);
166
+ }
167
+ testEnvFile.commit();
168
+ sink_1.logger.action('create').succeeded('.env.test');
169
+ /**
170
+ * Install required dependencies
171
+ */
172
+ const pkgFile = new sink_1.files.PackageJsonFile(this.application.appRoot);
173
+ pkgFile.install('@japa/runner');
174
+ pkgFile.install('@japa/preset-adonis');
175
+ pkgFile.useClient(this.getPackageManager());
176
+ const spinner = sink_1.logger.await(sink_1.logger.colors.gray('installing @japa/runner, @japa/preset-adonis'));
177
+ try {
178
+ await pkgFile.commitAsync();
179
+ spinner.update('Installed');
180
+ spinner.stop();
181
+ }
182
+ catch (error) {
183
+ spinner.update('Unable to install packages');
184
+ spinner.stop();
185
+ sink_1.logger.fatal(error);
186
+ }
187
+ }
188
+ /**
189
+ * Configure a give package
190
+ */
191
+ async configurePackage(name) {
192
+ if (name === 'encore') {
193
+ await this.configureEncore();
194
+ return;
195
+ }
196
+ if (name === 'tests') {
197
+ await this.configureTests();
198
+ return;
199
+ }
200
+ await new sink_1.tasks.Instructions(name, this.application.appRoot, this.application, true).execute();
201
+ await new Manifest_1.Manifest(this.application.appRoot, this.logger).generate();
202
+ }
203
+ /**
204
+ * Invoked automatically by ace
205
+ */
206
+ async run() {
207
+ for (let name of this.packages) {
208
+ await this.configurePackage(name);
209
+ }
210
+ }
211
+ }
212
+ Configure.commandName = 'configure';
213
+ Configure.description = 'Configure one or more AdonisJS packages';
214
+ Configure.aliases = ['invoke'];
215
+ __decorate([
216
+ standalone_1.args.spread({
217
+ description: 'Name of the package(s) you want to configure',
218
+ }),
219
+ __metadata("design:type", Array)
220
+ ], Configure.prototype, "packages", void 0);
221
+ exports.default = Configure;
@@ -1,30 +1,30 @@
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
+ 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 +1,75 @@
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
+ "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;