init
js/commands/init.ts
fino:commands/init — reusable fino init command task.
Builds the fino init command, which scaffolds a package.json in the
current working directory. Defaults are derived from the environment where
possible: the package name comes from the directory basename (falling back
to fino-app), the author from git config user.name / user.email, and
the repository from git config remote.origin.url. Git lookups fail soft —
a missing git binary or unset config simply yields an empty default.
When the command runs on an interactive terminal, each field that was not
passed explicitly as a flag is confirmed through a prompt; --yes accepts
all defaults without prompting, and non-interactive contexts behave as if
--yes were set. The generated manifest always includes type: "module" —
fino packages are ESM-only.
An existing package.json is never overwritten unless --force is passed.
Package names are validated against the npm-style form
@scope/name / name (lowercase letters, digits, dots, underscores,
hyphens); an invalid name aborts the command before anything is written.
import initCommand from 'fino:commands/init';
// Non-interactive scaffold, accepting derived defaults:
await initCommand.parse(['--yes', '--name', 'my-tool', '--license', 'Apache-2.0']);
Constants
const command
The init subcommand used by the root Fino CLI.
Writes package.json with name, version, type, description,
license, author, and repository fields, pretty-printed with two-space
indentation and a trailing newline. In text mode the task resolves to a
Wrote <path> message; with --json it writes and returns a structured
result of the shape { command, ok, path, package, message }.
Throws if package.json already exists and --force was not given, if the
resolved package name fails validation, or if the filesystem write fails.
import init from 'fino:commands/init';
// Interactive: prompts for each field on a TTY.
await init.parse([]);
// Scripted: accept defaults, overwrite an existing manifest.
await init.parse(['--yes', '--force', '--name', 'fino-app']);