@roots/bud-cache 5.0.0-next.9 → 5.3.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/README.md +8 -28
- package/lib/cjs/Cache/cache.dependencies.js +22 -4
- package/lib/cjs/Cache/index.js +40 -58
- package/lib/cjs/index.js +1 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -24
- package/types/Cache/cache.dependencies.d.ts +2 -1
- package/types/Cache/cache.dependencies.d.ts.map +1 -1
- package/types/Cache/index.d.ts +2 -8
- package/types/Cache/index.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/lib/cjs/Cache/cache.dependencies.js.map +0 -1
- package/lib/cjs/Cache/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/esm/Cache/cache.dependencies.js +0 -6
- package/lib/esm/Cache/cache.dependencies.js.map +0 -1
- package/lib/esm/Cache/index.js +0 -103
- package/lib/esm/Cache/index.js.map +0 -1
- package/lib/esm/index.js +0 -12
- package/lib/esm/index.js.map +0 -1
- package/lib/tsconfig-esm.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img
|
|
2
|
+
<img src="https://cdn.roots.io/app/uploads/logo-bud.svg" height="100" alt="Bud" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<img
|
|
7
|
-
alt="MIT License"
|
|
8
|
-
src="https://img.shields.io/github/license/roots/bud?color=%23525ddc&style=flat-square"
|
|
9
|
-
/>
|
|
10
|
-
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Froots%2Fbud?ref=badge_small" alt="FOSSA Status">
|
|
11
|
-
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Froots%2Fbud.svg?type=small"/>
|
|
12
|
-
</a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/@roots/bud">
|
|
14
|
-
<img src="https://img.shields.io/npm/v/@roots/bud.svg?color=%23525ddc&style=flat-square" />
|
|
15
|
-
</a>
|
|
16
|
-
<a href="https://codecov.io/gh/roots/bud">
|
|
17
|
-
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD"/>
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://twitter.com/rootswp">
|
|
20
|
-
<img
|
|
21
|
-
alt="Follow Roots"
|
|
22
|
-
src="https://img.shields.io/twitter/follow/rootswp.svg?color=%23525ddc&style=flat-square"
|
|
23
|
-
/>
|
|
24
|
-
</a>
|
|
6
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/roots/bud?color=%23525ddc&style=flat-square" /> <img alt="npm" src="https://img.shields.io/npm/v/@roots/bud.svg?color=%23525ddc&style=flat-square" /> <img alt="Follow Roots" src="https://img.shields.io/twitter/follow/rootswp.svg?color=%23525ddc&style=flat-square" />
|
|
25
7
|
</p>
|
|
26
8
|
|
|
27
|
-
|
|
28
9
|
<h1 align="center">
|
|
29
10
|
<strong>@roots/bud-cache</strong>
|
|
30
11
|
</h1>
|
|
31
12
|
|
|
32
|
-
>
|
|
13
|
+
<p align="center">
|
|
14
|
+
Config caching
|
|
15
|
+
</p>
|
|
16
|
+
|
|
33
17
|
## Installation
|
|
34
18
|
|
|
35
19
|
Install **@roots/bud-cache** to your project.
|
|
36
20
|
|
|
37
21
|
```shell
|
|
38
|
-
yarn add @roots/bud-cache
|
|
22
|
+
yarn add @roots/bud-cache --dev
|
|
39
23
|
```
|
|
40
24
|
|
|
41
25
|
## Documentation
|
|
@@ -67,8 +51,4 @@ Help support our open-source development efforts by [becoming a patron](https://
|
|
|
67
51
|
<a href="https://carrot.com/"><img src="https://cdn.roots.io/app/uploads/carrot.svg" alt="Carrot" width="200" height="150"/></a>
|
|
68
52
|
<a href="https://www.c21redwood.com/"><img src="https://cdn.roots.io/app/uploads/c21redwood.svg" alt="C21 Redwood Realty" width="200" height="150"/></a>
|
|
69
53
|
<a href="https://wordpress.com/"><img src="https://cdn.roots.io/app/uploads/wordpress.svg" alt="WordPress.com" width="200" height="150"/></a>
|
|
70
|
-
<a href="https://
|
|
71
|
-
<a href="https://www.harnessup.com/"><img src="https://cdn.roots.io/app/uploads/harness-software.svg" alt="Harness Software" width="200" height="150"/></a>
|
|
72
|
-
<a href="https://www.codersclan.com/"><img src="https://cdn.roots.io/app/uploads/coders-clan.svg" alt="Coders Clan" width="200" height="150"/></a>
|
|
73
|
-
<a href="https://generodigital.com/"><img src="https://cdn.roots.io/app/uploads/genero.svg" alt="Genero" width="200" height="150"/></a>
|
|
74
|
-
<a href="https://motto.ca/roots"><img src="https://cdn.roots.io/app/uploads/motto.svg" alt="Motto" width="200" height="150"/></a>
|
|
54
|
+
<a href="https://pantheon.io/"><img src="https://cdn.roots.io/app/uploads/pantheon.svg" alt="Pantheon" width="200" height="150"/></a>
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
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 =
|
|
4
|
-
const
|
|
5
|
-
exports.Bud =
|
|
22
|
+
exports.Bud = exports.writeFile = exports.writeJson = exports.remove = exports.readJson = exports.readFile = exports.ensureFile = exports.createHash = exports.globby = exports.bind = void 0;
|
|
23
|
+
const Bud = __importStar(require("@roots/bud-framework"));
|
|
24
|
+
exports.Bud = Bud;
|
|
6
25
|
var bud_support_1 = require("@roots/bud-support");
|
|
7
26
|
Object.defineProperty(exports, "bind", { enumerable: true, get: function () { return bud_support_1.bind; } });
|
|
8
27
|
Object.defineProperty(exports, "globby", { enumerable: true, get: function () { return bud_support_1.globby; } });
|
|
@@ -10,4 +29,3 @@ var crypto_1 = require("crypto");
|
|
|
10
29
|
Object.defineProperty(exports, "createHash", { enumerable: true, get: function () { return crypto_1.createHash; } });
|
|
11
30
|
const bud_support_2 = require("@roots/bud-support");
|
|
12
31
|
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
|
package/lib/cjs/Cache/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.Cache = void 0;
|
|
4
|
-
const
|
|
10
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
11
|
const helpful_decorators_1 = require("helpful-decorators");
|
|
6
12
|
const lodash_1 = require("lodash");
|
|
7
13
|
const cache_dependencies_1 = require("./cache.dependencies");
|
|
@@ -11,28 +17,6 @@ const cache_dependencies_1 = require("./cache.dependencies");
|
|
|
11
17
|
* @public
|
|
12
18
|
*/
|
|
13
19
|
class Cache extends cache_dependencies_1.Bud.Cache.Abstract {
|
|
14
|
-
/**
|
|
15
|
-
* True if cache is enabled
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
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;
|
|
35
|
-
}
|
|
36
20
|
/**
|
|
37
21
|
* Type
|
|
38
22
|
*
|
|
@@ -42,14 +26,14 @@ class Cache extends cache_dependencies_1.Bud.Cache.Abstract {
|
|
|
42
26
|
const flags = this.app.store.get('cli.flags');
|
|
43
27
|
const cache = this.app.store.get('cache');
|
|
44
28
|
if (!(0, lodash_1.isUndefined)(flags['cache.type'])) {
|
|
45
|
-
this.log('
|
|
29
|
+
this.log('log', {
|
|
46
30
|
message: '--cache.type flag',
|
|
47
31
|
suffix: flags['cache.type'],
|
|
48
32
|
});
|
|
49
33
|
return flags['cache.type'];
|
|
50
34
|
}
|
|
51
35
|
if (!(0, lodash_1.isUndefined)(cache.type)) {
|
|
52
|
-
this.log('
|
|
36
|
+
this.log('log', {
|
|
53
37
|
message: 'bud.store',
|
|
54
38
|
suffix: cache.type,
|
|
55
39
|
});
|
|
@@ -61,47 +45,45 @@ class Cache extends cache_dependencies_1.Bud.Cache.Abstract {
|
|
|
61
45
|
/**
|
|
62
46
|
* @public
|
|
63
47
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
});
|
|
48
|
+
async boot() {
|
|
49
|
+
this.version = await this.hashFileContents();
|
|
50
|
+
if (this.app.store.get('features.cache')) {
|
|
51
|
+
this.app.api.call('persist', this.type);
|
|
52
|
+
}
|
|
71
53
|
}
|
|
72
54
|
/**
|
|
73
55
|
* @public
|
|
74
56
|
*/
|
|
75
|
-
hashFileContents(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
async hashFileContents() {
|
|
58
|
+
const makeHash = async (str) => (0, cache_dependencies_1.createHash)('sha1')
|
|
59
|
+
.update(str)
|
|
60
|
+
.digest('base64')
|
|
61
|
+
.replace(/[^a-z0-9]/gi, '_')
|
|
62
|
+
.toLowerCase();
|
|
63
|
+
try {
|
|
64
|
+
const paths = this.app.project.get('dependencies');
|
|
65
|
+
const strings = await Promise.all(paths.map(async (path) => (0, fs_extra_1.readFile)(path, 'utf8')));
|
|
66
|
+
const hash = await makeHash(`${strings}${JSON.stringify(this.app.project.get('cli'))}`);
|
|
67
|
+
this.log('info', {
|
|
68
|
+
message: 'cache hash generated',
|
|
69
|
+
suffix: hash,
|
|
70
|
+
});
|
|
71
|
+
this.app.hooks.async('event.project.write', async (project) => {
|
|
72
|
+
project.set('cache.hash', hash);
|
|
73
|
+
return project;
|
|
84
74
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return finalHash;
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
this.app.error('error hashing file contents for cache');
|
|
95
|
-
throw new Error(e);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
75
|
+
return hash;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
this.app.error('error hashing file contents for cache');
|
|
79
|
+
throw new Error(e);
|
|
80
|
+
}
|
|
98
81
|
}
|
|
99
82
|
}
|
|
100
|
-
|
|
83
|
+
__decorate([
|
|
101
84
|
helpful_decorators_1.bind
|
|
102
|
-
], Cache.prototype, "
|
|
103
|
-
|
|
85
|
+
], Cache.prototype, "boot", null);
|
|
86
|
+
__decorate([
|
|
104
87
|
helpful_decorators_1.bind
|
|
105
88
|
], Cache.prototype, "hashFileContents", null);
|
|
106
89
|
exports.Cache = Cache;
|
|
107
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js
CHANGED
|
@@ -9,8 +9,7 @@ exports.Cache = void 0;
|
|
|
9
9
|
* @see https://roots.io/bud
|
|
10
10
|
* @see https://github.com/roots/bud
|
|
11
11
|
*
|
|
12
|
-
* @packageDocumentation
|
|
12
|
+
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
14
|
var Cache_1 = require("./Cache");
|
|
15
15
|
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return Cache_1.Cache; } });
|
|
16
|
-
//# sourceMappingURL=index.js.map
|