@teambit/workspace 0.0.555 → 0.0.556
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/package.json +56 -50
- package/build-graph-from-fs.ts +0 -160
- package/capsule.cmd.ts +0 -136
- package/component-config-file/component-config-file.ts +0 -98
- package/component-config-file/exceptions/already-exists.ts +0 -7
- package/component-config-file/exceptions/index.ts +0 -1
- package/component-config-file/index.ts +0 -2
- package/component-tree.widget.tsx +0 -16
- package/constants.ts +0 -1
- package/eject-conf.cmd.tsx +0 -62
- package/events/index.ts +0 -3
- package/events/on-component-add-event.ts +0 -14
- package/events/on-component-change-event.ts +0 -14
- package/events/on-component-removed-event.ts +0 -14
- package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
- package/exceptions/incorrect-env-aspect.ts +0 -8
- package/exceptions/index.ts +0 -1
- package/index.ts +0 -19
- package/install.cmd.tsx +0 -67
- package/link/component-list-links.ts +0 -50
- package/link/core-aspects-links.ts +0 -50
- package/link/get-package-name-from-target.ts +0 -5
- package/link/index.ts +0 -1
- package/link/link-row.ts +0 -20
- package/link/link-to-dir.ts +0 -13
- package/link/link.cmd.ts +0 -96
- package/link/nested-deps-in-nm-links.ts +0 -47
- package/link/rewire-row.ts +0 -17
- package/list.cmd.tsx +0 -30
- package/on-component-events.ts +0 -14
- package/package-tar/teambit-workspace-0.0.555.tgz +0 -0
- package/tag-cmd.ts +0 -247
- package/tsconfig.json +0 -34
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/types.ts +0 -40
- package/ui/index.ts +0 -1
- package/ui/workspace/default-component.ts +0 -7
- package/ui/workspace/index.ts +0 -1
- package/ui/workspace/use-workspace.ts +0 -193
- package/ui/workspace/workspace-context.tsx +0 -5
- package/ui/workspace/workspace-model.ts +0 -66
- package/ui/workspace/workspace-overview/index.ts +0 -1
- package/ui/workspace/workspace-overview/workspace-overview.module.scss +0 -6
- package/ui/workspace/workspace-overview/workspace-overview.tsx +0 -21
- package/ui/workspace/workspace-provider.tsx +0 -23
- package/ui/workspace/workspace.module.scss +0 -40
- package/ui/workspace/workspace.tsx +0 -99
- package/ui/workspace-components-drawer/index.ts +0 -1
- package/ui/workspace-components-drawer/workspace-components-drawer.module.scss +0 -4
- package/ui/workspace-components-drawer/workspace-components.drawer.tsx +0 -49
- package/watch/REFACTOR_GUIDE.md +0 -14
- package/watch/check-types.ts +0 -5
- package/watch/output-formatter.ts +0 -50
- package/watch/watch.cmd.tsx +0 -142
- package/watch/watcher.ts +0 -289
- package/workspace-component/component-status.ts +0 -67
- package/workspace-component/index.ts +0 -2
- package/workspace-component/workspace-component-loader.ts +0 -276
- package/workspace-component/workspace-component.ts +0 -51
- package/workspace-section.ts +0 -14
- package/workspace.aspect.ts +0 -9
- package/workspace.graphql.ts +0 -133
- package/workspace.main.runtime.ts +0 -50
- package/workspace.provider.ts +0 -218
- package/workspace.ts +0 -1539
- package/workspace.ui-root.ts +0 -64
- package/workspace.ui.runtime.tsx +0 -215
package/tag-cmd.ts
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import semver, { ReleaseType } from 'semver';
|
|
3
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
4
|
-
import { tagAction } from '@teambit/legacy/dist/api/consumer';
|
|
5
|
-
import {
|
|
6
|
-
TagResults,
|
|
7
|
-
NOTHING_TO_TAG_MSG,
|
|
8
|
-
AUTO_TAGGED_MSG,
|
|
9
|
-
BasicTagParams,
|
|
10
|
-
} from '@teambit/legacy/dist/api/consumer/lib/tag';
|
|
11
|
-
import { isString } from '@teambit/legacy/dist/utils';
|
|
12
|
-
import { DEFAULT_BIT_RELEASE_TYPE, BASE_DOCS_DOMAIN, WILDCARD_HELP } from '@teambit/legacy/dist/constants';
|
|
13
|
-
import GeneralError from '@teambit/legacy/dist/error/general-error';
|
|
14
|
-
import { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';
|
|
15
|
-
|
|
16
|
-
export class Tag implements Command {
|
|
17
|
-
name = 'tag [id...]';
|
|
18
|
-
group = 'development';
|
|
19
|
-
shortDescription = 'record component changes and lock versions';
|
|
20
|
-
description = `record component changes and lock versions.
|
|
21
|
-
if component ids are entered, you can specify a version per id using "@" sign, e.g. bit tag foo@1.0.0 bar@minor baz@major
|
|
22
|
-
https://${BASE_DOCS_DOMAIN}/docs/tag-component-version
|
|
23
|
-
${WILDCARD_HELP('tag')}`;
|
|
24
|
-
alias = 't';
|
|
25
|
-
loader = true;
|
|
26
|
-
options = [
|
|
27
|
-
['m', 'message <message>', 'log message describing the user changes'],
|
|
28
|
-
['a', 'all [version]', 'tag all new and modified components'],
|
|
29
|
-
['s', 'scope [version]', 'tag all components of the current scope'],
|
|
30
|
-
['', 'snapped [version]', 'tag components that their head is a snap (not a tag)'],
|
|
31
|
-
['', 'ver <version>', 'tag specified components with the given version'],
|
|
32
|
-
['p', 'patch', 'increment the patch version number'],
|
|
33
|
-
['', 'minor', 'increment the minor version number'],
|
|
34
|
-
['', 'major', 'increment the major version number'],
|
|
35
|
-
['', 'pre-release [identifier]', 'EXPERIMENTAL. increment a pre-release version (e.g. 1.0.0-dev.1)'],
|
|
36
|
-
['f', 'force', 'force-tag even if tests are failing and even when component has not changed'],
|
|
37
|
-
['v', 'verbose', 'show specs output on failure'],
|
|
38
|
-
['', 'ignore-unresolved-dependencies', 'DEPRECATED. use --ignore-issues instead'],
|
|
39
|
-
['i', 'ignore-issues', 'ignore component issues (shown in "bit status" as "issues found")'],
|
|
40
|
-
['I', 'ignore-newest-version', 'ignore existing of newer versions (default = false)'],
|
|
41
|
-
['', 'skip-tests', 'skip running component tests during tag process'],
|
|
42
|
-
['', 'skip-auto-tag', 'skip auto tagging dependents'],
|
|
43
|
-
['b', 'build', 'EXPERIMENTAL. not needed for now. run the pipeline build and complete the tag'],
|
|
44
|
-
['', 'soft', 'do not persist. only keep note of the changes to be made'],
|
|
45
|
-
['', 'persist', 'persist the changes generated by --soft tag'],
|
|
46
|
-
['', 'disable-deploy-pipeline', 'DEPRECATED. use --disable-tag-pipeline instead'],
|
|
47
|
-
['', 'disable-tag-pipeline', 'skip the tag pipeline to avoid publishing the components'],
|
|
48
|
-
['', 'force-deploy', 'run the tag pipeline although the build failed'],
|
|
49
|
-
[
|
|
50
|
-
'',
|
|
51
|
-
'increment-by <number>',
|
|
52
|
-
'(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.',
|
|
53
|
-
],
|
|
54
|
-
] as CommandOptions;
|
|
55
|
-
migration = true;
|
|
56
|
-
remoteOp = true; // In case a compiler / tester is not installed
|
|
57
|
-
|
|
58
|
-
// eslint-disable-next-line complexity
|
|
59
|
-
async report(
|
|
60
|
-
[id = []]: [string[]],
|
|
61
|
-
{
|
|
62
|
-
message = '',
|
|
63
|
-
ver,
|
|
64
|
-
all = false,
|
|
65
|
-
snapped = false,
|
|
66
|
-
patch,
|
|
67
|
-
minor,
|
|
68
|
-
major,
|
|
69
|
-
preRelease,
|
|
70
|
-
force = false,
|
|
71
|
-
verbose = false,
|
|
72
|
-
ignoreUnresolvedDependencies,
|
|
73
|
-
ignoreIssues = false,
|
|
74
|
-
ignoreNewestVersion = false,
|
|
75
|
-
skipTests = false,
|
|
76
|
-
skipAutoTag = false,
|
|
77
|
-
scope,
|
|
78
|
-
build,
|
|
79
|
-
soft = false,
|
|
80
|
-
persist = false,
|
|
81
|
-
disableDeployPipeline = false,
|
|
82
|
-
disableTagPipeline = false,
|
|
83
|
-
forceDeploy = false,
|
|
84
|
-
incrementBy = 1,
|
|
85
|
-
}: {
|
|
86
|
-
all?: boolean | string;
|
|
87
|
-
snapped?: boolean | string;
|
|
88
|
-
ver?: string;
|
|
89
|
-
patch?: boolean;
|
|
90
|
-
minor?: boolean;
|
|
91
|
-
major?: boolean;
|
|
92
|
-
ignoreUnresolvedDependencies?: boolean;
|
|
93
|
-
ignoreIssues?: boolean;
|
|
94
|
-
scope?: string | boolean;
|
|
95
|
-
incrementBy?: number;
|
|
96
|
-
disableDeployPipeline?: boolean;
|
|
97
|
-
disableTagPipeline?: boolean;
|
|
98
|
-
} & Partial<BasicTagParams>
|
|
99
|
-
): Promise<string> {
|
|
100
|
-
build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;
|
|
101
|
-
if (soft) build = false;
|
|
102
|
-
function getVersion(): string | undefined {
|
|
103
|
-
if (scope && isString(scope)) return scope;
|
|
104
|
-
if (all && isString(all)) return all;
|
|
105
|
-
if (snapped && isString(snapped)) return snapped;
|
|
106
|
-
return ver;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!id.length && !all && !snapped && !scope && !persist) {
|
|
110
|
-
throw new GeneralError('missing [id]. to tag all components, please use --all flag');
|
|
111
|
-
}
|
|
112
|
-
if (id.length && all) {
|
|
113
|
-
throw new GeneralError(
|
|
114
|
-
'you can use either a specific component [id] to tag a particular component or --all flag to tag them all'
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
if (typeof ignoreUnresolvedDependencies === 'boolean') {
|
|
118
|
-
ignoreIssues = ignoreUnresolvedDependencies;
|
|
119
|
-
}
|
|
120
|
-
if (id.length === 2) {
|
|
121
|
-
const secondArg = id[1];
|
|
122
|
-
// previously, the synopsis of this command was `bit tag [id] [version]`, show a descriptive
|
|
123
|
-
// error when users still use it.
|
|
124
|
-
if (semver.valid(secondArg)) {
|
|
125
|
-
throw new GeneralError(
|
|
126
|
-
`seems like you entered a version as the second arg, this is not supported anymore, please use "@" sign or --ver flag instead`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const disableTagAndSnapPipelines = disableTagPipeline || disableDeployPipeline;
|
|
131
|
-
if (disableTagAndSnapPipelines && forceDeploy) {
|
|
132
|
-
throw new GeneralError('you can use either force-deploy or disable-tag-pipeline, but not both');
|
|
133
|
-
}
|
|
134
|
-
if (all && persist) {
|
|
135
|
-
throw new GeneralError('you can use either --all or --persist, but not both');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const releaseFlags = [patch, minor, major, preRelease].filter((x) => x);
|
|
139
|
-
if (releaseFlags.length > 1) {
|
|
140
|
-
throw new GeneralError('you can use only one of the following - patch, minor, major, pre-release');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let releaseType: ReleaseType = DEFAULT_BIT_RELEASE_TYPE;
|
|
144
|
-
const includeImported = Boolean(scope && all);
|
|
145
|
-
|
|
146
|
-
if (major) releaseType = 'major';
|
|
147
|
-
else if (minor) releaseType = 'minor';
|
|
148
|
-
else if (patch) releaseType = 'patch';
|
|
149
|
-
else if (preRelease) releaseType = 'prerelease';
|
|
150
|
-
|
|
151
|
-
const params = {
|
|
152
|
-
ids: id,
|
|
153
|
-
all: Boolean(all),
|
|
154
|
-
snapped: Boolean(snapped),
|
|
155
|
-
message,
|
|
156
|
-
exactVersion: getVersion(),
|
|
157
|
-
releaseType,
|
|
158
|
-
preRelease: typeof preRelease === 'string' ? preRelease : '',
|
|
159
|
-
force,
|
|
160
|
-
verbose,
|
|
161
|
-
ignoreIssues,
|
|
162
|
-
ignoreNewestVersion,
|
|
163
|
-
skipTests,
|
|
164
|
-
skipAutoTag,
|
|
165
|
-
build,
|
|
166
|
-
soft,
|
|
167
|
-
persist,
|
|
168
|
-
scope,
|
|
169
|
-
includeImported,
|
|
170
|
-
disableTagAndSnapPipelines,
|
|
171
|
-
forceDeploy,
|
|
172
|
-
incrementBy,
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const results = await tagAction(params);
|
|
176
|
-
if (!results) return chalk.yellow(NOTHING_TO_TAG_MSG);
|
|
177
|
-
const { taggedComponents, autoTaggedResults, warnings, newComponents }: TagResults = results;
|
|
178
|
-
const changedComponents = taggedComponents.filter((component) => !newComponents.searchWithoutVersion(component.id));
|
|
179
|
-
const addedComponents = taggedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));
|
|
180
|
-
const autoTaggedCount = autoTaggedResults ? autoTaggedResults.length : 0;
|
|
181
|
-
|
|
182
|
-
const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\n'))}\n\n` : '';
|
|
183
|
-
const tagExplanationPersist = `\n(use "bit export [collection]" to push these components to a remote")
|
|
184
|
-
(use "bit untag" to unstage versions)\n`;
|
|
185
|
-
const tagExplanationSoft = `\n(use "bit tag --persist" to persist the changes")
|
|
186
|
-
(use "bit untag --soft" to remove the soft-tags)\n`;
|
|
187
|
-
|
|
188
|
-
const tagExplanation = results.isSoftTag ? tagExplanationSoft : tagExplanationPersist;
|
|
189
|
-
|
|
190
|
-
const outputComponents = (comps) => {
|
|
191
|
-
return comps
|
|
192
|
-
.map((component) => {
|
|
193
|
-
let componentOutput = ` > ${component.id.toString()}`;
|
|
194
|
-
const autoTag = autoTaggedResults.filter((result) =>
|
|
195
|
-
result.triggeredBy.searchWithoutScopeAndVersion(component.id)
|
|
196
|
-
);
|
|
197
|
-
if (autoTag.length) {
|
|
198
|
-
const autoTagComp = autoTag.map((a) => a.component.id.toString());
|
|
199
|
-
componentOutput += `\n ${AUTO_TAGGED_MSG}:
|
|
200
|
-
${autoTagComp.join('\n ')}`;
|
|
201
|
-
}
|
|
202
|
-
return componentOutput;
|
|
203
|
-
})
|
|
204
|
-
.join('\n');
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const publishOutput = () => {
|
|
208
|
-
const { publishedPackages } = results;
|
|
209
|
-
if (!publishedPackages || !publishedPackages.length) return '';
|
|
210
|
-
const successTitle = `\n\n${chalk.green(
|
|
211
|
-
`published the following ${publishedPackages.length} component(s) successfully\n`
|
|
212
|
-
)}`;
|
|
213
|
-
const successCompsStr = publishedPackages.join('\n');
|
|
214
|
-
const successOutput = successCompsStr ? successTitle + successCompsStr : '';
|
|
215
|
-
return successOutput;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const softTagPrefix = results.isSoftTag ? 'soft-tagged ' : '';
|
|
219
|
-
const outputIfExists = (label, explanation, components) => {
|
|
220
|
-
if (!components.length) return '';
|
|
221
|
-
return `\n${chalk.underline(softTagPrefix + label)}\n(${explanation})\n${outputComponents(components)}\n`;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const newDesc = results.isSoftTag
|
|
225
|
-
? 'set to be tagged first version for components'
|
|
226
|
-
: 'first version for components';
|
|
227
|
-
const changedDesc = results.isSoftTag
|
|
228
|
-
? 'components that set to get a version bump'
|
|
229
|
-
: 'components that got a version bump';
|
|
230
|
-
const softTagClarification = results.isSoftTag
|
|
231
|
-
? chalk.bold(
|
|
232
|
-
'keep in mind that this is a soft-tag (changes recorded to be tagged), to persist the changes use --persist flag'
|
|
233
|
-
)
|
|
234
|
-
: '';
|
|
235
|
-
return (
|
|
236
|
-
warningsOutput +
|
|
237
|
-
chalk.green(
|
|
238
|
-
`${taggedComponents.length + autoTaggedCount} component(s) ${results.isSoftTag ? 'soft-' : ''}tagged`
|
|
239
|
-
) +
|
|
240
|
-
tagExplanation +
|
|
241
|
-
outputIfExists('new components', newDesc, addedComponents) +
|
|
242
|
-
outputIfExists('changed components', changedDesc, changedComponents) +
|
|
243
|
-
publishOutput() +
|
|
244
|
-
softTagClarification
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
"es2019",
|
|
5
|
-
"DOM",
|
|
6
|
-
"ES6",
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ScriptHost"
|
|
9
|
-
],
|
|
10
|
-
"target": "es2015",
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
|
-
"composite": true,
|
|
20
|
-
"emitDeclarationOnly": true,
|
|
21
|
-
"experimentalDecorators": true,
|
|
22
|
-
"emitDecoratorMetadata": true,
|
|
23
|
-
"allowSyntheticDefaultImports": true,
|
|
24
|
-
"strictPropertyInitialization": false,
|
|
25
|
-
"strict": true,
|
|
26
|
-
"noImplicitAny": false,
|
|
27
|
-
"rootDir": ".",
|
|
28
|
-
"preserveConstEnums": true,
|
|
29
|
-
"resolveJsonModule": true
|
|
30
|
-
},
|
|
31
|
-
"exclude": [
|
|
32
|
-
"dist"
|
|
33
|
-
]
|
|
34
|
-
}
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
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
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|
package/types.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
interface VendorConfig {
|
|
2
|
-
directory: string;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface WorkspaceExtConfig {
|
|
6
|
-
/**
|
|
7
|
-
* name of the workspace.
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* path to icon.
|
|
13
|
-
*/
|
|
14
|
-
icon: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* applies only on bit.dev. configure the main owner of your workspace
|
|
18
|
-
*/
|
|
19
|
-
defaultOwner: string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* set the default scope when there is no matching for the component in the components array.
|
|
23
|
-
*/
|
|
24
|
-
defaultScope: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* set the default directory when there is no matching for the component in the components array.
|
|
28
|
-
*/
|
|
29
|
-
defaultDirectory: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* set the default structure of components in your project
|
|
33
|
-
*/
|
|
34
|
-
vendor: VendorConfig;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* All component extensions applied by default on all components in the workspace (except vendor components)
|
|
38
|
-
*/
|
|
39
|
-
extensions: { [extensionsId: string]: string };
|
|
40
|
-
}
|
package/ui/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Workspace } from './workspace';
|
package/ui/workspace/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './workspace';
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo } from 'react';
|
|
2
|
-
import { ComponentModel } from '@teambit/component';
|
|
3
|
-
import useLatest from '@react-hook/latest';
|
|
4
|
-
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
|
|
5
|
-
import { gql } from '@apollo/client';
|
|
6
|
-
import { ComponentID, ComponentIdObj } from '@teambit/component-id';
|
|
7
|
-
|
|
8
|
-
import { Workspace } from './workspace-model';
|
|
9
|
-
|
|
10
|
-
type UseWorkspaceOptions = {
|
|
11
|
-
onComponentAdded?: (component: ComponentModel[]) => void;
|
|
12
|
-
onComponentUpdated?: (component: ComponentModel[]) => void;
|
|
13
|
-
onComponentRemoved?: (compId: ComponentID[]) => void;
|
|
14
|
-
};
|
|
15
|
-
type RawComponent = { id: ComponentIdObj };
|
|
16
|
-
|
|
17
|
-
const wcComponentFields = gql`
|
|
18
|
-
fragment wcComponentFields on Component {
|
|
19
|
-
id {
|
|
20
|
-
name
|
|
21
|
-
version
|
|
22
|
-
scope
|
|
23
|
-
}
|
|
24
|
-
compositions {
|
|
25
|
-
identifier
|
|
26
|
-
}
|
|
27
|
-
description
|
|
28
|
-
issuesCount
|
|
29
|
-
status {
|
|
30
|
-
isOutdated
|
|
31
|
-
isNew
|
|
32
|
-
isInScope
|
|
33
|
-
isStaged
|
|
34
|
-
modifyInfo {
|
|
35
|
-
hasModifiedFiles
|
|
36
|
-
hasModifiedDependencies
|
|
37
|
-
}
|
|
38
|
-
isDeleted
|
|
39
|
-
}
|
|
40
|
-
deprecation {
|
|
41
|
-
isDeprecate
|
|
42
|
-
}
|
|
43
|
-
server {
|
|
44
|
-
env
|
|
45
|
-
url
|
|
46
|
-
}
|
|
47
|
-
env {
|
|
48
|
-
id
|
|
49
|
-
icon
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
const WORKSPACE = gql`
|
|
55
|
-
query workspace {
|
|
56
|
-
workspace {
|
|
57
|
-
name
|
|
58
|
-
path
|
|
59
|
-
icon
|
|
60
|
-
components {
|
|
61
|
-
...wcComponentFields
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
${wcComponentFields}
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
const COMPONENT_SUBSCRIPTION_ADDED = gql`
|
|
69
|
-
subscription OnComponentAdded {
|
|
70
|
-
componentAdded {
|
|
71
|
-
component {
|
|
72
|
-
...wcComponentFields
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
${wcComponentFields}
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
const COMPONENT_SUBSCRIPTION_CHANGED = gql`
|
|
80
|
-
subscription OnComponentChanged {
|
|
81
|
-
componentChanged {
|
|
82
|
-
component {
|
|
83
|
-
...wcComponentFields
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
${wcComponentFields}
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
const COMPONENT_SUBSCRIPTION_REMOVED = gql`
|
|
91
|
-
subscription OnComponentRemoved {
|
|
92
|
-
componentRemoved {
|
|
93
|
-
componentIds {
|
|
94
|
-
name
|
|
95
|
-
version
|
|
96
|
-
scope
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
export function useWorkspace(options: UseWorkspaceOptions = {}) {
|
|
103
|
-
const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE);
|
|
104
|
-
const optionsRef = useLatest(options);
|
|
105
|
-
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
const unSubCompAddition = subscribeToMore({
|
|
108
|
-
document: COMPONENT_SUBSCRIPTION_ADDED,
|
|
109
|
-
updateQuery: (prev, { subscriptionData }) => {
|
|
110
|
-
const update = subscriptionData.data;
|
|
111
|
-
const addedComponent = update?.componentAdded?.component;
|
|
112
|
-
if (!addedComponent) return prev;
|
|
113
|
-
|
|
114
|
-
const componentExists = prev.workspace.components.find((component: any) =>
|
|
115
|
-
ComponentID.isEqualObj(component.id, addedComponent.id, { ignoreVersion: true })
|
|
116
|
-
);
|
|
117
|
-
if (componentExists) return prev;
|
|
118
|
-
|
|
119
|
-
// side effect - trigger observers
|
|
120
|
-
setTimeout(() => optionsRef.current.onComponentAdded?.([ComponentModel.from(addedComponent)]));
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
...prev,
|
|
124
|
-
workspace: {
|
|
125
|
-
...prev.workspace,
|
|
126
|
-
components: [...prev.workspace.components, addedComponent],
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const unSubCompChange = subscribeToMore({
|
|
133
|
-
document: COMPONENT_SUBSCRIPTION_CHANGED,
|
|
134
|
-
updateQuery: (prev, { subscriptionData }) => {
|
|
135
|
-
const update = subscriptionData.data;
|
|
136
|
-
if (!update) return prev;
|
|
137
|
-
|
|
138
|
-
const updatedComponent = update.componentChanged.component;
|
|
139
|
-
// side effect - trigger observers
|
|
140
|
-
setTimeout(() => optionsRef.current.onComponentUpdated?.([ComponentModel.from(updatedComponent)]));
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
...prev,
|
|
144
|
-
workspace: {
|
|
145
|
-
...prev.workspace,
|
|
146
|
-
components: prev.workspace.components.map((component) =>
|
|
147
|
-
component.id.name === updatedComponent.id.name ? updatedComponent : component
|
|
148
|
-
),
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const unSubCompRemoved = subscribeToMore({
|
|
155
|
-
document: COMPONENT_SUBSCRIPTION_REMOVED,
|
|
156
|
-
updateQuery: (prev, { subscriptionData }) => {
|
|
157
|
-
const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds;
|
|
158
|
-
if (!idsToRemove || idsToRemove.length === 0) return prev;
|
|
159
|
-
|
|
160
|
-
// side effect - trigger observers
|
|
161
|
-
setTimeout(() => optionsRef.current.onComponentRemoved?.(idsToRemove.map((id) => ComponentID.fromObject(id))));
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
...prev,
|
|
165
|
-
workspace: {
|
|
166
|
-
...prev.workspace,
|
|
167
|
-
components: prev.workspace.components.filter((component: RawComponent) =>
|
|
168
|
-
idsToRemove.every((id) => !ComponentID.isEqualObj(id, component.id))
|
|
169
|
-
),
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// TODO - sub to component removal
|
|
176
|
-
|
|
177
|
-
return () => {
|
|
178
|
-
unSubCompAddition();
|
|
179
|
-
unSubCompChange();
|
|
180
|
-
unSubCompRemoved();
|
|
181
|
-
};
|
|
182
|
-
}, [optionsRef]);
|
|
183
|
-
|
|
184
|
-
const workspace = useMemo(() => {
|
|
185
|
-
return data?.workspace ? Workspace.from(data?.workspace) : undefined;
|
|
186
|
-
}, [data?.workspace]);
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
workspace,
|
|
190
|
-
subscribeToMore,
|
|
191
|
-
...rest,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// import { ComponentMeta } from '@teambit/component';
|
|
2
|
-
import { ComponentID, ComponentModel, ComponentModelProps } from '@teambit/component';
|
|
3
|
-
import { DeprecationInfo } from '@teambit/deprecation';
|
|
4
|
-
import { Descriptor } from '@teambit/envs';
|
|
5
|
-
|
|
6
|
-
import { ComponentStatus } from '../../workspace-component/component-status';
|
|
7
|
-
|
|
8
|
-
export type WorkspaceModelComponent = {
|
|
9
|
-
id: ComponentID;
|
|
10
|
-
status: ComponentStatus;
|
|
11
|
-
deprecation: DeprecationInfo;
|
|
12
|
-
env: Descriptor;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type WorkspaceProps = {
|
|
16
|
-
name: string;
|
|
17
|
-
path: string;
|
|
18
|
-
components: ComponentModelProps[];
|
|
19
|
-
icon: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export class Workspace {
|
|
23
|
-
constructor(
|
|
24
|
-
/**
|
|
25
|
-
* name of the workspace.
|
|
26
|
-
*/
|
|
27
|
-
readonly name: string,
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* absolute path of the workspace.
|
|
31
|
-
*/
|
|
32
|
-
readonly path: string,
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* icon of the workspace.
|
|
36
|
-
*/
|
|
37
|
-
readonly icon: string,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* components container in the workspace.
|
|
41
|
-
*/
|
|
42
|
-
readonly components: ComponentModel[]
|
|
43
|
-
) {}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* return a component from the workspace.
|
|
47
|
-
*/
|
|
48
|
-
getComponent(id: ComponentID) {
|
|
49
|
-
return this.components.find((component) => component.id.fullName === id.fullName);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static from({ name, path, components, icon }: WorkspaceProps) {
|
|
53
|
-
return new Workspace(
|
|
54
|
-
name,
|
|
55
|
-
path,
|
|
56
|
-
icon,
|
|
57
|
-
components.map((value) => {
|
|
58
|
-
return ComponentModel.from(value);
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static empty() {
|
|
64
|
-
return new Workspace('', '', '', []);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WorkspaceOverview } from './workspace-overview';
|