Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

g7-cli

그누보드7(G7) 확장 개발을 돕는 CLI 도구입니다.

g7-cli_bundled 아래의 모듈/플러그인 소스를 감시합니다. 감시 중인 파일이 변경되면 필요한 경우 프론트엔드 에셋을 먼저 빌드하고, 이어서 G7의 module:update 또는 plugin:update 명령을 실행합니다.

개발 원본은 _bundled에 유지하면서 변경 사항을 활성 디렉토리와 G7에 반영할 수 있으므로, 처리 완료 후 브라우저를 새로고침해서 바로 확인하는 개발 흐름을 목표로 합니다.

설치

Linux (amd64)

curl -fL https://github.com/ninecells/g7-cli/releases/latest/download/g7-cli-linux-amd64 -o g7-cli-linux-amd64
chmod 0755 g7-cli-linux-amd64
sudo install -m 0755 g7-cli-linux-amd64 /usr/local/bin/g7

Linux (arm64)

curl -fL https://github.com/ninecells/g7-cli/releases/latest/download/g7-cli-linux-arm64 -o g7-cli-linux-arm64
chmod 0755 g7-cli-linux-arm64
sudo install -m 0755 g7-cli-linux-arm64 /usr/local/bin/g7

macOS (Apple Silicon)

curl -fL https://github.com/ninecells/g7-cli/releases/latest/download/g7-cli-darwin-arm64 -o g7-cli-darwin-arm64
chmod 0755 g7-cli-darwin-arm64
sudo install -m 0755 g7-cli-darwin-arm64 /usr/local/bin/g7

macOS (Intel)

curl -fL https://github.com/ninecells/g7-cli/releases/latest/download/g7-cli-darwin-amd64 -o g7-cli-darwin-amd64
chmod 0755 g7-cli-darwin-amd64
sudo install -m 0755 g7-cli-darwin-amd64 /usr/local/bin/g7

Windows (amd64)

PowerShell에서 실행합니다.

Invoke-WebRequest -Uri "https://github.com/ninecells/g7-cli/releases/latest/download/g7-cli-windows-amd64.exe" -OutFile "g7.exe"

다운로드한 g7.exe를 PATH에 등록된 디렉터리로 이동합니다.

설치 확인:

g7 --version

기본 전제

g7-cli.yaml이 없으면 다음 환경을 기본값으로 사용합니다.

  • 현재 디렉토리가 G7 루트입니다.
  • 호스트에서 npm을 사용할 수 있습니다.
  • 현재 디렉토리에서 php artisan을 실행할 수 있습니다.

동일한 설정을 YAML로 작성하면 다음과 같습니다.

version: 1

g7_root: .

runners:
  node:
    command: npm

  artisan:
    command: php
    args:
      - artisan

watch: []

기본 설정 파일은 다음 명령으로 생성할 수 있습니다.

g7 init

g7-cli.yaml에는 개발 환경별 경로와 Runner 설정이 들어갈 수 있으므로 저장소에 커밋하지 않고 .gitignore에 추가해서 사용하는 것을 권장합니다.

g7-cli.yaml

Podman 사용 예

프로젝트 루트 아래 ./g7에 G7이 있고, Node/npm은 호스트에서 실행하며 Artisan은 FrankenPHP Podman 컨테이너 안에서 실행하는 경우입니다.

version: 1

g7_root: ./g7

runners:
  node:
    command: npm

  artisan:
    command: podman-compose
    cwd: .
    args:
      - -f
      - compose.yaml
      - -f
      - compose.dev.yaml
      - exec
      - -T
      - frankenphp
      - php
      - artisan

watch:
  - module:ninecells-marketplace

runner.args는 실제 명령 앞에 붙는 인자입니다. g7-cli가 그 뒤에 동적인 G7 명령을 추가합니다.

위 설정에서 모듈 업데이트는 실제로 다음과 같은 명령이 됩니다.

podman-compose -f compose.yaml -f compose.dev.yaml exec -T frankenphp php artisan module:update ninecells-marketplace --force --source=bundled

watch

기본 사용법은 다음과 같습니다.

g7 watch

인자를 지정하지 않고 g7 watch를 실행하면 저장된 watch: 설정의 존재 여부와 관계없이 항상 _bundled의 모듈/플러그인을 스캔해서 번호 선택 화면을 보여줍니다.

예:

Select extensions to watch:
  1. [x] module:ninecells-marketplace
  2. [ ] module:foo
  3. [x] plugin:bar

Selection [1,3]:

기존 선택을 그대로 사용하려면 아무것도 입력하지 않고 Enter를 누릅니다.

Selection [1,3]:

선택을 바꾸려면 번호를 쉼표로 구분해서 입력합니다.

Selection [1,3]: 1,2,3

기존 설정과 선택 결과가 달라졌을 때만 저장 여부를 묻습니다.

Save this selection to g7-cli.yaml? [Y/n]
  • Enter 또는 Y: 새로운 선택을 g7-cli.yaml에 저장하고 감시를 시작합니다.
  • n: 이번 실행에서만 새로운 선택을 사용하고 설정 파일은 수정하지 않습니다.
  • 기존 선택에서 Enter만 눌렀다면 저장 여부를 묻지 않고 바로 감시를 시작합니다.

명령행에서 감시 대상을 직접 지정할 수도 있습니다. 이 경우 선택 화면을 표시하지 않습니다.

g7 watch module:ninecells-marketplace
g7 watch module:foo plugin:bar

모든 번들 모듈/플러그인을 감시하려면 다음과 같이 실행합니다.

g7 watch --all

파일 변경 시 동작

프론트엔드 입력 파일이 변경된 경우 다음 순서로 처리합니다.

대상 예:

  • .js
  • .jsx
  • .ts
  • .tsx
  • .css
  • .scss
  • .sass
  • .less
  • package 관련 파일

처리 순서:

  1. package 메타데이터가 변경되었거나 node_modules가 없으면 npm install
  2. 해당 확장의 _bundled 디렉토리에서 npm run build
  3. G7 빌드 명령과 같은 디렉토리 규칙으로 components.json 생성
  4. module:update 또는 plugin:update --force --source=bundled 실행

PHP, JSON 등 프론트엔드 빌드가 필요하지 않은 소스가 변경되면 빌드를 생략하고 update 명령만 실행합니다.

다음 생성물/의존성 디렉토리는 감시에서 제외합니다.

  • .git
  • .idea
  • .vscode
  • node_modules
  • vendor
  • dist

g7-cli가 다음 메시지를 출력하면 처리가 끝난 것입니다.

ready - refresh the browser

그 뒤 G7이 열려 있는 브라우저를 직접 새로고침해서 변경 사항을 확인합니다.

Runner 작업 디렉토리

cwd를 지정하지 않은 경우 기본 작업 디렉토리는 다음과 같습니다.

  • node: 감시 중인 확장의 _bundled 디렉토리
  • artisan: g7_root

cwd를 지정하면 g7-cli.yaml이 위치한 디렉토리를 기준으로 경로를 해석합니다.

Runner 문자열에서는 다음 placeholder를 사용할 수 있습니다.

  • {project_root}
  • {g7_root}
  • {extension_dir}
  • {extension_id}
  • {extension_type}

명령

g7 init
g7 watch [module:id|plugin:id ...]
g7 config show
g7 config validate
g7 version
g7 --help

watch 관련 옵션은 다음 명령으로 확인합니다.

g7 watch --help

빌드

현재 플랫폼용 바이너리:

go build -o g7-cli ./cmd/g7-cli

Linux amd64:

GOOS=linux GOARCH=amd64 go build -o dist/g7-cli-linux-amd64 ./cmd/g7-cli

Windows amd64:

GOOS=windows GOARCH=amd64 go build -o dist/g7-cli-windows-amd64.exe ./cmd/g7-cli

About

G7 extension development helper CLI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages