Skip to content

Commit 77bc354

Browse files
committed
Release version v1.0.3
2 parents b1adabd + 2cc068a commit 77bc354

File tree

9 files changed

+946
-1721
lines changed

9 files changed

+946
-1721
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,39 @@ npm install @cloudstek/cache
3434

3535
## Development
3636

37-
Clone this repository to get started.
37+
Clone this repository to get started. You can replace `yarn` in the commands below with `npm` if you use NPM.
38+
39+
### Build code and watch for changes
40+
41+
During development you can build the code once and have typescript watch for changes and recompile automatically.
42+
43+
```sh
44+
yarn run watch
45+
```
3846

3947
### Checking code for style
4048

4149
To check the code for style correctness run:
4250

4351
```sh
44-
yarn lint
52+
yarn run lint
4553
```
4654

4755
### Running tests
4856

4957
Tests are run using [Ava](https://github.com/avajs/ava) and coverage is generated using [Istanbul](https://istanbul.js.org/). To run the tests run:
5058

5159
```sh
52-
yarn test
60+
yarn run build
61+
yarn run test
5362
```
5463

5564
### Building the code for release
5665

5766
To build the code for release (e.g. npm publish), run:
5867

5968
```sh
60-
yarn run clean
61-
yarn build
69+
yarn run build:dist
6270
```
6371

6472
## Also check out

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudstek/cache",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Simple key/value (cache) store.",
55
"author": "Maarten de Boer <maarten@cloudstek.nl>",
66
"license": "MIT",
@@ -14,12 +14,12 @@
1414
"moment": "^2.24.0"
1515
},
1616
"devDependencies": {
17-
"@types/fs-extra": "^7.0.0",
17+
"@types/fs-extra": "^8.0.0",
1818
"@types/mockdate": "^2.0.0",
1919
"@types/node": "^12.0.2",
20-
"ava": "^1.4.1",
20+
"ava": "^2.2.0",
2121
"coveralls": "^3.0.3",
22-
"del-cli": "^1.1.0",
22+
"del-cli": "^2.0.0",
2323
"mockdate": "^2.0.2",
2424
"npm-run-all": "^4.1.5",
2525
"nyc": "^14.1.1",
@@ -35,13 +35,12 @@
3535
"clean:dist": "del-cli dist",
3636
"clean:test": "del-cli build",
3737
"clean:coverage": "del-cli coverage .nyc_output",
38-
"build": "tsc",
39-
"build:test": "tsc --outDir build --declaration false --sourceMap true",
40-
"build:dist": "npm-run-all -s clean build",
41-
"test": "npm-run-all clean:test clean:coverage build:test test:run clean:test",
42-
"test:run": "nyc ava",
43-
"test:ci": "npm-run-all -p clean:* -s build:test && nyc -s ava && nyc report --reporter=text-lcov | coveralls",
44-
"lint": "npm-run-all -l -p lint:src lint:test",
38+
"build": "npm-run-all -p clean:test clean:coverage && tsc",
39+
"watch": "npm-run-all -p clean:test clean:coverage && tsc --watch",
40+
"build:dist": "npm-run-all -s clean:dist && tsc -p tsconfig.dist.json",
41+
"test": "npm-run-all -s clean:coverage && nyc ava",
42+
"test:ci": "npm-run-all -p clean:* -s build && nyc -s ava && nyc report --reporter=text-lcov | coveralls",
43+
"lint": "npm-run-all -l -p lint:*",
4544
"lint:src": "tslint src/**/*.ts",
4645
"lint:test": "tslint test/**/*.ts"
4746
},

test/expiration.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test.before((t) => {
1919
test.beforeEach((t) => {
2020
const dir = util.randomString();
2121

22-
MockDate.set(moment.utc("2019-01-01T14:00:00").valueOf());
22+
MockDate.set(moment.utc("2019-01-01T14:00:00").toDate());
2323

2424
t.context.dirs.push(dir);
2525
t.context.options = {
@@ -46,7 +46,7 @@ test("check expiration on new item", (t) => {
4646

4747
t.is(c.keys.length, 3);
4848

49-
MockDate.set(moment().add(30, "minutes"));
49+
MockDate.set(moment().add(30, "minutes").toDate());
5050

5151
t.true(c.has("apple"));
5252
t.true(c.has("strawberry"));
@@ -58,7 +58,7 @@ test("check expiration on new item", (t) => {
5858

5959
t.is(c.keys.length, 3);
6060

61-
MockDate.set(moment().add(1, "hour"));
61+
MockDate.set(moment().add(1, "hour").toDate());
6262

6363
t.true(c.has("apple"));
6464
t.false(c.has("strawberry"));
@@ -70,7 +70,7 @@ test("check expiration on new item", (t) => {
7070

7171
t.is(c.keys.length, 1);
7272

73-
MockDate.set(moment().add(2, "hours"));
73+
MockDate.set(moment().add(2, "hours").toDate());
7474

7575
t.false(c.has("apple"));
7676
t.is(c.get("foo"), undefined);
@@ -106,7 +106,7 @@ test("check expiration on new item with autocommit", (t) => {
106106
t.true(util.pathExists(t.context.options.dir, "cache.json"));
107107
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
108108

109-
MockDate.set(moment().add(30, "minutes"));
109+
MockDate.set(moment().add(30, "minutes").toDate());
110110

111111
t.true(c.has("apple"));
112112
t.true(c.has("strawberry"));
@@ -119,7 +119,7 @@ test("check expiration on new item with autocommit", (t) => {
119119
t.is(c.keys.length, 3);
120120
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
121121

122-
MockDate.set(moment().add(1, "hour"));
122+
MockDate.set(moment().add(1, "hour").toDate());
123123

124124
t.true(c.has("apple"));
125125
t.false(c.has("strawberry"));
@@ -132,7 +132,7 @@ test("check expiration on new item with autocommit", (t) => {
132132
t.is(c.keys.length, 1);
133133
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
134134

135-
MockDate.set(moment().add(2, "hours"));
135+
MockDate.set(moment().add(2, "hours").toDate());
136136

137137
t.false(c.has("apple"));
138138
t.is(c.get("foo"), undefined);
@@ -175,7 +175,7 @@ test("check expiration on init", (t) => {
175175
// Contents of file should not have changed with autoCommit disabled
176176
t.deepEqual(fs.readJsonSync(path.join(t.context.options.dir, "cache.json")), contents);
177177

178-
MockDate.set(moment().add(30, "minutes"));
178+
MockDate.set(moment().add(30, "minutes").toDate());
179179

180180
t.true(c.has("apple"));
181181
t.true(c.has("strawberry"));
@@ -189,7 +189,7 @@ test("check expiration on init", (t) => {
189189
// Contents of file should not have changed with autoCommit disabled
190190
t.deepEqual(fs.readJsonSync(path.join(t.context.options.dir, "cache.json")), contents);
191191

192-
MockDate.set(moment().add(1, "hour"));
192+
MockDate.set(moment().add(1, "hour").toDate());
193193

194194
t.true(c.has("apple"));
195195
t.false(c.has("strawberry"));
@@ -203,7 +203,7 @@ test("check expiration on init", (t) => {
203203
// Contents of file should not have changed with autoCommit disabled
204204
t.deepEqual(fs.readJsonSync(path.join(t.context.options.dir, "cache.json")), contents);
205205

206-
MockDate.set(moment().add(2, "hours"));
206+
MockDate.set(moment().add(2, "hours").toDate());
207207

208208
t.false(c.has("apple"));
209209
t.is(c.get("foo"), undefined);
@@ -250,7 +250,7 @@ test("check expiration on init with autocommit", (t) => {
250250
t.is(c.keys.length, 3);
251251
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
252252

253-
MockDate.set(moment().add(30, "minutes"));
253+
MockDate.set(moment().add(30, "minutes").toDate());
254254

255255
t.true(c.has("apple"));
256256
t.true(c.has("strawberry"));
@@ -263,7 +263,7 @@ test("check expiration on init with autocommit", (t) => {
263263
t.is(c.keys.length, 3);
264264
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
265265

266-
MockDate.set(moment().add(1, "hour"));
266+
MockDate.set(moment().add(1, "hour").toDate());
267267

268268
t.true(c.has("apple"));
269269
t.false(c.has("strawberry"));
@@ -276,7 +276,7 @@ test("check expiration on init with autocommit", (t) => {
276276
t.is(c.keys.length, 1);
277277
t.snapshot(fs.readFileSync(path.join(t.context.options.dir, "cache.json"), "utf8"));
278278

279-
MockDate.set(moment().add(2, "hours"));
279+
MockDate.set(moment().add(2, "hours").toDate());
280280

281281
t.false(c.has("apple"));
282282
t.is(c.get("foo"), undefined);
@@ -295,7 +295,7 @@ test("check never expiring item", (t) => {
295295
t.is(c.keys.length, 1);
296296
t.is(c.get("foo"), value);
297297

298-
MockDate.set(moment().add(1, "year"));
298+
MockDate.set(moment().add(1, "year").toDate());
299299

300300
t.true(c.has("foo"));
301301
t.is(c.keys.length, 1);

test/in-memory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test.before((t) => {
1515
});
1616

1717
test.beforeEach(() => {
18-
MockDate.set(moment.utc("2019-01-01T14:00:00").valueOf());
18+
MockDate.set(moment.utc("2019-01-01T14:00:00").toDate());
1919
});
2020

2121
// Undefined / null dir and name

test/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.before((t) => {
1717
});
1818

1919
test.beforeEach(() => {
20-
MockDate.set(moment.utc("2019-01-01T14:00:00").valueOf());
20+
MockDate.set(moment.utc("2019-01-01T14:00:00").toDate());
2121
});
2222

2323
// Defaults

test/iteration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.before((t) => {
1717
test.beforeEach((t) => {
1818
const dir = util.randomString();
1919

20-
MockDate.set(moment.utc("2019-01-01T14:00:00").valueOf());
20+
MockDate.set(moment.utc("2019-01-01T14:00:00").toDate());
2121

2222
t.context.dirs.push(dir);
2323
t.context.options = {
@@ -58,7 +58,7 @@ test("iterate over some expired items using all", (t) => {
5858

5959
t.snapshot(allBeforeExpiration);
6060

61-
MockDate.set(moment().add(1, "hour"));
61+
MockDate.set(moment().add(1, "hour").toDate());
6262

6363
const allAfterExpiration = c.all();
6464

@@ -110,7 +110,7 @@ test("iterate over some expired items using iterator", (t) => {
110110
t.deepEqual(itemsBeforeExpiration, c.all());
111111
t.snapshot(itemsBeforeExpiration);
112112

113-
MockDate.set(moment().add(1, "hour"));
113+
MockDate.set(moment().add(1, "hour").toDate());
114114

115115
t.is(c.keys.length, 2);
116116
t.is(c.length, c.keys.length);

tsconfig.dist.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "dist",
6+
},
7+
"include": [
8+
"src/**/*"
9+
],
10+
"exclude": [
11+
"test/**/*"
12+
]
13+
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"noImplicitAny": true,
88
"declaration": true,
99
"declarationMap": false,
10-
"sourceMap": false,
10+
"sourceMap": true,
1111
"esModuleInterop": true,
12-
"outDir": "dist",
12+
"outDir": "build",
1313
},
1414
"include": [
1515
"src/**/*",

0 commit comments

Comments
 (0)