@teambit/eject 0.0.0-024c646f108d6fc8deee77282d00916bbffe422a

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,64 @@
1
+ /**
2
+ * a classic use case of eject is when a user imports a component using `bit import` to update it,
3
+ * but the user has no intention to have the code as part of the project source code.
4
+ * the eject provides the option to delete the component locally and install it via the NPM client.
5
+ *
6
+ * an implementation note, the entire process is done with rollback in mind.
7
+ * since installing the component via NPM client is an error prone process, we do it first, before
8
+ * removing the component files, so then it's easier to rollback.
9
+ */
10
+ import { Workspace } from '@teambit/workspace';
11
+ import { Consumer } from '@teambit/legacy.consumer';
12
+ import { ComponentIdList, ComponentID } from '@teambit/component-id';
13
+ import { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';
14
+ import { Logger } from '@teambit/logger';
15
+ import { InstallMain } from '@teambit/install';
16
+ export type EjectResults = {
17
+ ejectedComponents: ComponentIdList;
18
+ failedComponents: FailedComponents;
19
+ };
20
+ export type EjectOptions = {
21
+ force?: boolean;
22
+ keepFiles?: boolean;
23
+ skipDependencyInstallation?: boolean;
24
+ };
25
+ type FailedComponents = {
26
+ modifiedComponents: ComponentIdList;
27
+ stagedComponents: ComponentIdList;
28
+ notExportedComponents: ComponentIdList;
29
+ selfHostedExportedComponents: ComponentIdList;
30
+ };
31
+ export declare class ComponentsEjector {
32
+ private workspace;
33
+ private install;
34
+ private logger;
35
+ private componentsIds;
36
+ private ejectOptions;
37
+ consumer: Consumer;
38
+ idsToEject: ComponentIdList;
39
+ componentsToEject: Component[];
40
+ notEjectedDependents: Array<{
41
+ dependent: Component;
42
+ ejectedDependencies: Component[];
43
+ }>;
44
+ failedComponents: FailedComponents;
45
+ constructor(workspace: Workspace, install: InstallMain, logger: Logger, componentsIds: ComponentID[], ejectOptions: EjectOptions);
46
+ eject(): Promise<EjectResults>;
47
+ decideWhichComponentsToEject(): Promise<void>;
48
+ loadComponentsToEject(): Promise<void>;
49
+ removeComponentsFromNodeModules(): Promise<void>;
50
+ installPackages(): Promise<void>;
51
+ getPackagesToInstall(): string[];
52
+ _buildExceptionMessageWithRollbackData(action: string): string;
53
+ /**
54
+ * as part of the 'eject' operation, a component is removed locally. as opposed to the remove
55
+ * command, in this case, no need to remove the objects from the scope, only remove from the
56
+ * filesystem, which means, delete the component files, untrack from .bitmap and clean
57
+ * package.json and bit.json traces.
58
+ */
59
+ private removeComponentsFiles;
60
+ private untrackComponents;
61
+ throwEjectError(message: string, originalError: Error): void;
62
+ _validateIdsHaveScopesAndVersions(): void;
63
+ }
64
+ export {};
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ComponentsEjector = void 0;
7
+ function _componentId() {
8
+ const data = require("@teambit/component-id");
9
+ _componentId = 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 _scope() {
22
+ const data = require("@teambit/scope.remotes");
23
+ _scope = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _pkgModules() {
29
+ const data = require("@teambit/pkg.modules.component-package-name");
30
+ _pkgModules = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _component() {
36
+ const data = require("@teambit/component.sources");
37
+ _component = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _remove() {
43
+ const data = require("@teambit/remove");
44
+ _remove = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ 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; }
50
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
51
+ 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); } /**
52
+ * a classic use case of eject is when a user imports a component using `bit import` to update it,
53
+ * but the user has no intention to have the code as part of the project source code.
54
+ * the eject provides the option to delete the component locally and install it via the NPM client.
55
+ *
56
+ * an implementation note, the entire process is done with rollback in mind.
57
+ * since installing the component via NPM client is an error prone process, we do it first, before
58
+ * removing the component files, so then it's easier to rollback.
59
+ */
60
+ class ComponentsEjector {
61
+ constructor(workspace, install, logger, componentsIds, ejectOptions) {
62
+ this.workspace = workspace;
63
+ this.install = install;
64
+ this.logger = logger;
65
+ this.componentsIds = componentsIds;
66
+ this.ejectOptions = ejectOptions;
67
+ _defineProperty(this, "consumer", void 0);
68
+ _defineProperty(this, "idsToEject", void 0);
69
+ _defineProperty(this, "componentsToEject", []);
70
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
71
+ _defineProperty(this, "notEjectedDependents", void 0);
72
+ _defineProperty(this, "failedComponents", void 0);
73
+ this.consumer = this.workspace.consumer;
74
+ this.idsToEject = new (_componentId().ComponentIdList)();
75
+ this.failedComponents = {
76
+ modifiedComponents: new (_componentId().ComponentIdList)(),
77
+ stagedComponents: new (_componentId().ComponentIdList)(),
78
+ notExportedComponents: new (_componentId().ComponentIdList)(),
79
+ selfHostedExportedComponents: new (_componentId().ComponentIdList)()
80
+ };
81
+ }
82
+ async eject() {
83
+ await this.decideWhichComponentsToEject();
84
+ this.logger.debug(`${this.idsToEject.length} to eject`);
85
+ await this.loadComponentsToEject();
86
+ if (this.idsToEject.length) {
87
+ this._validateIdsHaveScopesAndVersions();
88
+ await this.removeComponentsFromNodeModules();
89
+ await this.untrackComponents();
90
+ await this.installPackages();
91
+ await this.removeComponentsFiles();
92
+ await this.consumer.writeBitMap();
93
+ }
94
+ this.logger.debug('eject: completed successfully');
95
+ return {
96
+ ejectedComponents: this.idsToEject,
97
+ failedComponents: this.failedComponents
98
+ };
99
+ }
100
+ async decideWhichComponentsToEject() {
101
+ this.logger.setStatusLine('Eject: getting the components status');
102
+ if (!this.componentsIds.length) return;
103
+ const remotes = await (0, _scope().getScopeRemotes)(this.consumer.scope);
104
+ const hubExportedComponents = new (_componentId().ComponentIdList)();
105
+ this.componentsIds.forEach(componentId => {
106
+ const bitId = componentId;
107
+ if (!this.workspace.isExported(bitId)) this.failedComponents.notExportedComponents.push(bitId);else if (remotes.isHub(bitId.scope)) hubExportedComponents.push(bitId);else this.failedComponents.selfHostedExportedComponents.push(bitId);
108
+ });
109
+ if (this.ejectOptions.force) {
110
+ this.idsToEject = hubExportedComponents;
111
+ } else {
112
+ await Promise.all(hubExportedComponents.map(async id => {
113
+ try {
114
+ const componentStatus = await this.workspace.getComponentStatusById(id);
115
+ if (componentStatus.modified) this.failedComponents.modifiedComponents.push(id);else if (componentStatus.staged) this.failedComponents.stagedComponents.push(id);else this.idsToEject.push(id);
116
+ } catch (err) {
117
+ this.throwEjectError(`eject operation failed getting the status of ${id.toString()}, no action has been done.
118
+ please fix the issue to continue.`, err);
119
+ }
120
+ }));
121
+ }
122
+ this.logger.consoleSuccess();
123
+ }
124
+ async loadComponentsToEject() {
125
+ const {
126
+ components
127
+ } = await this.consumer.loadComponents(this.idsToEject);
128
+ this.componentsToEject = components;
129
+ }
130
+ async removeComponentsFromNodeModules() {
131
+ const action = 'Eject: removing the existing components from node_modules';
132
+ this.logger.setStatusLine(action);
133
+ this.logger.debug(action);
134
+ await (0, _remove().removeComponentsFromNodeModules)(this.consumer, this.componentsToEject);
135
+ this.logger.consoleSuccess(action);
136
+ }
137
+ async installPackages() {
138
+ if (this.ejectOptions.skipDependencyInstallation) return;
139
+ this.logger.setStatusLine('Eject: installing packages using the package-manager');
140
+ const packages = this.getPackagesToInstall();
141
+ await this.install.install(packages);
142
+ }
143
+ getPackagesToInstall() {
144
+ return this.componentsToEject.map(c => (0, _pkgModules().componentIdToPackageName)(c));
145
+ }
146
+ _buildExceptionMessageWithRollbackData(action) {
147
+ return `eject failed ${action}.
148
+ your package.json (if existed) has been restored, however, some bit generated data may have been deleted, please run "bit link" to restore them.`;
149
+ }
150
+
151
+ /**
152
+ * as part of the 'eject' operation, a component is removed locally. as opposed to the remove
153
+ * command, in this case, no need to remove the objects from the scope, only remove from the
154
+ * filesystem, which means, delete the component files, untrack from .bitmap and clean
155
+ * package.json and bit.json traces.
156
+ */
157
+ async removeComponentsFiles() {
158
+ if (this.ejectOptions.keepFiles) {
159
+ return;
160
+ }
161
+ this.logger.setStatusLine('Eject: removing the components files from the filesystem');
162
+ const dataToPersist = new (_component().DataToPersist)();
163
+ this.componentsToEject.forEach(component => {
164
+ const componentMap = component.componentMap;
165
+ if (!componentMap) {
166
+ throw new Error('ComponentEjector.removeComponentsFiles expect a component to have componentMap prop');
167
+ }
168
+ const rootDir = componentMap.rootDir;
169
+ if (!rootDir) {
170
+ throw new Error('ComponentEjector.removeComponentsFiles expect a componentMap to have rootDir');
171
+ }
172
+ dataToPersist.removePath(new (_component().RemovePath)(rootDir, true));
173
+ });
174
+ dataToPersist.addBasePath(this.consumer.getPath());
175
+ await dataToPersist.persistAllToFS();
176
+ this.logger.consoleSuccess();
177
+ }
178
+ async untrackComponents() {
179
+ this.logger.debug('eject: removing the components from the .bitmap');
180
+ await this.consumer.cleanFromBitMap(this.idsToEject);
181
+ }
182
+ throwEjectError(message, originalError) {
183
+ const {
184
+ message: originalErrorMessage
185
+ } = (0, _cli().defaultErrorHandler)(originalError);
186
+ this.logger.error(`eject has stopped due to an error ${originalErrorMessage}`, originalError);
187
+ throw new Error(`${message}
188
+
189
+ got the following error: ${originalErrorMessage}`);
190
+ }
191
+ _validateIdsHaveScopesAndVersions() {
192
+ this.idsToEject.forEach(id => {
193
+ if (!id.hasScope() || !id.hasVersion()) {
194
+ throw new TypeError(`EjectComponents expects ids with scope and version, got ${id.toString()}`);
195
+ }
196
+ });
197
+ }
198
+ }
199
+ exports.ComponentsEjector = ComponentsEjector;
200
+
201
+ //# sourceMappingURL=components-ejector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_componentId","data","require","_cli","_scope","_pkgModules","_component","_remove","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentsEjector","constructor","workspace","install","logger","componentsIds","ejectOptions","consumer","idsToEject","ComponentIdList","failedComponents","modifiedComponents","stagedComponents","notExportedComponents","selfHostedExportedComponents","eject","decideWhichComponentsToEject","debug","length","loadComponentsToEject","_validateIdsHaveScopesAndVersions","removeComponentsFromNodeModules","untrackComponents","installPackages","removeComponentsFiles","writeBitMap","ejectedComponents","setStatusLine","remotes","getScopeRemotes","scope","hubExportedComponents","forEach","componentId","bitId","isExported","push","isHub","force","Promise","all","map","id","componentStatus","getComponentStatusById","modified","staged","err","throwEjectError","toString","consoleSuccess","components","loadComponents","componentsToEject","action","skipDependencyInstallation","packages","getPackagesToInstall","c","componentIdToPackageName","_buildExceptionMessageWithRollbackData","keepFiles","dataToPersist","DataToPersist","component","componentMap","Error","rootDir","removePath","RemovePath","addBasePath","getPath","persistAllToFS","cleanFromBitMap","message","originalError","originalErrorMessage","defaultErrorHandler","error","hasScope","hasVersion","exports"],"sources":["components-ejector.ts"],"sourcesContent":["/**\n * a classic use case of eject is when a user imports a component using `bit import` to update it,\n * but the user has no intention to have the code as part of the project source code.\n * the eject provides the option to delete the component locally and install it via the NPM client.\n *\n * an implementation note, the entire process is done with rollback in mind.\n * since installing the component via NPM client is an error prone process, we do it first, before\n * removing the component files, so then it's easier to rollback.\n */\nimport { Workspace } from '@teambit/workspace';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentIdList, ComponentID } from '@teambit/component-id';\nimport { defaultErrorHandler } from '@teambit/cli';\nimport { getScopeRemotes } from '@teambit/scope.remotes';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';\nimport { DataToPersist, RemovePath } from '@teambit/component.sources';\nimport { Logger } from '@teambit/logger';\nimport { InstallMain } from '@teambit/install';\nimport { removeComponentsFromNodeModules } from '@teambit/remove';\n\nexport type EjectResults = {\n ejectedComponents: ComponentIdList;\n failedComponents: FailedComponents;\n};\n\nexport type EjectOptions = {\n force?: boolean; // eject although a component is modified/staged\n keepFiles?: boolean; // keep component files on the workspace\n skipDependencyInstallation?: boolean; // skip installing the dependencies\n};\n\ntype FailedComponents = {\n modifiedComponents: ComponentIdList;\n stagedComponents: ComponentIdList;\n notExportedComponents: ComponentIdList;\n selfHostedExportedComponents: ComponentIdList;\n};\n\nexport class ComponentsEjector {\n consumer: Consumer;\n idsToEject: ComponentIdList;\n componentsToEject: Component[] = [];\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n notEjectedDependents: Array<{ dependent: Component; ejectedDependencies: Component[] }>;\n failedComponents: FailedComponents;\n constructor(\n private workspace: Workspace,\n private install: InstallMain,\n private logger: Logger,\n private componentsIds: ComponentID[],\n private ejectOptions: EjectOptions\n ) {\n this.consumer = this.workspace.consumer;\n this.idsToEject = new ComponentIdList();\n this.failedComponents = {\n modifiedComponents: new ComponentIdList(),\n stagedComponents: new ComponentIdList(),\n notExportedComponents: new ComponentIdList(),\n selfHostedExportedComponents: new ComponentIdList(),\n };\n }\n\n async eject(): Promise<EjectResults> {\n await this.decideWhichComponentsToEject();\n this.logger.debug(`${this.idsToEject.length} to eject`);\n await this.loadComponentsToEject();\n if (this.idsToEject.length) {\n this._validateIdsHaveScopesAndVersions();\n await this.removeComponentsFromNodeModules();\n await this.untrackComponents();\n await this.installPackages();\n await this.removeComponentsFiles();\n await this.consumer.writeBitMap();\n }\n this.logger.debug('eject: completed successfully');\n return {\n ejectedComponents: this.idsToEject,\n failedComponents: this.failedComponents,\n };\n }\n\n async decideWhichComponentsToEject(): Promise<void> {\n this.logger.setStatusLine('Eject: getting the components status');\n if (!this.componentsIds.length) return;\n const remotes = await getScopeRemotes(this.consumer.scope);\n const hubExportedComponents = new ComponentIdList();\n this.componentsIds.forEach((componentId) => {\n const bitId = componentId;\n if (!this.workspace.isExported(bitId)) this.failedComponents.notExportedComponents.push(bitId);\n else if (remotes.isHub(bitId.scope as string)) hubExportedComponents.push(bitId);\n else this.failedComponents.selfHostedExportedComponents.push(bitId);\n });\n if (this.ejectOptions.force) {\n this.idsToEject = hubExportedComponents;\n } else {\n await Promise.all(\n hubExportedComponents.map(async (id) => {\n try {\n const componentStatus = await this.workspace.getComponentStatusById(id);\n if (componentStatus.modified) this.failedComponents.modifiedComponents.push(id);\n else if (componentStatus.staged) this.failedComponents.stagedComponents.push(id);\n else this.idsToEject.push(id);\n } catch (err: any) {\n this.throwEjectError(\n `eject operation failed getting the status of ${id.toString()}, no action has been done.\n please fix the issue to continue.`,\n err\n );\n }\n })\n );\n }\n this.logger.consoleSuccess();\n }\n\n async loadComponentsToEject() {\n const { components } = await this.consumer.loadComponents(this.idsToEject);\n this.componentsToEject = components;\n }\n\n async removeComponentsFromNodeModules() {\n const action = 'Eject: removing the existing components from node_modules';\n this.logger.setStatusLine(action);\n this.logger.debug(action);\n await removeComponentsFromNodeModules(this.consumer, this.componentsToEject);\n this.logger.consoleSuccess(action);\n }\n\n async installPackages() {\n if (this.ejectOptions.skipDependencyInstallation) return;\n this.logger.setStatusLine('Eject: installing packages using the package-manager');\n const packages = this.getPackagesToInstall();\n await this.install.install(packages);\n }\n\n getPackagesToInstall(): string[] {\n return this.componentsToEject.map((c) => componentIdToPackageName(c));\n }\n\n _buildExceptionMessageWithRollbackData(action: string): string {\n return `eject failed ${action}.\nyour package.json (if existed) has been restored, however, some bit generated data may have been deleted, please run \"bit link\" to restore them.`;\n }\n\n /**\n * as part of the 'eject' operation, a component is removed locally. as opposed to the remove\n * command, in this case, no need to remove the objects from the scope, only remove from the\n * filesystem, which means, delete the component files, untrack from .bitmap and clean\n * package.json and bit.json traces.\n */\n private async removeComponentsFiles() {\n if (this.ejectOptions.keepFiles) {\n return;\n }\n this.logger.setStatusLine('Eject: removing the components files from the filesystem');\n const dataToPersist = new DataToPersist();\n this.componentsToEject.forEach((component) => {\n const componentMap = component.componentMap;\n if (!componentMap) {\n throw new Error('ComponentEjector.removeComponentsFiles expect a component to have componentMap prop');\n }\n const rootDir = componentMap.rootDir;\n if (!rootDir) {\n throw new Error('ComponentEjector.removeComponentsFiles expect a componentMap to have rootDir');\n }\n dataToPersist.removePath(new RemovePath(rootDir, true));\n });\n dataToPersist.addBasePath(this.consumer.getPath());\n await dataToPersist.persistAllToFS();\n this.logger.consoleSuccess();\n }\n\n private async untrackComponents() {\n this.logger.debug('eject: removing the components from the .bitmap');\n await this.consumer.cleanFromBitMap(this.idsToEject);\n }\n\n throwEjectError(message: string, originalError: Error) {\n const { message: originalErrorMessage } = defaultErrorHandler(originalError);\n this.logger.error(`eject has stopped due to an error ${originalErrorMessage}`, originalError);\n throw new Error(`${message}\n\ngot the following error: ${originalErrorMessage}`);\n }\n\n _validateIdsHaveScopesAndVersions() {\n this.idsToEject.forEach((id) => {\n if (!id.hasScope() || !id.hasVersion()) {\n throw new TypeError(`EjectComponents expects ids with scope and version, got ${id.toString()}`);\n }\n });\n }\n}\n"],"mappings":";;;;;;AAWA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ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AC;EACtD;EAEAwC,eAAeA,CAAC0B,OAAe,EAAEC,aAAoB,EAAE;IACrD,MAAM;MAAED,OAAO,EAAEE;IAAqB,CAAC,GAAG,IAAAC,0BAAmB,EAACF,aAAa,CAAC;IAC5E,IAAI,CAACvE,MAAM,CAAC0E,KAAK,CAAC,qCAAqCF,oBAAoB,EAAE,EAAED,aAAa,CAAC;IAC7F,MAAM,IAAIT,KAAK,CAAC,GAAGQ,OAAO;AAC9B;AACA,2BAA2BE,oBAAoB,EAAE,CAAC;EAChD;EAEAxD,iCAAiCA,CAAA,EAAG;IAClC,IAAI,CAACZ,UAAU,CAACwB,OAAO,CAAEU,EAAE,IAAK;MAC9B,IAAI,CAACA,EAAE,CAACqC,QAAQ,CAAC,CAAC,IAAI,CAACrC,EAAE,CAACsC,UAAU,CAAC,CAAC,EAAE;QACtC,MAAM,IAAInF,SAAS,CAAC,2DAA2D6C,EAAE,CAACO,QAAQ,CAAC,CAAC,EAAE,CAAC;MACjG;IACF,CAAC,CAAC;EACJ;AACF;AAACgC,OAAA,CAAAjF,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Workspace } from '@teambit/workspace';
3
+ import { EjectMain } from './eject.main.runtime';
4
+ export declare class EjectCmd implements Command {
5
+ private ejectMain;
6
+ private workspace;
7
+ name: string;
8
+ description: string;
9
+ extendedDescription: string;
10
+ helpUrl: string;
11
+ arguments: {
12
+ name: string;
13
+ description: string;
14
+ }[];
15
+ alias: string;
16
+ options: CommandOptions;
17
+ loader: boolean;
18
+ group: string;
19
+ constructor(ejectMain: EjectMain, workspace: Workspace);
20
+ report([pattern]: [string], { force, json, keepFiles, skipDependencyInstallation, }: {
21
+ force: boolean;
22
+ json: boolean;
23
+ keepFiles: boolean;
24
+ skipDependencyInstallation?: boolean;
25
+ }): Promise<string>;
26
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EjectCmd = void 0;
7
+ function _legacy() {
8
+ const data = require("@teambit/legacy.constants");
9
+ _legacy = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _ejectTemplate() {
15
+ const data = require("./eject-template");
16
+ _ejectTemplate = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ 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); }
24
+ class EjectCmd {
25
+ constructor(ejectMain, workspace) {
26
+ this.ejectMain = ejectMain;
27
+ this.workspace = workspace;
28
+ _defineProperty(this, "name", 'eject <component-pattern>');
29
+ _defineProperty(this, "description", 'remove component from the workspace and install it instead as a regular npm package.');
30
+ _defineProperty(this, "extendedDescription", 'By default the component files will be removed from the workspace');
31
+ _defineProperty(this, "helpUrl", 'reference/components/exporting-components#ejecting-components');
32
+ _defineProperty(this, "arguments", [{
33
+ name: 'component-pattern',
34
+ description: _legacy().COMPONENT_PATTERN_HELP
35
+ }]);
36
+ _defineProperty(this, "alias", 'E');
37
+ _defineProperty(this, "options", [['f', 'force', 'ignore local changes/versions. eject component/s even when they are staged or modified. Note: unexported tags/snaps will be lost'], ['x', 'skip-dependency-installation', 'do not auto-install dependencies'], ['j', 'json', 'print the results in JSON format'], ['', 'keep-files', 'keep the component files in the workspace intact']]);
38
+ _defineProperty(this, "loader", true);
39
+ _defineProperty(this, "group", 'dependencies');
40
+ }
41
+ async report([pattern], {
42
+ force = false,
43
+ json = false,
44
+ keepFiles = false,
45
+ skipDependencyInstallation
46
+ }) {
47
+ const componentIds = await this.workspace.idsByPattern(pattern);
48
+ const ejectResults = await this.ejectMain.eject(componentIds, {
49
+ force,
50
+ keepFiles,
51
+ skipDependencyInstallation
52
+ });
53
+ if (json) return JSON.stringify(ejectResults, null, 2);
54
+ return (0, _ejectTemplate().ejectTemplate)(ejectResults);
55
+ }
56
+ }
57
+ exports.EjectCmd = EjectCmd;
58
+
59
+ //# sourceMappingURL=eject-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_legacy","data","require","_ejectTemplate","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","EjectCmd","constructor","ejectMain","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","force","json","keepFiles","skipDependencyInstallation","componentIds","idsByPattern","ejectResults","eject","JSON","stringify","ejectTemplate","exports"],"sources":["eject-cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { Workspace } from '@teambit/workspace';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport { ejectTemplate } from './eject-template';\nimport { EjectMain } from './eject.main.runtime';\n\nexport class EjectCmd implements Command {\n name = 'eject <component-pattern>';\n description = 'remove component from the workspace and install it instead as a regular npm package.';\n extendedDescription = 'By default the component files will be removed from the workspace';\n helpUrl = 'reference/components/exporting-components#ejecting-components';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n alias = 'E';\n options = [\n [\n 'f',\n 'force',\n 'ignore local changes/versions. eject component/s even when they are staged or modified. Note: unexported tags/snaps will be lost',\n ],\n ['x', 'skip-dependency-installation', 'do not auto-install dependencies'],\n ['j', 'json', 'print the results in JSON format'],\n ['', 'keep-files', 'keep the component files in the workspace intact'],\n ] as CommandOptions;\n loader = true;\n group = 'dependencies';\n\n constructor(\n private ejectMain: EjectMain,\n private workspace: Workspace\n ) {}\n\n async report(\n [pattern]: [string],\n {\n force = false,\n json = false,\n keepFiles = false,\n skipDependencyInstallation,\n }: {\n force: boolean;\n json: boolean;\n keepFiles: boolean;\n skipDependencyInstallation?: boolean;\n }\n ): Promise<string> {\n const componentIds = await this.workspace.idsByPattern(pattern);\n const ejectResults = await this.ejectMain.eject(componentIds, { force, keepFiles, skipDependencyInstallation });\n if (json) return JSON.stringify(ejectResults, null, 2);\n return ejectTemplate(ejectResults);\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,eAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,cAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiD,SAAAG,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAA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;AAACK,OAAA,CAAApB,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { EjectResults } from './components-ejector';
2
+ export declare const successEjectMessage = "successfully ejected the following components";
3
+ export declare const failureEjectMessage = "failed to eject the following components";
4
+ export declare function ejectTemplate(ejectResults: EjectResults): string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ejectTemplate = ejectTemplate;
7
+ exports.successEjectMessage = exports.failureEjectMessage = void 0;
8
+ function _chalk() {
9
+ const data = _interopRequireDefault(require("chalk"));
10
+ _chalk = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _legacy() {
16
+ const data = require("@teambit/legacy.constants");
17
+ _legacy = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
+ const successEjectMessage = exports.successEjectMessage = 'successfully ejected the following components';
24
+ const failureEjectMessage = exports.failureEjectMessage = 'failed to eject the following components';
25
+ function ejectTemplate(ejectResults) {
26
+ const getEjectedOutput = () => {
27
+ if (!ejectResults.ejectedComponents.length) return '';
28
+ return _chalk().default.green(`${successEjectMessage} ${_chalk().default.bold(ejectResults.ejectedComponents.toString())}\n`);
29
+ };
30
+ const getFailureOutput = () => {
31
+ const failures = ejectResults.failedComponents;
32
+ const title = _chalk().default.red(`${failureEjectMessage}\n`);
33
+ const modified = failures.modifiedComponents.length ? `stopped the eject process for the following components because they have local changes.
34
+ ${_chalk().default.bold(failures.modifiedComponents.toString())}
35
+ ejecting modified components discards all local, unstaged, changes.
36
+ use 'bit diff <component id>' to see the changes and decide if to 'bit tag' them or not.
37
+ use the '--force' flag to discard local modifications and proceed with the eject process.\n` : '';
38
+ const staged = failures.stagedComponents.length ? `components with local versions (use --force to ignore): ${failures.stagedComponents.toString()}\n` : '';
39
+ const notExported = failures.notExportedComponents.length ? `local components that were not exported yet: ${failures.notExportedComponents.toString()}\n` : '';
40
+ const selfHosted = failures.selfHostedExportedComponents.length ? `components that were exported to a self hosted scope (not ${(0, _legacy().getCloudDomain)()}): ${failures.selfHostedExportedComponents.toString()}\n` : '';
41
+ const body = modified + staged + notExported + selfHosted;
42
+ if (body) return _chalk().default.underline(title) + _chalk().default.red(body);
43
+ return '';
44
+ };
45
+ return getEjectedOutput() + getFailureOutput();
46
+ }
47
+
48
+ //# sourceMappingURL=eject-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_legacy","e","__esModule","default","successEjectMessage","exports","failureEjectMessage","ejectTemplate","ejectResults","getEjectedOutput","ejectedComponents","length","chalk","green","bold","toString","getFailureOutput","failures","failedComponents","title","red","modified","modifiedComponents","staged","stagedComponents","notExported","notExportedComponents","selfHosted","selfHostedExportedComponents","getCloudDomain","body","underline"],"sources":["eject-template.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { getCloudDomain } from '@teambit/legacy.constants';\nimport { EjectResults } from './components-ejector';\n\nexport const successEjectMessage = 'successfully ejected the following components';\nexport const failureEjectMessage = 'failed to eject the following components';\n\nexport function ejectTemplate(ejectResults: EjectResults): string {\n const getEjectedOutput = () => {\n if (!ejectResults.ejectedComponents.length) return '';\n return chalk.green(`${successEjectMessage} ${chalk.bold(ejectResults.ejectedComponents.toString())}\\n`);\n };\n const getFailureOutput = () => {\n const failures = ejectResults.failedComponents;\n const title = chalk.red(`${failureEjectMessage}\\n`);\n const modified = failures.modifiedComponents.length\n ? `stopped the eject process for the following components because they have local changes.\n${chalk.bold(failures.modifiedComponents.toString())}\nejecting modified components discards all local, unstaged, changes.\nuse 'bit diff <component id>' to see the changes and decide if to 'bit tag' them or not.\nuse the '--force' flag to discard local modifications and proceed with the eject process.\\n`\n : '';\n const staged = failures.stagedComponents.length\n ? `components with local versions (use --force to ignore): ${failures.stagedComponents.toString()}\\n`\n : '';\n const notExported = failures.notExportedComponents.length\n ? `local components that were not exported yet: ${failures.notExportedComponents.toString()}\\n`\n : '';\n const selfHosted = failures.selfHostedExportedComponents.length\n ? `components that were exported to a self hosted scope (not ${getCloudDomain()}): ${failures.selfHostedExportedComponents.toString()}\\n`\n : '';\n const body = modified + staged + notExported + selfHosted;\n if (body) return chalk.underline(title) + chalk.red(body);\n return '';\n };\n return getEjectedOutput() + getFailureOutput();\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2D,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGpD,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,+CAA+C;AAC3E,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,0CAA0C;AAEtE,SAASC,aAAaA,CAACC,YAA0B,EAAU;EAChE,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;IAC7B,IAAI,CAACD,YAAY,CAACE,iBAAiB,CAACC,MAAM,EAAE,OAAO,EAAE;IACrD,OAAOC,gBAAK,CAACC,KAAK,CAAC,GAAGT,mBAAmB,IAAIQ,gBAAK,CAACE,IAAI,CAACN,YAAY,CAACE,iBAAiB,CAACK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;EACzG,CAAC;EACD,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;IAC7B,MAAMC,QAAQ,GAAGT,YAAY,CAACU,gBAAgB;IAC9C,MAAMC,KAAK,GAAGP,gBAAK,CAACQ,GAAG,CAAC,GAAGd,mBAAmB,IAAI,CAAC;IACnD,MAAMe,QAAQ,GAAGJ,QAAQ,CAACK,kBAAkB,CAACX,MAAM,GAC/C;AACR,EAAEC,gBAAK,CAACE,IAAI,CAACG,QAAQ,CAACK,kBAAkB,CAACP,QAAQ,CAAC,CAAC,CAAC;AACpD;AACA;AACA,4FAA4F,GACpF,EAAE;IACN,MAAMQ,MAAM,GAAGN,QAAQ,CAACO,gBAAgB,CAACb,MAAM,GAC3C,2DAA2DM,QAAQ,CAACO,gBAAgB,CAACT,QAAQ,CAAC,CAAC,IAAI,GACnG,EAAE;IACN,MAAMU,WAAW,GAAGR,QAAQ,CAACS,qBAAqB,CAACf,MAAM,GACrD,gDAAgDM,QAAQ,CAACS,qBAAqB,CAACX,QAAQ,CAAC,CAAC,IAAI,GAC7F,EAAE;IACN,MAAMY,UAAU,GAAGV,QAAQ,CAACW,4BAA4B,CAACjB,MAAM,GAC3D,6DAA6D,IAAAkB,wBAAc,EAAC,CAAC,MAAMZ,QAAQ,CAACW,4BAA4B,CAACb,QAAQ,CAAC,CAAC,IAAI,GACvI,EAAE;IACN,MAAMe,IAAI,GAAGT,QAAQ,GAAGE,MAAM,GAAGE,WAAW,GAAGE,UAAU;IACzD,IAAIG,IAAI,EAAE,OAAOlB,gBAAK,CAACmB,SAAS,CAACZ,KAAK,CAAC,GAAGP,gBAAK,CAACQ,GAAG,CAACU,IAAI,CAAC;IACzD,OAAO,EAAE;EACX,CAAC;EACD,OAAOrB,gBAAgB,CAAC,CAAC,GAAGO,gBAAgB,CAAC,CAAC;AAChD","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const EjectAspect: Aspect;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EjectAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const EjectAspect = exports.EjectAspect = _harmony().Aspect.create({
15
+ id: 'teambit.workspace/eject'
16
+ });
17
+
18
+ //# sourceMappingURL=eject.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","EjectAspect","exports","Aspect","create","id"],"sources":["eject.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const EjectAspect = Aspect.create({\n id: 'teambit.workspace/eject',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACvCC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Logo = void 0;
7
+ function _react() {
8
+ const data = _interopRequireDefault(require("react"));
9
+ _react = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
16
+ style: {
17
+ height: '100%',
18
+ display: 'flex',
19
+ justifyContent: 'center'
20
+ }
21
+ }, /*#__PURE__*/_react().default.createElement("img", {
22
+ style: {
23
+ width: 70
24
+ },
25
+ src: "https://static.bit.dev/extensions-icons/eject.svg"
26
+ }));
27
+ exports.Logo = Logo;
28
+
29
+ //# sourceMappingURL=eject.composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","data","_interopRequireDefault","require","e","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"sources":["eject.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/eject.svg\" />\n </div>\n);\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAmD,CAAE,CACjF,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Replaces a Workspace component with an external dependency
3
+ labels: ['aspect', 'cli']
4
+ ---
5
+
6
+ One of the common scenarios of using `bit eject` is to make a quick change to an external (component) dependency. The component needs to be imported first and once it's changed and exported, there is no need to keep it in the current workspace. Without `eject`, the next steps would be: 1) remove the component from the workspace by `bit remove` and 2) installing the component by `bit install`.
7
+
8
+ `bit eject` combines the commands above to one command.
9
+
10
+ ## Eject process
11
+
12
+ The following steps are done during the `eject` process.
13
+
14
+ 1. remove the component's data from node-modules so then it won't interfere with the package installation.
15
+ 2. remove the component from the .bitmap file.
16
+ 3. install the component as a package by the package manager and add the package to the `workspace.json` file.
17
+ 4. depends on the `--keep-files` flag, deletes the component files from the workspace.
@@ -0,0 +1,16 @@
1
+ import { CLIMain } from '@teambit/cli';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { Logger, LoggerMain } from '@teambit/logger';
4
+ import { Workspace } from '@teambit/workspace';
5
+ import { InstallMain } from '@teambit/install';
6
+ import { EjectOptions, EjectResults } from './components-ejector';
7
+ export declare class EjectMain {
8
+ private workspace;
9
+ private install;
10
+ private logger;
11
+ constructor(workspace: Workspace, install: InstallMain, logger: Logger);
12
+ eject(componentIds: ComponentID[], ejectOptions?: EjectOptions): Promise<EjectResults>;
13
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
14
+ static dependencies: import("@teambit/harmony").Aspect[];
15
+ static provider([cli, workspace, loggerMain, install]: [CLIMain, Workspace, LoggerMain, InstallMain]): Promise<EjectMain>;
16
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EjectMain = void 0;
7
+ function _cli() {
8
+ const data = require("@teambit/cli");
9
+ _cli = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _logger() {
15
+ const data = require("@teambit/logger");
16
+ _logger = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _workspace() {
22
+ const data = require("@teambit/workspace");
23
+ _workspace = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _install() {
29
+ const data = require("@teambit/install");
30
+ _install = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _ejectCmd() {
36
+ const data = require("./eject-cmd");
37
+ _ejectCmd = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _eject() {
43
+ const data = require("./eject.aspect");
44
+ _eject = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _componentsEjector() {
50
+ const data = require("./components-ejector");
51
+ _componentsEjector = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ 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; }
57
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
58
+ 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); }
59
+ class EjectMain {
60
+ constructor(workspace, install, logger) {
61
+ this.workspace = workspace;
62
+ this.install = install;
63
+ this.logger = logger;
64
+ }
65
+ async eject(componentIds, ejectOptions = {}) {
66
+ if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
67
+ if (this.workspace.isOnLane()) {
68
+ throw new Error('unable to eject when the workspace is on a lane, please use "bit lane eject" to delete the component from the lane and install the main version');
69
+ }
70
+ const componentEjector = new (_componentsEjector().ComponentsEjector)(this.workspace, this.install, this.logger, componentIds, ejectOptions);
71
+ return componentEjector.eject();
72
+ }
73
+ static async provider([cli, workspace, loggerMain, install]) {
74
+ const logger = loggerMain.createLogger(_eject().EjectAspect.id);
75
+ const ejectMain = new EjectMain(workspace, install, logger);
76
+ cli.register(new (_ejectCmd().EjectCmd)(ejectMain, workspace));
77
+ return ejectMain;
78
+ }
79
+ }
80
+ exports.EjectMain = EjectMain;
81
+ _defineProperty(EjectMain, "runtime", _cli().MainRuntime);
82
+ _defineProperty(EjectMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _logger().LoggerAspect, _install().InstallAspect]);
83
+ _eject().EjectAspect.addRuntime(EjectMain);
84
+
85
+ //# sourceMappingURL=eject.main.runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_cli","data","require","_logger","_workspace","_install","_ejectCmd","_eject","_componentsEjector","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","EjectMain","constructor","workspace","install","logger","eject","componentIds","ejectOptions","OutsideWorkspaceError","isOnLane","Error","componentEjector","ComponentsEjector","provider","cli","loggerMain","createLogger","EjectAspect","id","ejectMain","register","EjectCmd","exports","MainRuntime","CLIAspect","WorkspaceAspect","LoggerAspect","InstallAspect","addRuntime"],"sources":["eject.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { WorkspaceAspect, OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { InstallAspect, InstallMain } from '@teambit/install';\nimport { EjectCmd } from './eject-cmd';\nimport { EjectAspect } from './eject.aspect';\nimport { ComponentsEjector, EjectOptions, EjectResults } from './components-ejector';\n\nexport class EjectMain {\n constructor(\n private workspace: Workspace,\n private install: InstallMain,\n private logger: Logger\n ) {}\n async eject(componentIds: ComponentID[], ejectOptions: EjectOptions = {}): Promise<EjectResults> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n if (this.workspace.isOnLane()) {\n throw new Error('unable to eject when the workspace is on a lane, please use \"bit lane eject\" to delete the component from the lane and install the main version');\n }\n const componentEjector = new ComponentsEjector(\n this.workspace,\n this.install,\n this.logger,\n componentIds,\n ejectOptions\n );\n return componentEjector.eject();\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [CLIAspect, WorkspaceAspect, LoggerAspect, InstallAspect];\n\n static async provider([cli, workspace, loggerMain, install]: [CLIMain, Workspace, LoggerMain, InstallMain]) {\n const logger = loggerMain.createLogger(EjectAspect.id);\n const ejectMain = new EjectMain(workspace, install, logger);\n cli.register(new EjectCmd(ejectMain, workspace));\n\n return ejectMain;\n }\n}\n\nEjectAspect.addRuntime(EjectMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA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KAAIC,oBAAQ,EAACF,SAAS,EAAEjB,SAAS,CAAC,CAAC;IAEhD,OAAOiB,SAAS;EAClB;AACF;AAACG,OAAA,CAAAtB,SAAA,GAAAA,SAAA;AAAAnB,eAAA,CAhCYmB,SAAS,aAqBHuB,kBAAW;AAAA1C,eAAA,CArBjBmB,SAAS,kBAuBE,CAACwB,gBAAS,EAAEC,4BAAe,EAAEC,sBAAY,EAAEC,wBAAa,CAAC;AAWjFV,oBAAW,CAACW,UAAU,CAAC5B,SAAS,CAAC","ignoreList":[]}
package/dist/esm.mjs ADDED
@@ -0,0 +1,8 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import cjsModule from './index.js';
3
+
4
+ export const successEjectMessage = cjsModule.successEjectMessage;
5
+ export const ejectTemplate = cjsModule.ejectTemplate;
6
+ export const EjectAspect = cjsModule.EjectAspect;
7
+
8
+ export default cjsModule;
@@ -0,0 +1,4 @@
1
+ export type { EjectMain } from './eject.main.runtime';
2
+ export type { EjectResults } from './components-ejector';
3
+ export { successEjectMessage, ejectTemplate } from './eject-template';
4
+ export { EjectAspect } from './eject.aspect';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EjectAspect", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _eject().EjectAspect;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ejectTemplate", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ejectTemplate().ejectTemplate;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "successEjectMessage", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ejectTemplate().successEjectMessage;
22
+ }
23
+ });
24
+ function _ejectTemplate() {
25
+ const data = require("./eject-template");
26
+ _ejectTemplate = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _eject() {
32
+ const data = require("./eject.aspect");
33
+ _eject = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ejectTemplate","data","require","_eject"],"sources":["index.ts"],"sourcesContent":["export type { EjectMain } from './eject.main.runtime';\nexport type { EjectResults } from './components-ejector';\nexport { successEjectMessage, ejectTemplate } from './eject-template';\nexport { EjectAspect } from './eject.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_eject@024c646f108d6fc8deee77282d00916bbffe422a/dist/eject.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_eject@024c646f108d6fc8deee77282d00916bbffe422a/dist/eject.docs.mdx';
3
+
4
+ export const compositions = [compositions_0];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ export const Logo = () => (
4
+ <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>
5
+ <img style={{ width: 70 }} src="https://static.bit.dev/extensions-icons/eject.svg" />
6
+ </div>
7
+ );
package/eject.docs.mdx ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Replaces a Workspace component with an external dependency
3
+ labels: ['aspect', 'cli']
4
+ ---
5
+
6
+ One of the common scenarios of using `bit eject` is to make a quick change to an external (component) dependency. The component needs to be imported first and once it's changed and exported, there is no need to keep it in the current workspace. Without `eject`, the next steps would be: 1) remove the component from the workspace by `bit remove` and 2) installing the component by `bit install`.
7
+
8
+ `bit eject` combines the commands above to one command.
9
+
10
+ ## Eject process
11
+
12
+ The following steps are done during the `eject` process.
13
+
14
+ 1. remove the component's data from node-modules so then it won't interfere with the package installation.
15
+ 2. remove the component from the .bitmap file.
16
+ 3. install the component as a package by the package manager and add the package to the `workspace.json` file.
17
+ 4. depends on the `--keep-files` flag, deletes the component files from the workspace.
package/esm.mjs ADDED
@@ -0,0 +1,8 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import cjsModule from './index.js';
3
+
4
+ export const successEjectMessage = cjsModule.successEjectMessage;
5
+ export const ejectTemplate = cjsModule.ejectTemplate;
6
+ export const EjectAspect = cjsModule.EjectAspect;
7
+
8
+ export default cjsModule;
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@teambit/eject",
3
+ "version": "0.0.0-024c646f108d6fc8deee77282d00916bbffe422a",
4
+ "homepage": "https://bit.cloud/teambit/workspace/eject",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.workspace",
8
+ "name": "eject",
9
+ "version": "024c646f108d6fc8deee77282d00916bbffe422a"
10
+ },
11
+ "dependencies": {
12
+ "chalk": "4.1.2",
13
+ "@teambit/component-id": "1.2.4",
14
+ "@teambit/harmony": "0.4.7",
15
+ "@teambit/cli": "0.0.0-fb057adf99925d2d44186453ee00564120be99f9",
16
+ "@teambit/component.sources": "0.0.106",
17
+ "@teambit/install": "0.0.0-89ff0a2041000086e352cc5e4aeeb102634cf3d3",
18
+ "@teambit/legacy.consumer-component": "0.0.55",
19
+ "@teambit/legacy.consumer": "0.0.54",
20
+ "@teambit/logger": "0.0.0-e93cbb6344c8816c28a2bce5633cfc79a755cbe5",
21
+ "@teambit/pkg.modules.component-package-name": "0.0.61",
22
+ "@teambit/remove": "0.0.0-78f030b3bb342ae420c63a81af21aac73c83bd23",
23
+ "@teambit/scope.remotes": "0.0.54",
24
+ "@teambit/workspace": "0.0.0-12b299951a32e3d28ca9a1e0e0b69f443b94fe83",
25
+ "@teambit/legacy.constants": "0.0.12"
26
+ },
27
+ "devDependencies": {
28
+ "@types/mocha": "9.1.0",
29
+ "@teambit/harmony.envs.core-aspect-env": "0.0.69"
30
+ },
31
+ "peerDependencies": {
32
+ "react": "^17.0.0 || ^18.0.0",
33
+ "@types/react": "^17.0.73"
34
+ },
35
+ "license": "Apache-2.0",
36
+ "optionalDependencies": {},
37
+ "peerDependenciesMeta": {},
38
+ "exports": {
39
+ ".": {
40
+ "node": {
41
+ "require": "./dist/index.js",
42
+ "import": "./dist/esm.mjs"
43
+ },
44
+ "default": "./dist/index.js"
45
+ },
46
+ "./dist/*": "./dist/*",
47
+ "./artifacts/*": "./artifacts/*",
48
+ "./*": "./*.ts"
49
+ },
50
+ "private": false,
51
+ "engines": {
52
+ "node": ">=16.0.0"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/teambit/bit"
57
+ },
58
+ "keywords": [
59
+ "bit",
60
+ "bit-aspect",
61
+ "bit-core-aspect",
62
+ "components",
63
+ "collaboration",
64
+ "web"
65
+ ]
66
+ }
@@ -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
+ }
@@ -0,0 +1,42 @@
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
+ }