@teambit/workspace-root 0.0.1
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/.npmignore +18 -0
- package/dist/clone.cmd.d.ts +27 -0
- package/dist/clone.cmd.js +67 -0
- package/dist/clone.cmd.js.map +1 -0
- package/dist/clone.d.ts +103 -0
- package/dist/clone.js +548 -0
- package/dist/clone.js.map +1 -0
- package/dist/clone.spec.d.ts +1 -0
- package/dist/clone.spec.js +419 -0
- package/dist/clone.spec.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1790106115091.js +7 -0
- package/dist/workspace-root-data.d.ts +42 -0
- package/dist/workspace-root-data.js +82 -0
- package/dist/workspace-root-data.js.map +1 -0
- package/dist/workspace-root-data.spec.d.ts +1 -0
- package/dist/workspace-root-data.spec.js +159 -0
- package/dist/workspace-root-data.spec.js.map +1 -0
- package/dist/workspace-root.aspect.d.ts +3 -0
- package/dist/workspace-root.aspect.js +19 -0
- package/dist/workspace-root.aspect.js.map +1 -0
- package/dist/workspace-root.docs.mdx +62 -0
- package/dist/workspace-root.fragment.d.ts +21 -0
- package/dist/workspace-root.fragment.js +36 -0
- package/dist/workspace-root.fragment.js.map +1 -0
- package/dist/workspace-root.main.runtime.d.ts +51 -0
- package/dist/workspace-root.main.runtime.js +176 -0
- package/dist/workspace-root.main.runtime.js.map +1 -0
- package/package.json +68 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +46 -0
- package/workspace-root.docs.mdx +62 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WorkspaceRootMain = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _cli() {
|
|
15
|
+
const data = require("@teambit/cli");
|
|
16
|
+
_cli = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _component() {
|
|
22
|
+
const data = require("@teambit/component");
|
|
23
|
+
_component = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _componentId() {
|
|
29
|
+
const data = require("@teambit/component-id");
|
|
30
|
+
_componentId = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _legacy() {
|
|
36
|
+
const data = require("@teambit/legacy.bit-map");
|
|
37
|
+
_legacy = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _workspace() {
|
|
43
|
+
const data = require("@teambit/workspace");
|
|
44
|
+
_workspace = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _clone() {
|
|
50
|
+
const data = require("./clone");
|
|
51
|
+
_clone = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
function _clone2() {
|
|
57
|
+
const data = require("./clone.cmd");
|
|
58
|
+
_clone2 = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
function _workspaceRoot() {
|
|
64
|
+
const data = require("./workspace-root.aspect");
|
|
65
|
+
_workspaceRoot = function () {
|
|
66
|
+
return data;
|
|
67
|
+
};
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
function _workspaceRoot2() {
|
|
71
|
+
const data = require("./workspace-root.fragment");
|
|
72
|
+
_workspaceRoot2 = function () {
|
|
73
|
+
return data;
|
|
74
|
+
};
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
function _workspaceRootData() {
|
|
78
|
+
const data = require("./workspace-root-data");
|
|
79
|
+
_workspaceRootData = function () {
|
|
80
|
+
return data;
|
|
81
|
+
};
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
85
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
86
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
87
|
+
/**
|
|
88
|
+
* the workspace-root component is the one tracked at the workspace root (rootDir "."). it versions
|
|
89
|
+
* the workspace's own files - workspace.jsonc, .bitmap, the lockfile, repo scripts and configs - and
|
|
90
|
+
* a git-free workspace is restored from it. this aspect is the home of that concept: the marker that
|
|
91
|
+
* tells a root apart wherever it is, and the record every member carries of the root it was snapped
|
|
92
|
+
* in.
|
|
93
|
+
*
|
|
94
|
+
* "workspace-root component" rather than "root component", which is the dependency-resolver's
|
|
95
|
+
* rootComponents, or "workspace component", which is every component loaded from a workspace.
|
|
96
|
+
*/
|
|
97
|
+
class WorkspaceRootMain {
|
|
98
|
+
constructor(workspace) {
|
|
99
|
+
this.workspace = workspace;
|
|
100
|
+
_defineProperty(this, "loadBit", void 0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* a clone loads bit for the new workspace, in a process that started outside of one. the function
|
|
105
|
+
* belongs to the bit aspect, which depends on this one, so it is handed over rather than imported
|
|
106
|
+
* (see load-bit.ts).
|
|
107
|
+
*/
|
|
108
|
+
setLoadBit(loadBit) {
|
|
109
|
+
this.loadBit = loadBit;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* make a workspace out of a workspace-root component: its files at the root, every component it
|
|
114
|
+
* lists in the directory it records, then install. see cloneWorkspace.
|
|
115
|
+
*/
|
|
116
|
+
async clone(idStr, dir, options = {}) {
|
|
117
|
+
if (this.workspace) {
|
|
118
|
+
throw new (_bitError().BitError)(`unable to clone inside the workspace at "${this.workspace.path}", a clone is a new workspace. run it from a directory outside of any workspace`);
|
|
119
|
+
}
|
|
120
|
+
if (!this.loadBit) throw new Error('WorkspaceRootMain.clone: loadBit was not set, see load-bit.ts');
|
|
121
|
+
return (0, _clone().cloneWorkspace)(_componentId().ComponentID.fromString(idStr), dir, options, this.loadBit);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* the id of the component that owns the workspace root, if the workspace has one.
|
|
126
|
+
*/
|
|
127
|
+
getRootComponentId() {
|
|
128
|
+
if (!this.workspace) return undefined;
|
|
129
|
+
return (0, _workspaceRootData().findWorkspaceRootMap)(this.workspace.consumer.bitMap)?.id;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* whether the component is a workspace-root component. read from its aspect data, so it works
|
|
134
|
+
* for a component loaded from a scope as well as from a workspace.
|
|
135
|
+
*/
|
|
136
|
+
isWorkspaceRootComponent(component) {
|
|
137
|
+
return (0, _workspaceRootData().isWorkspaceRootComponent)(this.extensionsOf(component));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* the workspace-root component a component was snapped in, at the version the root had then. the
|
|
142
|
+
* snap records it as aspect data, so it is available wherever the component is, a bare scope
|
|
143
|
+
* included. it is the way to know which root files (lockfile, tsconfig, scripts) a version was
|
|
144
|
+
* made with. a component snapped in a workspace without a root component has none.
|
|
145
|
+
*/
|
|
146
|
+
getRootOf(component) {
|
|
147
|
+
return (0, _workspaceRootData().readWorkspaceRoot)(this.extensionsOf(component));
|
|
148
|
+
}
|
|
149
|
+
extensionsOf(component) {
|
|
150
|
+
return component.state._consumer.extensions;
|
|
151
|
+
}
|
|
152
|
+
static async provider([workspace, component, cli]) {
|
|
153
|
+
const workspaceRoot = new WorkspaceRootMain(workspace);
|
|
154
|
+
component.registerShowFragments([new (_workspaceRoot2().WorkspaceRootFragment)(workspaceRoot)]);
|
|
155
|
+
cli.register(new (_clone2().CloneCmd)(workspaceRoot));
|
|
156
|
+
workspace?.registerOnComponentLoad(markWorkspaceRoot);
|
|
157
|
+
return workspaceRoot;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* the root marks itself as such in its aspect data when loaded. the snap saves the data with the
|
|
163
|
+
* version, and every consumer of the model reads the marker rather than guessing from the files.
|
|
164
|
+
*/
|
|
165
|
+
exports.WorkspaceRootMain = WorkspaceRootMain;
|
|
166
|
+
_defineProperty(WorkspaceRootMain, "runtime", _cli().MainRuntime);
|
|
167
|
+
_defineProperty(WorkspaceRootMain, "dependencies", [_workspace().WorkspaceAspect, _component().ComponentAspect, _cli().CLIAspect]);
|
|
168
|
+
async function markWorkspaceRoot(component) {
|
|
169
|
+
const consumerComponent = component.state._consumer;
|
|
170
|
+
return consumerComponent.componentMap?.rootDir === _legacy().WORKSPACE_ROOT_DIR ? {
|
|
171
|
+
isRoot: true
|
|
172
|
+
} : undefined;
|
|
173
|
+
}
|
|
174
|
+
_workspaceRoot().WorkspaceRootAspect.addRuntime(WorkspaceRootMain);
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=workspace-root.main.runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_cli","_component","_componentId","_legacy","_workspace","_clone","_clone2","_workspaceRoot","_workspaceRoot2","_workspaceRootData","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceRootMain","constructor","workspace","setLoadBit","loadBit","clone","idStr","dir","options","BitError","path","Error","cloneWorkspace","ComponentID","fromString","getRootComponentId","undefined","findWorkspaceRootMap","consumer","bitMap","id","isWorkspaceRootComponent","component","extensionsOf","getRootOf","readWorkspaceRoot","state","_consumer","extensions","provider","cli","workspaceRoot","registerShowFragments","WorkspaceRootFragment","register","CloneCmd","registerOnComponentLoad","markWorkspaceRoot","exports","MainRuntime","WorkspaceAspect","ComponentAspect","CLIAspect","consumerComponent","componentMap","rootDir","WORKSPACE_ROOT_DIR","isRoot","WorkspaceRootAspect","addRuntime"],"sources":["workspace-root.main.runtime.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport type { CLIMain } from '@teambit/cli';\nimport { CLIAspect, MainRuntime } from '@teambit/cli';\nimport type { Component, ComponentMain } from '@teambit/component';\nimport { ComponentAspect } from '@teambit/component';\nimport { ComponentID } from '@teambit/component-id';\nimport { WORKSPACE_ROOT_DIR } from '@teambit/legacy.bit-map';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport type { Workspace } from '@teambit/workspace';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { CloneOptions, CloneResult, LoadBit } from './clone';\nimport { cloneWorkspace } from './clone';\nimport { CloneCmd } from './clone.cmd';\nimport { WorkspaceRootAspect } from './workspace-root.aspect';\nimport { WorkspaceRootFragment } from './workspace-root.fragment';\nimport type { WorkspaceRootData } from './workspace-root-data';\nimport { findWorkspaceRootMap, isWorkspaceRootComponent, readWorkspaceRoot } from './workspace-root-data';\n\n/**\n * the workspace-root component is the one tracked at the workspace root (rootDir \".\"). it versions\n * the workspace's own files - workspace.jsonc, .bitmap, the lockfile, repo scripts and configs - and\n * a git-free workspace is restored from it. this aspect is the home of that concept: the marker that\n * tells a root apart wherever it is, and the record every member carries of the root it was snapped\n * in.\n *\n * \"workspace-root component\" rather than \"root component\", which is the dependency-resolver's\n * rootComponents, or \"workspace component\", which is every component loaded from a workspace.\n */\nexport class WorkspaceRootMain {\n private loadBit?: LoadBit;\n\n constructor(private workspace?: Workspace) {}\n\n /**\n * a clone loads bit for the new workspace, in a process that started outside of one. the function\n * belongs to the bit aspect, which depends on this one, so it is handed over rather than imported\n * (see load-bit.ts).\n */\n setLoadBit(loadBit: LoadBit) {\n this.loadBit = loadBit;\n }\n\n /**\n * make a workspace out of a workspace-root component: its files at the root, every component it\n * lists in the directory it records, then install. see cloneWorkspace.\n */\n async clone(idStr: string, dir: string | undefined, options: CloneOptions = {}): Promise<CloneResult> {\n if (this.workspace) {\n throw new BitError(\n `unable to clone inside the workspace at \"${this.workspace.path}\", a clone is a new workspace. run it from a directory outside of any workspace`\n );\n }\n if (!this.loadBit) throw new Error('WorkspaceRootMain.clone: loadBit was not set, see load-bit.ts');\n return cloneWorkspace(ComponentID.fromString(idStr), dir, options, this.loadBit);\n }\n\n /**\n * the id of the component that owns the workspace root, if the workspace has one.\n */\n getRootComponentId(): ComponentID | undefined {\n if (!this.workspace) return undefined;\n return findWorkspaceRootMap(this.workspace.consumer.bitMap)?.id;\n }\n\n /**\n * whether the component is a workspace-root component. read from its aspect data, so it works\n * for a component loaded from a scope as well as from a workspace.\n */\n isWorkspaceRootComponent(component: Component): boolean {\n return isWorkspaceRootComponent(this.extensionsOf(component));\n }\n\n /**\n * the workspace-root component a component was snapped in, at the version the root had then. the\n * snap records it as aspect data, so it is available wherever the component is, a bare scope\n * included. it is the way to know which root files (lockfile, tsconfig, scripts) a version was\n * made with. a component snapped in a workspace without a root component has none.\n */\n getRootOf(component: Component): ComponentID | undefined {\n return readWorkspaceRoot(this.extensionsOf(component));\n }\n\n private extensionsOf(component: Component) {\n return (component.state._consumer as ConsumerComponent).extensions;\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [WorkspaceAspect, ComponentAspect, CLIAspect];\n\n static async provider([workspace, component, cli]: [Workspace | undefined, ComponentMain, CLIMain]) {\n const workspaceRoot = new WorkspaceRootMain(workspace);\n component.registerShowFragments([new WorkspaceRootFragment(workspaceRoot)]);\n cli.register(new CloneCmd(workspaceRoot));\n workspace?.registerOnComponentLoad(markWorkspaceRoot);\n return workspaceRoot;\n }\n}\n\n/**\n * the root marks itself as such in its aspect data when loaded. the snap saves the data with the\n * version, and every consumer of the model reads the marker rather than guessing from the files.\n */\nasync function markWorkspaceRoot(component: Component): Promise<WorkspaceRootData | undefined> {\n const consumerComponent = component.state._consumer as ConsumerComponent;\n return consumerComponent.componentMap?.rootDir === WORKSPACE_ROOT_DIR ? { isRoot: true } : undefined;\n}\n\nWorkspaceRootAspect.addRuntime(WorkspaceRootMain);\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAC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AAC,IAAI,CAACF,YAAY,CAACD,SAAS,CAAC,CAAC;EACxD;EAEQC,YAAYA,CAACD,SAAoB,EAAE;IACzC,OAAQA,SAAS,CAACI,KAAK,CAACC,SAAS,CAAuBC,UAAU;EACpE;EAMA,aAAaC,QAAQA,CAAC,CAAC3B,SAAS,EAAEoB,SAAS,EAAEQ,GAAG,CAAkD,EAAE;IAClG,MAAMC,aAAa,GAAG,IAAI/B,iBAAiB,CAACE,SAAS,CAAC;IACtDoB,SAAS,CAACU,qBAAqB,CAAC,CAAC,KAAIC,uCAAqB,EAACF,aAAa,CAAC,CAAC,CAAC;IAC3ED,GAAG,CAACI,QAAQ,CAAC,KAAIC,kBAAQ,EAACJ,aAAa,CAAC,CAAC;IACzC7B,SAAS,EAAEkC,uBAAuB,CAACC,iBAAiB,CAAC;IACrD,OAAON,aAAa;EACtB;AACF;;AAEA;AACA;AACA;AACA;AAHAO,OAAA,CAAAtC,iBAAA,GAAAA,iBAAA;AAAAnB,eAAA,CAvEamB,iBAAiB,aA0DXuC,kBAAW;AAAA1D,eAAA,CA1DjBmB,iBAAiB,kBA4DN,CAACwC,4BAAe,EAAEC,4BAAe,EAAEC,gBAAS,CAAC;AAerE,eAAeL,iBAAiBA,CAACf,SAAoB,EAA0C;EAC7F,MAAMqB,iBAAiB,GAAGrB,SAAS,CAACI,KAAK,CAACC,SAA8B;EACxE,OAAOgB,iBAAiB,CAACC,YAAY,EAAEC,OAAO,KAAKC,4BAAkB,GAAG;IAAEC,MAAM,EAAE;EAAK,CAAC,GAAG/B,SAAS;AACtG;AAEAgC,oCAAmB,CAACC,UAAU,CAACjD,iBAAiB,CAAC","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/workspace-root",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"componentId": {
|
|
6
|
+
"name": "workspace-root",
|
|
7
|
+
"version": "0.0.1",
|
|
8
|
+
"scope": "teambit.workspace"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"fs-extra": "10.0.0",
|
|
12
|
+
"@teambit/bit-error": "0.0.404",
|
|
13
|
+
"@teambit/component-id": "1.2.4",
|
|
14
|
+
"@teambit/harmony": "0.4.12",
|
|
15
|
+
"@teambit/lane-id": "0.0.312",
|
|
16
|
+
"@teambit/legacy.utils": "0.0.51",
|
|
17
|
+
"@teambit/cli": "0.0.1394",
|
|
18
|
+
"@teambit/host-initializer": "0.0.888",
|
|
19
|
+
"@teambit/importer": "1.0.1175",
|
|
20
|
+
"@teambit/install": "1.0.1175",
|
|
21
|
+
"@teambit/legacy.bit-map": "0.0.222",
|
|
22
|
+
"@teambit/legacy.constants": "0.0.45",
|
|
23
|
+
"@teambit/scope.remotes": "0.0.165",
|
|
24
|
+
"@teambit/scope": "1.0.1175",
|
|
25
|
+
"@teambit/workspace.modules.workspace-locator": "0.0.46",
|
|
26
|
+
"@teambit/workspace": "1.0.1175",
|
|
27
|
+
"@teambit/legacy.extension-data": "0.0.167",
|
|
28
|
+
"@teambit/component": "1.0.1175",
|
|
29
|
+
"@teambit/legacy.consumer-component": "0.0.166"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/fs-extra": "9.0.7",
|
|
33
|
+
"@teambit/harmony.envs.core-aspect-env": "2.1.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"chai": "5.2.1"
|
|
37
|
+
},
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"optionalDependencies": {},
|
|
40
|
+
"peerDependenciesMeta": {},
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"node": {
|
|
45
|
+
"require": "./dist/index.js"
|
|
46
|
+
},
|
|
47
|
+
"default": "./dist/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./dist/*": "./dist/*",
|
|
50
|
+
"./artifacts/*": "./artifacts/*"
|
|
51
|
+
},
|
|
52
|
+
"private": false,
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=16.0.0"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/teambit/bit"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"bit",
|
|
62
|
+
"bit-aspect",
|
|
63
|
+
"bit-core-aspect",
|
|
64
|
+
"components",
|
|
65
|
+
"collaboration",
|
|
66
|
+
"web"
|
|
67
|
+
]
|
|
68
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
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
|
+
}
|
|
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
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
}
|
|
43
|
+
|
|
44
|
+
// `reset-css` ships only `reset.css` (no `.d.ts`). TS6 refuses bare
|
|
45
|
+
// side-effect imports without declarations, so we declare the module here.
|
|
46
|
+
declare module 'reset-css';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: The component that owns the workspace root, and the record its members keep of it
|
|
3
|
+
labels: ['core aspect', 'workspace', 'workspace-root']
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
A workspace-root component is tracked at the workspace root (`rootDir: "."`). It versions the
|
|
9
|
+
workspace's own files, such as `workspace.jsonc`, `.bitmap`, the lockfile and repo-level scripts and
|
|
10
|
+
configs, and a git-free workspace is restored from it.
|
|
11
|
+
|
|
12
|
+
This aspect owns two pieces of data, both saved with every version. The root marks itself, so it is
|
|
13
|
+
told from the model alone rather than by the files it happens to carry:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
"teambit.workspace/workspace-root": {
|
|
17
|
+
"data": { "isRoot": true }
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Every member the workspace snaps records which root it was snapped in and at which version:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
"teambit.workspace/workspace-root": {
|
|
25
|
+
"data": { "root": "my-org.my-scope/my-root@0.0.7" }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
A new or modified root joins every `bit tag` and `bit snap` of its members, so the recorded version
|
|
30
|
+
is always the one that has the files the member was made with. A root tagged along is bumped as a
|
|
31
|
+
patch, whatever version the members were given.
|
|
32
|
+
|
|
33
|
+
Both are aspect data, not config, so they never make a component modified and the root moving on
|
|
34
|
+
does not touch its members. Their consumers are tools that need the root's files a version was made
|
|
35
|
+
with, such as a CI building the component or a workspace clone.
|
|
36
|
+
|
|
37
|
+
## Cloning a workspace
|
|
38
|
+
|
|
39
|
+
`bit clone <root-id> [dir]` makes a workspace out of a workspace-root component, the way `git clone`
|
|
40
|
+
makes a working tree out of a repository. It runs outside a workspace, in an empty or absent
|
|
41
|
+
directory (default: the component name), and needs no `bit init`:
|
|
42
|
+
|
|
43
|
+
- the root's files land at the workspace root, `workspace.jsonc` included;
|
|
44
|
+
- every component the root's versioned `.bitmap` lists is imported into the directory it records;
|
|
45
|
+
- the dependencies are installed and the components compiled (`--skip-dependency-installation` to skip).
|
|
46
|
+
|
|
47
|
+
The versioned `.bitmap` holds no versions, only which components exist and where, so the components
|
|
48
|
+
come at their heads on main. `--lane <scope>/<name>` clones the workspace as it is on a lane: the
|
|
49
|
+
workspace comes out on the lane and the components at their heads there. A version on the root id
|
|
50
|
+
pins the root files only. A component the root lists that its remote does not have, one never
|
|
51
|
+
exported for instance, is reported and the clone goes on without it.
|
|
52
|
+
|
|
53
|
+
A clone comes out with nothing modified. What the root versions of its `.bitmap` is normalized to the
|
|
54
|
+
part an export does not change, so the map the clone writes is the map the root carries.
|
|
55
|
+
|
|
56
|
+
Scopes on bit.cloud resolve by name. For a self-hosted scope that is not in the global remotes,
|
|
57
|
+
`--remote <url>` registers it in the new workspace first.
|
|
58
|
+
|
|
59
|
+
## Terminology
|
|
60
|
+
|
|
61
|
+
"Workspace-root component", because "root component" is taken by the dependency-resolver's
|
|
62
|
+
`rootComponents`, and "workspace component" means any component loaded from a workspace.
|