@roots/bud-cache 6.3.5 → 6.4.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/LICENSE.md +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/invalidate-cache-extension/index.d.ts +1 -0
- package/lib/invalidate-cache-extension/index.d.ts.map +1 -1
- package/lib/invalidate-cache-extension/index.js +19 -8
- package/lib/invalidate-cache-extension/index.js.map +1 -1
- package/lib/service.d.ts +27 -30
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +72 -51
- package/lib/service.js.map +1 -1
- package/package.json +7 -10
package/LICENSE.md
CHANGED
|
@@ -12,7 +12,7 @@ copies or substantial portions of the Software.
|
|
|
12
12
|
|
|
13
13
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
14
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
16
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
17
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,wBAAwB,MAAM,uCAAuC,CAAA;AACjF,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,OAAO;QACf,mCAAmC,EAAE,wBAAwB,CAAA;KAC9D;CACF;AAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,wBAAwB,MAAM,uCAAuC,CAAA;AACjF,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,OAAO;QACf,mCAAmC,EAAE,wBAAwB,CAAA;KAC9D;CACF;AAED,eAAe,KAAK,CAAA"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,kCAAkC;AAYlC,OAAO,KAAK,MAAM,cAAc,CAAA;AAQhC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,kCAAkC;AAYlC,OAAO,KAAK,MAAM,cAAc,CAAA;AAQhC,eAAe,KAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invalidate-cache-extension/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invalidate-cache-extension/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;AAKxD;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAC7D,IAAW,IAAI,IAAI,MAAM,CAMxB;IAED;;;;;OAKG;IACgB,QAAQ;CA0B5B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { Extension } from '@roots/bud-framework/extension';
|
|
3
3
|
import { bind, label } from '@roots/bud-framework/extension/decorators';
|
|
4
|
-
import fs from 'fs
|
|
4
|
+
import * as fs from '@roots/bud-support/fs';
|
|
5
|
+
import stripAnsi from 'strip-ansi';
|
|
5
6
|
/**
|
|
6
7
|
* Cache invalidation extension
|
|
7
8
|
*
|
|
@@ -15,6 +16,9 @@ import fs from 'fs-extra';
|
|
|
15
16
|
* @decorator `@label`
|
|
16
17
|
*/
|
|
17
18
|
let InvalidateCacheExtension = class InvalidateCacheExtension extends Extension {
|
|
19
|
+
get file() {
|
|
20
|
+
return this.app.path(`@storage`, `${this.app.label}`, `${this.app.mode}.error.json`);
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* `register` callback
|
|
20
24
|
*
|
|
@@ -22,15 +26,22 @@ let InvalidateCacheExtension = class InvalidateCacheExtension extends Extension
|
|
|
22
26
|
* @decorator `@bind`
|
|
23
27
|
*/
|
|
24
28
|
async register() {
|
|
25
|
-
const invalidate = await fs.pathExists(this.
|
|
26
|
-
if (this.app.context.args.flush
|
|
27
|
-
await fs.remove(this.
|
|
29
|
+
const invalidate = await fs.pathExists(this.file);
|
|
30
|
+
if (invalidate || this.app.context.args.flush) {
|
|
31
|
+
await fs.remove(this.file);
|
|
32
|
+
await fs.remove(this.app.path(`@storage`, this.app.label, `cache`));
|
|
28
33
|
}
|
|
29
|
-
this.app.hooks.action(
|
|
30
|
-
this.app.compiler.
|
|
34
|
+
this.app.hooks.action(`compiler.after`, async () => {
|
|
35
|
+
this.app.compiler.instance.hooks.done.tap(this.label, async (compiler) => {
|
|
31
36
|
if (!compiler.hasErrors())
|
|
32
37
|
return;
|
|
33
|
-
await fs.
|
|
38
|
+
await fs.writeJson(this.file, {
|
|
39
|
+
hash: compiler.hash,
|
|
40
|
+
errors: compiler.stats.flatMap(stats => stats
|
|
41
|
+
.toString({ preset: `errors-warnings`, colors: false })
|
|
42
|
+
.split(/\n/)
|
|
43
|
+
.map(stripAnsi)),
|
|
44
|
+
});
|
|
34
45
|
});
|
|
35
46
|
});
|
|
36
47
|
}
|
|
@@ -39,7 +50,7 @@ __decorate([
|
|
|
39
50
|
bind
|
|
40
51
|
], InvalidateCacheExtension.prototype, "register", null);
|
|
41
52
|
InvalidateCacheExtension = __decorate([
|
|
42
|
-
label(
|
|
53
|
+
label(`@roots/bud-cache/invalidate-cache`)
|
|
43
54
|
], InvalidateCacheExtension);
|
|
44
55
|
export default InvalidateCacheExtension;
|
|
45
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/invalidate-cache-extension/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/invalidate-cache-extension/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,2CAA2C,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC;;;;;;;;;;;GAWG;AAEH,IAAqB,wBAAwB,GAA7C,MAAqB,wBAAyB,SAAQ,SAAS;IAC7D,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAClB,UAAU,EACV,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EACnB,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,aAAa,CAC9B,CAAA;IACH,CAAC;IAED;;;;;OAKG;I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B,wBAAwB"}
|
package/lib/service.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { Service
|
|
2
|
-
import type
|
|
1
|
+
import { Service } from '@roots/bud-framework/service';
|
|
2
|
+
import type * as Services from '@roots/bud-framework/services';
|
|
3
3
|
/**
|
|
4
4
|
* Cache service class
|
|
5
5
|
*
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
export default class Cache extends Service implements Services.Cache.Service {
|
|
9
|
+
/**
|
|
10
|
+
* Service label
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
static label: string;
|
|
9
15
|
/**
|
|
10
16
|
* Enabled
|
|
11
17
|
*
|
|
@@ -17,7 +23,6 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
17
23
|
*
|
|
18
24
|
* @public
|
|
19
25
|
*/
|
|
20
|
-
protected _name: string;
|
|
21
26
|
get name(): string;
|
|
22
27
|
set name(name: string);
|
|
23
28
|
/**
|
|
@@ -25,7 +30,6 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
25
30
|
*
|
|
26
31
|
* @public
|
|
27
32
|
*/
|
|
28
|
-
protected _type: 'memory' | 'filesystem';
|
|
29
33
|
get type(): 'memory' | 'filesystem';
|
|
30
34
|
set type(type: 'memory' | 'filesystem');
|
|
31
35
|
/**
|
|
@@ -33,7 +37,6 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
33
37
|
*
|
|
34
38
|
* @public
|
|
35
39
|
*/
|
|
36
|
-
protected _version: string;
|
|
37
40
|
get version(): string;
|
|
38
41
|
set version(version: string);
|
|
39
42
|
/**
|
|
@@ -42,39 +45,36 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
42
45
|
* @public
|
|
43
46
|
*/
|
|
44
47
|
get buildDependencies(): any;
|
|
45
|
-
set buildDependencies(deps: Context['disk']['config']);
|
|
46
48
|
/**
|
|
47
49
|
* Cache directory
|
|
48
50
|
*
|
|
49
51
|
* @public
|
|
50
52
|
*/
|
|
51
|
-
protected _cacheDirectory: string;
|
|
52
53
|
get cacheDirectory(): string;
|
|
53
54
|
set cacheDirectory(directory: string);
|
|
54
|
-
/**
|
|
55
|
-
* Managed paths
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
protected _managedPaths: Array<string>;
|
|
60
|
-
get managedPaths(): Array<string>;
|
|
61
|
-
set managedPaths(paths: Array<string>);
|
|
62
55
|
/**
|
|
63
56
|
* Webpack configuration
|
|
64
57
|
*
|
|
65
58
|
* @public
|
|
66
59
|
*/
|
|
67
|
-
get configuration():
|
|
60
|
+
get configuration(): boolean | {
|
|
61
|
+
name: string;
|
|
68
62
|
type: "memory" | "filesystem";
|
|
63
|
+
store: "pack";
|
|
64
|
+
allowCollectingMemory: boolean;
|
|
65
|
+
cacheDirectory: string;
|
|
66
|
+
buildDependencies: any;
|
|
67
|
+
idleTimeout: number;
|
|
68
|
+
idleTimeoutForInitialStore: number;
|
|
69
|
+
profile: boolean;
|
|
70
|
+
version: string;
|
|
69
71
|
};
|
|
70
72
|
/**
|
|
71
73
|
* Memory cache
|
|
72
74
|
*
|
|
73
75
|
* @public
|
|
74
76
|
*/
|
|
75
|
-
get memoryCache():
|
|
76
|
-
type: "memory" | "filesystem";
|
|
77
|
-
};
|
|
77
|
+
get memoryCache(): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Filesystem cache
|
|
80
80
|
*
|
|
@@ -83,25 +83,22 @@ export default class Cache extends Service implements Services.Cache.Service {
|
|
|
83
83
|
get filesystemCache(): {
|
|
84
84
|
name: string;
|
|
85
85
|
type: "memory" | "filesystem";
|
|
86
|
-
|
|
86
|
+
store: "pack";
|
|
87
|
+
allowCollectingMemory: boolean;
|
|
87
88
|
cacheDirectory: string;
|
|
88
|
-
managedPaths: string[];
|
|
89
89
|
buildDependencies: any;
|
|
90
|
+
idleTimeout: number;
|
|
91
|
+
idleTimeoutForInitialStore: number;
|
|
92
|
+
profile: boolean;
|
|
93
|
+
version: string;
|
|
90
94
|
};
|
|
91
|
-
/**
|
|
92
|
-
* `register` callback
|
|
93
|
-
*
|
|
94
|
-
* @public
|
|
95
|
-
* @decorator `@bind`
|
|
96
|
-
*/
|
|
97
|
-
register(): Promise<void>;
|
|
98
95
|
/**
|
|
99
96
|
* `boot` callback
|
|
100
97
|
*
|
|
101
98
|
* @public
|
|
102
99
|
* @decorator `@bind`
|
|
103
100
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
booted(): Promise<void>;
|
|
102
|
+
flush(): Promise<void>;
|
|
106
103
|
}
|
|
107
104
|
//# sourceMappingURL=service.d.ts.map
|
package/lib/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AACpD,OAAO,KAAK,KAAK,QAAQ,MAAM,+BAA+B,CAAA;AAQ9D;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,KACnB,SAAQ,OACR,YAAW,QAAQ,CAAC,KAAK,CAAC,OAAO;IAEjC;;;;OAIG;IACH,OAAc,KAAK,SAAU;IAE7B;;;;OAIG;IACI,OAAO,EAAE,OAAO,CAAO;IAE9B;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IACD,IAAW,IAAI,CAAC,IAAI,EAAE,MAAM,EAE3B;IAED;;;;OAIG;IACH,IAAW,IAAI,IAAI,QAAQ,GAAG,YAAY,CAEzC;IACD,IAAW,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,YAAY,EAE5C;IAED;;;;OAIG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IACD,IAAW,OAAO,CAAC,OAAO,EAAE,MAAM,EAEjC;IAED;;;;OAIG;IACH,IAAW,iBAAiB,IAAI,GAAG,CAIlC;IAED;;;;OAIG;IACH,IAAW,cAAc,IAAI,MAAM,CAElC;IACD,IAAW,cAAc,CAAC,SAAS,EAAE,MAAM,EAE1C;IAED;;;;OAIG;IACH,IAAW,aAAa;;;;;;;;;;;MAGvB;IAED;;;;OAIG;IACH,IAAW,WAAW,YAErB;IAED;;;;OAIG;IACH,IAAW,eAAe;;;;;;;;;;;MAazB;IAED;;;;;OAKG;IAEU,MAAM;IAqCN,KAAK;CAGnB"}
|
package/lib/service.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { Service } from '@roots/bud-framework';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { Service } from '@roots/bud-framework/service';
|
|
3
|
+
import { bind } from '@roots/bud-support/decorators';
|
|
4
|
+
import * as fs from '@roots/bud-support/fs';
|
|
5
|
+
import { isUndefined } from '@roots/bud-support/lodash-es';
|
|
5
6
|
import { createHash } from 'node:crypto';
|
|
6
7
|
import InvalidateCacheExtension from './invalidate-cache-extension/index.js';
|
|
7
8
|
/**
|
|
@@ -19,23 +20,38 @@ export default class Cache extends Service {
|
|
|
19
20
|
*/
|
|
20
21
|
this.enabled = true;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Type
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
22
28
|
get name() {
|
|
23
|
-
return this.app.hooks.filter(
|
|
29
|
+
return this.app.hooks.filter(`build.cache.name`);
|
|
24
30
|
}
|
|
25
31
|
set name(name) {
|
|
26
|
-
this.app.hooks.on(
|
|
32
|
+
this.app.hooks.on(`build.cache.name`, name);
|
|
27
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Type
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
28
39
|
get type() {
|
|
29
|
-
return this.
|
|
40
|
+
return this.app.hooks.filter(`build.cache.type`);
|
|
30
41
|
}
|
|
31
42
|
set type(type) {
|
|
32
|
-
this.
|
|
43
|
+
this.app.hooks.on(`build.cache.type`, type);
|
|
33
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* version
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
34
50
|
get version() {
|
|
35
|
-
return this.
|
|
51
|
+
return this.app.hooks.filter(`build.cache.version`);
|
|
36
52
|
}
|
|
37
53
|
set version(version) {
|
|
38
|
-
this.
|
|
54
|
+
this.app.hooks.on(`build.cache.version`, version);
|
|
39
55
|
}
|
|
40
56
|
/**
|
|
41
57
|
* Build dependencies
|
|
@@ -44,23 +60,19 @@ export default class Cache extends Service {
|
|
|
44
60
|
*/
|
|
45
61
|
get buildDependencies() {
|
|
46
62
|
return {
|
|
47
|
-
|
|
63
|
+
config: Object.values(this.app.context.config).map(({ path }) => path),
|
|
48
64
|
};
|
|
49
65
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Cache directory
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
53
71
|
get cacheDirectory() {
|
|
54
|
-
return this.
|
|
72
|
+
return this.app.hooks.filter(`build.cache.cacheDirectory`);
|
|
55
73
|
}
|
|
56
74
|
set cacheDirectory(directory) {
|
|
57
|
-
this.
|
|
58
|
-
}
|
|
59
|
-
get managedPaths() {
|
|
60
|
-
return this._managedPaths;
|
|
61
|
-
}
|
|
62
|
-
set managedPaths(paths) {
|
|
63
|
-
this._managedPaths = paths;
|
|
75
|
+
this.app.hooks.on(`build.cache.cacheDirectory`, directory);
|
|
64
76
|
}
|
|
65
77
|
/**
|
|
66
78
|
* Webpack configuration
|
|
@@ -68,9 +80,9 @@ export default class Cache extends Service {
|
|
|
68
80
|
* @public
|
|
69
81
|
*/
|
|
70
82
|
get configuration() {
|
|
71
|
-
if (this.enabled
|
|
72
|
-
return
|
|
73
|
-
return this.type
|
|
83
|
+
if (this.enabled !== true)
|
|
84
|
+
return false;
|
|
85
|
+
return this.type == `memory` ? this.memoryCache : this.filesystemCache;
|
|
74
86
|
}
|
|
75
87
|
/**
|
|
76
88
|
* Memory cache
|
|
@@ -78,9 +90,7 @@ export default class Cache extends Service {
|
|
|
78
90
|
* @public
|
|
79
91
|
*/
|
|
80
92
|
get memoryCache() {
|
|
81
|
-
return
|
|
82
|
-
type: this.type,
|
|
83
|
-
};
|
|
93
|
+
return true;
|
|
84
94
|
}
|
|
85
95
|
/**
|
|
86
96
|
* Filesystem cache
|
|
@@ -91,53 +101,64 @@ export default class Cache extends Service {
|
|
|
91
101
|
return {
|
|
92
102
|
name: this.name,
|
|
93
103
|
type: this.type,
|
|
94
|
-
|
|
104
|
+
store: `pack`,
|
|
105
|
+
allowCollectingMemory: true,
|
|
95
106
|
cacheDirectory: this.cacheDirectory,
|
|
96
|
-
managedPaths: this.managedPaths,
|
|
97
107
|
buildDependencies: this.buildDependencies,
|
|
108
|
+
idleTimeout: 10000,
|
|
109
|
+
idleTimeoutForInitialStore: 0,
|
|
110
|
+
profile: true,
|
|
111
|
+
version: this.version,
|
|
98
112
|
};
|
|
99
113
|
}
|
|
100
|
-
/**
|
|
101
|
-
* `register` callback
|
|
102
|
-
*
|
|
103
|
-
* @public
|
|
104
|
-
* @decorator `@bind`
|
|
105
|
-
*/
|
|
106
|
-
async register() {
|
|
107
|
-
await this.app.extensions.add(InvalidateCacheExtension);
|
|
108
|
-
}
|
|
109
114
|
/**
|
|
110
115
|
* `boot` callback
|
|
111
116
|
*
|
|
112
117
|
* @public
|
|
113
118
|
* @decorator `@bind`
|
|
114
119
|
*/
|
|
115
|
-
async
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
async booted() {
|
|
121
|
+
await this.app.extensions.add(InvalidateCacheExtension);
|
|
122
|
+
this.enabled =
|
|
123
|
+
isUndefined(this.app.context.args.cache) ||
|
|
124
|
+
this.app.context.args.cache !== false;
|
|
125
|
+
this.type =
|
|
126
|
+
isUndefined(this.app.context.args.cache) ||
|
|
127
|
+
(this.app.context.args.cache !== false &&
|
|
128
|
+
this.app.context.args.cache !== `memory`)
|
|
129
|
+
? `filesystem`
|
|
130
|
+
: `memory`;
|
|
131
|
+
this.app.context.args.cache === `memory` ? `memory` : `filesystem`;
|
|
132
|
+
this.name = `${this.app.label}/cache/${this.app.mode}/webpack`;
|
|
133
|
+
this.cacheDirectory = this.app.path(`@storage`);
|
|
120
134
|
const args = Object.entries(this.app.context.args)
|
|
121
135
|
.filter(([k, v]) => v !== undefined)
|
|
122
136
|
.map(([k, v]) => `${k}-${v}`)
|
|
123
137
|
.join(`.`);
|
|
124
138
|
this.version = createHash(`sha1`)
|
|
125
|
-
.update(this.app.json.stringify([this.app.context.
|
|
139
|
+
.update(this.app.json.stringify([this.app.context.config, args]))
|
|
126
140
|
.digest(`base64`)
|
|
127
141
|
.replace(/[^a-z0-9]/gi, `_`)
|
|
128
142
|
.toLowerCase();
|
|
143
|
+
this.app.success(`cache initialized`);
|
|
144
|
+
if (this.app.context.args.cache === false) {
|
|
145
|
+
this.app.log(`cache is disabled with a contextual argument`);
|
|
146
|
+
}
|
|
129
147
|
}
|
|
130
|
-
|
|
131
|
-
fs.
|
|
148
|
+
async flush() {
|
|
149
|
+
await fs.remove(this.cacheDirectory);
|
|
132
150
|
}
|
|
133
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Service label
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
Cache.label = `cache`;
|
|
134
158
|
__decorate([
|
|
135
159
|
bind
|
|
136
|
-
], Cache.prototype, "
|
|
137
|
-
__decorate([
|
|
138
|
-
bind
|
|
139
|
-
], Cache.prototype, "boot", null);
|
|
160
|
+
], Cache.prototype, "booted", null);
|
|
140
161
|
__decorate([
|
|
141
162
|
bind
|
|
142
|
-
], Cache.prototype, "
|
|
163
|
+
], Cache.prototype, "flush", null);
|
|
143
164
|
//# sourceMappingURL=service.js.map
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,8BAA8B,CAAA;AAEpD,OAAO,EAAC,IAAI,EAAC,MAAM,+BAA+B,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AAEtC,OAAO,wBAAwB,MAAM,uCAAuC,CAAA;AAE5E;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,KACnB,SAAQ,OAAO;IADjB;;QAWE;;;;WAIG;QACI,YAAO,GAAY,IAAI,CAAA;IAmJhC,CAAC;IAjJC;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAClD,CAAC;IACD,IAAW,IAAI,CAAC,IAAY;QAC1B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAClD,CAAC;IACD,IAAW,IAAI,CAAC,IAA6B;QAC3C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED;;;;OAIG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI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EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;aACnC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;aAC5B,IAAI,CAAC,GAAG,CAAC,CAAA;QAEZ,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;aAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;aAChE,MAAM,CAAC,QAAQ,CAAC;aAChB,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;aAC3B,WAAW,EAAE,CAAA;QAEhB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;QACrC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE;YACzC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAA;SAC7D;IACH,CAAC;IAGM,KAAK,CAAC,KAAK;QAChB,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IACtC,CAAC;;AA9JD;;;;GAIG;AACW,WAAK,GAAG,OAAO,CAAA;AAkH7B;IADC,IAAI;mCAmCJ;AAGD;IADC,IAAI;kCAGJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-cache",
|
|
3
3
|
"description": "Config caching",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.4.0",
|
|
5
5
|
"homepage": "https://roots.io/bud",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -55,17 +55,14 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@types/lodash": "4.14.182",
|
|
61
|
-
"@types/lodash-es": "4.17.6",
|
|
62
|
-
"tslib": "2.4.0"
|
|
58
|
+
"@jest/globals": "29.0.1",
|
|
59
|
+
"@skypack/package-check": "0.2.2"
|
|
63
60
|
},
|
|
64
61
|
"dependencies": {
|
|
65
|
-
"@roots/bud-framework": "6.
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
62
|
+
"@roots/bud-framework": "6.4.0",
|
|
63
|
+
"@roots/bud-support": "6.4.0",
|
|
64
|
+
"strip-ansi": "7.0.1",
|
|
65
|
+
"tslib": "2.4.0"
|
|
69
66
|
},
|
|
70
67
|
"volta": {
|
|
71
68
|
"extends": "../../../package.json"
|