Skip to content

Commit

Permalink
Added documentation for the new API
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugos68 committed Sep 25, 2023
1 parent bee2a49 commit e4a07e2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 4 additions & 12 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)}"`,
Expand Down
1 change: 0 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type ProjectOptions = {
appId: string;
platforms: Platform[];
plugins: Plugin[];
packageManager: PackageManager;
};

export type Platform = 'Android' | 'iOS';
Expand Down

0 comments on commit e4a07e2

Please sign in to comment.