@teambit/cache 0.0.470 → 0.0.474
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/dist/cache.main.runtime.d.ts +15 -1
- package/package.json +21 -6
- package/tsconfig.json +1 -2
- package/cache.aspect.ts +0 -7
- package/cache.main.runtime.ts +0 -66
- package/cache.spec.ts +0 -33
- package/index.ts +0 -2
- package/package-tar/teambit-cache-0.0.470.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
@@ -3,10 +3,24 @@ export declare type CacheConfig = {
|
|
3
3
|
cacheDirectory: string;
|
4
4
|
};
|
5
5
|
export declare class CacheMain {
|
6
|
+
/**
|
7
|
+
* extension config
|
8
|
+
*/
|
6
9
|
readonly config: CacheConfig;
|
10
|
+
/**
|
11
|
+
* logger extension.
|
12
|
+
*/
|
7
13
|
private readonly logger;
|
8
14
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
9
|
-
constructor(
|
15
|
+
constructor(
|
16
|
+
/**
|
17
|
+
* extension config
|
18
|
+
*/
|
19
|
+
config: CacheConfig,
|
20
|
+
/**
|
21
|
+
* logger extension.
|
22
|
+
*/
|
23
|
+
logger: Logger);
|
10
24
|
static dependencies: import("@teambit/harmony").Aspect[];
|
11
25
|
static defaultConfig: {
|
12
26
|
cacheDirectory: string;
|
package/package.json
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/cache",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.474",
|
4
4
|
"homepage": "https://bit.dev/teambit/harmony/cache",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.harmony",
|
8
8
|
"name": "cache",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.474"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"@teambit/harmony": "0.2.11",
|
13
13
|
"cacache": "15.0.5",
|
14
14
|
"@babel/runtime": "7.12.18",
|
15
15
|
"core-js": "^3.0.0",
|
16
|
-
"@teambit/cli": "0.0.
|
17
|
-
"@teambit/logger": "0.0.
|
16
|
+
"@teambit/cli": "0.0.389",
|
17
|
+
"@teambit/logger": "0.0.474"
|
18
18
|
},
|
19
19
|
"devDependencies": {
|
20
20
|
"@types/cacache": "12.0.1",
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"@types/node": "12.20.4"
|
31
31
|
},
|
32
32
|
"peerDependencies": {
|
33
|
-
"@teambit/legacy": "1.0.
|
33
|
+
"@teambit/legacy": "1.0.175",
|
34
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
35
35
|
"react": "^16.8.0 || ^17.0.0"
|
36
36
|
},
|
@@ -58,12 +58,27 @@
|
|
58
58
|
"react": "-"
|
59
59
|
},
|
60
60
|
"peerDependencies": {
|
61
|
-
"@teambit/legacy": "1.0.
|
61
|
+
"@teambit/legacy": "1.0.175",
|
62
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
63
63
|
"react": "^16.8.0 || ^17.0.0"
|
64
64
|
}
|
65
65
|
}
|
66
66
|
},
|
67
|
+
"files": [
|
68
|
+
"dist",
|
69
|
+
"!dist/tsconfig.tsbuildinfo",
|
70
|
+
"**/*.md",
|
71
|
+
"**/*.mdx",
|
72
|
+
"**/*.js",
|
73
|
+
"**/*.json",
|
74
|
+
"**/*.sass",
|
75
|
+
"**/*.scss",
|
76
|
+
"**/*.less",
|
77
|
+
"**/*.css",
|
78
|
+
"**/*.css",
|
79
|
+
"**/*.jpeg",
|
80
|
+
"**/*.gif"
|
81
|
+
],
|
67
82
|
"private": false,
|
68
83
|
"engines": {
|
69
84
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
"skipLibCheck": true,
|
16
16
|
"moduleResolution": "node",
|
17
17
|
"esModuleInterop": true,
|
18
|
-
"outDir": "dist",
|
19
18
|
"composite": true,
|
20
19
|
"emitDeclarationOnly": true,
|
20
|
+
"outDir": "dist",
|
21
21
|
"experimentalDecorators": true,
|
22
22
|
"emitDecoratorMetadata": true,
|
23
23
|
"allowSyntheticDefaultImports": true,
|
@@ -25,7 +25,6 @@
|
|
25
25
|
"strict": true,
|
26
26
|
"noImplicitAny": false,
|
27
27
|
"rootDir": ".",
|
28
|
-
"removeComments": true,
|
29
28
|
"preserveConstEnums": true,
|
30
29
|
"resolveJsonModule": true
|
31
30
|
},
|
package/cache.aspect.ts
DELETED
package/cache.main.runtime.ts
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
import { MainRuntime } from '@teambit/cli';
|
2
|
-
import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
|
3
|
-
import { CACHE_ROOT } from '@teambit/legacy/dist/constants';
|
4
|
-
import cacache from 'cacache';
|
5
|
-
|
6
|
-
import { CacheAspect } from './cache.aspect';
|
7
|
-
|
8
|
-
export type CacheConfig = {
|
9
|
-
cacheDirectory: string;
|
10
|
-
};
|
11
|
-
|
12
|
-
export class CacheMain {
|
13
|
-
static runtime = MainRuntime;
|
14
|
-
|
15
|
-
constructor(
|
16
|
-
/**
|
17
|
-
* extension config
|
18
|
-
*/
|
19
|
-
readonly config: CacheConfig,
|
20
|
-
|
21
|
-
/**
|
22
|
-
* logger extension.
|
23
|
-
*/
|
24
|
-
private readonly logger: Logger
|
25
|
-
) {}
|
26
|
-
|
27
|
-
static dependencies = [LoggerAspect];
|
28
|
-
|
29
|
-
static defaultConfig = {
|
30
|
-
cacheDirectory: CACHE_ROOT,
|
31
|
-
};
|
32
|
-
|
33
|
-
async set(key: string, data: any, ttl?: number): Promise<boolean> {
|
34
|
-
this.logger.debug(`put cache to ${key} with data ${data}`);
|
35
|
-
const expire = ttl ? new Date().getTime() + ttl : null;
|
36
|
-
return cacache
|
37
|
-
.put(this.globalCacheFolder, key, JSON.stringify({ data, expire }))
|
38
|
-
.then(() => true)
|
39
|
-
.catch(() => false);
|
40
|
-
}
|
41
|
-
|
42
|
-
async get<T>(key: string): Promise<T | undefined> {
|
43
|
-
this.logger.debug(`get cache for ${key}`);
|
44
|
-
return cacache
|
45
|
-
.get(this.globalCacheFolder, key)
|
46
|
-
.then(async (cacheObject) => {
|
47
|
-
const { data, expire } = JSON.parse(cacheObject.data.toString());
|
48
|
-
if (expire && new Date().getTime() > expire) {
|
49
|
-
return cacache.rm(this.globalCacheFolder, key);
|
50
|
-
}
|
51
|
-
return data;
|
52
|
-
})
|
53
|
-
.catch(() => undefined);
|
54
|
-
}
|
55
|
-
|
56
|
-
private get globalCacheFolder() {
|
57
|
-
return this.config.cacheDirectory;
|
58
|
-
}
|
59
|
-
|
60
|
-
static async provider([loggerFactory]: [LoggerMain], config: CacheConfig) {
|
61
|
-
const logger = loggerFactory.createLogger(CacheAspect.id);
|
62
|
-
return new CacheMain(config, logger);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
CacheAspect.addRuntime(CacheMain);
|
package/cache.spec.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import v4 from 'uuid';
|
2
|
-
import { rmdirSync } from 'fs';
|
3
|
-
import { expect } from 'chai';
|
4
|
-
import { Logger } from '@teambit/logger';
|
5
|
-
import { CacheMain } from './cache.main.runtime';
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
describe('Cache Aspect', () => {
|
10
|
-
const cacheDirectory = `/tmp/bit/${v4()}`;
|
11
|
-
const cache = new CacheMain({ cacheDirectory }, new Logger('cache.main.runtime'));
|
12
|
-
it('it should set cache with ttl', async () => {
|
13
|
-
await cache.set('_foo', 'bar', 1000);
|
14
|
-
const data = await cache.get('_foo');
|
15
|
-
expect(data).to.equal('bar');
|
16
|
-
});
|
17
|
-
|
18
|
-
it('it should expire cache', async () => {
|
19
|
-
await cache.set('_foo', 'bar', 1);
|
20
|
-
const data = await cache.get('_foo');
|
21
|
-
expect(data).to.equal(null);
|
22
|
-
});
|
23
|
-
|
24
|
-
it('it should set cache without expire ttl', async () => {
|
25
|
-
await cache.set('_foo', 'bar');
|
26
|
-
const data = await cache.get('_foo');
|
27
|
-
expect(data).to.equal('bar');
|
28
|
-
});
|
29
|
-
|
30
|
-
afterAll(() => {
|
31
|
-
rmdirSync(cacheDirectory, { recursive: true });
|
32
|
-
});
|
33
|
-
});
|
package/index.ts
DELETED
Binary file
|
package/types/asset.d.ts
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
declare module '*.png' {
|
2
|
-
const value: any;
|
3
|
-
export = value;
|
4
|
-
}
|
5
|
-
declare module '*.svg' {
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
7
|
-
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
9
|
-
const src: string;
|
10
|
-
export default src;
|
11
|
-
}
|
12
|
-
|
13
|
-
// @TODO Gilad
|
14
|
-
declare module '*.jpg' {
|
15
|
-
const value: any;
|
16
|
-
export = value;
|
17
|
-
}
|
18
|
-
declare module '*.jpeg' {
|
19
|
-
const value: any;
|
20
|
-
export = value;
|
21
|
-
}
|
22
|
-
declare module '*.gif' {
|
23
|
-
const value: any;
|
24
|
-
export = value;
|
25
|
-
}
|
26
|
-
declare module '*.bmp' {
|
27
|
-
const value: any;
|
28
|
-
export = value;
|
29
|
-
}
|
package/types/style.d.ts
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
declare module '*.module.css' {
|
2
|
-
const classes: { readonly [key: string]: string };
|
3
|
-
export default classes;
|
4
|
-
}
|
5
|
-
declare module '*.module.scss' {
|
6
|
-
const classes: { readonly [key: string]: string };
|
7
|
-
export default classes;
|
8
|
-
}
|
9
|
-
declare module '*.module.sass' {
|
10
|
-
const classes: { readonly [key: string]: string };
|
11
|
-
export default classes;
|
12
|
-
}
|
13
|
-
|
14
|
-
declare module '*.module.less' {
|
15
|
-
const classes: { readonly [key: string]: string };
|
16
|
-
export default classes;
|
17
|
-
}
|
18
|
-
|
19
|
-
declare module '*.less' {
|
20
|
-
const classes: { readonly [key: string]: string };
|
21
|
-
export default classes;
|
22
|
-
}
|
23
|
-
|
24
|
-
declare module '*.css' {
|
25
|
-
const classes: { readonly [key: string]: string };
|
26
|
-
export default classes;
|
27
|
-
}
|
28
|
-
|
29
|
-
declare module '*.sass' {
|
30
|
-
const classes: { readonly [key: string]: string };
|
31
|
-
export default classes;
|
32
|
-
}
|
33
|
-
|
34
|
-
declare module '*.scss' {
|
35
|
-
const classes: { readonly [key: string]: string };
|
36
|
-
export default classes;
|
37
|
-
}
|
38
|
-
|
39
|
-
declare module '*.mdx' {
|
40
|
-
const component: any;
|
41
|
-
export default component;
|
42
|
-
}
|