@teambit/clear-cache 0.0.396 → 0.0.397
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/artifacts/preview/teambit_workspace_clear_cache-preview.js +1 -0
- package/dist/{preview-1703647408454.js → preview-1703698405864.js} +2 -2
- package/package.json +3 -3
- package/clear-cache-cmd.ts +0 -46
- package/clear-cache.aspect.ts +0 -5
- package/clear-cache.main.runtime.ts +0 -42
- package/index.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.workspace/clear-cache-preview"]=t():e["teambit.workspace/clear-cache-preview"]=t()}(self,(()=>(()=>{"use strict";var e={3287:(e,t,o)=>{var r={id:"teambit.workspace/clear-cache@0.0.397",homepage:"https://bit.cloud/teambit/workspace/clear-cache",exported:!0};function n(){const e=c(o(87363));return n=function(){return e},e}function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,n.__bit_component=r,c.__bit_component=r;const i=()=>n().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},n().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/clean-cache.svg"}));i.__bit_component=r,t.Logo=i},87363:e=>{e.exports=React}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var c=t[r]={exports:{}};return e[r](c,c.exports,o),c.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{compositions:()=>d,compositions_metadata:()=>f,overview:()=>u});var e={};o.r(e),o.d(e,{default:()=>l});var t=o(3287);o(87363);const n=MdxJsReact,c=TeambitMdxUiMdxScopeContext;var i=["components"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},a.apply(this,arguments)}var p={},s="wrapper";function l(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},c=Object.keys(e);for(r=0;r<c.length;r++)o=c[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)o=c[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,i);return(0,n.mdx)(s,a({},p,o,{components:t,mdxType:"MDXLayout"}),(0,n.mdx)(c.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}l.isMDXComponent=!0;const d=[t],u=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.397/dist/clear-cache.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_clear-cache@0.0.397/dist/clear-cache.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/clear-cache",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.397",
|
|
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.
|
|
9
|
+
"version": "0.0.397"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@types/mocha": "9.1.0",
|
|
17
17
|
"@types/jest": "^29.2.2",
|
|
18
18
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
19
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
|
19
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.14"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": "^17.0.0 || ^18.0.0",
|
package/clear-cache-cmd.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
package/clear-cache.aspect.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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);
|