@roots/bud-cache 6.10.0 → 6.12.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 +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/invalidate-cache/index.d.ts +22 -0
- package/lib/invalidate-cache/index.d.ts.map +1 -0
- package/lib/invalidate-cache/index.js +59 -0
- package/lib/invalidate-cache/index.js.map +1 -0
- package/lib/service/index.d.ts +46 -0
- package/lib/service/index.d.ts.map +1 -0
- package/lib/service/index.js +109 -0
- package/lib/service/index.js.map +1 -0
- package/lib/types.d.ts +10 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +5 -0
- package/lib/types.js.map +1 -0
- package/package.json +25 -26
- package/src/index.ts +0 -2
- package/src/invalidate-cache/index.ts +2 -2
- package/src/service/index.ts +17 -14
- package/src/types.ts +4 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,OAAO,YAAY,CAAA;AAEnB,OAAO,KAAK,MAAM,oBAAoB,CAAA;AAEtC,eAAe,KAAK,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright © Roots Software Foundation LLC
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
/**
|
|
4
|
+
* Caching service
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://bud.js.org}
|
|
7
|
+
* @see {@link https://github.com/roots/bud}
|
|
8
|
+
*/
|
|
9
|
+
import './types.js';
|
|
10
|
+
import Cache from './service/index.js';
|
|
11
|
+
export default Cache;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,kCAAkC;AAElC;;;;;GAKG;AAEH,OAAO,YAAY,CAAA;AAEnB,OAAO,KAAK,MAAM,oBAAoB,CAAA;AAEtC,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Bud } from '@roots/bud-framework';
|
|
2
|
+
import { Extension } from '@roots/bud-framework/extension';
|
|
3
|
+
/**
|
|
4
|
+
* Cache invalidation extension
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Certain webpack components such as `eslint-webpack-plugin` and
|
|
8
|
+
* `ts-loader` have issues with fs caching. This extension writes a file
|
|
9
|
+
* to the cache directory which is used to invalidate the cache before
|
|
10
|
+
* webpack is invoked on subsequent builds
|
|
11
|
+
*/
|
|
12
|
+
export default class InvalidateCacheExtension extends Extension {
|
|
13
|
+
/**
|
|
14
|
+
* Invalidation file path
|
|
15
|
+
*/
|
|
16
|
+
get invalidationFile(): string;
|
|
17
|
+
/**
|
|
18
|
+
* {@link Extension.register}
|
|
19
|
+
*/
|
|
20
|
+
register(bud: Bud): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invalidate-cache/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;AAIxD;;;;;;;;GAQG;AAEH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D;;OAEG;IACH,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED;;OAEG;IAEmB,QAAQ,CAAC,GAAG,EAAE,GAAG;CA0BxC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { Extension } from '@roots/bud-framework/extension';
|
|
4
|
+
import { bind, label } from '@roots/bud-framework/extension/decorators';
|
|
5
|
+
import stripAnsi from 'strip-ansi';
|
|
6
|
+
/**
|
|
7
|
+
* Cache invalidation extension
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Certain webpack components such as `eslint-webpack-plugin` and
|
|
11
|
+
* `ts-loader` have issues with fs caching. This extension writes a file
|
|
12
|
+
* to the cache directory which is used to invalidate the cache before
|
|
13
|
+
* webpack is invoked on subsequent builds
|
|
14
|
+
*/
|
|
15
|
+
let InvalidateCacheExtension = class InvalidateCacheExtension extends Extension {
|
|
16
|
+
/**
|
|
17
|
+
* Invalidation file path
|
|
18
|
+
*/
|
|
19
|
+
get invalidationFile() {
|
|
20
|
+
return join(this.app.cache.cacheDirectory, `error.json`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* {@link Extension.register}
|
|
24
|
+
*/
|
|
25
|
+
async register(bud) {
|
|
26
|
+
const invalidate = await bud.fs?.exists(this.invalidationFile);
|
|
27
|
+
if (invalidate || (bud.isCLI() && bud.context.args.force)) {
|
|
28
|
+
await bud.fs.remove(this.invalidationFile);
|
|
29
|
+
await bud.fs.remove(bud.cache.cacheDirectory);
|
|
30
|
+
}
|
|
31
|
+
bud.after(async () => {
|
|
32
|
+
bud.compiler.instance.hooks.done.tap(this.label, async (compiler) => {
|
|
33
|
+
try {
|
|
34
|
+
if (!compiler.hasErrors())
|
|
35
|
+
return;
|
|
36
|
+
await bud.fs.json.write(this.invalidationFile, {
|
|
37
|
+
hash: compiler.hash,
|
|
38
|
+
errors: compiler.stats.flatMap(stats => stats
|
|
39
|
+
.toString({ preset: `errors-warnings`, colors: false })
|
|
40
|
+
.split(/\n/)
|
|
41
|
+
.map(stripAnsi)),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (e) { }
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
__decorate([
|
|
50
|
+
bind,
|
|
51
|
+
__metadata("design:type", Function),
|
|
52
|
+
__metadata("design:paramtypes", [Function]),
|
|
53
|
+
__metadata("design:returntype", Promise)
|
|
54
|
+
], InvalidateCacheExtension.prototype, "register", null);
|
|
55
|
+
InvalidateCacheExtension = __decorate([
|
|
56
|
+
label(`@roots/bud-cache/invalidate-cache`)
|
|
57
|
+
], InvalidateCacheExtension);
|
|
58
|
+
export default InvalidateCacheExtension;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/invalidate-cache/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAG9B,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,2CAA2C,CAAA;AACrE,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC;;;;;;;;GAQG;AAEY,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,SAAS;IAC7D;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAC1D,CAAC;IAED;;OAEG;IAEmB,AAAN,KAAK,CAAC,QAAQ,CAAC,GAAQ;QACrC,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAE9D,IAAI,UAAU,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACzD,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;YAC1C,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;SAC9C;QAED,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YACnB,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAC,QAAQ,EAAC,EAAE;gBAChE,IAAI;oBACF,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;wBAAE,OAAM;oBAEjC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE;wBAC7C,IAAI,EAAE,QAAQ,CAAC,IAAI;wBACnB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CACrC,KAAK;6BACF,QAAQ,CAAC,EAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAC,CAAC;6BACpD,KAAK,CAAC,IAAI,CAAC;6BACX,GAAG,CAAC,SAAS,CAAC,CAClB;qBACF,CAAC,CAAA;iBACH;gBAAC,OAAO,CAAC,EAAE,GAAE;YAChB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA1BuB;IADrB,IAAI;;;;wDA0BJ;AArCkB,wBAAwB;IAD5C,KAAK,CAAC,mCAAmC,CAAC;GACtB,wBAAwB,CAsC5C;eAtCoB,wBAAwB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Bud } from '@roots/bud-framework';
|
|
2
|
+
import { Service } from '@roots/bud-framework/service';
|
|
3
|
+
import type * as Services from '@roots/bud-framework/services';
|
|
4
|
+
import type { Configuration } from '@roots/bud-support/webpack';
|
|
5
|
+
/**
|
|
6
|
+
* Cache service class
|
|
7
|
+
*/
|
|
8
|
+
export default class Cache extends Service implements Services.Cache.Service {
|
|
9
|
+
/**
|
|
10
|
+
* Enabled
|
|
11
|
+
*/
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Type
|
|
15
|
+
*/
|
|
16
|
+
get name(): string;
|
|
17
|
+
set name(name: string);
|
|
18
|
+
/**
|
|
19
|
+
* Type
|
|
20
|
+
*/
|
|
21
|
+
get type(): 'memory' | 'filesystem';
|
|
22
|
+
set type(type: 'memory' | 'filesystem');
|
|
23
|
+
/**
|
|
24
|
+
* version
|
|
25
|
+
*/
|
|
26
|
+
get version(): string;
|
|
27
|
+
set version(version: string);
|
|
28
|
+
/**
|
|
29
|
+
* Cache directory
|
|
30
|
+
*/
|
|
31
|
+
get cacheDirectory(): string;
|
|
32
|
+
set cacheDirectory(directory: string);
|
|
33
|
+
/**
|
|
34
|
+
* Webpack configuration
|
|
35
|
+
*/
|
|
36
|
+
get configuration(): Configuration[`cache`];
|
|
37
|
+
/**
|
|
38
|
+
* {@link Extension.booted}
|
|
39
|
+
*/
|
|
40
|
+
booted?(bud: Bud): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Flush cache
|
|
43
|
+
*/
|
|
44
|
+
flush(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACpD,OAAO,KAAK,KAAK,QAAQ,MAAM,+BAA+B,CAAA;AAI9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAA;AAI7D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,KACnB,SAAQ,OACR,YAAW,QAAQ,CAAC,KAAK,CAAC,OAAO;IAEjC;;OAEG;IACI,OAAO,EAAE,OAAO,CAAO;IAE9B;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAKxB;IACD,IAAW,IAAI,CAAC,IAAI,EAAE,MAAM,EAE3B;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,QAAQ,GAAG,YAAY,CAOzC;IAED,IAAW,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,EAE5C;IAED;;OAEG;IACH,IAAW,OAAO,IAAI,MAAM,CAY3B;IAED,IAAW,OAAO,CAAC,OAAO,EAAE,MAAM,EAEjC;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,MAAM,CAKlC;IACD,IAAW,cAAc,CAAC,SAAS,EAAE,MAAM,EAE1C;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,aAAa,CAAC,OAAO,CAAC,CAkBjD;IAED;;OAEG;IAEmB,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG;IAKtC;;OAEG;IAEU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { Service } from '@roots/bud-framework/service';
|
|
5
|
+
import { bind } from '@roots/bud-support/decorators';
|
|
6
|
+
import isString from '@roots/bud-support/lodash/isString';
|
|
7
|
+
import { hash } from '@roots/bud-support/utilities/args';
|
|
8
|
+
import InvalidateCacheExtension from '../invalidate-cache/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Cache service class
|
|
11
|
+
*/
|
|
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
|
+
/**
|
|
41
|
+
* version
|
|
42
|
+
*/
|
|
43
|
+
get version() {
|
|
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
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Cache directory
|
|
56
|
+
*/
|
|
57
|
+
get cacheDirectory() {
|
|
58
|
+
return this.app.hooks.filter(`build.cache.cacheDirectory`, this.app.path(`@storage`, this.app.label, `cache`));
|
|
59
|
+
}
|
|
60
|
+
set cacheDirectory(directory) {
|
|
61
|
+
this.app.hooks.on(`build.cache.cacheDirectory`, directory);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Webpack configuration
|
|
65
|
+
*/
|
|
66
|
+
get configuration() {
|
|
67
|
+
if (this.enabled !== true)
|
|
68
|
+
return false;
|
|
69
|
+
return this.type === `memory`
|
|
70
|
+
? true
|
|
71
|
+
: {
|
|
72
|
+
name: this.name,
|
|
73
|
+
type: this.type,
|
|
74
|
+
store: `pack`,
|
|
75
|
+
allowCollectingMemory: true,
|
|
76
|
+
cacheDirectory: this.cacheDirectory,
|
|
77
|
+
idleTimeout: 10000,
|
|
78
|
+
idleTimeoutForInitialStore: 0,
|
|
79
|
+
profile: false,
|
|
80
|
+
version: this.app.hooks.filter(`build.cache.version`, this.version),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* {@link Extension.booted}
|
|
85
|
+
*/
|
|
86
|
+
async booted(bud) {
|
|
87
|
+
await bud.extensions.add(InvalidateCacheExtension);
|
|
88
|
+
this.app.success(`cache initialized`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Flush cache
|
|
92
|
+
*/
|
|
93
|
+
async flush() {
|
|
94
|
+
await this.app.fs.remove(this.cacheDirectory);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
__decorate([
|
|
98
|
+
bind,
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [Function]),
|
|
101
|
+
__metadata("design:returntype", Promise)
|
|
102
|
+
], Cache.prototype, "booted", null);
|
|
103
|
+
__decorate([
|
|
104
|
+
bind,
|
|
105
|
+
__metadata("design:type", Function),
|
|
106
|
+
__metadata("design:paramtypes", []),
|
|
107
|
+
__metadata("design:returntype", Promise)
|
|
108
|
+
], Cache.prototype, "flush", null);
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAG9B,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AAEpD,OAAO,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAA;AAClD,OAAO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qB,EAAE,IAAI;gBAC3B,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,WAAW,EAAE,KAAK;gBAClB,0BAA0B,EAAE,CAAC;gBAC7B,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAC5B,qBAAqB,EACrB,IAAI,CAAC,OAAO,CACb;aACF,CAAA;IACP,CAAC;IAED;;OAEG;IAEmB,AAAN,KAAK,CAAC,MAAM,CAAE,GAAQ;QACpC,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;QAClD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACvC,CAAC;IAED;;OAEG;IAEU,AAAN,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC/C,CAAC;CACF;AAZuB;IADrB,IAAI;;;;mCAIJ;AAMY;IADZ,IAAI;;;;kCAGJ"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @roots/bud-cache
|
|
3
|
+
*/
|
|
4
|
+
import type InvalidateCacheExtension from './invalidate-cache/index.js';
|
|
5
|
+
declare module '@roots/bud-framework' {
|
|
6
|
+
interface Modules {
|
|
7
|
+
'@roots/bud-cache/invalidate-cache': InvalidateCacheExtension;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,wBAAwB,MAAM,6BAA6B,CAAA;AAEvE,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,OAAO;QACf,mCAAmC,EAAE,wBAAwB,CAAA;KAC9D;CACF"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-cache",
|
|
3
|
+
"version": "6.12.0",
|
|
3
4
|
"description": "Config caching",
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/roots/bud.git",
|
|
9
|
-
"directory": "sources/@roots/bud-cache"
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=16"
|
|
10
7
|
},
|
|
11
8
|
"contributors": [
|
|
12
9
|
{
|
|
@@ -25,20 +22,21 @@
|
|
|
25
22
|
}
|
|
26
23
|
],
|
|
27
24
|
"license": "MIT",
|
|
28
|
-
"
|
|
29
|
-
"url": "https://github.com/roots/bud/issues"
|
|
30
|
-
},
|
|
25
|
+
"homepage": "https://roots.io/bud",
|
|
31
26
|
"funding": {
|
|
32
27
|
"type": "github sponsors",
|
|
33
28
|
"url": "https://github.com/sponsors/roots"
|
|
34
29
|
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/roots/bud.git",
|
|
33
|
+
"directory": "sources/@roots/bud-cache"
|
|
34
|
+
},
|
|
35
|
+
"bugs": "https://github.com/roots/bud/issues",
|
|
35
36
|
"keywords": [
|
|
36
37
|
"bud",
|
|
37
38
|
"bud-framework"
|
|
38
39
|
],
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=16"
|
|
41
|
-
},
|
|
42
40
|
"files": [
|
|
43
41
|
"docs",
|
|
44
42
|
"lib",
|
|
@@ -47,20 +45,20 @@
|
|
|
47
45
|
"type": "module",
|
|
48
46
|
"exports": {
|
|
49
47
|
".": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
48
|
+
"import": "./lib/index.js",
|
|
49
|
+
"default": "./lib/index.js"
|
|
52
50
|
},
|
|
53
51
|
"./service": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
52
|
+
"import": "./lib/service.js",
|
|
53
|
+
"default": "./lib/service.js"
|
|
56
54
|
},
|
|
57
55
|
"./invalidate-cache": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
56
|
+
"import": "./lib/invalidate-cache/index.js",
|
|
57
|
+
"default": "./lib/invalidate-cache/index.js"
|
|
60
58
|
},
|
|
61
59
|
"./types": {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
60
|
+
"import": "./lib/types.js",
|
|
61
|
+
"default": "./lib/types.js"
|
|
64
62
|
}
|
|
65
63
|
},
|
|
66
64
|
"typesVersions": {
|
|
@@ -68,23 +66,24 @@
|
|
|
68
66
|
".": [
|
|
69
67
|
"./lib/index.d.ts"
|
|
70
68
|
],
|
|
71
|
-
"
|
|
69
|
+
"service": [
|
|
72
70
|
"./lib/service.d.ts"
|
|
73
71
|
],
|
|
74
|
-
"
|
|
72
|
+
"types": [
|
|
75
73
|
"./lib/types.d.ts"
|
|
76
74
|
]
|
|
77
75
|
}
|
|
78
76
|
},
|
|
79
|
-
"module": "./lib/index.js",
|
|
80
77
|
"types": "./lib/index.d.ts",
|
|
78
|
+
"module": "./lib/index.js",
|
|
81
79
|
"devDependencies": {
|
|
82
80
|
"@skypack/package-check": "0.2.2"
|
|
83
81
|
},
|
|
84
82
|
"dependencies": {
|
|
85
|
-
"@roots/bud-framework": "6.
|
|
86
|
-
"@roots/bud-support": "6.
|
|
87
|
-
"strip-ansi": "7.0.1"
|
|
83
|
+
"@roots/bud-framework": "6.12.0",
|
|
84
|
+
"@roots/bud-support": "6.12.0",
|
|
85
|
+
"strip-ansi": "7.0.1",
|
|
86
|
+
"tslib": "2.5.0"
|
|
88
87
|
},
|
|
89
88
|
"volta": {
|
|
90
89
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -24,13 +24,13 @@ export default class InvalidateCacheExtension extends Extension {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* {@link Extension.register}
|
|
28
28
|
*/
|
|
29
29
|
@bind
|
|
30
30
|
public override async register(bud: Bud) {
|
|
31
31
|
const invalidate = await bud.fs?.exists(this.invalidationFile)
|
|
32
32
|
|
|
33
|
-
if (invalidate || (bud.isCLI() && bud.context.args.
|
|
33
|
+
if (invalidate || (bud.isCLI() && bud.context.args.force)) {
|
|
34
34
|
await bud.fs.remove(this.invalidationFile)
|
|
35
35
|
await bud.fs.remove(bud.cache.cacheDirectory)
|
|
36
36
|
}
|
package/src/service/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {createHash} from 'node:crypto'
|
|
2
|
+
import {join} from 'node:path'
|
|
2
3
|
|
|
3
4
|
import type {Bud} from '@roots/bud-framework'
|
|
4
5
|
import {Service} from '@roots/bud-framework/service'
|
|
5
6
|
import type * as Services from '@roots/bud-framework/services'
|
|
6
7
|
import {bind} from '@roots/bud-support/decorators'
|
|
7
8
|
import isString from '@roots/bud-support/lodash/isString'
|
|
8
|
-
import
|
|
9
|
+
import {hash} from '@roots/bud-support/utilities/args'
|
|
9
10
|
import type {Configuration} from '@roots/bud-support/webpack'
|
|
10
11
|
|
|
11
12
|
import InvalidateCacheExtension from '../invalidate-cache/index.js'
|
|
@@ -28,7 +29,7 @@ export default class Cache
|
|
|
28
29
|
public get name(): string {
|
|
29
30
|
return this.app.hooks.filter(
|
|
30
31
|
`build.cache.name`,
|
|
31
|
-
this.app.hooks.filter(`build.name`, this.app.
|
|
32
|
+
this.app.hooks.filter(`build.name`, join(`webpack`, this.app.mode)),
|
|
32
33
|
)
|
|
33
34
|
}
|
|
34
35
|
public set name(name: string) {
|
|
@@ -55,20 +56,19 @@ export default class Cache
|
|
|
55
56
|
* version
|
|
56
57
|
*/
|
|
57
58
|
public get version(): string {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
file => file?.bud
|
|
63
|
-
|
|
59
|
+
const version = createHash(`sha1`)
|
|
60
|
+
version.update(hash)
|
|
61
|
+
|
|
62
|
+
Object.values(this.app.context.files ?? {})
|
|
63
|
+
.filter(file => file?.bud || file?.name?.includes(`package.json`))
|
|
64
|
+
.map(({sha1}) => version.update(sha1))
|
|
64
65
|
|
|
65
66
|
return this.app.hooks.filter(
|
|
66
67
|
`build.cache.version`,
|
|
67
|
-
|
|
68
|
-
.update(join(args, ...files.map(({module: {sha1}}) => sha1)))
|
|
69
|
-
.digest(`base64`),
|
|
68
|
+
version.digest(`base64`),
|
|
70
69
|
)
|
|
71
70
|
}
|
|
71
|
+
|
|
72
72
|
public set version(version: string) {
|
|
73
73
|
this.app.hooks.on(`build.cache.version`, version)
|
|
74
74
|
}
|
|
@@ -79,7 +79,7 @@ export default class Cache
|
|
|
79
79
|
public get cacheDirectory(): string {
|
|
80
80
|
return this.app.hooks.filter(
|
|
81
81
|
`build.cache.cacheDirectory`,
|
|
82
|
-
this.app.path(`@storage`, this.app.label, `cache
|
|
82
|
+
this.app.path(`@storage`, this.app.label, `cache`),
|
|
83
83
|
)
|
|
84
84
|
}
|
|
85
85
|
public set cacheDirectory(directory: string) {
|
|
@@ -101,8 +101,11 @@ export default class Cache
|
|
|
101
101
|
cacheDirectory: this.cacheDirectory,
|
|
102
102
|
idleTimeout: 10000,
|
|
103
103
|
idleTimeoutForInitialStore: 0,
|
|
104
|
-
profile:
|
|
105
|
-
version: this.
|
|
104
|
+
profile: false,
|
|
105
|
+
version: this.app.hooks.filter(
|
|
106
|
+
`build.cache.version`,
|
|
107
|
+
this.version,
|
|
108
|
+
),
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|