Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make scaffolding cli package manager agnostic #316

Merged
merged 32 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1fa677e
add package manager module
c12i Jun 20, 2024
e8cb0d7
add test cases
c12i Jun 20, 2024
0b35b7a
add bun support
c12i Jun 20, 2024
29a8e71
refactor test filetree to resemble actual hApp filetree
c12i Jun 21, 2024
41235a8
Merge remote-tracking branch 'holochain/develop' into parameterize-pa…
c12i Jun 24, 2024
112ef47
update setup_git_environment
c12i Jun 24, 2024
042efc4
add package manager command handlebars helper
c12i Jun 24, 2024
183a4a1
add test cases for package_manager_command helper
c12i Jun 24, 2024
b4b55f6
use package_manager_command helper
c12i Jun 24, 2024
2bb5357
update ui package.json templates
c12i Jun 24, 2024
76f18e5
replace random port package
c12i Jun 24, 2024
d965cd4
set pnpm install command to recursive
c12i Jun 24, 2024
ba3fc74
add corepack_20 package to include required packages
c12i Jun 24, 2024
719fe12
fix test_run_with_pnpm test
c12i Jun 24, 2024
1ceec07
add bun to packages
c12i Jun 24, 2024
10236d7
add short version for package_manager flag
c12i Jun 24, 2024
5534a34
use pnpm on tests
c12i Jun 24, 2024
373c359
update hello world example ui script
c12i Jun 24, 2024
c6f0b76
update template readme
c12i Jun 25, 2024
b072c0e
revert to npm
c12i Jun 26, 2024
bce3f26
add mising version field in tests/package.json
c12i Jun 26, 2024
0002dbc
update rimraf
c12i Jun 26, 2024
d73db12
fix hello world template
c12i Jun 26, 2024
f6814e7
remove unnecessary depdencencies from vanilla template
c12i Jun 26, 2024
00027f0
add missing rimraf dependency
c12i Jun 26, 2024
b223585
add missing package_manager field to example hbs context data
c12i Jun 26, 2024
30490bd
add cli docs
c12i Jun 26, 2024
bb6d2f4
update lib.rs docs
c12i Jun 26, 2024
186b823
fix failing doc tests
c12i Jun 26, 2024
c877e5b
limit package manager option to specific commands that only need it
c12i Jun 27, 2024
85bb0ae
update docs
c12i Jun 27, 2024
f35501e
Merge remote-tracking branch 'holochain/develop' into parameterize-pa…
c12i Jun 28, 2024
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
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# Holochain Scaffolding CLI

CLI to easily generate and edit holochain apps.
A command-line interface for creating and modifying a Holochain application (hApp).
c12i marked this conversation as resolved.
Show resolved Hide resolved

```
USAGE:
hc-scaffold [OPTIONS] <SUBCOMMAND>

FLAGS:
-h, --help Prints help information
-V, --version Prints version information

OPTIONS:
-p, --package-manager <package-manager> The package manager to use for the hc-scaffold commands. Can be one of
the following: "bun", "npm", "pnpm", or "yarn". When a lockfile is
detected, the respective package manager will be used as the default
value; otherwise, npm will be set as the default [default: npm]
-t, --template <template> The template to use for the hc-scaffold commands Can either be an option
from the built-in templates: "vanilla", "vue", "lit", "svelte", "react",
"headless" Or a path to a custom template

SUBCOMMANDS:
collection Scaffold a collection of entries in an existing zome
dna Scaffold a DNA into an existing app
entry-type Scaffold an entry type and CRUD functions into an existing zome
example Scaffold an example hApp
help Prints this message or the help of the given subcommand(s)
link-type Scaffold a link type and its appropriate zome functions into an existing zome
template Manage custom templates
web-app Scaffold a new, empty web app
zome Scaffold one or multiple zomes into an existing DNA
```

See the full CLI reference [here](/guides/cli.md)

## Obtaining the scaffolding tool through holonix

Expand Down Expand Up @@ -43,7 +74,7 @@ hc scaffold collection global all_posts
hc scaffold link-type
```

## Documentation
## Custom Templates

See the [docs.rs documentation](https://docs.rs/holochain_scaffolding_cli) to learn how to use and create custom templates.

Expand Down
336 changes: 336 additions & 0 deletions guides/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
# Holochain Scaffolding CLI Documentation

## Overview

A command-line interface for creating and modifying a Holochain application (hApp).

## General Usage

```bash
hc-scaffold [OPTIONS] <SUBCOMMAND>
```

### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

### Options

- `-p`, `--package-manager <package-manager>`
The package manager to use for the `hc-scaffold` commands. Can be one of the following: "bun", "npm", "pnpm", or "yarn". When a lockfile is detected, the respective package manager will be used as the default value; otherwise, npm will be set as the default.
**Default:** `npm`

- `-t`, `--template <template>`
The template to use for the `hc-scaffold` commands. Can either be an option from the built-in templates: "vanilla", "vue", "lit", "svelte", "react", "headless" or a path to a custom template.

### Subcommands

- `collection`
Scaffold a collection of entries in an existing zome.

- `dna`
Scaffold a DNA into an existing app.

- `entry-type`
Scaffold an entry type and CRUD functions into an existing zome.

- `example`
Scaffold an example hApp.

- `help`
Prints this message or the help of the given subcommand(s).

- `link-type`
Scaffold a link type and its appropriate zome functions into an existing zome.

- `template`
Manage custom templates.

- `web-app`
Scaffold a new, empty web app.

- `zome`
Scaffold one or multiple zomes into an existing DNA.

## Subcommand Details

### `hc-scaffold collection`

Scaffold a collection of entries in an existing zome.

**Usage:**

```bash
hc-scaffold collection [FLAGS] [OPTIONS] [ARGS]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `--no-ui`
Skips UI generation for this collection.

- `-V`, `--version`
Prints version information.

#### Options

- `--dna <dna>`
Name of the DNA in which you want to scaffold the zome.

- `--zome <zome>`
Name of the integrity zome in which you want to scaffold the link type.

#### Arguments

- `<collection-type>`
Collection type: "global" or "by-author".

- `<collection-name>`
Collection name, just to differentiate it from other collections.

- `<entry-type>`
Entry type that is going to be added to the collection.

### `hc-scaffold dna`

Scaffold a DNA into an existing app.

**Usage:**

```bash
hc-scaffold dna [OPTIONS] [name]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

#### Options

- `--app <app>`
Name of the app in which you want to scaffold the DNA.

#### Arguments

- `<name>`
Name of the DNA being scaffolded.

### `hc-scaffold entry-type`

Scaffold an entry type and CRUD functions into an existing zome.

**Usage:**

```bash
hc-scaffold entry-type [FLAGS] [OPTIONS] [--] [name]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `--no-ui`
Skips UI generation for this entry-type, overriding any specified widgets in the `--fields` option.

**WARNING:** Opting out of UI generation for an entry type but not for other entry types, link types, or collections associated with it may result in potential UI inconsistencies. Specifically, UI elements intended for associated entry types, link types, or collections could inadvertently reference or expect elements from the skipped entry type.

If you choose to use this flag, consider applying it consistently across all entry-type, link-type, and collection scaffolds within your project to ensure UI consistency and avoid the outlined integration complications.

- `-V`, `--version`
Prints version information.

#### Options

- `--crud <crud>`
The Create, "Read", "Update", and "Delete" zome call functions that should be scaffolded for this entry type. If `--reference-entry-hash` is `true`, only "Create" and "Read" will be scaffolded.

- `--dna <dna>`
Name of the DNA in which you want to scaffold the zome.

- `--fields <fields>...`
The fields that the entry type struct should contain.
**Grammar:** `<FIELD_NAME>:<FIELD_TYPE>:<WIDGET>:<LINKED_FROM>`, (widget and linked_from are optional)
**Example:** `"title:String:TextField"`, `"posts_hashes:Vec\<ActionHash\>::Post"`

- `--link-from-original-to-each-update <link-from-original-to-each-update>`
Whether to create a link from the original entry to each update action. Only applies if update is selected in the `crud` argument.

- `--reference-entry-hash <reference-entry-hash>`
Whether this entry type should be referenced with its "EntryHash" or its "ActionHash". If referred to by "EntryHash", the entries can't be updated or deleted.

- `--zome <zome>`
Name of the integrity zome in which you want to scaffold the entry definition.

#### Arguments

- `<name>`
Name of the entry type being scaffolded.

### `hc-scaffold link-type`

Scaffold a link type and its appropriate zome functions into an existing zome.

**Usage:**

```bash
hc-scaffold link-type [FLAGS] [OPTIONS] [ARGS]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `--no-ui`
Skips UI generation for this link type.

- `-V`, `--version`
Prints version information.

#### Options

- `--bidirectional <bidirectional>`
Whether to create the inverse link, from the `--to-referenceable` entry type to the `--from-referenceable` entry type.

- `--delete <delete>`
Whether this link type can be deleted.

- `--dna <dna>`
Name of the DNA in which you want to scaffold the zome.

- `--zome <zome>`
Name of the integrity zome in which you want to scaffold the link type.

#### Arguments

- `<from-referenceable>`
Entry type (or agent role) used as the base for the links.

- `<to-referenceable>`
Entry type (or agent role) used as the target for the links.

### `hc-scaffold template`

Manage custom templates.

**Usage:**

```bash
hc-scaffold template <SUBCOMMAND>
```

#### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

#### Subcommands

- `clone`
Clone the template in use into a new custom template.

- `help`
Prints this message or the help of the given subcommand(s).

### `hc-scaffold template clone`

Clone the template in use into a new custom template.

**Usage:**
```
hc-scaffold template clone [OPTIONS]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

#### Options

- `--to-template <to-template>`
The folder to initialize the template into, will end up at `<TO TEMPLATE>`.

### `hc-scaffold web-app`

Scaffold a new, empty web app.

**Usage:**

```bash
hc-scaffold web-app [FLAGS] [ARGS]
```

#### Flags

- `-F`, `--disable-fast-track`
Whether to skip setting up an initial DNA and its zome(s) after the web app is scaffolded.

- `-h`, `--help`
Prints help information.

- `--setup-nix`
Whether to setup the holonix development environment for this web app.

- `-V`, `--version`
Prints version information.

#### Arguments

- `<name>`
Name of the app to scaffold.

- `<description>`
Description of the app to scaffold.

### hc-scaffold zome

Scaffold one or multiple zomes into an existing DNA.

**Usage:**

```bash
hc-scaffold zome [OPTIONS] [name]
```

#### Flags

- `-h`, `--help`
Prints help information.

- `-V`, `--version`
Prints version information.

#### Options

- `--coordinator <coordinator>`
Scaffold a coordinator zome at the given path.

- `--dna <dna>`
Name of the DNA in which you want to scaffold the zome.

- `--integrity <integrity>`
Scaffold an integrity zome at the given path.

#### Arguments

- `<name>`
Name of the zome being scaffolded.
Loading
Loading