@teambit/builder 0.0.815 → 0.0.818

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.
Files changed (50) hide show
  1. package/artifact/artifact-extractor.ts +31 -30
  2. package/artifact/artifact-factory.ts +10 -17
  3. package/artifact/artifact-list.ts +61 -19
  4. package/artifact/artifact.ts +27 -18
  5. package/artifact/fs-artifact.ts +21 -0
  6. package/artifact/index.ts +1 -0
  7. package/dist/artifact/artifact-extractor.js +43 -26
  8. package/dist/artifact/artifact-extractor.js.map +1 -1
  9. package/dist/artifact/artifact-factory.d.ts +4 -4
  10. package/dist/artifact/artifact-factory.js +9 -10
  11. package/dist/artifact/artifact-factory.js.map +1 -1
  12. package/dist/artifact/artifact-list.d.ts +15 -12
  13. package/dist/artifact/artifact-list.js +68 -13
  14. package/dist/artifact/artifact-list.js.map +1 -1
  15. package/dist/artifact/artifact.d.ts +8 -26
  16. package/dist/artifact/artifact.js +33 -14
  17. package/dist/artifact/artifact.js.map +1 -1
  18. package/dist/artifact/fs-artifact.d.ts +18 -0
  19. package/dist/artifact/fs-artifact.js +35 -0
  20. package/dist/artifact/fs-artifact.js.map +1 -0
  21. package/dist/artifact/index.d.ts +1 -0
  22. package/dist/artifact/index.js +16 -0
  23. package/dist/artifact/index.js.map +1 -1
  24. package/dist/build-pipe.d.ts +2 -2
  25. package/dist/build-pipe.js.map +1 -1
  26. package/dist/build-pipeline-result-list.js +2 -2
  27. package/dist/build-pipeline-result-list.js.map +1 -1
  28. package/dist/build-task.d.ts +5 -0
  29. package/dist/build-task.js.map +1 -1
  30. package/dist/builder.graphql.d.ts +80 -4
  31. package/dist/builder.graphql.js +122 -16
  32. package/dist/builder.graphql.js.map +1 -1
  33. package/dist/builder.main.runtime.d.ts +30 -16
  34. package/dist/builder.main.runtime.js +88 -41
  35. package/dist/builder.main.runtime.js.map +1 -1
  36. package/dist/builder.route.d.ts +20 -0
  37. package/dist/builder.route.js +145 -0
  38. package/dist/builder.route.js.map +1 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/storage/default-resolver.d.ts +2 -2
  42. package/dist/storage/default-resolver.js.map +1 -1
  43. package/dist/storage/storage-resolver.d.ts +3 -3
  44. package/dist/storage/storage-resolver.js.map +1 -1
  45. package/package-tar/teambit-builder-0.0.818.tgz +0 -0
  46. package/package.json +20 -14
  47. package/{preview-1660361218837.js → preview-1660620618310.js} +2 -2
  48. package/storage/default-resolver.ts +2 -2
  49. package/storage/storage-resolver.ts +3 -3
  50. package/package-tar/teambit-builder-0.0.815.tgz +0 -0
@@ -1,20 +1,20 @@
1
1
  import { Component, ComponentMap } from '@teambit/component';
2
2
  import { ArtifactDefinition } from './artifact-definition';
3
3
  import { ArtifactList } from './artifact-list';
4
- import { Artifact } from './artifact';
5
4
  import type { BuildContext, BuildTask } from '../build-task';
5
+ import { FsArtifact } from './fs-artifact';
6
6
  export declare const DEFAULT_CONTEXT = "component";
7
- export declare type ArtifactMap = ComponentMap<ArtifactList>;
7
+ export declare type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;
8
8
  export declare class ArtifactFactory {
9
9
  resolvePaths(root: string, def: ArtifactDefinition): string[];
10
10
  private getArtifactContextPath;
11
11
  private getArtifactContext;
12
- createFromComponent(context: BuildContext, component: Component, def: ArtifactDefinition, task: BuildTask): Artifact | undefined;
12
+ createFromComponent(context: BuildContext, component: Component, def: ArtifactDefinition, task: BuildTask): FsArtifact | undefined;
13
13
  private getStorageResolver;
14
14
  private toComponentMap;
15
15
  getRootDir(rootDir: string, def: ArtifactDefinition): string;
16
16
  /**
17
17
  * generate artifacts from a build context according to the spec defined in the artifact definitions.
18
18
  */
19
- generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList>;
19
+ generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList<FsArtifact>>;
20
20
  }
@@ -79,20 +79,20 @@ function _artifactList() {
79
79
  return data;
80
80
  }
81
81
 
82
- function _artifact() {
83
- const data = require("./artifact");
82
+ function _exceptions() {
83
+ const data = require("../exceptions");
84
84
 
85
- _artifact = function () {
85
+ _exceptions = function () {
86
86
  return data;
87
87
  };
88
88
 
89
89
  return data;
90
90
  }
91
91
 
92
- function _exceptions() {
93
- const data = require("../exceptions");
92
+ function _fsArtifact() {
93
+ const data = require("./fs-artifact");
94
94
 
95
- _exceptions = function () {
95
+ _fsArtifact = function () {
96
96
  return data;
97
97
  };
98
98
 
@@ -132,7 +132,6 @@ class ArtifactFactory {
132
132
  }
133
133
 
134
134
  createFromComponent(context, component, def, task) {
135
- const storageResolver = this.getStorageResolver(def);
136
135
  const contextPath = this.getArtifactContextPath(context, component, def);
137
136
  const rootDir = this.getRootDir(contextPath, def);
138
137
  const paths = this.resolvePaths(rootDir, def);
@@ -141,7 +140,7 @@ class ArtifactFactory {
141
140
  return undefined;
142
141
  }
143
142
 
144
- return new (_artifact().Artifact)(def, storageResolver, new (_artifactFiles().ArtifactFiles)(paths), rootDir, task);
143
+ return new (_fsArtifact().FsArtifact)(def, new (_artifactFiles().ArtifactFiles)(paths), task, rootDir);
145
144
  }
146
145
 
147
146
  getStorageResolver(def) {
@@ -152,7 +151,7 @@ class ArtifactFactory {
152
151
  return _component().ComponentMap.as(context.components, component => {
153
152
  const id = component.id.toString();
154
153
  const artifacts = artifactMap.filter(([targetId]) => targetId === id).map(([, artifact]) => artifact);
155
- return new (_artifactList().ArtifactList)(artifacts);
154
+ return _artifactList().ArtifactList.fromArray(artifacts);
156
155
  });
157
156
  }
158
157
 
@@ -176,7 +175,7 @@ class ArtifactFactory {
176
175
  const paths = this.resolvePaths(rootDir, def);
177
176
 
178
177
  if (paths && paths.length) {
179
- const artifact = new (_artifact().Artifact)(def, this.getStorageResolver(def), new (_artifactFiles().ArtifactFiles)(this.resolvePaths(rootDir, def)), rootDir, task);
178
+ const artifact = new (_fsArtifact().FsArtifact)(def, new (_artifactFiles().ArtifactFiles)(this.resolvePaths(rootDir, def)), task, rootDir);
180
179
  return context.components.forEach(component => {
181
180
  tupleArr.push([component.id.toString(), artifact]);
182
181
  });
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_CONTEXT","ArtifactFactory","resolvePaths","root","def","patternsFlattened","flatten","globPatterns","paths","globby","sync","cwd","getArtifactContextPath","context","component","artifactContext","getArtifactContext","capsulePath","capsuleNetwork","graphCapsules","getCapsule","id","path","CapsuleNotFound","capsulesRootDir","createFromComponent","task","storageResolver","getStorageResolver","contextPath","rootDir","getRootDir","length","undefined","Artifact","ArtifactFiles","DefaultResolver","toComponentMap","artifactMap","ComponentMap","as","components","toString","artifacts","filter","targetId","map","artifact","ArtifactList","join","generate","defs","tupleArr","forEach","capsuleDir","push"],"sources":["artifact-factory.ts"],"sourcesContent":["import { join } from 'path';\nimport globby from 'globby';\nimport { flatten } from 'lodash';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { ArtifactDefinition } from './artifact-definition';\nimport { DefaultResolver } from '../storage';\nimport { ArtifactList } from './artifact-list';\nimport { Artifact } from './artifact';\nimport type { BuildContext, BuildTask } from '../build-task';\nimport { CapsuleNotFound } from '../exceptions';\n\nexport const DEFAULT_CONTEXT = 'component';\n\nexport type ArtifactMap = ComponentMap<ArtifactList>;\n\nexport class ArtifactFactory {\n resolvePaths(root: string, def: ArtifactDefinition): string[] {\n const patternsFlattened = flatten(def.globPatterns);\n const paths = globby.sync(patternsFlattened, { cwd: root });\n return paths;\n }\n\n private getArtifactContextPath(context: BuildContext, component: Component, def: ArtifactDefinition) {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'component') {\n const capsulePath = context.capsuleNetwork.graphCapsules.getCapsule(component.id)?.path;\n if (!capsulePath) throw new CapsuleNotFound(component.id);\n return capsulePath;\n }\n\n return context.capsuleNetwork.capsulesRootDir;\n }\n\n private getArtifactContext(def: ArtifactDefinition) {\n return def.context || DEFAULT_CONTEXT;\n }\n\n createFromComponent(\n context: BuildContext,\n component: Component,\n def: ArtifactDefinition,\n task: BuildTask\n ): Artifact | undefined {\n const storageResolver = this.getStorageResolver(def);\n const contextPath = this.getArtifactContextPath(context, component, def);\n const rootDir = this.getRootDir(contextPath, def);\n const paths = this.resolvePaths(rootDir, def);\n if (!paths || !paths.length) {\n return undefined;\n }\n return new Artifact(def, storageResolver, new ArtifactFiles(paths), rootDir, task);\n }\n\n private getStorageResolver(def: ArtifactDefinition) {\n return def.storageResolver || new DefaultResolver();\n }\n\n private toComponentMap(context: BuildContext, artifactMap: [string, Artifact][]) {\n return ComponentMap.as<ArtifactList>(context.components, (component) => {\n const id = component.id.toString();\n const artifacts = artifactMap.filter(([targetId]) => targetId === id).map(([, artifact]) => artifact);\n\n return new ArtifactList(artifacts);\n });\n }\n\n getRootDir(rootDir: string, def: ArtifactDefinition) {\n if (!def.rootDir) return rootDir;\n return join(rootDir, def.rootDir);\n }\n\n /**\n * generate artifacts from a build context according to the spec defined in the artifact definitions.\n */\n generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList> {\n const tupleArr: [string, Artifact][] = [];\n\n defs.forEach((def) => {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'env') {\n const capsuleDir = context.capsuleNetwork.capsulesRootDir;\n const rootDir = this.getRootDir(capsuleDir, def);\n const paths = this.resolvePaths(rootDir, def);\n if (paths && paths.length) {\n const artifact = new Artifact(\n def,\n this.getStorageResolver(def),\n new ArtifactFiles(this.resolvePaths(rootDir, def)),\n rootDir,\n task\n );\n\n return context.components.forEach((component) => {\n tupleArr.push([component.id.toString(), artifact]);\n });\n }\n }\n\n return context.components.forEach((component) => {\n const artifact = this.createFromComponent(context, component, def, task);\n if (artifact) {\n tupleArr.push([component.id.toString(), artifact]);\n }\n });\n });\n\n return this.toComponentMap(context, tupleArr);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;EAAA;;EAA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QAC/C,MAAMiC,QAAQ,GAAG,KAAKtB,mBAAL,CAAyBZ,OAAzB,EAAkCC,SAAlC,EAA6CV,GAA7C,EAAkDsB,IAAlD,CAAjB;;QACA,IAAIqB,QAAJ,EAAc;UACZK,QAAQ,CAACG,IAAT,CAAc,CAACzC,SAAS,CAACO,EAAV,CAAaqB,QAAb,EAAD,EAA0BK,QAA1B,CAAd;QACD;MACF,CALM,CAAP;IAMD,CA3BD;IA6BA,OAAO,KAAKV,cAAL,CAAoBxB,OAApB,EAA6BuC,QAA7B,CAAP;EACD;;AA5F0B"}
1
+ {"version":3,"names":["DEFAULT_CONTEXT","ArtifactFactory","resolvePaths","root","def","patternsFlattened","flatten","globPatterns","paths","globby","sync","cwd","getArtifactContextPath","context","component","artifactContext","getArtifactContext","capsulePath","capsuleNetwork","graphCapsules","getCapsule","id","path","CapsuleNotFound","capsulesRootDir","createFromComponent","task","contextPath","rootDir","getRootDir","length","undefined","FsArtifact","ArtifactFiles","getStorageResolver","storageResolver","DefaultResolver","toComponentMap","artifactMap","ComponentMap","as","components","toString","artifacts","filter","targetId","map","artifact","ArtifactList","fromArray","join","generate","defs","tupleArr","forEach","capsuleDir","push"],"sources":["artifact-factory.ts"],"sourcesContent":["import { join } from 'path';\nimport globby from 'globby';\nimport { flatten } from 'lodash';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { ArtifactDefinition } from './artifact-definition';\nimport { DefaultResolver } from '../storage';\nimport { ArtifactList } from './artifact-list';\nimport type { BuildContext, BuildTask } from '../build-task';\nimport { CapsuleNotFound } from '../exceptions';\nimport { FsArtifact } from './fs-artifact';\n\nexport const DEFAULT_CONTEXT = 'component';\n\nexport type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;\n\nexport class ArtifactFactory {\n resolvePaths(root: string, def: ArtifactDefinition): string[] {\n const patternsFlattened = flatten(def.globPatterns);\n const paths = globby.sync(patternsFlattened, { cwd: root });\n return paths;\n }\n\n private getArtifactContextPath(context: BuildContext, component: Component, def: ArtifactDefinition) {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'component') {\n const capsulePath = context.capsuleNetwork.graphCapsules.getCapsule(component.id)?.path;\n if (!capsulePath) throw new CapsuleNotFound(component.id);\n return capsulePath;\n }\n\n return context.capsuleNetwork.capsulesRootDir;\n }\n\n private getArtifactContext(def: ArtifactDefinition) {\n return def.context || DEFAULT_CONTEXT;\n }\n\n createFromComponent(\n context: BuildContext,\n component: Component,\n def: ArtifactDefinition,\n task: BuildTask\n ): FsArtifact | undefined {\n const contextPath = this.getArtifactContextPath(context, component, def);\n const rootDir = this.getRootDir(contextPath, def);\n const paths = this.resolvePaths(rootDir, def);\n if (!paths || !paths.length) {\n return undefined;\n }\n return new FsArtifact(def, new ArtifactFiles(paths), task, rootDir);\n }\n\n private getStorageResolver(def: ArtifactDefinition) {\n return def.storageResolver || new DefaultResolver();\n }\n\n private toComponentMap(context: BuildContext, artifactMap: [string, FsArtifact][]) {\n return ComponentMap.as<ArtifactList<FsArtifact>>(context.components, (component) => {\n const id = component.id.toString();\n const artifacts = artifactMap.filter(([targetId]) => targetId === id).map(([, artifact]) => artifact);\n\n return ArtifactList.fromArray(artifacts);\n });\n }\n\n getRootDir(rootDir: string, def: ArtifactDefinition) {\n if (!def.rootDir) return rootDir;\n return join(rootDir, def.rootDir);\n }\n\n /**\n * generate artifacts from a build context according to the spec defined in the artifact definitions.\n */\n generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList<FsArtifact>> {\n const tupleArr: [string, FsArtifact][] = [];\n\n defs.forEach((def) => {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'env') {\n const capsuleDir = context.capsuleNetwork.capsulesRootDir;\n const rootDir = this.getRootDir(capsuleDir, def);\n const paths = this.resolvePaths(rootDir, def);\n if (paths && paths.length) {\n const artifact = new FsArtifact(def, new ArtifactFiles(this.resolvePaths(rootDir, def)), task, rootDir);\n\n return context.components.forEach((component) => {\n tupleArr.push([component.id.toString(), artifact]);\n });\n }\n }\n\n return context.components.forEach((component) => {\n const artifact = this.createFromComponent(context, component, def, task);\n if (artifact) {\n tupleArr.push([component.id.toString(), artifact]);\n }\n });\n });\n\n return this.toComponentMap(context, tupleArr);\n }\n}\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;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;;AAEO,MAAMA,eAAe,GAAG,WAAxB;;;AAIA,MAAMC,eAAN,CAAsB;EAC3BC,YAAY,CAACC,IAAD,EAAeC,GAAf,EAAkD;IAC5D,MAAMC,iBAAiB,GAAG,IAAAC,iBAAA,EAAQF,GAAG,CAACG,YAAZ,CAA1B;;IACA,MAAMC,KAAK,GAAGC,iBAAA,CAAOC,IAAP,CAAYL,iBAAZ,EAA+B;MAAEM,GAAG,EAAER;IAAP,CAA/B,CAAd;;IACA,OAAOK,KAAP;EACD;;EAEOI,sBAAsB,CAACC,OAAD,EAAwBC,SAAxB,EAA8CV,GAA9C,EAAuE;IACnG,MAAMW,eAAe,GAAG,KAAKC,kBAAL,CAAwBZ,GAAxB,CAAxB;;IACA,IAAIW,eAAe,KAAK,WAAxB,EAAqC;MAAA;;MACnC,MAAME,WAAW,4BAAGJ,OAAO,CAACK,cAAR,CAAuBC,aAAvB,CAAqCC,UAArC,CAAgDN,SAAS,CAACO,EAA1D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b,EAAD,EAA0BK,QAA1B,CAAd;UACD,CAFM,CAAP;QAGD;MACF;;MAED,OAAOlC,OAAO,CAAC4B,UAAR,CAAmBa,OAAnB,CAA4BxC,SAAD,IAAe;QAC/C,MAAMiC,QAAQ,GAAG,KAAKtB,mBAAL,CAAyBZ,OAAzB,EAAkCC,SAAlC,EAA6CV,GAA7C,EAAkDsB,IAAlD,CAAjB;;QACA,IAAIqB,QAAJ,EAAc;UACZM,QAAQ,CAACG,IAAT,CAAc,CAAC1C,SAAS,CAACO,EAAV,CAAaqB,QAAb,EAAD,EAA0BK,QAA1B,CAAd;QACD;MACF,CALM,CAAP;IAMD,CArBD;IAuBA,OAAO,KAAKV,cAAL,CAAoBxB,OAApB,EAA6BwC,QAA7B,CAAP;EACD;;AArF0B"}
@@ -1,24 +1,25 @@
1
1
  import { Component } from '@teambit/component';
2
2
  import type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
3
- import type { Artifact } from './artifact';
4
- export declare type ResolverMap = {
5
- [key: string]: Artifact[];
3
+ import { BitId } from '@teambit/legacy/dist/bit-id';
4
+ import { Scope } from '@teambit/legacy/dist/scope';
5
+ import { ArtifactVinyl } from '@teambit/legacy/dist/consumer/component/sources/artifact';
6
+ import { Artifact } from './artifact';
7
+ export declare type ResolverMap<T extends Artifact> = {
8
+ [key: string]: T[];
6
9
  };
7
- export declare class ArtifactList {
8
- readonly artifacts: Artifact[];
9
- constructor(artifacts: Artifact[]);
10
- /**
11
- * return an array of artifact objects.
12
- */
13
- toArray(): Artifact[];
10
+ export declare class ArtifactList<T extends Artifact> extends Array<T> {
11
+ byAspectNameAndName(aspectName?: string, name?: string): ArtifactList<T>;
12
+ byAspectNameAndTaskName(aspectName?: string, name?: string): ArtifactList<T>;
13
+ isEmpty(): boolean;
14
14
  /**
15
15
  * group artifacts by the storage resolver.
16
16
  */
17
- groupByResolver(): ResolverMap;
17
+ groupByResolver(): ResolverMap<T>;
18
18
  toObject(): ArtifactObject[];
19
19
  groupByTaskId(): {
20
- [key: string]: Artifact;
20
+ [key: string]: T;
21
21
  };
22
+ getVinylsAndImportIfMissing(id: BitId, scope: Scope): Promise<ArtifactVinyl[]>;
22
23
  /**
23
24
  * store all artifacts using the configured storage resolvers.
24
25
  */
@@ -38,4 +39,6 @@ export declare class ArtifactList {
38
39
  * @param component
39
40
  */
40
41
  private storeArtifactFilesByResolver;
42
+ static fromArtifactObjects(artifactObjects: ArtifactObject[]): ArtifactList<Artifact>;
43
+ static fromArray<T extends Artifact>(artifacts: T[]): ArtifactList<T>;
41
44
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.array.flat.js");
4
+
3
5
  require("core-js/modules/es.array.iterator.js");
4
6
 
7
+ require("core-js/modules/es.array.unscopables.flat.js");
8
+
5
9
  require("core-js/modules/es.promise.js");
6
10
 
7
11
  Object.defineProperty(exports, "__esModule", {
@@ -9,6 +13,16 @@ Object.defineProperty(exports, "__esModule", {
9
13
  });
10
14
  exports.ArtifactList = void 0;
11
15
 
16
+ function _artifact() {
17
+ const data = require("./artifact");
18
+
19
+ _artifact = function () {
20
+ return data;
21
+ };
22
+
23
+ return data;
24
+ }
25
+
12
26
  function _storage() {
13
27
  const data = require("../storage");
14
28
 
@@ -19,17 +33,43 @@ function _storage() {
19
33
  return data;
20
34
  }
21
35
 
22
- class ArtifactList {
23
- constructor(artifacts) {
24
- this.artifacts = artifacts;
36
+ class ArtifactList extends Array {
37
+ byAspectNameAndName(aspectName, name) {
38
+ const filtered = this.filter(artifact => {
39
+ let cond = true;
40
+
41
+ if (aspectName) {
42
+ cond = cond && artifact.task.aspectId === aspectName;
43
+ }
44
+
45
+ if (name) {
46
+ cond = cond && artifact.name === name;
47
+ }
48
+
49
+ return cond;
50
+ });
51
+ return ArtifactList.fromArray(filtered);
25
52
  }
26
- /**
27
- * return an array of artifact objects.
28
- */
29
53
 
54
+ byAspectNameAndTaskName(aspectName, name) {
55
+ const filtered = this.filter(artifact => {
56
+ let cond = true;
57
+
58
+ if (aspectName) {
59
+ cond = cond && artifact.task.aspectId === aspectName;
60
+ }
61
+
62
+ if (name) {
63
+ cond = cond && artifact.task.name === name;
64
+ }
30
65
 
31
- toArray() {
32
- return this.artifacts;
66
+ return cond;
67
+ });
68
+ return ArtifactList.fromArray(filtered);
69
+ }
70
+
71
+ isEmpty() {
72
+ return this.every(artifact => artifact.files.isEmpty());
33
73
  }
34
74
  /**
35
75
  * group artifacts by the storage resolver.
@@ -38,7 +78,7 @@ class ArtifactList {
38
78
 
39
79
  groupByResolver() {
40
80
  const resolverMap = {};
41
- this.artifacts.forEach(artifact => {
81
+ this.forEach(artifact => {
42
82
  const storageResolver = artifact.storageResolver;
43
83
  const resolverArray = resolverMap[storageResolver.name];
44
84
 
@@ -55,16 +95,22 @@ class ArtifactList {
55
95
  }
56
96
 
57
97
  toObject() {
58
- return this.artifacts.map(artifact => artifact.toObject());
98
+ return this.map(artifact => artifact.toObject());
59
99
  }
60
100
 
61
101
  groupByTaskId() {
62
- return this.artifacts.reduce((acc, artifact) => {
102
+ return this.reduce((acc, artifact) => {
63
103
  const taskId = artifact.task.aspectId;
64
104
  acc[taskId] = artifact;
65
105
  return acc;
66
106
  }, {});
67
107
  }
108
+
109
+ async getVinylsAndImportIfMissing(id, scope) {
110
+ if (this.isEmpty()) return [];
111
+ const vinyls = await Promise.all(this.map(artifact => artifact.files.getVinylsAndImportIfMissing(id, scope)));
112
+ return vinyls.flat();
113
+ }
68
114
  /**
69
115
  * store all artifacts using the configured storage resolvers.
70
116
  */
@@ -76,8 +122,8 @@ class ArtifactList {
76
122
  const artifacts = byResolvers[key];
77
123
  if (!artifacts.length) return;
78
124
  const storageResolver = artifacts[0].storageResolver;
79
- const artifactList = new ArtifactList(artifacts);
80
- const artifactPromises = artifactList.artifacts.map(async artifact => {
125
+ const artifactList = ArtifactList.fromArray(artifacts);
126
+ const artifactPromises = artifactList.map(async artifact => {
81
127
  return this.storeArtifact(storageResolver, artifact, component);
82
128
  });
83
129
  await Promise.all(artifactPromises);
@@ -137,6 +183,15 @@ class ArtifactList {
137
183
  return Promise.all(promises);
138
184
  }
139
185
 
186
+ static fromArtifactObjects(artifactObjects) {
187
+ const artifacts = artifactObjects.map(object => _artifact().Artifact.fromArtifactObject(object));
188
+ return ArtifactList.fromArray(artifacts);
189
+ }
190
+
191
+ static fromArray(artifacts) {
192
+ return new ArtifactList(...artifacts);
193
+ }
194
+
140
195
  }
141
196
 
142
197
  exports.ArtifactList = ArtifactList;
@@ -1 +1 @@
1
- {"version":3,"names":["ArtifactList","constructor","artifacts","toArray","groupByResolver","resolverMap","forEach","artifact","storageResolver","resolverArray","name","length","push","toObject","map","groupByTaskId","reduce","acc","taskId","task","aspectId","store","component","byResolvers","promises","Object","keys","key","artifactList","artifactPromises","storeArtifact","Promise","all","defaultResolver","DefaultResolver","storeWholeArtifactByResolver","storeArtifactFilesByResolver","results","files","vinyls","file","url","relative","storeFile"],"sources":["artifact-list.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport type { Artifact } from './artifact';\nimport {\n ArtifactStorageResolver,\n FileStorageResolver,\n WholeArtifactStorageResolver,\n DefaultResolver,\n} from '../storage';\n\nexport type ResolverMap = { [key: string]: Artifact[] };\n\nexport class ArtifactList {\n constructor(readonly artifacts: Artifact[]) {}\n\n /**\n * return an array of artifact objects.\n */\n toArray() {\n return this.artifacts;\n }\n\n /**\n * group artifacts by the storage resolver.\n */\n groupByResolver(): ResolverMap {\n const resolverMap: ResolverMap = {};\n this.artifacts.forEach((artifact) => {\n const storageResolver = artifact.storageResolver;\n const resolverArray = resolverMap[storageResolver.name];\n if (!resolverArray) {\n resolverMap[storageResolver.name] = [artifact];\n return;\n }\n if (resolverArray.length) {\n resolverMap[storageResolver.name].push(artifact);\n }\n });\n\n return resolverMap;\n }\n\n toObject(): ArtifactObject[] {\n return this.artifacts.map((artifact) => artifact.toObject());\n }\n\n groupByTaskId() {\n return this.artifacts.reduce((acc: { [key: string]: Artifact }, artifact) => {\n const taskId = artifact.task.aspectId;\n acc[taskId] = artifact;\n return acc;\n }, {});\n }\n\n /**\n * store all artifacts using the configured storage resolvers.\n */\n async store(component: Component) {\n const byResolvers = this.groupByResolver();\n const promises = Object.keys(byResolvers).map(async (key) => {\n const artifacts = byResolvers[key];\n if (!artifacts.length) return;\n const storageResolver = artifacts[0].storageResolver;\n const artifactList = new ArtifactList(artifacts);\n const artifactPromises = artifactList.artifacts.map(async (artifact) => {\n return this.storeArtifact(storageResolver, artifact, component);\n });\n await Promise.all(artifactPromises);\n });\n\n return Promise.all(promises);\n }\n\n private async storeArtifact(storageResolver: ArtifactStorageResolver, artifact: Artifact, component: Component) {\n // For now we are always storing also using the default resolver\n if (storageResolver.name !== 'default') {\n const defaultResolver = new DefaultResolver();\n await defaultResolver.store(component, artifact);\n }\n // @ts-ignore\n if (storageResolver.store && typeof storageResolver.store === 'function') {\n return this.storeWholeArtifactByResolver(storageResolver as WholeArtifactStorageResolver, artifact, component);\n }\n return this.storeArtifactFilesByResolver(storageResolver as FileStorageResolver, artifact, component);\n }\n\n /**\n * Send the entire artifact to the resolver then get back the result for all files from the resolver\n * @param storageResolver\n * @param artifact\n * @param component\n */\n private async storeWholeArtifactByResolver(\n storageResolver: WholeArtifactStorageResolver,\n artifact: Artifact,\n component: Component\n ) {\n const results = await storageResolver.store(component, artifact);\n if (!results) return;\n artifact.files.vinyls.map(async (file) => {\n const url = results[file.relative];\n if (url) {\n file.url = url;\n }\n });\n }\n\n /**\n * Go over the artifact files and send them to the resolver one by one\n * @param storageResolver\n * @param artifact\n * @param component\n */\n private storeArtifactFilesByResolver(storageResolver: FileStorageResolver, artifact: Artifact, component: Component) {\n const promises = artifact.files.vinyls.map(async (file) => {\n const url = await storageResolver.storeFile(component, artifact, file);\n if (url) {\n file.url = url;\n }\n });\n return Promise.all(promises);\n }\n}\n"],"mappings":";;;;;;;;;;;AA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SAHwC,EAIxC;IACA,MAAMe,OAAO,GAAG,MAAM7B,eAAe,CAACa,KAAhB,CAAsBC,SAAtB,EAAiCf,QAAjC,CAAtB;IACA,IAAI,CAAC8B,OAAL,EAAc;IACd9B,QAAQ,CAAC+B,KAAT,CAAeC,MAAf,CAAsBzB,GAAtB,CAA0B,MAAO0B,IAAP,IAAgB;MACxC,MAAMC,GAAG,GAAGJ,OAAO,CAACG,IAAI,CAACE,QAAN,CAAnB;;MACA,IAAID,GAAJ,EAAS;QACPD,IAAI,CAACC,GAAL,GAAWA,GAAX;MACD;IACF,CALD;EAMD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACUL,4BAA4B,CAAC5B,eAAD,EAAuCD,QAAvC,EAA2De,SAA3D,EAAiF;IACnH,MAAME,QAAQ,GAAGjB,QAAQ,CAAC+B,KAAT,CAAeC,MAAf,CAAsBzB,GAAtB,CAA0B,MAAO0B,IAAP,IAAgB;MACzD,MAAMC,GAAG,GAAG,MAAMjC,eAAe,CAACmC,SAAhB,CAA0BrB,SAA1B,EAAqCf,QAArC,EAA+CiC,IAA/C,CAAlB;;MACA,IAAIC,GAAJ,EAAS;QACPD,IAAI,CAACC,GAAL,GAAWA,GAAX;MACD;IACF,CALgB,CAAjB;IAMA,OAAOV,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAAP;EACD;;AA7GuB"}
1
+ {"version":3,"names":["ArtifactList","Array","byAspectNameAndName","aspectName","name","filtered","filter","artifact","cond","task","aspectId","fromArray","byAspectNameAndTaskName","isEmpty","every","files","groupByResolver","resolverMap","forEach","storageResolver","resolverArray","length","push","toObject","map","groupByTaskId","reduce","acc","taskId","getVinylsAndImportIfMissing","id","scope","vinyls","Promise","all","flat","store","component","byResolvers","promises","Object","keys","key","artifacts","artifactList","artifactPromises","storeArtifact","defaultResolver","DefaultResolver","storeWholeArtifactByResolver","storeArtifactFilesByResolver","results","file","url","relative","storeFile","fromArtifactObjects","artifactObjects","object","Artifact","fromArtifactObject"],"sources":["artifact-list.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { BitId } from '@teambit/legacy/dist/bit-id';\nimport { Scope } from '@teambit/legacy/dist/scope';\nimport { ArtifactVinyl } from '@teambit/legacy/dist/consumer/component/sources/artifact';\nimport { FsArtifact } from './fs-artifact';\nimport { Artifact } from './artifact';\nimport {\n ArtifactStorageResolver,\n FileStorageResolver,\n WholeArtifactStorageResolver,\n DefaultResolver,\n} from '../storage';\n\nexport type ResolverMap<T extends Artifact> = { [key: string]: T[] };\n\nexport class ArtifactList<T extends Artifact> extends Array<T> {\n byAspectNameAndName(aspectName?: string, name?: string): ArtifactList<T> {\n const filtered = this.filter((artifact) => {\n let cond = true;\n if (aspectName) {\n cond = cond && artifact.task.aspectId === aspectName;\n }\n if (name) {\n cond = cond && artifact.name === name;\n }\n return cond;\n });\n return ArtifactList.fromArray(filtered);\n }\n\n byAspectNameAndTaskName(aspectName?: string, name?: string): ArtifactList<T> {\n const filtered = this.filter((artifact) => {\n let cond = true;\n if (aspectName) {\n cond = cond && artifact.task.aspectId === aspectName;\n }\n if (name) {\n cond = cond && artifact.task.name === name;\n }\n return cond;\n });\n return ArtifactList.fromArray(filtered);\n }\n\n isEmpty(): boolean {\n return this.every((artifact) => artifact.files.isEmpty());\n }\n\n /**\n * group artifacts by the storage resolver.\n */\n groupByResolver(): ResolverMap<T> {\n const resolverMap: ResolverMap<T> = {};\n this.forEach((artifact) => {\n const storageResolver = artifact.storageResolver;\n const resolverArray = resolverMap[storageResolver.name];\n if (!resolverArray) {\n resolverMap[storageResolver.name] = [artifact];\n return;\n }\n if (resolverArray.length) {\n resolverMap[storageResolver.name].push(artifact);\n }\n });\n\n return resolverMap;\n }\n\n toObject(): ArtifactObject[] {\n return this.map((artifact) => artifact.toObject());\n }\n\n groupByTaskId() {\n return this.reduce((acc: { [key: string]: T }, artifact) => {\n const taskId = artifact.task.aspectId;\n acc[taskId] = artifact;\n return acc;\n }, {});\n }\n\n async getVinylsAndImportIfMissing(id: BitId, scope: Scope): Promise<ArtifactVinyl[]> {\n if (this.isEmpty()) return [];\n const vinyls = await Promise.all(this.map((artifact) => artifact.files.getVinylsAndImportIfMissing(id, scope)));\n return vinyls.flat();\n }\n\n /**\n * store all artifacts using the configured storage resolvers.\n */\n async store(component: Component) {\n const byResolvers = this.groupByResolver();\n const promises = Object.keys(byResolvers).map(async (key) => {\n const artifacts = byResolvers[key];\n if (!artifacts.length) return;\n const storageResolver = artifacts[0].storageResolver;\n const artifactList = ArtifactList.fromArray(artifacts);\n const artifactPromises = artifactList.map(async (artifact) => {\n return this.storeArtifact(storageResolver, artifact, component);\n });\n await Promise.all(artifactPromises);\n });\n\n return Promise.all(promises);\n }\n\n private async storeArtifact(storageResolver: ArtifactStorageResolver, artifact: Artifact, component: Component) {\n // For now we are always storing also using the default resolver\n if (storageResolver.name !== 'default') {\n const defaultResolver = new DefaultResolver();\n await defaultResolver.store(component, artifact as FsArtifact);\n }\n // @ts-ignore\n if (storageResolver.store && typeof storageResolver.store === 'function') {\n return this.storeWholeArtifactByResolver(storageResolver as WholeArtifactStorageResolver, artifact, component);\n }\n return this.storeArtifactFilesByResolver(storageResolver as FileStorageResolver, artifact, component);\n }\n\n /**\n * Send the entire artifact to the resolver then get back the result for all files from the resolver\n * @param storageResolver\n * @param artifact\n * @param component\n */\n private async storeWholeArtifactByResolver(\n storageResolver: WholeArtifactStorageResolver,\n artifact: Artifact,\n component: Component\n ) {\n const results = await storageResolver.store(component, artifact as FsArtifact);\n if (!results) return;\n artifact.files.vinyls.map(async (file) => {\n const url = results[file.relative];\n if (url) {\n file.url = url;\n }\n });\n }\n\n /**\n * Go over the artifact files and send them to the resolver one by one\n * @param storageResolver\n * @param artifact\n * @param component\n */\n private storeArtifactFilesByResolver(storageResolver: FileStorageResolver, artifact: Artifact, component: Component) {\n const promises = artifact.files.vinyls.map(async (file) => {\n const url = await storageResolver.storeFile(component, artifact as FsArtifact, file);\n if (url) {\n file.url = url;\n }\n });\n return Promise.all(promises);\n }\n\n static fromArtifactObjects(artifactObjects: ArtifactObject[]): ArtifactList<Artifact> {\n const artifacts = artifactObjects.map((object) => Artifact.fromArtifactObject(object));\n return ArtifactList.fromArray(artifacts);\n }\n\n static fromArray<T extends Artifact>(artifacts: T[]) {\n return new ArtifactList(...artifacts);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AASO,MAAMA,YAAN,SAA+CC,KAA/C,CAAwD;EAC7DC,mBAAmB,CAACC,UAAD,EAAsBC,IAAtB,EAAsD;IACvE,MAAMC,QAAQ,GAAG,KAAKC,MAAL,CAAaC,QAAD,IAAc;MACzC,IAAIC,IAAI,GAAG,IAAX;;MACA,IAAIL,UAAJ,EAAgB;QACdK,IAAI,GAAGA,IAAI,IAAID,QAAQ,CAACE,IAAT,CAAcC,QAAd,KAA2BP,UAA1C;MACD;;MACD,IAAIC,IAAJ,EAAU;QACRI,IAAI,GAAGA,IAAI,IAAID,QAAQ,CAACH,IAAT,KAAkBA,IAAjC;MACD;;MACD,OAAOI,IAAP;IACD,CATgB,CAAjB;IAUA,OAAOR,YAAY,CAACW,SAAb,CAAuBN,QAAvB,CAAP;EACD;;EAEDO,uBAAuB,CAACT,UAAD,EAAsBC,IAAtB,EAAsD;IAC3E,MAAMC,QAAQ,GAAG,KAAKC,MAAL,CAAaC,QAAD,IAAc;MACzC,IAAIC,IAAI,GAAG,IAAX;;MACA,IAAIL,UAAJ,EAAgB;QACdK,IAAI,GAAGA,IAAI,IAAID,QAAQ,CAACE,IAAT,CAAcC,QAAd,KAA2BP,UAA1C;MACD;;MACD,IAAIC,IAAJ,EAAU;QACRI,IAAI,GAAGA,IAAI,IAAID,QAAQ,CAACE,IAAT,CAAcL,IAAd,KAAuBA,IAAtC;MACD;;MACD,OAAOI,IAAP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,IAAYC,oBAAA,CAASC,kBAAT,CAA4BF,MAA5B,CAAhC,CAAlB;IACA,OAAO1D,YAAY,CAACW,SAAb,CAAuBgC,SAAvB,CAAP;EACD;;EAEe,OAAThC,SAAS,CAAqBgC,SAArB,EAAqC;IACnD,OAAO,IAAI3C,YAAJ,CAAiB,GAAG2C,SAApB,CAAP;EACD;;AAnJ4D"}
@@ -1,27 +1,16 @@
1
1
  import type { ArtifactFiles, ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
2
- import type { BuildTask } from '../build-task';
3
- import type { ArtifactStorageResolver } from '../storage';
2
+ import type { TaskDescriptor } from '../build-task';
4
3
  import type { ArtifactDefinition } from './artifact-definition';
5
4
  export declare class Artifact {
6
5
  /**
7
6
  * definition of the artifact.
8
7
  */
9
8
  readonly def: ArtifactDefinition;
10
- /**
11
- * storage resolver. can be used to replace where artifacts are stored.
12
- */
13
- readonly storageResolver: ArtifactStorageResolver;
14
9
  readonly files: ArtifactFiles;
15
- /**
16
- * join this with `this.paths` to get the absolute paths
17
- */
18
- readonly rootDir: string;
19
10
  /**
20
11
  * the declaring task.
21
- * todo: change this to taskDescriptor that has only the metadata of the task, so it could be
22
- * saved into the model.
23
12
  */
24
- readonly task: BuildTask;
13
+ readonly task: TaskDescriptor;
25
14
  /**
26
15
  * timestamp of the artifact creation.
27
16
  */
@@ -30,26 +19,17 @@ export declare class Artifact {
30
19
  /**
31
20
  * definition of the artifact.
32
21
  */
33
- def: ArtifactDefinition,
34
- /**
35
- * storage resolver. can be used to replace where artifacts are stored.
36
- */
37
- storageResolver: ArtifactStorageResolver, files: ArtifactFiles,
38
- /**
39
- * join this with `this.paths` to get the absolute paths
40
- */
41
- rootDir: string,
22
+ def: ArtifactDefinition, files: ArtifactFiles,
42
23
  /**
43
24
  * the declaring task.
44
- * todo: change this to taskDescriptor that has only the metadata of the task, so it could be
45
- * saved into the model.
46
25
  */
47
- task: BuildTask,
26
+ task: TaskDescriptor,
48
27
  /**
49
28
  * timestamp of the artifact creation.
50
29
  */
51
30
  timestamp?: number);
52
- get storage(): ArtifactStorageResolver;
31
+ get storage(): string;
32
+ get storageResolver(): import("..").ArtifactStorageResolver;
53
33
  /**
54
34
  * name of the artifact.
55
35
  */
@@ -62,9 +42,11 @@ export declare class Artifact {
62
42
  * aspect id (string) that generated the artifact
63
43
  */
64
44
  get generatedBy(): string;
45
+ isEmpty(): boolean;
65
46
  /**
66
47
  * archive all artifact files into a tar.
67
48
  */
68
49
  tar(): void;
69
50
  toObject(): ArtifactObject;
51
+ static fromArtifactObject(object: ArtifactObject): Artifact;
70
52
  }
@@ -7,24 +7,24 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.Artifact = void 0;
9
9
 
10
+ function _defaultResolver() {
11
+ const data = require("../storage/default-resolver");
12
+
13
+ _defaultResolver = function () {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
10
20
  class Artifact {
11
21
  constructor(
12
22
  /**
13
23
  * definition of the artifact.
14
24
  */
15
- def,
16
- /**
17
- * storage resolver. can be used to replace where artifacts are stored.
18
- */
19
- storageResolver, files,
20
- /**
21
- * join this with `this.paths` to get the absolute paths
22
- */
23
- rootDir,
25
+ def, files,
24
26
  /**
25
27
  * the declaring task.
26
- * todo: change this to taskDescriptor that has only the metadata of the task, so it could be
27
- * saved into the model.
28
28
  */
29
29
  task,
30
30
  /**
@@ -32,15 +32,17 @@ class Artifact {
32
32
  */
33
33
  timestamp = Date.now()) {
34
34
  this.def = def;
35
- this.storageResolver = storageResolver;
36
35
  this.files = files;
37
- this.rootDir = rootDir;
38
36
  this.task = task;
39
37
  this.timestamp = timestamp;
40
38
  }
41
39
 
42
40
  get storage() {
43
- return this.storageResolver;
41
+ return this.storageResolver.name;
42
+ }
43
+
44
+ get storageResolver() {
45
+ return this.def.storageResolver || new (_defaultResolver().DefaultResolver)();
44
46
  }
45
47
  /**
46
48
  * name of the artifact.
@@ -66,6 +68,10 @@ class Artifact {
66
68
  get generatedBy() {
67
69
  return this.def.generatedBy || this.task.aspectId;
68
70
  }
71
+
72
+ isEmpty() {
73
+ return this.files.isEmpty();
74
+ }
69
75
  /**
70
76
  * archive all artifact files into a tar.
71
77
  */
@@ -87,6 +93,19 @@ class Artifact {
87
93
  };
88
94
  }
89
95
 
96
+ static fromArtifactObject(object) {
97
+ const artifactDef = {
98
+ name: object.name,
99
+ generatedBy: object.generatedBy,
100
+ description: object.description
101
+ };
102
+ const task = {
103
+ aspectId: object.task.id,
104
+ name: object.task.name
105
+ };
106
+ return new Artifact(artifactDef, object.files, task);
107
+ }
108
+
90
109
  }
91
110
 
92
111
  exports.Artifact = Artifact;
@@ -1 +1 @@
1
- {"version":3,"names":["Artifact","constructor","def","storageResolver","files","rootDir","task","timestamp","Date","now","storage","name","description","generatedBy","aspectId","tar","toObject","id"],"sources":["artifact.ts"],"sourcesContent":["import type { ArtifactFiles, ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport type { BuildTask } from '../build-task';\nimport type { ArtifactStorageResolver } from '../storage';\nimport type { ArtifactDefinition } from './artifact-definition';\n\nexport class Artifact {\n constructor(\n /**\n * definition of the artifact.\n */\n readonly def: ArtifactDefinition,\n\n /**\n * storage resolver. can be used to replace where artifacts are stored.\n */\n readonly storageResolver: ArtifactStorageResolver,\n\n readonly files: ArtifactFiles,\n\n /**\n * join this with `this.paths` to get the absolute paths\n */\n readonly rootDir: string,\n\n /**\n * the declaring task.\n * todo: change this to taskDescriptor that has only the metadata of the task, so it could be\n * saved into the model.\n */\n readonly task: BuildTask,\n\n /**\n * timestamp of the artifact creation.\n */\n readonly timestamp: number = Date.now()\n ) {}\n\n get storage() {\n return this.storageResolver;\n }\n\n /**\n * name of the artifact.\n */\n get name(): string {\n return this.def.name;\n }\n\n /**\n * description of the artifact.\n */\n get description() {\n return this.def.description;\n }\n\n /**\n * aspect id (string) that generated the artifact\n */\n get generatedBy(): string {\n return this.def.generatedBy || this.task.aspectId;\n }\n\n /**\n * archive all artifact files into a tar.\n */\n tar() {}\n\n toObject(): ArtifactObject {\n return {\n name: this.name,\n description: this.description,\n generatedBy: this.generatedBy,\n storage: this.storageResolver.name,\n task: {\n id: this.task.aspectId,\n name: this.task.name,\n },\n files: this.files,\n };\n }\n}\n"],"mappings":";;;;;;;;;AAKO,MAAMA,QAAN,CAAe;EACpBC,WAAW;EACT;AACJ;AACA;EACaC,GAJA;EAMT;AACJ;AACA;EACaC,eATA,EAWAC,KAXA;EAaT;AACJ;AACA;EACaC,OAhBA;EAkBT;AACJ;AACA;AACA;AACA;EACaC,IAvBA;EAyBT;AACJ;AACA;EACaC,SAAiB,GAAGC,IAAI,CAACC,GAAL,EA5BpB,EA6BT;IAAA,KAzBSP,GAyBT,GAzBSA,GAyBT;IAAA,KApBSC,eAoBT,GApBSA,eAoBT;IAAA,KAlBSC,KAkBT,GAlBSA,KAkBT;IAAA,KAbSC,OAaT,GAbSA,OAaT;IAAA,KANSC,IAMT,GANSA,IAMT;IAAA,KADSC,SACT,GADSA,SACT;EAAE;;EAEO,IAAPG,OAAO,GAAG;IACZ,OAAO,KAAKP,eAAZ;EACD;EAED;AACF;AACA;;;EACU,IAAJQ,IAAI,GAAW;IACjB,OAAO,KAAKT,GAAL,CAASS,IAAhB;EACD;EAED;AACF;AACA;;;EACiB,IAAXC,WAAW,GAAG;IAChB,OAAO,KAAKV,GAAL,CAASU,WAAhB;EACD;EAED;AACF;AACA;;;EACiB,IAAXC,WAAW,GAAW;IACxB,OAAO,KAAKX,GAAL,CAASW,WAAT,IAAwB,KAAKP,IAAL,CAAUQ,QAAzC;EACD;EAED;AACF;AACA;;;EACEC,GAAG,GAAG,CAAE;;EAERC,QAAQ,GAAmB;IACzB,OAAO;MACLL,IAAI,EAAE,KAAKA,IADN;MAELC,WAAW,EAAE,KAAKA,WAFb;MAGLC,WAAW,EAAE,KAAKA,WAHb;MAILH,OAAO,EAAE,KAAKP,eAAL,CAAqBQ,IAJzB;MAKLL,IAAI,EAAE;QACJW,EAAE,EAAE,KAAKX,IAAL,CAAUQ,QADV;QAEJH,IAAI,EAAE,KAAKL,IAAL,CAAUK;MAFZ,CALD;MASLP,KAAK,EAAE,KAAKA;IATP,CAAP;EAWD;;AA1EmB"}
1
+ {"version":3,"names":["Artifact","constructor","def","files","task","timestamp","Date","now","storage","storageResolver","name","DefaultResolver","description","generatedBy","aspectId","isEmpty","tar","toObject","id","fromArtifactObject","object","artifactDef"],"sources":["artifact.ts"],"sourcesContent":["import type { ArtifactFiles, ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport type { TaskDescriptor } from '../build-task';\nimport type { ArtifactDefinition } from './artifact-definition';\nimport { DefaultResolver } from '../storage/default-resolver';\n\nexport class Artifact {\n constructor(\n /**\n * definition of the artifact.\n */\n readonly def: ArtifactDefinition,\n\n readonly files: ArtifactFiles,\n /**\n * the declaring task.\n */\n readonly task: TaskDescriptor,\n /**\n * timestamp of the artifact creation.\n */\n readonly timestamp: number = Date.now()\n ) {}\n\n get storage() {\n return this.storageResolver.name;\n }\n\n get storageResolver() {\n return this.def.storageResolver || new DefaultResolver();\n }\n\n /**\n * name of the artifact.\n */\n get name(): string {\n return this.def.name;\n }\n\n /**\n * description of the artifact.\n */\n get description() {\n return this.def.description;\n }\n\n /**\n * aspect id (string) that generated the artifact\n */\n get generatedBy(): string {\n return this.def.generatedBy || this.task.aspectId;\n }\n\n isEmpty(): boolean {\n return this.files.isEmpty();\n }\n\n /**\n * archive all artifact files into a tar.\n */\n tar() {}\n\n toObject(): ArtifactObject {\n return {\n name: this.name,\n description: this.description,\n generatedBy: this.generatedBy,\n storage: this.storageResolver.name,\n task: {\n id: this.task.aspectId,\n name: this.task.name,\n },\n files: this.files,\n };\n }\n\n static fromArtifactObject(object: ArtifactObject): Artifact {\n const artifactDef: ArtifactDefinition = {\n name: object.name,\n generatedBy: object.generatedBy,\n description: object.description,\n };\n\n const task: TaskDescriptor = {\n aspectId: object.task.id,\n name: object.task.name,\n };\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KAAKN,IAAL,CAAUM;MAFZ,CALD;MASLP,KAAK,EAAE,KAAKA;IATP,CAAP;EAWD;;EAEwB,OAAlBgB,kBAAkB,CAACC,MAAD,EAAmC;IAC1D,MAAMC,WAA+B,GAAG;MACtCX,IAAI,EAAEU,MAAM,CAACV,IADyB;MAEtCG,WAAW,EAAEO,MAAM,CAACP,WAFkB;MAGtCD,WAAW,EAAEQ,MAAM,CAACR;IAHkB,CAAxC;IAMA,MAAMR,IAAoB,GAAG;MAC3BU,QAAQ,EAAEM,MAAM,CAAChB,IAAP,CAAYc,EADK;MAE3BR,IAAI,EAAEU,MAAM,CAAChB,IAAP,CAAYM;IAFS,CAA7B;IAKA,OAAO,IAAIV,QAAJ,CAAaqB,WAAb,EAA0BD,MAAM,CAACjB,KAAjC,EAAwCC,IAAxC,CAAP;EACD;;AAnFmB"}
@@ -0,0 +1,18 @@
1
+ import type { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
2
+ import type { ArtifactDefinition } from './artifact-definition';
3
+ import { Artifact } from './artifact';
4
+ import { TaskDescriptor } from '../build-task';
5
+ export declare class FsArtifact extends Artifact {
6
+ /**
7
+ * definition of the artifact.
8
+ */
9
+ readonly def: ArtifactDefinition;
10
+ readonly files: ArtifactFiles;
11
+ readonly task: TaskDescriptor;
12
+ readonly rootDir: string;
13
+ constructor(
14
+ /**
15
+ * definition of the artifact.
16
+ */
17
+ def: ArtifactDefinition, files: ArtifactFiles, task: TaskDescriptor, rootDir: string);
18
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FsArtifact = void 0;
7
+
8
+ function _artifact() {
9
+ const data = require("./artifact");
10
+
11
+ _artifact = function () {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ class FsArtifact extends _artifact().Artifact {
19
+ constructor(
20
+ /**
21
+ * definition of the artifact.
22
+ */
23
+ def, files, task, rootDir) {
24
+ super(def, files, task);
25
+ this.def = def;
26
+ this.files = files;
27
+ this.task = task;
28
+ this.rootDir = rootDir;
29
+ }
30
+
31
+ }
32
+
33
+ exports.FsArtifact = FsArtifact;
34
+
35
+ //# sourceMappingURL=fs-artifact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FsArtifact","Artifact","constructor","def","files","task","rootDir"],"sources":["fs-artifact.ts"],"sourcesContent":["import type { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport type { ArtifactDefinition } from './artifact-definition';\nimport { Artifact } from './artifact';\nimport { TaskDescriptor } from '../build-task';\n\nexport class FsArtifact extends Artifact {\n constructor(\n /**\n * definition of the artifact.\n */\n readonly def: ArtifactDefinition,\n\n readonly files: ArtifactFiles,\n\n readonly task: TaskDescriptor,\n\n readonly rootDir: string\n ) {\n super(def, files, task);\n }\n}\n"],"mappings":";;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,UAAN,SAAyBC,oBAAzB,CAAkC;EACvCC,WAAW;EACT;AACJ;AACA;EACaC,GAJA,EAMAC,KANA,EAQAC,IARA,EAUAC,OAVA,EAWT;IACA,MAAMH,GAAN,EAAWC,KAAX,EAAkBC,IAAlB;IADA,KAPSF,GAOT,GAPSA,GAOT;IAAA,KALSC,KAKT,GALSA,KAKT;IAAA,KAHSC,IAGT,GAHSA,IAGT;IAAA,KADSC,OACT,GADSA,OACT;EAED;;AAdsC"}
@@ -3,3 +3,4 @@ export { ExtensionArtifact } from './extension-artifact';
3
3
  export { Artifact } from './artifact';
4
4
  export { ArtifactList } from './artifact-list';
5
5
  export { ArtifactFactory, ArtifactMap } from './artifact-factory';
6
+ export { FsArtifact } from './fs-artifact';
@@ -45,6 +45,12 @@ Object.defineProperty(exports, "ExtensionArtifact", {
45
45
  return _extensionArtifact().ExtensionArtifact;
46
46
  }
47
47
  });
48
+ Object.defineProperty(exports, "FsArtifact", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _fsArtifact().FsArtifact;
52
+ }
53
+ });
48
54
 
49
55
  function _artifactDefinition() {
50
56
  const data = require("./artifact-definition");
@@ -96,4 +102,14 @@ function _artifactFactory() {
96
102
  return data;
97
103
  }
98
104
 
105
+ function _fsArtifact() {
106
+ const data = require("./fs-artifact");
107
+
108
+ _fsArtifact = function () {
109
+ return data;
110
+ };
111
+
112
+ return data;
113
+ }
114
+
99
115
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ArtifactDefinition, ArtifactModelDefinition } from './artifact-definition';\nexport { ExtensionArtifact } from './extension-artifact';\nexport { Artifact } from './artifact';\nexport { ArtifactList } from './artifact-list';\nexport { ArtifactFactory, ArtifactMap } from './artifact-factory';\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ArtifactDefinition, ArtifactModelDefinition } from './artifact-definition';\nexport { ExtensionArtifact } from './extension-artifact';\nexport { Artifact } from './artifact';\nexport { ArtifactList } from './artifact-list';\nexport { ArtifactFactory, ArtifactMap } from './artifact-factory';\nexport { FsArtifact } from './fs-artifact';\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}