Skip to content

Commit

Permalink
Merge pull request #1103 from nxext/crystal-ionic-capacitor
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPieper authored Sep 27, 2024
2 parents 7c6c031 + 81c9f77 commit 89e3117
Show file tree
Hide file tree
Showing 136 changed files with 6,318 additions and 8,830 deletions.
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
/build

/.nx/cache
/.nx/workspace-data
/.nx/workspace-data

pnpm-lock.yaml
19 changes: 19 additions & 0 deletions docs/docs/capacitor/executors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## @nxext/capacitor:cap

Run a Capacitor command

Options can be configured in the 'project.json' when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/configuration/projectjson#targets.

### Options

#### cmd

Type: `string`

The Capacitor command.

#### preserveProjectNodeModules

Type: `boolean`

Preserve the node_modules folder inside the project dir.
61 changes: 61 additions & 0 deletions docs/docs/capacitor/generators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## @nxext/capacitor:configuration

Configure Capacitor for an Nx project

### Usage

```bash
nx generate configuration ...
```

By default, Nx will search for `configuration` in the default collection provisioned in nx.json.

You can specify the collection explicitly as follows:

```bash
nx g @nxext/capacitor:configuration ...
```

Show what will be generated without writing to disk:

```bash
nx g configuration ... --dry-run
```

### Options

#### project (_**required**_)

Alias(es): p

Type: `string`

The name of the frontend project for Capacitor.

#### appId

Default: `io.ionic.starter`

Type: `string`

The app ID for the project.

#### appName

Type: `string`

The application name for the project.

#### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files.

#### webDir

Type: `string`

The directory of your projects built web assets.
Empty file.
47 changes: 47 additions & 0 deletions docs/docs/ionic-angular/generators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## @nxext/ionic-angular:configuration

Configure Ionic for an Angular application.

### Usage

```bash
nx generate configuration ...
```

By default, Nx will search for `configuration` in the default collection provisioned in nx.json.

You can specify the collection explicitly as follows:

```bash
nx g @nxext/ionic-angular:configuration ...
```

Show what will be generated without writing to disk:

```bash
nx g configuration ... --dry-run
```

### Options

#### project (_**required**_)

Type: `string`

The name of the project.

#### capacitor

Default: `true`

Type: `boolean`

Generate a Capacitor project.

#### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files.
Empty file.
47 changes: 47 additions & 0 deletions docs/docs/ionic-react/generators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## @nxext/ionic-react:configuration

Configure Ionic for a React application.

### Usage

```bash
nx generate configuration ...
```

By default, Nx will search for `configuration` in the default collection provisioned in nx.json.

You can specify the collection explicitly as follows:

```bash
nx g @nxext/ionic-react:configuration ...
```

Show what will be generated without writing to disk:

```bash
nx g configuration ... --dry-run
```

### Options

#### project (_**required**_)

Type: `string`

The name of the project.

#### capacitor

Default: `true`

Type: `boolean`

Generate a Capacitor project.

#### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files.
1 change: 1 addition & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ module.exports = {
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: { escapeString: true, printBasicPrototype: true },
setupFiles: ['<rootDir>/../../tools/scripts/mock-project-graph.ts'],
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"fs-extra": "^10.1.0",
"globrex": "^0.1.2",
"husky": "^8.0.0",
"ignore": "^5.2.4",
"ignore": "^5.3.1",
"is-ci": "^3.0.1",
"jest": "^29.0.0",
"jest-environment-jsdom": "29.5.0",
Expand Down Expand Up @@ -141,5 +141,6 @@
},
"nx": {
"includedScripts": []
}
},
"packageManager": "pnpm@9.1.1+sha512.14e915759c11f77eac07faba4d019c193ec8637229e62ec99eefb7cf3c3b75c64447882b7c485142451ee3a6b408059cdfb7b7fa0341b975f12d0f7629c71195"
}
89 changes: 89 additions & 0 deletions packages/capacitor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Changelog

# 13.0.0

## Features

- support Nx 13

# 12.1.0

## Features

- restore Angular CLI support

# 12.0.0

## Features

- support Nx 12
- plugin rewritten with `@nx/devkit` for better maintainability and future proofing for future Nx versions
- update Capacitor to 3.2.5
- add Capacitor `run` target (requires Capacitor 3)

## BREAKING CHANGES

- Angular CLI is no longer officially supported
- `add-plugin` schematic has been removed
- the `init` generator has been removed and the functionaltiy has been moved to the `application` schematic

# 11.1.1

## Bug Fixes

- support Nx 11.3.0

# 11.1.0

## Features

- support quotes in `cap` builder `cmd` option (useful for passing additional options for Capacitor commands)

# 11.0.2

## Bug Fixes

- support `angular.json` as well as `workspace.json` during migrations

# 11.0.1

## Bug Fixes

- fix 11.0.0 workspace migration

# 11.0.0

## Features

- Nx 11 support (Nx 11 now required)
- update Capacitor to 2.4.5
- added `cap` builder for a more generic interface with the Capacitor CLI

## BREAKING CHANGES

- the `command` builder has been removed

# 2.0.2

# Fixes

- fix Windows support

# Features

- update Capacitor to 2.4.2
- add Capacitor configs to frontend application
- add or update `package.json` in project folder when generating a Capacitor project
- add builder configurations for Nx Console
- add `add-plugin` schematic for adding Capacitor plugins

# BREAKING CHANGES

- Capacitor plugins must now be added to both the root and project-level `package.json`

# 1.1.0

## Features

- upgrade Capacitor to 2.4.0
- copy package.json from workspace root for cap commands
32 changes: 32 additions & 0 deletions packages/capacitor/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Migration

# 1.x.x - 2.0.0

## Move Capacitor Configs

With `@nxext/capacitor` 2.0+, Capacitor configurations will be added to the associated frontend project instead of creating a dedicated Capacitor project. Migrating to this new paradigm is trivial and takes just a few steps.

First, add a new set of Capacitor configs to your frontend project.

```
nx g @nxext/capacitor:capacitor-project --project my-app
```

Move `capacitor.config.json` from the Capacitor project to the root of the associated frontend project. You will have to overwrite the `capacitor.config.json` that was just generated.

Move all platform folders (`android`, `ios`, `electron`) from the Capacitor project to the root of the frontend project.

You should now test the Capacitor commands for the frontend project and ensure the project works as expected.

```
nx run my-app:sync --platform ios
nx run my-app:open --platform ios
```

If everything works as expected then you can safely remove the Capacitor project.

```
nx g @nx/workspace:remove my-app
```

The `@capacitor/cli` dependency in the root `package.json` is also no longer needed and can be removed.
11 changes: 11 additions & 0 deletions packages/capacitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# capacitor

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build capacitor` to build the library.

## Running unit tests

Run `nx test capacitor` to execute the unit tests via [Jest](https://jestjs.io).
39 changes: 39 additions & 0 deletions packages/capacitor/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { FlatCompat } = require('@eslint/eslintrc');
const baseConfig = require('../../eslint.config.js');
const js = require('@eslint/js');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
module.exports = [
...baseConfig,
{
files: [
'packages/capacitor/**/*.ts',
'packages/capacitor/**/*.tsx',
'packages/capacitor/**/*.js',
'packages/capacitor/**/*.jsx',
],
rules: {},
},
{
files: ['packages/capacitor/**/*.ts', 'packages/capacitor/**/*.tsx'],
rules: {},
},
{
files: ['packages/capacitor/**/*.js', 'packages/capacitor/**/*.jsx'],
rules: {},
},
...compat.config({ parser: 'jsonc-eslint-parser' }).map((config) => ({
...config,
files: [
'packages/capacitor/package.json',
'packages/capacitor/generators.json',
'packages/capacitor/executors.json',
'packages/capacitor/generators.json',
'packages/capacitor/executors.json',
'packages/capacitor/migrations.json',
],
rules: { '@nx/nx-plugin-checks': 'error' },
})),
];
Loading

0 comments on commit 89e3117

Please sign in to comment.