Skip to content

Commit 167a68c

Browse files
committed
fix(cordova): use allowlist for supported project types
1 parent 36edd3c commit 167a68c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • packages/ionic/src/lib/integrations/cordova

packages/ionic/src/lib/integrations/cordova/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import * as os from 'os';
66
import * as path from 'path';
77

88
import { BaseIntegration, IntegrationConfig } from '../';
9-
import { InfoItem, IntegrationAddDetails, IntegrationAddHandlers, IntegrationName, ProjectIntegration, ProjectPersonalizationDetails } from '../../../definitions';
9+
import { InfoItem, IntegrationAddDetails, IntegrationAddHandlers, IntegrationName, ProjectIntegration, ProjectPersonalizationDetails, ProjectType } from '../../../definitions';
1010
import { FatalException } from '../../../lib/errors';
1111
import { ancillary, input, strong } from '../../color';
1212

1313
const debug = Debug('ionic:lib:integrations:cordova');
1414

1515
export class Integration extends BaseIntegration<ProjectIntegration> {
16+
readonly SUPPORTED_PROJECT_TYPES: readonly ProjectType[] = ['custom', 'ionic1', 'ionic-angular', 'angular'];
17+
1618
readonly name: IntegrationName = 'cordova';
1719
readonly summary = 'Target native iOS and Android with Apache Cordova';
1820
readonly archiveUrl = 'https://d2ql0qc7j8u4b2.cloudfront.net/integration-cordova.tar.gz';
@@ -22,12 +24,10 @@ export class Integration extends BaseIntegration<ProjectIntegration> {
2224
}
2325

2426
async add(details: IntegrationAddDetails): Promise<void> {
25-
if (this.e.project.type === 'vue' || this.e.project.type === 'react') {
26-
throw new FatalException(
27-
`Cordova is not supported for ${this.e.project.type} projects\n\n` +
28-
`See ${strong(`https://ionicframework.com/docs/${this.e.project.type}/overview`)} for detailed information.\n`
29-
);
27+
if (!this.SUPPORTED_PROJECT_TYPES.includes(this.e.project.type)) {
28+
throw new FatalException(`Cordova is not supported for ${this.e.project.type} projects`);
3029
}
30+
3131
const handlers: IntegrationAddHandlers = {
3232
conflictHandler: async (f, stats) => {
3333
const isDirectory = stats.isDirectory();

0 commit comments

Comments
 (0)