maiass 5.10.1 → 5.10.4
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.
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import colors from './colors.js';
|
|
5
|
+
import { SYMBOLS } from './symbols.js';
|
|
6
|
+
|
|
7
|
+
// Resolve the templates directory relative to this file (works after npm install -g)
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const TEMPLATES_DIR = path.join(__dirname, '..', 'templates', 'ci');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copy a CI template file to the target path in the current project.
|
|
13
|
+
* Creates intermediate directories if needed.
|
|
14
|
+
* Prompts before overwriting an existing file.
|
|
15
|
+
*/
|
|
16
|
+
function copyTemplate(templateFile, targetPath, label) {
|
|
17
|
+
const src = path.join(TEMPLATES_DIR, templateFile);
|
|
18
|
+
|
|
19
|
+
// Verify the template exists in the package
|
|
20
|
+
if (!fs.existsSync(src)) {
|
|
21
|
+
console.error(colors.Red(`${SYMBOLS.CROSS} Template not found: ${src}`));
|
|
22
|
+
console.error(colors.Gray('This may indicate a broken installation — try: npm install -g maiass'));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Warn rather than silently overwrite
|
|
27
|
+
if (fs.existsSync(targetPath)) {
|
|
28
|
+
console.warn(colors.Yellow(`${SYMBOLS.WARNING} ${targetPath} already exists — skipping.`));
|
|
29
|
+
console.warn(colors.Gray(` Delete it first if you want a fresh copy.`));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Create parent directories (e.g. .github/workflows/)
|
|
34
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
35
|
+
fs.copyFileSync(src, targetPath);
|
|
36
|
+
|
|
37
|
+
console.log(colors.BGreen(`${SYMBOLS.CHECKMARK} Created ${targetPath}`));
|
|
38
|
+
console.log(colors.Gray(` ${label}`));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Print a template to stdout so the user can copy it manually.
|
|
43
|
+
* Used for Bitbucket where the file location varies per project.
|
|
44
|
+
*/
|
|
45
|
+
function showTemplate(templateFile, label) {
|
|
46
|
+
const src = path.join(TEMPLATES_DIR, templateFile);
|
|
47
|
+
|
|
48
|
+
if (!fs.existsSync(src)) {
|
|
49
|
+
console.error(colors.Red(`${SYMBOLS.CROSS} Template not found: ${src}`));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(colors.BGreen(`\n${label}\n`));
|
|
54
|
+
console.log(colors.Gray('─'.repeat(60)));
|
|
55
|
+
console.log(fs.readFileSync(src, 'utf8'));
|
|
56
|
+
console.log(colors.Gray('─'.repeat(60)));
|
|
57
|
+
console.log(colors.Gray('Copy the above into your bitbucket-pipelines.yml\n'));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Handle --create-gh-action
|
|
62
|
+
* Copies the GitHub Actions version-bump workflow into .github/workflows/
|
|
63
|
+
*/
|
|
64
|
+
export function createGithubAction() {
|
|
65
|
+
copyTemplate(
|
|
66
|
+
'github-version-bump.yml',
|
|
67
|
+
path.join(process.cwd(), '.github', 'workflows', 'maiass-version-bump.yml'),
|
|
68
|
+
'Next: add a GH_PAT secret in your repo → Settings → Secrets → Actions'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Handle --show-gl-excerpt
|
|
74
|
+
* Prints the GitLab CI excerpt to stdout — users merge it into their existing .gitlab-ci.yml
|
|
75
|
+
*/
|
|
76
|
+
export function showGitlabExcerpt() {
|
|
77
|
+
showTemplate(
|
|
78
|
+
'gitlab-ci-excerpt.yml',
|
|
79
|
+
'MAIASS — GitLab CI excerpt (merge into your .gitlab-ci.yml)'
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Handle --show-bb-excerpt
|
|
85
|
+
* Prints the Bitbucket Pipelines excerpt to stdout — users merge it into their existing bitbucket-pipelines.yml
|
|
86
|
+
*/
|
|
87
|
+
export function showBitbucketExcerpt() {
|
|
88
|
+
showTemplate(
|
|
89
|
+
'bitbucket-pipelines-excerpt.yml',
|
|
90
|
+
'MAIASS — Bitbucket Pipelines excerpt (merge into your bitbucket-pipelines.yml)'
|
|
91
|
+
);
|
|
92
|
+
}
|
package/maiass.mjs
CHANGED
|
@@ -7,6 +7,19 @@ import { hideBin } from 'yargs/helpers';
|
|
|
7
7
|
import { initLogger, logger } from './lib/logger.js';
|
|
8
8
|
import { loadEnvironmentConfig, ensureConfigDirectories } from './lib/config.js';
|
|
9
9
|
|
|
10
|
+
// If running from a subdirectory of a git repo, cd to the repo root first so
|
|
11
|
+
// that .env.maiass is loaded from the right place and git operations are
|
|
12
|
+
// consistent with the project root.
|
|
13
|
+
import { execSync } from 'child_process';
|
|
14
|
+
try {
|
|
15
|
+
const gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
16
|
+
if (gitRoot && gitRoot !== process.cwd()) {
|
|
17
|
+
process.chdir(gitRoot);
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
// Not in a git repo — leave cwd as-is, pipeline will handle it gracefully
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
// Load environment variables from multiple sources with cross-platform support
|
|
11
24
|
ensureConfigDirectories();
|
|
12
25
|
const envConfig = loadEnvironmentConfig();
|
|
@@ -39,6 +52,7 @@ import { handleMaiassCommand } from './lib/maiass-command.js';
|
|
|
39
52
|
import { handleAccountInfoCommand } from './lib/account-info.js';
|
|
40
53
|
import { SYMBOLS } from './lib/symbols.js';
|
|
41
54
|
import { bootstrapProject } from './lib/bootstrap.js';
|
|
55
|
+
import { createGithubAction, showGitlabExcerpt, showBitbucketExcerpt } from './lib/ci-templates.js';
|
|
42
56
|
|
|
43
57
|
// Simple CLI setup for pkg compatibility
|
|
44
58
|
const args = process.argv.slice(2);
|
|
@@ -117,7 +131,10 @@ const validFlags = [
|
|
|
117
131
|
'--force', '-f',
|
|
118
132
|
'--silent', '-s',
|
|
119
133
|
'--json',
|
|
120
|
-
'--tag', '-t'
|
|
134
|
+
'--tag', '-t',
|
|
135
|
+
'--create-gh-action',
|
|
136
|
+
'--show-gl-excerpt',
|
|
137
|
+
'--show-bb-excerpt'
|
|
121
138
|
];
|
|
122
139
|
|
|
123
140
|
// Check for unrecognized flags
|
|
@@ -174,9 +191,18 @@ if (args.includes('--help') || args.includes('-h') || command === 'help') {
|
|
|
174
191
|
console.log(' --dry-run Run without making changes');
|
|
175
192
|
console.log(' --force Skip confirmation prompts');
|
|
176
193
|
console.log(' --silent Suppress non-essential output');
|
|
194
|
+
console.log('\nCI Setup:');
|
|
195
|
+
console.log(' --create-gh-action Create .github/workflows/maiass-version-bump.yml');
|
|
196
|
+
console.log(' --show-gl-excerpt Print GitLab CI excerpt to stdout (merge into .gitlab-ci.yml)');
|
|
197
|
+
console.log(' --show-bb-excerpt Print Bitbucket Pipelines excerpt to stdout');
|
|
177
198
|
process.exit(0);
|
|
178
199
|
}
|
|
179
200
|
|
|
201
|
+
// CI template commands — these run and exit immediately, no pipeline needed
|
|
202
|
+
if (args.includes('--create-gh-action')) { createGithubAction(); process.exit(0); }
|
|
203
|
+
if (args.includes('--show-gl-excerpt')) { showGitlabExcerpt(); process.exit(0); }
|
|
204
|
+
if (args.includes('--show-bb-excerpt')) { showBitbucketExcerpt(); process.exit(0); }
|
|
205
|
+
|
|
180
206
|
// Command routing (wrapped in async IIFE to handle async commands)
|
|
181
207
|
(async () => {
|
|
182
208
|
// --setup/--bootstrap: run the full interactive wizard and exit
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maiass",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.10.
|
|
4
|
+
"version": "5.10.4",
|
|
5
5
|
"description": "AI commit message generator, semantic versioning, and changelog automation for Git. One command stages, commits with AI, bumps version, and merges branches. Free credits on install — no sign-up needed.",
|
|
6
6
|
"main": "maiass.mjs",
|
|
7
7
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"lib/",
|
|
23
|
+
"templates/",
|
|
23
24
|
"maiass.mjs",
|
|
24
25
|
"setup-env.js",
|
|
25
26
|
"README.md",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# MAIASS — Bitbucket Pipelines: Auto Version Bump on Push to Develop
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# Runs `maiass -a patch` whenever a commit lands on your develop branch
|
|
5
|
+
# (including merged pull requests). Bumps the patch version, commits, and pushes.
|
|
6
|
+
#
|
|
7
|
+
# ⚠️ Double-bump caveat:
|
|
8
|
+
# Unlike GitHub Actions, Bitbucket Pipelines cannot trigger exclusively on
|
|
9
|
+
# PR merge events — it fires on every push to the branch, including the
|
|
10
|
+
# version bump commit itself. The script below guards against this by checking
|
|
11
|
+
# the last commit message. If it looks like a MAIASS version bump, it exits early.
|
|
12
|
+
#
|
|
13
|
+
# Setup:
|
|
14
|
+
# 1. Merge this excerpt into your bitbucket-pipelines.yml (or use as-is)
|
|
15
|
+
# 2. In Bitbucket: Repository Settings → Pipelines → SSH Keys
|
|
16
|
+
# Add a key pair and grant write access, OR use an app password:
|
|
17
|
+
# - Create an app password with Repositories: Read & Write scope
|
|
18
|
+
# - Add it as a repository variable named BB_APP_PASSWORD (secured)
|
|
19
|
+
# - Add your Bitbucket username as BB_USERNAME
|
|
20
|
+
# 3. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
21
|
+
|
|
22
|
+
pipelines:
|
|
23
|
+
branches:
|
|
24
|
+
develop: # Change to match your MAIASS_DEVELOPBRANCH if different
|
|
25
|
+
- step:
|
|
26
|
+
name: MAIASS Version Bump
|
|
27
|
+
image: node:20
|
|
28
|
+
script:
|
|
29
|
+
# Guard: skip if last commit was already a version bump
|
|
30
|
+
- |
|
|
31
|
+
LAST_MSG=$(git log -1 --pretty=format:'%s')
|
|
32
|
+
if echo "$LAST_MSG" | grep -qiE '^Bumped version'; then
|
|
33
|
+
echo "Version bump commit detected — skipping to avoid loop."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
- npm install -g maiass --no-fund --no-audit
|
|
37
|
+
- git config user.name "Bitbucket Pipelines"
|
|
38
|
+
- git config user.email "pipelines@bitbucket.org"
|
|
39
|
+
# Authenticate push via app password
|
|
40
|
+
- git remote set-url origin "https://${BB_USERNAME}:${BB_APP_PASSWORD}@bitbucket.org/${BITBUCKET_REPO_FULL_NAME}.git"
|
|
41
|
+
- maiass -a patch
|
|
42
|
+
variables:
|
|
43
|
+
MAIASS_AI_MODE: "off" # Disable AI — no credits used in CI
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# MAIASS — GitHub Actions: Auto Version Bump on PR Merge
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# When a pull request is merged into your develop branch, this workflow
|
|
5
|
+
# automatically runs `maiass -a patch` to bump the patch version, commit
|
|
6
|
+
# the change, and push it back to develop.
|
|
7
|
+
#
|
|
8
|
+
# Setup:
|
|
9
|
+
# 1. Copy this file to .github/workflows/maiass-version-bump.yml in your repo
|
|
10
|
+
# 2. Create a fine-grained Personal Access Token (PAT) with:
|
|
11
|
+
# - Contents: Read & Write
|
|
12
|
+
# - Metadata: Read-only
|
|
13
|
+
# - Workflows: Read & Write
|
|
14
|
+
# 3. Add the PAT as a repository secret named GH_PAT
|
|
15
|
+
# 4. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
16
|
+
#
|
|
17
|
+
# Notes:
|
|
18
|
+
# - AI is disabled (MAIASS_AI_MODE: off) so no credits are used
|
|
19
|
+
# - The workflow reads MAIASS_DEVELOPBRANCH from your .env.maiass automatically
|
|
20
|
+
# - maiass pulls the latest develop before bumping to prevent stale version conflicts
|
|
21
|
+
|
|
22
|
+
name: Version Bump on PR Merge
|
|
23
|
+
|
|
24
|
+
on:
|
|
25
|
+
pull_request:
|
|
26
|
+
types: [closed]
|
|
27
|
+
branches:
|
|
28
|
+
- develop # Change this to match your MAIASS_DEVELOPBRANCH if different
|
|
29
|
+
|
|
30
|
+
jobs:
|
|
31
|
+
bump-version:
|
|
32
|
+
# Only run when the PR was actually merged (not just closed)
|
|
33
|
+
if: github.event.pull_request.merged == true
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
permissions:
|
|
37
|
+
contents: write # Required to push the version bump commit
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0 # Full history needed for changelog generation
|
|
43
|
+
token: ${{ secrets.GH_PAT }} # PAT allows the bot to push back to the repo
|
|
44
|
+
|
|
45
|
+
- uses: actions/setup-node@v4
|
|
46
|
+
with:
|
|
47
|
+
node-version: '20'
|
|
48
|
+
cache: 'npm'
|
|
49
|
+
|
|
50
|
+
- name: Install maiass
|
|
51
|
+
run: npm install -g maiass --no-fund --no-audit
|
|
52
|
+
|
|
53
|
+
- name: Configure git
|
|
54
|
+
run: |
|
|
55
|
+
git config user.name "github-actions[bot]"
|
|
56
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
57
|
+
|
|
58
|
+
# Explicitly check out the develop branch head (the pull_request closed
|
|
59
|
+
# event checks out a merge ref, not the branch itself)
|
|
60
|
+
- name: Checkout develop
|
|
61
|
+
run: git checkout develop
|
|
62
|
+
|
|
63
|
+
- name: Bump version
|
|
64
|
+
run: maiass -a patch
|
|
65
|
+
env:
|
|
66
|
+
MAIASS_AI_MODE: off # Disable AI — no credits used in CI
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# MAIASS — GitLab CI: Auto Version Bump on Merge to Develop
|
|
2
|
+
#
|
|
3
|
+
# What this does:
|
|
4
|
+
# Runs `maiass -a patch` whenever a commit lands on your develop branch
|
|
5
|
+
# (including merge requests). Bumps the patch version, commits, and pushes.
|
|
6
|
+
#
|
|
7
|
+
# Setup:
|
|
8
|
+
# 1. Merge this excerpt into your existing .gitlab-ci.yml, or use it as-is
|
|
9
|
+
# 2. In GitLab: Settings → Repository → Protected branches → allow pipelines to push
|
|
10
|
+
# 3. Create a project access token or personal access token with write access
|
|
11
|
+
# 4. Add it as a CI/CD variable named GITLAB_TOKEN (masked, protected)
|
|
12
|
+
# 5. Set MAIASS_DEVELOPBRANCH in your .env.maiass if your branch isn't 'develop'
|
|
13
|
+
#
|
|
14
|
+
# Double-bump protection:
|
|
15
|
+
# The script checks the last commit author and skips if it was already made
|
|
16
|
+
# by the CI bot — preventing an infinite loop of version bumps.
|
|
17
|
+
|
|
18
|
+
stages:
|
|
19
|
+
- version
|
|
20
|
+
|
|
21
|
+
maiass-version-bump:
|
|
22
|
+
stage: version
|
|
23
|
+
image: node:20
|
|
24
|
+
only:
|
|
25
|
+
- develop # Change to match your MAIASS_DEVELOPBRANCH if different
|
|
26
|
+
script:
|
|
27
|
+
# Skip if the last commit was already a version bump from this pipeline
|
|
28
|
+
- |
|
|
29
|
+
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
|
|
30
|
+
LAST_MSG=$(git log -1 --pretty=format:'%s')
|
|
31
|
+
if echo "$LAST_AUTHOR" | grep -q "GitLab CI" || echo "$LAST_MSG" | grep -qiE '^Bumped version'; then
|
|
32
|
+
echo "Version bump commit detected — skipping to avoid loop."
|
|
33
|
+
exit 0
|
|
34
|
+
fi
|
|
35
|
+
- npm install -g maiass --no-fund --no-audit
|
|
36
|
+
- git config user.name "GitLab CI"
|
|
37
|
+
- git config user.email "ci@gitlab.com"
|
|
38
|
+
# Authenticate push via HTTPS using the project token
|
|
39
|
+
- git remote set-url origin "https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
|
|
40
|
+
- maiass -a patch
|
|
41
|
+
variables:
|
|
42
|
+
MAIASS_AI_MODE: "off" # Disable AI — no credits used in CI
|