@roots/bud-cache 5.0.0-next.1 → 5.0.0-next.10
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/cjs/Cache/cache.dependencies.js +13 -0
- package/lib/cjs/Cache/cache.dependencies.js.map +1 -0
- package/lib/cjs/Cache/index.js +86 -82
- package/lib/cjs/Cache/index.js.map +1 -1
- package/lib/cjs/index.js +3 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/Cache/cache.dependencies.js +6 -0
- package/lib/esm/Cache/cache.dependencies.js.map +1 -0
- package/lib/esm/Cache/index.js +83 -80
- package/lib/esm/Cache/index.js.map +1 -1
- package/lib/esm/index.js +2 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig-esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/types/Cache/cache.dependencies.d.ts +6 -0
- package/types/Cache/cache.dependencies.d.ts.map +1 -0
- package/types/Cache/index.d.ts +18 -35
- package/types/Cache/index.d.ts.map +1 -1
- package/types/index.d.ts +2 -3
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFile = exports.writeJson = exports.remove = exports.readJson = exports.readFile = exports.ensureFile = exports.createHash = exports.globby = exports.bind = exports.Bud = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
exports.Bud = (0, tslib_1.__importStar)(require("@roots/bud-framework"));
|
|
6
|
+
var bud_support_1 = require("@roots/bud-support");
|
|
7
|
+
Object.defineProperty(exports, "bind", { enumerable: true, get: function () { return bud_support_1.bind; } });
|
|
8
|
+
Object.defineProperty(exports, "globby", { enumerable: true, get: function () { return bud_support_1.globby; } });
|
|
9
|
+
var crypto_1 = require("crypto");
|
|
10
|
+
Object.defineProperty(exports, "createHash", { enumerable: true, get: function () { return crypto_1.createHash; } });
|
|
11
|
+
const bud_support_2 = require("@roots/bud-support");
|
|
12
|
+
exports.ensureFile = bud_support_2.fs.ensureFile, exports.readFile = bud_support_2.fs.readFile, exports.readJson = bud_support_2.fs.readJson, exports.remove = bud_support_2.fs.remove, exports.writeJson = bud_support_2.fs.writeJson, exports.writeFile = bud_support_2.fs.writeFile;
|
|
13
|
+
//# sourceMappingURL=cache.dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.dependencies.js","sourceRoot":"","sources":["../../../src/Cache/cache.dependencies.ts"],"names":[],"mappings":";;;;AAAA,yEAA2C;AAC3C,kDAA+C;AAAvC,mGAAA,IAAI,OAAA;AAAE,qGAAA,MAAM,OAAA;AACpB,iCAAiC;AAAzB,oGAAA,UAAU,OAAA;AAElB,oDAAqC;AAEnC,kBAAU,GAMR,gBAAE,aALJ,gBAAQ,GAKN,gBAAE,WAJJ,gBAAQ,GAIN,gBAAE,WAHJ,cAAM,GAGJ,gBAAE,SAFJ,iBAAS,GAEP,gBAAE,YADJ,iBAAS,GACP,gBAAE,WAAA"}
|
package/lib/cjs/Cache/index.js
CHANGED
|
@@ -1,107 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cache = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const { readFileSync } = bud_support_1.fs;
|
|
5
|
+
const helpful_decorators_1 = require("helpful-decorators");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const cache_dependencies_1 = require("./cache.dependencies");
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Interfaces with:
|
|
13
|
-
* - {@link @roots/bud-framework#Project} to determine project dependencies for snapshotting/validation.
|
|
14
|
-
* - {@link @roots/bud-framework#Build} via {@link @roots/bud-framework#Hooks} to update config.
|
|
15
|
-
*
|
|
16
|
-
* Facades:
|
|
17
|
-
* - {@link @roots/bud-framework#Api} can toggle cache settings with {@link Bud.Persist}
|
|
9
|
+
* Cache service class
|
|
18
10
|
*
|
|
19
11
|
* @public
|
|
20
12
|
*/
|
|
21
|
-
class
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
/**
|
|
25
|
-
* {@inheritDoc}
|
|
26
|
-
*/
|
|
27
|
-
this.name = 'cache';
|
|
28
|
-
}
|
|
13
|
+
class Cache extends cache_dependencies_1.Bud.Cache.Abstract {
|
|
29
14
|
/**
|
|
30
|
-
*
|
|
15
|
+
* True if cache is enabled
|
|
31
16
|
*
|
|
32
|
-
* @
|
|
17
|
+
* @public
|
|
33
18
|
*/
|
|
34
|
-
|
|
35
|
-
app.
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
get enabled() {
|
|
20
|
+
if (this.app.store.is('cli.flags.cache', true)) {
|
|
21
|
+
this.log('info', {
|
|
22
|
+
message: '--cache',
|
|
23
|
+
suffix: this.app.store.get('cli.flags.cache'),
|
|
24
|
+
});
|
|
25
|
+
return this.app.store.get('cli.flags.cache');
|
|
26
|
+
}
|
|
27
|
+
if (this.app.store.is('features.cache', true)) {
|
|
28
|
+
this.log('info', {
|
|
29
|
+
message: 'bud.store',
|
|
30
|
+
suffix: this.app.store.get('features.cache'),
|
|
31
|
+
});
|
|
32
|
+
return this.app.store.get('features.cache');
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
40
35
|
}
|
|
41
36
|
/**
|
|
42
|
-
*
|
|
37
|
+
* Type
|
|
43
38
|
*
|
|
44
|
-
* @
|
|
39
|
+
* @public
|
|
45
40
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
41
|
+
get type() {
|
|
42
|
+
const flags = this.app.store.get('cli.flags');
|
|
43
|
+
const cache = this.app.store.get('cache');
|
|
44
|
+
if (!(0, lodash_1.isUndefined)(flags['cache.type'])) {
|
|
45
|
+
this.log('info', {
|
|
46
|
+
message: '--cache.type flag',
|
|
47
|
+
suffix: flags['cache.type'],
|
|
48
|
+
});
|
|
49
|
+
return flags['cache.type'];
|
|
50
|
+
}
|
|
51
|
+
if (!(0, lodash_1.isUndefined)(cache.type)) {
|
|
52
|
+
this.log('info', {
|
|
53
|
+
message: 'bud.store',
|
|
54
|
+
suffix: cache.type,
|
|
55
|
+
});
|
|
56
|
+
return cache.type;
|
|
57
|
+
}
|
|
58
|
+
this.log('warn', 'no cache setting was passed from cli flags or from settings');
|
|
59
|
+
return false;
|
|
52
60
|
}
|
|
53
61
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @decorator `@bind`
|
|
62
|
+
* @public
|
|
57
63
|
*/
|
|
58
|
-
|
|
59
|
-
return
|
|
64
|
+
boot() {
|
|
65
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
66
|
+
this.version = yield this.hashFileContents();
|
|
67
|
+
if (this.enabled) {
|
|
68
|
+
this.app.persist(this.type);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
60
71
|
}
|
|
61
72
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* @see https://webpack.js.org/configuration/cache/#cachebuilddependencies
|
|
66
|
-
*
|
|
67
|
-
* @decorator `@bind`
|
|
73
|
+
* @public
|
|
68
74
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
hashFileContents() {
|
|
76
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
77
|
+
const hash = (str) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
78
|
+
return (0, cache_dependencies_1.createHash)('sha1')
|
|
79
|
+
.update(str)
|
|
80
|
+
.digest('base64')
|
|
81
|
+
.replace(/[^a-z0-9]/gi, '_')
|
|
82
|
+
.toLowerCase();
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
return yield hash(JSON.stringify({
|
|
86
|
+
checks: [
|
|
87
|
+
this.app.mode,
|
|
88
|
+
this.app.store.get('cli.flags.features'),
|
|
89
|
+
this.app.store.get('cli.flags.location'),
|
|
90
|
+
this.app.project.get('manifest'),
|
|
91
|
+
this.app.project.get('configs'),
|
|
92
|
+
this.app.project.get('resolve'),
|
|
93
|
+
this.app.project.get('dependencies'),
|
|
94
|
+
],
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
this.app.error('error hashing file contents for cache');
|
|
99
|
+
throw new Error(e);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
104
|
(0, tslib_1.__decorate)([
|
|
92
|
-
|
|
93
|
-
],
|
|
94
|
-
(0, tslib_1.__decorate)([
|
|
95
|
-
bud_support_1.bind
|
|
96
|
-
], default_1.prototype, "version", null);
|
|
97
|
-
(0, tslib_1.__decorate)([
|
|
98
|
-
bud_support_1.bind
|
|
99
|
-
], default_1.prototype, "directory", null);
|
|
100
|
-
(0, tslib_1.__decorate)([
|
|
101
|
-
bud_support_1.bind
|
|
102
|
-
], default_1.prototype, "buildDependencies", null);
|
|
105
|
+
helpful_decorators_1.bind
|
|
106
|
+
], Cache.prototype, "boot", null);
|
|
103
107
|
(0, tslib_1.__decorate)([
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
exports.
|
|
108
|
+
helpful_decorators_1.bind
|
|
109
|
+
], Cache.prototype, "hashFileContents", null);
|
|
110
|
+
exports.Cache = Cache;
|
|
107
111
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Cache/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Cache/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAuC;AACvC,mCAAkC;AAElC,6DAAoD;AAEpD;;;;GAIG;AACH,MAAa,KACX,SAAQ,wBAAG,CAAC,KAAK,CAAC,QAAQ;IAG1B;;;;OAIG;IACH,IAAW,OAAO;QAChB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE;YAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBACf,OAAO,EAAE,SAAS;gBAClB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;aAC9C,CAAC,CAAA;YAEF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;SAC7C;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YAC7C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBACf,OAAO,EAAE,WAAW;gBACpB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC;aAC7C,CAAC,CAAA;YAEF,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;SAC5C;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;OAIG;IACH,IAAW,IAAI;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;Q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BACb,MAAM,EAAE;wBACN,IAAI,CAAC,GAAG,CAAC,IAAI;wBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;wBACxC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;wBACxC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;wBAChC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;wBAC/B,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;wBAC/B,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;qBACrC;iBACF,CAAC,CACH,CAAA;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA;gBACvD,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAA;aACnB;QACH,CAAC;KAAA;CACF;AAtCC;IADC,yBAAI;iCAMJ;AAMD;IADC,yBAAI;6CA2BJ;AApHH,sBAqHC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
// Licensed under the MIT license.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.Cache = void 0;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
/**
|
|
8
7
|
* The {@link @roots/bud-cache#} package implements the {@link @roots/bud-framework#Cache | Cache interface}
|
|
9
8
|
*
|
|
10
9
|
* @see https://roots.io/bud
|
|
11
10
|
* @see https://github.com/roots/bud
|
|
12
11
|
*
|
|
13
|
-
* @
|
|
12
|
+
* @packageDocumentation @betaDocumentation
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
exports
|
|
14
|
+
var Cache_1 = require("./Cache");
|
|
15
|
+
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return Cache_1.Cache; } });
|
|
17
16
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC;;;;;;;GAOG;AAEH,iCAA6B;AAArB,8FAAA,KAAK,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as Bud from '@roots/bud-framework';
|
|
2
|
+
export { bind, globby } from '@roots/bud-support';
|
|
3
|
+
export { createHash } from 'crypto';
|
|
4
|
+
import { fs } from '@roots/bud-support';
|
|
5
|
+
export const { ensureFile, readFile, readJson, remove, writeJson, writeFile, } = fs;
|
|
6
|
+
//# sourceMappingURL=cache.dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.dependencies.js","sourceRoot":"","sources":["../../../src/Cache/cache.dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAA;AACrC,MAAM,CAAC,MAAM,EACX,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,GACV,GAAG,EAAE,CAAA"}
|
package/lib/esm/Cache/index.js
CHANGED
|
@@ -1,104 +1,107 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { createHash } from '
|
|
5
|
-
const { readFileSync } = fs;
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { bind } from 'helpful-decorators';
|
|
3
|
+
import { isUndefined } from 'lodash';
|
|
4
|
+
import { Bud, createHash } from './cache.dependencies';
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* Interfaces with:
|
|
11
|
-
* - {@link @roots/bud-framework#Project} to determine project dependencies for snapshotting/validation.
|
|
12
|
-
* - {@link @roots/bud-framework#Build} via {@link @roots/bud-framework#Hooks} to update config.
|
|
13
|
-
*
|
|
14
|
-
* Facades:
|
|
15
|
-
* - {@link @roots/bud-framework#Api} can toggle cache settings with {@link Bud.Persist}
|
|
6
|
+
* Cache service class
|
|
16
7
|
*
|
|
17
8
|
* @public
|
|
18
9
|
*/
|
|
19
|
-
export
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
/**
|
|
23
|
-
* {@inheritDoc}
|
|
24
|
-
*/
|
|
25
|
-
this.name = 'cache';
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* {@inheritDoc}
|
|
29
|
-
*
|
|
30
|
-
* @decorator `@bind`
|
|
31
|
-
*/
|
|
32
|
-
register(app) {
|
|
33
|
-
app.hooks
|
|
34
|
-
.on('build/cache', () => ({
|
|
35
|
-
type: app.hooks.filter('build/cache/type'),
|
|
36
|
-
}))
|
|
37
|
-
.hooks.on('build/cache/type', () => 'memory');
|
|
38
|
-
}
|
|
10
|
+
export class Cache extends Bud.Cache.Abstract {
|
|
39
11
|
/**
|
|
40
|
-
*
|
|
12
|
+
* True if cache is enabled
|
|
41
13
|
*
|
|
42
|
-
* @
|
|
14
|
+
* @public
|
|
43
15
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
get enabled() {
|
|
17
|
+
if (this.app.store.is('cli.flags.cache', true)) {
|
|
18
|
+
this.log('info', {
|
|
19
|
+
message: '--cache',
|
|
20
|
+
suffix: this.app.store.get('cli.flags.cache'),
|
|
21
|
+
});
|
|
22
|
+
return this.app.store.get('cli.flags.cache');
|
|
23
|
+
}
|
|
24
|
+
if (this.app.store.is('features.cache', true)) {
|
|
25
|
+
this.log('info', {
|
|
26
|
+
message: 'bud.store',
|
|
27
|
+
suffix: this.app.store.get('features.cache'),
|
|
28
|
+
});
|
|
29
|
+
return this.app.store.get('features.cache');
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
50
32
|
}
|
|
51
33
|
/**
|
|
52
|
-
*
|
|
34
|
+
* Type
|
|
53
35
|
*
|
|
54
|
-
* @
|
|
36
|
+
* @public
|
|
55
37
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
get type() {
|
|
39
|
+
const flags = this.app.store.get('cli.flags');
|
|
40
|
+
const cache = this.app.store.get('cache');
|
|
41
|
+
if (!isUndefined(flags['cache.type'])) {
|
|
42
|
+
this.log('info', {
|
|
43
|
+
message: '--cache.type flag',
|
|
44
|
+
suffix: flags['cache.type'],
|
|
45
|
+
});
|
|
46
|
+
return flags['cache.type'];
|
|
47
|
+
}
|
|
48
|
+
if (!isUndefined(cache.type)) {
|
|
49
|
+
this.log('info', {
|
|
50
|
+
message: 'bud.store',
|
|
51
|
+
suffix: cache.type,
|
|
52
|
+
});
|
|
53
|
+
return cache.type;
|
|
54
|
+
}
|
|
55
|
+
this.log('warn', 'no cache setting was passed from cli flags or from settings');
|
|
56
|
+
return false;
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @remarks
|
|
63
|
-
* @see https://webpack.js.org/configuration/cache/#cachebuilddependencies
|
|
64
|
-
*
|
|
65
|
-
* @decorator `@bind`
|
|
59
|
+
* @public
|
|
66
60
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.app.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...((_g = (_c = (_b = (_a = this.app.project) === null || _a === void 0 ? void 0 : _a.resolveFrom) === null || _b === void 0 ? void 0 : _b.map(dep => `${dep}/lib/cjs/index.js`)) !== null && _c !== void 0 ? _c : (_f = (_e = (_d = this.app.parent) === null || _d === void 0 ? void 0 : _d.project) === null || _e === void 0 ? void 0 : _e.resolveFrom) === null || _f === void 0 ? void 0 : _f.map(dep => `${dep}/lib/cjs/index.js`)) !== null && _g !== void 0 ? _g : []),
|
|
75
|
-
this.app.path('storage', 'cache/*'),
|
|
76
|
-
])),
|
|
77
|
-
];
|
|
61
|
+
boot() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
this.version = yield this.hashFileContents();
|
|
64
|
+
if (this.enabled) {
|
|
65
|
+
this.app.persist(this.type);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
78
68
|
}
|
|
79
69
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @decorator `@bind`
|
|
70
|
+
* @public
|
|
83
71
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
hashFileContents() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const hash = (str) => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return createHash('sha1')
|
|
76
|
+
.update(str)
|
|
77
|
+
.digest('base64')
|
|
78
|
+
.replace(/[^a-z0-9]/gi, '_')
|
|
79
|
+
.toLowerCase();
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
return yield hash(JSON.stringify({
|
|
83
|
+
checks: [
|
|
84
|
+
this.app.mode,
|
|
85
|
+
this.app.store.get('cli.flags.features'),
|
|
86
|
+
this.app.store.get('cli.flags.location'),
|
|
87
|
+
this.app.project.get('manifest'),
|
|
88
|
+
this.app.project.get('configs'),
|
|
89
|
+
this.app.project.get('resolve'),
|
|
90
|
+
this.app.project.get('dependencies'),
|
|
91
|
+
],
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
this.app.error('error hashing file contents for cache');
|
|
96
|
+
throw new Error(e);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
__decorate([
|
|
90
102
|
bind
|
|
91
|
-
],
|
|
92
|
-
__decorate([
|
|
93
|
-
bind
|
|
94
|
-
], default_1.prototype, "version", null);
|
|
95
|
-
__decorate([
|
|
96
|
-
bind
|
|
97
|
-
], default_1.prototype, "directory", null);
|
|
98
|
-
__decorate([
|
|
99
|
-
bind
|
|
100
|
-
], default_1.prototype, "buildDependencies", null);
|
|
103
|
+
], Cache.prototype, "boot", null);
|
|
101
104
|
__decorate([
|
|
102
105
|
bind
|
|
103
|
-
],
|
|
106
|
+
], Cache.prototype, "hashFileContents", null);
|
|
104
107
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Cache/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Cache/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAC,GAAG,EAAE,UAAU,EAAC,MAAM,sBAAsB,CAAA;AAEpD;;;;GAIG;AACH,MAAM,OAAO,KACX,SAAQ,GAAG,CAAC,KAAK,CAAC,QAAQ;IAG1B;;;;OAIG;IACH,IAAW,OAAO;QAChB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE;YAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBACf,OAAO,EAAE,SAAS;gBAClB,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,C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AC,CAAA;aACnB;QACH,CAAC;KAAA;CACF;AAtCC;IADC,IAAI;iCAMJ;AAMD;IADC,IAAI;6CA2BJ"}
|
package/lib/esm/index.js
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @see https://roots.io/bud
|
|
7
7
|
* @see https://github.com/roots/bud
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
9
|
+
* @packageDocumentation @betaDocumentation
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
export { Cache };
|
|
11
|
+
export { Cache } from './Cache';
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,kCAAkC;AAElC;;;;;;;GAOG;AAEH,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA"}
|