@teambit/workspace 1.0.251 → 1.0.253
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/__bit_junit.xml +1 -1
- package/artifacts/preview/static/css/teambit.workspace/{workspace-preview.f9f484f7.css → workspace-preview.b6736c2c.css} +2 -2
- package/artifacts/preview/teambit_workspace_workspace-preview.js +1 -1
- package/artifacts/schema.json +2366 -2208
- package/component-config-file/component-config-file.ts +19 -11
- package/dist/component-config-file/component-config-file.d.ts +3 -2
- package/dist/component-config-file/component-config-file.js +21 -17
- package/dist/component-config-file/component-config-file.js.map +1 -1
- package/dist/{preview-1713928852794.js → preview-1714015260289.js} +2 -2
- package/dist/workspace.d.ts +3 -2
- package/dist/workspace.js +30 -17
- package/dist/workspace.js.map +1 -1
- package/package.json +20 -21
|
@@ -2,17 +2,17 @@ import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@t
|
|
|
2
2
|
import { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';
|
|
3
3
|
import { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
4
4
|
import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
|
|
5
|
+
import { JsonVinyl } from '@teambit/legacy/dist/consumer/component/json-vinyl';
|
|
5
6
|
import detectIndent from 'detect-indent';
|
|
6
7
|
import detectNewline from 'detect-newline';
|
|
7
8
|
import fs from 'fs-extra';
|
|
8
9
|
import path from 'path';
|
|
9
|
-
import stringifyPackage from 'stringify-package';
|
|
10
10
|
import { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';
|
|
11
11
|
import { merge } from 'lodash';
|
|
12
12
|
import { AlreadyExistsError } from './exceptions';
|
|
13
13
|
|
|
14
14
|
interface ComponentConfigFileOptions {
|
|
15
|
-
indent:
|
|
15
|
+
indent: string;
|
|
16
16
|
newLine: '\r\n' | '\n' | undefined;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ interface ComponentConfigFileJson {
|
|
|
28
28
|
defaultScope?: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const DEFAULT_INDENT =
|
|
31
|
+
const DEFAULT_INDENT = ' ';
|
|
32
32
|
const DEFAULT_NEWLINE = '\n';
|
|
33
33
|
|
|
34
34
|
export class ComponentConfigFile {
|
|
@@ -53,7 +53,7 @@ export class ComponentConfigFile {
|
|
|
53
53
|
}
|
|
54
54
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
55
55
|
const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);
|
|
56
|
-
const indent = detectIndent(content).
|
|
56
|
+
const indent = detectIndent(content).indent;
|
|
57
57
|
const newLine = detectNewline(content);
|
|
58
58
|
const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);
|
|
59
59
|
const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));
|
|
@@ -72,14 +72,27 @@ export class ComponentConfigFile {
|
|
|
72
72
|
return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
async
|
|
75
|
+
async toVinylFile(options: WriteConfigFileOptions = {}): Promise<JsonVinyl> {
|
|
76
76
|
const json = this.toJson();
|
|
77
77
|
const filePath = ComponentConfigFile.composePath(this.componentDir);
|
|
78
78
|
const isExist = await fs.pathExists(filePath);
|
|
79
79
|
if (isExist && !options.override) {
|
|
80
80
|
throw new AlreadyExistsError(filePath);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
return JsonVinyl.load({
|
|
84
|
+
base: path.dirname(filePath),
|
|
85
|
+
path: filePath,
|
|
86
|
+
content: json,
|
|
87
|
+
override: true,
|
|
88
|
+
indent: this.options.indent,
|
|
89
|
+
newline: this.options.newLine,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async write(options: WriteConfigFileOptions = {}): Promise<void> {
|
|
94
|
+
const vinyl = await this.toVinylFile(options);
|
|
95
|
+
await vinyl.write();
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
async addAspect(
|
|
@@ -130,11 +143,6 @@ export class ComponentConfigFile {
|
|
|
130
143
|
extensions: this.aspects.toConfigObject(),
|
|
131
144
|
};
|
|
132
145
|
}
|
|
133
|
-
|
|
134
|
-
toString(): string {
|
|
135
|
-
const json = this.toJson();
|
|
136
|
-
return stringifyPackage(json, this.options.indent, this.options.newLine);
|
|
137
|
-
}
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
function parseComponentJsonContent(str: string, dir: string) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ComponentID, AspectList, ResolveComponentIdFunc } from '@teambit/component';
|
|
2
2
|
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
|
|
3
3
|
import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
|
|
4
|
+
import { JsonVinyl } from '@teambit/legacy/dist/consumer/component/json-vinyl';
|
|
4
5
|
interface ComponentConfigFileOptions {
|
|
5
|
-
indent:
|
|
6
|
+
indent: string;
|
|
6
7
|
newLine: '\r\n' | '\n' | undefined;
|
|
7
8
|
}
|
|
8
9
|
interface WriteConfigFileOptions {
|
|
@@ -24,11 +25,11 @@ export declare class ComponentConfigFile {
|
|
|
24
25
|
constructor(componentId: ComponentID, aspects: AspectList, componentDir: PathOsBasedAbsolute, propagate?: boolean, options?: ComponentConfigFileOptions, defaultScope?: string | undefined);
|
|
25
26
|
static load(componentDir: PathOsBasedAbsolute, aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>, outsideDefaultScope?: string): Promise<ComponentConfigFile | undefined>;
|
|
26
27
|
static composePath(componentRootFolder: string): string;
|
|
28
|
+
toVinylFile(options?: WriteConfigFileOptions): Promise<JsonVinyl>;
|
|
27
29
|
write(options?: WriteConfigFileOptions): Promise<void>;
|
|
28
30
|
addAspect(aspectId: string, config: any, resolveComponentId: ResolveComponentIdFunc, shouldMergeConfig?: boolean): Promise<void>;
|
|
29
31
|
removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc): Promise<void>;
|
|
30
32
|
private aspectEntryFromConfigObject;
|
|
31
33
|
toJson(): ComponentConfigFileJson;
|
|
32
|
-
toString(): string;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
|
@@ -25,6 +25,13 @@ function _extensionData() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _jsonVinyl() {
|
|
29
|
+
const data = require("@teambit/legacy/dist/consumer/component/json-vinyl");
|
|
30
|
+
_jsonVinyl = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _detectIndent() {
|
|
29
36
|
const data = _interopRequireDefault(require("detect-indent"));
|
|
30
37
|
_detectIndent = function () {
|
|
@@ -53,13 +60,6 @@ function _path() {
|
|
|
53
60
|
};
|
|
54
61
|
return data;
|
|
55
62
|
}
|
|
56
|
-
function _stringifyPackage() {
|
|
57
|
-
const data = _interopRequireDefault(require("stringify-package"));
|
|
58
|
-
_stringifyPackage = function () {
|
|
59
|
-
return data;
|
|
60
|
-
};
|
|
61
|
-
return data;
|
|
62
|
-
}
|
|
63
63
|
function _config() {
|
|
64
64
|
const data = require("@teambit/legacy/dist/consumer/config");
|
|
65
65
|
_config = function () {
|
|
@@ -82,7 +82,7 @@ function _exceptions() {
|
|
|
82
82
|
return data;
|
|
83
83
|
}
|
|
84
84
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
85
|
-
const DEFAULT_INDENT =
|
|
85
|
+
const DEFAULT_INDENT = ' ';
|
|
86
86
|
const DEFAULT_NEWLINE = '\n';
|
|
87
87
|
class ComponentConfigFile {
|
|
88
88
|
constructor(componentId, aspects, componentDir, propagate = false, options = {
|
|
@@ -104,7 +104,7 @@ class ComponentConfigFile {
|
|
|
104
104
|
}
|
|
105
105
|
const content = await _fsExtra().default.readFile(filePath, 'utf-8');
|
|
106
106
|
const parsed = parseComponentJsonContent(content, componentDir);
|
|
107
|
-
const indent = (0, _detectIndent().default)(content).
|
|
107
|
+
const indent = (0, _detectIndent().default)(content).indent;
|
|
108
108
|
const newLine = (0, _detectNewline().default)(content);
|
|
109
109
|
const componentId = _component().ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);
|
|
110
110
|
const aspects = await aspectListFactory(_extensionData().ExtensionDataList.fromConfigObject(parsed.extensions));
|
|
@@ -116,18 +116,26 @@ class ComponentConfigFile {
|
|
|
116
116
|
static composePath(componentRootFolder) {
|
|
117
117
|
return _path().default.join(componentRootFolder, _constants().COMPONENT_CONFIG_FILE_NAME);
|
|
118
118
|
}
|
|
119
|
-
async
|
|
119
|
+
async toVinylFile(options = {}) {
|
|
120
120
|
const json = this.toJson();
|
|
121
121
|
const filePath = ComponentConfigFile.composePath(this.componentDir);
|
|
122
122
|
const isExist = await _fsExtra().default.pathExists(filePath);
|
|
123
123
|
if (isExist && !options.override) {
|
|
124
124
|
throw new (_exceptions().AlreadyExistsError)(filePath);
|
|
125
125
|
}
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
return _jsonVinyl().JsonVinyl.load({
|
|
127
|
+
base: _path().default.dirname(filePath),
|
|
128
|
+
path: filePath,
|
|
129
|
+
content: json,
|
|
130
|
+
override: true,
|
|
131
|
+
indent: this.options.indent,
|
|
132
|
+
newline: this.options.newLine
|
|
129
133
|
});
|
|
130
134
|
}
|
|
135
|
+
async write(options = {}) {
|
|
136
|
+
const vinyl = await this.toVinylFile(options);
|
|
137
|
+
await vinyl.write();
|
|
138
|
+
}
|
|
131
139
|
async addAspect(aspectId, config, resolveComponentId, shouldMergeConfig = false) {
|
|
132
140
|
const existing = this.aspects.get(aspectId);
|
|
133
141
|
if (existing) {
|
|
@@ -167,10 +175,6 @@ class ComponentConfigFile {
|
|
|
167
175
|
extensions: this.aspects.toConfigObject()
|
|
168
176
|
};
|
|
169
177
|
}
|
|
170
|
-
toString() {
|
|
171
|
-
const json = this.toJson();
|
|
172
|
-
return (0, _stringifyPackage().default)(json, this.options.indent, this.options.newLine);
|
|
173
|
-
}
|
|
174
178
|
}
|
|
175
179
|
exports.ComponentConfigFile = ComponentConfigFile;
|
|
176
180
|
function parseComponentJsonContent(str, dir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_component","data","require","_constants","_extensionData","_detectIndent","_interopRequireDefault","_detectNewline","_fsExtra","_path","_stringifyPackage","_config","_lodash","_exceptions","obj","__esModule","default","DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","componentDir","propagate","options","indent","newLine","defaultScope","load","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","detectIndent","amount","detectNewline","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","Boolean","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","write","json","toJson","override","AlreadyExistsError","writeJsonSync","spaces","EOL","addAspect","aspectId","config","resolveComponentId","shouldMergeConfig","existing","get","getNewConfig","merge","aspectEntry","aspectEntryFromConfigObject","entries","push","removeAspect","markWithMinusIfNotExist","aspectList","withoutEntries","REMOVE_EXTENSION_SPECIAL_SIGN","id","legacyEntry","configEntryToDataEntry","AspectEntry","toObject","toConfigObject","toString","stringifyPackage","exports","str","dir","JSON","parse","err","Error","message"],"sources":["component-config-file.ts"],"sourcesContent":["import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport stringifyPackage from 'stringify-package';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { merge } from 'lodash';\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: number;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = 2;\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n private componentDir: PathOsBasedAbsolute,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).amount;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(\n componentId,\n aspects,\n componentDir,\n Boolean(parsed.propagate),\n { indent, newLine },\n parsed.defaultScope\n );\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async write(options: WriteConfigFileOptions = {}): Promise<void> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(this.componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });\n }\n\n async addAspect(\n aspectId: string,\n config: any,\n resolveComponentId: ResolveComponentIdFunc,\n shouldMergeConfig = false\n ) {\n const existing = this.aspects.get(aspectId);\n\n if (existing) {\n const getNewConfig = () => {\n if (!shouldMergeConfig) return config;\n if (!config || config === '-') return config;\n if (!existing.config) return config;\n // @ts-ignore\n if (existing.config === '-') return config;\n return merge(existing.config, config);\n };\n existing.config = getNewConfig();\n } else {\n const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);\n this.aspects.entries.push(aspectEntry);\n }\n }\n\n async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n const aspectList = this.aspects.withoutEntries([aspectId]);\n this.aspects = aspectList;\n } else if (markWithMinusIfNotExist) {\n await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);\n }\n }\n\n private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const aspectId = await resolveComponentId(id);\n const legacyEntry = configEntryToDataEntry(id, config);\n return new AspectEntry(aspectId, legacyEntry);\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n\n toString(): string {\n const json = this.toJson();\n return stringifyPackage(json, this.options.indent, this.options.newLine);\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\n }\n}\n"],"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AAuB,EAAE;MAClC,MAAM,IAAI,CAACd,SAAS,CAACC,QAAQ,EAAEgB,uCAA6B,EAAEd,kBAAkB,CAAC;IACnF;EACF;EAEA,MAAcO,2BAA2BA,CAACQ,EAAU,EAAEhB,MAAW,EAAEC,kBAA0C,EAAE;IAC7G,MAAMF,QAAQ,GAAG,MAAME,kBAAkB,CAACe,EAAE,CAAC;IAC7C,MAAMC,WAAW,GAAG,IAAAC,uCAAsB,EAACF,EAAE,EAAEhB,MAAM,CAAC;IACtD,OAAO,KAAImB,wBAAW,EAACpB,QAAQ,EAAEkB,WAAW,CAAC;EAC/C;EAEAzB,MAAMA,CAAA,EAA4B;IAChC,OAAO;MACLpC,WAAW,EAAE,IAAI,CAACA,WAAW,CAACgE,QAAQ,CAAC,CAAC;MACxC7D,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,YAAY,EAAE,IAAI,CAACA,YAAY;MAC/BqB,UAAU,EAAE,IAAI,CAAC3B,OAAO,CAACgE,cAAc,CAAC;IAC1C,CAAC;EACH;EAEAC,QAAQA,CAAA,EAAW;IACjB,MAAM/B,IAAI,GAAG,IAAI,CAACC,MAAM,CAAC,CAAC;IAC1B,OAAO,IAAA+B,2BAAgB,EAAChC,IAAI,EAAE,IAAI,CAAC/B,OAAO,CAACC,MAAM,EAAE,IAAI,CAACD,OAAO,CAACE,OAAO,CAAC;EAC1E;AACF;AAAC8D,OAAA,CAAAtE,mBAAA,GAAAA,mBAAA;AAED,SAASsB,yBAAyBA,CAACiD,GAAW,EAAEC,GAAW,EAAE;EAC3D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC;EACxB,CAAC,CAAC,OAAOI,GAAQ,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAE,yCAAwCJ,GAAI,qBAAoBG,GAAG,CAACE,OAAQ,EAAC,CAAC;EACjG;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_component","data","require","_constants","_extensionData","_jsonVinyl","_detectIndent","_interopRequireDefault","_detectNewline","_fsExtra","_path","_config","_lodash","_exceptions","obj","__esModule","default","DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","componentDir","propagate","options","indent","newLine","defaultScope","load","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","detectIndent","detectNewline","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","Boolean","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","toVinylFile","json","toJson","override","AlreadyExistsError","JsonVinyl","base","dirname","newline","write","vinyl","addAspect","aspectId","config","resolveComponentId","shouldMergeConfig","existing","get","getNewConfig","merge","aspectEntry","aspectEntryFromConfigObject","entries","push","removeAspect","markWithMinusIfNotExist","aspectList","withoutEntries","REMOVE_EXTENSION_SPECIAL_SIGN","id","legacyEntry","configEntryToDataEntry","AspectEntry","toObject","toConfigObject","exports","str","dir","JSON","parse","err","Error","message"],"sources":["component-config-file.ts"],"sourcesContent":["import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { JsonVinyl } from '@teambit/legacy/dist/consumer/component/json-vinyl';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { merge } from 'lodash';\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: string;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = ' ';\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n private componentDir: PathOsBasedAbsolute,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).indent;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(\n componentId,\n aspects,\n componentDir,\n Boolean(parsed.propagate),\n { indent, newLine },\n parsed.defaultScope\n );\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async toVinylFile(options: WriteConfigFileOptions = {}): Promise<JsonVinyl> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(this.componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n\n return JsonVinyl.load({\n base: path.dirname(filePath),\n path: filePath,\n content: json,\n override: true,\n indent: this.options.indent,\n newline: this.options.newLine,\n });\n }\n\n async write(options: WriteConfigFileOptions = {}): Promise<void> {\n const vinyl = await this.toVinylFile(options);\n await vinyl.write();\n }\n\n async addAspect(\n aspectId: string,\n config: any,\n resolveComponentId: ResolveComponentIdFunc,\n shouldMergeConfig = false\n ) {\n const existing = this.aspects.get(aspectId);\n\n if (existing) {\n const getNewConfig = () => {\n if (!shouldMergeConfig) return config;\n if (!config || config === '-') return config;\n if (!existing.config) return config;\n // @ts-ignore\n if (existing.config === '-') return config;\n return merge(existing.config, config);\n };\n existing.config = getNewConfig();\n } else {\n const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);\n this.aspects.entries.push(aspectEntry);\n }\n }\n\n async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n const aspectList = this.aspects.withoutEntries([aspectId]);\n this.aspects = aspectList;\n } else if (markWithMinusIfNotExist) {\n await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);\n }\n }\n\n private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const aspectId = await resolveComponentId(id);\n const legacyEntry = configEntryToDataEntry(id, config);\n return new AspectEntry(aspectId, legacyEntry);\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,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AACd,SAAS,CAACC,QAAQ,EAAEgB,uCAA6B,EAAEd,kBAAkB,CAAC;IACnF;EACF;EAEA,MAAcO,2BAA2BA,CAACQ,EAAU,EAAEhB,MAAW,EAAEC,kBAA0C,EAAE;IAC7G,MAAMF,QAAQ,GAAG,MAAME,kBAAkB,CAACe,EAAE,CAAC;IAC7C,MAAMC,WAAW,GAAG,IAAAC,uCAAsB,EAACF,EAAE,EAAEhB,MAAM,CAAC;IACtD,OAAO,KAAImB,wBAAW,EAACpB,QAAQ,EAAEkB,WAAW,CAAC;EAC/C;EAEA5B,MAAMA,CAAA,EAA4B;IAChC,OAAO;MACLnC,WAAW,EAAE,IAAI,CAACA,WAAW,CAACkE,QAAQ,CAAC,CAAC;MACxC/D,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,YAAY,EAAE,IAAI,CAACA,YAAY;MAC/BoB,UAAU,EAAE,IAAI,CAAC1B,OAAO,CAACkE,cAAc,CAAC;IAC1C,CAAC;EACH;AACF;AAACC,OAAA,CAAAtE,mBAAA,GAAAA,mBAAA;AAED,SAASsB,yBAAyBA,CAACiD,GAAW,EAAEC,GAAW,EAAE;EAC3D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC;EACxB,CAAC,CAAC,OAAOI,GAAQ,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAE,yCAAwCJ,GAAI,qBAAoBG,GAAG,CAACE,OAAQ,EAAC,CAAC;EACjG;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.253/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.253/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/workspace.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-compo
|
|
|
26
26
|
import { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';
|
|
27
27
|
import { Lane } from '@teambit/legacy/dist/scope/models';
|
|
28
28
|
import { GlobalConfigMain } from '@teambit/global-config';
|
|
29
|
+
import { JsonVinyl } from '@teambit/legacy/dist/consumer/component/json-vinyl';
|
|
29
30
|
import { ComponentConfigFile } from './component-config-file';
|
|
30
31
|
import { OnComponentAdd, OnComponentChange, OnComponentEventResult, OnComponentLoad, OnComponentRemove } from './on-component-events';
|
|
31
32
|
import { WorkspaceExtConfig } from './types';
|
|
@@ -308,9 +309,9 @@ export declare class Workspace implements ComponentFactory {
|
|
|
308
309
|
*/
|
|
309
310
|
getCurrentRemoteLane(): Promise<Lane | null>;
|
|
310
311
|
getDefaultExtensions(): ExtensionDataList;
|
|
312
|
+
getComponentConfigVinylFile(id: ComponentID, options: EjectConfOptions, excludeLocalChanges?: boolean): Promise<JsonVinyl>;
|
|
311
313
|
ejectMultipleConfigs(ids: ComponentID[], options: EjectConfOptions): Promise<EjectConfResult[]>;
|
|
312
|
-
|
|
313
|
-
getExtensionsFromScopeAndSpecific(id: ComponentID): Promise<ExtensionDataList>;
|
|
314
|
+
getExtensionsFromScopeAndSpecific(id: ComponentID, excludeComponentJson?: boolean): Promise<ExtensionDataList>;
|
|
314
315
|
/**
|
|
315
316
|
* @deprecated use `this.idsByPattern` instead for consistency. also, it supports negation and list of patterns.
|
|
316
317
|
*
|
package/dist/workspace.js
CHANGED
|
@@ -235,6 +235,13 @@ function _http() {
|
|
|
235
235
|
};
|
|
236
236
|
return data;
|
|
237
237
|
}
|
|
238
|
+
function _dataToPersist() {
|
|
239
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/sources/data-to-persist"));
|
|
240
|
+
_dataToPersist = function () {
|
|
241
|
+
return data;
|
|
242
|
+
};
|
|
243
|
+
return data;
|
|
244
|
+
}
|
|
238
245
|
function _componentConfigFile() {
|
|
239
246
|
const data = require("./component-config-file");
|
|
240
247
|
_componentConfigFile = function () {
|
|
@@ -1022,32 +1029,38 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
1022
1029
|
}
|
|
1023
1030
|
return _extensionData().ExtensionDataList.fromConfigObject(this.config.extensions);
|
|
1024
1031
|
}
|
|
1025
|
-
async
|
|
1026
|
-
return Promise.all(ids.map(id => this.ejectConfig(id, options)));
|
|
1027
|
-
}
|
|
1028
|
-
async ejectConfig(id, options) {
|
|
1032
|
+
async getComponentConfigVinylFile(id, options, excludeLocalChanges = false) {
|
|
1029
1033
|
const componentId = await this.resolveComponentId(id);
|
|
1030
|
-
const extensions = await this.getExtensionsFromScopeAndSpecific(id);
|
|
1034
|
+
const extensions = await this.getExtensionsFromScopeAndSpecific(id, excludeLocalChanges);
|
|
1031
1035
|
const aspects = await this.createAspectList(extensions);
|
|
1032
1036
|
const componentDir = this.componentDir(id, {
|
|
1033
1037
|
ignoreVersion: true
|
|
1038
|
+
}, {
|
|
1039
|
+
relative: true
|
|
1034
1040
|
});
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
override: options.override
|
|
1038
|
-
});
|
|
1039
|
-
// remove config from the .bitmap as it's not needed anymore. it is replaced by the component.json
|
|
1040
|
-
this.bitMap.removeEntireConfig(id);
|
|
1041
|
-
await this.bitMap.write(`eject-conf (${id.toString()})`);
|
|
1042
|
-
return {
|
|
1043
|
-
configPath: _componentConfigFile().ComponentConfigFile.composePath(componentDir)
|
|
1044
|
-
};
|
|
1041
|
+
const configFile = new (_componentConfigFile().ComponentConfigFile)(componentId, aspects, componentDir, options.propagate);
|
|
1042
|
+
return configFile.toVinylFile(options);
|
|
1045
1043
|
}
|
|
1046
|
-
async
|
|
1044
|
+
async ejectMultipleConfigs(ids, options) {
|
|
1045
|
+
const vinylFiles = await Promise.all(ids.map(id => this.getComponentConfigVinylFile(id, options)));
|
|
1046
|
+
const EjectConfResult = vinylFiles.map(file => ({
|
|
1047
|
+
configPath: file.path
|
|
1048
|
+
}));
|
|
1049
|
+
const dataToPersist = new (_dataToPersist().default)();
|
|
1050
|
+
dataToPersist.addManyFiles(vinylFiles);
|
|
1051
|
+
dataToPersist.addBasePath(this.path);
|
|
1052
|
+
await dataToPersist.persistAllToFS();
|
|
1053
|
+
ids.map(id => this.bitMap.removeEntireConfig(id));
|
|
1054
|
+
await this.bitMap.write(`eject-conf (${ids.length} component(s))`);
|
|
1055
|
+
return EjectConfResult;
|
|
1056
|
+
}
|
|
1057
|
+
async getExtensionsFromScopeAndSpecific(id, excludeComponentJson = false) {
|
|
1047
1058
|
const componentFromScope = await this.scope.get(id);
|
|
1059
|
+
const exclude = ['WorkspaceVariants'];
|
|
1060
|
+
if (excludeComponentJson) exclude.push('ComponentJsonFile');
|
|
1048
1061
|
const {
|
|
1049
1062
|
extensions
|
|
1050
|
-
} = await this.componentExtensions(id, componentFromScope,
|
|
1063
|
+
} = await this.componentExtensions(id, componentFromScope, exclude);
|
|
1051
1064
|
return extensions;
|
|
1052
1065
|
}
|
|
1053
1066
|
|