Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1b06408
feat(cli): add drx add and drx remove
Decipher Nov 18, 2026
5dc9b6a
chore: merge the release tooling from the branch below
Decipher Nov 18, 2026
4253a21
chore: merge the pipeline triggers, the prose check and the slash tri…
Decipher Nov 18, 2026
aa32224
chore: merge the fixes to init and the checks from the branch below
Decipher Nov 18, 2026
2f7f5fa
chore: merge the fixes to the release check from the branch below
Decipher Nov 18, 2026
4900ca9
chore: merge the fixes to init, module info and the unattended messag…
Decipher Nov 18, 2026
947919b
fix(cli): make drx remove undo only what drx add recorded
Decipher Nov 18, 2026
f0a3fa8
chore: merge the test suite's git environment fix from the branch below
Decipher Nov 18, 2026
8704963
chore: merge the name checks, forced init and group option fixes from…
Decipher Nov 18, 2026
7f2aa6b
fix(cli): keep files, records and tool arguments true when adding and…
Decipher Nov 18, 2026
4151ffe
chore: merge the options before a command fix from the branch below
Decipher Nov 18, 2026
6788e69
fix(cli): decide what add and remove do from the site, never from one…
Decipher Nov 19, 2026
4cdb791
chore: merge the attribution check's fixes from the branch below
Decipher Nov 19, 2026
1cdcbcb
chore: merge the cd line and config path fixes from the branch below
Decipher Nov 19, 2026
88844b3
chore: merge the branch below after its rebase onto the release line
Decipher Nov 19, 2026
6ddb35e
chore: merge the quieter install and the setup check from the branch …
Decipher Nov 19, 2026
8eec893
chore: merge the site's own project name from the branch below
Decipher Nov 19, 2026
6083656
chore: merge the notes for an existing backend from the branch below
Decipher Nov 19, 2026
9f22b45
chore: merge the one-pass project name from the branch below
Decipher Nov 19, 2026
b8dd9e2
chore: merge the Node version check from the branch below
Decipher Nov 19, 2026
7193075
chore: merge running on an older Node from the branch below
Decipher Nov 19, 2026
0c6210c
chore: merge the test fix for the Node search from the branch below
Decipher Nov 19, 2026
da9091c
chore: merge the menu wording from the branch below
Decipher Nov 19, 2026
e2bcf1e
chore: merge the launcher review fixes from the branch below
Decipher Nov 19, 2026
a758451
chore: merge the release lookup and attribution fixes from the branch…
Decipher Nov 19, 2026
2a39780
chore: merge the release guide note from the branch below
Decipher Nov 19, 2026
ae95600
chore: merge the icon and banner from the branch below
Decipher Nov 19, 2026
a6eca04
chore: merge 0.x from the branch below
Decipher Nov 19, 2026
89c57cd
chore: merge the registry revision from the branch below
Decipher Nov 19, 2026
60317fc
chore: merge the registry test helper from the branch below
Decipher Nov 19, 2026
452130f
chore: merge the engine note from the branch below
Decipher Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changeset/first-release-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ First release of the Druxt command-line tool, with the binary `drx`.

- `drx init` creates a site from a starter in a registry, records its layout and parts in `drx.config.json` and prints what the site needs next. `--engine` chooses how the backend runs, from the engines the starter lists or `none` for a backend that exists already. `init` keeps that engine's files only and warns when its commands are not on `PATH`.
- `drx module list`, `drx module search` and `drx module info` read the Druxt module registry, and in a project show what is installed and whether each module's range admits the Druxt there.
- `drx add` installs a module and lists it in the Nuxt config. It also requires and enables the Drupal modules the module needs, through the backend's engine. `drx remove` takes it out again. Both take `--dry-run`.
- `drx info` prints the versions of the CLI, Node and the packages of each part of a project.
- At a terminal, bare `drx` opens a menu and `drx init` is a guided run that asks before it writes. `--no-interactive`, `DRX_NO_INTERACTIVE=1`, `CI` or no terminal turn every prompt off.
- The registry holds one starter, `quickstart`, and the `monorepo` layout is the one available.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"**/CHANGELOG.md",
"package-lock.json",
".vale/",
"packages/cli/starters/"
"packages/cli/starters/",
"packages/cli/test/fixtures/"
],
"useGitignore": true
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ CHANGELOG.md
.vale/
packages/cli/starters/

# Copies of real files, kept byte for byte so an edit to one can be compared.
packages/cli/test/fixtures/

# Pipeline definitions are owned by yamllint, not prettier. The two disagree on
# comment spacing, and letting both format these files means each run of one
# undoes the other.
Expand Down
144 changes: 139 additions & 5 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default tseslint.config(
'reports/**',
'.vale/**',
'packages/cli/starters/**',
'packages/cli/test/fixtures/**',
],
},
js.configs.recommended,
Expand Down
2 changes: 2 additions & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"$schema": "https://unpkg.com/knip@6/schema.json",
// Copies of real files from other projects, with those projects' imports.
"ignore": ["packages/cli/test/fixtures/**"],
"workspaces": {
".": {
"entry": ["scripts/*.mjs", "test/**/*.test.ts"],
Expand Down
7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The binary is `drx`. Install the package in a project to use that name: `npm ins
| `drx init [dir]` | Creates a site from a starter and records its layout in `drx.config.json` |
| `drx info` | Prints the versions of the CLI, Node and the packages of each part |
| `drx module list`, `search`, `info` | Lists, searches and shows the modules in the Druxt module registry |
| `drx add`, `drx remove` | Adds a module to the frontend and backend of a project, or removes it |

The options, the registry format and the configuration files are in the [repository README](https://github.com/druxt/cli#readme).

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@druxt/cli",
"version": "0.0.0",
"description": "The Druxt command-line tool: create a site from a starter and report on it.",
"description": "Command-line tool for Druxt: create a site, add modules and manage a decoupled Drupal project.",
"keywords": [
"druxt",
"cli"
Expand Down Expand Up @@ -46,6 +46,7 @@
"c12": "^3.3.4",
"citty": "^0.2.2",
"giget": "^3.3.1",
"magicast": "^0.5.5",
"semver": "^7.8.6"
}
}
192 changes: 185 additions & 7 deletions packages/cli/src/adapters/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DrxError } from '../errors.js'
import type { ToolResult } from '../exec.js'
import type { BackendModule } from '../modules/entry.js'
import type { Role } from '../parts.js'

/** One package a part depends on. */
Expand Down Expand Up @@ -34,7 +35,13 @@ export interface KindAdapter {
* The values of one reach the tools of the part as arguments, so each is
* checked by its pattern where it is read, before any command is built.
*/
moduleProblem?(module: { name: string }): FieldProblem | undefined
moduleProblem?(module: BackendModule): FieldProblem | undefined
/**
* What is wrong with a record of what was done to a part of this kind, or
* undefined. A record is read from a file anybody may have written, and
* its values reach the same tools, so it is checked in the same way.
*/
recordProblem?(record: BackendRecord): FieldProblem | undefined
/** The packages `info` reports for a part of this kind. */
packages(dir: string): Promise<PackageVersion[]>
/**
Expand All @@ -47,11 +54,182 @@ export interface KindAdapter {
* asks for it nor has it installed.
*/
package(dir: string, name: string): Promise<PackageVersion | undefined>
/** Installs a module into the part and registers it. Not available yet. */
addModule(dir: string, name: string): Promise<void>
/**
* What adding a module to the part takes. Nothing is run or written here:
* the command prints the steps, and runs them unless it is a dry run.
*/
addModule(dir: string, request: AddRequest): Promise<ModuleChange>
/** What taking a module out of the part takes. */
removeModule(dir: string, request: RemoveRequest): Promise<ModuleChange>
}

/** A tool to run in the part, by the name the part's engine knows it by. */
export interface ToolRun {
tool: string
args: string[]
}

/**
* Asks a part something by running one of its tools, with arguments that
* change nothing. It is how a plan finds out what the part has now.
*/
export type Ask = (tool: string, args: string[]) => Promise<ToolResult>

/**
* A change to a file of the part. The new content is worked out from the
* file as it is when the step is taken, never from a copy read while
* planning: a tool or another module may have written to it in between.
*/
export interface FileEdit {
/** Relative to the part. */
file: string
/**
* The content to write, given the content the file has now. It throws,
* with the reason, when the file no longer takes the change.
*/
change(source: string): string
/** What the edit does, as one line. */
summary: string
}

/**
* A file of the part to delete. Whether it goes is worked out from the file
* as it is when the step is taken, and a file that is not there is left out.
*/
export interface FileRemoval {
/** Relative to the part. */
file: string
/** True when the file, with the content it has now, is to go. */
when(source: string): boolean
/** What the step does, as one line. */
summary: string
}

/**
* One step of a change. For an add it carries what it will have done once
* it is taken, so the record can say what was done when a later step fails.
*/
export type ChangeStep = (
{ run: ToolRun } | { edit: FileEdit } | { remove: FileRemoval }
) & {
/** What the step does about the package of the module. */
did?: Partial<PackageRecord>
/** What the step does to a backend part. */
record?: BackendRecord
}

/** What a module needs of a part. A kind reads the fields that apply to it. */
export interface AddRequest {
/** The frontend package of the module. */
package?: string
/**
* The root of the project the part is in. A part looks from there down to
* itself for what the whole project declares, such as its package manager.
*/
root?: string
/** The backend modules it needs, of this part's kind. */
needs: BackendModule[]
/** False to leave the patches of those modules out. */
patches: boolean
/** True when the registry marks core modules, so one not marked is not core. */
registryStatesCore: boolean
/**
* Asks the part what it has. Undefined when the part is not run from this
* machine, so nothing in it can be looked at or changed from here.
*/
ask?: Ask
}

export interface RemoveRequest {
package?: string
/** The root of the project the part is in. */
root?: string
/**
* What an earlier add did to the package in this part. Undefined when the
* record does not say, as one written by an older version does not.
*/
did?: PackageRecord
/** What an earlier add did to this backend part, and is to be undone. */
record?: BackendRecord
ask?: Ask
}

/** What an add did about the package of a module in a frontend part. */
export interface PackageRecord {
/** True when it installed the package, false when the part had it. */
installed: boolean
/** True when it listed the package in the config, false when it was there. */
listed: boolean
/**
* True when it could not write to the config, and left the line that lists
* the package to the user. Nothing then says whether the line is there.
*/
byHand?: boolean
}

/** What an add did to a backend part, kept so a remove undoes that and no more. */
export interface BackendRecord {
modules: {
name: string
/** The package that provides it. A module of core has none. */
package?: string
/** True when the add enabled it, false when it was enabled already. */
enabled: boolean
/** True when the add put its requirement in the manifest. */
required: boolean
}[]
/** The patches it wrote, each with the module it was for. */
patches: {
package: string
description: string
url: string
/** Absent in a record written before the module was kept. */
module?: string
}[]
/**
* What the add put in the part for its patches to be applied with, when
* the part did not have it: `required` for the requirement on the tool that
* applies them, `allowed` for the permission that lets the tool run. Absent
* when the part had both. They go with the last patch of the part.
*/
patcher?: { required: boolean; allowed: boolean }
}

/** The steps of a change to one part, in the order to take them. */
export interface ModuleChange {
steps: ChangeStep[]
/** Reasons the change cannot be made. With any, no step is taken. */
problems: string[]
warnings: string[]
/** What was found that needs no step. */
notes: string[]
/** What the user has to do by hand, because the tool could not. */
manual: string[]
/** What is left to do once the change is made. */
after: string[]
/** For an add, what the steps do to the package of the module. */
did?: PackageRecord
/**
* For an add, what the steps do to a backend part. For a remove, what
* they leave in it, which stays on the project's record.
*/
record?: BackendRecord
/**
* For an add, asks the part what the steps did once they have run, or
* once one of them has failed. It is given the record of the steps that
* were taken, and returns the record to keep. A backend may enable more
* than it was asked to, or less, and only then can that be seen.
*/
settle?: (done: BackendRecord) => Promise<BackendRecord>
}

/** The `addModule` of every adapter until the `add` command exists. */
export async function addModuleNotAvailable(): Promise<never> {
throw new DrxError('not-available', 'Adding a module is not available yet.')
export function emptyChange(): ModuleChange {
return {
steps: [],
problems: [],
warnings: [],
notes: [],
manual: [],
after: [],
}
}
Loading
Loading