@teambit/workspace 1.0.937 → 1.0.939

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.
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.937/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.937/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.939/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.939/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -11,7 +11,7 @@ export declare class CompFiles {
11
11
  private repository;
12
12
  private currentFiles;
13
13
  readonly compDir: PathLinux;
14
- private modelFiles;
14
+ readonly modelFiles: SourceFileModel[];
15
15
  constructor(id: ComponentID, repository: Repository, currentFiles: SourceFile[], compDir: PathLinux, modelFiles?: SourceFileModel[]);
16
16
  isModified(): boolean;
17
17
  getCurrentFiles(): SourceFile[];
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","modelFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/component.sources';\nimport type { Repository, SourceFileModel } from '@teambit/objects';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\ntype PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path.\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n private modelFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.modelFiles.length) return false;\n if (this.currentFiles.length !== this.modelFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.modelFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.modelFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIyB;;AAGlB,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EACnBC,UAA6B,GAAG,EAAE,EAC1C;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA,YAA0B;IA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ACnB,QAAQ,EAAE,OAAO,KAAK;QAC3B,IAAIA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,WAAW;QAC/E,OAAO,UAAU;MACnB,CAAC;MACDW,GAAG,CAACnB,IAAI,CAACK,QAAQ,CAAC,GAAGe,OAAO,CAAC,CAAC;MAC9B,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,IAAI,CAACvB,UAAU,CAACyB,OAAO,CAAEpB,QAAQ,IAAK;MACpC,MAAMqB,WAAW,GAAG,IAAI,CAAC5B,YAAY,CAACQ,IAAI,CAAEqB,CAAC,IAAKA,CAAC,CAAClB,QAAQ,KAAKJ,QAAQ,CAACG,YAAY,CAAC;MACvF,IAAI,CAACkB,WAAW,EAAE;QAChBL,MAAM,CAAChB,QAAQ,CAACG,YAAY,CAAC,GAAG,SAAS;MAC3C;IACF,CAAC,CAAC;IACF,OAAOa,MAAM;EACf;AACF;AAACO,OAAA,CAAAlC,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_component","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","modelFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/component.sources';\nimport type { Repository, SourceFileModel } from '@teambit/objects';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\ntype PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path.\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n readonly modelFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.modelFiles.length) return false;\n if (this.currentFiles.length !== this.modelFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.modelFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.modelFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIyB;;AAGlB,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EAClBC,UAA6B,GAAG,EAAE,EAC3C;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA,YAA0B;IAAA,KACzBC,OAAkB,GAAlBA,OAAkB;IAAA,KAClBC,UAA6B,GAA7BA,UAA6B;EACrC;EAEHC,UAAUA,CA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,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,WAAW;QAC/E,OAAO,UAAU;MACnB,CAAC;MACDW,GAAG,CAACnB,IAAI,CAACK,QAAQ,CAAC,GAAGe,OAAO,CAAC,CAAC;MAC9B,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,IAAI,CAACvB,UAAU,CAACyB,OAAO,CAAEpB,QAAQ,IAAK;MACpC,MAAMqB,WAAW,GAAG,IAAI,CAAC5B,YAAY,CAACQ,IAAI,CAAEqB,CAAC,IAAKA,CAAC,CAAClB,QAAQ,KAAKJ,QAAQ,CAACG,YAAY,CAAC;MACvF,IAAI,CAACkB,WAAW,EAAE;QAChBL,MAAM,CAAChB,QAAQ,CAACG,YAAY,CAAC,GAAG,SAAS;MAC3C;IACF,CAAC,CAAC;IACF,OAAOa,MAAM;EACf;AACF;AAACO,OAAA,CAAAlC,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -532,6 +532,7 @@ export declare class Workspace implements ComponentFactory {
532
532
  * @param componentPath can be relative or absolute. supports Linux and Windows
533
533
  */
534
534
  getComponentIdByPath(componentPath: PathOsBased): Promise<ComponentID | undefined>;
535
+ private resolveIdFromRootDir;
535
536
  private componentConfigFileFromComponentDirAndName;
536
537
  /**
537
538
  * load aspects from the workspace and if not exists in the workspace, load from the scope.
package/dist/workspace.js CHANGED
@@ -1755,6 +1755,11 @@ the following envs are used in this workspace: ${(0, _lodash().uniq)(availableEn
1755
1755
  }
1756
1756
  return undefined;
1757
1757
  }
1758
+ resolveIdFromRootDir(id) {
1759
+ if (typeof id !== 'string') return undefined;
1760
+ const normalized = _path().default.posix.normalize((0, _toolboxPath().pathNormalizeToLinux)(id)).replace(/^\.\//, '');
1761
+ return this.consumer.bitMap.getComponentIdByRootPath(normalized);
1762
+ }
1758
1763
  async componentConfigFileFromComponentDirAndName(relativeComponentDir) {
1759
1764
  let componentConfigFile;
1760
1765
  if (relativeComponentDir) {
@@ -1931,6 +1936,8 @@ the following envs are used in this workspace: ${(0, _lodash().uniq)(availableEn
1931
1936
  * Transform the id to ComponentId and get the exact id as appear in bitmap
1932
1937
  */
1933
1938
  async resolveComponentId(id) {
1939
+ const idFromPath = this.resolveIdFromRootDir(id);
1940
+ if (idFromPath) return idFromPath;
1934
1941
  if (id instanceof _legacyBitId().BitId && id.hasScope() && id.hasVersion()) {
1935
1942
  // an optimization to make it faster when BitId is passed
1936
1943
  return _componentId().ComponentID.fromLegacy(id);