Skip to content

pfy init

Initialize a new project configuration file (project.yaml) with project metadata and CI/CD settings.

Synopsis

bash
pfy init [flags]

Description

The init command creates a project.yaml file in the current directory with project configuration. This file stores CI/CD settings, project metadata, and environment mappings, allowing subsequent commands to run without repetitive flags.

The command will:

  1. Auto-detect project language from go.mod or package.json
  2. Use the current directory name as the project name
  3. Set sensible defaults for registry and CI type
  4. Create a project.yaml file

Flags

--name <string>

Project name. Defaults to the current directory name.

bash
pfy init --name my-application

--language <string>

Project programming language. Valid values: go, node.

If not specified, auto-detects from:

  • go.mod → Go
  • package.json → Node.js
bash
pfy init --language go

--ci-type <string>

CI/CD platform type. Valid values: github, gitlab.

Defaults to github.

bash
pfy init --ci-type gitlab

--registry <string>

Docker container registry URL.

Defaults to ghcr.io (GitHub Container Registry).

bash
pfy init --registry docker.io

Examples

Basic Initialization

Initialize with auto-detected settings:

bash
pfy init

Output:

Successfully initialized project configuration:
  Name: my-project
  Language: go
  CI Type: github
  Registry: ghcr.io
  Image: my-project

Configuration saved to project.yaml
You can now run 'pfy ci update' without additional flags.

Custom Configuration

Specify all settings explicitly:

bash
pfy init \
  --name my-service \
  --language node \
  --ci-type gitlab \
  --registry docker.io

Go Project

For a Go project (with go.mod present):

bash
pfy init --name auth-service

Generated project.yaml:

yaml
project_name: auth-service
version: 0.1.0
ci:
  type: github
  language: go
  registry: ghcr.io
  image_name: auth-service

Node.js Project

For a Node.js project (with package.json present):

bash
pfy init --name api-gateway --ci-type gitlab

Generated project.yaml:

yaml
project_name: api-gateway
version: 0.1.0
ci:
  type: gitlab
  language: node
  registry: ghcr.io
  image_name: api-gateway

Custom Registry

Use a different Docker registry:

bash
pfy init --registry registry.example.com

Generated File

The command creates project.yaml:

yaml
project_name: my-application
version: 0.1.0
ci:
  type: github
  language: go
  registry: ghcr.io
  image_name: my-application

Usage After Initialization

Once project.yaml exists, you can run commands without flags:

bash
# Without project.yaml - need all flags
pfy ci update --type github --language go --project-name my-app --output .github/workflows/ci.yml

# With project.yaml - no flags needed
pfy ci update --output .github/workflows/ci.yml

Auto-Detection

The command auto-detects settings in this order:

  1. Language Detection:

    • Check for go.mod → Set language to go
    • Check for package.json → Set language to node
    • Default to go if neither found
  2. Project Name:

    • Use --name flag if provided
    • Otherwise use current directory name
  3. Image Name:

    • Derived from project name (lowercase)

Error Handling

File Already Exists

If project.yaml already exists:

bash
$ pfy init
Error: project.yaml already exists in current directory

Solution: Delete the file or edit it manually.

Invalid Language

If an invalid language is specified:

bash
$ pfy init --language python

The file will be created, but CI commands may fail. Valid languages: go, node.

Updating Configuration

To update an existing configuration:

  1. Manual Edit: Directly edit project.yaml
  2. Reinitialize: Delete project.yaml and run pfy init again

Global Flags

All global pfy flags are available:

  • --verbose, -v: Show detailed output
  • --quiet, -q: Suppress non-essential output

Verbose Output

bash
pfy init --verbose

Output:

Initializing project: my-project
Successfully initialized project configuration:
  Name: my-project
  Language: go
  CI Type: github
  Registry: ghcr.io
  Image: my-project

Configuration saved to project.yaml
You can now run 'pfy ci update' without additional flags.

Best Practices

Version Control

Commit project.yaml to version control:

bash
pfy init
git add project.yaml
git commit -m "Add project configuration"

Team Collaboration

Initialize the project once and share via version control. All team members will use the same configuration.

Environment-Specific Overrides

Use flags to override for specific environments:

bash
# Development
pfy ci update

# Production with different registry
pfy ci update --registry production.registry.com

See Also