@teambit/scope 1.0.108 → 1.0.110

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/scope.ui-root.ts DELETED
@@ -1,43 +0,0 @@
1
- import { ResolveAspectsOptions } from '@teambit/component';
2
- import { ComponentID } from '@teambit/component-id';
3
- import { UIRoot } from '@teambit/ui';
4
-
5
- import type { ScopeMain } from './scope.main.runtime';
6
-
7
- export class ScopeUIRoot implements UIRoot {
8
- constructor(
9
- /**
10
- * scope extension.
11
- */
12
- private scope: ScopeMain
13
- ) {}
14
-
15
- get name() {
16
- return this.scope.name;
17
- }
18
-
19
- get path(): string {
20
- return this.scope.path;
21
- }
22
-
23
- get configFile(): string {
24
- return 'scope.jsonc';
25
- }
26
-
27
- get devServers() {
28
- return Promise.resolve([]);
29
- }
30
-
31
- buildOptions = {
32
- ssr: true,
33
- prebundle: true,
34
- };
35
-
36
- resolveAspects(runtime: string, componentIds?: ComponentID[], opts?: ResolveAspectsOptions) {
37
- return this.scope.resolveAspects(runtime, componentIds, opts);
38
- }
39
-
40
- async resolvePattern() {
41
- return [];
42
- }
43
- }
package/staged-config.ts DELETED
@@ -1,79 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import { ComponentID } from '@teambit/component-id';
4
- import { DEFAULT_LANE, LaneId } from '@teambit/lane-id';
5
- import { Logger } from '@teambit/logger';
6
-
7
- const STAGED_CONFIG_DIR = 'staged-config';
8
-
9
- type Config = Record<string, any> | undefined;
10
- type ComponentConfig = { id: ComponentID; config: Config };
11
-
12
- export class StagedConfig {
13
- hasChanged = false;
14
- constructor(readonly filePath: string, private componentsConfig: ComponentConfig[], private logger: Logger) {}
15
-
16
- static async load(scopePath: string, logger: Logger, laneId?: LaneId): Promise<StagedConfig> {
17
- const lanePath = laneId ? path.join(laneId.scope, laneId.name) : DEFAULT_LANE;
18
- const filePath = path.join(scopePath, STAGED_CONFIG_DIR, `${lanePath}.json`);
19
- let componentsConfig: ComponentConfig[] = [];
20
- try {
21
- const fileContent = await fs.readJson(filePath);
22
- componentsConfig = fileContent.map((item) => ({ id: ComponentID.fromObject(item.id), config: item.config }));
23
- } catch (err: any) {
24
- if (err.code === 'ENOENT') {
25
- componentsConfig = [];
26
- } else {
27
- throw err;
28
- }
29
- }
30
- return new StagedConfig(filePath, componentsConfig, logger);
31
- }
32
-
33
- toObject() {
34
- return this.componentsConfig.map(({ id, config }) => ({ id: id.toObject(), config }));
35
- }
36
-
37
- async write() {
38
- if (!this.hasChanged) return;
39
- await fs.outputFile(this.filePath, JSON.stringify(this.toObject(), null, 2));
40
- }
41
-
42
- getConfigPerId(id: ComponentID): Config {
43
- return this.componentsConfig.find((c) => c.id.isEqual(id, { ignoreVersion: true }))?.config;
44
- }
45
-
46
- getAll() {
47
- return this.componentsConfig;
48
- }
49
-
50
- isEmpty() {
51
- return this.componentsConfig.length === 0;
52
- }
53
-
54
- async deleteFile() {
55
- this.logger.debug(`staged-config, deleting ${this.filePath}`);
56
- await fs.remove(this.filePath);
57
- this.componentsConfig = [];
58
- }
59
-
60
- addComponentConfig(id: ComponentID, config: Config) {
61
- const exists = this.componentsConfig.find((c) => c.id.isEqual(id, { ignoreVersion: true }));
62
- if (exists) {
63
- exists.config = config;
64
- } else {
65
- this.componentsConfig.push({ id, config });
66
- }
67
- this.hasChanged = true;
68
- }
69
-
70
- removeComponentConfig(id: ComponentID) {
71
- const componentsConfigLengthBefore = this.componentsConfig.length;
72
- this.componentsConfig = this.componentsConfig.filter((c) => !c.id.isEqual(id, { ignoreVersion: true }));
73
- if (this.componentsConfig.length === componentsConfigLengthBefore) {
74
- this.logger.debug(`removeComponentConfig: unable to find ${id.toString()}`);
75
- } else {
76
- this.hasChanged = true;
77
- }
78
- }
79
- }
package/types.ts DELETED
@@ -1,12 +0,0 @@
1
- export type Serializable = {
2
- toString(): string;
3
- };
4
-
5
- export type Metadata = {
6
- [key: string]: Serializable;
7
- };
8
-
9
- export type DataToPersist = {
10
- metadata: Metadata;
11
- files: string[];
12
- };