Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e881958
ci: add linting, commit hooks, the pipelines and the contributor guides
Decipher Nov 18, 2026
742cf9d
feat: add drx init, drx info and create-druxt
Decipher Nov 18, 2026
99bf17e
feat(cli): add drx module list, search and info, and check a starter'…
Decipher Nov 18, 2026
1468883
ci: add the house changelog format, the release check and CodeQL
Decipher Nov 18, 2026
c3b427b
chore: merge the release tooling from the branch below
Decipher Nov 18, 2026
04bef0a
ci: add the release workflow
Decipher Nov 18, 2026
62eaead
chore: merge the release tooling from the branch below
Decipher Nov 18, 2026
9ea6953
ci: run on every pull request, and on a push to any release line
Decipher Nov 18, 2026
33905a8
ci: leave a review bot's summary out of the prose check of a description
Decipher Nov 18, 2026
d08b9a0
chore: merge the pipeline triggers and the prose check from the branc…
Decipher Nov 18, 2026
37c18cc
fix(cli): trim a registry URL's slashes in linear time
Decipher Nov 18, 2026
29518ae
chore: merge the pipeline triggers, the prose check and the slash tri…
Decipher Nov 18, 2026
a19985a
fix: tighten the attribution, prose and private-host checks
Decipher Nov 18, 2026
1ecea9c
chore: merge the fixes to the checks from the branch below
Decipher Nov 18, 2026
e77ce95
fix(cli): keep init to its own archive and quote the directory it prints
Decipher Nov 18, 2026
30c7c62
chore: merge the fixes to init and the checks from the branch below
Decipher Nov 18, 2026
1790c52
fix: read more as unpublishable in the release check, and lint a fork…
Decipher Nov 18, 2026
db979eb
chore: merge the fixes to the release check from the branch below
Decipher Nov 18, 2026
78c6d02
chore: merge the fixes to the release check from the branch below
Decipher Nov 18, 2026
0e39a58
fix(cli): leave the steps an install ran out of init's next steps
Decipher Nov 18, 2026
f72090c
chore: merge the install steps and the create-druxt heading from the …
Decipher Nov 18, 2026
815804e
fix(cli): report a backend module's core flag as unknown when the reg…
Decipher Nov 18, 2026
22e87d7
fix: keep a commit hook's git variables out of the test suite
Decipher Nov 18, 2026
3a31bac
chore: merge the test suite's git environment fix from the branch below
Decipher Nov 18, 2026
303b583
chore: merge the test suite's git environment fix from the branch below
Decipher Nov 18, 2026
2ce9ff5
fix(cli): check the names in a module registry by pattern as it is read
Decipher Nov 18, 2026
c6fe7f9
fix: read staged files and whole words in the attribution check
Decipher Nov 19, 2026
30b0137
chore: merge the attribution check's fixes from the branch below
Decipher Nov 19, 2026
280735b
chore: merge the attribution check's fixes from the branch below
Decipher Nov 19, 2026
76ea95c
fix(cli): print a hyphen-led directory as a path, and fall back on an…
Decipher Nov 19, 2026
804e8d7
chore: merge the cd line and config path fixes from the branch below
Decipher Nov 19, 2026
18b8677
feat: add drx init, drx info and create-druxt
Decipher Nov 18, 2026
4bd5c57
ci: add the release workflow
Decipher Nov 18, 2026
d3898ed
fix(cli): trim a registry URL's slashes in linear time
Decipher Nov 18, 2026
be7d2cf
fix(cli): keep init to its own archive and quote the directory it prints
Decipher Nov 18, 2026
a873b4e
fix(cli): leave the steps an install ran out of init's next steps
Decipher Nov 18, 2026
e3a08b4
fix(cli): print a hyphen-led directory as a path, and fall back on an…
Decipher Nov 19, 2026
135c018
docs: describe the packages' sources and commands in the contributor …
Decipher Nov 19, 2026
cc13373
chore: merge the branch below after its rebase onto the release line
Decipher Nov 19, 2026
65ba428
fix(cli): say which Node drx needs when it is started on an older one
Decipher Nov 19, 2026
e2dbae8
chore: merge the Node version check from the branch below
Decipher Nov 19, 2026
2650b19
feat(cli): run drx in a site that pins an older Node
Decipher Nov 19, 2026
300b2ac
chore: merge running on an older Node from the branch below
Decipher Nov 19, 2026
64c16aa
test(cli): keep the search for a newer Node off the machine's own ins…
Decipher Nov 19, 2026
9b2b271
chore: merge the test fix for the Node search from the branch below
Decipher Nov 19, 2026
9c9f41b
fix(cli): report a launcher failure as JSON, and look in FNM_DIR
Decipher Nov 19, 2026
89169f3
chore: merge the launcher review fixes from the branch below
Decipher Nov 19, 2026
9c0f766
fix: stop a release on a registry error, and match tool names on macOS
Decipher Nov 19, 2026
8deebdb
chore: merge the release lookup and attribution fixes from the branch…
Decipher Nov 19, 2026
8894c08
docs: say how to repair the latest tag after two releases collide
Decipher Nov 19, 2026
d4f7b69
chore: merge the release guide note from the branch below
Decipher Nov 19, 2026
750c1a1
docs: add the icon and the README banner
Decipher Nov 19, 2026
e3ecaea
chore: merge the icon and banner from the branch below
Decipher Nov 19, 2026
ef91fc0
chore: merge 0.x after the init and info commands were merged
Decipher Nov 19, 2026
f4245dd
fix(cli): read the bundled starters when the published registry is older
Decipher Nov 19, 2026
cf2e1d0
test(cli): read a served default registry without the bundled copy
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
3 changes: 2 additions & 1 deletion .changeset/first-release-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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.
- `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. It warns when the commands the starter needs 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 info` prints the versions of the CLI, Node and the packages of each part of a project.
- The registry holds one starter, `quickstart`, and the `monorepo` layout is the one available.
106 changes: 89 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,44 @@ Prints the versions of the CLI and Node. Inside a project it adds the layout and

Outside a project it says so and prints the two versions.

### `drx module list`

Lists the modules in the Druxt module registry: name, package, type, status and the Druxt versions each works with.

```text
Name Package Type Status Druxt
auth druxt-auth official stable unknown
blocks druxt-blocks official stable ^0.25.1
```

Inside a project it adds two columns for the frontend part:

| Column | What it shows |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Installed` | The installed version, `declared` when `package.json` asks for the package and it is not installed, or `no` |
| `Compatible` | `yes` or `no` when the module's range can be compared with the part's Druxt version, and `unknown` when the module states no range or the part has no Druxt |

The Druxt version compared is the one installed in the part, or the range the part asks for when none is installed. A module whose range is `unknown` or not stated is shown as `unknown`, never as compatible.

| Option | What it does |
| ------------------------- | --------------------------------------------------------------- |
| `--all` | Include archived modules |
| `--type <type>` | Only modules of this type, such as `official` or `contrib` |
| `--category <category>` | Only modules in this category |
| `--module-registry <url>` | A module registry: a URL, or a name from the user configuration |
| `--refresh` | Read the registry again even when the cached copy is fresh |
| `--json` | Print the result as JSON on stdout |

### `drx module search <text>`

The same table, for the modules whose name, package name or description contains the text. Case is ignored. It takes the options of `drx module list`.

### `drx module info <name>`

Shows one module, found by its registry name or its package name: the package, type, status, category, Druxt range, repository and website, and the backend modules it needs, with the ones that are part of Drupal core marked. When the registry marks no module as core, the text says so and `core` is `null` in the JSON. It is `false` only in a registry that marks the modules that are core. Inside a project it adds the installed version and the compatibility. It takes `--module-registry`, `--refresh` and `--json`.

A name that matches nothing exits with 1 and prints the closest names.

### `drx --help`, `drx <command> --help`, `drx --version`

Usage for the CLI or one command, and the version.
Expand Down Expand Up @@ -136,7 +174,8 @@ A registry is a URL that answers `/<name>.json` for each starter, in the format
],
"requires": {
"node": "16.18.1",
"tools": ["PHP 8.3 or newer with Composer, or DDEV"]
"tools": ["PHP 8.3 or newer with Composer, or DDEV"],
"commands": [["php", "composer"], ["ddev"]]
},
"maintained": "2026-11-15",
"default": true,
Expand All @@ -151,34 +190,63 @@ A registry is a URL that answers `/<name>.json` for each starter, in the format

`name`, `tar`, `defaultDir`, `url`, `subdir` and `headers` are giget's fields. giget ignores the `druxt` object, so the same file works with `GIGET_REGISTRY=<url> npx giget quickstart`.

| Key in `druxt` | What it holds |
| ---------------- | -------------------------------------------------------------------------- |
| `line` | The Druxt release line |
| `layout` | The layout the starter has |
| `parts` | The parts of the starter, as in the project configuration |
| `requires.node` | The Node version the site runs on: a full version, or a major such as `22` |
| `requires.tools` | What else the site needs, each as a phrase to show the user |
| `maintained` | The date the starter was last checked to work, as `YYYY-MM-DD` |
| `default` | `true` for the starter `init` uses when none is named |
| `steps` | Optional. The commands to run in the new site, in order |
| `install.runs` | Optional. The steps the install runs itself, left out of "Next" after one |
| `install.notes` | Optional. Lines printed under "Note" after an install |

`index.json` is `{ "starters": ["quickstart"] }`.
| Key in `druxt` | What it holds |
| ------------------- | -------------------------------------------------------------------------- |
| `line` | The Druxt release line |
| `layout` | The layout the starter has |
| `parts` | The parts of the starter, as in the project configuration |
| `requires.node` | The Node version the site runs on: a full version, or a major such as `22` |
| `requires.tools` | What else the site needs, each as a phrase to show the user |
| `requires.commands` | Optional. The commands the site needs on `PATH`, as a list of alternatives |
| `maintained` | The date the starter was last checked to work, as `YYYY-MM-DD` |
| `default` | `true` for the starter `init` uses when none is named |
| `steps` | Optional. The commands to run in the new site, in order |
| `install.runs` | Optional. The steps the install runs itself, left out of "Next" after one |
| `install.notes` | Optional. Lines printed under "Note" after an install |

`index.json` is `{ "revision": 1, "starters": ["quickstart"] }`. The revision is a whole number that goes up whenever the entries gain something a version of `drx` depends on. A `drx` whose bundled copy has a higher revision than the default registry reads the bundled copy, so a build made ahead of what is published keeps working.

`requires.commands` is a list of alternatives, and each alternative is a list of command names. The site can be set up when every command of one alternative is on `PATH`. `[["php", "composer"], ["ddev"]]` reads as `php` and `composer`, or `ddev`. A name is a bare command, and an entry with a path or arguments in one is rejected.

`init` looks each command up on `PATH` without running it. On Windows it tries the extensions in `PATHEXT`. When no alternative is complete it prints one warning naming the missing commands, and still creates the site:

```text
Warning: The quickstart starter needs php and composer, or ddev. Not found on PATH: php, composer, ddev. Install the commands of one alternative before you set up the site.
```

With `--json` the result has a `commands` object: `satisfied`, `alternatives`, `found` and `missing`. It is `null` for an entry with no `requires.commands`, which is not checked.

`init` checks an entry before it downloads anything, and fails with a message naming the field that is wrong. It warns when the starter was last maintained more than a year ago, and when the running Node is not the one the starter needs.

The package includes a copy of the public registry. When the public registry cannot be read, `init` uses the copy and says so. A registry you name with `--registry` is never replaced by the copy.

## The module registry

The module commands read `https://cdn.jsdelivr.net/gh/druxt/modules@main/modules.json`, which the [druxt/modules](https://github.com/druxt/modules) repository publishes. The CLI reads `schemaVersion` 1. It refuses any other version with a message saying so, and ignores fields it has no use for.

The names in an entry become arguments of a package manager or a backend tool, so each is checked as the registry is read. A package name has to be one npm takes, and the name of a Drupal module has to be a machine name. Anything else, such as a name that starts with a hyphen, makes the registry invalid, and the message names the entry and the field.

The registry is cached on disk:

- A copy under an hour old is used without a request. `--refresh` reads the registry anyway.
- An older copy is replaced by a new read.
- When the registry cannot be read, the copy is used whatever its age, and the command says so and how old it is.
- With no copy and no registry, the command fails.

The copy is kept in `~/.cache/drx`, or under `XDG_CACHE_HOME` when that is set. `DRX_CACHE_DIR` names another directory.

## The user configuration

`~/.config/drx/config.json` names registries and sources of your own. `DRX_CONFIG` points at another file, and `XDG_CONFIG_HOME` is used when it is set.
`~/.config/drx/config.json` names starter registries, module registries and sources of your own. `DRX_CONFIG` points at another file, and `XDG_CONFIG_HOME` is used when it is set.

```json
{
"registries": {
"team": "https://example.com/starters"
},
"moduleRegistries": {
"team": "https://example.com/modules.json"
},
"sources": {
"next": { "type": "npm", "tag": "next" },
"branch": { "type": "git", "url": "https://example.com/druxt.git", "ref": "main" }
Expand All @@ -187,14 +255,18 @@ The package includes a copy of the public registry. When the public registry can
```

- `--registry team` reads starters from that URL. `GIGET_AUTH` is giget's own variable, and giget sends it as a bearer token with every tarball it downloads. The CLI also sends it to a registry you name, and never to the public registry.
- `--module-registry team` reads modules from that URL, with `GIGET_AUTH` sent to it in the same way.
- `--source` takes `npm`, `git:<url>#<ref>`, or a name defined here. Only `npm` creates a site in this version. The others are read and answer that they are not available yet.

## Not there yet

- The `split` and `workspace` layouts. `--layout` accepts them and fails with a message.
- Sources other than `npm`.
- Adding a module, making a wrapper component and upgrading a site.
- `drx module add`, `drx module remove` and `drx module configure`. The commands exist and fail with a message.
- Making a wrapper component and upgrading a site.
- Kinds other than `nuxt` and `drupal`.
- A version check of the commands a starter needs. `init` checks that `php` is on `PATH`, not that it is 8.3 or newer.
- The same check in `drx info`. A project does not record what its starter requires, so `info` would have to read the registry again.
- A published public registry. Until this repository is public, `init` reads the copy in the package.

## Development
Expand Down
12 changes: 10 additions & 2 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@commitlint/config-conventional": "21.2.4",
"@eslint/js": "10.0.1",
"@types/node": "24.19.2",
"@types/semver": "7.8.0",
"@vitest/coverage-v8": "5.1.0",
"cspell": "10.5.1",
"eslint": "10.15.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ npx @druxt/cli info

The binary is `drx`. Install the package in a project to use that name: `npm install -D @druxt/cli`, then `drx <command>` in a package script. `npx drx` without the package installed downloads another package that holds the name on npm.

| Command | What it does |
| ---------------- | ------------------------------------------------------------------------- |
| `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 |
| Command | What it does |
| ----------------------------------- | ------------------------------------------------------------------------- |
| `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 |

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
Expand Up @@ -45,6 +45,7 @@
"@clack/prompts": "^1.9.0",
"c12": "^3.3.4",
"citty": "^0.2.2",
"giget": "^3.3.1"
"giget": "^3.3.1",
"semver": "^7.8.6"
}
}
24 changes: 24 additions & 0 deletions packages/cli/src/adapters/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export interface PackageVersion {
installed: string | null
}

/** A field that is not in the form it has to be, and what that form is. */
export interface FieldProblem {
/** The field, as a path from the value that was checked. */
field: string
/** What it must be, to follow the field's name in a message. */
must: string
}

/**
* Everything the CLI knows about one kind of part. The commands call this
* interface and never a kind by name, so a new kind is a new file in this
Expand All @@ -21,8 +29,24 @@ export interface KindAdapter {
readonly role: Role
/** True when the directory holds a part of this kind. */
detect(dir: string): Promise<boolean>
/**
* What is wrong with a module a registry lists for this kind, or undefined.
* 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
/** The packages `info` reports for a part of this kind. */
packages(dir: string): Promise<PackageVersion[]>
/**
* The Druxt package of the part: the range it asks for and the version
* installed. Undefined when the part has none, or its kind never holds one.
*/
druxt(dir: string): Promise<PackageVersion | undefined>
/**
* One package of the part by name, or undefined when the part neither
* 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>
}
Expand Down
20 changes: 20 additions & 0 deletions packages/cli/src/adapters/drupal-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { FieldProblem } from './adapter.js'

/** A module's machine name, as the backend itself defines one. */
const MACHINE_NAME = /^[a-z][a-z0-9_]*$/
const MACHINE_NAME_RULE =
'must be a machine name: lower-case letters, digits and underscores, starting with a letter'

/**
* What is wrong with a module the registry lists for this kind. Its name is
* handed to the backend's tools as an argument, so anything but a machine
* name is refused here: an option, a list, or a character a shell reads.
*/
export function moduleProblem(module: {
name: string
}): FieldProblem | undefined {
if (!MACHINE_NAME.test(module.name)) {
return { field: 'name', must: MACHINE_NAME_RULE }
}
return undefined
}
7 changes: 7 additions & 0 deletions packages/cli/src/adapters/drupal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type KindAdapter,
type PackageVersion,
} from './adapter.js'
import { moduleProblem } from './drupal-fields.js'
import { readJsonObject, stringMap } from './read-json.js'

/** Any of these in `require` makes a Composer project a Drupal site. */
Expand Down Expand Up @@ -44,6 +45,8 @@ export const drupalAdapter: KindAdapter = {
return CORE.some((name) => name in requires)
},

moduleProblem,

async packages(dir) {
const requires = await required(dir)
const versions = await installed(dir)
Expand All @@ -56,5 +59,9 @@ export const drupalAdapter: KindAdapter = {
)
},

// The Druxt packages a module registry lists are frontend packages.
druxt: async () => undefined,
package: async () => undefined,

addModule: addModuleNotAvailable,
}
8 changes: 8 additions & 0 deletions packages/cli/src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Role } from '../parts.js'
import type { KindAdapter } from './adapter.js'
import { drupalAdapter } from './drupal.js'
import { nuxtAdapter } from './nuxt.js'
Expand All @@ -14,3 +15,10 @@ export function adapterFor(kind: string): KindAdapter | undefined {
export function knownKinds(): string[] {
return ADAPTERS.map((adapter) => adapter.kind)
}

/** The kinds a part of the given role can be. */
export function kindsWithRole(role: Role): string[] {
return ADAPTERS.filter((adapter) => adapter.role === role).map(
(adapter) => adapter.kind
)
}
Loading
Loading