@roots/bud-cache 6.15.1 → 6.16.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.
@@ -0,0 +1,2 @@
1
+ import type { File } from '@roots/bud-framework/context';
2
+ export declare const isBuildDependency: (file: File) => boolean;
package/lib/helpers.js ADDED
@@ -0,0 +1,9 @@
1
+ export const isBuildDependency = (file) => [
2
+ `.npmrc`,
3
+ `.pnpmfile`,
4
+ `.yarnrc`,
5
+ `jsconfig`,
6
+ `package`,
7
+ `pnpm-workspace`,
8
+ `tsconfig`,
9
+ ].includes(file.name) || file.bud;
package/lib/service.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Bud } from '@roots/bud-framework';
2
- import type { Configuration } from '@roots/bud-framework/config';
3
- import type { Cache as BudCache } from '@roots/bud-framework/services';
2
+ import type { Configuration, FileCacheOptions } from '@roots/bud-framework/config';
3
+ import type { Cache as BudCache, CacheCallback as Callback } from '@roots/bud-framework/services/cache';
4
4
  import { Service } from '@roots/bud-framework/service';
5
5
  /**
6
6
  * {@link Bud.cache}
@@ -11,19 +11,39 @@ export default class Cache extends Service implements BudCache {
11
11
  */
12
12
  enabled: boolean;
13
13
  /**
14
- * {@link Service.boot}
14
+ * {@link BudCache.allowCollectingMemory}
15
15
  */
16
- boot?(bud: Bud): Promise<void>;
16
+ get allowCollectingMemory(): FileCacheOptions[`allowCollectingMemory`];
17
+ set allowCollectingMemory(value: Callback<FileCacheOptions[`allowCollectingMemory`]>);
17
18
  /**
18
19
  *{@link BudCache.buildDependencies}
19
20
  */
20
- get buildDependencies(): Record<string, Array<string>>;
21
- set buildDependencies(dependencies: Record<string, Array<string>>);
21
+ get buildDependencies(): FileCacheOptions[`buildDependencies`];
22
+ set buildDependencies(dependencies: Callback<FileCacheOptions[`buildDependencies`]>);
22
23
  /**
23
24
  * {@link BudCache.cacheDirectory}
24
25
  */
25
26
  get cacheDirectory(): string;
26
- set cacheDirectory(directory: string);
27
+ set cacheDirectory(directory: Callback<FileCacheOptions[`cacheDirectory`]>);
28
+ /**
29
+ * {@link BudCache.name}
30
+ */
31
+ get name(): string;
32
+ set name(name: string);
33
+ /**
34
+ * {@link BudCache.type}
35
+ */
36
+ get type(): 'filesystem' | 'memory';
37
+ set type(type: Callback<FileCacheOptions[`type`]>);
38
+ /**
39
+ * {@link BudCache.version}
40
+ */
41
+ get version(): string | undefined;
42
+ set version(version: string);
43
+ /**
44
+ * {@link Service.boot}
45
+ */
46
+ boot?(bud: Bud): Promise<void>;
27
47
  /**
28
48
  * {@link BudCache.configuration}
29
49
  * @readonly
@@ -34,22 +54,41 @@ export default class Cache extends Service implements BudCache {
34
54
  */
35
55
  flush(): Promise<void>;
36
56
  /**
37
- * {@link BudCache.name}
57
+ * Get {@link BudCache.allowCollectingMemory}
38
58
  */
39
- get name(): string;
40
- set name(name: string);
59
+ getAllowCollectingMemory(): boolean | undefined;
60
+ /**
61
+ * Get {@link BudCache.buildDependencies}
62
+ */
63
+ getBuildDependencies(): {
64
+ [index: string]: string[];
65
+ } | undefined;
66
+ /**
67
+ * Get {@link BudCache.cacheDirectory}
68
+ */
69
+ getCacheDirectory(): string;
70
+ /**
71
+ * Get {@link BudCache.type}
72
+ */
73
+ getType(): "filesystem" | "memory";
41
74
  /**
42
75
  * {@link BudCache.register}
43
76
  */
44
77
  register?(bud: Bud): Promise<void>;
45
78
  /**
46
- * {@link BudCache.type}
79
+ * Set {@link BudCache.allowCollectingMemory}
47
80
  */
48
- get type(): 'filesystem' | 'memory';
49
- set type(type: 'filesystem' | 'memory');
81
+ setAllowCollectingMemory(value: Callback<FileCacheOptions[`allowCollectingMemory`]>): this;
50
82
  /**
51
- * {@link BudCache.version}
83
+ * Set {@link BudCache.buildDependencies}
52
84
  */
53
- get version(): string | undefined;
54
- set version(version: string);
85
+ setBuildDependencies(dependencies: ((records?: Record<string, Array<string>>) => Record<string, Array<string>>) | Record<string, Array<string>>): this;
86
+ /**
87
+ * Set {@link BudCache.cacheDirectory}
88
+ */
89
+ setCacheDirectory(directory: Callback<FileCacheOptions[`cacheDirectory`]>): this;
90
+ /**
91
+ * Set {@link BudCache.type}
92
+ */
93
+ setType(type: Callback<FileCacheOptions[`type`]>): this;
55
94
  }
package/lib/service.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { join } from 'node:path';
3
+ import { isBuildDependency } from '@roots/bud-cache/helpers';
3
4
  import { Service } from '@roots/bud-framework/service';
4
5
  import { bind } from '@roots/bud-support/decorators/bind';
5
6
  import isString from '@roots/bud-support/lodash/isString';
@@ -8,27 +9,31 @@ import isString from '@roots/bud-support/lodash/isString';
8
9
  */
9
10
  export default class Cache extends Service {
10
11
  /**
11
- * {@link Service.boot}
12
+ * {@link BudCache.allowCollectingMemory}
12
13
  */
13
- async boot(bud) {
14
- if (bud.context.force === true) {
15
- await this.flush();
16
- }
17
- this.enabled = bud.context.cache !== false;
14
+ get allowCollectingMemory() {
15
+ const fallback = true;
16
+ const value = this.app.hooks.filter(`build.cache.allowCollectingMemory`, fallback);
17
+ return typeof value === `boolean` ? value : fallback;
18
+ }
19
+ set allowCollectingMemory(value) {
20
+ this.app.hooks.on(`build.cache.allowCollectingMemory`, value);
18
21
  }
19
22
  /**
20
23
  *{@link BudCache.buildDependencies}
21
24
  */
22
25
  get buildDependencies() {
23
- const baseDependencies = {
24
- bud: [
25
- this.app.context.files[`package`]?.path,
26
- ...Object.values(this.app.context.files)
27
- .filter(({ bud }) => bud)
28
- .map(({ path }) => path),
29
- ].filter(Boolean),
26
+ const dependencies = new Set([
27
+ this.app.context.files[`package`]?.path,
28
+ ...Object.values(this.app.context.files)
29
+ .filter(isBuildDependency)
30
+ .map(({ path }) => path),
31
+ ].filter(Boolean));
32
+ const records = {
33
+ bud: [...dependencies],
30
34
  };
31
- return (this.app.hooks.filter(`build.cache.buildDependencies`, baseDependencies) ?? baseDependencies);
35
+ return (this.app.hooks.filter(`build.cache.buildDependencies`, records) ??
36
+ records);
32
37
  }
33
38
  set buildDependencies(dependencies) {
34
39
  this.app.hooks.on(`build.cache.buildDependencies`, dependencies);
@@ -37,11 +42,53 @@ export default class Cache extends Service {
37
42
  * {@link BudCache.cacheDirectory}
38
43
  */
39
44
  get cacheDirectory() {
40
- return (this.app.hooks.filter(`build.cache.cacheDirectory`, this.app.path(`@storage`, this.app.label, `cache`)) ?? this.app.path(`@storage`, this.app.label, `cache`));
45
+ const fallback = this.app.path(`@storage`, this.app.label, `cache`);
46
+ return (this.app.hooks.filter(`build.cache.cacheDirectory`, fallback) ??
47
+ fallback);
41
48
  }
42
49
  set cacheDirectory(directory) {
43
50
  this.app.hooks.on(`build.cache.cacheDirectory`, directory);
44
51
  }
52
+ /**
53
+ * {@link BudCache.name}
54
+ */
55
+ get name() {
56
+ const fallback = join(this.app.mode, ...Object.values(this.app.context._ ?? {}));
57
+ return (this.app.hooks.filter(`build.cache.name`, this.app.hooks.filter(`build.name`, fallback)) ?? fallback);
58
+ }
59
+ set name(name) {
60
+ this.app.hooks.on(`build.cache.name`, name);
61
+ }
62
+ /**
63
+ * {@link BudCache.type}
64
+ */
65
+ get type() {
66
+ const fallback = isString(this.app.context.cache)
67
+ ? this.app.context.cache
68
+ : `filesystem`;
69
+ return this.app.hooks.filter(`build.cache.type`) ?? fallback;
70
+ }
71
+ set type(type) {
72
+ this.app.hooks.on(`build.cache.type`, type);
73
+ }
74
+ /**
75
+ * {@link BudCache.version}
76
+ */
77
+ get version() {
78
+ return this.app.hooks.filter(`build.cache.version`, undefined);
79
+ }
80
+ set version(version) {
81
+ this.app.hooks.on(`build.cache.version`, version);
82
+ }
83
+ /**
84
+ * {@link Service.boot}
85
+ */
86
+ async boot(bud) {
87
+ if (bud.context.force === true) {
88
+ await this.flush();
89
+ }
90
+ this.enabled = bud.context.cache !== false;
91
+ }
45
92
  /**
46
93
  * {@link BudCache.configuration}
47
94
  * @readonly
@@ -52,7 +99,7 @@ export default class Cache extends Service {
52
99
  if (this.type === `memory`)
53
100
  return true;
54
101
  return {
55
- allowCollectingMemory: true,
102
+ allowCollectingMemory: this.allowCollectingMemory,
56
103
  buildDependencies: this.buildDependencies,
57
104
  cacheDirectory: this.cacheDirectory,
58
105
  compression: this.app.isDevelopment ? false : `brotli`,
@@ -73,13 +120,28 @@ export default class Cache extends Service {
73
120
  await this.app.fs.remove(this.cacheDirectory);
74
121
  }
75
122
  /**
76
- * {@link BudCache.name}
123
+ * Get {@link BudCache.allowCollectingMemory}
77
124
  */
78
- get name() {
79
- return (this.app.hooks.filter(`build.cache.name`, this.app.hooks.filter(`build.name`, join(this.app.mode, ...Object.values(this.app.context._ ?? {})))) ?? join(this.app.mode, ...Object.values(this.app.context._ ?? {})));
125
+ getAllowCollectingMemory() {
126
+ return this.allowCollectingMemory;
80
127
  }
81
- set name(name) {
82
- this.app.hooks.on(`build.cache.name`, name);
128
+ /**
129
+ * Get {@link BudCache.buildDependencies}
130
+ */
131
+ getBuildDependencies() {
132
+ return this.buildDependencies;
133
+ }
134
+ /**
135
+ * Get {@link BudCache.cacheDirectory}
136
+ */
137
+ getCacheDirectory() {
138
+ return this.cacheDirectory;
139
+ }
140
+ /**
141
+ * Get {@link BudCache.type}
142
+ */
143
+ getType() {
144
+ return this.type;
83
145
  }
84
146
  /**
85
147
  * {@link BudCache.register}
@@ -89,24 +151,32 @@ export default class Cache extends Service {
89
151
  this.version = bud.context.bud.version;
90
152
  }
91
153
  /**
92
- * {@link BudCache.type}
154
+ * Set {@link BudCache.allowCollectingMemory}
93
155
  */
94
- get type() {
95
- return (this.app.hooks.filter(`build.cache.type`, isString(this.app.context.cache)
96
- ? this.app.context.cache
97
- : `filesystem`) ?? `filesystem`);
156
+ setAllowCollectingMemory(value) {
157
+ this.allowCollectingMemory = value;
158
+ return this;
98
159
  }
99
- set type(type) {
100
- this.app.hooks.on(`build.cache.type`, type);
160
+ /**
161
+ * Set {@link BudCache.buildDependencies}
162
+ */
163
+ setBuildDependencies(dependencies) {
164
+ this.buildDependencies = dependencies;
165
+ return this;
101
166
  }
102
167
  /**
103
- * {@link BudCache.version}
168
+ * Set {@link BudCache.cacheDirectory}
104
169
  */
105
- get version() {
106
- return this.app.hooks.filter(`build.cache.version`, undefined);
170
+ setCacheDirectory(directory) {
171
+ this.cacheDirectory = directory;
172
+ return this;
107
173
  }
108
- set version(version) {
109
- this.app.hooks.on(`build.cache.version`, version);
174
+ /**
175
+ * Set {@link BudCache.type}
176
+ */
177
+ setType(type) {
178
+ this.type = type;
179
+ return this;
110
180
  }
111
181
  }
112
182
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roots/bud-cache",
3
- "version": "6.15.1",
3
+ "version": "6.16.0",
4
4
  "description": "Config caching",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -50,6 +50,7 @@
50
50
  "type": "module",
51
51
  "exports": {
52
52
  ".": "./lib/index.js",
53
+ "./helpers": "./lib/helpers.js",
53
54
  "./service": "./lib/service.js"
54
55
  },
55
56
  "typesVersions": {
@@ -57,6 +58,9 @@
57
58
  ".": [
58
59
  "./lib/index.d.ts"
59
60
  ],
61
+ "./helpers": [
62
+ "./lib/helpers.d.ts"
63
+ ],
60
64
  "service": [
61
65
  "./lib/service.d.ts"
62
66
  ]
@@ -68,10 +72,10 @@
68
72
  "@skypack/package-check": "0.2.2"
69
73
  },
70
74
  "dependencies": {
71
- "@roots/bud-framework": "6.15.1",
72
- "@roots/bud-support": "6.15.1",
75
+ "@roots/bud-framework": "6.16.0",
76
+ "@roots/bud-support": "6.16.0",
73
77
  "strip-ansi": "7.1.0",
74
- "tslib": "2.6.1"
78
+ "tslib": "2.6.2"
75
79
  },
76
80
  "volta": {
77
81
  "extends": "../../../package.json"
package/src/helpers.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type {File} from '@roots/bud-framework/context'
2
+
3
+ export const isBuildDependency = (file: File): boolean =>
4
+ [
5
+ `.npmrc`,
6
+ `.pnpmfile`,
7
+ `.yarnrc`,
8
+ `jsconfig`,
9
+ `package`,
10
+ `pnpm-workspace`,
11
+ `tsconfig`,
12
+ ].includes(file.name) || file.bud
package/src/service.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import type {Bud} from '@roots/bud-framework'
2
- import type {Configuration} from '@roots/bud-framework/config'
3
- import type {Cache as BudCache} from '@roots/bud-framework/services'
2
+ import type {
3
+ Configuration,
4
+ FileCacheOptions,
5
+ } from '@roots/bud-framework/config'
6
+ import type {
7
+ Cache as BudCache,
8
+ CacheCallback as Callback,
9
+ } from '@roots/bud-framework/services/cache'
4
10
 
5
11
  import {join} from 'node:path'
6
12
 
13
+ import {isBuildDependency} from '@roots/bud-cache/helpers'
7
14
  import {Service} from '@roots/bud-framework/service'
8
15
  import {bind} from '@roots/bud-support/decorators/bind'
9
16
  import isString from '@roots/bud-support/lodash/isString'
@@ -16,39 +23,47 @@ export default class Cache extends Service implements BudCache {
16
23
  * {@link BudCache.enabled}
17
24
  */
18
25
  public declare enabled: boolean
19
-
20
26
  /**
21
- * {@link Service.boot}
27
+ * {@link BudCache.allowCollectingMemory}
22
28
  */
23
- public override async boot?(bud: Bud) {
24
- if (bud.context.force === true) {
25
- await this.flush()
26
- }
27
- this.enabled = bud.context.cache !== false
29
+ public get allowCollectingMemory(): FileCacheOptions[`allowCollectingMemory`] {
30
+ const fallback = true
31
+
32
+ const value = this.app.hooks.filter(
33
+ `build.cache.allowCollectingMemory`,
34
+ fallback,
35
+ )
36
+ return typeof value === `boolean` ? value : fallback
37
+ }
38
+ public set allowCollectingMemory(
39
+ value: Callback<FileCacheOptions[`allowCollectingMemory`]>,
40
+ ) {
41
+ this.app.hooks.on(`build.cache.allowCollectingMemory`, value)
28
42
  }
29
43
 
30
44
  /**
31
45
  *{@link BudCache.buildDependencies}
32
46
  */
33
- public get buildDependencies(): Record<string, Array<string>> {
34
- const baseDependencies = {
35
- bud: [
47
+ public get buildDependencies(): FileCacheOptions[`buildDependencies`] {
48
+ const dependencies = new Set(
49
+ [
36
50
  this.app.context.files[`package`]?.path,
37
51
  ...Object.values(this.app.context.files)
38
- .filter(({bud}) => bud)
52
+ .filter(isBuildDependency)
39
53
  .map(({path}) => path),
40
54
  ].filter(Boolean),
55
+ )
56
+ const records = {
57
+ bud: [...dependencies],
41
58
  }
42
59
 
43
60
  return (
44
- this.app.hooks.filter(
45
- `build.cache.buildDependencies`,
46
- baseDependencies,
47
- ) ?? baseDependencies
61
+ this.app.hooks.filter(`build.cache.buildDependencies`, records) ??
62
+ records
48
63
  )
49
64
  }
50
65
  public set buildDependencies(
51
- dependencies: Record<string, Array<string>>,
66
+ dependencies: Callback<FileCacheOptions[`buildDependencies`]>,
52
67
  ) {
53
68
  this.app.hooks.on(`build.cache.buildDependencies`, dependencies)
54
69
  }
@@ -57,17 +72,71 @@ export default class Cache extends Service implements BudCache {
57
72
  * {@link BudCache.cacheDirectory}
58
73
  */
59
74
  public get cacheDirectory(): string {
75
+ const fallback = this.app.path(`@storage`, this.app.label, `cache`)
60
76
  return (
61
- this.app.hooks.filter(
62
- `build.cache.cacheDirectory`,
63
- this.app.path(`@storage`, this.app.label, `cache`),
64
- ) ?? this.app.path(`@storage`, this.app.label, `cache`)
77
+ this.app.hooks.filter(`build.cache.cacheDirectory`, fallback) ??
78
+ fallback
65
79
  )
66
80
  }
67
- public set cacheDirectory(directory: string) {
81
+ public set cacheDirectory(
82
+ directory: Callback<FileCacheOptions[`cacheDirectory`]>,
83
+ ) {
68
84
  this.app.hooks.on(`build.cache.cacheDirectory`, directory)
69
85
  }
70
86
 
87
+ /**
88
+ * {@link BudCache.name}
89
+ */
90
+ public get name(): string {
91
+ const fallback = join(
92
+ this.app.mode,
93
+ ...Object.values(this.app.context._ ?? {}),
94
+ )
95
+ return (
96
+ this.app.hooks.filter(
97
+ `build.cache.name`,
98
+ this.app.hooks.filter(`build.name`, fallback),
99
+ ) ?? fallback
100
+ )
101
+ }
102
+ public set name(name: string) {
103
+ this.app.hooks.on(`build.cache.name`, name)
104
+ }
105
+
106
+ /**
107
+ * {@link BudCache.type}
108
+ */
109
+ public get type(): 'filesystem' | 'memory' {
110
+ const fallback = isString(this.app.context.cache)
111
+ ? this.app.context.cache
112
+ : `filesystem`
113
+
114
+ return this.app.hooks.filter(`build.cache.type`) ?? fallback
115
+ }
116
+ public set type(type: Callback<FileCacheOptions[`type`]>) {
117
+ this.app.hooks.on(`build.cache.type`, type)
118
+ }
119
+
120
+ /**
121
+ * {@link BudCache.version}
122
+ */
123
+ public get version(): string | undefined {
124
+ return this.app.hooks.filter(`build.cache.version`, undefined)
125
+ }
126
+ public set version(version: string) {
127
+ this.app.hooks.on(`build.cache.version`, version)
128
+ }
129
+
130
+ /**
131
+ * {@link Service.boot}
132
+ */
133
+ public override async boot?(bud: Bud) {
134
+ if (bud.context.force === true) {
135
+ await this.flush()
136
+ }
137
+ this.enabled = bud.context.cache !== false
138
+ }
139
+
71
140
  /**
72
141
  * {@link BudCache.configuration}
73
142
  * @readonly
@@ -77,7 +146,7 @@ export default class Cache extends Service implements BudCache {
77
146
  if (this.type === `memory`) return true
78
147
 
79
148
  return {
80
- allowCollectingMemory: true,
149
+ allowCollectingMemory: this.allowCollectingMemory,
81
150
  buildDependencies: this.buildDependencies,
82
151
  cacheDirectory: this.cacheDirectory,
83
152
  compression: this.app.isDevelopment ? false : `brotli`,
@@ -91,7 +160,6 @@ export default class Cache extends Service implements BudCache {
91
160
  type: this.type,
92
161
  }
93
162
  }
94
-
95
163
  /**
96
164
  * {@link BudCache.flush}
97
165
  */
@@ -101,21 +169,29 @@ export default class Cache extends Service implements BudCache {
101
169
  }
102
170
 
103
171
  /**
104
- * {@link BudCache.name}
172
+ * Get {@link BudCache.allowCollectingMemory}
105
173
  */
106
- public get name(): string {
107
- return (
108
- this.app.hooks.filter(
109
- `build.cache.name`,
110
- this.app.hooks.filter(
111
- `build.name`,
112
- join(this.app.mode, ...Object.values(this.app.context._ ?? {})),
113
- ),
114
- ) ?? join(this.app.mode, ...Object.values(this.app.context._ ?? {}))
115
- )
174
+ public getAllowCollectingMemory() {
175
+ return this.allowCollectingMemory
116
176
  }
117
- public set name(name: string) {
118
- this.app.hooks.on(`build.cache.name`, name)
177
+ /**
178
+ * Get {@link BudCache.buildDependencies}
179
+ */
180
+ public getBuildDependencies() {
181
+ return this.buildDependencies
182
+ }
183
+
184
+ /**
185
+ * Get {@link BudCache.cacheDirectory}
186
+ */
187
+ public getCacheDirectory() {
188
+ return this.cacheDirectory
189
+ }
190
+ /**
191
+ * Get {@link BudCache.type}
192
+ */
193
+ public getType() {
194
+ return this.type
119
195
  }
120
196
 
121
197
  /**
@@ -125,31 +201,45 @@ export default class Cache extends Service implements BudCache {
125
201
  this.enabled = bud.context.cache !== false
126
202
  this.version = bud.context.bud.version
127
203
  }
128
-
129
204
  /**
130
- * {@link BudCache.type}
205
+ * Set {@link BudCache.allowCollectingMemory}
131
206
  */
132
- public get type(): 'filesystem' | 'memory' {
133
- return (
134
- this.app.hooks.filter(
135
- `build.cache.type`,
136
- isString(this.app.context.cache)
137
- ? this.app.context.cache
138
- : `filesystem`,
139
- ) ?? `filesystem`
140
- )
207
+ public setAllowCollectingMemory(
208
+ value: Callback<FileCacheOptions[`allowCollectingMemory`]>,
209
+ ): this {
210
+ this.allowCollectingMemory = value
211
+ return this
141
212
  }
142
- public set type(type: 'filesystem' | 'memory') {
143
- this.app.hooks.on(`build.cache.type`, type)
213
+
214
+ /**
215
+ * Set {@link BudCache.buildDependencies}
216
+ */
217
+ public setBuildDependencies(
218
+ dependencies:
219
+ | ((
220
+ records?: Record<string, Array<string>>,
221
+ ) => Record<string, Array<string>>)
222
+ | Record<string, Array<string>>,
223
+ ) {
224
+ this.buildDependencies = dependencies
225
+ return this
144
226
  }
145
227
 
146
228
  /**
147
- * {@link BudCache.version}
229
+ * Set {@link BudCache.cacheDirectory}
148
230
  */
149
- public get version(): string | undefined {
150
- return this.app.hooks.filter(`build.cache.version`, undefined)
231
+ public setCacheDirectory(
232
+ directory: Callback<FileCacheOptions[`cacheDirectory`]>,
233
+ ) {
234
+ this.cacheDirectory = directory
235
+ return this
151
236
  }
152
- public set version(version: string) {
153
- this.app.hooks.on(`build.cache.version`, version)
237
+
238
+ /**
239
+ * Set {@link BudCache.type}
240
+ */
241
+ public setType(type: Callback<FileCacheOptions[`type`]>) {
242
+ this.type = type
243
+ return this
154
244
  }
155
245
  }