Skip to content

Commit

Permalink
Merge pull request #220 from mittwald/feature/ddev-support
Browse files Browse the repository at this point in the history
Add DDEV integration
  • Loading branch information
martin-helmich authored Feb 23, 2024
2 parents 4a56d83 + b1a5a6f commit 0408ce4
Show file tree
Hide file tree
Showing 31 changed files with 1,014 additions and 109 deletions.
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ USAGE
* [`mw database redis list`](#mw-database-redis-list)
* [`mw database redis shell DATABASE-ID`](#mw-database-redis-shell-database-id)
* [`mw database redis versions`](#mw-database-redis-versions)
* [`mw ddev init [INSTALLATION-ID]`](#mw-ddev-init-installation-id)
* [`mw ddev render-config [INSTALLATION-ID]`](#mw-ddev-render-config-installation-id)
* [`mw domain dnszone get DNSZONE-ID`](#mw-domain-dnszone-get-dnszone-id)
* [`mw domain dnszone list`](#mw-domain-dnszone-list)
* [`mw domain dnszone update DNSZONE-ID RECORD-SET`](#mw-domain-dnszone-update-dnszone-id-record-set)
Expand Down Expand Up @@ -2698,6 +2700,95 @@ FLAG DESCRIPTIONS
to persistently set a default project for all commands that accept this flag.
```

## `mw ddev init [INSTALLATION-ID]`

Initialize a new ddev project in the current directory.

```
USAGE
$ mw ddev init [INSTALLATION-ID] [-q] [--override-type <value>] [--project-name <value>]
[--override-mittwald-plugin <value>]
ARGUMENTS
INSTALLATION-ID ID or short ID of an app installation; this argument is optional if a default app installation is set
in the context
FLAGS
-q, --quiet suppress process output and only display a machine-readable summary.
--override-type=<value> [default: auto] Override the type of the generated DDEV configuration
--project-name=<value> DDEV project name
DEVELOPMENT FLAGS
--override-mittwald-plugin=<value> [default: mittwald/ddev] override the mittwald plugin
DESCRIPTION
Initialize a new ddev project in the current directory.
This command initializes a new ddev configuration for an existing app installation in the current directory.
More precisely, this command will do the following:
1. Create a new ddev configuration file in the .ddev directory, appropriate for the reference app installation
2. Initialize a new ddev project with the given configuration
3. Install the official mittwald DDEV addon
4. Add SSH credentials to the DDEV project
This command can be run repeatedly to update the DDEV configuration of the project.
Please note that this command requires DDEV to be installed on your system.
FLAG DESCRIPTIONS
-q, --quiet suppress process output and only display a machine-readable summary.
This flag controls if you want to see the process output or only a summary. When using mw non-interactively (e.g. in
scripts), you can use this flag to easily get the IDs of created resources for further processing.
--override-mittwald-plugin=<value> override the mittwald plugin
This flag allows you to override the mittwald plugin that should be installed by default; this is useful for testing
purposes
--override-type=<value> Override the type of the generated DDEV configuration
The type of the generated DDEV configuration; this can be any of the documented DDEV project types, or 'auto' (which
is also the default) for automatic discovery.
See https://ddev.readthedocs.io/en/latest/users/configuration/config/#type for more information
--project-name=<value> DDEV project name
The name of the DDEV project
```

## `mw ddev render-config [INSTALLATION-ID]`

Generate a DDEV configuration YAML file for the current app.

```
USAGE
$ mw ddev render-config [INSTALLATION-ID] [--override-type <value>]
ARGUMENTS
INSTALLATION-ID ID or short ID of an app installation; this argument is optional if a default app installation is set
in the context
FLAGS
--override-type=<value> [default: auto] Override the type of the generated DDEV configuration
DESCRIPTION
Generate a DDEV configuration YAML file for the current app.
This command initializes a new ddev configuration in the current directory.
FLAG DESCRIPTIONS
--override-type=<value> Override the type of the generated DDEV configuration
The type of the generated DDEV configuration; this can be any of the documented DDEV project types, or 'auto' (which
is also the default) for automatic discovery.
See https://ddev.readthedocs.io/en/latest/users/configuration/config/#type for more information
```

## `mw domain dnszone get DNSZONE-ID`

gets a specific zone
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"devDependencies": {
"@types/chalk": "^2.2.0",
"@types/copyfiles": "^2.4.1",
"@types/js-yaml": "^4.0.5",
"@types/js-yaml": "^4.0.9",
"@types/marked-terminal": "^3.1.3",
"@types/node": "^20.3.3",
"@types/node-notifier": "^8.0.2",
Expand Down Expand Up @@ -154,6 +154,9 @@
"database": {
"description": "Manage databases (like MySQL and Redis) in your projects"
},
"ddev": {
"description": "Integrate your mittwald projects with DDEV"
},
"domain": {
"description": "Manage domains, virtual hosts and DNS settings in your projects"
},
Expand Down
35 changes: 8 additions & 27 deletions src/commands/app/download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
import { Flags } from "@oclif/core";
import { Success } from "../../rendering/react/components/Success.js";
import { ReactNode } from "react";
import { spawn } from "child_process";
import { hasBinary } from "../../lib/hasbin.js";
import { getSSHConnectionForAppInstallation } from "../../lib/ssh/appinstall.js";
import { spawnInProcess } from "../../rendering/process/process_exec.js";
import { sshConnectionFlags } from "../../lib/ssh/flags.js";

export class Download extends ExecRenderBaseCommand<typeof Download, void> {
Expand Down Expand Up @@ -64,10 +64,6 @@ export class Download extends ExecRenderBaseCommand<typeof Download, void> {
}
});

const downloadStep = p.addStep(
"downloading app installation" + (dryRun ? " (dry-run)" : ""),
);

const rsyncOpts = [
"--archive",
"--recursive",
Expand All @@ -82,38 +78,23 @@ export class Download extends ExecRenderBaseCommand<typeof Download, void> {
rsyncOpts.push("--delete");
}

const child = spawn(
await spawnInProcess(
p,
"downloading app installation" + (dryRun ? " (dry-run)" : ""),
"rsync",
[...rsyncOpts, `${user}@${host}:${directory}/`, target],
{
shell: false,
},
);

child.stdout.on("data", (chunk) =>
downloadStep.appendOutput(chunk.toString()),
);
child.stderr.on("data", (chunk) =>
downloadStep.appendOutput(chunk.toString()),
);
child.on("exit", (code) => {
if (code === 0) {
downloadStep.complete();
} else {
downloadStep.error(new Error(`rsync exited with code ${code}`));
}
});

await downloadStep.wait();

if (dryRun) {
p.complete(
await p.complete(
<Success>
App would (probably) have successfully been downloaded. 🙂
</Success>,
);
} else {
p.complete(<Success>App successfully downloaded; have fun! 🚀</Success>);
await p.complete(
<Success>App successfully downloaded; have fun! 🚀</Success>,
);
}
}

Expand Down
15 changes: 10 additions & 5 deletions src/commands/app/install/drupal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AppInstaller,
} from "../../../lib/app/Installer.js";

const installer = new AppInstaller(
export const drupalInstaller = new AppInstaller(
"3d8a261a-3d6f-4e09-b68c-bfe90aece514",
"Drupal",
[
Expand All @@ -23,14 +23,19 @@ export default class InstallDrupal extends ExecRenderBaseCommand<
typeof InstallDrupal,
AppInstallationResult
> {
static description = installer.description;
static flags = installer.flags;
static description = drupalInstaller.description;
static flags = drupalInstaller.flags;

protected async exec(): Promise<{ appInstallationId: string }> {
return installer.exec(this.apiClient, this.args, this.flags, this.config);
return drupalInstaller.exec(
this.apiClient,
this.args,
this.flags,
this.config,
);
}

protected render(result: AppInstallationResult): React.ReactNode {
return installer.render(result, this.flags);
return drupalInstaller.render(result, this.flags);
}
}
15 changes: 10 additions & 5 deletions src/commands/app/install/shopware6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AppInstaller,
} from "../../../lib/app/Installer.js";

const installer = new AppInstaller(
export const shopware6Installer = new AppInstaller(
"12d54d05-7e55-4cf3-90c4-093516e0eaf8",
"Shopware 6",
[
Expand All @@ -28,14 +28,19 @@ export default class InstallShopware6 extends ExecRenderBaseCommand<
typeof InstallShopware6,
AppInstallationResult
> {
static description = installer.description;
static flags = installer.flags;
static description = shopware6Installer.description;
static flags = shopware6Installer.flags;

protected async exec(): Promise<{ appInstallationId: string }> {
return installer.exec(this.apiClient, this.args, this.flags, this.config);
return shopware6Installer.exec(
this.apiClient,
this.args,
this.flags,
this.config,
);
}

protected render(result: AppInstallationResult): React.ReactNode {
return installer.render(result, this.flags);
return shopware6Installer.render(result, this.flags);
}
}
15 changes: 10 additions & 5 deletions src/commands/app/install/typo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AppInstaller,
} from "../../../lib/app/Installer.js";

const installer = new AppInstaller(
export const typo3Installer = new AppInstaller(
"352971cc-b96a-4a26-8651-b08d7c8a7357",
"TYPO3",
[
Expand All @@ -24,14 +24,19 @@ export default class InstallTYPO3 extends ExecRenderBaseCommand<
typeof InstallTYPO3,
AppInstallationResult
> {
static description = installer.description;
static flags = installer.flags;
static description = typo3Installer.description;
static flags = typo3Installer.flags;

protected async exec(): Promise<{ appInstallationId: string }> {
return installer.exec(this.apiClient, this.args, this.flags, this.config);
return typo3Installer.exec(
this.apiClient,
this.args,
this.flags,
this.config,
);
}

protected render(result: AppInstallationResult): React.ReactNode {
return installer.render(result, this.flags);
return typo3Installer.render(result, this.flags);
}
}
15 changes: 10 additions & 5 deletions src/commands/app/install/wordpress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
AppInstaller,
} from "../../../lib/app/Installer.js";

const installer = new AppInstaller(
export const wordpressInstaller = new AppInstaller(
"da3aa3ae-4b6b-4398-a4a8-ee8def827876",
"WordPress",
[
Expand All @@ -23,14 +23,19 @@ export default class InstallWordPress extends ExecRenderBaseCommand<
typeof InstallWordPress,
AppInstallationResult
> {
static description = installer.description;
static flags = installer.flags;
static description = wordpressInstaller.description;
static flags = wordpressInstaller.flags;

protected async exec(): Promise<{ appInstallationId: string }> {
return installer.exec(this.apiClient, this.args, this.flags, this.config);
return wordpressInstaller.exec(
this.apiClient,
this.args,
this.flags,
this.config,
);
}

protected render(result: AppInstallationResult): React.ReactNode {
return installer.render(result, this.flags);
return wordpressInstaller.render(result, this.flags);
}
}
Loading

0 comments on commit 0408ce4

Please sign in to comment.