@teambit/objects 0.0.0-f9dd59931dd35350b5dd307c07adee82f4575ee4 → 0.0.0-f9fa5156e992ab1e2daf77bf6d601123f297e733
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/dist/models/dependencies-graph.d.ts +1 -1
- package/dist/models/dependencies-graph.js.map +1 -1
- package/dist/models/export-metadata.js +0 -2
- package/dist/models/export-metadata.js.map +1 -1
- package/dist/models/lane-history.d.ts +1 -1
- package/dist/models/lane-history.js.map +1 -1
- package/dist/models/lane.d.ts +6 -5
- package/dist/models/lane.js.map +1 -1
- package/dist/models/model-component.d.ts +10 -8
- package/dist/models/model-component.js +0 -3
- package/dist/models/model-component.js.map +1 -1
- package/dist/models/scopeMeta.d.ts +1 -1
- package/dist/models/scopeMeta.js +0 -3
- package/dist/models/scopeMeta.js.map +1 -1
- package/dist/models/source.d.ts +2 -2
- package/dist/models/source.js +0 -1
- package/dist/models/source.js.map +1 -1
- package/dist/models/symlink.d.ts +1 -1
- package/dist/models/version-history.d.ts +1 -1
- package/dist/models/version-history.js.map +1 -1
- package/dist/models/version.d.ts +11 -9
- package/dist/models/version.js +1 -13
- package/dist/models/version.js.map +1 -1
- package/dist/models/version.spec.js +4 -12
- package/dist/models/version.spec.js.map +1 -1
- package/dist/objects/bit-object-list.d.ts +1 -1
- package/dist/objects/bit-object-list.js.map +1 -1
- package/dist/objects/object-list-to-graph.d.ts +2 -2
- package/dist/objects/object-list-to-graph.js.map +1 -1
- package/dist/objects/object.d.ts +2 -2
- package/dist/objects/object.js +0 -1
- package/dist/objects/object.js.map +1 -1
- package/dist/objects/objects-readable-generator.d.ts +4 -4
- package/dist/objects/objects-readable-generator.js.map +1 -1
- package/dist/objects/raw-object.d.ts +2 -2
- package/dist/objects/raw-object.js +1 -11
- package/dist/objects/raw-object.js.map +1 -1
- package/dist/objects/ref.d.ts +2 -2
- package/dist/objects/ref.js.map +1 -1
- package/dist/objects/repository.d.ts +23 -7
- package/dist/objects/repository.js +14 -10
- package/dist/objects/repository.js.map +1 -1
- package/dist/objects/scope-index.d.ts +2 -2
- package/dist/objects/scope-index.js +0 -1
- package/dist/objects/scope-index.js.map +1 -1
- package/models/dependencies-graph.ts +1 -1
- package/models/export-metadata.ts +0 -1
- package/models/lane-history.ts +1 -1
- package/models/lane.ts +4 -3
- package/models/model-component.ts +13 -14
- package/models/scopeMeta.ts +1 -3
- package/models/source.ts +0 -1
- package/models/version-history.ts +1 -1
- package/models/version.spec.ts +4 -12
- package/models/version.ts +10 -21
- package/objects/bit-object-list.ts +1 -1
- package/objects/object-list-to-graph.ts +2 -2
- package/objects/object.ts +2 -3
- package/objects/objects-readable-generator.ts +6 -6
- package/objects/raw-object.ts +2 -12
- package/objects/ref.ts +2 -2
- package/objects/repository.ts +28 -17
- package/objects/scope-index.ts +2 -3
- package/package.json +31 -32
- package/dist/objects/repository-hooks.d.ts +0 -4
- package/dist/objects/repository-hooks.js +0 -56
- package/dist/objects/repository-hooks.js.map +0 -1
- package/objects/repository-hooks.ts +0 -42
- /package/dist/{preview-1752542268171.js → preview-1762285671759.js} +0 -0
|
@@ -6,19 +6,20 @@ import { BitError } from '@teambit/bit-error';
|
|
|
6
6
|
import { LaneId, DEFAULT_LANE } from '@teambit/lane-id';
|
|
7
7
|
import { ComponentID, ComponentIdList } from '@teambit/component-id';
|
|
8
8
|
import pMapSeries from 'p-map-series';
|
|
9
|
-
import { LegacyComponentLog } from '@teambit/legacy-component-log';
|
|
9
|
+
import type { LegacyComponentLog } from '@teambit/legacy-component-log';
|
|
10
10
|
import { findDuplications } from '@teambit/toolbox.array.duplications-finder';
|
|
11
11
|
import { BitId } from '@teambit/legacy-bit-id';
|
|
12
12
|
import { DEFAULT_BIT_RELEASE_TYPE, DEFAULT_BIT_VERSION, DEFAULT_LANGUAGE, Extensions } from '@teambit/legacy.constants';
|
|
13
|
-
import {
|
|
13
|
+
import type { Dependencies, Dependency } from '@teambit/legacy.consumer-component';
|
|
14
|
+
import { ConsumerComponent, SchemaName } from '@teambit/legacy.consumer-component';
|
|
14
15
|
import { License, SourceFile, getRefsFromExtensions } from '@teambit/component.sources';
|
|
15
16
|
import { ComponentOverrides, getBindingPrefixByDefaultScope } from '@teambit/legacy.consumer-config';
|
|
16
17
|
import { ValidationError } from '@teambit/legacy.cli.error';
|
|
17
18
|
import { logger } from '@teambit/legacy.logger';
|
|
18
19
|
import { getStringifyArgs } from '@teambit/legacy.utils';
|
|
19
20
|
import { getLatestVersion, validateVersion } from '@teambit/pkg.modules.semver-helper';
|
|
21
|
+
import type { SnapsDistance } from '@teambit/component.snap-distance';
|
|
20
22
|
import {
|
|
21
|
-
SnapsDistance,
|
|
22
23
|
getDivergeData,
|
|
23
24
|
getAllVersionParents,
|
|
24
25
|
getAllVersionsInfo,
|
|
@@ -36,20 +37,21 @@ import {
|
|
|
36
37
|
errorIsTypeOfMissingObject,
|
|
37
38
|
BitIdCompIdError,
|
|
38
39
|
} from '@teambit/legacy.scope';
|
|
39
|
-
import { Repository
|
|
40
|
-
import
|
|
40
|
+
import type { Repository } from '../objects';
|
|
41
|
+
import { BitObject, Ref } from '../objects';
|
|
42
|
+
import type Lane from './lane';
|
|
41
43
|
import ScopeMeta from './scopeMeta';
|
|
42
|
-
import Source from './source';
|
|
43
|
-
import Version from './version';
|
|
44
|
-
import
|
|
45
|
-
import
|
|
44
|
+
import type Source from './source';
|
|
45
|
+
import type Version from './version';
|
|
46
|
+
import type { VersionParents } from './version-history';
|
|
47
|
+
import VersionHistory from './version-history';
|
|
48
|
+
import type { ObjectItem } from '../objects/object-list';
|
|
46
49
|
import type { Scope } from '@teambit/legacy.scope';
|
|
47
|
-
import { ExtensionDataList } from '@teambit/legacy.extension-data';
|
|
50
|
+
import type { ExtensionDataList } from '@teambit/legacy.extension-data';
|
|
48
51
|
import { DetachedHeads } from './detach-heads';
|
|
49
52
|
|
|
50
53
|
type State = {
|
|
51
54
|
versions?: {
|
|
52
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
53
55
|
[version: string]: {
|
|
54
56
|
local?: boolean; // whether a component was changed locally
|
|
55
57
|
};
|
|
@@ -98,7 +100,6 @@ export const VERSION_ZERO = '0.0.0';
|
|
|
98
100
|
* with 'Component' in their headers. see object-registrar.types()
|
|
99
101
|
*/
|
|
100
102
|
// TODO: FIX me .parser
|
|
101
|
-
// @ts-ignore
|
|
102
103
|
export default class Component extends BitObject {
|
|
103
104
|
scope: string;
|
|
104
105
|
name: string;
|
|
@@ -603,7 +604,6 @@ export default class Component extends BitObject {
|
|
|
603
604
|
collectVersions(repo: Repository): Promise<ConsumerComponent[]> {
|
|
604
605
|
return Promise.all(
|
|
605
606
|
this.listVersions().map((versionNum) => {
|
|
606
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
607
607
|
return this.toConsumerComponent(versionNum, this.scope, repo);
|
|
608
608
|
})
|
|
609
609
|
);
|
|
@@ -1086,7 +1086,6 @@ consider using --ignore-missing-artifacts flag if you're sure the artifacts are
|
|
|
1086
1086
|
// @todo: this is weird. why the scopeMeta would be taken from the current scope and not he component scope?
|
|
1087
1087
|
const scopeMetaP = scopeName ? ScopeMeta.fromScopeName(scopeName).load(repository) : Promise.resolve();
|
|
1088
1088
|
const log = version.log || null;
|
|
1089
|
-
// @ts-ignore
|
|
1090
1089
|
const [files, scopeMeta] = await Promise.all([filesP, scopeMetaP]);
|
|
1091
1090
|
|
|
1092
1091
|
const extensions = version.extensions.clone();
|
package/models/scopeMeta.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getStringifyArgs } from '@teambit/legacy.utils';
|
|
2
2
|
import { BitObject } from '../objects';
|
|
3
|
-
import Ref from '../objects/ref';
|
|
3
|
+
import type Ref from '../objects/ref';
|
|
4
4
|
|
|
5
5
|
type ScopeMetaProps = {
|
|
6
6
|
name: string;
|
|
@@ -8,7 +8,6 @@ type ScopeMetaProps = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// TODO: fix parse
|
|
11
|
-
// @ts-ignore
|
|
12
11
|
export default class ScopeMeta extends BitObject {
|
|
13
12
|
license: string | null | undefined;
|
|
14
13
|
name: string;
|
|
@@ -26,7 +25,6 @@ export default class ScopeMeta extends BitObject {
|
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
30
28
|
toString(pretty: boolean): string {
|
|
31
29
|
const args = getStringifyArgs(pretty);
|
|
32
30
|
return JSON.stringify(this.toObject(), ...args);
|
package/models/source.ts
CHANGED
|
@@ -7,7 +7,7 @@ import Ref from '../objects/ref';
|
|
|
7
7
|
import { BitObject } from '../objects';
|
|
8
8
|
import type Version from './version';
|
|
9
9
|
import { getVersionParentsFromVersion } from '@teambit/component.snap-distance';
|
|
10
|
-
import ModelComponent from './model-component';
|
|
10
|
+
import type ModelComponent from './model-component';
|
|
11
11
|
|
|
12
12
|
export type VersionParents = {
|
|
13
13
|
hash: Ref;
|
package/models/version.spec.ts
CHANGED
|
@@ -67,21 +67,13 @@ describe('Version', () => {
|
|
|
67
67
|
it('dependencies should be an array', () => {
|
|
68
68
|
expect(dependencies).to.be.an('array').and.have.lengthOf(1);
|
|
69
69
|
});
|
|
70
|
-
it('dependencies should have
|
|
70
|
+
it('dependencies should have id property only (relativePaths removed)', () => {
|
|
71
71
|
expect(dependencies[0]).to.haveOwnProperty('id');
|
|
72
|
-
expect(dependencies[0]).to.haveOwnProperty('relativePaths');
|
|
72
|
+
expect(dependencies[0]).to.not.haveOwnProperty('relativePaths');
|
|
73
73
|
expect(dependencies[0]).to.not.haveOwnProperty('nonExistProperty');
|
|
74
|
-
expect(Object.keys(dependencies[0])).to.have.lengthOf(
|
|
75
|
-
});
|
|
76
|
-
it('relativePaths should be an array', () => {
|
|
77
|
-
expect(dependencies[0].relativePaths).to.be.an('array').and.have.lengthOf(1);
|
|
78
|
-
});
|
|
79
|
-
it('relativePaths should have properties sourceRelativePath and destinationRelativePath only', () => {
|
|
80
|
-
expect(dependencies[0].relativePaths[0]).to.haveOwnProperty('sourceRelativePath');
|
|
81
|
-
expect(dependencies[0].relativePaths[0]).to.haveOwnProperty('destinationRelativePath');
|
|
82
|
-
expect(dependencies[0].relativePaths[0]).to.not.haveOwnProperty('nonExistProperty');
|
|
83
|
-
expect(Object.keys(dependencies[0].relativePaths[0])).to.have.lengthOf(2);
|
|
74
|
+
expect(Object.keys(dependencies[0])).to.have.lengthOf(1);
|
|
84
75
|
});
|
|
76
|
+
// relativePaths tests removed - no longer included in Version.id() hash for Harmony components
|
|
85
77
|
});
|
|
86
78
|
});
|
|
87
79
|
describe('hash()', () => {
|
package/models/version.ts
CHANGED
|
@@ -3,24 +3,27 @@ import { isSnap } from '@teambit/component-version';
|
|
|
3
3
|
import { ComponentID, ComponentIdList } from '@teambit/component-id';
|
|
4
4
|
import { LaneId } from '@teambit/lane-id';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
|
-
import { BuildStatus
|
|
6
|
+
import type { BuildStatus } from '@teambit/legacy.constants';
|
|
7
|
+
import { DEFAULT_BUNDLE_FILENAME, Extensions } from '@teambit/legacy.constants';
|
|
8
|
+
import type { ConsumerComponent } from '@teambit/legacy.consumer-component';
|
|
7
9
|
import {
|
|
8
10
|
isSchemaSupport,
|
|
9
11
|
SchemaFeature,
|
|
10
12
|
SchemaName,
|
|
11
13
|
Dependencies,
|
|
12
14
|
Dependency,
|
|
13
|
-
ConsumerComponent,
|
|
14
15
|
} from '@teambit/legacy.consumer-component';
|
|
15
16
|
import { getRefsFromExtensions, SourceFile } from '@teambit/component.sources';
|
|
16
|
-
import { ComponentOverridesData } from '@teambit/legacy.consumer-config';
|
|
17
|
+
import type { ComponentOverridesData } from '@teambit/legacy.consumer-config';
|
|
17
18
|
import { ExtensionDataEntry, ExtensionDataList } from '@teambit/legacy.extension-data';
|
|
18
19
|
import type { Doclet } from '@teambit/semantics.doc-parser';
|
|
19
20
|
import { logger } from '@teambit/legacy.logger';
|
|
20
|
-
import {
|
|
21
|
+
import type { PathLinux } from '@teambit/legacy.utils';
|
|
22
|
+
import { getStringifyArgs, pathNormalizeToLinux } from '@teambit/legacy.utils';
|
|
21
23
|
import { sha1 } from '@teambit/toolbox.crypto.sha1';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
+
import type { Repository } from '../objects';
|
|
25
|
+
import { BitObject, Ref } from '../objects';
|
|
26
|
+
import type { ObjectItem } from '../objects/object-list';
|
|
24
27
|
import { BitIdCompIdError, VersionInvalid, validateVersionInstance } from '@teambit/legacy.scope';
|
|
25
28
|
import Source from './source';
|
|
26
29
|
import { DependenciesGraph } from './dependencies-graph';
|
|
@@ -67,11 +70,8 @@ export type VersionProps = {
|
|
|
67
70
|
flattenedEdges?: DepEdge[];
|
|
68
71
|
flattenedEdgesRef?: Ref;
|
|
69
72
|
dependenciesGraphRef?: Ref;
|
|
70
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
71
73
|
packageDependencies?: { [key: string]: string };
|
|
72
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
73
74
|
devPackageDependencies?: { [key: string]: string };
|
|
74
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
75
75
|
peerPackageDependencies?: { [key: string]: string };
|
|
76
76
|
bindingPrefix: string;
|
|
77
77
|
schema?: string;
|
|
@@ -120,7 +120,6 @@ export default class Version extends BitObject {
|
|
|
120
120
|
* (around August 2023 should be safe)
|
|
121
121
|
*/
|
|
122
122
|
private flattenedEdges: DepEdge[];
|
|
123
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
124
123
|
packageDependencies: { [key: string]: string };
|
|
125
124
|
devPackageDependencies: { [key: string]: string };
|
|
126
125
|
peerPackageDependencies: { [key: string]: string };
|
|
@@ -232,19 +231,11 @@ export default class Version extends BitObject {
|
|
|
232
231
|
id() {
|
|
233
232
|
const obj = this.toObject();
|
|
234
233
|
|
|
235
|
-
// @todo: remove the entire dependencies.relativePaths from the ID (it's going to be a breaking change)
|
|
236
234
|
const getDependencies = (deps: Dependencies) => {
|
|
237
235
|
const clonedDependencies = deps.cloneAsString();
|
|
238
|
-
|
|
239
|
-
return clonedDependencies.map((dependency: Dependency) => {
|
|
236
|
+
return clonedDependencies.map((dependency) => {
|
|
240
237
|
return {
|
|
241
238
|
id: dependency.id,
|
|
242
|
-
relativePaths: dependency.relativePaths.map((relativePath) => {
|
|
243
|
-
return {
|
|
244
|
-
sourceRelativePath: relativePath.sourceRelativePath,
|
|
245
|
-
destinationRelativePath: relativePath.destinationRelativePath,
|
|
246
|
-
};
|
|
247
|
-
}),
|
|
248
239
|
};
|
|
249
240
|
});
|
|
250
241
|
};
|
|
@@ -697,7 +688,6 @@ export default class Version extends BitObject {
|
|
|
697
688
|
files: files.map(parseFile),
|
|
698
689
|
bindingPrefix: component.bindingPrefix,
|
|
699
690
|
log: component.log as Log,
|
|
700
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
701
691
|
docs: component.docs,
|
|
702
692
|
dependencies: component.dependencies.get(),
|
|
703
693
|
devDependencies: component.devDependencies.get(),
|
|
@@ -711,7 +701,6 @@ export default class Version extends BitObject {
|
|
|
711
701
|
flattenedEdgesRef: flattenedEdges?.hash(),
|
|
712
702
|
schema: component.schema,
|
|
713
703
|
overrides: component.overrides.componentOverridesData,
|
|
714
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
715
704
|
packageJsonChangedProps: component.packageJsonChangedProps,
|
|
716
705
|
extensions: component.extensions,
|
|
717
706
|
buildStatus: component.buildStatus,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Graph, Node, Edge } from '@teambit/graph.cleargraph';
|
|
2
2
|
import { uniqBy } from 'lodash';
|
|
3
|
-
import { ComponentID } from '@teambit/component-id';
|
|
3
|
+
import type { ComponentID } from '@teambit/component-id';
|
|
4
4
|
import type { ObjectList } from './object-list';
|
|
5
|
-
import { BitObjectList } from './bit-object-list';
|
|
5
|
+
import type { BitObjectList } from './bit-object-list';
|
|
6
6
|
import { getAllVersionsInfo } from '@teambit/component.snap-distance';
|
|
7
7
|
import { Dependency } from '@teambit/graph';
|
|
8
8
|
|
package/objects/object.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { NULL_BYTE, SPACE_DELIMITER } from '@teambit/legacy.constants';
|
|
|
4
4
|
import { deflate, inflate } from '@teambit/legacy.utils';
|
|
5
5
|
import { sha1 } from '@teambit/toolbox.crypto.sha1';
|
|
6
6
|
import { UnknownObjectType, typesObj as types } from '@teambit/legacy.scope';
|
|
7
|
-
import { ObjectItem } from './object-list';
|
|
7
|
+
import type { ObjectItem } from './object-list';
|
|
8
8
|
import Ref from './ref';
|
|
9
|
-
import Repository from './repository';
|
|
9
|
+
import type Repository from './repository';
|
|
10
10
|
|
|
11
11
|
function parse(buffer: Buffer): BitObject {
|
|
12
12
|
const { type, hash, contents } = extractHeaderAndContent(buffer);
|
|
@@ -147,7 +147,6 @@ path: ${err.path}`);
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
static makeHash(str: string | Buffer): string {
|
|
150
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
151
150
|
return sha1(str);
|
|
152
151
|
}
|
|
153
152
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import pMapSeries from 'p-map-series';
|
|
2
2
|
import { BitError } from '@teambit/bit-error';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
|
-
import BitObject from './object';
|
|
5
|
-
import Repository from './repository';
|
|
6
|
-
import Ref from './ref';
|
|
7
|
-
import { Scope } from '@teambit/legacy.scope';
|
|
4
|
+
import type BitObject from './object';
|
|
5
|
+
import type Repository from './repository';
|
|
6
|
+
import type Ref from './ref';
|
|
7
|
+
import type { Scope } from '@teambit/legacy.scope';
|
|
8
8
|
import { logger } from '@teambit/legacy.logger';
|
|
9
9
|
import { getAllVersionHashesMemoized } from '@teambit/component.snap-distance';
|
|
10
|
-
import { Lane, LaneHistory, ModelComponent, Version } from '../models';
|
|
11
|
-
import { ObjectItem } from './object-list';
|
|
10
|
+
import type { Lane, LaneHistory, ModelComponent, Version } from '../models';
|
|
11
|
+
import type { ObjectItem } from './object-list';
|
|
12
12
|
|
|
13
13
|
export type ComponentWithCollectOptions = {
|
|
14
14
|
component: ModelComponent;
|
package/objects/raw-object.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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 BitObject from './object';
|
|
4
|
+
import type BitObject from './object';
|
|
5
5
|
import { clone } from 'lodash';
|
|
6
6
|
|
|
7
7
|
export default class BitRawObject {
|
|
8
8
|
headers: string[];
|
|
9
9
|
type: string;
|
|
10
10
|
content: Buffer;
|
|
11
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
12
11
|
parsedContent: any;
|
|
13
12
|
_ref: string;
|
|
14
13
|
|
|
@@ -17,7 +16,6 @@ export default class BitRawObject {
|
|
|
17
16
|
ref: string | null | undefined,
|
|
18
17
|
type: string | null | undefined,
|
|
19
18
|
content: Buffer | null | undefined,
|
|
20
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
21
19
|
parsedContent: any | null | undefined
|
|
22
20
|
) {
|
|
23
21
|
let headers;
|
|
@@ -72,17 +70,14 @@ export default class BitRawObject {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
76
73
|
set ref(ref: string) {
|
|
77
74
|
this._ref = ref;
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
81
77
|
get ref(): string {
|
|
82
78
|
return this._ref;
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
86
81
|
get id(): string {
|
|
87
82
|
switch (this.type) {
|
|
88
83
|
case 'Version':
|
|
@@ -114,11 +109,7 @@ export default class BitRawObject {
|
|
|
114
109
|
return [];
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
static async fromDeflatedBuffer(
|
|
118
|
-
fileContents: Buffer,
|
|
119
|
-
ref: string | null | undefined
|
|
120
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
121
|
-
): Promise<BitObject> {
|
|
112
|
+
static async fromDeflatedBuffer(fileContents: Buffer, ref: string | null | undefined): Promise<BitObject> {
|
|
122
113
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
123
114
|
return inflate(fileContents).then((buffer) => new BitRawObject(buffer, ref));
|
|
124
115
|
}
|
|
@@ -129,7 +120,6 @@ export default class BitRawObject {
|
|
|
129
120
|
* @param {Any} parsedContent
|
|
130
121
|
*/
|
|
131
122
|
toRealObject() {
|
|
132
|
-
// @ts-ignore
|
|
133
123
|
return types[this.type].from(this.parsedContent || this.getParsedContent(), this.headers[1]);
|
|
134
124
|
}
|
|
135
125
|
|
package/objects/ref.ts
CHANGED
package/objects/repository.ts
CHANGED
|
@@ -3,37 +3,34 @@ import uidNumber from 'uid-number';
|
|
|
3
3
|
import { Mutex } from 'async-mutex';
|
|
4
4
|
import { compact, uniqBy, differenceWith, isEqual } from 'lodash';
|
|
5
5
|
import { BitError } from '@teambit/bit-error';
|
|
6
|
-
import { ComponentID } from '@teambit/component-id';
|
|
6
|
+
import type { ComponentID } from '@teambit/component-id';
|
|
7
7
|
import { HASH_SIZE, isSnap } from '@teambit/component-version';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import { pMapPool } from '@teambit/toolbox.promise.map-pool';
|
|
10
10
|
import { OBJECTS_DIR } from '@teambit/legacy.constants';
|
|
11
11
|
import { logger } from '@teambit/legacy.logger';
|
|
12
|
-
import {
|
|
12
|
+
import type { ChownOptions, PathOsBasedAbsolute } from '@teambit/legacy.utils';
|
|
13
|
+
import { glob, writeFile } from '@teambit/legacy.utils';
|
|
13
14
|
import { removeEmptyDir } from '@teambit/toolbox.fs.remove-empty-dir';
|
|
14
15
|
import { concurrentIOLimit } from '@teambit/harmony.modules.concurrency';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ScopeJson,
|
|
20
|
-
UnmergedComponents,
|
|
21
|
-
RemoteLanes,
|
|
22
|
-
} from '@teambit/legacy.scope';
|
|
23
|
-
import { ScopeIndex, IndexType, IndexItem } from './scope-index';
|
|
16
|
+
import type { Types, ScopeJson } from '@teambit/legacy.scope';
|
|
17
|
+
import { HashNotFound, OutdatedIndexJson, UnmergedComponents, RemoteLanes } from '@teambit/legacy.scope';
|
|
18
|
+
import type { IndexType, IndexItem } from './scope-index';
|
|
19
|
+
import { ScopeIndex } from './scope-index';
|
|
24
20
|
import BitObject from './object';
|
|
25
|
-
import { ObjectItem
|
|
21
|
+
import type { ObjectItem } from './object-list';
|
|
22
|
+
import { ObjectList } from './object-list';
|
|
26
23
|
import BitRawObject from './raw-object';
|
|
27
24
|
import Ref from './ref';
|
|
28
|
-
import {
|
|
29
|
-
import { getMaxSizeForObjects,
|
|
25
|
+
import type { InMemoryCache } from '@teambit/harmony.modules.in-memory-cache';
|
|
26
|
+
import { getMaxSizeForObjects, createInMemoryCache } from '@teambit/harmony.modules.in-memory-cache';
|
|
30
27
|
import { ScopeMeta, Lane, ModelComponent } from '../models';
|
|
31
28
|
|
|
29
|
+
type ContentTransformer = (content: Buffer) => Buffer;
|
|
32
30
|
const OBJECTS_BACKUP_DIR = `${OBJECTS_DIR}.bak`;
|
|
33
31
|
const TRASH_DIR = 'trash';
|
|
34
32
|
|
|
35
33
|
export default class Repository {
|
|
36
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
37
34
|
objects: { [key: string]: BitObject } = {};
|
|
38
35
|
objectsToRemove: Ref[] = [];
|
|
39
36
|
scopeJson: ScopeJson;
|
|
@@ -48,8 +45,8 @@ export default class Repository {
|
|
|
48
45
|
constructor(scopePath: string, scopeJson: ScopeJson) {
|
|
49
46
|
this.scopePath = scopePath;
|
|
50
47
|
this.scopeJson = scopeJson;
|
|
51
|
-
this.onRead =
|
|
52
|
-
this.onPersist =
|
|
48
|
+
this.onRead = (content: Buffer) => Repository.onPostObjectRead?.(content) || content;
|
|
49
|
+
this.onPersist = (content: Buffer) => Repository.onPreObjectPersist?.(content) || content;
|
|
53
50
|
this.cache = createInMemoryCache({ maxSize: getMaxSizeForObjects() });
|
|
54
51
|
}
|
|
55
52
|
|
|
@@ -92,6 +89,20 @@ export default class Repository {
|
|
|
92
89
|
|
|
93
90
|
static onPostObjectsPersist: () => Promise<void>;
|
|
94
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Hook for transforming content before objects are persisted to the filesystem.
|
|
94
|
+
* Note: This function cannot be async because it's used by the synchronous `loadSync` method
|
|
95
|
+
* which needs to maintain sync behavior for compatibility with existing code.
|
|
96
|
+
*/
|
|
97
|
+
static onPreObjectPersist: (content: Buffer) => Buffer;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Hook for transforming content after objects are read from the filesystem.
|
|
101
|
+
* Note: This function cannot be async because it's used by the synchronous `loadSync` method
|
|
102
|
+
* which needs to maintain sync behavior for compatibility with existing code.
|
|
103
|
+
*/
|
|
104
|
+
static onPostObjectRead: (content: Buffer) => Buffer;
|
|
105
|
+
|
|
95
106
|
async reLoadScopeIndex() {
|
|
96
107
|
this.scopeIndex = await this.loadOptionallyCreateScopeIndex();
|
|
97
108
|
}
|
package/objects/scope-index.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { logger } from '@teambit/legacy.logger';
|
|
|
7
7
|
import { InvalidIndexJson } from '@teambit/legacy.scope';
|
|
8
8
|
import { ModelComponent, Symlink } from '../models';
|
|
9
9
|
import Lane from '../models/lane';
|
|
10
|
-
import BitObject from './object';
|
|
11
|
-
import Ref from './ref';
|
|
10
|
+
import type BitObject from './object';
|
|
11
|
+
import type Ref from './ref';
|
|
12
12
|
import { difference } from 'lodash';
|
|
13
13
|
|
|
14
14
|
const COMPONENTS_INDEX_FILENAME = 'index.json';
|
|
@@ -111,7 +111,6 @@ export class ScopeIndex {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
getHashes(indexType: IndexType): string[] {
|
|
114
|
-
// @ts-ignore how to tell TS that all this.index.prop are array?
|
|
115
114
|
return this.index[indexType].map((indexItem: IndexItem) => indexItem.hash);
|
|
116
115
|
}
|
|
117
116
|
getHashesByQuery(indexType: IndexType, filter: Function): string[] {
|
package/package.json
CHANGED
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/objects",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-f9fa5156e992ab1e2daf77bf6d601123f297e733",
|
|
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": "
|
|
9
|
+
"version": "f9fa5156e992ab1e2daf77bf6d601123f297e733"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@pnpm/dependency-path": "1001.
|
|
13
|
-
"@pnpm/lockfile.types": "^
|
|
12
|
+
"@pnpm/dependency-path": "1001.1.2",
|
|
13
|
+
"@pnpm/lockfile.types": "^1002.0.1",
|
|
14
14
|
"semver": "7.7.1",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
16
|
"uuid": "8.3.2",
|
|
17
17
|
"async-mutex": "0.3.1",
|
|
18
18
|
"p-map-series": "2.1.0",
|
|
19
19
|
"tar-stream": "2.2.0",
|
|
20
|
-
"is-relative-path": "2.0.0",
|
|
21
20
|
"fs-extra": "10.0.0",
|
|
22
21
|
"uid-number": "0.0.6",
|
|
23
22
|
"@teambit/harmony": "0.4.7",
|
|
23
|
+
"@teambit/cli": "0.0.1283",
|
|
24
24
|
"@teambit/component-id": "1.2.4",
|
|
25
|
+
"@teambit/legacy.utils": "0.0.28",
|
|
26
|
+
"@teambit/harmony.modules.get-basic-log": "0.0.85",
|
|
25
27
|
"@teambit/bit-error": "0.0.404",
|
|
26
28
|
"@teambit/component-version": "1.0.4",
|
|
29
|
+
"@teambit/component.snap-distance": "0.0.85",
|
|
30
|
+
"@teambit/config-store": "0.0.163",
|
|
27
31
|
"@teambit/lane-id": "0.0.312",
|
|
32
|
+
"@teambit/legacy.cli.error": "0.0.30",
|
|
33
|
+
"@teambit/legacy.constants": "0.0.19",
|
|
34
|
+
"@teambit/legacy.logger": "0.0.30",
|
|
35
|
+
"@teambit/legacy.scope": "0.0.84",
|
|
36
|
+
"@teambit/toolbox.crypto.sha1": "0.0.10",
|
|
37
|
+
"@teambit/component.sources": "0.0.136",
|
|
28
38
|
"@teambit/legacy-bit-id": "1.1.3",
|
|
29
|
-
"@teambit/
|
|
30
|
-
"@teambit/
|
|
31
|
-
"@teambit/legacy.
|
|
32
|
-
"@teambit/
|
|
33
|
-
"@teambit/
|
|
34
|
-
"@teambit/config-store": "0.0.0-7477d0d8764ecd8124f856daa6c01ae7f02e73e1",
|
|
35
|
-
"@teambit/legacy.cli.error": "0.0.21",
|
|
36
|
-
"@teambit/legacy.constants": "0.0.12",
|
|
37
|
-
"@teambit/legacy.logger": "0.0.21",
|
|
38
|
-
"@teambit/legacy.scope": "0.0.55",
|
|
39
|
-
"@teambit/toolbox.crypto.sha1": "0.0.7",
|
|
40
|
-
"@teambit/component.sources": "0.0.107",
|
|
41
|
-
"@teambit/legacy-component-log": "0.0.407",
|
|
42
|
-
"@teambit/legacy.consumer-component": "0.0.56",
|
|
43
|
-
"@teambit/legacy.consumer-config": "0.0.55",
|
|
44
|
-
"@teambit/legacy.extension-data": "0.0.57",
|
|
45
|
-
"@teambit/pkg.modules.semver-helper": "0.0.11",
|
|
39
|
+
"@teambit/legacy-component-log": "0.0.412",
|
|
40
|
+
"@teambit/legacy.consumer-component": "0.0.85",
|
|
41
|
+
"@teambit/legacy.consumer-config": "0.0.84",
|
|
42
|
+
"@teambit/legacy.extension-data": "0.0.86",
|
|
43
|
+
"@teambit/pkg.modules.semver-helper": "0.0.17",
|
|
46
44
|
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
|
47
|
-
"@teambit/
|
|
48
|
-
"@teambit/
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/harmony.modules.concurrency": "0.0.
|
|
51
|
-
"@teambit/toolbox.promise.map-pool": "0.0.
|
|
52
|
-
"@teambit/harmony.modules.in-memory-cache": "0.0.
|
|
53
|
-
"@teambit/toolbox.fs.remove-empty-dir": "0.0.
|
|
45
|
+
"@teambit/graph.cleargraph": "0.0.11",
|
|
46
|
+
"@teambit/bit.get-bit-version": "0.0.10",
|
|
47
|
+
"@teambit/semantics.doc-parser": "0.0.92",
|
|
48
|
+
"@teambit/harmony.modules.concurrency": "0.0.20",
|
|
49
|
+
"@teambit/toolbox.promise.map-pool": "0.0.9",
|
|
50
|
+
"@teambit/harmony.modules.in-memory-cache": "0.0.23",
|
|
51
|
+
"@teambit/toolbox.fs.remove-empty-dir": "0.0.8",
|
|
52
|
+
"@teambit/graph": "0.0.0-0f2083e2364b36dbdec72d53bbc6adaf7d224444"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@types/semver": "7.5.8",
|
|
57
56
|
"@types/lodash": "4.14.165",
|
|
58
57
|
"@types/uuid": "8.3.4",
|
|
59
58
|
"@types/fs-extra": "9.0.7",
|
|
60
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
|
59
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.79"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
63
|
-
"chai": "
|
|
64
|
-
"@types/chai": "
|
|
62
|
+
"chai": "5.2.1",
|
|
63
|
+
"@types/chai": "5.2.2"
|
|
65
64
|
},
|
|
66
65
|
"license": "Apache-2.0",
|
|
67
66
|
"optionalDependencies": {},
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ScopeJson } from '@teambit/legacy.scope';
|
|
2
|
-
export type ContentTransformer = (content: Buffer) => Buffer;
|
|
3
|
-
export declare function onPersist(scopePath: string, scopeJson: ScopeJson): ContentTransformer;
|
|
4
|
-
export declare function onRead(scopePath: string, scopeJson: ScopeJson): ContentTransformer;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.onPersist = onPersist;
|
|
7
|
-
exports.onRead = onRead;
|
|
8
|
-
function _isRelativePath() {
|
|
9
|
-
const data = _interopRequireDefault(require("is-relative-path"));
|
|
10
|
-
_isRelativePath = function () {
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
function _path() {
|
|
16
|
-
const data = _interopRequireDefault(require("path"));
|
|
17
|
-
_path = function () {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
function loadHooks(scopePath, scopeJson) {
|
|
24
|
-
const hooksPath = scopeJson.hooksPath;
|
|
25
|
-
if (hooksPath) {
|
|
26
|
-
const hooksFinalPath = (0, _isRelativePath().default)(hooksPath) ? _path().default.join(scopePath, hooksPath) : hooksPath;
|
|
27
|
-
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
28
|
-
const hooks = require(hooksFinalPath);
|
|
29
|
-
return hooks;
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
function onPersist(scopePath, scopeJson) {
|
|
34
|
-
const defaultFunc = content => content;
|
|
35
|
-
const hooks = loadHooks(scopePath, scopeJson);
|
|
36
|
-
if (hooks) {
|
|
37
|
-
const onReadFunction = hooks.onPersist;
|
|
38
|
-
if (onReadFunction) {
|
|
39
|
-
return onReadFunction;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return defaultFunc;
|
|
43
|
-
}
|
|
44
|
-
function onRead(scopePath, scopeJson) {
|
|
45
|
-
const defaultFunc = content => content;
|
|
46
|
-
const hooks = loadHooks(scopePath, scopeJson);
|
|
47
|
-
if (hooks) {
|
|
48
|
-
const onReadFunction = hooks.onRead;
|
|
49
|
-
if (onReadFunction) {
|
|
50
|
-
return onReadFunction;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return defaultFunc;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=repository-hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_isRelativePath","data","_interopRequireDefault","require","_path","e","__esModule","default","loadHooks","scopePath","scopeJson","hooksPath","hooksFinalPath","isRelative","path","join","hooks","undefined","onPersist","defaultFunc","content","onReadFunction","onRead"],"sources":["repository-hooks.ts"],"sourcesContent":["import isRelative from 'is-relative-path';\nimport path from 'path';\n\nimport { ScopeJson } from '@teambit/legacy.scope';\n\nexport type ContentTransformer = (content: Buffer) => Buffer;\n\nfunction loadHooks(scopePath: string, scopeJson: ScopeJson): any | undefined {\n const hooksPath = scopeJson.hooksPath;\n if (hooksPath) {\n const hooksFinalPath = isRelative(hooksPath) ? path.join(scopePath, hooksPath) : hooksPath;\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const hooks = require(hooksFinalPath);\n return hooks;\n }\n return undefined;\n}\n\nexport function onPersist(scopePath: string, scopeJson: ScopeJson): ContentTransformer {\n const defaultFunc = (content) => content;\n const hooks = loadHooks(scopePath, scopeJson);\n if (hooks) {\n const onReadFunction = hooks.onPersist;\n if (onReadFunction) {\n return onReadFunction;\n }\n }\n return defaultFunc;\n}\n\nexport function onRead(scopePath: string, scopeJson: ScopeJson): ContentTransformer {\n const defaultFunc = (content) => content;\n\n const hooks = loadHooks(scopePath, scopeJson);\n if (hooks) {\n const onReadFunction = hooks.onRead;\n if (onReadFunction) {\n return onReadFunction;\n }\n }\n return defaultFunc;\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,gBAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,eAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwB,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMxB,SAASG,SAASA,CAACC,SAAiB,EAAEC,SAAoB,EAAmB;EAC3E,MAAMC,SAAS,GAAGD,SAAS,CAACC,SAAS;EACrC,IAAIA,SAAS,EAAE;IACb,MAAMC,cAAc,GAAG,IAAAC,yBAAU,EAACF,SAAS,CAAC,GAAGG,eAAI,CAACC,IAAI,CAACN,SAAS,EAAEE,SAAS,CAAC,GAAGA,SAAS;IAC1F;IACA,MAAMK,KAAK,GAAGb,OAAO,CAACS,cAAc,CAAC;IACrC,OAAOI,KAAK;EACd;EACA,OAAOC,SAAS;AAClB;AAEO,SAASC,SAASA,CAACT,SAAiB,EAAEC,SAAoB,EAAsB;EACrF,MAAMS,WAAW,GAAIC,OAAO,IAAKA,OAAO;EACxC,MAAMJ,KAAK,GAAGR,SAAS,CAACC,SAAS,EAAEC,SAAS,CAAC;EAC7C,IAAIM,KAAK,EAAE;IACT,MAAMK,cAAc,GAAGL,KAAK,CAACE,SAAS;IACtC,IAAIG,cAAc,EAAE;MAClB,OAAOA,cAAc;IACvB;EACF;EACA,OAAOF,WAAW;AACpB;AAEO,SAASG,MAAMA,CAACb,SAAiB,EAAEC,SAAoB,EAAsB;EAClF,MAAMS,WAAW,GAAIC,OAAO,IAAKA,OAAO;EAExC,MAAMJ,KAAK,GAAGR,SAAS,CAACC,SAAS,EAAEC,SAAS,CAAC;EAC7C,IAAIM,KAAK,EAAE;IACT,MAAMK,cAAc,GAAGL,KAAK,CAACM,MAAM;IACnC,IAAID,cAAc,EAAE;MAClB,OAAOA,cAAc;IACvB;EACF;EACA,OAAOF,WAAW;AACpB","ignoreList":[]}
|