@teambit/objects 0.0.727 → 0.0.728

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.
@@ -85,9 +85,9 @@ export type ComponentProps = {
85
85
  name: string;
86
86
  versions?: Versions;
87
87
  orphanedVersions?: Versions;
88
- lang: string;
89
- deprecated: boolean;
90
- bindingPrefix: string;
88
+ lang?: string;
89
+ deprecated?: boolean;
90
+ bindingPrefix?: string;
91
91
  state?: State; // get deleted after export
92
92
  scopesList?: ScopeListItem[];
93
93
  head?: Ref;
@@ -546,13 +546,11 @@ export default class Component extends BitObject {
546
546
  latestExisting(repository: Repository): string {
547
547
  if (isEmpty(this.versions)) return VERSION_ZERO;
548
548
  const versions = this.listVersions('ASC');
549
- let version = null;
550
- let versionStr = null;
549
+ let version: Version | undefined;
550
+ let versionStr: string | undefined;
551
551
  while (!version && versions && versions.length) {
552
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
553
552
  versionStr = versions.pop();
554
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
555
- version = this.loadVersionSync(versionStr, repository, false);
553
+ version = this.loadVersionSync(versionStr!, repository, false);
556
554
  }
557
555
  return versionStr || VERSION_ZERO;
558
556
  }
@@ -893,7 +891,19 @@ Error from "semver": ${err.message}`);
893
891
  return obj;
894
892
  }
895
893
 
896
- const componentObject = {
894
+ const componentObject: {
895
+ name: string;
896
+ scope: string;
897
+ versions: Record<string, string>;
898
+ lang: string;
899
+ deprecated: boolean;
900
+ bindingPrefix: string;
901
+ remotes: ScopeListItem[];
902
+ schema: string | undefined;
903
+ detachedHeads: ReturnType<DetachedHeads['toObject']>;
904
+ local?: boolean;
905
+ state?: State;
906
+ } = {
897
907
  name: this.name,
898
908
  scope: this.scope,
899
909
  versions: versions(this.versions),
@@ -904,9 +914,7 @@ Error from "semver": ${err.message}`);
904
914
  schema: this.schema,
905
915
  detachedHeads: this.detachedHeads.toObject(),
906
916
  };
907
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
908
917
  if (this.local) componentObject.local = this.local;
909
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
910
918
  if (!isEmpty(this.state)) componentObject.state = this.state;
911
919
  // @ts-ignore
912
920
  if (!isEmpty(this.orphanedVersions)) componentObject.orphanedVersions = versions(this.orphanedVersions);
@@ -928,8 +936,7 @@ Error from "semver": ${err.message}`);
928
936
  loadVersionSync(version: string, repository: Repository, throws = true): Version {
929
937
  const versionRef = this.getRef(version);
930
938
  if (!versionRef) throw new VersionNotFound(version, this.id());
931
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
932
- return versionRef.loadSync(repository, throws);
939
+ return versionRef.loadSync(repository, throws) as Version;
933
940
  }
934
941
 
935
942
  async collectVersionsObjects(
@@ -1300,10 +1307,8 @@ bit import ${this.id()}@${resolvedVersion} --objects --all-history`
1300
1307
 
1301
1308
  markVersionAsLocal(version: string) {
1302
1309
  if (!this.state.versions) this.state = { versions: {} };
1303
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
1304
- if (!this.state.versions[version]) this.state.versions[version] = {};
1305
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
1306
- this.state.versions[version].local = true;
1310
+ if (!this.state.versions![version]) this.state.versions![version] = {};
1311
+ this.state.versions![version].local = true;
1307
1312
  }
1308
1313
 
1309
1314
  /**
@@ -1312,8 +1317,7 @@ bit import ${this.id()}@${resolvedVersion} --objects --all-history`
1312
1317
  */
1313
1318
  getLocalVersions(): string[] {
1314
1319
  if (isEmpty(this.state) || isEmpty(this.state.versions)) return [];
1315
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
1316
- return Object.keys(this.state.versions).filter((version) => this.state.versions[version].local);
1320
+ return Object.keys(this.state.versions!).filter((version) => this.state.versions![version].local);
1317
1321
  }
1318
1322
 
1319
1323
  hasLocalTag(tag: string): boolean {
@@ -1523,7 +1527,6 @@ bit import ${this.id()}@${resolvedVersion} --objects --all-history`
1523
1527
  }
1524
1528
 
1525
1529
  static fromBitId(bitId: ComponentID): Component {
1526
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
1527
1530
  return new Component({
1528
1531
  name: bitId.fullName,
1529
1532
  scope: bitId.scope,
@@ -4,7 +4,7 @@ import type Ref from '../objects/ref';
4
4
 
5
5
  type ScopeMetaProps = {
6
6
  name: string;
7
- license: string;
7
+ license?: string | null;
8
8
  };
9
9
 
10
10
  // TODO: fix parse
@@ -39,13 +39,11 @@ export default class ScopeMeta extends BitObject {
39
39
  }
40
40
 
41
41
  static fromScopeName(name: string): Ref {
42
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
43
42
  return ScopeMeta.fromObject({ name }).hash();
44
43
  }
45
44
 
46
45
  static parse(propsStr: string | Buffer): ScopeMeta {
47
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
48
- return this.fromObject(JSON.parse(propsStr));
46
+ return this.fromObject(JSON.parse(propsStr.toString()));
49
47
  }
50
48
 
51
49
  static fromObject(props: ScopeMetaProps): ScopeMeta {
package/models/version.ts CHANGED
@@ -4,7 +4,7 @@ import { ComponentID, ComponentIdList } from '@teambit/component-id';
4
4
  import { LaneId } from '@teambit/lane-id';
5
5
  import { v4 } from 'uuid';
6
6
  import type { BuildStatus } from '@teambit/legacy.constants';
7
- import { DEFAULT_BUNDLE_FILENAME, Extensions } from '@teambit/legacy.constants';
7
+ import { Extensions } from '@teambit/legacy.constants';
8
8
  import type { ConsumerComponent } from '@teambit/legacy.consumer-component';
9
9
  import {
10
10
  isSchemaSupport,
@@ -903,16 +903,6 @@ export default class Version extends BitObject {
903
903
  : undefined;
904
904
  }
905
905
 
906
- setDist(dist: Source | undefined) {
907
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
908
- this.dist = dist
909
- ? {
910
- file: dist.hash(),
911
- name: DEFAULT_BUNDLE_FILENAME,
912
- }
913
- : null;
914
- }
915
-
916
906
  hasParent(ref: Ref) {
917
907
  return this.parents.find((p) => p.toString() === ref.toString());
918
908
  }
package/objects/object.ts CHANGED
@@ -46,7 +46,7 @@ export default class BitObject {
46
46
  }
47
47
 
48
48
  async collectRefs(repo: Repository): Promise<Ref[]> {
49
- const refsCollection = [];
49
+ const refsCollection: Ref[] = [];
50
50
  const objectType = this.getType();
51
51
  const objectId = objectType === 'Component' ? `Component ${this.id()}` : objectType;
52
52
 
@@ -63,7 +63,6 @@ path: ${err.path}`);
63
63
  throw err;
64
64
  }
65
65
 
66
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
67
66
  refsCollection.push(...refs);
68
67
  await Promise.all(objs.map((obj) => addRefs(obj)));
69
68
  }
@@ -1,7 +1,6 @@
1
1
  import { NULL_BYTE, SPACE_DELIMITER } from '@teambit/legacy.constants';
2
2
  import { getStringifyArgs, inflate } from '@teambit/legacy.utils';
3
3
  import { typesObj as types } from '@teambit/legacy.scope';
4
- import type BitObject from './object';
5
4
  import { clone } from 'lodash';
6
5
 
7
6
  export default class BitRawObject {
@@ -12,11 +11,11 @@ export default class BitRawObject {
12
11
  _ref: string;
13
12
 
14
13
  constructor(
15
- buffer: Buffer,
16
- ref: string | null | undefined,
17
- type: string | null | undefined,
18
- content: Buffer | null | undefined,
19
- parsedContent: any | null | undefined
14
+ buffer?: Buffer,
15
+ ref?: string | null,
16
+ type?: string | null,
17
+ content?: Buffer | null,
18
+ parsedContent?: any | null
20
19
  ) {
21
20
  let headers;
22
21
  let contentFromBuffer;
@@ -28,10 +27,8 @@ export default class BitRawObject {
28
27
  this.content = content || contentFromBuffer;
29
28
  this.headers = headers ? headers.split(SPACE_DELIMITER) : undefined;
30
29
  const typeFromHeader = this.headers ? this.headers[0] : undefined;
31
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
32
- this.type = type || typeFromHeader;
33
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
34
- this._ref = ref;
30
+ this.type = (type || typeFromHeader)!;
31
+ this._ref = ref!;
35
32
  this.parsedContent = parsedContent || this.getParsedContent();
36
33
  }
37
34
 
@@ -109,8 +106,7 @@ export default class BitRawObject {
109
106
  return [];
110
107
  }
111
108
 
112
- static async fromDeflatedBuffer(fileContents: Buffer, ref: string | null | undefined): Promise<BitObject> {
113
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
109
+ static async fromDeflatedBuffer(fileContents: Buffer, ref: string | null | undefined): Promise<BitRawObject> {
114
110
  return inflate(fileContents).then((buffer) => new BitRawObject(buffer, ref));
115
111
  }
116
112
 
@@ -126,7 +122,6 @@ export default class BitRawObject {
126
122
  clone() {
127
123
  const parsedContent = this.parsedContent ? clone(this.parsedContent) : undefined;
128
124
  // TODO: Should also clone the buffers (content)
129
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
130
125
  return new BitRawObject(undefined, this._ref, this.type, this.content, parsedContent);
131
126
  }
132
127
  }
@@ -180,8 +180,7 @@ export default class Repository {
180
180
  return path.join(this.scopePath, TRASH_DIR);
181
181
  }
182
182
 
183
- getLicense(): Promise<string> {
184
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
183
+ getLicense(): Promise<string | null | undefined> {
185
184
  return this.scopeJson.getPopulatedLicense();
186
185
  }
187
186
 
@@ -564,7 +563,7 @@ export default class Repository {
564
563
  if (throws) {
565
564
  throw new HashNotFound(ref.toString());
566
565
  }
567
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
566
+ // @ts-expect-error @todo: it should return BitObject | null (same as `load()`)
568
567
  return null;
569
568
  }
570
569
  }
@@ -11,7 +11,6 @@ describe('ComponentsIndex', () => {
11
11
  scopeIndex = new ScopeIndex('scope-path');
12
12
  });
13
13
  it('should add to the index array', () => {
14
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
15
14
  const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });
16
15
  scopeIndex.addOne(modelComponent);
17
16
  const allItems = scopeIndex.getAll();
@@ -19,7 +18,6 @@ describe('ComponentsIndex', () => {
19
18
  expect(allItems[0].id).to.deep.equal({ scope: 'my-scope', name: 'is-string' });
20
19
  });
21
20
  it('should not add the same component multiple times', () => {
22
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
23
21
  const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });
24
22
  scopeIndex.addOne(modelComponent);
25
23
  scopeIndex.addOne(modelComponent);
@@ -27,8 +25,7 @@ describe('ComponentsIndex', () => {
27
25
  expect(scopeIndex.getAll()).to.have.lengthOf(1);
28
26
  });
29
27
  it('should not add BitObjects that are not Symlink nor ModelComponent', () => {
30
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
31
- const bitObject = new BitObject({ scope: 'my-scope', name: 'is-string' });
28
+ const bitObject = new BitObject();
32
29
  const result = scopeIndex.addOne(bitObject);
33
30
  expect(scopeIndex.getAll()).to.have.lengthOf(0);
34
31
  expect(result).to.be.false;
@@ -40,7 +37,6 @@ describe('ComponentsIndex', () => {
40
37
  scopeIndex = new ScopeIndex('scope-path');
41
38
  });
42
39
  it('should remove from the index array', () => {
43
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
44
40
  const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });
45
41
  scopeIndex.addOne(modelComponent);
46
42
  expect(scopeIndex.getAll()).to.have.lengthOf(1);
@@ -48,9 +44,7 @@ describe('ComponentsIndex', () => {
48
44
  expect(scopeIndex.getAll()).to.have.lengthOf(0);
49
45
  });
50
46
  it('should remove the correct one when there are multiple', () => {
51
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
52
47
  const isStringComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });
53
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
54
48
  const isTypeComponent = new ModelComponent({ scope: 'my-scope', name: 'is-type' });
55
49
  scopeIndex.addOne(isStringComponent);
56
50
  scopeIndex.addOne(isTypeComponent);
@@ -68,9 +62,7 @@ describe('ComponentsIndex', () => {
68
62
  let isTypeComponent;
69
63
  beforeEach(() => {
70
64
  scopeIndex = new ScopeIndex('scope-path');
71
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
72
65
  isStringComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });
73
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
74
66
  isTypeComponent = new ModelComponent({ scope: 'my-scope', name: 'is-type' });
75
67
  scopeIndex.addMany([isStringComponent, isTypeComponent]);
76
68
  expect(scopeIndex.getAll()).to.have.lengthOf(2);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/objects",
3
- "version": "0.0.727",
3
+ "version": "0.0.728",
4
4
  "homepage": "https://bit.cloud/teambit/scope/objects",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.scope",
8
8
  "name": "objects",
9
- "version": "0.0.727"
9
+ "version": "0.0.728"
10
10
  },
11
11
  "dependencies": {
12
12
  "@pnpm/lockfile.types": "1100.0.19",
@@ -22,16 +22,13 @@
22
22
  "@teambit/harmony.modules.runtimes": "0.0.4",
23
23
  "@teambit/component-id": "1.2.5",
24
24
  "@teambit/legacy.utils": "0.0.56",
25
- "@teambit/harmony.modules.get-basic-log": "0.0.193",
26
25
  "@teambit/bit-error": "0.0.404",
27
26
  "@teambit/component-version": "1.0.4",
28
27
  "@teambit/component.snap-distance": "0.0.191",
29
- "@teambit/config-store": "0.0.304",
30
28
  "@teambit/lane-id": "0.0.312",
31
29
  "@teambit/legacy.cli.error": "0.0.71",
32
30
  "@teambit/legacy.constants": "0.0.50",
33
31
  "@teambit/legacy.logger": "0.0.70",
34
- "@teambit/legacy.scope": "0.0.192",
35
32
  "@teambit/toolbox.crypto.sha1": "0.0.24",
36
33
  "@teambit/component.sources": "0.0.243",
37
34
  "@teambit/harmony.modules.concurrency": "0.0.51",
@@ -47,7 +44,10 @@
47
44
  "@teambit/bit.get-bit-version": "0.0.31",
48
45
  "@teambit/semantics.doc-parser": "0.0.199",
49
46
  "@teambit/harmony.modules.in-memory-cache": "0.0.55",
50
- "@teambit/toolbox.fs.remove-empty-dir": "0.0.22"
47
+ "@teambit/toolbox.fs.remove-empty-dir": "0.0.22",
48
+ "@teambit/harmony.modules.get-basic-log": "0.0.194",
49
+ "@teambit/config-store": "0.0.305",
50
+ "@teambit/legacy.scope": "0.0.193"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/semver": "7.5.8",