Skip to content

Commit

Permalink
chore(cli): Register enterprise-specific platforms (#4960)
Browse files Browse the repository at this point in the history
* Register enterprise-specific platforms

Track @ionic-enterprise platforms in the CLI
  • Loading branch information
mlynch authored Aug 30, 2021
1 parent 17a73ff commit 4f35202
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ export async function isValidCommunityPlatform(
return (await getKnownCommunityPlatforms()).includes(platform);
}

export async function getKnownEnterprisePlatforms(): Promise<string[]> {
return ['windows'];
}

export async function isValidEnterprisePlatform(
platform: string,
): Promise<boolean> {
return (await getKnownEnterprisePlatforms()).includes(platform);
}

export async function promptForPlatform(
platforms: string[],
promptMessage: string,
Expand Down Expand Up @@ -502,6 +512,16 @@ export function resolvePlatform(
if (community) {
return dirname(community);
}

const enterprise = resolveNode(
config.app.rootDir,
`@ionic-enterprise/capacitor-${platform}`,
'package.json',
);

if (enterprise) {
return dirname(enterprise);
}
}

// third-party
Expand Down
7 changes: 7 additions & 0 deletions cli/src/tasks/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isValidCommunityPlatform,
promptForPlatform,
getProjectPlatformDirectory,
isValidEnterprisePlatform,
} from '../common';
import type { CheckFunction } from '../common';
import type { Config } from '../definitions';
Expand Down Expand Up @@ -55,6 +56,12 @@ export async function addCommand(
)} and adding the platform again.`;
}

if (await isValidEnterprisePlatform(selectedPlatformName)) {
msg +=
`\nThis is an enterprise platform and @ionic-enterprise/capacitor-${selectedPlatformName} is not installed.\n` +
`To learn how to use this platform, visit https://ionic.io/docs/${selectedPlatformName}`;
}

logger.error(msg);
}
} else {
Expand Down

0 comments on commit 4f35202

Please sign in to comment.