@teambit/pkg 1.0.1272 → 1.0.1273

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.
@@ -2,6 +2,7 @@ import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@te
2
2
  import type { Logger } from '@teambit/logger';
3
3
  import type { Packer } from './packer';
4
4
  import { Extensions } from '@teambit/legacy.constants';
5
+ import type { Component } from '@teambit/component';
5
6
  /**
6
7
  * pack components to a .tgz file
7
8
  */
@@ -15,4 +16,8 @@ export declare class PackTask implements BuildTask {
15
16
  readonly dependencies: Extensions[];
16
17
  constructor(aspectId: string, packer: Packer, logger: Logger);
17
18
  execute(context: BuildContext): Promise<BuiltTaskResult>;
19
+ /**
20
+ * packing runs the pack lifecycle scripts and bundles dependencies, which need the packages.
21
+ */
22
+ requiresCapsuleInstallation(components: Component[]): boolean;
18
23
  }
package/dist/pack.task.js CHANGED
@@ -11,6 +11,13 @@ function _legacy() {
11
11
  };
12
12
  return data;
13
13
  }
14
+ function _packageJsonRequiresInstallation() {
15
+ const data = require("./package-json-requires-installation");
16
+ _packageJsonRequiresInstallation = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
14
21
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
23
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -39,6 +46,13 @@ class PackTask {
39
46
  artifacts: [packArtifactsDefs]
40
47
  };
41
48
  }
49
+
50
+ /**
51
+ * packing runs the pack lifecycle scripts and bundles dependencies, which need the packages.
52
+ */
53
+ requiresCapsuleInstallation(components) {
54
+ return (0, _packageJsonRequiresInstallation().packageJsonRequiresInstallation)(components, this.aspectId, _packageJsonRequiresInstallation().PACK_LIFECYCLE_SCRIPTS);
55
+ }
42
56
  }
43
57
  exports.PackTask = PackTask;
44
58
 
@@ -1 +1 @@
1
- {"version":3,"names":["_legacy","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","PackTask","constructor","aspectId","packer","logger","Extensions","typescript","execute","context","capsules","capsuleNetwork","seedersCapsules","info","length","packResults","packMultipleCapsules","override","packArtifactsDefs","getArtifactDefInCapsule","componentsResults","artifacts","exports"],"sources":["pack.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@teambit/builder';\nimport type { Logger } from '@teambit/logger';\nimport type { Packer } from './packer';\nimport { Extensions } from '@teambit/legacy.constants';\n\n/**\n * pack components to a .tgz file\n */\nexport class PackTask implements BuildTask {\n readonly name = 'PackComponents';\n readonly description = 'Packing components into a .tgz file';\n readonly location: TaskLocation = 'end';\n readonly dependencies = [Extensions.typescript];\n constructor(\n readonly aspectId: string,\n private packer: Packer,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const capsules = context.capsuleNetwork.seedersCapsules;\n this.logger.info(`going to run pack on ${capsules.length} capsules`);\n const packResults = await this.packer.packMultipleCapsules(capsules, { override: true }, false, true);\n const packArtifactsDefs = this.packer.getArtifactDefInCapsule();\n\n return {\n componentsResults: packResults,\n artifacts: [packArtifactsDefs],\n };\n }\n}\n"],"mappings":";;;;;;AAGA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAuD,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD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oB,CAACN,QAAQ,EAAE;MAAEO,QAAQ,EAAE;IAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC;IACrG,MAAMC,iBAAiB,GAAG,IAAI,CAACd,MAAM,CAACe,uBAAuB,CAAC,CAAC;IAE/D,OAAO;MACLC,iBAAiB,EAAEL,WAAW;MAC9BM,SAAS,EAAE,CAACH,iBAAiB;IAC/B,CAAC;EACH;AACF;AAACI,OAAA,CAAArB,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_legacy","data","require","_packageJsonRequiresInstallation","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","PackTask","constructor","aspectId","packer","logger","Extensions","typescript","execute","context","capsules","capsuleNetwork","seedersCapsules","info","length","packResults","packMultipleCapsules","override","packArtifactsDefs","getArtifactDefInCapsule","componentsResults","artifacts","requiresCapsuleInstallation","components","packageJsonRequiresInstallation","PACK_LIFECYCLE_SCRIPTS","exports"],"sources":["pack.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@teambit/builder';\nimport type { Logger } from '@teambit/logger';\nimport type { Packer } from './packer';\nimport { Extensions } from '@teambit/legacy.constants';\nimport type { Component } from '@teambit/component';\nimport { PACK_LIFECYCLE_SCRIPTS, packageJsonRequiresInstallation } from './package-json-requires-installation';\n\n/**\n * pack components to a .tgz file\n */\nexport class PackTask implements BuildTask {\n readonly name = 'PackComponents';\n readonly description = 'Packing components into a .tgz file';\n readonly location: TaskLocation = 'end';\n readonly dependencies = [Extensions.typescript];\n constructor(\n readonly aspectId: string,\n private packer: Packer,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const capsules = context.capsuleNetwork.seedersCapsules;\n this.logger.info(`going to run pack on ${capsules.length} capsules`);\n const packResults = await this.packer.packMultipleCapsules(capsules, { override: true }, false, true);\n const packArtifactsDefs = this.packer.getArtifactDefInCapsule();\n\n return {\n componentsResults: packResults,\n artifacts: [packArtifactsDefs],\n };\n }\n\n /**\n * packing runs the pack lifecycle scripts and bundles dependencies, which need the packages.\n */\n requiresCapsuleInstallation(components: Component[]): boolean {\n return packageJsonRequiresInstallation(components, this.aspectId, PACK_LIFECYCLE_SCRIPTS);\n }\n}\n"],"mappings":";;;;;;AAGA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,iCAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,gCAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+G,SAAAG,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAE/G;AACA;AACA;AACO,MAAMgB,QAAQ,CAAsB;EAKzCC,WAAWA,CACAC,QAAgB,EACjBC,MAAc,EACdC,MAAc,EACtB;IAAA,KAHSF,QAAgB,GAAhBA,QAAgB;IAAA,KACjBC,MAAc,GAAdA,MAAc;IAAA,KACdC,MAAc,GAAdA,MAAc;IAAAvB,eAAA,eAPR,gBAAgB;IAAAA,eAAA,sBACT,qCAAqC;IAAAA,eAAA,mBAC1B,KAAK;IAAAA,eAAA,uBACf,CAACwB,oBAAU,CAACC,UAAU,CAAC;EAK5C;EAEH,MAAMC,OAAOA,CAACC,OAAqB,EAA4B;IAC7D,MAAMC,QAAQ,GAAGD,OAAO,CAACE,cAAc,CAACC,eAAe;IACvD,IAAI,CAACP,MAAM,CAACQ,IAAI,CAAC,wBAAwBH,QAAQ,CAACI,MAAM,WAAW,CAAC;IACpE,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACX,MAAM,CAACY,oBAAoB,CAACN,QAAQ,EAAE;MAAEO,QAAQ,EAAE;IAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC;IACrG,MAAMC,iBAAiB,GAAG,IAAI,CAACd,MAAM,CAACe,uBAAuB,CAAC,CAAC;IAE/D,OAAO;MACLC,iBAAiB,EAAEL,WAAW;MAC9BM,SAAS,EAAE,CAACH,iBAAiB;IAC/B,CAAC;EACH;;EAEA;AACF;AACA;EACEI,2BAA2BA,CAACC,UAAuB,EAAW;IAC5D,OAAO,IAAAC,kEAA+B,EAACD,UAAU,EAAE,IAAI,CAACpB,QAAQ,EAAEsB,yDAAsB,CAAC;EAC3F;AACF;AAACC,OAAA,CAAAzB,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { Component } from '@teambit/component';
2
+ export declare const PACK_LIFECYCLE_SCRIPTS: string[];
3
+ export declare const PUBLISH_LIFECYCLE_SCRIPTS: string[];
4
+ /**
5
+ * whether the package.json of any of the components needs the packages installed in the capsules, because it runs
6
+ * any of the given lifecycle scripts or it bundles dependencies (taken from node_modules).
7
+ * the package.json written to the capsule comes from the pkg config, the component overrides and, when the
8
+ * artifacts are reused, the package.json of the last build (which includes the env transformations).
9
+ */
10
+ export declare function packageJsonRequiresInstallation(components: Component[], pkgAspectId: string, lifecycleScripts: string[]): boolean;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PUBLISH_LIFECYCLE_SCRIPTS = exports.PACK_LIFECYCLE_SCRIPTS = void 0;
7
+ exports.packageJsonRequiresInstallation = packageJsonRequiresInstallation;
8
+ function _legacy() {
9
+ const data = require("@teambit/legacy.constants");
10
+ _legacy = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ const PACK_LIFECYCLE_SCRIPTS = exports.PACK_LIFECYCLE_SCRIPTS = ['prepack', 'prepare', 'postpack'];
16
+ const PUBLISH_LIFECYCLE_SCRIPTS = exports.PUBLISH_LIFECYCLE_SCRIPTS = ['prepublishOnly', 'prepublish', 'publish', 'postpublish'];
17
+
18
+ /**
19
+ * whether the package.json of any of the components needs the packages installed in the capsules, because it runs
20
+ * any of the given lifecycle scripts or it bundles dependencies (taken from node_modules).
21
+ * the package.json written to the capsule comes from the pkg config, the component overrides and, when the
22
+ * artifacts are reused, the package.json of the last build (which includes the env transformations).
23
+ */
24
+ function packageJsonRequiresInstallation(components, pkgAspectId, lifecycleScripts) {
25
+ return components.some(component => {
26
+ const legacyComponent = component.state._consumer;
27
+ const pkgJsonOfLastBuild = legacyComponent.extensions.findExtension(_legacy().Extensions.builder)?.data?.aspectsData?.find(aspectData => aspectData.aspectId === pkgAspectId)?.data?.pkgJson;
28
+ const pkgJsonSources = [component.state.aspects.get(pkgAspectId)?.data?.packageJsonModification, legacyComponent.overrides?.componentOverridesPackageJsonData, pkgJsonOfLastBuild];
29
+ return pkgJsonSources.some(pkgJson => lifecycleScripts.some(script => pkgJson?.scripts?.[script]) || hasBundledDependencies(pkgJson?.bundledDependencies) || hasBundledDependencies(pkgJson?.bundleDependencies));
30
+ });
31
+ }
32
+
33
+ /**
34
+ * the value is either a list of package names or `true` to bundle all of them.
35
+ */
36
+ function hasBundledDependencies(bundledDependencies) {
37
+ return Array.isArray(bundledDependencies) ? bundledDependencies.length > 0 : Boolean(bundledDependencies);
38
+ }
39
+
40
+ //# sourceMappingURL=package-json-requires-installation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_legacy","data","require","PACK_LIFECYCLE_SCRIPTS","exports","PUBLISH_LIFECYCLE_SCRIPTS","packageJsonRequiresInstallation","components","pkgAspectId","lifecycleScripts","some","component","legacyComponent","state","_consumer","pkgJsonOfLastBuild","extensions","findExtension","Extensions","builder","aspectsData","find","aspectData","aspectId","pkgJson","pkgJsonSources","aspects","get","packageJsonModification","overrides","componentOverridesPackageJsonData","script","scripts","hasBundledDependencies","bundledDependencies","bundleDependencies","Array","isArray","length","Boolean"],"sources":["package-json-requires-installation.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { Extensions } from '@teambit/legacy.constants';\n\nexport const PACK_LIFECYCLE_SCRIPTS = ['prepack', 'prepare', 'postpack'];\nexport const PUBLISH_LIFECYCLE_SCRIPTS = ['prepublishOnly', 'prepublish', 'publish', 'postpublish'];\n\n/**\n * whether the package.json of any of the components needs the packages installed in the capsules, because it runs\n * any of the given lifecycle scripts or it bundles dependencies (taken from node_modules).\n * the package.json written to the capsule comes from the pkg config, the component overrides and, when the\n * artifacts are reused, the package.json of the last build (which includes the env transformations).\n */\nexport function packageJsonRequiresInstallation(\n components: Component[],\n pkgAspectId: string,\n lifecycleScripts: string[]\n): boolean {\n return components.some((component) => {\n const legacyComponent = component.state._consumer;\n const pkgJsonOfLastBuild = legacyComponent.extensions\n .findExtension(Extensions.builder)\n ?.data?.aspectsData?.find((aspectData) => aspectData.aspectId === pkgAspectId)?.data?.pkgJson;\n const pkgJsonSources: Array<Record<string, any> | undefined> = [\n component.state.aspects.get(pkgAspectId)?.data?.packageJsonModification,\n legacyComponent.overrides?.componentOverridesPackageJsonData,\n pkgJsonOfLastBuild,\n ];\n return pkgJsonSources.some(\n (pkgJson) =>\n lifecycleScripts.some((script) => pkgJson?.scripts?.[script]) ||\n hasBundledDependencies(pkgJson?.bundledDependencies) ||\n hasBundledDependencies(pkgJson?.bundleDependencies)\n );\n });\n}\n\n/**\n * the value is either a list of package names or `true` to bundle all of them.\n */\nfunction hasBundledDependencies(bundledDependencies: unknown): boolean {\n return Array.isArray(bundledDependencies) ? bundledDependencies.length > 0 : Boolean(bundledDependencies);\n}\n"],"mappings":";;;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;AACjE,MAAME,yBAAyB,GAAAD,OAAA,CAAAC,yBAAA,GAAG,CAAC,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,CAAC;;AAEnG;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,+BAA+BA,CAC7CC,UAAuB,EACvBC,WAAmB,EACnBC,gBAA0B,EACjB;EACT,OAAOF,UAAU,CAACG,IAAI,CAAEC,SAAS,IAAK;IACpC,MAAMC,eAAe,GAAGD,SAAS,CAACE,KAAK,CAACC,SAAS;IACjD,MAAMC,kBAAkB,GAAGH,eAAe,CAACI,UAAU,CAClDC,aAAa,CAACC,oBAAU,CAACC,OAAO,CAAC,EAChClB,IAAI,EAAEmB,WAAW,EAAEC,IAAI,CAAEC,UAAU,IAAKA,UAAU,CAACC,QAAQ,KAAKf,WAAW,CAAC,EAAEP,IAAI,EAAEuB,OAAO;IAC/F,MAAMC,cAAsD,GAAG,CAC7Dd,SAAS,CAACE,KAAK,CAACa,OAAO,CAACC,GAAG,CAACnB,WAAW,CAAC,EAAEP,IAAI,EAAE2B,uBAAuB,EACvEhB,eAAe,CAACiB,SAAS,EAAEC,iCAAiC,EAC5Df,kBAAkB,CACnB;IACD,OAAOU,cAAc,CAACf,IAAI,CACvBc,OAAO,IACNf,gBAAgB,CAACC,IAAI,CAAEqB,MAAM,IAAKP,OAAO,EAAEQ,OAAO,GAAGD,MAAM,CAAC,CAAC,IAC7DE,sBAAsB,CAACT,OAAO,EAAEU,mBAAmB,CAAC,IACpDD,sBAAsB,CAACT,OAAO,EAAEW,kBAAkB,CACtD,CAAC;EACH,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA,SAASF,sBAAsBA,CAACC,mBAA4B,EAAW;EACrE,OAAOE,KAAK,CAACC,OAAO,CAACH,mBAAmB,CAAC,GAAGA,mBAAmB,CAACI,MAAM,GAAG,CAAC,GAAGC,OAAO,CAACL,mBAAmB,CAAC;AAC3G","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ function _chai() {
4
+ const data = require("chai");
5
+ _chai = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ function _packageJsonRequiresInstallation() {
11
+ const data = require("./package-json-requires-installation");
12
+ _packageJsonRequiresInstallation = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _pack() {
18
+ const data = require("./pack.task");
19
+ _pack = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _publish() {
25
+ const data = require("./publish.task");
26
+ _publish = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ const PKG_ASPECT_ID = 'teambit.pkg/pkg';
32
+ const BUILDER_ASPECT_ID = 'teambit.pipelines/builder';
33
+ const componentWithPkgJson = ({
34
+ pkgConfig,
35
+ overrides,
36
+ lastBuild
37
+ } = {}) => ({
38
+ state: {
39
+ aspects: {
40
+ get: id => id === PKG_ASPECT_ID ? {
41
+ data: {
42
+ packageJsonModification: pkgConfig
43
+ }
44
+ } : undefined
45
+ },
46
+ _consumer: {
47
+ overrides: {
48
+ componentOverridesPackageJsonData: overrides
49
+ },
50
+ extensions: {
51
+ findExtension: id => id === BUILDER_ASPECT_ID ? {
52
+ data: {
53
+ aspectsData: [{
54
+ aspectId: PKG_ASPECT_ID,
55
+ data: {
56
+ pkgJson: lastBuild
57
+ }
58
+ }]
59
+ }
60
+ } : undefined
61
+ }
62
+ }
63
+ }
64
+ });
65
+ const componentsWith = pkgJsonSources => [componentWithPkgJson(), componentWithPkgJson(pkgJsonSources)];
66
+ describe('packageJsonRequiresInstallation', () => {
67
+ const requiresInstallation = pkgJsonSources => (0, _packageJsonRequiresInstallation().packageJsonRequiresInstallation)(componentsWith(pkgJsonSources), PKG_ASPECT_ID, _packageJsonRequiresInstallation().PACK_LIFECYCLE_SCRIPTS);
68
+ it('does not require the installation when neither the scripts run nor dependencies are bundled', () => {
69
+ (0, _chai().expect)(requiresInstallation({
70
+ pkgConfig: {
71
+ scripts: {
72
+ test: 'mocha'
73
+ }
74
+ },
75
+ lastBuild: {
76
+ scripts: {
77
+ start: 'node index.js'
78
+ },
79
+ bundledDependencies: []
80
+ }
81
+ })).to.be.false;
82
+ });
83
+ it('requires the installation when the pkg config has a lifecycle script', () => {
84
+ (0, _chai().expect)(requiresInstallation({
85
+ pkgConfig: {
86
+ scripts: {
87
+ prepack: 'tsc'
88
+ }
89
+ }
90
+ })).to.be.true;
91
+ });
92
+ it('requires the installation when the component overrides have a lifecycle script', () => {
93
+ (0, _chai().expect)(requiresInstallation({
94
+ overrides: {
95
+ scripts: {
96
+ prepare: 'tsc'
97
+ }
98
+ }
99
+ })).to.be.true;
100
+ });
101
+ it('requires the installation when the package.json of the last build has a lifecycle script', () => {
102
+ (0, _chai().expect)(requiresInstallation({
103
+ lastBuild: {
104
+ scripts: {
105
+ postpack: 'node clean.js'
106
+ }
107
+ }
108
+ })).to.be.true;
109
+ });
110
+ it('requires the installation when the package.json bundles dependencies', () => {
111
+ (0, _chai().expect)(requiresInstallation({
112
+ lastBuild: {
113
+ bundledDependencies: ['lodash']
114
+ }
115
+ })).to.be.true;
116
+ (0, _chai().expect)(requiresInstallation({
117
+ pkgConfig: {
118
+ bundleDependencies: true
119
+ }
120
+ })).to.be.true;
121
+ });
122
+ });
123
+ describe('PackTask and PublishTask requiresCapsuleInstallation', () => {
124
+ const packTask = new (_pack().PackTask)(PKG_ASPECT_ID, undefined, undefined);
125
+ const publishTask = new (_publish().PublishTask)(PKG_ASPECT_ID, undefined, undefined);
126
+ it('requires the installation for a publish lifecycle script only when publishing', () => {
127
+ const components = componentsWith({
128
+ pkgConfig: {
129
+ scripts: {
130
+ prepublishOnly: 'npm test'
131
+ }
132
+ }
133
+ });
134
+ (0, _chai().expect)(packTask.requiresCapsuleInstallation(components)).to.be.false;
135
+ (0, _chai().expect)(publishTask.requiresCapsuleInstallation(components)).to.be.true;
136
+ });
137
+ it('requires the installation for a pack lifecycle script in both tasks', () => {
138
+ const components = componentsWith({
139
+ pkgConfig: {
140
+ scripts: {
141
+ prepack: 'tsc'
142
+ }
143
+ }
144
+ });
145
+ (0, _chai().expect)(packTask.requiresCapsuleInstallation(components)).to.be.true;
146
+ (0, _chai().expect)(publishTask.requiresCapsuleInstallation(components)).to.be.true;
147
+ });
148
+ });
149
+
150
+ //# sourceMappingURL=package-json-requires-installation.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chai","data","require","_packageJsonRequiresInstallation","_pack","_publish","PKG_ASPECT_ID","BUILDER_ASPECT_ID","componentWithPkgJson","pkgConfig","overrides","lastBuild","state","aspects","get","id","packageJsonModification","undefined","_consumer","componentOverridesPackageJsonData","extensions","findExtension","aspectsData","aspectId","pkgJson","componentsWith","pkgJsonSources","describe","requiresInstallation","packageJsonRequiresInstallation","PACK_LIFECYCLE_SCRIPTS","it","expect","scripts","test","start","bundledDependencies","to","be","false","prepack","true","prepare","postpack","bundleDependencies","packTask","PackTask","publishTask","PublishTask","components","prepublishOnly","requiresCapsuleInstallation"],"sources":["package-json-requires-installation.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { PACK_LIFECYCLE_SCRIPTS, packageJsonRequiresInstallation } from './package-json-requires-installation';\nimport { PackTask } from './pack.task';\nimport { PublishTask } from './publish.task';\n\nconst PKG_ASPECT_ID = 'teambit.pkg/pkg';\nconst BUILDER_ASPECT_ID = 'teambit.pipelines/builder';\n\ntype PkgJsonSources = {\n pkgConfig?: Record<string, any>;\n overrides?: Record<string, any>;\n lastBuild?: Record<string, any>;\n};\nconst componentWithPkgJson = ({ pkgConfig, overrides, lastBuild }: PkgJsonSources = {}) =>\n ({\n state: {\n aspects: {\n get: (id: string) => (id === PKG_ASPECT_ID ? { data: { packageJsonModification: pkgConfig } } : undefined),\n },\n _consumer: {\n overrides: { componentOverridesPackageJsonData: overrides },\n extensions: {\n findExtension: (id: string) =>\n id === BUILDER_ASPECT_ID\n ? { data: { aspectsData: [{ aspectId: PKG_ASPECT_ID, data: { pkgJson: lastBuild } }] } }\n : undefined,\n },\n },\n },\n }) as any;\nconst componentsWith = (pkgJsonSources: PkgJsonSources) => [\n componentWithPkgJson(),\n componentWithPkgJson(pkgJsonSources),\n];\n\ndescribe('packageJsonRequiresInstallation', () => {\n const requiresInstallation = (pkgJsonSources: PkgJsonSources) =>\n packageJsonRequiresInstallation(componentsWith(pkgJsonSources), PKG_ASPECT_ID, PACK_LIFECYCLE_SCRIPTS);\n it('does not require the installation when neither the scripts run nor dependencies are bundled', () => {\n expect(\n requiresInstallation({\n pkgConfig: { scripts: { test: 'mocha' } },\n lastBuild: { scripts: { start: 'node index.js' }, bundledDependencies: [] },\n })\n ).to.be.false;\n });\n it('requires the installation when the pkg config has a lifecycle script', () => {\n expect(requiresInstallation({ pkgConfig: { scripts: { prepack: 'tsc' } } })).to.be.true;\n });\n it('requires the installation when the component overrides have a lifecycle script', () => {\n expect(requiresInstallation({ overrides: { scripts: { prepare: 'tsc' } } })).to.be.true;\n });\n it('requires the installation when the package.json of the last build has a lifecycle script', () => {\n expect(requiresInstallation({ lastBuild: { scripts: { postpack: 'node clean.js' } } })).to.be.true;\n });\n it('requires the installation when the package.json bundles dependencies', () => {\n expect(requiresInstallation({ lastBuild: { bundledDependencies: ['lodash'] } })).to.be.true;\n expect(requiresInstallation({ pkgConfig: { bundleDependencies: true } })).to.be.true;\n });\n});\n\ndescribe('PackTask and PublishTask requiresCapsuleInstallation', () => {\n const packTask = new PackTask(PKG_ASPECT_ID, undefined as any, undefined as any);\n const publishTask = new PublishTask(PKG_ASPECT_ID, undefined as any, undefined as any);\n it('requires the installation for a publish lifecycle script only when publishing', () => {\n const components = componentsWith({ pkgConfig: { scripts: { prepublishOnly: 'npm test' } } });\n expect(packTask.requiresCapsuleInstallation(components)).to.be.false;\n expect(publishTask.requiresCapsuleInstallation(components)).to.be.true;\n });\n it('requires the installation for a pack lifecycle script in both tasks', () => {\n const components = componentsWith({ pkgConfig: { scripts: { prepack: 'tsc' } } });\n expect(packTask.requiresCapsuleInstallation(components)).to.be.true;\n expect(publishTask.requiresCapsuleInstallation(components)).to.be.true;\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,iCAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,gCAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMK,aAAa,GAAG,iBAAiB;AACvC,MAAMC,iB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,CAAC;EAChF,MAAM8B,WAAW,GAAG,KAAIC,sBAAW,EAAC1C,aAAa,EAAEW,SAAS,EAASA,SAAgB,CAAC;EACtFc,EAAE,CAAC,+EAA+E,EAAE,MAAM;IACxF,MAAMkB,UAAU,GAAGxB,cAAc,CAAC;MAAEhB,SAAS,EAAE;QAAEwB,OAAO,EAAE;UAAEiB,cAAc,EAAE;QAAW;MAAE;IAAE,CAAC,CAAC;IAC7F,IAAAlB,cAAM,EAACa,QAAQ,CAACM,2BAA2B,CAACF,UAAU,CAAC,CAAC,CAACZ,EAAE,CAACC,EAAE,CAACC,KAAK;IACpE,IAAAP,cAAM,EAACe,WAAW,CAACI,2BAA2B,CAACF,UAAU,CAAC,CAAC,CAACZ,EAAE,CAACC,EAAE,CAACG,IAAI;EACxE,CAAC,CAAC;EACFV,EAAE,CAAC,qEAAqE,EAAE,MAAM;IAC9E,MAAMkB,UAAU,GAAGxB,cAAc,CAAC;MAAEhB,SAAS,EAAE;QAAEwB,OAAO,EAAE;UAAEO,OAAO,EAAE;QAAM;MAAE;IAAE,CAAC,CAAC;IACjF,IAAAR,cAAM,EAACa,QAAQ,CAACM,2BAA2B,CAACF,UAAU,CAAC,CAAC,CAACZ,EAAE,CAACC,EAAE,CAACG,IAAI;IACnE,IAAAT,cAAM,EAACe,WAAW,CAACI,2BAA2B,CAACF,UAAU,CAAC,CAAC,CAACZ,EAAE,CAACC,EAAE,CAACG,IAAI;EACxE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -13,6 +13,7 @@ export declare class PreparePackagesTask implements BuildTask {
13
13
  readonly location = "end";
14
14
  constructor(aspectId: string, logger: Logger, envs: EnvsMain);
15
15
  execute(context: BuildContext): Promise<BuiltTaskResult>;
16
+ requiresCapsuleInstallation(): boolean;
16
17
  private writeNpmIgnoreFile;
17
18
  /**
18
19
  * remove the source files and copy the dists files
@@ -57,6 +57,9 @@ class PreparePackagesTask {
57
57
  };
58
58
  return result;
59
59
  }
60
+ requiresCapsuleInstallation() {
61
+ return false;
62
+ }
60
63
  async writeNpmIgnoreFile(context) {
61
64
  await Promise.all(context.capsuleNetwork.seedersCapsules.map(async capsule => {
62
65
  await (0, _writeNpmIgnore().writeNpmIgnore)(capsule, this.envs);
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_fsExtra","_interopRequireDefault","_path","_writeNpmIgnore","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","PreparePackagesTask","constructor","aspectId","logger","envs","execute","context","writeNpmIgnoreFile","result","componentsResults","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","writeNpmIgnore","executeDistAsRootTask","env","getCompiler","compilerInstance","distDir","graphCapsules","removeSourceFiles","moveDistToRoot","updatePackageJson","excludeDirs","dir","excludeFiles","allFiles","getAllFilesPaths","ignore","debug","join","file","fs","remove","path","from","to","moveSync","compiler","distMainFile","getDistPathBySrcPath","component","state","_consumer","mainFile","distMainFileWithoutDistDir","replace","sep","packageJson","PackageJsonFile","loadFromCapsuleSync","addOrUpdateProperty","write","exports"],"sources":["prepare-packages.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask } from '@teambit/builder';\nimport type { Compiler } from '@teambit/compiler';\nimport type { Capsule } from '@teambit/isolator';\nimport type { EnvsMain } from '@teambit/envs';\nimport type { Logger } from '@teambit/logger';\nimport { PackageJsonFile } from '@teambit/component.sources';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { writeNpmIgnore } from './write-npm-ignore';\n\n/**\n * prepare packages for publishing.\n */\nexport class PreparePackagesTask implements BuildTask {\n readonly name = 'PreparePackages';\n readonly description = 'Preparing the packages for publishing';\n readonly location = 'end';\n constructor(\n readonly aspectId: string,\n private logger: Logger,\n private envs: EnvsMain\n ) {}\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n await this.writeNpmIgnoreFile(context);\n const result = {\n componentsResults: [],\n };\n\n return result;\n }\n\n private async writeNpmIgnoreFile(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n await writeNpmIgnore(capsule, this.envs);\n })\n );\n }\n\n /**\n * remove the source files and copy the dists files\n * into the root of the capsule.\n * this is needed when components import from other components internal paths. without this task,\n * the internal paths are the source, so node will throw an error when trying to use them. this\n * task makes sure that the internal paths point to the consumable code (dists).\n */\n private async executeDistAsRootTask(context: BuildContext) {\n if (!context.env.getCompiler) return;\n const compilerInstance: Compiler = context.env.getCompiler();\n const distDir = compilerInstance.distDir;\n\n await Promise.all(\n context.capsuleNetwork.graphCapsules.map(async (capsule) => {\n await this.removeSourceFiles(capsule, distDir);\n await this.moveDistToRoot(capsule, distDir);\n await this.updatePackageJson(capsule, compilerInstance, distDir);\n })\n );\n }\n\n private async removeSourceFiles(capsule: Capsule, distDir: string) {\n const excludeDirs = [distDir, 'node_modules', 'public', 'bin'].map((dir) => `${dir}/**`);\n const excludeFiles = ['package.json'];\n const allFiles = capsule.getAllFilesPaths('.', { ignore: [...excludeDirs, ...excludeFiles] });\n this.logger.debug(`delete the following files:\\n${allFiles.join('\\n')}`);\n await Promise.all(allFiles.map((file) => fs.remove(path.join(capsule.path, file))));\n }\n\n private async moveDistToRoot(capsule: Capsule, distDir: string) {\n const from = path.join(capsule.path, distDir);\n const to = capsule.path;\n this.logger.debug(`move from ${from} to: ${to}`);\n // for some reason `fs.move` throws an error \"dest already exists.\".\n fs.moveSync(from, to);\n }\n\n /**\n * by default, the \"main\" prop points to the dist file (e.g. \"dist/index./js\").\n * here, we have to change it because there is no dist dir anymore.\n */\n private async updatePackageJson(capsule: Capsule, compiler: Compiler, distDir: string) {\n const distMainFile = compiler.getDistPathBySrcPath(capsule.component.state._consumer.mainFile);\n const distMainFileWithoutDistDir = distMainFile.replace(`${distDir}${path.sep}`, '');\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule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E,EAAE,CAAC;IAChD;IACAJ,kBAAE,CAACK,QAAQ,CAACF,IAAI,EAAEC,EAAE,CAAC;EACvB;;EAEA;AACF;AACA;AACA;EACE,MAAcd,iBAAiBA,CAACV,OAAgB,EAAE0B,QAAkB,EAAEpB,OAAe,EAAE;IACrF,MAAMqB,YAAY,GAAGD,QAAQ,CAACE,oBAAoB,CAAC5B,OAAO,CAAC6B,SAAS,CAACC,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC;IAC9F,MAAMC,0BAA0B,GAAGN,YAAY,CAACO,OAAO,CAAC,GAAG5B,OAAO,GAAGgB,eAAI,CAACa,GAAG,EAAE,EAAE,EAAE,CAAC;IACpF,MAAMC,WAAW,GAAGC,4BAAe,CAACC,mBAAmB,CAACtC,OAAO,CAACsB,IAAI,CAAC;IACrEc,WAAW,CAACG,mBAAmB,CAAC,MAAM,EAAEN,0BAA0B,CAAC;IACnE,MAAMG,WAAW,CAACI,KAAK,CAAC,CAAC;EAC3B;AACF;AAACC,OAAA,CAAAxD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_component","data","require","_fsExtra","_interopRequireDefault","_path","_writeNpmIgnore","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","PreparePackagesTask","constructor","aspectId","logger","envs","execute","context","writeNpmIgnoreFile","result","componentsResults","requiresCapsuleInstallation","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","writeNpmIgnore","executeDistAsRootTask","env","getCompiler","compilerInstance","distDir","graphCapsules","removeSourceFiles","moveDistToRoot","updatePackageJson","excludeDirs","dir","excludeFiles","allFiles","getAllFilesPaths","ignore","debug","join","file","fs","remove","path","from","to","moveSync","compiler","distMainFile","getDistPathBySrcPath","component","state","_consumer","mainFile","distMainFileWithoutDistDir","replace","sep","packageJson","PackageJsonFile","loadFromCapsuleSync","addOrUpdateProperty","write","exports"],"sources":["prepare-packages.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask } from '@teambit/builder';\nimport type { Compiler } from '@teambit/compiler';\nimport type { Capsule } from '@teambit/isolator';\nimport type { EnvsMain } from '@teambit/envs';\nimport type { Logger } from '@teambit/logger';\nimport { PackageJsonFile } from '@teambit/component.sources';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { writeNpmIgnore } from './write-npm-ignore';\n\n/**\n * prepare packages for publishing.\n */\nexport class PreparePackagesTask implements BuildTask {\n readonly name = 'PreparePackages';\n readonly description = 'Preparing the packages for publishing';\n readonly location = 'end';\n constructor(\n readonly aspectId: string,\n private logger: Logger,\n private envs: EnvsMain\n ) {}\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n await this.writeNpmIgnoreFile(context);\n const result = {\n componentsResults: [],\n };\n\n return result;\n }\n\n requiresCapsuleInstallation(): boolean {\n return false;\n }\n\n private async writeNpmIgnoreFile(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n await writeNpmIgnore(capsule, this.envs);\n })\n );\n }\n\n /**\n * remove the source files and copy the dists files\n * into the root of the capsule.\n * this is needed when components import from other components internal paths. without this task,\n * the internal paths are the source, so node will throw an error when trying to use them. this\n * task makes sure that the internal paths point to the consumable code (dists).\n */\n private async executeDistAsRootTask(context: BuildContext) {\n if (!context.env.getCompiler) return;\n const compilerInstance: Compiler = context.env.getCompiler();\n const distDir = compilerInstance.distDir;\n\n await Promise.all(\n context.capsuleNetwork.graphCapsules.map(async (capsule) => {\n await this.removeSourceFiles(capsule, distDir);\n await this.moveDistToRoot(capsule, distDir);\n await this.updatePackageJson(capsule, compilerInstance, distDir);\n })\n );\n }\n\n private async removeSourceFiles(capsule: Capsule, distDir: string) {\n const excludeDirs = [distDir, 'node_modules', 'public', 'bin'].map((dir) => `${dir}/**`);\n const excludeFiles = ['package.json'];\n const allFiles = capsule.getAllFilesPaths('.', { ignore: [...excludeDirs, ...excludeFiles] });\n this.logger.debug(`delete the following files:\\n${allFiles.join('\\n')}`);\n await Promise.all(allFiles.map((file) => fs.remove(path.join(capsule.path, file))));\n }\n\n private async moveDistToRoot(capsule: Capsule, distDir: string) {\n const from = path.join(capsule.path, distDir);\n const to = capsule.path;\n this.logger.debug(`move from ${from} to: ${to}`);\n // for some reason `fs.move` throws an error \"dest already exists.\".\n fs.moveSync(from, to);\n }\n\n /**\n * by default, the \"main\" prop points to the dist file (e.g. \"dist/index./js\").\n * here, we have to change it because there is no dist dir anymore.\n */\n private async updatePackageJson(capsule: Capsule, compiler: Compiler, distDir: string) {\n const distMainFile = compiler.getDistPathBySrcPath(capsule.component.state._consumer.mainFile);\n const distMainFileWithoutDistDir = distMainFile.replace(`${distDir}${path.sep}`, '');\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n packageJson.addOrUpdateProperty('main', distMainFileWithoutDistDir);\n await packageJson.write();\n }\n}\n"],"mappings":";;;;;;AAKA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,gBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,eAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoD,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,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AA,CAAAzD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pkg_pkg@1.0.1272/dist/pkg.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pkg_pkg@1.0.1272/dist/pkg.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pkg_pkg@1.0.1273/dist/pkg.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pkg_pkg@1.0.1273/dist/pkg.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -1,5 +1,6 @@
1
1
  import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@teambit/builder';
2
2
  import type { Logger } from '@teambit/logger';
3
+ import type { Component } from '@teambit/component';
3
4
  import type { Publisher } from './publisher';
4
5
  /**
5
6
  * publish components by running "npm publish"
@@ -13,4 +14,9 @@ export declare class PublishTask implements BuildTask {
13
14
  readonly location: TaskLocation;
14
15
  constructor(aspectId: string, publisher: Publisher, logger: Logger);
15
16
  execute(context: BuildContext): Promise<BuiltTaskResult>;
17
+ /**
18
+ * normally, it publishes the tarball created by the PackComponents task. without a tarball (e.g. the pack task was
19
+ * skipped), it publishes the capsule dir, which runs the pack and publish lifecycle scripts and bundles dependencies.
20
+ */
21
+ requiresCapsuleInstallation(components: Component[]): boolean;
16
22
  }
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PublishTask = void 0;
7
+ function _packageJsonRequiresInstallation() {
8
+ const data = require("./package-json-requires-installation");
9
+ _packageJsonRequiresInstallation = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
7
14
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
16
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -37,6 +44,14 @@ class PublishTask {
37
44
  artifacts: []
38
45
  };
39
46
  }
47
+
48
+ /**
49
+ * normally, it publishes the tarball created by the PackComponents task. without a tarball (e.g. the pack task was
50
+ * skipped), it publishes the capsule dir, which runs the pack and publish lifecycle scripts and bundles dependencies.
51
+ */
52
+ requiresCapsuleInstallation(components) {
53
+ return (0, _packageJsonRequiresInstallation().packageJsonRequiresInstallation)(components, this.aspectId, [..._packageJsonRequiresInstallation().PACK_LIFECYCLE_SCRIPTS, ..._packageJsonRequiresInstallation().PUBLISH_LIFECYCLE_SCRIPTS]);
54
+ }
40
55
  }
41
56
  exports.PublishTask = PublishTask;
42
57
 
@@ -1 +1 @@
1
- {"version":3,"names":["PublishTask","constructor","aspectId","publisher","logger","_defineProperty","execute","context","options","dryRun","capsules","capsuleNetwork","seedersCapsules","capsulesToPublish","forEach","c","shouldPublish","component","config","extensions","push","info","length","publishResults","publishMultipleCapsules","componentsResults","artifacts","exports"],"sources":["publish.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@teambit/builder';\nimport type { Logger } from '@teambit/logger';\nimport type { Capsule } from '@teambit/isolator';\nimport type { Publisher } from './publisher';\n\n/**\n * publish components by running \"npm publish\"\n */\nexport class PublishTask implements BuildTask {\n readonly name = 'PublishComponents';\n readonly description = 'Publishing components to the package registry';\n readonly location: TaskLocation = 'end';\n constructor(\n readonly aspectId: string,\n private publisher: Publisher,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n this.publisher.options.dryRun = false;\n const capsules = context.capsuleNetwork.seedersCapsules;\n // const capsulesToPublish = capsules.filter((c) => this.publisher.shouldPublish(c.component.config.extensions));\n const capsulesToPublish: Capsule[] = [];\n capsules.forEach((c) => {\n const shouldPublish = this.publisher.shouldPublish(c.component.config.extensions);\n if (shouldPublish) {\n capsulesToPublish.push(c);\n }\n });\n this.logger.info(`going to run publish on ${capsulesToPublish.length} out of ${capsules.length}`);\n const publishResults = await this.publisher.publishMultipleCapsules(capsulesToPublish);\n\n return {\n componentsResults: publishResults,\n artifacts: [],\n };\n }\n}\n"],"mappings":";;;;;;;;;AAKA;AACA;AACA;AACO,MAAMA,WAAW,CAAsB;EAI5CC,WAAWA,CACAC,QAAgB,EACjBC,SAAoB,EACpBC,MAAc,EACtB;IAAA,KAHSF,QAAgB,GAAhBA,QAAgB;IAAA,KACjBC,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAAC,eAAA,eANR,mBAAmB;IAAAA,eAAA,sBACZ,+CAA+C;IAAAA,eAAA,mBACpC,KAAK;EAKpC;EAEH,MAAMC,OAAOA,CAACC,OAAqB,EAA4B;IAC7D,IAAI,CAACJ,SAAS,CAACK,OAAO,CAACC,MAAM,GAAG,KAAK;IACrC,MAAMC,QAAQ,GAAGH,OAAO,CAACI,cAAc,CAACC,eAAe;IACvD;IACA,MAAMC,iBAA4B,GAAG,EAAE;IACvCH,QAAQ,CAACI,OAAO,CAAEC,CAAC,IAAK;MACtB,MAAMC,aAAa,GAAG,IAAI,CAACb,SAAS,CAACa,aAAa,CAACD,CAAC,CAACE,SAAS,CAACC,MAAM,CAACC,UAAU,CAAC;MACjF,IAAIH,aAAa,EAAE;QACjBH,iBAAiB,CAACO,IAAI,CAACL,CAAC,CAAC;MAC3B;IACF,CAAC,CAAC;IACF,IAAI,CAACX,MAAM,CAACiB,IAAI,CAAC,2BAA2BR,iBAAiB,CAACS,MAAM,WAAWZ,QAAQ,CAACY,MAAM,EAAE,CAAC;IACjG,MAAMC,cAAc,GAAG,MAAM,IAAI,CAACpB,SAAS,CAACqB,uBAAuB,CAACX,iBAAiB,CAAC;IAEtF,OAAO;MACLY,iBAAiB,EAAEF,cAAc;MACjCG,SAAS,EAAE;IACb,CAAC;EACH;AACF;AAACC,OAAA,CAAA3B,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_packageJsonRequiresInstallation","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","PublishTask","constructor","aspectId","publisher","logger","execute","context","options","dryRun","capsules","capsuleNetwork","seedersCapsules","capsulesToPublish","forEach","c","shouldPublish","component","config","extensions","push","info","length","publishResults","publishMultipleCapsules","componentsResults","artifacts","requiresCapsuleInstallation","components","packageJsonRequiresInstallation","PACK_LIFECYCLE_SCRIPTS","PUBLISH_LIFECYCLE_SCRIPTS","exports"],"sources":["publish.task.ts"],"sourcesContent":["import type { BuildContext, BuiltTaskResult, BuildTask, TaskLocation } from '@teambit/builder';\nimport type { Logger } from '@teambit/logger';\nimport type { Capsule } from '@teambit/isolator';\nimport type { Component } from '@teambit/component';\nimport type { Publisher } from './publisher';\nimport {\n PACK_LIFECYCLE_SCRIPTS,\n PUBLISH_LIFECYCLE_SCRIPTS,\n packageJsonRequiresInstallation,\n} from './package-json-requires-installation';\n\n/**\n * publish components by running \"npm publish\"\n */\nexport class PublishTask implements BuildTask {\n readonly name = 'PublishComponents';\n readonly description = 'Publishing components to the package registry';\n readonly location: TaskLocation = 'end';\n constructor(\n readonly aspectId: string,\n private publisher: Publisher,\n private logger: Logger\n ) {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n this.publisher.options.dryRun = false;\n const capsules = context.capsuleNetwork.seedersCapsules;\n // const capsulesToPublish = capsules.filter((c) => this.publisher.shouldPublish(c.component.config.extensions));\n const capsulesToPublish: Capsule[] = [];\n capsules.forEach((c) => {\n const shouldPublish = this.publisher.shouldPublish(c.component.config.extensions);\n if (shouldPublish) {\n capsulesToPublish.push(c);\n }\n });\n this.logger.info(`going to run publish on ${capsulesToPublish.length} out of ${capsules.length}`);\n const publishResults = await this.publisher.publishMultipleCapsules(capsulesToPublish);\n\n return {\n componentsResults: publishResults,\n artifacts: [],\n };\n }\n\n /**\n * normally, it publishes the tarball created by the PackComponents task. without a tarball (e.g. the pack task was\n * skipped), it publishes the capsule dir, which runs the pack and publish lifecycle scripts and bundles dependencies.\n */\n requiresCapsuleInstallation(components: Component[]): boolean {\n return packageJsonRequiresInstallation(components, this.aspectId, [\n ...PACK_LIFECYCLE_SCRIPTS,\n ...PUBLISH_LIFECYCLE_SCRIPTS,\n ]);\n }\n}\n"],"mappings":";;;;;;AAKA,SAAAA,iCAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,gCAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAI8C,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,u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zB,QAAQ,EAAE,CAChE,GAAG2B,yDAAsB,EACzB,GAAGC,4DAAyB,CAC7B,CAAC;EACJ;AACF;AAACC,OAAA,CAAA/B,WAAA,GAAAA,WAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/pkg",
3
- "version": "1.0.1272",
3
+ "version": "1.0.1273",
4
4
  "homepage": "https://bit.cloud/teambit/pkg/pkg",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.pkg",
8
8
  "name": "pkg",
9
- "version": "1.0.1272"
9
+ "version": "1.0.1273"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "4.1.2",
@@ -20,12 +20,11 @@
20
20
  "graphql-tag": "2.12.1",
21
21
  "cli-highlight": "2.1.9",
22
22
  "execa": "2.1.0",
23
- "@teambit/cli": "0.0.1433",
24
23
  "@teambit/legacy.constants": "0.0.51",
25
24
  "@teambit/logger": "0.0.1503",
26
25
  "@teambit/envs.contracts": "0.0.2",
26
+ "@teambit/express": "0.0.1510",
27
27
  "@teambit/component-version": "1.0.4",
28
- "@teambit/legacy.scope": "0.0.202",
29
28
  "@teambit/legacy.utils": "0.0.57",
30
29
  "@teambit/component.sources": "0.0.247",
31
30
  "@teambit/harmony": "0.4.12",
@@ -36,20 +35,21 @@
36
35
  "@teambit/harmony.modules.in-memory-cache": "0.0.56",
37
36
  "@teambit/harmony.modules.runtimes": "0.0.4",
38
37
  "@teambit/legacy.bit-map": "0.0.252",
39
- "@teambit/workspace.modules.node-modules-linker": "0.0.435",
40
38
  "@teambit/ui-foundation.ui.use-box.menu": "1.0.16",
41
39
  "@teambit/component-id": "1.2.5",
42
40
  "@teambit/legacy.extension-data": "0.0.197",
43
- "@teambit/legacy.consumer-component": "0.0.196",
44
- "@teambit/builder": "1.0.1272",
45
- "@teambit/envs": "1.0.1252",
46
- "@teambit/component": "1.0.1249",
47
- "@teambit/express": "0.0.1510",
48
- "@teambit/isolator": "1.0.1270",
49
- "@teambit/scope": "1.0.1271",
50
- "@teambit/dependency-resolver": "1.0.1254",
51
- "@teambit/workspace": "1.0.1272",
52
- "@teambit/compiler": "1.0.1272"
41
+ "@teambit/cli": "0.0.1434",
42
+ "@teambit/builder": "1.0.1273",
43
+ "@teambit/component": "1.0.1250",
44
+ "@teambit/envs": "1.0.1253",
45
+ "@teambit/isolator": "1.0.1271",
46
+ "@teambit/legacy.scope": "0.0.203",
47
+ "@teambit/scope": "1.0.1272",
48
+ "@teambit/dependency-resolver": "1.0.1255",
49
+ "@teambit/workspace.modules.node-modules-linker": "0.0.436",
50
+ "@teambit/workspace": "1.0.1273",
51
+ "@teambit/compiler": "1.0.1273",
52
+ "@teambit/legacy.consumer-component": "0.0.197"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/mime": "2.0.3",