@teambit/clear-cache 0.0.395 → 0.0.396

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.
@@ -0,0 +1,46 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import chalk from 'chalk';
3
+ import { ClearCacheMain } from './clear-cache.main.runtime';
4
+
5
+ export default class ClearCacheCmd implements Command {
6
+ name = 'clear-cache';
7
+ description = "clears Bit's cache from current working machine";
8
+ group = 'general';
9
+ extendedDescription: string;
10
+ alias = 'cc';
11
+ options = [['r', 'remote <remote-name>', 'clear memory cache from a remote scope']] as CommandOptions;
12
+ loader = false;
13
+ skipWorkspace = true;
14
+ helpUrl = 'reference/workspace/clearing-cache';
15
+
16
+ constructor(private clearCache: ClearCacheMain) {
17
+ this.extendedDescription = `The following gets removed by this command:
18
+ 1) V8 compiled code (generated the first time Bit is loaded by v8-compile-cache package)
19
+ 2) components cache on the filesystem (mainly the dependencies graph and docs)
20
+ 3) scope's index file, which maps the component-id:object-hash`;
21
+ }
22
+
23
+ async report(arg, { remote }: { remote?: string }): Promise<string> {
24
+ if (remote) {
25
+ const success = await this.clearCache.clearRemoteCache(remote);
26
+ if (success) {
27
+ return chalk.green(`successfully cleaned the cache of "${remote}"`);
28
+ }
29
+ return chalk.red(`failed cleaning the cache of "${remote}"`);
30
+ }
31
+ const { succeed, failed } = await this.clearCache.clearCache();
32
+ const getSuccessOutput = () => {
33
+ if (!succeed.length) return '';
34
+ const title = 'the following cache(s) have been cleared:';
35
+ const output = succeed.map((str) => ` ✔ ${str}`).join('\n');
36
+ return chalk.green(`${chalk.bold(title)}\n${output}`);
37
+ };
38
+ const getFailedOutput = () => {
39
+ if (!failed.length) return '';
40
+ const title = 'the following cache(s) failed to clear:';
41
+ const output = failed.map((str) => ` X ${str}`).join('\n');
42
+ return chalk.red(`${chalk.bold(title)}\n${output}`);
43
+ };
44
+ return `${getSuccessOutput()}\n${getFailedOutput()}`;
45
+ }
46
+ }
@@ -0,0 +1,5 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+
3
+ export const ClearCacheAspect = Aspect.create({
4
+ id: 'teambit.bit/clear-cache',
5
+ });
@@ -0,0 +1,42 @@
1
+ import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
2
+ import { clearCache, CacheClearResult } from '@teambit/legacy/dist/api/consumer/lib/clear-cache';
3
+ import getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';
4
+ import { loadConsumerIfExist, Consumer } from '@teambit/legacy/dist/consumer';
5
+ import ClearCacheCmd from './clear-cache-cmd';
6
+ import { ClearCacheAspect } from './clear-cache.aspect';
7
+
8
+ /**
9
+ * avoid adding `workspace` / `scope` aspects as dependencies to this aspect.
10
+ * the clear-cache command is often being used when the workspace/scope is not working properly.
11
+ */
12
+ export class ClearCacheMain {
13
+ async clearCache(): Promise<CacheClearResult> {
14
+ return clearCache();
15
+ }
16
+
17
+ async clearRemoteCache(remote: string) {
18
+ const maybeConsumer = await this.getConsumerGracefully();
19
+ const remoteObj = await getRemoteByName(remote, maybeConsumer);
20
+ const result = await remoteObj.action('ClearCacheAction', {});
21
+ return result;
22
+ }
23
+
24
+ private async getConsumerGracefully(): Promise<Consumer | undefined> {
25
+ try {
26
+ return await loadConsumerIfExist();
27
+ } catch (err: any) {
28
+ return undefined;
29
+ }
30
+ }
31
+
32
+ static slots = [];
33
+ static dependencies = [CLIAspect];
34
+ static runtime = MainRuntime;
35
+ static async provider([cli]: [CLIMain]) {
36
+ const clearCacheMain = new ClearCacheMain();
37
+ cli.register(new ClearCacheCmd(clearCacheMain));
38
+ return clearCacheMain;
39
+ }
40
+ }
41
+
42
+ ClearCacheAspect.addRuntime(ClearCacheMain);
@@ -1,2 +1,2 @@
1
- import React from 'react';
2
- export declare const Logo: () => React.JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const Logo: () => JSX.Element;
@@ -8,7 +8,7 @@ export declare class ClearCacheMain {
8
8
  clearCache(): Promise<CacheClearResult>;
9
9
  clearRemoteCache(remote: string): Promise<unknown>;
10
10
  private getConsumerGracefully;
11
- static slots: never[];
11
+ static slots: any[];
12
12
  static dependencies: import("@teambit/harmony").Aspect[];
13
13
  static runtime: import("@teambit/harmony").RuntimeDefinition;
14
14
  static provider([cli]: [CLIMain]): Promise<ClearCacheMain>;
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.395/dist/clear-cache.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.395/dist/clear-cache.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.396/dist/clear-cache.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.396/dist/clear-cache.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ClearCacheAspect } from './clear-cache.aspect';
2
+
3
+ export type { ClearCacheMain } from './clear-cache.main.runtime';
4
+ export default ClearCacheAspect;
5
+ export { ClearCacheAspect };
package/package.json CHANGED
@@ -1,31 +1,27 @@
1
1
  {
2
2
  "name": "@teambit/clear-cache",
3
- "version": "0.0.395",
3
+ "version": "0.0.396",
4
4
  "homepage": "https://bit.cloud/teambit/workspace/clear-cache",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "clear-cache",
9
- "version": "0.0.395"
9
+ "version": "0.0.396"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
- "core-js": "^3.0.0",
14
- "@babel/runtime": "7.20.0",
15
13
  "@teambit/harmony": "0.4.6"
16
14
  },
17
15
  "devDependencies": {
18
- "@types/react": "^17.0.8",
19
16
  "@types/mocha": "9.1.0",
20
- "@types/node": "12.20.4",
21
- "@types/react-dom": "^17.0.5",
22
- "@types/jest": "^26.0.0",
23
- "@types/testing-library__jest-dom": "5.9.5"
17
+ "@types/jest": "^29.2.2",
18
+ "@types/testing-library__jest-dom": "^5.9.5",
19
+ "@teambit/harmony.envs.core-aspect-env": "0.0.13"
24
20
  },
25
21
  "peerDependencies": {
26
- "@teambit/legacy": "1.0.624",
27
- "react": "^16.8.0 || ^17.0.0",
28
- "react-dom": "^16.8.0 || ^17.0.0"
22
+ "react": "^17.0.0 || ^18.0.0",
23
+ "@types/react": "^18.2.12",
24
+ "@teambit/legacy": "1.0.624"
29
25
  },
30
26
  "license": "Apache-2.0",
31
27
  "optionalDependencies": {},
@@ -39,7 +35,7 @@
39
35
  },
40
36
  "private": false,
41
37
  "engines": {
42
- "node": ">=12.22.0"
38
+ "node": ">=16.0.0"
43
39
  },
44
40
  "repository": {
45
41
  "type": "git",
@@ -48,12 +44,9 @@
48
44
  "keywords": [
49
45
  "bit",
50
46
  "bit-aspect",
47
+ "bit-core-aspect",
51
48
  "components",
52
49
  "collaboration",
53
- "web",
54
- "react",
55
- "react-components",
56
- "angular",
57
- "angular-components"
50
+ "web"
58
51
  ]
59
52
  }
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }