-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9963c2
commit 2fb2ccf
Showing
6 changed files
with
58 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{ readme }} | ||
|
||
{%- if links != "" %} | ||
{{ links }} | ||
{%- endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import * as zx from 'npm:zx' | ||
import { z, ZodSchema } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { assertEquals } from 'https://jsr.io/@std/assert/1.0.0/equals.ts' | ||
import { assert } from 'https://jsr.io/@std/assert/1.0.0/assert.ts' | ||
|
||
const CargoToml = z.object({ | ||
package: z.object({ | ||
|
@@ -21,6 +22,17 @@ const CargoToml = z.object({ | |
|
||
type CargoToml = z.infer<typeof CargoToml>; | ||
|
||
const CargoMetadataSchema = z.object({ | ||
packages: z.array(z.object({ | ||
name: z.string(), | ||
targets: z.array(z.object({ | ||
name: z.string(), | ||
})), | ||
})), | ||
}) | ||
|
||
type CargoMetadata = z.infer<typeof CargoMetadataSchema>; | ||
|
||
const Repo = z.object({ | ||
url: z.string().url(), | ||
}) | ||
|
@@ -37,6 +49,12 @@ const theCargoToml: CargoToml = parse(CargoToml, await $`yj -t < Cargo.toml`) | |
const { package: { name, description, metadata: { details: { title } } } } = theCargoToml | ||
const bin = name | ||
const help = await $`cargo run --quiet --bin ${bin} -- --help` | ||
const theCargoMetadata: CargoMetadata = parse(CargoMetadataSchema, await $`cargo metadata --format-version 1`) | ||
const thePackageMetadata = theCargoMetadata.packages.find(p => p.name == name) | ||
assert(thePackageMetadata, 'Could not find package metadata') | ||
const target = thePackageMetadata.targets[0] | ||
assert(target, 'Could not find package first target') | ||
const doc = await $`cargo doc2readme --template README.jl --target-name ${target.name} --out -` | ||
const repo: Repo = parse(Repo, await $`gh repo view --json url`) | ||
const extraBins = (await $`find src/bin/*.rs -type f -exec basename {} .rs \\;`).valueOf().split('\n') | ||
|
||
|
@@ -56,35 +74,7 @@ ${autogenerated} | |
[](${repo.url}) | ||
[](https://docs.rs/${name}) | ||
## Overview | ||
${description} | ||
## Examples | ||
\`\`\`shell | ||
# Create a GitHub repo & init a Rust project | ||
${bin} --name my-new-project | ||
# Copy configs from existing project | ||
${bin} --name my-new-project --copy-configs-from ~/workspace/my-existing-project | ||
# Clone to a specific directory | ||
${bin} --name my-new-project --dir ~/workspace/my-new-project | ||
# Create a public repo | ||
${bin} --name my-new-project --repo-create-cmd "gh repo create --public {{name}}" | ||
# Create a lib instead of bin | ||
${bin} --name my-new-project --project-init-cmd "cargo init --lib" | ||
\`\`\` | ||
## Features | ||
* [x] Uses existing \`gh\`, \`git\`, \`cargo\` commands | ||
* [x] Supports overrides for all commands | ||
* [x] Supports substitutions (see help below) | ||
* [x] Can be used as a library | ||
${doc.stdout.trim()} | ||
## Installation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ npm install --global \ | |
[email protected] \ | ||
[email protected] | ||
|
||
cargo install --git https://github.com/DenisGorbachev/cargo-doc2readme --branch dev | ||
|
||
# Install yj | ||
curl -L https://github.com/sclevine/yj/releases/download/v5.1.0/yj-linux-amd64 -o /tmp/yj | ||
chmod +x /tmp/yj | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use clap::Parser; | ||
|
||
use create_rust_github_repo::CreateRustGithubRepo; | ||
|
||
fn main() -> anyhow::Result<()> { | ||
|