@adonisjs/core 5.8.9 → 5.9.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/build/adonis-typings/assets-manager.d.ts +4 -0
- package/build/commands/ListRoutes/index.d.ts +1 -1
- package/build/src/AssetsManager/Drivers/Base.d.ts +27 -0
- package/build/src/AssetsManager/Drivers/Base.js +66 -0
- package/build/src/AssetsManager/Drivers/Encore.d.ts +4 -24
- package/build/src/AssetsManager/Drivers/Encore.js +6 -61
- package/build/src/AssetsManager/Drivers/Fake.d.ts +1 -0
- package/build/src/AssetsManager/Drivers/Fake.js +4 -3
- package/build/src/AssetsManager/Drivers/Vite.d.ts +84 -0
- package/build/src/AssetsManager/Drivers/Vite.js +139 -0
- package/build/src/AssetsManager/index.d.ts +4 -0
- package/build/src/AssetsManager/index.js +24 -11
- package/build/src/HealthCheck/index.js +6 -6
- package/build/src/Ignitor/Ace/App/index.js +7 -7
- package/package.json +12 -12
|
@@ -27,6 +27,10 @@ declare module '@ioc:Adonis/Core/AssetsManager' {
|
|
|
27
27
|
* A boolean to know if entry points are supported or not
|
|
28
28
|
*/
|
|
29
29
|
hasEntrypoints: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Attributes to apply to the script tag
|
|
32
|
+
*/
|
|
33
|
+
scriptAttributes: Record<string, any>;
|
|
30
34
|
/**
|
|
31
35
|
* The current version of assets.
|
|
32
36
|
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
|
+
export declare abstract class BaseDriver {
|
|
3
|
+
protected application: ApplicationContract;
|
|
4
|
+
/**
|
|
5
|
+
* We cache the manifest contents and the entrypoints contents
|
|
6
|
+
* in production
|
|
7
|
+
*/
|
|
8
|
+
private manifestCache?;
|
|
9
|
+
private entrypointsCache?;
|
|
10
|
+
/**
|
|
11
|
+
* Path to the output public dir. Defaults to `/public/assets`
|
|
12
|
+
*/
|
|
13
|
+
publicPath: string;
|
|
14
|
+
constructor(application: ApplicationContract);
|
|
15
|
+
/**
|
|
16
|
+
* Reads the file contents as JSON
|
|
17
|
+
*/
|
|
18
|
+
protected readFileAsJSON(filePath: string): any;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the manifest contents as object
|
|
21
|
+
*/
|
|
22
|
+
manifest(): any;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the entrypoints contents as object
|
|
25
|
+
*/
|
|
26
|
+
entryPoints(): any;
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseDriver = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class BaseDriver {
|
|
7
|
+
constructor(application) {
|
|
8
|
+
this.application = application;
|
|
9
|
+
/**
|
|
10
|
+
* Path to the output public dir. Defaults to `/public/assets`
|
|
11
|
+
*/
|
|
12
|
+
this.publicPath = this.application.publicPath('assets');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Reads the file contents as JSON
|
|
16
|
+
*/
|
|
17
|
+
readFileAsJSON(filePath) {
|
|
18
|
+
if (!(0, fs_extra_1.pathExistsSync)(filePath)) {
|
|
19
|
+
throw new Error(`Cannot find "${filePath}" file. Make sure you are compiling assets`);
|
|
20
|
+
}
|
|
21
|
+
return JSON.parse((0, fs_extra_1.readFileSync)(filePath, 'utf-8'));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the manifest contents as object
|
|
25
|
+
*/
|
|
26
|
+
manifest() {
|
|
27
|
+
/**
|
|
28
|
+
* Use in-memory cache when exists
|
|
29
|
+
*/
|
|
30
|
+
if (this.manifestCache) {
|
|
31
|
+
this.application.logger.trace('reading manifest from cache');
|
|
32
|
+
return this.manifestCache;
|
|
33
|
+
}
|
|
34
|
+
const manifest = this.readFileAsJSON((0, path_1.join)(this.publicPath, 'manifest.json'));
|
|
35
|
+
this.application.logger.trace('reading manifest from %s', this.publicPath);
|
|
36
|
+
/**
|
|
37
|
+
* Cache manifest in production to avoid re-reading the file from disk
|
|
38
|
+
*/
|
|
39
|
+
if (this.application.inProduction) {
|
|
40
|
+
this.manifestCache = manifest;
|
|
41
|
+
}
|
|
42
|
+
return manifest;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the entrypoints contents as object
|
|
46
|
+
*/
|
|
47
|
+
entryPoints() {
|
|
48
|
+
/**
|
|
49
|
+
* Use in-memory cache when exists
|
|
50
|
+
*/
|
|
51
|
+
if (this.entrypointsCache) {
|
|
52
|
+
this.application.logger.trace('reading entrypoints from cache');
|
|
53
|
+
return this.entrypointsCache;
|
|
54
|
+
}
|
|
55
|
+
const entryPoints = this.readFileAsJSON((0, path_1.join)(this.publicPath, 'entrypoints.json'));
|
|
56
|
+
this.application.logger.trace('reading entrypoints from %s', this.publicPath);
|
|
57
|
+
/**
|
|
58
|
+
* Cache entrypoints file in production to avoid re-reading the file from disk
|
|
59
|
+
*/
|
|
60
|
+
if (this.application.inProduction) {
|
|
61
|
+
this.entrypointsCache = entryPoints.entrypoints || {};
|
|
62
|
+
}
|
|
63
|
+
return entryPoints.entrypoints || {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.BaseDriver = BaseDriver;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
|
2
1
|
import { AssetsDriverContract } from '@ioc:Adonis/Core/AssetsManager';
|
|
2
|
+
import { BaseDriver } from './Base';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves entry points and assets path for webpack encore. Relies
|
|
5
5
|
* on the "manifest.json" and "entrypoints.json" files.
|
|
@@ -28,45 +28,25 @@ import { AssetsDriverContract } from '@ioc:Adonis/Core/AssetsManager';
|
|
|
28
28
|
* }
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export declare class EncoreDriver implements AssetsDriverContract {
|
|
32
|
-
private application;
|
|
33
|
-
/**
|
|
34
|
-
* We cache the manifest contents and the entrypoints contents
|
|
35
|
-
* in production
|
|
36
|
-
*/
|
|
37
|
-
private manifestCache?;
|
|
38
|
-
private entrypointsCache?;
|
|
31
|
+
export declare class EncoreDriver extends BaseDriver implements AssetsDriverContract {
|
|
39
32
|
name: string;
|
|
40
33
|
/**
|
|
41
34
|
* Encore driver has support for entrypoints
|
|
42
35
|
*/
|
|
43
36
|
hasEntrypoints: boolean;
|
|
44
37
|
/**
|
|
45
|
-
*
|
|
38
|
+
* Attributes to apply to the script tag
|
|
46
39
|
*/
|
|
47
|
-
|
|
40
|
+
scriptAttributes: Record<string, any>;
|
|
48
41
|
/**
|
|
49
42
|
* Returns the version of the assets by hashing the manifest file
|
|
50
43
|
* contents
|
|
51
44
|
*/
|
|
52
45
|
get version(): string;
|
|
53
|
-
constructor(application: ApplicationContract);
|
|
54
|
-
/**
|
|
55
|
-
* Reads the file contents as JSON
|
|
56
|
-
*/
|
|
57
|
-
private readFileAsJSON;
|
|
58
|
-
/**
|
|
59
|
-
* Returns the manifest contents as object
|
|
60
|
-
*/
|
|
61
|
-
manifest(): any;
|
|
62
46
|
/**
|
|
63
47
|
* Returns path to a given asset file
|
|
64
48
|
*/
|
|
65
49
|
assetPath(name: string): string;
|
|
66
|
-
/**
|
|
67
|
-
* Returns the entrypoints contents as object
|
|
68
|
-
*/
|
|
69
|
-
entryPoints(): any;
|
|
70
50
|
/**
|
|
71
51
|
* Returns list for all the javascript files for a given entry point
|
|
72
52
|
*/
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.EncoreDriver = void 0;
|
|
12
|
-
const path_1 = require("path");
|
|
13
12
|
const crypto_1 = require("crypto");
|
|
14
|
-
const
|
|
13
|
+
const Base_1 = require("./Base");
|
|
15
14
|
/**
|
|
16
15
|
* Resolves entry points and assets path for webpack encore. Relies
|
|
17
16
|
* on the "manifest.json" and "entrypoints.json" files.
|
|
@@ -40,18 +39,18 @@ const fs_extra_1 = require("fs-extra");
|
|
|
40
39
|
* }
|
|
41
40
|
* ```
|
|
42
41
|
*/
|
|
43
|
-
class EncoreDriver {
|
|
44
|
-
constructor(
|
|
45
|
-
|
|
42
|
+
class EncoreDriver extends Base_1.BaseDriver {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
46
45
|
this.name = 'encore';
|
|
47
46
|
/**
|
|
48
47
|
* Encore driver has support for entrypoints
|
|
49
48
|
*/
|
|
50
49
|
this.hasEntrypoints = true;
|
|
51
50
|
/**
|
|
52
|
-
*
|
|
51
|
+
* Attributes to apply to the script tag
|
|
53
52
|
*/
|
|
54
|
-
this.
|
|
53
|
+
this.scriptAttributes = {};
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* Returns the version of the assets by hashing the manifest file
|
|
@@ -60,39 +59,6 @@ class EncoreDriver {
|
|
|
60
59
|
get version() {
|
|
61
60
|
return (0, crypto_1.createHash)('md5').update(JSON.stringify(this.manifest())).digest('hex').slice(0, 10);
|
|
62
61
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Reads the file contents as JSON
|
|
65
|
-
*/
|
|
66
|
-
readFileAsJSON(filePath) {
|
|
67
|
-
/**
|
|
68
|
-
* Ensure the file exists, otherwise raise a meaningful exception
|
|
69
|
-
*/
|
|
70
|
-
if (!(0, fs_extra_1.pathExistsSync)(filePath)) {
|
|
71
|
-
throw new Error(`Cannot find "${filePath}" file. Make sure you are compiling assets`);
|
|
72
|
-
}
|
|
73
|
-
return JSON.parse((0, fs_extra_1.readFileSync)(filePath, 'utf-8'));
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns the manifest contents as object
|
|
77
|
-
*/
|
|
78
|
-
manifest() {
|
|
79
|
-
/**
|
|
80
|
-
* Use in-memory cache when exists
|
|
81
|
-
*/
|
|
82
|
-
if (this.manifestCache) {
|
|
83
|
-
this.application.logger.trace('reading encore manifest from cache');
|
|
84
|
-
return this.manifestCache;
|
|
85
|
-
}
|
|
86
|
-
const manifest = this.readFileAsJSON((0, path_1.join)(this.publicPath, 'manifest.json'));
|
|
87
|
-
this.application.logger.trace('reading encore manifest from %s', this.publicPath);
|
|
88
|
-
/**
|
|
89
|
-
* Cache manifest in production to avoid re-reading the file from disk
|
|
90
|
-
*/
|
|
91
|
-
if (this.application.inProduction) {
|
|
92
|
-
this.manifestCache = manifest;
|
|
93
|
-
}
|
|
94
|
-
return manifest;
|
|
95
|
-
}
|
|
96
62
|
/**
|
|
97
63
|
* Returns path to a given asset file
|
|
98
64
|
*/
|
|
@@ -103,27 +69,6 @@ class EncoreDriver {
|
|
|
103
69
|
}
|
|
104
70
|
return manifest[name];
|
|
105
71
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Returns the entrypoints contents as object
|
|
108
|
-
*/
|
|
109
|
-
entryPoints() {
|
|
110
|
-
/**
|
|
111
|
-
* Use in-memory cache when exists
|
|
112
|
-
*/
|
|
113
|
-
if (this.entrypointsCache) {
|
|
114
|
-
this.application.logger.trace('reading encore entrypoints from cache');
|
|
115
|
-
return this.entrypointsCache;
|
|
116
|
-
}
|
|
117
|
-
const entryPoints = this.readFileAsJSON((0, path_1.join)(this.publicPath, 'entrypoints.json'));
|
|
118
|
-
this.application.logger.trace('reading encore entrypoints from %s', this.publicPath);
|
|
119
|
-
/**
|
|
120
|
-
* Cache entrypoints file in production to avoid re-reading the file from disk
|
|
121
|
-
*/
|
|
122
|
-
if (this.application.inProduction) {
|
|
123
|
-
this.entrypointsCache = entryPoints.entrypoints || {};
|
|
124
|
-
}
|
|
125
|
-
return entryPoints.entrypoints || {};
|
|
126
|
-
}
|
|
127
72
|
/**
|
|
128
73
|
* Returns list for all the javascript files for a given entry point
|
|
129
74
|
*/
|
|
@@ -17,14 +17,15 @@ exports.FakeDriver = void 0;
|
|
|
17
17
|
* testing without compiling the real assets
|
|
18
18
|
*/
|
|
19
19
|
class FakeDriver {
|
|
20
|
+
get version() {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
20
23
|
constructor(application) {
|
|
21
24
|
this.application = application;
|
|
22
25
|
this.name = 'fake';
|
|
23
26
|
this.hasEntrypoints = true;
|
|
24
27
|
this.publicPath = this.application.publicPath('assets');
|
|
25
|
-
|
|
26
|
-
get version() {
|
|
27
|
-
return '';
|
|
28
|
+
this.scriptAttributes = {};
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Returns the manifest contents as object
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { AssetsDriverContract } from '@ioc:Adonis/Core/AssetsManager';
|
|
2
|
+
import { BaseDriver } from './Base';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves entry points and assets path for Vite. Relies
|
|
5
|
+
* on the "manifest.json" and "entrypoints.json" files.
|
|
6
|
+
*
|
|
7
|
+
**********************************************************************
|
|
8
|
+
* The driver assumes following format for the manifest.json file
|
|
9
|
+
**********************************************************************
|
|
10
|
+
*
|
|
11
|
+
* ```json
|
|
12
|
+
* {
|
|
13
|
+
* "assetName": {
|
|
14
|
+
* "file": "path",
|
|
15
|
+
* "src": "path"
|
|
16
|
+
* },
|
|
17
|
+
* ...
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
**********************************************************************
|
|
21
|
+
* The driver assumes following format for the entrypoints.json file
|
|
22
|
+
***********************************************************************
|
|
23
|
+
*
|
|
24
|
+
* ```json
|
|
25
|
+
* {
|
|
26
|
+
* "url": "url"
|
|
27
|
+
* "entrypoints": {
|
|
28
|
+
* "entryPointName": {
|
|
29
|
+
* "js": ["url", "url"],
|
|
30
|
+
* "css": ["url", "url"],
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Please read the documentation for understanding the format of the files.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ViteDriver extends BaseDriver implements AssetsDriverContract {
|
|
39
|
+
name: string;
|
|
40
|
+
/**
|
|
41
|
+
* Vite driver has support for entrypoints
|
|
42
|
+
*/
|
|
43
|
+
hasEntrypoints: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Attributes to apply to the script tag. Vite needs to serve
|
|
46
|
+
* source over native ESM
|
|
47
|
+
*/
|
|
48
|
+
scriptAttributes: Record<string, any>;
|
|
49
|
+
/**
|
|
50
|
+
* If we should use the manifest. We only use the manifest in production.
|
|
51
|
+
*/
|
|
52
|
+
private shouldUseManifest;
|
|
53
|
+
/**
|
|
54
|
+
* Get the assets url from the entrypoints.json file
|
|
55
|
+
*/
|
|
56
|
+
private getAssetUrl;
|
|
57
|
+
/**
|
|
58
|
+
* Returns path to a given asset file
|
|
59
|
+
*/
|
|
60
|
+
assetPath(filename: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the manifest contents as object
|
|
63
|
+
*
|
|
64
|
+
* Note that the manifest file is only available in production.
|
|
65
|
+
* Vite doesn't generate any manifest file in development.
|
|
66
|
+
*/
|
|
67
|
+
manifest(): any;
|
|
68
|
+
/**
|
|
69
|
+
* Returns list for all the javascript files for a given entry point
|
|
70
|
+
*/
|
|
71
|
+
entryPointJsFiles(name: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Returns list for all the css files for a given entry point
|
|
74
|
+
*/
|
|
75
|
+
entryPointCssFiles(name: string): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Returns the script needed for the HMR working with React
|
|
78
|
+
*/
|
|
79
|
+
getReactHmrScript(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the script needed for the HMR working with Vite
|
|
82
|
+
*/
|
|
83
|
+
getViteHmrScript(): string;
|
|
84
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViteDriver = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const Base_1 = require("./Base");
|
|
6
|
+
/**
|
|
7
|
+
* Resolves entry points and assets path for Vite. Relies
|
|
8
|
+
* on the "manifest.json" and "entrypoints.json" files.
|
|
9
|
+
*
|
|
10
|
+
**********************************************************************
|
|
11
|
+
* The driver assumes following format for the manifest.json file
|
|
12
|
+
**********************************************************************
|
|
13
|
+
*
|
|
14
|
+
* ```json
|
|
15
|
+
* {
|
|
16
|
+
* "assetName": {
|
|
17
|
+
* "file": "path",
|
|
18
|
+
* "src": "path"
|
|
19
|
+
* },
|
|
20
|
+
* ...
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
**********************************************************************
|
|
24
|
+
* The driver assumes following format for the entrypoints.json file
|
|
25
|
+
***********************************************************************
|
|
26
|
+
*
|
|
27
|
+
* ```json
|
|
28
|
+
* {
|
|
29
|
+
* "url": "url"
|
|
30
|
+
* "entrypoints": {
|
|
31
|
+
* "entryPointName": {
|
|
32
|
+
* "js": ["url", "url"],
|
|
33
|
+
* "css": ["url", "url"],
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* Please read the documentation for understanding the format of the files.
|
|
40
|
+
*/
|
|
41
|
+
class ViteDriver extends Base_1.BaseDriver {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.name = 'vite';
|
|
45
|
+
/**
|
|
46
|
+
* Vite driver has support for entrypoints
|
|
47
|
+
*/
|
|
48
|
+
this.hasEntrypoints = true;
|
|
49
|
+
/**
|
|
50
|
+
* Attributes to apply to the script tag. Vite needs to serve
|
|
51
|
+
* source over native ESM
|
|
52
|
+
*/
|
|
53
|
+
this.scriptAttributes = { type: 'module' };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* If we should use the manifest. We only use the manifest in production.
|
|
57
|
+
*/
|
|
58
|
+
shouldUseManifest() {
|
|
59
|
+
return this.application.inProduction;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the assets url from the entrypoints.json file
|
|
63
|
+
*/
|
|
64
|
+
getAssetUrl() {
|
|
65
|
+
return this.readFileAsJSON((0, path_1.join)(this.publicPath, 'entrypoints.json')).url;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns path to a given asset file
|
|
69
|
+
*/
|
|
70
|
+
assetPath(filename) {
|
|
71
|
+
if (!this.shouldUseManifest()) {
|
|
72
|
+
return `${this.getAssetUrl()}/${filename}`;
|
|
73
|
+
}
|
|
74
|
+
const manifest = this.manifest();
|
|
75
|
+
if (!manifest[filename]) {
|
|
76
|
+
throw new Error(`Cannot find "${filename}" asset in the manifest file`);
|
|
77
|
+
}
|
|
78
|
+
return `${this.getAssetUrl()}/${manifest[filename].file}`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the manifest contents as object
|
|
82
|
+
*
|
|
83
|
+
* Note that the manifest file is only available in production.
|
|
84
|
+
* Vite doesn't generate any manifest file in development.
|
|
85
|
+
*/
|
|
86
|
+
manifest() {
|
|
87
|
+
if (!this.shouldUseManifest()) {
|
|
88
|
+
throw new Error('Cannot use manifest when not in production');
|
|
89
|
+
}
|
|
90
|
+
return super.manifest();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns list for all the javascript files for a given entry point
|
|
94
|
+
*/
|
|
95
|
+
entryPointJsFiles(name) {
|
|
96
|
+
const entrypoints = this.entryPoints();
|
|
97
|
+
if (!entrypoints[name]) {
|
|
98
|
+
throw new Error(`Cannot find assets for "${name}" entrypoint. Make sure to define it inside the "entryPoints" vite config`);
|
|
99
|
+
}
|
|
100
|
+
return entrypoints[name].js;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns list for all the css files for a given entry point
|
|
104
|
+
*/
|
|
105
|
+
entryPointCssFiles(name) {
|
|
106
|
+
const entrypoints = this.entryPoints();
|
|
107
|
+
if (!entrypoints[name]) {
|
|
108
|
+
throw new Error(`Cannot find assets for "${name}" entrypoint. Make sure to define it inside the "entryPoints" vite config`);
|
|
109
|
+
}
|
|
110
|
+
return entrypoints[name].css;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns the script needed for the HMR working with React
|
|
114
|
+
*/
|
|
115
|
+
getReactHmrScript() {
|
|
116
|
+
if (!this.application.inDev) {
|
|
117
|
+
return '';
|
|
118
|
+
}
|
|
119
|
+
return `
|
|
120
|
+
<script type="module">
|
|
121
|
+
import RefreshRuntime from '${this.getAssetUrl()}/@react-refresh'
|
|
122
|
+
RefreshRuntime.injectIntoGlobalHook(window)
|
|
123
|
+
window.$RefreshReg$ = () => {}
|
|
124
|
+
window.$RefreshSig$ = () => (type) => type
|
|
125
|
+
window.__vite_plugin_react_preamble_installed__ = true
|
|
126
|
+
</script>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the script needed for the HMR working with Vite
|
|
131
|
+
*/
|
|
132
|
+
getViteHmrScript() {
|
|
133
|
+
if (!this.application.inDev) {
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
return `<script type="module" src="${this.getAssetUrl()}/@vite/client"></script>`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.ViteDriver = ViteDriver;
|
|
@@ -11,6 +11,10 @@ export declare class AssetsManager implements AssetsManagerContract {
|
|
|
11
11
|
private config;
|
|
12
12
|
application: ApplicationContract;
|
|
13
13
|
private drivers;
|
|
14
|
+
/**
|
|
15
|
+
* Attributes to apply to the script tag
|
|
16
|
+
*/
|
|
17
|
+
get scriptAttributes(): Record<string, any>;
|
|
14
18
|
/**
|
|
15
19
|
* Configured driver
|
|
16
20
|
*/
|
|
@@ -16,6 +16,7 @@ const utils_1 = require("@poppinss/utils");
|
|
|
16
16
|
const stringify_attributes_1 = __importDefault(require("stringify-attributes"));
|
|
17
17
|
const Fake_1 = require("./Drivers/Fake");
|
|
18
18
|
const Encore_1 = require("./Drivers/Encore");
|
|
19
|
+
const Vite_1 = require("./Drivers/Vite");
|
|
19
20
|
/**
|
|
20
21
|
* Assets manager exposes the API to make link and HTML fragments
|
|
21
22
|
* for static assets.
|
|
@@ -24,14 +25,11 @@ const Encore_1 = require("./Drivers/Encore");
|
|
|
24
25
|
* separately
|
|
25
26
|
*/
|
|
26
27
|
class AssetsManager {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
fake: () => new Fake_1.FakeDriver(this.application),
|
|
33
|
-
};
|
|
34
|
-
this.booted = false;
|
|
28
|
+
/**
|
|
29
|
+
* Attributes to apply to the script tag
|
|
30
|
+
*/
|
|
31
|
+
get scriptAttributes() {
|
|
32
|
+
return this.driver.scriptAttributes;
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
35
|
* Find if the configured driver supports entrypoints or not
|
|
@@ -62,6 +60,16 @@ class AssetsManager {
|
|
|
62
60
|
this.boot();
|
|
63
61
|
return this.driver.name;
|
|
64
62
|
}
|
|
63
|
+
constructor(config, application) {
|
|
64
|
+
this.config = config;
|
|
65
|
+
this.application = application;
|
|
66
|
+
this.drivers = {
|
|
67
|
+
vite: () => new Vite_1.ViteDriver(this.application),
|
|
68
|
+
encore: () => new Encore_1.EncoreDriver(this.application),
|
|
69
|
+
fake: () => new Fake_1.FakeDriver(this.application),
|
|
70
|
+
};
|
|
71
|
+
this.booted = false;
|
|
72
|
+
}
|
|
65
73
|
/**
|
|
66
74
|
* Boot the manager. Must be done lazily to allow `extend` method to takes
|
|
67
75
|
* in effect.
|
|
@@ -144,9 +152,14 @@ class AssetsManager {
|
|
|
144
152
|
*/
|
|
145
153
|
entryPointScriptTags(name) {
|
|
146
154
|
const scripts = this.entryPointJsFiles(name);
|
|
147
|
-
const
|
|
155
|
+
const configDefinedAttributes = this.config.script?.attributes || {};
|
|
156
|
+
const driverDefinedAttributes = this.driver.scriptAttributes || {};
|
|
157
|
+
const mergedAttributes = {
|
|
158
|
+
...configDefinedAttributes,
|
|
159
|
+
...driverDefinedAttributes,
|
|
160
|
+
};
|
|
148
161
|
return scripts
|
|
149
|
-
.map((url) => `<script src="${url}"${(0, stringify_attributes_1.default)(
|
|
162
|
+
.map((url) => `<script src="${url}"${(0, stringify_attributes_1.default)(mergedAttributes)}></script>`)
|
|
150
163
|
.join('\n');
|
|
151
164
|
}
|
|
152
165
|
/**
|
|
@@ -155,7 +168,7 @@ class AssetsManager {
|
|
|
155
168
|
*/
|
|
156
169
|
entryPointStyleTags(name) {
|
|
157
170
|
const links = this.entryPointCssFiles(name);
|
|
158
|
-
const styleAttributes = this.config.style
|
|
171
|
+
const styleAttributes = this.config.style?.attributes || {};
|
|
159
172
|
return links
|
|
160
173
|
.map((url) => `<link rel="stylesheet" href="${url}"${(0, stringify_attributes_1.default)(styleAttributes)} />`)
|
|
161
174
|
.join('\n');
|
|
@@ -14,6 +14,12 @@ exports.HealthCheck = void 0;
|
|
|
14
14
|
* the system. You can also add your own checkers.
|
|
15
15
|
*/
|
|
16
16
|
class HealthCheck {
|
|
17
|
+
/**
|
|
18
|
+
* Returns an array of registered services names
|
|
19
|
+
*/
|
|
20
|
+
get servicesList() {
|
|
21
|
+
return Object.keys(this.healthCheckers);
|
|
22
|
+
}
|
|
17
23
|
constructor(application) {
|
|
18
24
|
this.application = application;
|
|
19
25
|
/**
|
|
@@ -25,12 +31,6 @@ class HealthCheck {
|
|
|
25
31
|
*/
|
|
26
32
|
this.resolver = this.application.container.getResolver('report');
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns an array of registered services names
|
|
30
|
-
*/
|
|
31
|
-
get servicesList() {
|
|
32
|
-
return Object.keys(this.healthCheckers);
|
|
33
|
-
}
|
|
34
34
|
/**
|
|
35
35
|
* Invokes a given checker to collect the report metrics.
|
|
36
36
|
*/
|
|
@@ -43,6 +43,13 @@ const ASSEMBLER_COMMANDS = [
|
|
|
43
43
|
* the manifest file.
|
|
44
44
|
*/
|
|
45
45
|
class App {
|
|
46
|
+
/**
|
|
47
|
+
* Returns a boolean if mentioned command is an assembler
|
|
48
|
+
* command
|
|
49
|
+
*/
|
|
50
|
+
get isAssemblerCommand() {
|
|
51
|
+
return ASSEMBLER_COMMANDS.includes(this.commandName);
|
|
52
|
+
}
|
|
46
53
|
/**
|
|
47
54
|
* Source root always points to the compiled source
|
|
48
55
|
* code.
|
|
@@ -58,13 +65,6 @@ class App {
|
|
|
58
65
|
*/
|
|
59
66
|
this.ace = new ace_1.Kernel(this.kernel.application);
|
|
60
67
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Returns a boolean if mentioned command is an assembler
|
|
63
|
-
* command
|
|
64
|
-
*/
|
|
65
|
-
get isAssemblerCommand() {
|
|
66
|
-
return ASSEMBLER_COMMANDS.includes(this.commandName);
|
|
67
|
-
}
|
|
68
68
|
/**
|
|
69
69
|
* Print commands help
|
|
70
70
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0",
|
|
4
4
|
"description": "Core of AdonisJS",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
},
|
|
69
69
|
"homepage": "https://github.com/adonisjs/core#readme",
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@adonisjs/assembler": "^5.9.
|
|
71
|
+
"@adonisjs/assembler": "^5.9.5",
|
|
72
72
|
"@adonisjs/fold": "^8.2.0",
|
|
73
73
|
"@adonisjs/logger": "^4.1.5",
|
|
74
74
|
"@adonisjs/mrm-preset": "^5.0.3",
|
|
75
75
|
"@adonisjs/repl": "^3.1.11",
|
|
76
76
|
"@adonisjs/require-ts": "^2.0.13",
|
|
77
|
-
"@adonisjs/sink": "^5.4.
|
|
78
|
-
"@japa/assert": "^1.3.
|
|
79
|
-
"@japa/preset-adonis": "^1.
|
|
80
|
-
"@japa/run-failed-tests": "^1.0
|
|
77
|
+
"@adonisjs/sink": "^5.4.2",
|
|
78
|
+
"@japa/assert": "^1.3.6",
|
|
79
|
+
"@japa/preset-adonis": "^1.2.0",
|
|
80
|
+
"@japa/run-failed-tests": "^1.1.0",
|
|
81
81
|
"@japa/runner": "^2.2.2",
|
|
82
82
|
"@japa/spec-reporter": "^1.3.2",
|
|
83
83
|
"@poppinss/dev-utils": "^2.0.3",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"copyfiles": "^2.4.1",
|
|
89
89
|
"cz-conventional-changelog": "^3.3.0",
|
|
90
90
|
"del-cli": "^5.0.0",
|
|
91
|
-
"eslint": "^8.
|
|
91
|
+
"eslint": "^8.28.0",
|
|
92
92
|
"eslint-config-prettier": "^8.5.0",
|
|
93
93
|
"eslint-plugin-adonis": "^2.1.1",
|
|
94
94
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
"strip-ansi": "^6.0.1",
|
|
103
103
|
"supertest": "^6.3.1",
|
|
104
104
|
"test-console": "^2.0.0",
|
|
105
|
-
"typescript": "^4.
|
|
106
|
-
"youch": "^3.2.
|
|
105
|
+
"typescript": "^4.9.3",
|
|
106
|
+
"youch": "^3.2.2",
|
|
107
107
|
"youch-terminal": "^2.1.5"
|
|
108
108
|
},
|
|
109
109
|
"nyc": {
|
|
@@ -126,12 +126,12 @@
|
|
|
126
126
|
},
|
|
127
127
|
"dependencies": {
|
|
128
128
|
"@adonisjs/ace": "^11.3.1",
|
|
129
|
-
"@adonisjs/application": "^5.
|
|
129
|
+
"@adonisjs/application": "^5.3.0",
|
|
130
130
|
"@adonisjs/bodyparser": "^8.1.7",
|
|
131
131
|
"@adonisjs/drive": "^2.3.0",
|
|
132
132
|
"@adonisjs/encryption": "^4.0.8",
|
|
133
133
|
"@adonisjs/events": "^7.2.1",
|
|
134
|
-
"@adonisjs/hash": "^7.2.
|
|
134
|
+
"@adonisjs/hash": "^7.2.2",
|
|
135
135
|
"@adonisjs/http-server": "^5.12.0",
|
|
136
136
|
"@adonisjs/validator": "^12.4.1",
|
|
137
137
|
"@poppinss/cliui": "^3.0.5",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"@poppinss/utils": "^5.0.0",
|
|
140
140
|
"fs-extra": "^10.1.0",
|
|
141
141
|
"macroable": "^7.0.2",
|
|
142
|
-
"memfs": "^3.4.
|
|
142
|
+
"memfs": "^3.4.12",
|
|
143
143
|
"serve-static": "^1.15.0",
|
|
144
144
|
"stringify-attributes": "^2.0.0"
|
|
145
145
|
},
|