diff --git a/README.md b/README.md index a84df6f..f885a6d 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,23 @@ bun: bunx build ``` +### API + +CapKit also exposes an API to allow you to use it programmatically. This can be useful if you want to integrate CapKit into your own tooling or if you want to extend CapKit's functionality, you can use it like this: + +```ts +import { initializeProject, type Options } from 'capkit'; + +const options: Options = { + appName: 'My App', + appId: 'com.myapp', + platforms: ['android', 'ios'], + plugins: ['clipboard', 'push-notifications'] // See a full list of plugins here: https://capacitorjs.com/docs/apis +}; + +initializeProject(options); +``` + --- ## Capacitor diff --git a/src/commands/init.ts b/src/commands/init.ts index 83459a8..ede73ac 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -126,30 +126,22 @@ async function promptOptions() { })) as Plugin[]; } - const packageManager = getPM(); - const options = { appName, appId, platforms, - plugins, - packageManager + plugins } as ProjectOptions; return options; } -export async function initializeProject({ - appName, - appId, - platforms, - plugins, - packageManager -}: ProjectOptions) { +export async function initializeProject({ appName, appId, platforms, plugins }: ProjectOptions) { + const extension = getConfigExtension(); + const packageManager = getPM(); const jobs: Job[] = []; /* Configuration jobs */ - const extension = getConfigExtension(); if (extension) { jobs.push({ start: `Removing existing config: "${kleur.cyan(`capacitor.config.${extension}`)}"`, diff --git a/src/types/types.ts b/src/types/types.ts index 9dff6db..9e7560f 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -9,7 +9,6 @@ export type ProjectOptions = { appId: string; platforms: Platform[]; plugins: Plugin[]; - packageManager: PackageManager; }; export type Platform = 'Android' | 'iOS';