@kaikybrofc/omnizap-system 2.1.8
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/.env.example +534 -0
- package/LICENSE +21 -0
- package/README.md +431 -0
- package/RELEASE-v2.1.2.md +83 -0
- package/app/config/adminIdentity.js +87 -0
- package/app/config/baileysConfig.js +693 -0
- package/app/config/groupUtils.js +388 -0
- package/app/connection/socketController.js +992 -0
- package/app/controllers/messageController.js +354 -0
- package/app/modules/adminModule/groupCommandHandlers.js +1294 -0
- package/app/modules/adminModule/groupEventHandlers.js +355 -0
- package/app/modules/aiModule/catCommand.js +1006 -0
- package/app/modules/broadcastModule/noticeCommand.js +416 -0
- package/app/modules/gameModule/diceCommand.js +67 -0
- package/app/modules/menuModule/common.js +311 -0
- package/app/modules/menuModule/menus.js +59 -0
- package/app/modules/playModule/playCommand.js +1615 -0
- package/app/modules/quoteModule/quoteCommand.js +851 -0
- package/app/modules/rpgPokemonModule/rpgBattleCanvasRenderer.js +786 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.js +2082 -0
- package/app/modules/rpgPokemonModule/rpgBattleService.test.js +760 -0
- package/app/modules/rpgPokemonModule/rpgEvolutionUtils.js +22 -0
- package/app/modules/rpgPokemonModule/rpgPokemonCommand.js +172 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.js +192 -0
- package/app/modules/rpgPokemonModule/rpgPokemonDomain.test.js +93 -0
- package/app/modules/rpgPokemonModule/rpgPokemonEvolution.test.js +46 -0
- package/app/modules/rpgPokemonModule/rpgPokemonMessages.js +746 -0
- package/app/modules/rpgPokemonModule/rpgPokemonRepository.js +1859 -0
- package/app/modules/rpgPokemonModule/rpgPokemonService.js +6738 -0
- package/app/modules/rpgPokemonModule/rpgProfileCanvasRenderer.js +354 -0
- package/app/modules/statsModule/globalRankingCommand.js +65 -0
- package/app/modules/statsModule/noMessageCommand.js +288 -0
- package/app/modules/statsModule/rankingCommand.js +60 -0
- package/app/modules/statsModule/rankingCommon.js +889 -0
- package/app/modules/stickerModule/addStickerMetadata.js +239 -0
- package/app/modules/stickerModule/convertToWebp.js +390 -0
- package/app/modules/stickerModule/stickerCommand.js +454 -0
- package/app/modules/stickerModule/stickerConvertCommand.js +156 -0
- package/app/modules/stickerModule/stickerTextCommand.js +657 -0
- package/app/modules/stickerPackModule/autoPackCollectorRuntime.js +20 -0
- package/app/modules/stickerPackModule/autoPackCollectorService.js +284 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.js +466 -0
- package/app/modules/stickerPackModule/semanticReclassificationEngine.test.js +88 -0
- package/app/modules/stickerPackModule/semanticThemeClusterService.js +571 -0
- package/app/modules/stickerPackModule/stickerAssetClassificationRepository.js +449 -0
- package/app/modules/stickerPackModule/stickerAssetRepository.js +400 -0
- package/app/modules/stickerPackModule/stickerAssetReprocessQueueRepository.js +180 -0
- package/app/modules/stickerPackModule/stickerAutoPackByTagsRuntime.js +4078 -0
- package/app/modules/stickerPackModule/stickerClassificationBackgroundRuntime.js +598 -0
- package/app/modules/stickerPackModule/stickerClassificationService.js +588 -0
- package/app/modules/stickerPackModule/stickerMarketplaceDriftService.js +102 -0
- package/app/modules/stickerPackModule/stickerPackCatalogHttp.js +7506 -0
- package/app/modules/stickerPackModule/stickerPackCommandHandlers.js +1095 -0
- package/app/modules/stickerPackModule/stickerPackEngagementRepository.js +108 -0
- package/app/modules/stickerPackModule/stickerPackErrors.js +30 -0
- package/app/modules/stickerPackModule/stickerPackInteractionEventRepository.js +110 -0
- package/app/modules/stickerPackModule/stickerPackItemRepository.js +440 -0
- package/app/modules/stickerPackModule/stickerPackMarketplaceService.js +337 -0
- package/app/modules/stickerPackModule/stickerPackMessageService.js +296 -0
- package/app/modules/stickerPackModule/stickerPackRepository.js +442 -0
- package/app/modules/stickerPackModule/stickerPackService.js +788 -0
- package/app/modules/stickerPackModule/stickerPackServiceRuntime.js +51 -0
- package/app/modules/stickerPackModule/stickerPackUtils.js +97 -0
- package/app/modules/stickerPackModule/stickerStorageService.js +507 -0
- package/app/modules/stickerPackModule/stickerWorkerPipelineRuntime.js +233 -0
- package/app/modules/stickerPackModule/stickerWorkerTaskQueueRepository.js +205 -0
- package/app/modules/systemMetricsModule/pingCommand.js +421 -0
- package/app/modules/tiktokModule/tiktokCommand.js +798 -0
- package/app/modules/userModule/userCommand.js +1217 -0
- package/app/modules/waifuPicsModule/waifuPicsCommand.js +177 -0
- package/app/observability/metrics.js +734 -0
- package/app/services/captchaService.js +492 -0
- package/app/services/dbWriteQueue.js +572 -0
- package/app/services/groupMetadataService.js +279 -0
- package/app/services/lidMapService.js +663 -0
- package/app/services/messagePersistenceService.js +56 -0
- package/app/services/newsBroadcastService.js +351 -0
- package/app/services/pokeApiService.js +398 -0
- package/app/services/queueUtils.js +57 -0
- package/app/services/socketState.js +7 -0
- package/app/store/aiPromptStore.js +38 -0
- package/app/store/groupConfigStore.js +58 -0
- package/app/store/premiumUserStore.js +36 -0
- package/app/utils/antiLink/antiLinkModule.js +804 -0
- package/app/utils/http/getImageBufferModule.js +18 -0
- package/app/utils/json/jsonSanitizer.js +113 -0
- package/app/utils/json/jsonSanitizer.test.js +40 -0
- package/app/utils/logger/loggerModule.js +262 -0
- package/app/utils/systemMetrics/systemMetricsModule.js +91 -0
- package/database/index.js +2052 -0
- package/database/init.js +516 -0
- package/database/migrations/20260203_0001_sticker_packs.sql +54 -0
- package/database/migrations/20260210_0003_rpg_pokemon.sql +58 -0
- package/database/migrations/20260210_0004_rpg_shiny_biome.sql +9 -0
- package/database/migrations/20260210_0005_rpg_missions.sql +14 -0
- package/database/migrations/20260210_0006_rpg_world_pokedex_traits.sql +27 -0
- package/database/migrations/20260210_0007_rpg_raid_pvp.sql +56 -0
- package/database/migrations/20260210_0008_rpg_social_system.sql +195 -0
- package/database/migrations/20260211_0009_rpg_social_xp.sql +36 -0
- package/database/migrations/20260222_0010_remove_message_xp.sql +2 -0
- package/database/migrations/20260226_0011_sticker_asset_classification.sql +17 -0
- package/database/migrations/20260226_0012_sticker_pack_engagement.sql +16 -0
- package/database/migrations/20260226_0013_sticker_marketplace_intelligence.sql +19 -0
- package/database/migrations/20260226_0014_sticker_pack_publish_flow.sql +30 -0
- package/database/migrations/20260226_0014_sticker_worker_queues.sql +42 -0
- package/database/migrations/20260226_0015_sticker_auto_pack_curation_integrity.sql +18 -0
- package/database/migrations/20260226_0016_sticker_web_google_auth_persistence.sql +34 -0
- package/database/migrations/20260226_0017_sticker_web_admin_ban.sql +22 -0
- package/database/migrations/20260226_0018_sticker_web_admin_moderator.sql +18 -0
- package/database/migrations/20260227_0019_sticker_classification_v2_signals.sql +12 -0
- package/database/migrations/20260227_0020_semantic_theme_clusters.sql +35 -0
- package/docker-compose.yml +103 -0
- package/ecosystem.prod.config.cjs +35 -0
- package/eslint.config.js +61 -0
- package/index.js +437 -0
- package/ml/clip_classifier/Dockerfile +16 -0
- package/ml/clip_classifier/README.md +120 -0
- package/ml/clip_classifier/adaptive_scoring.py +40 -0
- package/ml/clip_classifier/classifier.py +654 -0
- package/ml/clip_classifier/embedding_store.py +481 -0
- package/ml/clip_classifier/env_loader.py +15 -0
- package/ml/clip_classifier/llm_label_expander.py +144 -0
- package/ml/clip_classifier/main.py +213 -0
- package/ml/clip_classifier/requirements.txt +10 -0
- package/ml/clip_classifier/similarity_engine.py +74 -0
- package/observability/alert-rules.yml +60 -0
- package/observability/grafana/dashboards/omnizap-mysql.json +136 -0
- package/observability/grafana/dashboards/omnizap-overview.json +170 -0
- package/observability/grafana/provisioning/dashboards/dashboards.yml +11 -0
- package/observability/grafana/provisioning/datasources/datasources.yml +15 -0
- package/observability/loki-config.yml +38 -0
- package/observability/mysql-exporter.cnf +5 -0
- package/observability/mysql-setup.sql +46 -0
- package/observability/prometheus.yml +32 -0
- package/observability/promtail-config.yml +84 -0
- package/package.json +109 -0
- package/public/api-docs/index.html +144 -0
- package/public/css/github-project-panel.css +297 -0
- package/public/css/stickers-admin.css +1272 -0
- package/public/css/styles.css +671 -0
- package/public/index.html +1311 -0
- package/public/js/apps/apiDocsApp.js +310 -0
- package/public/js/apps/createPackApp.js +2069 -0
- package/public/js/apps/homeApp.js +396 -0
- package/public/js/apps/stickersAdminApp.js +1744 -0
- package/public/js/apps/stickersApp.js +4830 -0
- package/public/js/catalog.js +1019 -0
- package/public/js/github-panel/components/CommitList.js +34 -0
- package/public/js/github-panel/components/ErrorState.js +16 -0
- package/public/js/github-panel/components/GithubProjectPanel.js +106 -0
- package/public/js/github-panel/components/ReleaseList.js +38 -0
- package/public/js/github-panel/components/SkeletonPanel.js +22 -0
- package/public/js/github-panel/components/StatCard.js +15 -0
- package/public/js/github-panel/index.js +15 -0
- package/public/js/github-panel/useGithubRepoData.js +154 -0
- package/public/js/github-panel/vendor/react.js +11 -0
- package/public/js/runtime/react-runtime.js +19 -0
- package/public/licenca/index.html +106 -0
- package/public/stickers/admin/index.html +23 -0
- package/public/stickers/create/index.html +47 -0
- package/public/stickers/index.html +48 -0
- package/public/termos-de-uso/index.html +125 -0
- package/scripts/cache-bust.mjs +107 -0
- package/scripts/deploy.sh +458 -0
- package/scripts/github-deploy-notify.mjs +174 -0
- package/scripts/release.sh +129 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import dotenv from 'dotenv';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
12
|
+
|
|
13
|
+
dotenv.config({ path: path.join(projectRoot, '.env') });
|
|
14
|
+
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
const action = String(args[0] || '').trim();
|
|
17
|
+
|
|
18
|
+
const getArg = (flag, fallback = '') => {
|
|
19
|
+
const index = args.indexOf(flag);
|
|
20
|
+
if (index === -1) return fallback;
|
|
21
|
+
return String(args[index + 1] || fallback).trim();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const env = (...keys) => {
|
|
25
|
+
for (const key of keys) {
|
|
26
|
+
const value = process.env[key];
|
|
27
|
+
if (value && String(value).trim()) return String(value).trim();
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const parseRepoFromRemote = () => {
|
|
33
|
+
try {
|
|
34
|
+
const remoteUrl = execSync('git config --get remote.origin.url', {
|
|
35
|
+
cwd: projectRoot,
|
|
36
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
37
|
+
})
|
|
38
|
+
.toString('utf8')
|
|
39
|
+
.trim();
|
|
40
|
+
if (!remoteUrl) return '';
|
|
41
|
+
|
|
42
|
+
const httpsMatch = remoteUrl.match(/github\.com\/([^/]+\/[^/.]+)(?:\.git)?$/i);
|
|
43
|
+
if (httpsMatch?.[1]) return httpsMatch[1];
|
|
44
|
+
|
|
45
|
+
const sshMatch = remoteUrl.match(/github\.com:([^/]+\/[^/.]+)(?:\.git)?$/i);
|
|
46
|
+
if (sshMatch?.[1]) return sshMatch[1];
|
|
47
|
+
} catch {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
return '';
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const currentRef = () => {
|
|
54
|
+
const explicitRef = env('DEPLOY_GITHUB_REF');
|
|
55
|
+
if (explicitRef) return explicitRef;
|
|
56
|
+
try {
|
|
57
|
+
return execSync('git rev-parse HEAD', {
|
|
58
|
+
cwd: projectRoot,
|
|
59
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
60
|
+
})
|
|
61
|
+
.toString('utf8')
|
|
62
|
+
.trim();
|
|
63
|
+
} catch {
|
|
64
|
+
return 'main';
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const token = env('DEPLOY_GITHUB_TOKEN', 'GITHUB_TOKEN', 'GH_TOKEN');
|
|
69
|
+
const repository = env('DEPLOY_GITHUB_REPO', 'GITHUB_REPOSITORY') || parseRepoFromRemote();
|
|
70
|
+
const environment = getArg('--environment', env('DEPLOY_GITHUB_ENVIRONMENT') || 'production');
|
|
71
|
+
const environmentUrl = getArg('--environment-url', env('DEPLOY_GITHUB_ENV_URL', 'DEPLOY_VERIFY_URL') || '');
|
|
72
|
+
const logUrl = getArg('--log-url', env('DEPLOY_GITHUB_LOG_URL', 'DEPLOY_VERIFY_URL') || environmentUrl);
|
|
73
|
+
const buildId = getArg('--build-id', env('DEPLOY_BUILD_ID') || '');
|
|
74
|
+
const deploymentId = getArg('--deployment-id', '');
|
|
75
|
+
const state = getArg('--state', '');
|
|
76
|
+
const description = getArg('--description', '');
|
|
77
|
+
|
|
78
|
+
if (!action || !['start', 'status'].includes(action)) {
|
|
79
|
+
console.error('Uso: node scripts/github-deploy-notify.mjs <start|status> [opções]');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!token || !repository) {
|
|
84
|
+
console.error('GitHub deploy notify ignorado: token ou repositório não configurado.');
|
|
85
|
+
process.exit(2);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const [repoOwnerRaw, repoNameRaw] = repository.split('/', 2);
|
|
89
|
+
const repoOwner = String(repoOwnerRaw || '').trim();
|
|
90
|
+
const repoName = String(repoNameRaw || '').trim();
|
|
91
|
+
if (!repoOwner || !repoName) {
|
|
92
|
+
console.error('GitHub deploy notify ignorado: formato de repositório inválido (esperado owner/repo).');
|
|
93
|
+
process.exit(2);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const headers = {
|
|
97
|
+
Accept: 'application/vnd.github+json',
|
|
98
|
+
Authorization: `Bearer ${token}`,
|
|
99
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
'User-Agent': 'omnizap-deploy-script',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const request = async (url, method, payload) => {
|
|
105
|
+
const response = await fetch(url, {
|
|
106
|
+
method,
|
|
107
|
+
headers,
|
|
108
|
+
body: payload ? JSON.stringify(payload) : undefined,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const raw = await response.text();
|
|
112
|
+
let data = null;
|
|
113
|
+
try {
|
|
114
|
+
data = raw ? JSON.parse(raw) : null;
|
|
115
|
+
} catch {
|
|
116
|
+
data = null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
const message = data?.message || raw || response.statusText;
|
|
121
|
+
throw new Error(`GitHub API ${response.status}: ${message}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return data;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const run = async () => {
|
|
128
|
+
const baseUrl = `https://api.github.com/repos/${encodeURIComponent(repoOwner)}/${encodeURIComponent(repoName)}`;
|
|
129
|
+
|
|
130
|
+
if (action === 'start') {
|
|
131
|
+
const startDescription = description || `Deploy OmniZap ${buildId || new Date().toISOString()}`;
|
|
132
|
+
const deployment = await request(`${baseUrl}/deployments`, 'POST', {
|
|
133
|
+
ref: currentRef(),
|
|
134
|
+
task: 'deploy',
|
|
135
|
+
auto_merge: false,
|
|
136
|
+
required_contexts: [],
|
|
137
|
+
environment,
|
|
138
|
+
description: startDescription,
|
|
139
|
+
transient_environment: environment !== 'production',
|
|
140
|
+
production_environment: environment === 'production',
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
await request(`${baseUrl}/deployments/${deployment.id}/statuses`, 'POST', {
|
|
144
|
+
state: 'in_progress',
|
|
145
|
+
environment,
|
|
146
|
+
environment_url: environmentUrl || undefined,
|
|
147
|
+
log_url: logUrl || undefined,
|
|
148
|
+
auto_inactive: false,
|
|
149
|
+
description: `Deploy iniciado (${buildId || 'manual'})`,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
process.stdout.write(String(deployment.id));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!deploymentId || !state) {
|
|
157
|
+
throw new Error('Ação status requer --deployment-id e --state.');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const finalDescription = description || `Deploy ${state} (${buildId || 'manual'})`;
|
|
161
|
+
await request(`${baseUrl}/deployments/${deploymentId}/statuses`, 'POST', {
|
|
162
|
+
state,
|
|
163
|
+
environment,
|
|
164
|
+
environment_url: environmentUrl || undefined,
|
|
165
|
+
log_url: logUrl || undefined,
|
|
166
|
+
auto_inactive: state === 'success',
|
|
167
|
+
description: finalDescription,
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
run().catch((error) => {
|
|
172
|
+
console.error(error?.message || error);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
RELEASE_TYPE="${RELEASE_TYPE:-patch}"
|
|
6
|
+
RELEASE_GIT_AUTO_COMMIT="${RELEASE_GIT_AUTO_COMMIT:-1}"
|
|
7
|
+
RELEASE_GIT_AUTO_PUSH="${RELEASE_GIT_AUTO_PUSH:-1}"
|
|
8
|
+
RELEASE_GIT_REMOTE="${RELEASE_GIT_REMOTE:-origin}"
|
|
9
|
+
RELEASE_GIT_BRANCH="${RELEASE_GIT_BRANCH:-}"
|
|
10
|
+
RELEASE_GIT_PRE_COMMIT_MESSAGE="${RELEASE_GIT_PRE_COMMIT_MESSAGE:-chore(release): auto-commit before release}"
|
|
11
|
+
RELEASE_GIT_COMMIT_VERSION="${RELEASE_GIT_COMMIT_VERSION:-1}"
|
|
12
|
+
RELEASE_GIT_VERSION_COMMIT_PREFIX="${RELEASE_GIT_VERSION_COMMIT_PREFIX:-chore(release): v}"
|
|
13
|
+
|
|
14
|
+
case "$RELEASE_TYPE" in
|
|
15
|
+
patch|minor|major|prepatch|preminor|premajor|prerelease)
|
|
16
|
+
;;
|
|
17
|
+
*)
|
|
18
|
+
printf '[release] RELEASE_TYPE inválido: %s\n' "$RELEASE_TYPE" >&2
|
|
19
|
+
printf '[release] Valores permitidos: patch, minor, major, prepatch, preminor, premajor, prerelease\n' >&2
|
|
20
|
+
exit 1
|
|
21
|
+
;;
|
|
22
|
+
esac
|
|
23
|
+
|
|
24
|
+
log() {
|
|
25
|
+
printf '[release] %s\n' "$*"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
require_cmd() {
|
|
29
|
+
if ! command -v "$1" >/dev/null 2>&1; then
|
|
30
|
+
printf '[release] comando ausente: %s\n' "$1" >&2
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
resolve_branch() {
|
|
36
|
+
if [ -n "$RELEASE_GIT_BRANCH" ]; then
|
|
37
|
+
printf '%s' "$RELEASE_GIT_BRANCH"
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
local branch=""
|
|
42
|
+
branch="$(cd "$PROJECT_ROOT" && git symbolic-ref --quiet --short HEAD 2>/dev/null || true)"
|
|
43
|
+
if [ -z "$branch" ]; then
|
|
44
|
+
branch="$(cd "$PROJECT_ROOT" && git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
|
|
45
|
+
fi
|
|
46
|
+
if [ "$branch" = "HEAD" ]; then
|
|
47
|
+
branch=""
|
|
48
|
+
fi
|
|
49
|
+
printf '%s' "$branch"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
commit_and_push_if_dirty() {
|
|
53
|
+
local commit_message="$1"
|
|
54
|
+
|
|
55
|
+
if [ "$RELEASE_GIT_AUTO_COMMIT" != "1" ]; then
|
|
56
|
+
return 0
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
local git_status=""
|
|
60
|
+
git_status="$(cd "$PROJECT_ROOT" && git status --porcelain --untracked-files=normal)"
|
|
61
|
+
if [ -z "$git_status" ]; then
|
|
62
|
+
return 0
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
log "Alterações não commitadas detectadas. Criando commit automático."
|
|
66
|
+
(
|
|
67
|
+
cd "$PROJECT_ROOT"
|
|
68
|
+
git add -A
|
|
69
|
+
if git diff --cached --quiet; then
|
|
70
|
+
exit 0
|
|
71
|
+
fi
|
|
72
|
+
git commit -m "$commit_message" >/dev/null
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if [ "$RELEASE_GIT_AUTO_PUSH" = "1" ]; then
|
|
76
|
+
local branch=""
|
|
77
|
+
branch="$(resolve_branch)"
|
|
78
|
+
if [ -z "$branch" ]; then
|
|
79
|
+
printf '[release] Branch atual indefinida (detached HEAD). Defina RELEASE_GIT_BRANCH para push automático.\n' >&2
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|
|
82
|
+
log "Enviando commit para $RELEASE_GIT_REMOTE/$branch"
|
|
83
|
+
(cd "$PROJECT_ROOT" && git push "$RELEASE_GIT_REMOTE" "$branch")
|
|
84
|
+
fi
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
require_cmd git
|
|
88
|
+
require_cmd npm
|
|
89
|
+
|
|
90
|
+
if ! (cd "$PROJECT_ROOT" && git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
|
91
|
+
printf '[release] este diretório não é um repositório git válido.\n' >&2
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
commit_and_push_if_dirty "$RELEASE_GIT_PRE_COMMIT_MESSAGE"
|
|
96
|
+
|
|
97
|
+
current_version="$(cd "$PROJECT_ROOT" && npm pkg get version | tr -d '"[:space:]')"
|
|
98
|
+
log "Versão atual: $current_version"
|
|
99
|
+
log "Aplicando bump: $RELEASE_TYPE"
|
|
100
|
+
|
|
101
|
+
(cd "$PROJECT_ROOT" && npm version "$RELEASE_TYPE" --no-git-tag-version >/dev/null)
|
|
102
|
+
|
|
103
|
+
new_version="$(cd "$PROJECT_ROOT" && npm pkg get version | tr -d '"[:space:]')"
|
|
104
|
+
log "Nova versão: $new_version"
|
|
105
|
+
|
|
106
|
+
log "Executando deploy com publish de package"
|
|
107
|
+
|
|
108
|
+
if ! (
|
|
109
|
+
cd "$PROJECT_ROOT"
|
|
110
|
+
DEPLOY_PACKAGE_STEP="${DEPLOY_PACKAGE_STEP:-1}" \
|
|
111
|
+
DEPLOY_PACKAGE_PUBLISH="${DEPLOY_PACKAGE_PUBLISH:-1}" \
|
|
112
|
+
DEPLOY_PACKAGE_PUBLISH_SECONDARY="${DEPLOY_PACKAGE_PUBLISH_SECONDARY:-1}" \
|
|
113
|
+
DEPLOY_PACKAGE_SECONDARY_REGISTRY="${DEPLOY_PACKAGE_SECONDARY_REGISTRY:-https://registry.npmjs.org}" \
|
|
114
|
+
DEPLOY_PACKAGE_SECONDARY_ACCESS="${DEPLOY_PACKAGE_SECONDARY_ACCESS:-public}" \
|
|
115
|
+
DEPLOY_PACKAGE_INSTALL="${DEPLOY_PACKAGE_INSTALL:-0}" \
|
|
116
|
+
DEPLOY_PACKAGE_TEST="${DEPLOY_PACKAGE_TEST:-0}" \
|
|
117
|
+
DEPLOY_PACKAGE_PACK="${DEPLOY_PACKAGE_PACK:-1}" \
|
|
118
|
+
npm run deploy
|
|
119
|
+
); then
|
|
120
|
+
log "Deploy/release falhou. Revertendo versão para $current_version"
|
|
121
|
+
(cd "$PROJECT_ROOT" && npm version "$current_version" --no-git-tag-version >/dev/null)
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
if [ "$RELEASE_GIT_COMMIT_VERSION" = "1" ]; then
|
|
126
|
+
commit_and_push_if_dirty "${RELEASE_GIT_VERSION_COMMIT_PREFIX}${new_version}"
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
log "Release concluída: $new_version"
|