diff --git a/src/__snapshots__/appPackageManifest.test.ts.snap b/src/__snapshots__/appPackageManifest.test.ts.snap index fd6a40c9..87144bd6 100644 --- a/src/__snapshots__/appPackageManifest.test.ts.snap +++ b/src/__snapshots__/appPackageManifest.test.ts.snap @@ -8,9 +8,6 @@ Object { "watch": Object { "higgs": Object { "filename": "device-higgs.zip", - "platform": Array [ - "30.1.2+", - ], }, }, }, @@ -38,9 +35,6 @@ Object { "watch": Object { "higgs": Object { "filename": "device-higgs.zip", - "platform": Array [ - "30.1.2+", - ], }, }, }, @@ -68,9 +62,6 @@ Object { "watch": Object { "higgs": Object { "filename": "device-higgs.zip", - "platform": Array [ - "30.1.2+", - ], }, }, }, @@ -91,9 +82,6 @@ Object { "watch": Object { "higgs": Object { "filename": "device-higgs.zip", - "platform": Array [ - "30.1.2+", - ], }, }, }, @@ -117,15 +105,9 @@ Object { "watch": Object { "higgs": Object { "filename": "device-higgs.zip", - "platform": Array [ - "30.1.2+", - ], }, "meson": Object { "filename": "device-meson.zip", - "platform": Array [ - "32.4.18+", - ], }, }, }, @@ -143,13 +125,11 @@ Object { } `; -exports[`emits an error if a component bundle tag has a device type but invalid platform 1`] = `"Unknown bundle component tag: Invalid value \\"1.1.1+\\" supplied to : (({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array }/platform: Array"`; +exports[`emits an error if a component bundle tag has a device type but invalid platform 1`] = `"Unknown bundle component tag: Invalid value \\"1.1.1+\\" supplied to : (({ type: \\"device\\", family: string } & Partial<{ platform: Array, isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string } & Partial<{ platform: Array, isNative: true }>)/1: Partial<{ platform: Array, isNative: true }>/platform: Array"`; -exports[`emits an error if a component bundle tag has a device type but missing family 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array }/family: string"`; +exports[`emits an error if a component bundle tag has a device type but missing family 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string } & Partial<{ platform: Array, isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string } & Partial<{ platform: Array, isNative: true }>)/0: { type: \\"device\\", family: string }/family: string"`; -exports[`emits an error if a component bundle tag has a device type but missing platform 1`] = `"Unknown bundle component tag: Invalid value undefined supplied to : (({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>) | { type: \\"companion\\" })/0: ({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>)/0: { type: \\"device\\", family: string, platform: Array }/platform: Array"`; - -exports[`emits an error if a component bundle tag has an invalid type field 1`] = `"Unknown bundle component tag: Invalid value {\\"type\\":\\"__invalid__\\"} supplied to : (({ type: \\"device\\", family: string, platform: Array } & Partial<{ isNative: true }>) | { type: \\"companion\\" })"`; +exports[`emits an error if a component bundle tag has an invalid type field 1`] = `"Unknown bundle component tag: Invalid value {\\"type\\":\\"__invalid__\\"} supplied to : (({ type: \\"device\\", family: string } & Partial<{ platform: Array, isNative: true }>) | { type: \\"companion\\" })"`; exports[`emits an error if both JS and native device components are present 1`] = `"Cannot bundle mixed native/JS device components"`; diff --git a/src/appPackageManifest.test.ts b/src/appPackageManifest.test.ts index 90753b52..1256a80b 100644 --- a/src/appPackageManifest.test.ts +++ b/src/appPackageManifest.test.ts @@ -2,7 +2,6 @@ import { Readable } from 'stream'; import Vinyl from 'vinyl'; import appPackageManifest from './appPackageManifest'; -import buildTargets from './buildTargets'; import { ComponentType } from './componentTargets'; import ProjectConfiguration, { AppType, @@ -74,7 +73,6 @@ function expectValidPackageManifest(options?: { componentBundle: { type: 'device', family: platform, - platform: buildTargets[platform].platform, ...(nativeApp && { isNative: true }), }, }), @@ -129,7 +127,6 @@ it('emits an error if both JS and native device components are present', () => { componentBundle: { type: 'device', family: 'foo', - platform: ['1.1.1+'], }, path: 'bundle.zip', contents: Buffer.alloc(0), @@ -164,7 +161,6 @@ it('emits an error if multiple bundles are present for the same device family', componentBundle: { type: 'device', family: 'foo', - platform: ['1.1.1+'], }, path: `bundle${i}.zip`, contents: Buffer.alloc(0), @@ -190,7 +186,6 @@ it('builds a package manifest with a native device component and companion', () it.each<[string, any]>([ ['has an invalid type field', { type: '__invalid__' }], - ['has a device type but missing platform', { type: 'device', family: 'foo' }], [ 'has a device type but missing family', { type: 'device', platform: ['1.1.1+'] }, diff --git a/src/appPackageManifest.ts b/src/appPackageManifest.ts index 87cdba3b..19efaf09 100644 --- a/src/appPackageManifest.ts +++ b/src/appPackageManifest.ts @@ -19,7 +19,7 @@ interface Components { watch?: { [platform: string]: { filename: string; - platform: string[]; + platform?: string[]; }; }; companion?: { @@ -33,9 +33,9 @@ const ComponentBundleTag = t.taggedUnion('type', [ t.interface({ type: t.literal('device'), family: t.string, - platform: t.array(t.string), }), t.partial({ + platform: t.array(t.string), isNative: t.literal(true), }), ]), @@ -71,6 +71,7 @@ class AppPackageManifestTransform extends Transform { super({ objectMode: true }); } + // tslint:disable-next-line:cognitive-complexity private transformComponentBundle(file: Vinyl) { const bundleInfo = getBundleInfo(file); @@ -106,9 +107,12 @@ class AppPackageManifestTransform extends Transform { } this.components.watch[bundleInfo.family] = { - platform: bundleInfo.platform, filename: file.relative, }; + + if (bundleInfo.platform) { + this.components.watch[bundleInfo.family].platform = bundleInfo.platform; + } } else { if (this.components[bundleInfo.type] !== undefined) { throwDuplicateComponent(this.components[bundleInfo.type]!.filename); diff --git a/src/buildTargets.test.ts b/src/buildTargets.test.ts index bcdf8f84..644e627d 100644 --- a/src/buildTargets.test.ts +++ b/src/buildTargets.test.ts @@ -33,7 +33,6 @@ it('merges the build target descriptors', () => { expect(generateBuildTargets()).toMatchObject({ higgs: { displayName: 'Fitbit Ionic', - platform: expect.any(Array), resourceFilterTag: '348x250', }, // Unfortunately, due to the way that module mocking works, the diff --git a/src/buildTargets.ts b/src/buildTargets.ts index 08268855..e6d9b978 100644 --- a/src/buildTargets.ts +++ b/src/buildTargets.ts @@ -6,7 +6,6 @@ import { PolyfillMap } from './plugins/polyfill'; export interface BuildTargetDescriptor { displayName: string; - platform: string[]; resourceFilterTag: string; polyfills?: PolyfillMap; maxDeviceBundleSize?: number; // in bytes @@ -16,17 +15,14 @@ export interface BuildTargetDescriptor { const baseBuildTargets: { [platform: string]: BuildTargetDescriptor } = { higgs: { displayName: 'Fitbit Ionic', - platform: ['30.1.2+'], resourceFilterTag: '348x250', }, meson: { displayName: 'Fitbit Versa', - platform: ['32.4.18+'], resourceFilterTag: '300x300', }, gemini: { displayName: 'Fitbit Versa Lite', - platform: ['33.1.30+'], resourceFilterTag: '300x300', minSDKVersion: '3.1.0', maxDeviceBundleSize: 3145728, diff --git a/src/index.ts b/src/index.ts index 32421dd2..3042cc74 100644 --- a/src/index.ts +++ b/src/index.ts @@ -210,12 +210,9 @@ export function buildDeviceComponents({ // before building the resources for each component. ...projectConfig.buildTargets.map((family) => lazyObjectReadable(() => { - const { - platform, - displayName, - polyfills, - maxDeviceBundleSize, - } = buildTargets[family]; + const { displayName, polyfills, maxDeviceBundleSize } = buildTargets[ + family + ]; onDiagnostic({ messageText: `Building app for ${displayName}`, category: DiagnosticCategory.Message, @@ -275,7 +272,6 @@ export function buildDeviceComponents({ gulpSetProperty({ componentBundle: { family, - platform, type: 'device', }, }), diff --git a/yarn.lock b/yarn.lock index addcb149..d817f794 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2684,10 +2684,10 @@ invert-kv@^2.0.0: resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== -io-ts@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.0.0.tgz#560f8ddf92cce7ea73820cedab7b31044e464d1e" - integrity sha512-6i8PKyNR/dvEbUU9uE+v4iVFU7l674ZEGQsh92y6xEZF/rj46fXbPy+uPPXJEsCP0J0X3UpzXAxp04K4HR2jVw== +io-ts@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.0.1.tgz#1261c12f915c2f48d16393a36966636b48a45aa1" + integrity sha512-RezD+WcCfW4VkMkEcQWL/Nmy/nqsWTvTYg7oUmTGzglvSSV2P9h2z1PVeREPFf0GWNzruYleAt1XCMQZSg1xxQ== is-absolute@^1.0.0: version "1.0.0" @@ -3954,12 +3954,11 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -multistream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/multistream/-/multistream-3.0.0.tgz#93d6a672828c311a5b228212d319a5e9073d2e45" - integrity sha512-v1Fx9uhHEpTB725/Kj8YpRCvrLhb20LeABFLw+0dkBkKUUAbDCY6CUUNzGQsJ94ji/p50wBPsRjIQXN1iOwZYA== +multistream@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/multistream/-/multistream-4.0.0.tgz#c771b6d17d169138b6abcb15f0061170e3c09cea" + integrity sha512-t0C8MAtH/d3Y+5nooEtUMWli92lVw9Jhx4uOhRl5GAwS5vc+YTmp/VXNJNsCBAMeEyK/6zhbk6x9JE3AiCvo4g== dependencies: - inherits "^2.0.1" readable-stream "^3.4.0" mute-stream@0.0.7: