Skip to content

Commit

Permalink
docs: add tooth.json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Jan 4, 2025
1 parent ba52ee4 commit d0db3ca
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 82 deletions.
210 changes: 132 additions & 78 deletions docs/schemas/tooth.v3.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"type": "integer",
"const": 3
},
"format_uuid": {
"type": "string",
"const": "289f771f-2c9a-4d73-9f3f-8492495a924d"
},
"tooth": {
"type": "string"
},
Expand All @@ -21,6 +25,9 @@
"description": {
"type": "string"
},
"author": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
Expand All @@ -32,114 +39,161 @@
"type": "string"
}
}
}
},
"patternProperties": {
"^([a-z0-9]+|\\*)\\/([a-z0-9]+|\\*)$": {
"type": "object",
"properties": {
"commands": {
"type": "object",
"properties": {
"pre_install": {
"type": "array",
"items": {
"type": "string"
}
},
"post_install": {
"type": "array",
"items": {
"type": "string"
}
},
"pre_uninstall": {
"type": "array",
"items": {
},
"variants": {
"type": "array",
"items": {
"type": "object",
"properties": {
"platform": {
"type": "string"
},
"dependencies": {
"type": "object",
"patternProperties": {
"^.*$": {
"type": "string"
}
},
"post_uninstall": {
"type": "array",
"items": {
}
},
"prerequisites": {
"type": "object",
"patternProperties": {
"^.*$": {
"type": "string"
}
}
}
},
"dependencies": {
"type": "object",
"patternProperties": {
"^.*$": {
"type": "string"
}
}
},
"prerequisites": {
"type": "object",
"patternProperties": {
"^.*$": {
"type": "string"
},
"assets": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"self",
"uncompressed",
"tar",
"tar.gz",
"zip"
]
},
"urls": {
"type": "array",
"items": {
"type": "string"
}
},
"place": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"file",
"dir"
]
},
"src": {
"type": "string"
},
"dest": {
"type": "string"
}
},
"required": [
"type",
"src",
"dest"
]
}
},
"preserve": {
"type": "array",
"items": {
"type": "string"
}
},
"remove": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"type"
]
}
}
},
"assets": {
"type": "array",
"items": {
},
"scripts": {
"type": "object",
"properties": {
"download_urls": {
"pre_install": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"type": "string",
"enum": [
"uncompressed",
"tar",
"tar.gz",
"zip"
]
"install": {
"type": "array",
"items": {
"type": "string"
}
},
"place": {
"post_install": {
"type": "array",
"items": {
"type": "object",
"properties": {
"src": {
"type": "string"
},
"dest": {
"type": "string"
}
},
"required": [
"src",
"dest"
]
"type": "string"
}
},
"pre_pack": {
"type": "array",
"items": {
"type": "string"
}
},
"post_pack": {
"type": "array",
"items": {
"type": "string"
}
},
"pre_uninstall": {
"type": "array",
"items": {
"type": "string"
}
},
"preserve": {
"uninstall": {
"type": "array",
"items": {
"type": "string"
}
},
"remove": {
"post_uninstall": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"download_urls",
"type"
]
"patternProperties": {
"^[a-z0-9]+(-[a-z0-9]+)*$": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
},
"required": [
"platform"
]
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/commands/lip-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lip cache list

Inspect and manage lip’s cache.

lip stores cache data in `%LocalAppData%\lip-cache` for Windows and `~/.cache/lip` for POSIX-like systems by default. This can be configured by configuration item `cache.dir`.
lip stores cache data in `%LocalAppData%\lip-cache` for Windows and `~/.cache/lip` for POSIX-like systems by default.

## Sub-commands

Expand All @@ -24,7 +24,7 @@ lip cache add <package-spec>

Add a package to the cache. `<package-spec>` is a [package specifier](#), e.g. `github.com/futrime/example-package#subpack@1.0.0`.

If the configuration item `download.goproxy` is set, lip will download the package via Goproxy. Otherwise, lip will download the package directly from the Git repository.
If a Go module proxy is set in configuration, lip will download the package via Goproxy. Otherwise, lip will download the package directly from the Git repository.

### clean

Expand Down
28 changes: 26 additions & 2 deletions docs/user-guide/commands/lip-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ A `<package>` can be any of the following (in order of priority):
- An archive (`.zip`, `.tar`, `.tgz` or `.tar.gz`) containing a directory with a `tooth.json` file
- A [package specifier](#) referencing a Git repository

If no `<package>` is specified and the current directory contains a `tooth.json` file, lip will install the package in the current directory. Be aware that this may cause file conflicts.
If no `<package>` is specified and the current directory contains a `tooth.json` file, lip will install the package in the current directory. Inplace file placement will not be performed.

When using a package specifier, lip will use Goproxy to download the package if the `download.goproxy` configuration is enabled. Otherwise, packages are downloaded directly from their Git repositories.
When using a package specifier, lip will use Goproxy to download the package if a Go module proxy is set in configuration. Otherwise, packages are downloaded directly from their Git repositories.

Package prerequisites must be installed manually. lip will not proceed with installation if it detects missing prerequisites.

Expand Down Expand Up @@ -59,3 +59,27 @@ Pre-release versions can be installed by explicitly specifying the version numbe
- `--save-prerequisites`

Save the installed packages to the `tooth.json` file as prerequisites.

## Package Specifier

A package specifier is a string that identifies a package, a sub-directory path, and a version.

The format is `<package>[#<path>][@<version>]`.

- `<package>` is the identifier of the package.
- `<version>` is the version of the package. If omitted, lip will install the latest version.
- `<path>` is an optional sub-directory path within the package, which must be a valid relative path beginning with a directory or a file name.

Examples:

- `github.com/futrime/example-package`
- `github.com/futrime/example-package#cmd/example-package`
- `github.com/futrime/example-package@v1.0.0`
- `github.com/futrime/example-package#cmd/example-package@v1.0.0-beta.1`

Wrong examples:

- `github.com/futrime/example-package#/cmd/example-package/`
- `github.com/futrime/example-package#~cmd/example-package/`
- `github.com/futrime/example-package#../cmd/example-package/`
- `github.com/futrime/example-package#./cmd/example-package/`
Loading

0 comments on commit d0db3ca

Please sign in to comment.