@teambit/tracker 0.0.97 → 0.0.99
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/tracker.main.runtime.d.ts +7 -5
- package/dist/tracker.main.runtime.js +17 -5
- package/dist/tracker.main.runtime.js.map +1 -1
- package/package-tar/teambit-tracker-0.0.99.tgz +0 -0
- package/package.json +8 -7
- package/package-tar/teambit-tracker-0.0.97.tgz +0 -0
- /package/dist/{preview-1685331045403.js → preview-1685503265901.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
2
|
import { Workspace } from '@teambit/workspace';
|
|
3
|
+
import { Logger, LoggerMain } from '@teambit/logger';
|
|
3
4
|
import { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';
|
|
4
5
|
import { AddActionResults, AddProps, Warnings } from './add-components';
|
|
5
6
|
export declare type TrackResult = {
|
|
@@ -18,10 +19,8 @@ export declare type TrackData = {
|
|
|
18
19
|
};
|
|
19
20
|
export declare class TrackerMain {
|
|
20
21
|
private workspace;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static dependencies: import("@teambit/harmony").Aspect[];
|
|
24
|
-
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
22
|
+
private logger;
|
|
23
|
+
constructor(workspace: Workspace, logger: Logger);
|
|
25
24
|
/**
|
|
26
25
|
* add a new component to the .bitmap file.
|
|
27
26
|
* this method only adds the records in memory but doesn't persist to the filesystem.
|
|
@@ -46,6 +45,9 @@ export declare class TrackerMain {
|
|
|
46
45
|
* otherwise, it is self-hosted
|
|
47
46
|
*/
|
|
48
47
|
private isHostedByBit;
|
|
49
|
-
static
|
|
48
|
+
static slots: never[];
|
|
49
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
50
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
51
|
+
static provider([cli, workspace, loggerMain]: [CLIMain, Workspace, LoggerMain]): Promise<TrackerMain>;
|
|
50
52
|
}
|
|
51
53
|
export default TrackerMain;
|
|
@@ -36,6 +36,13 @@ function _workspace() {
|
|
|
36
36
|
};
|
|
37
37
|
return data;
|
|
38
38
|
}
|
|
39
|
+
function _logger() {
|
|
40
|
+
const data = require("@teambit/logger");
|
|
41
|
+
_logger = function () {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
39
46
|
function _addCmd() {
|
|
40
47
|
const data = require("./add-cmd");
|
|
41
48
|
_addCmd = function () {
|
|
@@ -60,9 +67,11 @@ function _tracker() {
|
|
|
60
67
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
68
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
69
|
class TrackerMain {
|
|
63
|
-
constructor(workspace) {
|
|
70
|
+
constructor(workspace, logger) {
|
|
64
71
|
this.workspace = workspace;
|
|
72
|
+
this.logger = logger;
|
|
65
73
|
}
|
|
74
|
+
|
|
66
75
|
/**
|
|
67
76
|
* add a new component to the .bitmap file.
|
|
68
77
|
* this method only adds the records in memory but doesn't persist to the filesystem.
|
|
@@ -128,7 +137,9 @@ class TrackerMain {
|
|
|
128
137
|
if (isSelfHosted) return scopeName;
|
|
129
138
|
const wsDefaultScope = this.workspace.defaultScope;
|
|
130
139
|
if (!wsDefaultScope.includes('.')) {
|
|
131
|
-
|
|
140
|
+
this.logger.warn(`the entered scope ${scopeName} has no owner nor the defaultScope in workspace.jsonc`);
|
|
141
|
+
// it's possible that the user entered a non-exist scope just to test the command and will change it later.
|
|
142
|
+
return scopeName;
|
|
132
143
|
}
|
|
133
144
|
const [owner] = wsDefaultScope.split('.');
|
|
134
145
|
return `${owner}.${scopeName}`;
|
|
@@ -143,15 +154,16 @@ class TrackerMain {
|
|
|
143
154
|
const remotes = await this.workspace.scope._legacyRemotes();
|
|
144
155
|
return remotes.isHub(scopeName);
|
|
145
156
|
}
|
|
146
|
-
static async provider([cli, workspace]) {
|
|
147
|
-
const
|
|
157
|
+
static async provider([cli, workspace, loggerMain]) {
|
|
158
|
+
const logger = loggerMain.createLogger(_tracker().TrackerAspect.id);
|
|
159
|
+
const trackerMain = new TrackerMain(workspace, logger);
|
|
148
160
|
cli.register(new (_addCmd().AddCmd)(trackerMain));
|
|
149
161
|
return trackerMain;
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
exports.TrackerMain = TrackerMain;
|
|
153
165
|
(0, _defineProperty2().default)(TrackerMain, "slots", []);
|
|
154
|
-
(0, _defineProperty2().default)(TrackerMain, "dependencies", [_cli().CLIAspect, _workspace().default]);
|
|
166
|
+
(0, _defineProperty2().default)(TrackerMain, "dependencies", [_cli().CLIAspect, _workspace().default, _logger().LoggerAspect]);
|
|
155
167
|
(0, _defineProperty2().default)(TrackerMain, "runtime", _cli().MainRuntime);
|
|
156
168
|
_tracker().TrackerAspect.addRuntime(TrackerMain);
|
|
157
169
|
var _default = TrackerMain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TrackerMain","constructor","workspace","track","trackData","defaultScope","addOwnerToScopeName","undefined","addComponent","AddComponents","componentPaths","rootDir","id","componentName","main","mainFile","override","config","result","add","addedComponent","addedComponents","name","files","map","f","relativePath","warnings","addForCLI","addProps","OutsideWorkspaceError","addContext","shouldHandleOutOfSync","env","addEnvToConfig","addComponents","addResults","consumer","onDestroy","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","EnvsAspect","toStringWithoutVersion","scopeName","includes","isSelfHosted","isHostedByBit","wsDefaultScope","
|
|
1
|
+
{"version":3,"names":["TrackerMain","constructor","workspace","logger","track","trackData","defaultScope","addOwnerToScopeName","undefined","addComponent","AddComponents","componentPaths","rootDir","id","componentName","main","mainFile","override","config","result","add","addedComponent","addedComponents","name","files","map","f","relativePath","warnings","addForCLI","addProps","OutsideWorkspaceError","addContext","shouldHandleOutOfSync","env","addEnvToConfig","addComponents","addResults","consumer","onDestroy","userEnvId","resolveComponentId","userEnvIdWithPotentialVersion","resolveEnvIdWithPotentialVersionForConfig","EnvsAspect","toStringWithoutVersion","scopeName","includes","isSelfHosted","isHostedByBit","wsDefaultScope","warn","owner","split","remotes","scope","_legacyRemotes","isHub","provider","cli","loggerMain","createLogger","TrackerAspect","trackerMain","register","AddCmd","CLIAspect","WorkspaceAspect","LoggerAspect","MainRuntime","addRuntime"],"sources":["tracker.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport EnvsAspect from '@teambit/envs';\nimport WorkspaceAspect, { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AddCmd } from './add-cmd';\nimport AddComponents, { AddActionResults, AddContext, AddProps, Warnings } from './add-components';\nimport { TrackerAspect } from './tracker.aspect';\n\nexport type TrackResult = { componentName: string; files: string[]; warnings: Warnings };\n\nexport type TrackData = {\n rootDir: PathOsBasedRelative; // path relative to the workspace\n componentName?: string; // if empty, it'll be generated from the path\n mainFile?: string; // if empty, attempts will be made to guess the best candidate\n defaultScope?: string; // can be entered as part of \"bit create\" command, helpful for out-of-sync logic\n config?: { [aspectName: string]: any }; // config specific to this component, which overrides variants of workspace.jsonc\n};\n\nexport class TrackerMain {\n constructor(private workspace: Workspace, private logger: Logger) {}\n\n /**\n * add a new component to the .bitmap file.\n * this method only adds the records in memory but doesn't persist to the filesystem.\n * to write the .bitmap file once completed, run \"await this.bitMap.write();\"\n */\n async track(trackData: TrackData): Promise<TrackResult> {\n const defaultScope = trackData.defaultScope ? await this.addOwnerToScopeName(trackData.defaultScope) : undefined;\n const addComponent = new AddComponents(\n { workspace: this.workspace },\n {\n componentPaths: [trackData.rootDir],\n id: trackData.componentName,\n main: trackData.mainFile,\n override: false,\n defaultScope,\n config: trackData.config,\n }\n );\n const result = await addComponent.add();\n const addedComponent = result.addedComponents[0];\n const componentName = addedComponent?.id.name || (trackData.componentName as string);\n const files = addedComponent?.files.map((f) => f.relativePath) || [];\n return { componentName, files, warnings: result.warnings };\n }\n\n async addForCLI(addProps: AddProps): Promise<AddActionResults> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const addContext: AddContext = { workspace: this.workspace };\n addProps.shouldHandleOutOfSync = true;\n if (addProps.env) {\n const config = {};\n await this.addEnvToConfig(addProps.env, config);\n addProps.config = config;\n }\n const addComponents = new AddComponents(addContext, addProps);\n const addResults = await addComponents.add();\n await this.workspace.consumer.onDestroy();\n\n return addResults;\n }\n\n async addEnvToConfig(env: string, config: { [aspectName: string]: any }) {\n const userEnvId = await this.workspace.resolveComponentId(env);\n const userEnvIdWithPotentialVersion = await this.workspace.resolveEnvIdWithPotentialVersionForConfig(userEnvId);\n config[userEnvIdWithPotentialVersion] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnvId.toStringWithoutVersion();\n }\n\n /**\n * scopes in bit.dev are \"owner.collection\".\n * we might have the scope-name only without the owner and we need to retrieve it from the defaultScope in the\n * workspace.jsonc file.\n *\n * @param scopeName scopeName that might not have the owner part.\n * @returns full scope name\n */\n private async addOwnerToScopeName(scopeName: string): Promise<string> {\n if (scopeName.includes('.')) return scopeName; // it has owner.\n const isSelfHosted = !(await this.isHostedByBit(scopeName));\n if (isSelfHosted) return scopeName;\n const wsDefaultScope = this.workspace.defaultScope;\n if (!wsDefaultScope.includes('.')) {\n this.logger.warn(`the entered scope ${scopeName} has no owner nor the defaultScope in workspace.jsonc`);\n // it's possible that the user entered a non-exist scope just to test the command and will change it later.\n return scopeName;\n }\n const [owner] = wsDefaultScope.split('.');\n return `${owner}.${scopeName}`;\n }\n\n /**\n * whether a scope is hosted by Bit cloud.\n * otherwise, it is self-hosted\n */\n private async isHostedByBit(scopeName: string): Promise<boolean> {\n // TODO: once scope create a new API for this, replace it with the new one\n const remotes = await this.workspace.scope._legacyRemotes();\n return remotes.isHub(scopeName);\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, loggerMain]: [CLIMain, Workspace, LoggerMain]) {\n const logger = loggerMain.createLogger(TrackerAspect.id);\n const trackerMain = new TrackerMain(workspace, logger);\n cli.register(new AddCmd(trackerMain));\n return trackerMain;\n }\n}\n\nTrackerAspect.addRuntime(TrackerMain);\n\nexport default TrackerMain;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAiD;AAAA;AAY1C,MAAMA,WAAW,CAAC;EACvBC,WAAW,CAASC,SAAoB,EAAUC,MAAc,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"@teambit/tracker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.99",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/tracker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "tracker",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.99"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
"@babel/runtime": "7.20.0",
|
|
22
22
|
"@teambit/harmony": "0.4.6",
|
|
23
23
|
"@teambit/bit-error": "0.0.402",
|
|
24
|
-
"@teambit/cli": "0.0.
|
|
25
|
-
"@teambit/workspace.modules.node-modules-linker": "0.0.
|
|
26
|
-
"@teambit/workspace": "0.0.
|
|
27
|
-
"@teambit/envs": "0.0.
|
|
24
|
+
"@teambit/cli": "0.0.721",
|
|
25
|
+
"@teambit/workspace.modules.node-modules-linker": "0.0.65",
|
|
26
|
+
"@teambit/workspace": "0.0.1068",
|
|
27
|
+
"@teambit/envs": "0.0.1068",
|
|
28
|
+
"@teambit/logger": "0.0.814"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/fs-extra": "9.0.7",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"@teambit/legacy": "1.0.
|
|
40
|
+
"@teambit/legacy": "1.0.501",
|
|
40
41
|
"react": "^16.8.0 || ^17.0.0",
|
|
41
42
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
42
43
|
},
|
|
Binary file
|
|
File without changes
|