viv init

Reach for this when you're starting a project and want a composer.json written from sensible defaults — inferred from git and the current directory — with no interactive question flow. Pass --require/ --require-dev to chain straight into the same resolve/lock/install viv add runs; --no-install opts out.

Usage

Write a composer.json for a new project and stop (#143): no interactive question flow, defaults inferred from git and the directory. `--require`/`--require-dev` chain into the same resolve/lock/install `viv add` runs (`--no-install` opts out)

Usage: viv init [OPTIONS]

Options:
      --name <NAME>                `vendor/package`; inferred from git/the OS user and the directory name when not given
  -v, --verbose                    Raise logging to debug
      --cache-dir <CACHE_DIR>      Store location (default `$XDG_CACHE_HOME/vivace`, or `~/.cache/vivace`)
      --description <DESCRIPTION>  Free-text project description; left out of the file entirely when not given
      --offline                    Fail fast on any request instead of connecting: install errors, naming every package not already in the store; update solves from cached repository metadata only, erroring on an uncached package. Also set by `COMPOSER_DISABLE_NETWORK` (any value but unset, empty or `0`; Composer's own git-priming `prime` value is not special-cased here, since neither `install` nor `update` touch a git source)
      --type <PACKAGE_TYPE>        Package type. Defaults to `project`
      --license <LICENSE>          SPDX licence identifier. Defaults to `MIT`
      --autoload <AUTOLOAD>        Directory to autoload under `psr-4`; also forces the entry even when the directory doesn't exist yet (the default only adds one when `src/` is already there)
      --require <REQUIRE>          `vendor/package[:constraint]`, repeatable; a bare name gets a synthesised constraint, same as `viv add`
      --require-dev <REQUIRE_DEV>  `vendor/package[:constraint]` for `require-dev`, repeatable
      --repository <TYPE:URL>      `type:url`, repeatable; appended to `repositories` (#315), e.g. `--repository path:packages/*`
      --no-install                 Write composer.json (and, with `--require`/`--require-dev`, composer.lock) but don't install
      --force                      Overwrite an existing composer.json
  -d, --project-dir <PROJECT_DIR>  Project directory to write composer.json into [default: .]
  -h, --help                       Print help

Reads and writes

  • Reads: git config (for the author and package name defaults).
  • Writes: composer.json; with --require/--require-dev and no --no-install, also composer.lock and vendor/, and reads/writes the store under $XDG_CACHE_HOME/vivace.

Exit codes

  • 0 — composer.json written (and, if requested, installed).
  • 1 — a filesystem error, or a bad flag.
  • 2 — a --require/--require-dev chain into add failed to resolve.

See also

viv new, viv add