Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
feat: add descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed May 2, 2023
1 parent ca86561 commit 13a6773
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
5 changes: 3 additions & 2 deletions cli/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { Command } from "../deps/cliffy.ts"
import { CapiBinary, resolveBinary } from "../devnets/binary.ts"

export default new Command()
.description("TODO: bin description and describe binary/version arguments")
.description("Executes the <binary>@<version> for the current platform with [args...]")
.arguments("<binary:string> <version:string> [...args:string]")
.stopEarly()
.example("polkadot", "capi bin polkadot v0.9.41 --dev")
.example("polkadot in dev", "capi bin polkadot v0.9.41 --dev")
.example("polkadot build-spec", "capi bin polkadot v0.9.41 build-spec --chain rococo-local")
.action(async function(_options, binary: string, version: string, ...args: string[]) {
if (!binary || !version) throw new Error("Must specify binary and version")

Expand Down
12 changes: 3 additions & 9 deletions cli/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,23 @@ import { gracefulExit } from "../util/mod.ts"
import { resolveConfig } from "./resolveConfig.ts"

export default new Command()
.description("TODO: serve description")
.option("-c, --config <config:file>", "capi.config.ts path", { default: "./capi.config.ts" })
.description("Starts CAPI server")
.option("-c, --config <config:file>", "capi.config.ts file path", { default: "./capi.config.ts" })
.option("--port <port:number>", "", { default: 4646 })
.option("--out <out:string>", "", { default: "target/capi" })
.option("--out <out:string>", "Metadata and codegen output directory", { default: "target/capi" })
.action(async function({ config: configFile, port, out }) {
const literalArgs = this.getLiteralArgs()
const config = await resolveConfig(configFile)

const tempDir = await createTempDir()

const href = `http://localhost:${port}/`

const controller = new AbortController()
const { signal } = controller

const dataCache = new FsCache(out, signal)
const tempCache = new InMemoryCache(signal)

const running = await fetch(`${href}capi_cwd`)
.then((r) => r.text())
.then((r) => r === Deno.cwd())
.catch(() => false)

if (!running) {
const devnetsHandler = createDevnetsHandler(tempDir, config, signal)
const codegenHandler = createCodegenHandler(dataCache, tempCache)
Expand Down
13 changes: 5 additions & 8 deletions cli/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ import { normalizePackageName } from "../util/mod.ts"
import { resolveConfig } from "./resolveConfig.ts"

export default new Command()
.description("TODO: sync description")
.option("-c, --config <config:file>", "capi.config.ts path", { default: "./capi.config.ts" })
.option("--import-map <importMap:file>", "import_map.json path")
.option("--package-json <packageJson:file>", "package.json path")
.option("--check", "TODO: check description")
.description("Syncs metadata and codegen")
.option("-c, --config <config:file>", "capi.config.ts file path", { default: "./capi.config.ts" })
.option("--import-map <import-map:file>", "import_map.json file path")
.option("--package-json <package-json:file>", "package.json file path")
.option("--check", "ensures that metadata and codegen are in sync")
.action(
async function(
{ config: configFile, importMap: importMapFile, packageJson: packageJsonFile, check },
) {
const config = await resolveConfig(configFile)

const tempDir = await createTempDir()
const baseUrl = await syncConfig(tempDir, config)

if (importMapFile) {
syncFile(importMapFile, (importMap) => {
importMap.imports["@capi/"] = baseUrl
})
}

if (packageJsonFile) {
syncFile(packageJsonFile, (packageJson) => {
const addedPackages = new Set()
Expand Down

0 comments on commit 13a6773

Please sign in to comment.