@roots/bud-cache 6.14.3 → 6.15.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/lib/index.d.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * @see {@link https://bud.js.org}
5
5
  * @see {@link https://github.com/roots/bud}
6
6
  */
7
- export { default } from './service/index.js';
7
+ export { default } from '@roots/bud-cache/service';
package/lib/index.js CHANGED
@@ -6,4 +6,4 @@
6
6
  * @see {@link https://bud.js.org}
7
7
  * @see {@link https://github.com/roots/bud}
8
8
  */
9
- export { default } from './service/index.js';
9
+ export { default } from '@roots/bud-cache/service';
@@ -3,7 +3,7 @@ import type { Configuration } from '@roots/bud-framework/config';
3
3
  import type { Cache as BudCache } from '@roots/bud-framework/services';
4
4
  import { Service } from '@roots/bud-framework/service';
5
5
  /**
6
- * Cache service class
6
+ * {@link Bud.cache}
7
7
  */
8
8
  export default class Cache extends Service implements BudCache {
9
9
  /**
@@ -11,7 +11,7 @@ export default class Cache extends Service implements BudCache {
11
11
  */
12
12
  enabled: boolean;
13
13
  /**
14
- * {@link Extension.boot}
14
+ * {@link Service.boot}
15
15
  */
16
16
  boot?(bud: Bud): Promise<void>;
17
17
  /**
@@ -50,6 +50,6 @@ export default class Cache extends Service implements BudCache {
50
50
  /**
51
51
  * {@link BudCache.version}
52
52
  */
53
- get version(): string;
53
+ get version(): string | undefined;
54
54
  set version(version: string);
55
55
  }
@@ -1,18 +1,14 @@
1
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { join } from 'node:path';
3
3
  import { Service } from '@roots/bud-framework/service';
4
4
  import { bind } from '@roots/bud-support/decorators/bind';
5
5
  import isString from '@roots/bud-support/lodash/isString';
6
6
  /**
7
- * Cache service class
7
+ * {@link Bud.cache}
8
8
  */
9
9
  export default class Cache extends Service {
10
10
  /**
11
- * {@link BudCache.enabled}
12
- */
13
- enabled;
14
- /**
15
- * {@link Extension.boot}
11
+ * {@link Service.boot}
16
12
  */
17
13
  async boot(bud) {
18
14
  if (bud.context.force === true) {
@@ -24,14 +20,15 @@ export default class Cache extends Service {
24
20
  *{@link BudCache.buildDependencies}
25
21
  */
26
22
  get buildDependencies() {
27
- return this.app.hooks.filter(`build.cache.buildDependencies`, {
23
+ const baseDependencies = {
28
24
  bud: [
29
25
  this.app.context.files[`package`]?.path,
30
26
  ...Object.values(this.app.context.files)
31
27
  .filter(({ bud }) => bud)
32
28
  .map(({ path }) => path),
33
29
  ].filter(Boolean),
34
- });
30
+ };
31
+ return (this.app.hooks.filter(`build.cache.buildDependencies`, baseDependencies) ?? baseDependencies);
35
32
  }
36
33
  set buildDependencies(dependencies) {
37
34
  this.app.hooks.on(`build.cache.buildDependencies`, dependencies);
@@ -40,7 +37,7 @@ export default class Cache extends Service {
40
37
  * {@link BudCache.cacheDirectory}
41
38
  */
42
39
  get cacheDirectory() {
43
- return this.app.hooks.filter(`build.cache.cacheDirectory`, this.app.path(`@storage`, this.app.label, `cache`));
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`));
44
41
  }
45
42
  set cacheDirectory(directory) {
46
43
  this.app.hooks.on(`build.cache.cacheDirectory`, directory);
@@ -79,7 +76,7 @@ export default class Cache extends Service {
79
76
  * {@link BudCache.name}
80
77
  */
81
78
  get name() {
82
- return this.app.hooks.filter(`build.cache.name`, this.app.hooks.filter(`build.name`, join(this.app.mode, ...Object.values(this.app.context._ ?? {}))));
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._ ?? {})));
83
80
  }
84
81
  set name(name) {
85
82
  this.app.hooks.on(`build.cache.name`, name);
@@ -95,9 +92,9 @@ export default class Cache extends Service {
95
92
  * {@link BudCache.type}
96
93
  */
97
94
  get type() {
98
- return this.app.hooks.filter(`build.cache.type`, isString(this.app.context.cache)
95
+ return (this.app.hooks.filter(`build.cache.type`, isString(this.app.context.cache)
99
96
  ? this.app.context.cache
100
- : `filesystem`);
97
+ : `filesystem`) ?? `filesystem`);
101
98
  }
102
99
  set type(type) {
103
100
  this.app.hooks.on(`build.cache.type`, type);
@@ -113,8 +110,5 @@ export default class Cache extends Service {
113
110
  }
114
111
  }
115
112
  __decorate([
116
- bind,
117
- __metadata("design:type", Function),
118
- __metadata("design:paramtypes", []),
119
- __metadata("design:returntype", Promise)
113
+ bind
120
114
  ], Cache.prototype, "flush", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roots/bud-cache",
3
- "version": "6.14.3",
3
+ "version": "6.15.0",
4
4
  "description": "Config caching",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -49,22 +49,8 @@
49
49
  ],
50
50
  "type": "module",
51
51
  "exports": {
52
- ".": {
53
- "import": "./lib/index.js",
54
- "default": "./lib/index.js"
55
- },
56
- "./service": {
57
- "import": "./lib/service.js",
58
- "default": "./lib/service.js"
59
- },
60
- "./invalidate-cache": {
61
- "import": "./lib/invalidate-cache/index.js",
62
- "default": "./lib/invalidate-cache/index.js"
63
- },
64
- "./types": {
65
- "import": "./lib/types.js",
66
- "default": "./lib/types.js"
67
- }
52
+ ".": "./lib/index.js",
53
+ "./service": "./lib/service.js"
68
54
  },
69
55
  "typesVersions": {
70
56
  "*": {
@@ -73,9 +59,6 @@
73
59
  ],
74
60
  "service": [
75
61
  "./lib/service.d.ts"
76
- ],
77
- "types": [
78
- "./lib/types.d.ts"
79
62
  ]
80
63
  }
81
64
  },
@@ -85,8 +68,8 @@
85
68
  "@skypack/package-check": "0.2.2"
86
69
  },
87
70
  "dependencies": {
88
- "@roots/bud-framework": "6.14.3",
89
- "@roots/bud-support": "6.14.3",
71
+ "@roots/bud-framework": "6.15.0",
72
+ "@roots/bud-support": "6.15.0",
90
73
  "strip-ansi": "7.1.0",
91
74
  "tslib": "2.6.0"
92
75
  },
package/src/index.ts CHANGED
@@ -8,4 +8,4 @@
8
8
  * @see {@link https://github.com/roots/bud}
9
9
  */
10
10
 
11
- export {default} from './service/index.js'
11
+ export {default} from '@roots/bud-cache/service'
@@ -9,16 +9,16 @@ import {bind} from '@roots/bud-support/decorators/bind'
9
9
  import isString from '@roots/bud-support/lodash/isString'
10
10
 
11
11
  /**
12
- * Cache service class
12
+ * {@link Bud.cache}
13
13
  */
14
14
  export default class Cache extends Service implements BudCache {
15
15
  /**
16
16
  * {@link BudCache.enabled}
17
17
  */
18
- public enabled: boolean
18
+ public declare enabled: boolean
19
19
 
20
20
  /**
21
- * {@link Extension.boot}
21
+ * {@link Service.boot}
22
22
  */
23
23
  public override async boot?(bud: Bud) {
24
24
  if (bud.context.force === true) {
@@ -31,14 +31,21 @@ export default class Cache extends Service implements BudCache {
31
31
  *{@link BudCache.buildDependencies}
32
32
  */
33
33
  public get buildDependencies(): Record<string, Array<string>> {
34
- return this.app.hooks.filter(`build.cache.buildDependencies`, {
34
+ const baseDependencies = {
35
35
  bud: [
36
36
  this.app.context.files[`package`]?.path,
37
37
  ...Object.values(this.app.context.files)
38
38
  .filter(({bud}) => bud)
39
39
  .map(({path}) => path),
40
40
  ].filter(Boolean),
41
- })
41
+ }
42
+
43
+ return (
44
+ this.app.hooks.filter(
45
+ `build.cache.buildDependencies`,
46
+ baseDependencies,
47
+ ) ?? baseDependencies
48
+ )
42
49
  }
43
50
  public set buildDependencies(
44
51
  dependencies: Record<string, Array<string>>,
@@ -50,9 +57,11 @@ export default class Cache extends Service implements BudCache {
50
57
  * {@link BudCache.cacheDirectory}
51
58
  */
52
59
  public get cacheDirectory(): string {
53
- return this.app.hooks.filter(
54
- `build.cache.cacheDirectory`,
55
- this.app.path(`@storage`, this.app.label, `cache`),
60
+ 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`)
56
65
  )
57
66
  }
58
67
  public set cacheDirectory(directory: string) {
@@ -95,12 +104,14 @@ export default class Cache extends Service implements BudCache {
95
104
  * {@link BudCache.name}
96
105
  */
97
106
  public get name(): string {
98
- return this.app.hooks.filter(
99
- `build.cache.name`,
107
+ return (
100
108
  this.app.hooks.filter(
101
- `build.name`,
102
- join(this.app.mode, ...Object.values(this.app.context._ ?? {})),
103
- ),
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._ ?? {}))
104
115
  )
105
116
  }
106
117
  public set name(name: string) {
@@ -119,11 +130,13 @@ export default class Cache extends Service implements BudCache {
119
130
  * {@link BudCache.type}
120
131
  */
121
132
  public get type(): 'filesystem' | 'memory' {
122
- return this.app.hooks.filter(
123
- `build.cache.type`,
124
- isString(this.app.context.cache)
125
- ? this.app.context.cache
126
- : `filesystem`,
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`
127
140
  )
128
141
  }
129
142
  public set type(type: 'filesystem' | 'memory') {
@@ -133,7 +146,7 @@ export default class Cache extends Service implements BudCache {
133
146
  /**
134
147
  * {@link BudCache.version}
135
148
  */
136
- public get version(): string {
149
+ public get version(): string | undefined {
137
150
  return this.app.hooks.filter(`build.cache.version`, undefined)
138
151
  }
139
152
  public set version(version: string) {