@teambit/objects 0.0.0-fe8e30c7942d34e4dfb8bda5b2527ab810254a3d → 0.0.0-ff3121b14c6880670d2b2c275634315b73294711
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 +22 -5
- 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-list.d.ts +6 -0
- package/dist/objects/object-list.js +20 -0
- package/dist/objects/object-list.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 +23 -12
- 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 +36 -16
- 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-list.ts +14 -0
- 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 +29 -17
- package/objects/scope-index.ts +2 -3
- package/package.json +32 -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-1752679581363.js → preview-1765762480694.js} +0 -0
package/objects/repository.ts
CHANGED
|
@@ -3,37 +3,35 @@ 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 { writeFile } from '@teambit/legacy.utils';
|
|
14
|
+
import { glob } from 'glob';
|
|
13
15
|
import { removeEmptyDir } from '@teambit/toolbox.fs.remove-empty-dir';
|
|
14
16
|
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';
|
|
17
|
+
import type { Types, ScopeJson } from '@teambit/legacy.scope';
|
|
18
|
+
import { HashNotFound, OutdatedIndexJson, UnmergedComponents, RemoteLanes } from '@teambit/legacy.scope';
|
|
19
|
+
import type { IndexType, IndexItem } from './scope-index';
|
|
20
|
+
import { ScopeIndex } from './scope-index';
|
|
24
21
|
import BitObject from './object';
|
|
25
|
-
import { ObjectItem
|
|
22
|
+
import type { ObjectItem } from './object-list';
|
|
23
|
+
import { ObjectList } from './object-list';
|
|
26
24
|
import BitRawObject from './raw-object';
|
|
27
25
|
import Ref from './ref';
|
|
28
|
-
import {
|
|
29
|
-
import { getMaxSizeForObjects,
|
|
26
|
+
import type { InMemoryCache } from '@teambit/harmony.modules.in-memory-cache';
|
|
27
|
+
import { getMaxSizeForObjects, createInMemoryCache } from '@teambit/harmony.modules.in-memory-cache';
|
|
30
28
|
import { ScopeMeta, Lane, ModelComponent } from '../models';
|
|
31
29
|
|
|
30
|
+
type ContentTransformer = (content: Buffer) => Buffer;
|
|
32
31
|
const OBJECTS_BACKUP_DIR = `${OBJECTS_DIR}.bak`;
|
|
33
32
|
const TRASH_DIR = 'trash';
|
|
34
33
|
|
|
35
34
|
export default class Repository {
|
|
36
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
37
35
|
objects: { [key: string]: BitObject } = {};
|
|
38
36
|
objectsToRemove: Ref[] = [];
|
|
39
37
|
scopeJson: ScopeJson;
|
|
@@ -48,8 +46,8 @@ export default class Repository {
|
|
|
48
46
|
constructor(scopePath: string, scopeJson: ScopeJson) {
|
|
49
47
|
this.scopePath = scopePath;
|
|
50
48
|
this.scopeJson = scopeJson;
|
|
51
|
-
this.onRead =
|
|
52
|
-
this.onPersist =
|
|
49
|
+
this.onRead = (content: Buffer) => Repository.onPostObjectRead?.(content) || content;
|
|
50
|
+
this.onPersist = (content: Buffer) => Repository.onPreObjectPersist?.(content) || content;
|
|
53
51
|
this.cache = createInMemoryCache({ maxSize: getMaxSizeForObjects() });
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -92,6 +90,20 @@ export default class Repository {
|
|
|
92
90
|
|
|
93
91
|
static onPostObjectsPersist: () => Promise<void>;
|
|
94
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Hook for transforming content before objects are persisted to the filesystem.
|
|
95
|
+
* Note: This function cannot be async because it's used by the synchronous `loadSync` method
|
|
96
|
+
* which needs to maintain sync behavior for compatibility with existing code.
|
|
97
|
+
*/
|
|
98
|
+
static onPreObjectPersist: (content: Buffer) => Buffer;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Hook for transforming content after objects are read from the filesystem.
|
|
102
|
+
* Note: This function cannot be async because it's used by the synchronous `loadSync` method
|
|
103
|
+
* which needs to maintain sync behavior for compatibility with existing code.
|
|
104
|
+
*/
|
|
105
|
+
static onPostObjectRead: (content: Buffer) => Buffer;
|
|
106
|
+
|
|
95
107
|
async reLoadScopeIndex() {
|
|
96
108
|
this.scopeIndex = await this.loadOptionallyCreateScopeIndex();
|
|
97
109
|
}
|
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,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/objects",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ff3121b14c6880670d2b2c275634315b73294711",
|
|
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": "ff3121b14c6880670d2b2c275634315b73294711"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@pnpm/dependency-path": "1001.
|
|
13
|
-
"@pnpm/lockfile.types": "^
|
|
12
|
+
"@pnpm/dependency-path": "1001.1.7",
|
|
13
|
+
"@pnpm/lockfile.types": "^1002.0.6",
|
|
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",
|
|
21
|
+
"glob": "13.0.0",
|
|
22
22
|
"uid-number": "0.0.6",
|
|
23
23
|
"@teambit/harmony": "0.4.7",
|
|
24
24
|
"@teambit/component-id": "1.2.4",
|
|
@@ -26,42 +26,42 @@
|
|
|
26
26
|
"@teambit/component-version": "1.0.4",
|
|
27
27
|
"@teambit/lane-id": "0.0.312",
|
|
28
28
|
"@teambit/legacy-bit-id": "1.1.3",
|
|
29
|
-
"@teambit/graph.cleargraph": "0.0.11",
|
|
30
|
-
"@teambit/cli": "0.0.0-81601363f5d92834876d7fc06c2f2e36696ab1c2",
|
|
31
|
-
"@teambit/legacy.utils": "0.0.21",
|
|
32
|
-
"@teambit/harmony.modules.get-basic-log": "0.0.56",
|
|
33
|
-
"@teambit/component.snap-distance": "0.0.56",
|
|
34
|
-
"@teambit/config-store": "0.0.0-1899900ee3812e7608cdc89f69d6cd54e5b87309",
|
|
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",
|
|
46
29
|
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
|
47
|
-
"@teambit/
|
|
48
|
-
"@teambit/
|
|
49
|
-
"@teambit/
|
|
50
|
-
"@teambit/harmony.modules.
|
|
51
|
-
"@teambit/
|
|
52
|
-
"@teambit/
|
|
53
|
-
"@teambit/
|
|
30
|
+
"@teambit/graph.cleargraph": "0.0.11",
|
|
31
|
+
"@teambit/cli": "0.0.0-69a03b2177c66dececbe9883c1fcd9c630beda4a",
|
|
32
|
+
"@teambit/legacy.utils": "0.0.0-6295a8192f6b5690d60e820e03b50b49f6e073da",
|
|
33
|
+
"@teambit/harmony.modules.get-basic-log": "0.0.0-47a2e6f6b3937ad7e7ac6d560fb367ba0ae10cea",
|
|
34
|
+
"@teambit/component.snap-distance": "0.0.0-2274755b369ae5a0699b1b1f59e27784a89cc53a",
|
|
35
|
+
"@teambit/config-store": "0.0.0-1ff31af92694d12576e1e3a72baec12f81890d0c",
|
|
36
|
+
"@teambit/legacy.cli.error": "0.0.0-4b4ca3eae38b41b16b582e88cc71df7486bb9320",
|
|
37
|
+
"@teambit/legacy.constants": "0.0.0-d75a19d39ec69adb051d384b260cd1035a1cb3f6",
|
|
38
|
+
"@teambit/legacy.logger": "0.0.0-0cf1108d874f2b5ba9c3fd3a3b422e9bf48e99c5",
|
|
39
|
+
"@teambit/legacy.scope": "0.0.0-4d81bcba0c98a9aff72479ad04da65c4ca7d4e90",
|
|
40
|
+
"@teambit/toolbox.crypto.sha1": "0.0.0-1aab01159fc75f42007d28d2b4b7eee55c5f8022",
|
|
41
|
+
"@teambit/component.sources": "0.0.0-b3da4721a60c5b9c9cb6ea87432561899b4c15ac",
|
|
42
|
+
"@teambit/legacy-component-log": "0.0.0-de6dd7d5cab27d5a97a9550195a4baaea45bc915",
|
|
43
|
+
"@teambit/legacy.consumer-component": "0.0.0-ee4ca34eb70b6969a710bdb63d229a4b2281480c",
|
|
44
|
+
"@teambit/legacy.consumer-config": "0.0.0-83bab93821cb0e23164cdd37894626985d3f06cb",
|
|
45
|
+
"@teambit/legacy.extension-data": "0.0.0-3990447ef57cae9d7d1d1ca8a0361873d610cc14",
|
|
46
|
+
"@teambit/pkg.modules.semver-helper": "0.0.0-6390eb2fd66bae6c4e6ae5db48a0a2d5542a827f",
|
|
47
|
+
"@teambit/bit.get-bit-version": "0.0.0-c0d1877a0377936650ad85593ecd49745504282b",
|
|
48
|
+
"@teambit/semantics.doc-parser": "0.0.0-9cd4d1f915ff7bb5f83ebcb0160191ace7026628",
|
|
49
|
+
"@teambit/graph": "0.0.0-a9bb47c7ba50e86f9149a45b5f62b1af653a55de",
|
|
50
|
+
"@teambit/harmony.modules.concurrency": "0.0.0-43f782bb55ca2196348e9a1e2393ce3a8459377b",
|
|
51
|
+
"@teambit/toolbox.promise.map-pool": "0.0.0-2c58e80bf30293b35bdd68bb5b9f4ff02907c5d8",
|
|
52
|
+
"@teambit/harmony.modules.in-memory-cache": "0.0.0-b0882c18906d00edf0ca7bdd784115e84cd40a3e",
|
|
53
|
+
"@teambit/toolbox.fs.remove-empty-dir": "0.0.0-cd8f2201e578f5c349b56a8333cff10824df6629"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/semver": "7.5.8",
|
|
57
57
|
"@types/lodash": "4.14.165",
|
|
58
58
|
"@types/uuid": "8.3.4",
|
|
59
59
|
"@types/fs-extra": "9.0.7",
|
|
60
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0
|
|
60
|
+
"@teambit/harmony.envs.core-aspect-env": "0.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"chai": "
|
|
64
|
-
"@types/chai": "
|
|
63
|
+
"chai": "5.2.1",
|
|
64
|
+
"@types/chai": "5.2.2"
|
|
65
65
|
},
|
|
66
66
|
"license": "Apache-2.0",
|
|
67
67
|
"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":[]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import isRelative from 'is-relative-path';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
import { ScopeJson } from '@teambit/legacy.scope';
|
|
5
|
-
|
|
6
|
-
export type ContentTransformer = (content: Buffer) => Buffer;
|
|
7
|
-
|
|
8
|
-
function loadHooks(scopePath: string, scopeJson: ScopeJson): any | undefined {
|
|
9
|
-
const hooksPath = scopeJson.hooksPath;
|
|
10
|
-
if (hooksPath) {
|
|
11
|
-
const hooksFinalPath = isRelative(hooksPath) ? path.join(scopePath, hooksPath) : hooksPath;
|
|
12
|
-
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
13
|
-
const hooks = require(hooksFinalPath);
|
|
14
|
-
return hooks;
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function onPersist(scopePath: string, scopeJson: ScopeJson): ContentTransformer {
|
|
20
|
-
const defaultFunc = (content) => content;
|
|
21
|
-
const hooks = loadHooks(scopePath, scopeJson);
|
|
22
|
-
if (hooks) {
|
|
23
|
-
const onReadFunction = hooks.onPersist;
|
|
24
|
-
if (onReadFunction) {
|
|
25
|
-
return onReadFunction;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return defaultFunc;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function onRead(scopePath: string, scopeJson: ScopeJson): ContentTransformer {
|
|
32
|
-
const defaultFunc = (content) => content;
|
|
33
|
-
|
|
34
|
-
const hooks = loadHooks(scopePath, scopeJson);
|
|
35
|
-
if (hooks) {
|
|
36
|
-
const onReadFunction = hooks.onRead;
|
|
37
|
-
if (onReadFunction) {
|
|
38
|
-
return onReadFunction;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return defaultFunc;
|
|
42
|
-
}
|
|
File without changes
|