@codigodoleo/wp-kit 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/init.js +19 -10
- package/lib/config/versions.js +5 -5
- package/lib/core/infer-ci-capabilities.js +17 -0
- package/lib/prompts/index.js +27 -17
- package/lib/utils/git.js +50 -13
- package/modules/blank-theme/index.js +71 -0
- package/modules/blank-theme/lint/.prettierrc.json +12 -0
- package/modules/blank-theme/lint/.stylelintrc.json +7 -0
- package/modules/{lint → blank-theme/lint}/eslint.config.mjs +2 -8
- package/modules/blank-theme/lint/pint.json +11 -0
- package/modules/blank-theme/prompts.js +36 -0
- package/modules/blank-theme/templates/.lando.yml.hbs +26 -0
- package/modules/blank-theme/templates/functions.php.hbs +46 -0
- package/modules/blank-theme/templates/package.json.hbs +16 -0
- package/modules/blank-theme/templates/style.css.hbs +7 -0
- package/modules/blank-theme/templates/vite.config.js.hbs +23 -0
- package/modules/deploy/.github/workflows/deploy-docker.yml +104 -0
- package/modules/deploy/.github/workflows/deploy-ssh.yml +128 -0
- package/modules/deploy/.github/workflows/release.yml +57 -0
- package/modules/deploy/index.js +77 -0
- package/modules/deploy/prompts.js +1 -3
- package/modules/deploy/templates/.github/workflows/ci.yml.hbs +29 -1
- package/modules/deploy/templates/.gitlab/ci/deploy-docker.yml.hbs +35 -0
- package/modules/deploy/templates/.gitlab/ci/deploy-ssh.yml.hbs +83 -0
- package/modules/deploy/templates/.gitlab/ci/lint-blank-theme.yml.hbs +35 -0
- package/modules/deploy/templates/.gitlab/ci/lint-mu-plugin.yml.hbs +19 -0
- package/modules/deploy/templates/.gitlab/ci/lint-plugin.yml.hbs +19 -0
- package/modules/deploy/templates/.gitlab/ci/lint-sage.yml.hbs +47 -0
- package/modules/deploy/templates/.gitlab/ci/release.yml.hbs +26 -0
- package/modules/git/.husky/commit-msg +8 -4
- package/modules/git/.husky/pre-commit +0 -3
- package/modules/git/templates/package.json.hbs +4 -4
- package/modules/git/templates/workspace.json.hbs +1 -1
- package/modules/lint/.commitlintrc.json +21 -0
- package/modules/lint/.prettierignore +15 -25
- package/modules/lint/.prettierrc.json +5 -16
- package/modules/lint/index.js +75 -8
- package/modules/lint/prompts.js +1 -8
- package/modules/lint/templates/.lando.yml.hbs +3 -8
- package/modules/lint/templates/package.json.hbs +4 -4
- package/modules/lint/templates/workspace.json.hbs +3 -3
- package/modules/mu-plugin/index.js +49 -0
- package/modules/mu-plugin/lint/.prettierrc.json +7 -0
- package/modules/mu-plugin/lint/eslint.config.mjs +30 -0
- package/modules/mu-plugin/lint/pint.json +11 -0
- package/modules/mu-plugin/prompts.js +29 -0
- package/modules/mu-plugin/templates/.lando.yml.hbs +15 -0
- package/modules/mu-plugin/templates/composer.json.hbs +14 -0
- package/modules/mu-plugin/templates/plugin.php.hbs +15 -0
- package/modules/php/templates/composer.json.hbs +15 -1
- package/modules/plugin/index.js +45 -0
- package/modules/plugin/lint/.prettierrc.json +7 -0
- package/modules/plugin/lint/eslint.config.mjs +30 -0
- package/modules/plugin/lint/pint.json +11 -0
- package/modules/plugin/prompts.js +29 -0
- package/modules/plugin/templates/.lando.yml.hbs +15 -0
- package/modules/plugin/templates/composer.json.hbs +14 -0
- package/modules/plugin/templates/plugin.php.hbs +15 -0
- package/modules/sage/index.js +139 -15
- package/modules/sage/lint/.prettierrc.json +12 -0
- package/modules/sage/lint/.stylelintrc.json +7 -0
- package/modules/sage/lint/eslint.config.mjs +30 -0
- package/modules/sage/lint/pint.json +11 -0
- package/modules/sage/prompts.js +22 -1
- package/modules/sage/templates/.devcontainer/devcontainer.json.hbs +7 -0
- package/modules/sage/templates/.devcontainer/docker-compose.override.yml.hbs +6 -0
- package/modules/sage/templates/.devcontainer/post-create.sh.hbs +11 -0
- package/modules/sage/templates/.lando.yml.hbs +43 -45
- package/modules/sage/templates/server/cmd/setup-sage-node.sh.hbs +23 -0
- package/modules/sage/templates/server/cmd/setup-sage-php.sh.hbs +24 -0
- package/modules/sage/templates/theme/app/Blocks/.gitkeep.hbs +0 -0
- package/modules/sage/templates/theme/app/Fields/.gitkeep.hbs +0 -0
- package/modules/sage/templates/theme/composer.json.hbs +25 -3
- package/modules/sage/templates/theme/package.json.hbs +15 -3
- package/modules/sage/templates/theme/resources/views/blocks/.gitkeep.hbs +0 -0
- package/modules/sage/templates/theme/vite.config.js.hbs +55 -13
- package/modules/sage/templates/workspace.json.hbs +94 -6
- package/modules/skills/index.js +18 -0
- package/modules/skills/prompts.js +21 -0
- package/modules/test/index.js +19 -0
- package/modules/test/prompts.js +8 -0
- package/modules/test/templates/composer.json.hbs +16 -0
- package/modules/test/templates/package.json.hbs +11 -0
- package/modules/test/templates/playwright.config.js.hbs +29 -0
- package/modules/test/tests/Pest.php +39 -0
- package/modules/test/tests/SmokeTest.php +15 -0
- package/modules/test/tests/e2e/example.spec.js +11 -0
- package/modules/test/tests/e2e/helpers/loginHelper.js +40 -0
- package/package.json +1 -1
- package/templates/.devcontainer/Dockerfile.hbs +24 -0
- package/templates/.devcontainer/config/nginx.conf +23 -0
- package/templates/.devcontainer/config/nginx.conf.hbs +23 -0
- package/templates/.devcontainer/devcontainer.json.hbs +29 -0
- package/templates/.devcontainer/docker-compose.yml.hbs +73 -0
- package/templates/.devcontainer/setup.sh.hbs +17 -0
- package/templates/.env.hbs +38 -15
- package/templates/.gitignore.hbs +84 -13
- package/templates/.lando.yml.hbs +61 -17
- package/templates/README.md.hbs +23 -7
- package/templates/composer.json.hbs +60 -12
- package/templates/package.json.hbs +0 -2
- package/templates/server/cmd/install-wp.sh.hbs +54 -43
- package/templates/server/cmd/setup-node.sh.hbs +11 -0
- package/templates/server/cmd/setup-php.sh.hbs +14 -0
- package/templates/server/www/vhosts.conf.hbs +54 -17
- package/templates/workspace.json.hbs +57 -1
- package/templates/wp-cli.yml.hbs +1 -0
- package/modules/lint/.eslintignore +0 -36
- package/modules/lint/.eslintrc.json +0 -8
- package/modules/lint/.stylelintignore +0 -19
- package/modules/lint/.stylelintrc.json +0 -9
- package/modules/lint/pint.json +0 -26
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Reusable workflow — Docker Build & Push to Container Registry
|
|
2
|
+
#
|
|
3
|
+
# Como usar no seu workflow principal (.github/workflows/main.yml):
|
|
4
|
+
#
|
|
5
|
+
# on:
|
|
6
|
+
# push:
|
|
7
|
+
# branches: [main]
|
|
8
|
+
#
|
|
9
|
+
# jobs:
|
|
10
|
+
# deploy:
|
|
11
|
+
# uses: ./.github/workflows/deploy-docker.yml
|
|
12
|
+
# with:
|
|
13
|
+
# registry: ghcr.io # opcional — default: ghcr.io
|
|
14
|
+
# # registry: docker.io # para Docker Hub
|
|
15
|
+
# secrets:
|
|
16
|
+
# REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GHCR usa GITHUB_TOKEN
|
|
17
|
+
# # REGISTRY_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} # Docker Hub
|
|
18
|
+
#
|
|
19
|
+
# Secrets necessários (Settings → Secrets → Actions):
|
|
20
|
+
# REGISTRY_TOKEN — token de autenticação no registry (GITHUB_TOKEN é suficiente para GHCR)
|
|
21
|
+
|
|
22
|
+
name: Deploy (Docker)
|
|
23
|
+
|
|
24
|
+
on:
|
|
25
|
+
workflow_call:
|
|
26
|
+
inputs:
|
|
27
|
+
registry:
|
|
28
|
+
description: 'Container registry (ghcr.io ou docker.io)'
|
|
29
|
+
required: false
|
|
30
|
+
type: string
|
|
31
|
+
default: ghcr.io
|
|
32
|
+
image-name:
|
|
33
|
+
description: 'Nome da imagem (default: github.repository em lowercase)'
|
|
34
|
+
required: false
|
|
35
|
+
type: string
|
|
36
|
+
default: ''
|
|
37
|
+
dockerfile:
|
|
38
|
+
description: 'Caminho para o Dockerfile'
|
|
39
|
+
required: false
|
|
40
|
+
type: string
|
|
41
|
+
default: Dockerfile
|
|
42
|
+
context:
|
|
43
|
+
description: 'Contexto do build Docker'
|
|
44
|
+
required: false
|
|
45
|
+
type: string
|
|
46
|
+
default: '.'
|
|
47
|
+
secrets:
|
|
48
|
+
REGISTRY_TOKEN:
|
|
49
|
+
required: false
|
|
50
|
+
|
|
51
|
+
permissions:
|
|
52
|
+
contents: read
|
|
53
|
+
packages: write
|
|
54
|
+
|
|
55
|
+
jobs:
|
|
56
|
+
build-push:
|
|
57
|
+
name: Build & Push
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
env:
|
|
60
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
61
|
+
steps:
|
|
62
|
+
- name: Checkout
|
|
63
|
+
uses: actions/checkout@v4
|
|
64
|
+
|
|
65
|
+
- name: Resolve image name
|
|
66
|
+
id: image
|
|
67
|
+
run: |
|
|
68
|
+
NAME="${{ inputs.image-name }}"
|
|
69
|
+
[ -z "$NAME" ] && NAME="${{ github.repository }}"
|
|
70
|
+
echo "name=${NAME,,}" >> $GITHUB_OUTPUT
|
|
71
|
+
|
|
72
|
+
- name: Set up QEMU
|
|
73
|
+
uses: docker/setup-qemu-action@v3
|
|
74
|
+
|
|
75
|
+
- name: Set up Docker Buildx
|
|
76
|
+
uses: docker/setup-buildx-action@v3
|
|
77
|
+
|
|
78
|
+
- name: Log in to registry
|
|
79
|
+
uses: docker/login-action@v3
|
|
80
|
+
with:
|
|
81
|
+
registry: ${{ inputs.registry }}
|
|
82
|
+
username: ${{ github.actor }}
|
|
83
|
+
password: ${{ secrets.REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
|
|
84
|
+
|
|
85
|
+
- name: Extract Docker metadata
|
|
86
|
+
id: meta
|
|
87
|
+
uses: docker/metadata-action@v5
|
|
88
|
+
with:
|
|
89
|
+
images: ${{ inputs.registry }}/${{ steps.image.outputs.name }}
|
|
90
|
+
tags: |
|
|
91
|
+
type=ref,event=branch
|
|
92
|
+
type=semver,pattern={{version}}
|
|
93
|
+
type=sha,prefix=sha-,format=short
|
|
94
|
+
|
|
95
|
+
- name: Build and push
|
|
96
|
+
uses: docker/build-push-action@v6
|
|
97
|
+
with:
|
|
98
|
+
context: ${{ inputs.context }}
|
|
99
|
+
file: ${{ inputs.dockerfile }}
|
|
100
|
+
push: true
|
|
101
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
102
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
103
|
+
cache-from: type=gha
|
|
104
|
+
cache-to: type=gha,mode=max
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Reusable workflow — SSH Deploy via rsync
|
|
2
|
+
#
|
|
3
|
+
# Como usar no seu workflow principal (.github/workflows/main.yml):
|
|
4
|
+
#
|
|
5
|
+
# on:
|
|
6
|
+
# push:
|
|
7
|
+
# branches: [main]
|
|
8
|
+
#
|
|
9
|
+
# jobs:
|
|
10
|
+
# deploy:
|
|
11
|
+
# uses: ./.github/workflows/deploy-ssh.yml
|
|
12
|
+
# with:
|
|
13
|
+
# host: meu-servidor.example.com
|
|
14
|
+
# user: deploy
|
|
15
|
+
# remote-path: /var/www/html
|
|
16
|
+
# theme-path: content/themes/meu-tema # opcional, para projetos com Sage
|
|
17
|
+
# secrets:
|
|
18
|
+
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
19
|
+
# SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
|
|
20
|
+
#
|
|
21
|
+
# Secrets necessários (Settings → Secrets → Actions):
|
|
22
|
+
# SSH_PRIVATE_KEY — chave SSH privada (gerada sem passphrase para CI)
|
|
23
|
+
# SSH_KNOWN_HOSTS — saída de: ssh-keyscan -H <host>
|
|
24
|
+
#
|
|
25
|
+
# Permissões no servidor — o rsync usa --no-perms --no-owner --no-group,
|
|
26
|
+
# portanto não altera permissões/proprietários existentes no destino.
|
|
27
|
+
|
|
28
|
+
name: Deploy (SSH + rsync)
|
|
29
|
+
|
|
30
|
+
on:
|
|
31
|
+
workflow_call:
|
|
32
|
+
inputs:
|
|
33
|
+
host:
|
|
34
|
+
description: 'Endereço do servidor de destino'
|
|
35
|
+
required: true
|
|
36
|
+
type: string
|
|
37
|
+
user:
|
|
38
|
+
description: 'Usuário SSH no servidor'
|
|
39
|
+
required: true
|
|
40
|
+
type: string
|
|
41
|
+
remote-path:
|
|
42
|
+
description: 'Caminho absoluto no servidor de destino'
|
|
43
|
+
required: true
|
|
44
|
+
type: string
|
|
45
|
+
php-version:
|
|
46
|
+
description: 'Versão do PHP para instalar dependências Composer'
|
|
47
|
+
required: false
|
|
48
|
+
type: string
|
|
49
|
+
default: '8.3'
|
|
50
|
+
node-version:
|
|
51
|
+
description: 'Versão do Node.js para build de assets'
|
|
52
|
+
required: false
|
|
53
|
+
type: string
|
|
54
|
+
default: '22'
|
|
55
|
+
theme-path:
|
|
56
|
+
description: 'Caminho relativo do tema para build (vazio = sem build de tema)'
|
|
57
|
+
required: false
|
|
58
|
+
type: string
|
|
59
|
+
default: ''
|
|
60
|
+
rsync-excludes:
|
|
61
|
+
description: 'Caminhos a excluir do rsync, separados por vírgula'
|
|
62
|
+
required: false
|
|
63
|
+
type: string
|
|
64
|
+
default: '.git,.env,node_modules/.cache'
|
|
65
|
+
secrets:
|
|
66
|
+
SSH_PRIVATE_KEY:
|
|
67
|
+
required: true
|
|
68
|
+
SSH_KNOWN_HOSTS:
|
|
69
|
+
required: true
|
|
70
|
+
|
|
71
|
+
jobs:
|
|
72
|
+
build-and-deploy:
|
|
73
|
+
name: Build & Deploy via SSH
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
env:
|
|
76
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
77
|
+
steps:
|
|
78
|
+
- name: Checkout
|
|
79
|
+
uses: actions/checkout@v4
|
|
80
|
+
with:
|
|
81
|
+
fetch-depth: 0
|
|
82
|
+
|
|
83
|
+
- name: Setup PHP
|
|
84
|
+
uses: shivammathur/setup-php@v2
|
|
85
|
+
with:
|
|
86
|
+
php-version: ${{ inputs.php-version }}
|
|
87
|
+
|
|
88
|
+
- name: Install Composer dependencies
|
|
89
|
+
run: composer install --no-dev --optimize-autoloader --no-interaction
|
|
90
|
+
|
|
91
|
+
- name: Setup Node.js
|
|
92
|
+
if: inputs.theme-path != ''
|
|
93
|
+
uses: actions/setup-node@v4
|
|
94
|
+
with:
|
|
95
|
+
node-version: ${{ inputs.node-version }}
|
|
96
|
+
cache: 'npm'
|
|
97
|
+
cache-dependency-path: ${{ inputs.theme-path }}/package-lock.json
|
|
98
|
+
|
|
99
|
+
- name: Build theme assets
|
|
100
|
+
if: inputs.theme-path != ''
|
|
101
|
+
run: |
|
|
102
|
+
npm install --prefix "${{ inputs.theme-path }}"
|
|
103
|
+
npm run build --prefix "${{ inputs.theme-path }}"
|
|
104
|
+
|
|
105
|
+
- name: Configure SSH agent
|
|
106
|
+
uses: webfactory/ssh-agent@v0.9.0
|
|
107
|
+
with:
|
|
108
|
+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
109
|
+
|
|
110
|
+
- name: Add known hosts
|
|
111
|
+
run: |
|
|
112
|
+
mkdir -p ~/.ssh
|
|
113
|
+
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
|
|
114
|
+
chmod 600 ~/.ssh/known_hosts
|
|
115
|
+
|
|
116
|
+
- name: Deploy via rsync
|
|
117
|
+
run: |
|
|
118
|
+
EXCLUDE_ARGS=""
|
|
119
|
+
IFS=',' read -ra ITEMS <<< "${{ inputs.rsync-excludes }}"
|
|
120
|
+
for item in "${ITEMS[@]}"; do
|
|
121
|
+
EXCLUDE_ARGS="$EXCLUDE_ARGS --exclude=${item// /}"
|
|
122
|
+
done
|
|
123
|
+
|
|
124
|
+
rsync -avz --delete \
|
|
125
|
+
$EXCLUDE_ARGS \
|
|
126
|
+
--no-perms --no-owner --no-group \
|
|
127
|
+
./ \
|
|
128
|
+
"${{ inputs.user }}@${{ inputs.host }}:${{ inputs.remote-path }}/"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Reusable workflow — Semantic Release
|
|
2
|
+
#
|
|
3
|
+
# Como usar no seu workflow principal (.github/workflows/main.yml):
|
|
4
|
+
#
|
|
5
|
+
# on:
|
|
6
|
+
# push:
|
|
7
|
+
# branches: [main]
|
|
8
|
+
#
|
|
9
|
+
# jobs:
|
|
10
|
+
# release:
|
|
11
|
+
# uses: ./.github/workflows/release.yml
|
|
12
|
+
# secrets:
|
|
13
|
+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # opcional para projetos WordPress
|
|
14
|
+
#
|
|
15
|
+
# GITHUB_TOKEN é injetado automaticamente com os devidos escopos.
|
|
16
|
+
|
|
17
|
+
name: Semantic Release (reusable)
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
workflow_call:
|
|
21
|
+
secrets:
|
|
22
|
+
NPM_TOKEN:
|
|
23
|
+
required: false
|
|
24
|
+
|
|
25
|
+
permissions:
|
|
26
|
+
contents: write
|
|
27
|
+
issues: write
|
|
28
|
+
pull-requests: write
|
|
29
|
+
id-token: write
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
release:
|
|
33
|
+
name: Semantic Release
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
env:
|
|
36
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
37
|
+
steps:
|
|
38
|
+
- name: Checkout
|
|
39
|
+
uses: actions/checkout@v4
|
|
40
|
+
with:
|
|
41
|
+
fetch-depth: 0
|
|
42
|
+
persist-credentials: false
|
|
43
|
+
|
|
44
|
+
- name: Setup Node.js
|
|
45
|
+
uses: actions/setup-node@v4
|
|
46
|
+
with:
|
|
47
|
+
node-version: '24'
|
|
48
|
+
cache: 'npm'
|
|
49
|
+
|
|
50
|
+
- name: Install dependencies
|
|
51
|
+
run: npm ci
|
|
52
|
+
|
|
53
|
+
- name: Release
|
|
54
|
+
run: npx semantic-release
|
|
55
|
+
env:
|
|
56
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
57
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/modules/deploy/index.js
CHANGED
|
@@ -12,6 +12,65 @@ export async function setupModule(context, generator) {
|
|
|
12
12
|
if (context.gitProvider === 'gitlab') {
|
|
13
13
|
await generator.generateFile('.gitlab/gitlab-ci.yml', context, 'deploy', '.gitlab-ci.yml');
|
|
14
14
|
log(color.green, '[deploy] .gitlab-ci.yml gerado com sucesso.');
|
|
15
|
+
|
|
16
|
+
// Jobs reutilizáveis para .gitlab/ci/ (include: no pipeline principal)
|
|
17
|
+
await generator.generateFile(
|
|
18
|
+
'.gitlab/ci/release.yml',
|
|
19
|
+
context,
|
|
20
|
+
'deploy',
|
|
21
|
+
'.gitlab/ci/release.yml'
|
|
22
|
+
);
|
|
23
|
+
await generator.generateFile(
|
|
24
|
+
'.gitlab/ci/deploy-docker.yml',
|
|
25
|
+
context,
|
|
26
|
+
'deploy',
|
|
27
|
+
'.gitlab/ci/deploy-docker.yml'
|
|
28
|
+
);
|
|
29
|
+
await generator.generateFile(
|
|
30
|
+
'.gitlab/ci/deploy-ssh.yml',
|
|
31
|
+
context,
|
|
32
|
+
'deploy',
|
|
33
|
+
'.gitlab/ci/deploy-ssh.yml'
|
|
34
|
+
);
|
|
35
|
+
log(color.green, '[deploy] Jobs reutilizáveis GitLab gerados em .gitlab/ci/');
|
|
36
|
+
|
|
37
|
+
// Lint jobs condicionais por módulo
|
|
38
|
+
if (context.ci?.lint?.sage) {
|
|
39
|
+
await generator.generateFile(
|
|
40
|
+
'.gitlab/ci/lint-sage.yml',
|
|
41
|
+
context,
|
|
42
|
+
'deploy',
|
|
43
|
+
'.gitlab/ci/lint-sage.yml'
|
|
44
|
+
);
|
|
45
|
+
log(color.green, '[deploy] GitLab lint job para Sage gerado.');
|
|
46
|
+
}
|
|
47
|
+
if (context.ci?.lint?.mu_plugin) {
|
|
48
|
+
await generator.generateFile(
|
|
49
|
+
'.gitlab/ci/lint-mu-plugin.yml',
|
|
50
|
+
context,
|
|
51
|
+
'deploy',
|
|
52
|
+
'.gitlab/ci/lint-mu-plugin.yml'
|
|
53
|
+
);
|
|
54
|
+
log(color.green, '[deploy] GitLab lint job para MU Plugin gerado.');
|
|
55
|
+
}
|
|
56
|
+
if (context.ci?.lint?.plugin) {
|
|
57
|
+
await generator.generateFile(
|
|
58
|
+
'.gitlab/ci/lint-plugin.yml',
|
|
59
|
+
context,
|
|
60
|
+
'deploy',
|
|
61
|
+
'.gitlab/ci/lint-plugin.yml'
|
|
62
|
+
);
|
|
63
|
+
log(color.green, '[deploy] GitLab lint job para Plugin gerado.');
|
|
64
|
+
}
|
|
65
|
+
if (context.ci?.lint?.blank_theme) {
|
|
66
|
+
await generator.generateFile(
|
|
67
|
+
'.gitlab/ci/lint-blank-theme.yml',
|
|
68
|
+
context,
|
|
69
|
+
'deploy',
|
|
70
|
+
'.gitlab/ci/lint-blank-theme.yml'
|
|
71
|
+
);
|
|
72
|
+
log(color.green, '[deploy] GitLab lint job para Blank Theme gerado.');
|
|
73
|
+
}
|
|
15
74
|
}
|
|
16
75
|
if (context.gitProvider === 'github') {
|
|
17
76
|
await generator.generateFile(
|
|
@@ -21,6 +80,24 @@ export async function setupModule(context, generator) {
|
|
|
21
80
|
'.github/workflows/ci.yml'
|
|
22
81
|
);
|
|
23
82
|
log(color.green, '[deploy] GitHub Actions workflow gerado com sucesso.');
|
|
83
|
+
|
|
84
|
+
// Reusable workflows para .github/workflows/ (workflow_call no pipeline principal)
|
|
85
|
+
await generator.copyFile(
|
|
86
|
+
'.github/workflows/release.yml',
|
|
87
|
+
'deploy',
|
|
88
|
+
'.github/workflows/release.yml'
|
|
89
|
+
);
|
|
90
|
+
await generator.copyFile(
|
|
91
|
+
'.github/workflows/deploy-docker.yml',
|
|
92
|
+
'deploy',
|
|
93
|
+
'.github/workflows/deploy-docker.yml'
|
|
94
|
+
);
|
|
95
|
+
await generator.copyFile(
|
|
96
|
+
'.github/workflows/deploy-ssh.yml',
|
|
97
|
+
'deploy',
|
|
98
|
+
'.github/workflows/deploy-ssh.yml'
|
|
99
|
+
);
|
|
100
|
+
log(color.green, '[deploy] Reusable workflows GitHub gerados em .github/workflows/');
|
|
24
101
|
}
|
|
25
102
|
if (context.gitProvider === 'bitbucket') {
|
|
26
103
|
await generator.generateFile(
|
|
@@ -26,6 +26,34 @@ env.NODE_VERSION
|
|
|
26
26
|
não encontrado em $THEME — pulando build do tema" fi
|
|
27
27
|
{{/if}}
|
|
28
28
|
|
|
29
|
+
{{#if ci.lint.sage}}
|
|
30
|
+
lint-sage: name: Lint Sage Theme runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: ${{'{{'}}
|
|
31
|
+
env.NODE_VERSION
|
|
32
|
+
{{'}}'}}
|
|
33
|
+
- name: Lint Sage run: | cd {{ci.theme.paths.themeRoot}} && npm ci && npx eslint resources/ --config eslint.config.mjs --fix-dry-run && npx stylelint "resources/**/*.{css,scss}"
|
|
34
|
+
{{/if}}
|
|
35
|
+
|
|
36
|
+
{{#if ci.lint.mu_plugin}}
|
|
37
|
+
lint-mu-plugin: name: Lint MU Plugin runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{'{{'}}
|
|
38
|
+
env.PHP_VERSION
|
|
39
|
+
{{'}}'}}
|
|
40
|
+
- name: Lint MU Plugin PHP run: | cd content/mu-plugins/{{mu_plugin_name}} && composer install --no-dev && ./vendor/bin/pint --test
|
|
41
|
+
{{/if}}
|
|
42
|
+
|
|
43
|
+
{{#if ci.lint.plugin}}
|
|
44
|
+
lint-plugin: name: Lint Plugin runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{'{{'}}
|
|
45
|
+
env.PHP_VERSION
|
|
46
|
+
{{'}}'}}
|
|
47
|
+
- name: Lint Plugin PHP run: | cd content/plugins/{{plugin_name}} && composer install --no-dev && ./vendor/bin/pint --test
|
|
48
|
+
{{/if}}
|
|
49
|
+
|
|
50
|
+
{{#if ci.lint.blank_theme}}
|
|
51
|
+
lint-blank-theme: name: Lint Blank Theme runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: ${{'{{'}}
|
|
52
|
+
env.NODE_VERSION
|
|
53
|
+
{{'}}'}}
|
|
54
|
+
- name: Lint Blank Theme run: | cd content/themes/{{blank_theme_name}} && npm ci && npx eslint src/js/ --config eslint.config.mjs --fix-dry-run && npx stylelint "src/scss/**/*.scss"
|
|
55
|
+
{{/if}}
|
|
56
|
+
|
|
29
57
|
test-basic: name: Tests runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 -
|
|
30
58
|
name: Setup Node uses: actions/setup-node@v4 with: node-version: ${{'{{'}}
|
|
31
59
|
env.NODE_VERSION
|
|
@@ -46,4 +74,4 @@ env.NODE_VERSION
|
|
|
46
74
|
{{/if}}
|
|
47
75
|
|
|
48
76
|
env: PHP_VERSION: "{{phpVersion}}" NODE_VERSION: "{{ci.nodeVersion}}" WORDPRESS_VERSION: "{{wpCoreVersion}}"
|
|
49
|
-
PROJECT_NAME: "{{projectName}}"
|
|
77
|
+
PROJECT_NAME: "{{projectName}}"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Job reutilizável — Docker Build & Push to Container Registry
|
|
2
|
+
#
|
|
3
|
+
# Como usar no .gitlab-ci.yml principal:
|
|
4
|
+
#
|
|
5
|
+
# include:
|
|
6
|
+
# - local: '.gitlab/ci/deploy-docker.yml'
|
|
7
|
+
#
|
|
8
|
+
# stages:
|
|
9
|
+
# - deploy
|
|
10
|
+
#
|
|
11
|
+
# Variáveis necessárias (Settings → CI/CD → Variables):
|
|
12
|
+
# CI_REGISTRY_USER — automático para o GitLab Container Registry
|
|
13
|
+
# CI_REGISTRY_PASSWORD — automático para o GitLab Container Registry
|
|
14
|
+
# CI_REGISTRY_IMAGE — automático: registry.gitlab.com/<grupo>/<projeto>
|
|
15
|
+
#
|
|
16
|
+
# Para registry externo (Docker Hub, GHCR), sobrescreva as variáveis acima.
|
|
17
|
+
|
|
18
|
+
deploy:docker:
|
|
19
|
+
stage: deploy
|
|
20
|
+
image: docker:latest
|
|
21
|
+
services:
|
|
22
|
+
- docker:dind
|
|
23
|
+
variables:
|
|
24
|
+
DOCKER_TLS_CERTDIR: '/certs'
|
|
25
|
+
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
|
26
|
+
IMAGE_LATEST: $CI_REGISTRY_IMAGE:latest
|
|
27
|
+
before_script:
|
|
28
|
+
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
|
|
29
|
+
script:
|
|
30
|
+
- docker build --tag "$IMAGE_TAG" --tag "$IMAGE_LATEST" .
|
|
31
|
+
- docker push "$IMAGE_TAG"
|
|
32
|
+
- docker push "$IMAGE_LATEST"
|
|
33
|
+
rules:
|
|
34
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
35
|
+
- if: $CI_COMMIT_TAG
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Job reutilizável — SSH Deploy via rsync
|
|
2
|
+
#
|
|
3
|
+
# Como usar no .gitlab-ci.yml principal:
|
|
4
|
+
#
|
|
5
|
+
# include:
|
|
6
|
+
# - local: '.gitlab/ci/deploy-ssh.yml'
|
|
7
|
+
#
|
|
8
|
+
# stages:
|
|
9
|
+
# - build
|
|
10
|
+
# - deploy
|
|
11
|
+
#
|
|
12
|
+
# Variáveis necessárias (Settings → CI/CD → Variables):
|
|
13
|
+
# SSH_PRIVATE_KEY — chave SSH privada (sem passphrase para CI)
|
|
14
|
+
# SSH_KNOWN_HOSTS — saída de: ssh-keyscan -H <host>
|
|
15
|
+
# DEPLOY_HOST — endereço do servidor (ex: meu-servidor.example.com)
|
|
16
|
+
# DEPLOY_USER — usuário SSH (ex: deploy)
|
|
17
|
+
# DEPLOY_PATH — caminho absoluto no servidor (ex: /var/www/html)
|
|
18
|
+
#
|
|
19
|
+
# O rsync usa --no-perms --no-owner --no-group, portanto não altera
|
|
20
|
+
# permissões nem proprietários existentes no servidor de destino.
|
|
21
|
+
|
|
22
|
+
.ssh-agent-setup: &ssh-agent-setup
|
|
23
|
+
- eval "$(ssh-agent -s)"
|
|
24
|
+
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
25
|
+
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
|
26
|
+
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
|
|
27
|
+
|
|
28
|
+
build:deps:
|
|
29
|
+
stage: build
|
|
30
|
+
image: composer:latest
|
|
31
|
+
script:
|
|
32
|
+
- composer install --no-dev --optimize-autoloader --no-interaction
|
|
33
|
+
artifacts:
|
|
34
|
+
paths:
|
|
35
|
+
- vendor/
|
|
36
|
+
expire_in: 1 hour
|
|
37
|
+
rules:
|
|
38
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
39
|
+
|
|
40
|
+
build:assets:
|
|
41
|
+
stage: build
|
|
42
|
+
image: node:{{nodeVersion}}-alpine
|
|
43
|
+
before_script:
|
|
44
|
+
- apk add --no-cache git
|
|
45
|
+
script:
|
|
46
|
+
- |
|
|
47
|
+
{{#if ci.theme.paths.themeRoot}}
|
|
48
|
+
if [ -d "{{ci.theme.paths.themeRoot}}" ]; then
|
|
49
|
+
npm install --prefix "{{ci.theme.paths.themeRoot}}"
|
|
50
|
+
npm run build --prefix "{{ci.theme.paths.themeRoot}}"
|
|
51
|
+
fi
|
|
52
|
+
{{else}}
|
|
53
|
+
if [ -f package.json ]; then npm ci && npm run build --if-present; fi
|
|
54
|
+
{{/if}}
|
|
55
|
+
artifacts:
|
|
56
|
+
paths:
|
|
57
|
+
- content/themes/*/public/
|
|
58
|
+
- public/
|
|
59
|
+
expire_in: 1 hour
|
|
60
|
+
rules:
|
|
61
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
62
|
+
|
|
63
|
+
deploy:ssh:
|
|
64
|
+
stage: deploy
|
|
65
|
+
image: alpine:latest
|
|
66
|
+
needs:
|
|
67
|
+
- job: build:deps
|
|
68
|
+
- job: build:assets
|
|
69
|
+
before_script:
|
|
70
|
+
- apk add --no-cache rsync openssh-client
|
|
71
|
+
- *ssh-agent-setup
|
|
72
|
+
script:
|
|
73
|
+
- |
|
|
74
|
+
rsync -avz --delete \
|
|
75
|
+
--no-perms --no-owner --no-group \
|
|
76
|
+
--exclude='.git' \
|
|
77
|
+
--exclude='.env' \
|
|
78
|
+
--exclude='node_modules' \
|
|
79
|
+
--exclude='node_modules/.cache' \
|
|
80
|
+
./ \
|
|
81
|
+
"$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/"
|
|
82
|
+
rules:
|
|
83
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{{#if ci.lint.blank_theme}}
|
|
2
|
+
lint:blank-theme:eslint:
|
|
3
|
+
stage: lint
|
|
4
|
+
image: node:${NODE_VERSION}-alpine
|
|
5
|
+
variables:
|
|
6
|
+
THEME_DIR: content/themes/{{blank_theme_name}}
|
|
7
|
+
before_script:
|
|
8
|
+
- apk add --no-cache git
|
|
9
|
+
script:
|
|
10
|
+
- cd $THEME_DIR
|
|
11
|
+
- npm ci --cache .npm --prefer-offline
|
|
12
|
+
- npx eslint src/js/ --config eslint.config.mjs --fix-dry-run
|
|
13
|
+
rules:
|
|
14
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
15
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
16
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
17
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
18
|
+
|
|
19
|
+
lint:blank-theme:stylelint:
|
|
20
|
+
stage: lint
|
|
21
|
+
image: node:${NODE_VERSION}-alpine
|
|
22
|
+
variables:
|
|
23
|
+
THEME_DIR: content/themes/{{blank_theme_name}}
|
|
24
|
+
before_script:
|
|
25
|
+
- apk add --no-cache git
|
|
26
|
+
script:
|
|
27
|
+
- cd $THEME_DIR
|
|
28
|
+
- npm ci --cache .npm --prefer-offline
|
|
29
|
+
- npx stylelint "src/scss/**/*.scss"
|
|
30
|
+
rules:
|
|
31
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
32
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
33
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
34
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
35
|
+
{{/if}}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{{#if ci.lint.mu_plugin}}
|
|
2
|
+
lint:mu-plugin:pint:
|
|
3
|
+
stage: lint
|
|
4
|
+
image: php:${PHP_VERSION}-cli
|
|
5
|
+
variables:
|
|
6
|
+
PLUGIN_DIR: content/mu-plugins/{{mu_plugin_name}}
|
|
7
|
+
before_script:
|
|
8
|
+
- apt-get update -qq && apt-get install -qq --no-install-recommends git unzip
|
|
9
|
+
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
10
|
+
script:
|
|
11
|
+
- cd $PLUGIN_DIR
|
|
12
|
+
- composer install --no-dev
|
|
13
|
+
- ./vendor/bin/pint --test
|
|
14
|
+
rules:
|
|
15
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
16
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
17
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
18
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
19
|
+
{{/if}}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{{#if ci.lint.plugin}}
|
|
2
|
+
lint:plugin:pint:
|
|
3
|
+
stage: lint
|
|
4
|
+
image: php:${PHP_VERSION}-cli
|
|
5
|
+
variables:
|
|
6
|
+
PLUGIN_DIR: content/plugins/{{plugin_name}}
|
|
7
|
+
before_script:
|
|
8
|
+
- apt-get update -qq && apt-get install -qq --no-install-recommends git unzip
|
|
9
|
+
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
10
|
+
script:
|
|
11
|
+
- cd $PLUGIN_DIR
|
|
12
|
+
- composer install --no-dev
|
|
13
|
+
- ./vendor/bin/pint --test
|
|
14
|
+
rules:
|
|
15
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
16
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
17
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
18
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
19
|
+
{{/if}}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{{#if ci.lint.sage}}
|
|
2
|
+
lint:sage:eslint:
|
|
3
|
+
stage: lint
|
|
4
|
+
image: node:${NODE_VERSION}-alpine
|
|
5
|
+
before_script:
|
|
6
|
+
- apk add --no-cache git
|
|
7
|
+
script:
|
|
8
|
+
- cd {{ci.theme.paths.themeRoot}}
|
|
9
|
+
- npm ci --cache .npm --prefer-offline
|
|
10
|
+
- npx eslint resources/ --config eslint.config.mjs --fix-dry-run
|
|
11
|
+
rules:
|
|
12
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
13
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
14
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
15
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
16
|
+
|
|
17
|
+
lint:sage:stylelint:
|
|
18
|
+
stage: lint
|
|
19
|
+
image: node:${NODE_VERSION}-alpine
|
|
20
|
+
before_script:
|
|
21
|
+
- apk add --no-cache git
|
|
22
|
+
script:
|
|
23
|
+
- cd {{ci.theme.paths.themeRoot}}
|
|
24
|
+
- npm ci --cache .npm --prefer-offline
|
|
25
|
+
- npx stylelint "resources/**/*.{css,scss}"
|
|
26
|
+
rules:
|
|
27
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
28
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
29
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
30
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
31
|
+
|
|
32
|
+
lint:sage:pint:
|
|
33
|
+
stage: lint
|
|
34
|
+
image: php:${PHP_VERSION}-cli
|
|
35
|
+
before_script:
|
|
36
|
+
- apt-get update -qq && apt-get install -qq --no-install-recommends git unzip
|
|
37
|
+
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
38
|
+
script:
|
|
39
|
+
- cd {{ci.theme.paths.themeRoot}}
|
|
40
|
+
- composer install --no-dev --optimize-autoloader
|
|
41
|
+
- ./vendor/bin/pint --test
|
|
42
|
+
rules:
|
|
43
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
44
|
+
- if: $CI_COMMIT_BRANCH == "main"
|
|
45
|
+
- if: $CI_COMMIT_BRANCH == "staging"
|
|
46
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
47
|
+
{{/if}}
|