@adonisjs/assembler 5.9.4 → 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.
- package/LICENSE.md +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/src/bundler.d.ts +10 -0
- package/build/src/bundler.js +133 -0
- package/build/src/dev_server.d.ts +13 -0
- package/build/src/dev_server.js +189 -0
- package/build/src/run.d.ts +3 -0
- package/build/src/run.js +19 -0
- package/build/src/types.d.ts +26 -0
- package/build/src/watch.d.ts +8 -0
- package/build/src/watch.js +18 -0
- package/package.json +77 -99
- package/build/ace-manifest.json +0 -521
- package/build/commands/Build.d.ts +0 -37
- package/build/commands/Build.js +0 -138
- package/build/commands/Invoke.d.ts +0 -34
- package/build/commands/Invoke.js +0 -234
- package/build/commands/Make/Base.d.ts +0 -30
- package/build/commands/Make/Base.js +0 -75
- package/build/commands/Make/Command.d.ts +0 -35
- package/build/commands/Make/Command.js +0 -82
- package/build/commands/Make/Controller.d.ts +0 -37
- package/build/commands/Make/Controller.js +0 -89
- package/build/commands/Make/Exception.d.ts +0 -32
- package/build/commands/Make/Exception.js +0 -75
- package/build/commands/Make/Listener.d.ts +0 -30
- package/build/commands/Make/Listener.js +0 -70
- package/build/commands/Make/Middleware.d.ts +0 -31
- package/build/commands/Make/Middleware.js +0 -87
- package/build/commands/Make/PreloadFile.d.ts +0 -38
- package/build/commands/Make/PreloadFile.js +0 -157
- package/build/commands/Make/Provider.d.ts +0 -31
- package/build/commands/Make/Provider.js +0 -114
- package/build/commands/Make/Suite.d.ts +0 -41
- package/build/commands/Make/Suite.js +0 -120
- package/build/commands/Make/Test.d.ts +0 -35
- package/build/commands/Make/Test.js +0 -96
- package/build/commands/Make/Validator.d.ts +0 -31
- package/build/commands/Make/Validator.js +0 -71
- package/build/commands/Make/View.d.ts +0 -30
- package/build/commands/Make/View.js +0 -70
- package/build/commands/Serve.d.ts +0 -33
- package/build/commands/Serve.js +0 -112
- package/build/commands/Test.d.ts +0 -57
- package/build/commands/Test.js +0 -159
- package/build/commands/TypeCheck.d.ts +0 -16
- package/build/commands/TypeCheck.js +0 -85
- package/build/config/paths.d.ts +0 -7
- package/build/config/paths.js +0 -18
- package/build/register.js +0 -15
- package/build/src/AssetsBundler/index.d.ts +0 -76
- package/build/src/AssetsBundler/index.js +0 -216
- package/build/src/Compiler/index.d.ts +0 -62
- package/build/src/Compiler/index.js +0 -287
- package/build/src/Contracts/index.d.ts +0 -8
- package/build/src/Contracts/index.js +0 -10
- package/build/src/DevServer/index.d.ts +0 -70
- package/build/src/DevServer/index.js +0 -306
- package/build/src/EnvParser/index.d.ts +0 -21
- package/build/src/EnvParser/index.js +0 -48
- package/build/src/HttpServer/index.d.ts +0 -34
- package/build/src/HttpServer/index.js +0 -87
- package/build/src/Manifest/index.d.ts +0 -32
- package/build/src/Manifest/index.js +0 -88
- package/build/src/RcFile/index.d.ts +0 -72
- package/build/src/RcFile/index.js +0 -174
- package/build/src/Test/index.d.ts +0 -75
- package/build/src/Test/index.js +0 -346
- package/build/src/Test/process.d.ts +0 -22
- package/build/src/Test/process.js +0 -68
- package/build/src/Ts/index.d.ts +0 -24
- package/build/src/Ts/index.js +0 -55
- package/build/src/requireHook/index.d.ts +0 -5
- package/build/src/requireHook/index.js +0 -28
- package/build/src/requireHook/ioc-transformer.d.ts +0 -6
- package/build/src/requireHook/ioc-transformer.js +0 -21
- package/build/templates/command.txt +0 -33
- package/build/templates/controller.txt +0 -3
- package/build/templates/event-listener.txt +0 -3
- package/build/templates/exception.txt +0 -15
- package/build/templates/middleware.txt +0 -8
- package/build/templates/preload-file.txt +0 -9
- package/build/templates/provider.txt +0 -40
- package/build/templates/resource-controller.txt +0 -17
- package/build/templates/self-handle-exception.txt +0 -32
- package/build/templates/test-entrypoint.txt +0 -45
- package/build/templates/test.txt +0 -5
- package/build/templates/tests/bootstrap.txt +0 -69
- package/build/templates/tests/functional/hello_world_api.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_slim.spec.txt +0 -8
- package/build/templates/tests/functional/hello_world_web.spec.txt +0 -8
- package/build/templates/tests-contract.txt +0 -18
- package/build/templates/validator.txt +0 -40
- package/build/templates/view.txt +0 -0
- package/build/templates/webpack.config.txt +0 -214
- /package/build/{register.d.ts → src/types.js} +0 -0
package/build/commands/Test.js
DELETED
|
@@ -1,159 +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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
-
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;
|
|
30
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
-
};
|
|
32
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
40
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
44
|
-
/**
|
|
45
|
-
* Run tests
|
|
46
|
-
*/
|
|
47
|
-
class Test extends standalone_1.BaseCommand {
|
|
48
|
-
constructor() {
|
|
49
|
-
super(...arguments);
|
|
50
|
-
/**
|
|
51
|
-
* Arguments to pass to the `node` binary
|
|
52
|
-
*/
|
|
53
|
-
this.nodeArgs = [];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Convert command flags to test filters
|
|
57
|
-
*/
|
|
58
|
-
getTestFilters() {
|
|
59
|
-
const filters = {};
|
|
60
|
-
if (this.forceExit) {
|
|
61
|
-
filters['--force-exit'] = true;
|
|
62
|
-
}
|
|
63
|
-
if (this.files) {
|
|
64
|
-
filters['--files'] = this.files;
|
|
65
|
-
}
|
|
66
|
-
if (this.timeout !== undefined) {
|
|
67
|
-
filters['--timeout'] = this.timeout;
|
|
68
|
-
}
|
|
69
|
-
if (this.tags) {
|
|
70
|
-
filters['--tags'] = this.tags;
|
|
71
|
-
}
|
|
72
|
-
if (this.suites) {
|
|
73
|
-
filters._ = this.suites;
|
|
74
|
-
}
|
|
75
|
-
if (this.ignoreTags) {
|
|
76
|
-
filters['--ignore-tags'] = this.ignoreTags;
|
|
77
|
-
}
|
|
78
|
-
if (this.tests) {
|
|
79
|
-
filters['--tests'] = this.tests;
|
|
80
|
-
}
|
|
81
|
-
if (this.groups) {
|
|
82
|
-
filters['--groups'] = this.groups;
|
|
83
|
-
}
|
|
84
|
-
return filters;
|
|
85
|
-
}
|
|
86
|
-
async run() {
|
|
87
|
-
const { TestsServer } = await Promise.resolve().then(() => __importStar(require('../src/Test')));
|
|
88
|
-
try {
|
|
89
|
-
if (this.watch) {
|
|
90
|
-
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).watch();
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
await new TestsServer(this.application.appRoot, this.getTestFilters(), this.nodeArgs, this.logger).run();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
this.exitCode = 1;
|
|
98
|
-
this.logger.fatal(error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
Test.commandName = 'test';
|
|
103
|
-
Test.description = 'Run AdonisJS tests';
|
|
104
|
-
Test.settings = {
|
|
105
|
-
stayAlive: true,
|
|
106
|
-
};
|
|
107
|
-
__decorate([
|
|
108
|
-
standalone_1.args.spread({ description: 'Run tests for only the specified suites', required: false }),
|
|
109
|
-
__metadata("design:type", Array)
|
|
110
|
-
], Test.prototype, "suites", void 0);
|
|
111
|
-
__decorate([
|
|
112
|
-
standalone_1.flags.array({
|
|
113
|
-
description: 'Run tests for the mentioned files only',
|
|
114
|
-
}),
|
|
115
|
-
__metadata("design:type", Array)
|
|
116
|
-
], Test.prototype, "files", void 0);
|
|
117
|
-
__decorate([
|
|
118
|
-
standalone_1.flags.boolean({
|
|
119
|
-
description: 'Watch for file changes and re-run tests on file change',
|
|
120
|
-
alias: 'w',
|
|
121
|
-
}),
|
|
122
|
-
__metadata("design:type", Boolean)
|
|
123
|
-
], Test.prototype, "watch", void 0);
|
|
124
|
-
__decorate([
|
|
125
|
-
standalone_1.flags.boolean({
|
|
126
|
-
description: 'Detect file changes by polling files instead of listening to filesystem events',
|
|
127
|
-
alias: 'p',
|
|
128
|
-
}),
|
|
129
|
-
__metadata("design:type", Boolean)
|
|
130
|
-
], Test.prototype, "poll", void 0);
|
|
131
|
-
__decorate([
|
|
132
|
-
standalone_1.flags.array({ description: 'CLI options to pass to the node command line' }),
|
|
133
|
-
__metadata("design:type", Array)
|
|
134
|
-
], Test.prototype, "nodeArgs", void 0);
|
|
135
|
-
__decorate([
|
|
136
|
-
standalone_1.flags.array({ description: 'Filter tests by tags' }),
|
|
137
|
-
__metadata("design:type", Array)
|
|
138
|
-
], Test.prototype, "tags", void 0);
|
|
139
|
-
__decorate([
|
|
140
|
-
standalone_1.flags.array({ description: 'Filter tests by ignoring tags' }),
|
|
141
|
-
__metadata("design:type", Array)
|
|
142
|
-
], Test.prototype, "ignoreTags", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
standalone_1.flags.array({ description: 'Filter tests by title' }),
|
|
145
|
-
__metadata("design:type", Array)
|
|
146
|
-
], Test.prototype, "tests", void 0);
|
|
147
|
-
__decorate([
|
|
148
|
-
standalone_1.flags.array({ description: 'Filter tests by group title' }),
|
|
149
|
-
__metadata("design:type", Array)
|
|
150
|
-
], Test.prototype, "groups", void 0);
|
|
151
|
-
__decorate([
|
|
152
|
-
standalone_1.flags.number({ description: 'Customize tests timeout' }),
|
|
153
|
-
__metadata("design:type", Number)
|
|
154
|
-
], Test.prototype, "timeout", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
standalone_1.flags.boolean({ description: 'Force exit the tests runner process' }),
|
|
157
|
-
__metadata("design:type", Boolean)
|
|
158
|
-
], Test.prototype, "forceExit", void 0);
|
|
159
|
-
exports.default = Test;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from '@adonisjs/core/build/standalone';
|
|
2
|
-
/**
|
|
3
|
-
* TypeCheck project without writing the compiled output to the disk
|
|
4
|
-
*/
|
|
5
|
-
export default class TypeCheck extends BaseCommand {
|
|
6
|
-
static commandName: string;
|
|
7
|
-
static description: string;
|
|
8
|
-
/**
|
|
9
|
-
* Path to the TypeScript project configuration file. Defaults to "tsconfig.json"
|
|
10
|
-
*/
|
|
11
|
-
tsconfig: string;
|
|
12
|
-
/**
|
|
13
|
-
* Invoked automatically by ace
|
|
14
|
-
*/
|
|
15
|
-
run(): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,85 +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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
-
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;
|
|
30
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
-
};
|
|
32
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
40
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
const standalone_1 = require("@adonisjs/core/build/standalone");
|
|
44
|
-
const paths_1 = require("../config/paths");
|
|
45
|
-
/**
|
|
46
|
-
* TypeCheck project without writing the compiled output to the disk
|
|
47
|
-
*/
|
|
48
|
-
class TypeCheck extends standalone_1.BaseCommand {
|
|
49
|
-
constructor() {
|
|
50
|
-
super(...arguments);
|
|
51
|
-
/**
|
|
52
|
-
* Path to the TypeScript project configuration file. Defaults to "tsconfig.json"
|
|
53
|
-
*/
|
|
54
|
-
this.tsconfig = paths_1.TSCONFIG_FILE_NAME;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Invoked automatically by ace
|
|
58
|
-
*/
|
|
59
|
-
async run() {
|
|
60
|
-
const { Compiler } = await Promise.resolve().then(() => __importStar(require('../src/Compiler')));
|
|
61
|
-
try {
|
|
62
|
-
const compiler = new Compiler(this.application.appRoot, [], false, this.logger, this.tsconfig);
|
|
63
|
-
const success = await compiler.typeCheck();
|
|
64
|
-
/**
|
|
65
|
-
* Set exitCode based upon the typecheck status
|
|
66
|
-
*/
|
|
67
|
-
if (!success) {
|
|
68
|
-
this.exitCode = 1;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
this.logger.fatal(error);
|
|
73
|
-
this.exitCode = 1;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
TypeCheck.commandName = 'type-check';
|
|
78
|
-
TypeCheck.description = 'Type check TypeScript source without writing the compiled output on disk';
|
|
79
|
-
__decorate([
|
|
80
|
-
standalone_1.flags.string({
|
|
81
|
-
description: 'Path to the TypeScript project configuration file',
|
|
82
|
-
}),
|
|
83
|
-
__metadata("design:type", String)
|
|
84
|
-
], TypeCheck.prototype, "tsconfig", void 0);
|
|
85
|
-
exports.default = TypeCheck;
|
package/build/config/paths.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const ACE_FILE_NAME = "ace";
|
|
2
|
-
export declare const DEFAULT_BUILD_DIR = "build";
|
|
3
|
-
export declare const RCFILE_NAME = ".adonisrc.json";
|
|
4
|
-
export declare const ENV_FILES: string[];
|
|
5
|
-
export declare const SERVER_ENTRY_FILE = "server.ts";
|
|
6
|
-
export declare const TESTS_ENTRY_FILE = "test.ts";
|
|
7
|
-
export declare const TSCONFIG_FILE_NAME = "tsconfig.json";
|
package/build/config/paths.js
DELETED
|
@@ -1,18 +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.TSCONFIG_FILE_NAME = exports.TESTS_ENTRY_FILE = exports.SERVER_ENTRY_FILE = exports.ENV_FILES = exports.RCFILE_NAME = exports.DEFAULT_BUILD_DIR = exports.ACE_FILE_NAME = void 0;
|
|
12
|
-
exports.ACE_FILE_NAME = 'ace';
|
|
13
|
-
exports.DEFAULT_BUILD_DIR = 'build';
|
|
14
|
-
exports.RCFILE_NAME = '.adonisrc.json';
|
|
15
|
-
exports.ENV_FILES = ['.env', '.env.testing'];
|
|
16
|
-
exports.SERVER_ENTRY_FILE = 'server.ts';
|
|
17
|
-
exports.TESTS_ENTRY_FILE = 'test.ts';
|
|
18
|
-
exports.TSCONFIG_FILE_NAME = 'tsconfig.json';
|
package/build/register.js
DELETED
|
@@ -1,15 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const requireHook_1 = __importDefault(require("./src/requireHook"));
|
|
15
|
-
(0, requireHook_1.default)(process.env.ADONIS_ACE_CWD || process.cwd());
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import Emittery from 'emittery';
|
|
2
|
-
import { logger as uiLogger } from '@poppinss/cliui';
|
|
3
|
-
export type DevServerResponse = {
|
|
4
|
-
state: 'not-installed' | 'no-assets';
|
|
5
|
-
} | {
|
|
6
|
-
state: 'running';
|
|
7
|
-
port: string;
|
|
8
|
-
host: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Assets bundler uses webpack encore to build frontend dependencies
|
|
12
|
-
*/
|
|
13
|
-
export declare class AssetsBundler extends Emittery {
|
|
14
|
-
private projectRoot;
|
|
15
|
-
private buildAssets;
|
|
16
|
-
private logger;
|
|
17
|
-
private env;
|
|
18
|
-
/**
|
|
19
|
-
* Binary to execute
|
|
20
|
-
*/
|
|
21
|
-
private binaryName;
|
|
22
|
-
private encoreArgs;
|
|
23
|
-
/**
|
|
24
|
-
* Options passed to spawn a child process
|
|
25
|
-
*/
|
|
26
|
-
private execaOptions;
|
|
27
|
-
constructor(projectRoot: string, encoreArgs: string[] | undefined, buildAssets: boolean, logger: typeof uiLogger, env?: {
|
|
28
|
-
[key: string]: string;
|
|
29
|
-
});
|
|
30
|
-
/**
|
|
31
|
-
* Find if encore is installed
|
|
32
|
-
*/
|
|
33
|
-
private isEncoreInstalled;
|
|
34
|
-
/**
|
|
35
|
-
* Notify user that we are about use encore
|
|
36
|
-
*/
|
|
37
|
-
private notifyAboutEncore;
|
|
38
|
-
/**
|
|
39
|
-
* Logs the line to stdout
|
|
40
|
-
*/
|
|
41
|
-
private log;
|
|
42
|
-
/**
|
|
43
|
-
* Logs the line to stderr
|
|
44
|
-
*/
|
|
45
|
-
private logError;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the custom port defined using the `--port` flag in encore
|
|
48
|
-
* flags
|
|
49
|
-
*/
|
|
50
|
-
private findCustomPort;
|
|
51
|
-
/**
|
|
52
|
-
* Returns the custom host defined using the `--host` flag in encore
|
|
53
|
-
* flags
|
|
54
|
-
*/
|
|
55
|
-
private findCustomHost;
|
|
56
|
-
/**
|
|
57
|
-
* Execute command
|
|
58
|
-
*/
|
|
59
|
-
private exec;
|
|
60
|
-
/**
|
|
61
|
-
* Build assets using encore
|
|
62
|
-
*/
|
|
63
|
-
build(): Promise<{
|
|
64
|
-
hasErrors: boolean;
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Build assets for production
|
|
68
|
-
*/
|
|
69
|
-
buildForProduction(): Promise<{
|
|
70
|
-
hasErrors: boolean;
|
|
71
|
-
}>;
|
|
72
|
-
/**
|
|
73
|
-
* Start the webpack dev server
|
|
74
|
-
*/
|
|
75
|
-
startDevServer(): Promise<DevServerResponse>;
|
|
76
|
-
}
|
|
@@ -1,216 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.AssetsBundler = void 0;
|
|
15
|
-
const execa_1 = __importDefault(require("execa"));
|
|
16
|
-
const get_port_1 = __importDefault(require("get-port"));
|
|
17
|
-
const emittery_1 = __importDefault(require("emittery"));
|
|
18
|
-
const helpers_1 = require("@poppinss/utils/build/helpers");
|
|
19
|
-
/**
|
|
20
|
-
* Assets bundler uses webpack encore to build frontend dependencies
|
|
21
|
-
*/
|
|
22
|
-
class AssetsBundler extends emittery_1.default {
|
|
23
|
-
constructor(projectRoot, encoreArgs = [], buildAssets = true, logger, env = {}) {
|
|
24
|
-
super();
|
|
25
|
-
this.projectRoot = projectRoot;
|
|
26
|
-
this.buildAssets = buildAssets;
|
|
27
|
-
this.logger = logger;
|
|
28
|
-
this.env = env;
|
|
29
|
-
/**
|
|
30
|
-
* Binary to execute
|
|
31
|
-
*/
|
|
32
|
-
this.binaryName = 'encore';
|
|
33
|
-
this.encoreArgs = [];
|
|
34
|
-
/**
|
|
35
|
-
* Options passed to spawn a child process
|
|
36
|
-
*/
|
|
37
|
-
this.execaOptions = {
|
|
38
|
-
preferLocal: true,
|
|
39
|
-
buffer: false,
|
|
40
|
-
stdio: 'pipe',
|
|
41
|
-
localDir: this.projectRoot,
|
|
42
|
-
cwd: this.projectRoot,
|
|
43
|
-
windowsHide: false,
|
|
44
|
-
env: {
|
|
45
|
-
FORCE_COLOR: 'true',
|
|
46
|
-
...this.env,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
this.encoreArgs = encoreArgs.reduce((result, arg) => {
|
|
50
|
-
result = result.concat(arg.split(' '));
|
|
51
|
-
return result;
|
|
52
|
-
}, []);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Find if encore is installed
|
|
56
|
-
*/
|
|
57
|
-
isEncoreInstalled() {
|
|
58
|
-
try {
|
|
59
|
-
(0, helpers_1.resolveDir)(this.projectRoot, '@symfony/webpack-encore');
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Notify user that we are about use encore
|
|
68
|
-
*/
|
|
69
|
-
notifyAboutEncore() {
|
|
70
|
-
this.logger.info(`detected { ${this.logger.colors.dim().yellow('@symfony/webpack-encore')} }`);
|
|
71
|
-
this.logger.info(`building frontend assets. Use { ${this.logger.colors
|
|
72
|
-
.dim()
|
|
73
|
-
.yellow('--no-assets')} } to disable`);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Logs the line to stdout
|
|
77
|
-
*/
|
|
78
|
-
log(line) {
|
|
79
|
-
line = line.toString().trim();
|
|
80
|
-
if (!line.length) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
console.log(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Logs the line to stderr
|
|
87
|
-
*/
|
|
88
|
-
logError(line) {
|
|
89
|
-
line = line.toString().trim();
|
|
90
|
-
if (!line.length) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
console.error(`[ ${this.logger.colors.cyan('encore')} ] ${line}`);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Returns the custom port defined using the `--port` flag in encore
|
|
97
|
-
* flags
|
|
98
|
-
*/
|
|
99
|
-
findCustomPort() {
|
|
100
|
-
let portIndex = this.encoreArgs.findIndex((arg) => arg === '--port');
|
|
101
|
-
if (portIndex > -1) {
|
|
102
|
-
return this.encoreArgs[portIndex + 1];
|
|
103
|
-
}
|
|
104
|
-
portIndex = this.encoreArgs.findIndex((arg) => arg.includes('--port'));
|
|
105
|
-
if (portIndex > -1) {
|
|
106
|
-
const tokens = this.encoreArgs[portIndex].split('=');
|
|
107
|
-
return tokens[1] && tokens[1].trim();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns the custom host defined using the `--host` flag in encore
|
|
112
|
-
* flags
|
|
113
|
-
*/
|
|
114
|
-
findCustomHost() {
|
|
115
|
-
let hostIndex = this.encoreArgs.findIndex((arg) => arg === '--host');
|
|
116
|
-
if (hostIndex > -1) {
|
|
117
|
-
return this.encoreArgs[hostIndex + 1];
|
|
118
|
-
}
|
|
119
|
-
hostIndex = this.encoreArgs.findIndex((arg) => arg.includes('--host'));
|
|
120
|
-
if (hostIndex > -1) {
|
|
121
|
-
const tokens = this.encoreArgs[hostIndex].split('=');
|
|
122
|
-
return tokens[1] && tokens[1].trim();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Execute command
|
|
127
|
-
*/
|
|
128
|
-
exec(args) {
|
|
129
|
-
return new Promise((resolve, reject) => {
|
|
130
|
-
const childProcess = (0, execa_1.default)(this.binaryName, args, this.execaOptions);
|
|
131
|
-
childProcess.stdout?.on('data', (line) => this.log(line));
|
|
132
|
-
childProcess.stderr?.on('data', (line) => this.logError(line));
|
|
133
|
-
childProcess.on('error', (error) => reject(error));
|
|
134
|
-
childProcess.on('close', (code) => {
|
|
135
|
-
if (code && code !== 0) {
|
|
136
|
-
reject(`Process exited with code ${code}`);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
resolve();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Build assets using encore
|
|
146
|
-
*/
|
|
147
|
-
async build() {
|
|
148
|
-
if (!this.buildAssets) {
|
|
149
|
-
return { hasErrors: false };
|
|
150
|
-
}
|
|
151
|
-
if (!this.isEncoreInstalled()) {
|
|
152
|
-
return { hasErrors: false };
|
|
153
|
-
}
|
|
154
|
-
this.notifyAboutEncore();
|
|
155
|
-
try {
|
|
156
|
-
await this.exec(['dev'].concat(this.encoreArgs));
|
|
157
|
-
return { hasErrors: false };
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
return { hasErrors: true };
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Build assets for production
|
|
165
|
-
*/
|
|
166
|
-
async buildForProduction() {
|
|
167
|
-
if (!this.buildAssets) {
|
|
168
|
-
return { hasErrors: false };
|
|
169
|
-
}
|
|
170
|
-
if (!this.isEncoreInstalled()) {
|
|
171
|
-
return { hasErrors: false };
|
|
172
|
-
}
|
|
173
|
-
this.notifyAboutEncore();
|
|
174
|
-
try {
|
|
175
|
-
await this.exec(['production'].concat(this.encoreArgs));
|
|
176
|
-
return { hasErrors: false };
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
return { hasErrors: true };
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Start the webpack dev server
|
|
184
|
-
*/
|
|
185
|
-
async startDevServer() {
|
|
186
|
-
if (!this.isEncoreInstalled()) {
|
|
187
|
-
return { state: 'not-installed' };
|
|
188
|
-
}
|
|
189
|
-
if (!this.buildAssets) {
|
|
190
|
-
return { state: 'no-assets' };
|
|
191
|
-
}
|
|
192
|
-
const customHost = this.findCustomHost() || 'localhost';
|
|
193
|
-
/**
|
|
194
|
-
* Define a random port when the "--port" flag is not passed.
|
|
195
|
-
*
|
|
196
|
-
* Encore anyways doesn't allow defining port inside the webpack.config.js
|
|
197
|
-
* file for generating the manifest and entrypoints file.
|
|
198
|
-
*
|
|
199
|
-
* @see
|
|
200
|
-
* https://github.com/symfony/webpack-encore/issues/941#issuecomment-787568811
|
|
201
|
-
*/
|
|
202
|
-
let customPort = this.findCustomPort();
|
|
203
|
-
if (!customPort) {
|
|
204
|
-
const randomPort = await (0, get_port_1.default)({ port: 8080, host: 'localhost' });
|
|
205
|
-
customPort = String(randomPort);
|
|
206
|
-
this.encoreArgs.push('--port', customPort);
|
|
207
|
-
}
|
|
208
|
-
const childProcess = (0, execa_1.default)(this.binaryName, ['dev-server'].concat(this.encoreArgs), this.execaOptions);
|
|
209
|
-
childProcess.stdout?.on('data', (line) => this.log(line));
|
|
210
|
-
childProcess.stderr?.on('data', (line) => this.logError(line));
|
|
211
|
-
childProcess.on('close', (code, signal) => this.emit('close', { code, signal }));
|
|
212
|
-
childProcess.on('exit', (code, signal) => this.emit('exit', { code, signal }));
|
|
213
|
-
return { state: 'running', port: customPort, host: customHost };
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
exports.AssetsBundler = AssetsBundler;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { logger as uiLogger } from '@poppinss/cliui';
|
|
2
|
-
/**
|
|
3
|
-
* Exposes the API to build the AdonisJs project for development or
|
|
4
|
-
* production. The production build has it's own set of node_modules
|
|
5
|
-
*/
|
|
6
|
-
export declare class Compiler {
|
|
7
|
-
appRoot: string;
|
|
8
|
-
private encoreArgs;
|
|
9
|
-
private buildAssets;
|
|
10
|
-
private logger;
|
|
11
|
-
/**
|
|
12
|
-
* Reference to typescript compiler
|
|
13
|
-
*/
|
|
14
|
-
private ts;
|
|
15
|
-
/**
|
|
16
|
-
* Reference to rc File
|
|
17
|
-
*/
|
|
18
|
-
private rcFile;
|
|
19
|
-
constructor(appRoot: string, encoreArgs: string[], buildAssets: boolean, logger?: typeof uiLogger, tsconfig?: string);
|
|
20
|
-
/**
|
|
21
|
-
* Returns relative unix path from the project root. Used for
|
|
22
|
-
* display only
|
|
23
|
-
*/
|
|
24
|
-
private getRelativeUnixPath;
|
|
25
|
-
/**
|
|
26
|
-
* Cleans up the build directory
|
|
27
|
-
*/
|
|
28
|
-
private cleanupBuildDirectory;
|
|
29
|
-
/**
|
|
30
|
-
* Copies .adonisrc.json file to the destination
|
|
31
|
-
*/
|
|
32
|
-
private copyAdonisRcFile;
|
|
33
|
-
/**
|
|
34
|
-
* Copy all meta files to the build directory
|
|
35
|
-
*/
|
|
36
|
-
private copyMetaFiles;
|
|
37
|
-
/**
|
|
38
|
-
* Copy files to destination directory
|
|
39
|
-
*/
|
|
40
|
-
private copyFiles;
|
|
41
|
-
/**
|
|
42
|
-
* Build typescript source files
|
|
43
|
-
*/
|
|
44
|
-
private buildTypescriptSource;
|
|
45
|
-
/**
|
|
46
|
-
* Log the message that ts build and failed
|
|
47
|
-
*/
|
|
48
|
-
private logTsBuildFailed;
|
|
49
|
-
/**
|
|
50
|
-
* Typecheck the project without emit
|
|
51
|
-
*/
|
|
52
|
-
typeCheck(): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Compile project. See [[Compiler.compileForProduction]] for
|
|
55
|
-
* production build
|
|
56
|
-
*/
|
|
57
|
-
compile(stopOnError?: boolean, extraFiles?: string[]): Promise<boolean>;
|
|
58
|
-
/**
|
|
59
|
-
* Compile project. See [[Compiler.compile]] for development build
|
|
60
|
-
*/
|
|
61
|
-
compileForProduction(stopOnError: boolean | undefined, client: 'npm' | 'yarn'): Promise<boolean>;
|
|
62
|
-
}
|