@roots/bud-cache 6.12.3 → 6.13.1
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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/invalidate-cache/index.js +4 -4
- package/lib/service/index.d.ts +22 -22
- package/lib/service/index.js +56 -59
- package/package.json +5 -5
- package/src/index.ts +1 -2
- package/src/invalidate-cache/index.ts +5 -5
- package/src/service/index.ts +75 -75
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { join } from 'node:path';
|
|
3
2
|
import { Extension } from '@roots/bud-framework/extension';
|
|
4
3
|
import { bind, label } from '@roots/bud-framework/extension/decorators';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
5
|
import stripAnsi from 'strip-ansi';
|
|
6
6
|
/**
|
|
7
7
|
* Cache invalidation extension
|
|
@@ -24,7 +24,7 @@ let InvalidateCacheExtension = class InvalidateCacheExtension extends Extension
|
|
|
24
24
|
*/
|
|
25
25
|
async register(bud) {
|
|
26
26
|
const invalidate = await bud.fs?.exists(this.invalidationFile);
|
|
27
|
-
if (invalidate ||
|
|
27
|
+
if (invalidate || bud.context.force) {
|
|
28
28
|
await bud.fs.remove(this.invalidationFile);
|
|
29
29
|
await bud.fs.remove(bud.cache.cacheDirectory);
|
|
30
30
|
}
|
|
@@ -34,11 +34,11 @@ let InvalidateCacheExtension = class InvalidateCacheExtension extends Extension
|
|
|
34
34
|
if (!compiler.hasErrors())
|
|
35
35
|
return;
|
|
36
36
|
await bud.fs.json.write(this.invalidationFile, {
|
|
37
|
-
hash: compiler.hash,
|
|
38
37
|
errors: compiler.stats.flatMap(stats => stats
|
|
39
|
-
.toString({ preset: `errors-warnings
|
|
38
|
+
.toString({ colors: false, preset: `errors-warnings` })
|
|
40
39
|
.split(/\n/)
|
|
41
40
|
.map(stripAnsi)),
|
|
41
|
+
hash: compiler.hash,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
catch (e) { }
|
package/lib/service/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Bud } from '@roots/bud-framework';
|
|
2
|
-
import {
|
|
2
|
+
import type { Configuration } from '@roots/bud-framework/config';
|
|
3
3
|
import type * as Services from '@roots/bud-framework/services';
|
|
4
|
-
import
|
|
4
|
+
import { Service } from '@roots/bud-framework/service';
|
|
5
5
|
/**
|
|
6
6
|
* Cache service class
|
|
7
7
|
*/
|
|
@@ -11,40 +11,40 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
11
11
|
*/
|
|
12
12
|
enabled: boolean;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* {@link Extension.boot}
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
set name(name: string);
|
|
16
|
+
boot(bud: Bud): Promise<void>;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
get type(): 'memory' | 'filesystem';
|
|
22
|
-
set type(type: 'memory' | 'filesystem');
|
|
23
|
-
/**
|
|
24
|
-
* version
|
|
18
|
+
* Cache dependencies
|
|
25
19
|
*/
|
|
26
|
-
get
|
|
27
|
-
set
|
|
20
|
+
get buildDependencies(): Record<string, Array<string>>;
|
|
21
|
+
set buildDependencies(dependencies: Record<string, Array<string>>);
|
|
28
22
|
/**
|
|
29
23
|
* Cache directory
|
|
30
24
|
*/
|
|
31
25
|
get cacheDirectory(): string;
|
|
32
26
|
set cacheDirectory(directory: string);
|
|
33
|
-
/**
|
|
34
|
-
* Cache dependencies
|
|
35
|
-
*/
|
|
36
|
-
get buildDependencies(): Record<string, Array<string>>;
|
|
37
|
-
set buildDependencies(dependencies: Record<string, Array<string>>);
|
|
38
27
|
/**
|
|
39
28
|
* Webpack configuration
|
|
40
29
|
*/
|
|
41
30
|
get configuration(): Configuration[`cache`];
|
|
42
|
-
/**
|
|
43
|
-
* {@link Extension.booted}
|
|
44
|
-
*/
|
|
45
|
-
booted?(bud: Bud): Promise<void>;
|
|
46
31
|
/**
|
|
47
32
|
* Flush cache
|
|
48
33
|
*/
|
|
49
34
|
flush(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Type
|
|
37
|
+
*/
|
|
38
|
+
get name(): string;
|
|
39
|
+
set name(name: string);
|
|
40
|
+
/**
|
|
41
|
+
* Type
|
|
42
|
+
*/
|
|
43
|
+
get type(): 'filesystem' | 'memory';
|
|
44
|
+
set type(type: 'filesystem' | 'memory');
|
|
45
|
+
/**
|
|
46
|
+
* version
|
|
47
|
+
*/
|
|
48
|
+
get version(): string;
|
|
49
|
+
set version(version: string);
|
|
50
50
|
}
|
package/lib/service/index.js
CHANGED
|
@@ -1,64 +1,25 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
2
|
import { Service } from '@roots/bud-framework/service';
|
|
5
3
|
import { bind } from '@roots/bud-support/decorators/bind';
|
|
6
4
|
import isString from '@roots/bud-support/lodash/isString';
|
|
7
5
|
import { hash } from '@roots/bud-support/utilities/args';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
8
|
import InvalidateCacheExtension from '../invalidate-cache/index.js';
|
|
9
9
|
/**
|
|
10
10
|
* Cache service class
|
|
11
11
|
*/
|
|
12
12
|
export default class Cache extends Service {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
/**
|
|
16
|
-
* Enabled
|
|
17
|
-
*/
|
|
18
|
-
this.enabled = true;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Type
|
|
22
|
-
*/
|
|
23
|
-
get name() {
|
|
24
|
-
return this.app.hooks.filter(`build.cache.name`, this.app.hooks.filter(`build.name`, join(`webpack`, this.app.mode)));
|
|
25
|
-
}
|
|
26
|
-
set name(name) {
|
|
27
|
-
this.app.hooks.on(`build.cache.name`, name);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Type
|
|
31
|
-
*/
|
|
32
|
-
get type() {
|
|
33
|
-
return this.app.hooks.filter(`build.cache.type`, this.app.isCLI() && isString(this.app.context.args.cache)
|
|
34
|
-
? this.app.context.args.cache
|
|
35
|
-
: `filesystem`);
|
|
36
|
-
}
|
|
37
|
-
set type(type) {
|
|
38
|
-
this.app.hooks.on(`build.cache.type`, type);
|
|
39
|
-
}
|
|
40
13
|
/**
|
|
41
|
-
*
|
|
14
|
+
* Enabled
|
|
42
15
|
*/
|
|
43
|
-
|
|
44
|
-
const version = createHash(`sha1`);
|
|
45
|
-
version.update(hash);
|
|
46
|
-
Object.values(this.app.context.files ?? {})
|
|
47
|
-
.filter(file => file?.bud || file?.name?.includes(`package.json`))
|
|
48
|
-
.map(({ sha1 }) => version.update(sha1));
|
|
49
|
-
return this.app.hooks.filter(`build.cache.version`, version.digest(`base64`));
|
|
50
|
-
}
|
|
51
|
-
set version(version) {
|
|
52
|
-
this.app.hooks.on(`build.cache.version`, version);
|
|
53
|
-
}
|
|
16
|
+
enabled = true;
|
|
54
17
|
/**
|
|
55
|
-
*
|
|
18
|
+
* {@link Extension.boot}
|
|
56
19
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
set cacheDirectory(directory) {
|
|
61
|
-
this.app.hooks.on(`build.cache.cacheDirectory`, directory);
|
|
20
|
+
async boot(bud) {
|
|
21
|
+
await bud.extensions.add(InvalidateCacheExtension);
|
|
22
|
+
this.logger.success(`cache initialized`);
|
|
62
23
|
}
|
|
63
24
|
/**
|
|
64
25
|
* Cache dependencies
|
|
@@ -76,6 +37,15 @@ export default class Cache extends Service {
|
|
|
76
37
|
set buildDependencies(dependencies) {
|
|
77
38
|
this.app.hooks.on(`build.cache.buildDependencies`, dependencies);
|
|
78
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Cache directory
|
|
42
|
+
*/
|
|
43
|
+
get cacheDirectory() {
|
|
44
|
+
return this.app.hooks.filter(`build.cache.cacheDirectory`, this.app.path(`@storage`, this.app.label, `cache`));
|
|
45
|
+
}
|
|
46
|
+
set cacheDirectory(directory) {
|
|
47
|
+
this.app.hooks.on(`build.cache.cacheDirectory`, directory);
|
|
48
|
+
}
|
|
79
49
|
/**
|
|
80
50
|
* Webpack configuration
|
|
81
51
|
*/
|
|
@@ -85,38 +55,65 @@ export default class Cache extends Service {
|
|
|
85
55
|
if (this.type === `memory`)
|
|
86
56
|
return true;
|
|
87
57
|
return {
|
|
88
|
-
name: this.name,
|
|
89
|
-
type: this.type,
|
|
90
|
-
store: `pack`,
|
|
91
58
|
allowCollectingMemory: true,
|
|
92
59
|
buildDependencies: this.buildDependencies,
|
|
93
60
|
cacheDirectory: this.cacheDirectory,
|
|
94
61
|
idleTimeout: 10000,
|
|
95
62
|
idleTimeoutForInitialStore: 0,
|
|
96
|
-
|
|
63
|
+
name: this.name,
|
|
64
|
+
profile: this.app.context.debug === true,
|
|
65
|
+
store: `pack`,
|
|
66
|
+
type: this.type,
|
|
97
67
|
version: this.app.hooks.filter(`build.cache.version`, this.version),
|
|
98
68
|
};
|
|
99
69
|
}
|
|
100
|
-
/**
|
|
101
|
-
* {@link Extension.booted}
|
|
102
|
-
*/
|
|
103
|
-
async booted(bud) {
|
|
104
|
-
await bud.extensions.add(InvalidateCacheExtension);
|
|
105
|
-
this.logger.success(`cache initialized`);
|
|
106
|
-
}
|
|
107
70
|
/**
|
|
108
71
|
* Flush cache
|
|
109
72
|
*/
|
|
110
73
|
async flush() {
|
|
111
74
|
await this.app.fs.remove(this.cacheDirectory);
|
|
112
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Type
|
|
78
|
+
*/
|
|
79
|
+
get name() {
|
|
80
|
+
return this.app.hooks.filter(`build.cache.name`, this.app.hooks.filter(`build.name`, join(`webpack`, this.app.mode)));
|
|
81
|
+
}
|
|
82
|
+
set name(name) {
|
|
83
|
+
this.app.hooks.on(`build.cache.name`, name);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Type
|
|
87
|
+
*/
|
|
88
|
+
get type() {
|
|
89
|
+
return this.app.hooks.filter(`build.cache.type`, isString(this.app.context.cache)
|
|
90
|
+
? this.app.context.cache
|
|
91
|
+
: `filesystem`);
|
|
92
|
+
}
|
|
93
|
+
set type(type) {
|
|
94
|
+
this.app.hooks.on(`build.cache.type`, type);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* version
|
|
98
|
+
*/
|
|
99
|
+
get version() {
|
|
100
|
+
const version = createHash(`sha1`);
|
|
101
|
+
version.update(hash);
|
|
102
|
+
Object.values(this.app.context.files ?? {})
|
|
103
|
+
.filter(file => file?.bud || file?.name?.includes(`package.json`))
|
|
104
|
+
.map(({ sha1 }) => version.update(sha1));
|
|
105
|
+
return this.app.hooks.filter(`build.cache.version`, version.digest(`base64`));
|
|
106
|
+
}
|
|
107
|
+
set version(version) {
|
|
108
|
+
this.app.hooks.on(`build.cache.version`, version);
|
|
109
|
+
}
|
|
113
110
|
}
|
|
114
111
|
__decorate([
|
|
115
112
|
bind,
|
|
116
113
|
__metadata("design:type", Function),
|
|
117
114
|
__metadata("design:paramtypes", [Function]),
|
|
118
115
|
__metadata("design:returntype", Promise)
|
|
119
|
-
], Cache.prototype, "
|
|
116
|
+
], Cache.prototype, "boot", null);
|
|
120
117
|
__decorate([
|
|
121
118
|
bind,
|
|
122
119
|
__metadata("design:type", Function),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-cache",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.1",
|
|
4
4
|
"description": "Config caching",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"@skypack/package-check": "0.2.2"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@roots/bud-framework": "6.
|
|
89
|
-
"@roots/bud-support": "6.
|
|
90
|
-
"strip-ansi": "7.0
|
|
91
|
-
"tslib": "2.5.
|
|
88
|
+
"@roots/bud-framework": "6.13.1",
|
|
89
|
+
"@roots/bud-support": "6.13.1",
|
|
90
|
+
"strip-ansi": "7.1.0",
|
|
91
|
+
"tslib": "2.5.3"
|
|
92
92
|
},
|
|
93
93
|
"volta": {
|
|
94
94
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {join} from 'node:path'
|
|
2
|
-
|
|
3
1
|
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
|
|
4
3
|
import {Extension} from '@roots/bud-framework/extension'
|
|
5
4
|
import {bind, label} from '@roots/bud-framework/extension/decorators'
|
|
5
|
+
import {join} from 'node:path'
|
|
6
6
|
import stripAnsi from 'strip-ansi'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -30,7 +30,7 @@ export default class InvalidateCacheExtension extends Extension {
|
|
|
30
30
|
public override async register(bud: Bud) {
|
|
31
31
|
const invalidate = await bud.fs?.exists(this.invalidationFile)
|
|
32
32
|
|
|
33
|
-
if (invalidate ||
|
|
33
|
+
if (invalidate || bud.context.force) {
|
|
34
34
|
await bud.fs.remove(this.invalidationFile)
|
|
35
35
|
await bud.fs.remove(bud.cache.cacheDirectory)
|
|
36
36
|
}
|
|
@@ -41,13 +41,13 @@ export default class InvalidateCacheExtension extends Extension {
|
|
|
41
41
|
if (!compiler.hasErrors()) return
|
|
42
42
|
|
|
43
43
|
await bud.fs.json.write(this.invalidationFile, {
|
|
44
|
-
hash: compiler.hash,
|
|
45
44
|
errors: compiler.stats.flatMap(stats =>
|
|
46
45
|
stats
|
|
47
|
-
.toString({preset: `errors-warnings
|
|
46
|
+
.toString({colors: false, preset: `errors-warnings`})
|
|
48
47
|
.split(/\n/)
|
|
49
48
|
.map(stripAnsi),
|
|
50
49
|
),
|
|
50
|
+
hash: compiler.hash,
|
|
51
51
|
})
|
|
52
52
|
} catch (e) {}
|
|
53
53
|
})
|
package/src/service/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {createHash} from 'node:crypto'
|
|
2
|
-
import {join} from 'node:path'
|
|
3
|
-
|
|
4
1
|
import type {Bud} from '@roots/bud-framework'
|
|
5
|
-
import {
|
|
2
|
+
import type {Configuration} from '@roots/bud-framework/config'
|
|
6
3
|
import type * as Services from '@roots/bud-framework/services'
|
|
4
|
+
|
|
5
|
+
import {Service} from '@roots/bud-framework/service'
|
|
7
6
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
8
7
|
import isString from '@roots/bud-support/lodash/isString'
|
|
9
8
|
import {hash} from '@roots/bud-support/utilities/args'
|
|
10
|
-
import
|
|
9
|
+
import {createHash} from 'node:crypto'
|
|
10
|
+
import {join} from 'node:path'
|
|
11
11
|
|
|
12
12
|
import InvalidateCacheExtension from '../invalidate-cache/index.js'
|
|
13
13
|
|
|
@@ -24,66 +24,13 @@ export default class Cache
|
|
|
24
24
|
public enabled: boolean = true
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
public get name(): string {
|
|
30
|
-
return this.app.hooks.filter(
|
|
31
|
-
`build.cache.name`,
|
|
32
|
-
this.app.hooks.filter(`build.name`, join(`webpack`, this.app.mode)),
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
public set name(name: string) {
|
|
36
|
-
this.app.hooks.on(`build.cache.name`, name)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Type
|
|
27
|
+
* {@link Extension.boot}
|
|
41
28
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
? this.app.context.args.cache
|
|
47
|
-
: `filesystem`,
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
public set type(type: 'memory' | 'filesystem') {
|
|
51
|
-
this.app.hooks.on(`build.cache.type`, type)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* version
|
|
56
|
-
*/
|
|
57
|
-
public get version(): string {
|
|
58
|
-
const version = createHash(`sha1`)
|
|
59
|
-
version.update(hash)
|
|
60
|
-
|
|
61
|
-
Object.values(this.app.context.files ?? {})
|
|
62
|
-
.filter(file => file?.bud || file?.name?.includes(`package.json`))
|
|
63
|
-
.map(({sha1}) => version.update(sha1))
|
|
64
|
-
|
|
65
|
-
return this.app.hooks.filter(
|
|
66
|
-
`build.cache.version`,
|
|
67
|
-
version.digest(`base64`),
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
public set version(version: string) {
|
|
71
|
-
this.app.hooks.on(`build.cache.version`, version)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Cache directory
|
|
76
|
-
*/
|
|
77
|
-
public get cacheDirectory(): string {
|
|
78
|
-
return this.app.hooks.filter(
|
|
79
|
-
`build.cache.cacheDirectory`,
|
|
80
|
-
this.app.path(`@storage`, this.app.label, `cache`),
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
public set cacheDirectory(directory: string) {
|
|
84
|
-
this.app.hooks.on(`build.cache.cacheDirectory`, directory)
|
|
29
|
+
@bind
|
|
30
|
+
public override async boot(bud: Bud) {
|
|
31
|
+
await bud.extensions.add(InvalidateCacheExtension)
|
|
32
|
+
this.logger.success(`cache initialized`)
|
|
85
33
|
}
|
|
86
|
-
|
|
87
34
|
/**
|
|
88
35
|
* Cache dependencies
|
|
89
36
|
*/
|
|
@@ -97,12 +44,25 @@ export default class Cache
|
|
|
97
44
|
].filter(Boolean),
|
|
98
45
|
})
|
|
99
46
|
}
|
|
47
|
+
|
|
100
48
|
public set buildDependencies(
|
|
101
49
|
dependencies: Record<string, Array<string>>,
|
|
102
50
|
) {
|
|
103
51
|
this.app.hooks.on(`build.cache.buildDependencies`, dependencies)
|
|
104
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Cache directory
|
|
55
|
+
*/
|
|
56
|
+
public get cacheDirectory(): string {
|
|
57
|
+
return this.app.hooks.filter(
|
|
58
|
+
`build.cache.cacheDirectory`,
|
|
59
|
+
this.app.path(`@storage`, this.app.label, `cache`),
|
|
60
|
+
)
|
|
61
|
+
}
|
|
105
62
|
|
|
63
|
+
public set cacheDirectory(directory: string) {
|
|
64
|
+
this.app.hooks.on(`build.cache.cacheDirectory`, directory)
|
|
65
|
+
}
|
|
106
66
|
/**
|
|
107
67
|
* Webpack configuration
|
|
108
68
|
*/
|
|
@@ -111,33 +71,73 @@ export default class Cache
|
|
|
111
71
|
if (this.type === `memory`) return true
|
|
112
72
|
|
|
113
73
|
return {
|
|
114
|
-
name: this.name,
|
|
115
|
-
type: this.type,
|
|
116
|
-
store: `pack` as `pack`,
|
|
117
74
|
allowCollectingMemory: true,
|
|
118
75
|
buildDependencies: this.buildDependencies,
|
|
119
76
|
cacheDirectory: this.cacheDirectory,
|
|
120
77
|
idleTimeout: 10000,
|
|
121
78
|
idleTimeoutForInitialStore: 0,
|
|
122
|
-
|
|
79
|
+
name: this.name,
|
|
80
|
+
profile: this.app.context.debug === true,
|
|
81
|
+
store: `pack` as `pack`,
|
|
82
|
+
type: this.type,
|
|
123
83
|
version: this.app.hooks.filter(`build.cache.version`, this.version),
|
|
124
84
|
}
|
|
125
85
|
}
|
|
126
86
|
|
|
127
87
|
/**
|
|
128
|
-
*
|
|
88
|
+
* Flush cache
|
|
129
89
|
*/
|
|
130
90
|
@bind
|
|
131
|
-
public
|
|
132
|
-
await
|
|
133
|
-
|
|
91
|
+
public async flush(): Promise<void> {
|
|
92
|
+
await this.app.fs.remove(this.cacheDirectory)
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Type
|
|
96
|
+
*/
|
|
97
|
+
public get name(): string {
|
|
98
|
+
return this.app.hooks.filter(
|
|
99
|
+
`build.cache.name`,
|
|
100
|
+
this.app.hooks.filter(`build.name`, join(`webpack`, this.app.mode)),
|
|
101
|
+
)
|
|
134
102
|
}
|
|
135
103
|
|
|
104
|
+
public set name(name: string) {
|
|
105
|
+
this.app.hooks.on(`build.cache.name`, name)
|
|
106
|
+
}
|
|
136
107
|
/**
|
|
137
|
-
*
|
|
108
|
+
* Type
|
|
138
109
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
110
|
+
public get type(): 'filesystem' | 'memory' {
|
|
111
|
+
return this.app.hooks.filter(
|
|
112
|
+
`build.cache.type`,
|
|
113
|
+
isString(this.app.context.cache)
|
|
114
|
+
? this.app.context.cache
|
|
115
|
+
: `filesystem`,
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public set type(type: 'filesystem' | 'memory') {
|
|
120
|
+
this.app.hooks.on(`build.cache.type`, type)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* version
|
|
125
|
+
*/
|
|
126
|
+
public get version(): string {
|
|
127
|
+
const version = createHash(`sha1`)
|
|
128
|
+
version.update(hash)
|
|
129
|
+
|
|
130
|
+
Object.values(this.app.context.files ?? {})
|
|
131
|
+
.filter(file => file?.bud || file?.name?.includes(`package.json`))
|
|
132
|
+
.map(({sha1}) => version.update(sha1))
|
|
133
|
+
|
|
134
|
+
return this.app.hooks.filter(
|
|
135
|
+
`build.cache.version`,
|
|
136
|
+
version.digest(`base64`),
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public set version(version: string) {
|
|
141
|
+
this.app.hooks.on(`build.cache.version`, version)
|
|
142
142
|
}
|
|
143
143
|
}
|