agentic-mobile-kit 0.7.12 → 0.7.13
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/doctor.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const { spawnSync } = require('child_process');
|
|
7
|
-
const { tool, hookManager, hooksWired, checkProject, emptyFolder } = require('./init');
|
|
7
|
+
const { tool, hookManager, hooksWired, kitRun, checkProject, emptyFolder } = require('./init');
|
|
8
8
|
const screens = require('../stacks/react-native/template/scripts/amk/screens.js');
|
|
9
9
|
|
|
10
10
|
const RULESYNC = 'rulesync@27.0.0';
|
|
@@ -57,7 +57,7 @@ function projectChecks(cwd, opts) {
|
|
|
57
57
|
? ok('Git hooks active')
|
|
58
58
|
: fail('Git hooks not active on this clone', 'run: git config core.hooksPath .githooks (your package manager\'s install does this too)'));
|
|
59
59
|
} else if (manager.manual) {
|
|
60
|
-
out.push(warn(`Git hooks run from ${manager.name}, without the kit's checks`,
|
|
60
|
+
out.push(warn(`Git hooks run from ${manager.name}, without the kit's checks`, `add "${kitRun('pre-commit')}" and "${kitRun('pre-push')}" to those hooks`));
|
|
61
61
|
} else if (!hooksWired(cwd, manager)) {
|
|
62
62
|
out.push(fail(`The kit's checks aren't in your ${manager.name} hooks`, 'run: npx agentic-mobile-kit sync'));
|
|
63
63
|
} else {
|
|
@@ -68,6 +68,10 @@ function projectChecks(cwd, opts) {
|
|
|
68
68
|
: fail(`${manager.name} isn't set up on this clone, so no git hooks run`, 'run your package manager\'s install'));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// a team may keep .githooks out of git, so a fresh clone has none until it runs sync, and no kit checks run till then
|
|
72
|
+
const noHooks = ['pre-commit', 'pre-push'].filter(h => !fs.existsSync(path.join(cwd, '.githooks', h)));
|
|
73
|
+
if (noHooks.length) out.push(fail(`This clone has no ${noHooks.map(h => `.githooks/${h}`).join(' or ')}, so the kit's checks don't run`, 'run: npx agentic-mobile-kit sync'));
|
|
74
|
+
|
|
71
75
|
if (fs.existsSync(path.join(cwd, 'scripts/amk/case-check.js'))) {
|
|
72
76
|
const r = spawnSync(process.execPath, ['scripts/amk/case-check.js'], { cwd, encoding: 'utf8' });
|
|
73
77
|
const lines = (r.stderr || '').trim().split('\n');
|
package/lib/init.js
CHANGED
|
@@ -430,7 +430,12 @@ function merge3(current, base, kitNew, from) {
|
|
|
430
430
|
// two tools setting it undo each other on every install (husky's prepare script runs after the kit's postinstall).
|
|
431
431
|
const KIT_HOOKS = ['pre-commit', 'pre-push'];
|
|
432
432
|
const MARK = 'agentic-mobile-kit';
|
|
433
|
-
|
|
433
|
+
// the kit's command in a hook manager. A team may keep .githooks out of git, so a fresh clone has none until it runs
|
|
434
|
+
// sync: run-hook.sh then skips the hook with a hint, where a plain `sh .githooks/<hook>` failed every commit and push
|
|
435
|
+
const kitRun = h => `sh scripts/amk/run-hook.sh .githooks/${h}`;
|
|
436
|
+
// that plain command, which kits up to 0.7.12 added: sync upgrades it
|
|
437
|
+
const oldRun = h => new RegExp(`(^|[\\s"'])sh \\.githooks/${h}(?=$|[\\s"'])`, 'gm');
|
|
438
|
+
const hookCall = h => `${kitRun(h)}${h === 'pre-push' ? ' "$@"' : ''} || exit 1 # ${MARK}`;
|
|
434
439
|
// git's other client-side hooks. One another tool installed into .git/hooks (a time tracker's post-commit, say) stops
|
|
435
440
|
// running once core.hooksPath points at .githooks, so a .githooks file passes it on, in every clone that has one
|
|
436
441
|
const OTHER_HOOKS = ['applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-merge-commit', 'prepare-commit-msg', 'commit-msg',
|
|
@@ -461,7 +466,11 @@ function hookManager(cwd, pkg) {
|
|
|
461
466
|
}
|
|
462
467
|
|
|
463
468
|
const hookFile = (m, h) => (m.dir ? `${m.dir}/${h}` : m.yaml);
|
|
464
|
-
|
|
469
|
+
// the kit's command, or the team's own call to the hook; not an earlier kit's plain one, which sync upgrades
|
|
470
|
+
const hooksWired = (cwd, m) => KIT_HOOKS.every(h => {
|
|
471
|
+
const text = m.json ? m.json[h] || '' : readIf(path.join(cwd, hookFile(m, h))) || '';
|
|
472
|
+
return text.includes(`.githooks/${h}`) && !oldRun(h).test(text);
|
|
473
|
+
});
|
|
465
474
|
|
|
466
475
|
// after the shebang, comments and husky's own setup line: a command after the team's `exit` would never run
|
|
467
476
|
function insertCall(text, line) {
|
|
@@ -474,7 +483,7 @@ function insertCall(text, line) {
|
|
|
474
483
|
|
|
475
484
|
// adds the kit's command to a lefthook hook (under its commands: or jobs:), or the hook itself; null if it can't tell where
|
|
476
485
|
function lefthookAdd(text, h) {
|
|
477
|
-
const run =
|
|
486
|
+
const run = kitRun(h);
|
|
478
487
|
const lines = text.replace(/\n+$/, '').split('\n');
|
|
479
488
|
const start = lines.findIndex(l => new RegExp(`^["']?${h}["']?\\s*:`).test(l));
|
|
480
489
|
if (start < 0) return `${lines.join('\n')}\n${h}: # ${MARK}\n commands: # ${MARK}\n ${MARK}:\n run: ${run}\n`;
|
|
@@ -500,24 +509,31 @@ function lefthookAdd(text, h) {
|
|
|
500
509
|
// runs the kit's hooks from the project's hook manager; true if package.json changed
|
|
501
510
|
function wireHooks(cwd, m, done) {
|
|
502
511
|
if (m.manual) {
|
|
503
|
-
done.warnings.push(`git hooks already run from ${m.name}, so the kit left core.hooksPath alone. To run the kit's checks too, add "
|
|
512
|
+
done.warnings.push(`git hooks already run from ${m.name}, so the kit left core.hooksPath alone. To run the kit's checks too, add "${kitRun('pre-commit')}" and "${kitRun('pre-push')}" to those hooks.`);
|
|
504
513
|
return false;
|
|
505
514
|
}
|
|
506
515
|
let pkgChanged = false;
|
|
507
516
|
for (const h of KIT_HOOKS) {
|
|
508
517
|
if (m.json) {
|
|
509
|
-
|
|
510
|
-
|
|
518
|
+
const v = m.json[h] || '';
|
|
519
|
+
if (oldRun(h).test(v)) m.json[h] = v.replace(oldRun(h), `$1${kitRun(h)}`);
|
|
520
|
+
else if (v.includes(`.githooks/${h}`)) continue;
|
|
521
|
+
else m.json[h] = v ? `${kitRun(h)} && ${v}` : kitRun(h);
|
|
511
522
|
pkgChanged = true;
|
|
512
523
|
continue;
|
|
513
524
|
}
|
|
514
525
|
const rel = hookFile(m, h);
|
|
515
526
|
const file = path.join(cwd, rel);
|
|
516
527
|
const text = readIf(file);
|
|
528
|
+
if (text !== null && oldRun(h).test(text)) {
|
|
529
|
+
fs.writeFileSync(file, text.replace(oldRun(h), `$1${kitRun(h)}`));
|
|
530
|
+
if (!done.merged.includes(rel)) done.merged.push(rel);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
517
533
|
if ((text || '').includes(`.githooks/${h}`)) continue;
|
|
518
534
|
if (m.yaml) {
|
|
519
535
|
const next = lefthookAdd(text, h);
|
|
520
|
-
if (next === null) { done.warnings.push(`couldn't add the kit's ${h} check to ${rel}: add a command there that runs "
|
|
536
|
+
if (next === null) { done.warnings.push(`couldn't add the kit's ${h} check to ${rel}: add a command there that runs "${kitRun(h)}"`); continue; }
|
|
521
537
|
fs.writeFileSync(file, next);
|
|
522
538
|
if (!done.merged.includes(rel)) done.merged.push(rel);
|
|
523
539
|
continue;
|
|
@@ -539,8 +555,8 @@ function unwireHooks(cwd, m, report) {
|
|
|
539
555
|
for (const h of KIT_HOOKS) {
|
|
540
556
|
if (m.json) {
|
|
541
557
|
const before = m.json[h];
|
|
542
|
-
if (before === `sh .githooks/${h}`) delete m.json[h];
|
|
543
|
-
else if (before) m.json[h] = before.replace(`sh .githooks/${h} && `, '');
|
|
558
|
+
if (before === kitRun(h) || before === `sh .githooks/${h}`) delete m.json[h];
|
|
559
|
+
else if (before) m.json[h] = before.replace(`${kitRun(h)} && `, '').replace(`sh .githooks/${h} && `, '');
|
|
544
560
|
if (m.json[h] !== before) { pkgChanged = true; report.removed.push(`package.json ${m.name} ${h} (the kit's command)`); }
|
|
545
561
|
continue;
|
|
546
562
|
}
|
|
@@ -641,6 +657,9 @@ function finish(cwd, { pkg, deps, tools, files, stack, skipGenerate }) {
|
|
|
641
657
|
// the project's hook manager runs the kit's hooks; drop the postinstall earlier kit versions added, which fought it
|
|
642
658
|
if (dropHooksCmd(scripts)) pkgChanged = true;
|
|
643
659
|
if (wireHooks(cwd, manager, done)) pkgChanged = true;
|
|
660
|
+
if (!manager.manual && ignoredByGit(cwd, '.githooks/pre-commit')) {
|
|
661
|
+
done.warnings.push(`.githooks is kept out of git here, so a fresh clone has none until it runs npx agentic-mobile-kit sync. Until then, ${manager.name} skips the kit's checks and says so`);
|
|
662
|
+
}
|
|
644
663
|
} else if (!(scripts.postinstall || '').includes('core.hooksPath')) {
|
|
645
664
|
// parentheses keep the existing script's failure behavior: `a && b || true` would hide a failing `a`
|
|
646
665
|
scripts.postinstall = scripts.postinstall ? `${scripts.postinstall} && (${HOOKS_CMD})` : HOOKS_CMD;
|
|
@@ -781,7 +800,9 @@ function sync(cwd, opts = {}) {
|
|
|
781
800
|
continue;
|
|
782
801
|
}
|
|
783
802
|
if (current === null) {
|
|
784
|
-
|
|
803
|
+
// new in the kit, or kept out of git, so this clone doesn't have it yet (a team may keep .githooks out of git).
|
|
804
|
+
// Not rulesync.jsonc: it holds the team's choice of tools, which the kit's own copy doesn't know
|
|
805
|
+
if (kitOld === null || rel !== 'rulesync.jsonc' && ignoredByGit(cwd, rel)) { writeKitFile(cwd, rel, kitNew); report.added.push(rel); } else report.kept.push(`${rel} (you deleted it)`);
|
|
785
806
|
continue;
|
|
786
807
|
}
|
|
787
808
|
if (current === kitNew) continue;
|
|
@@ -939,5 +960,5 @@ function printUninstall({ report }, log = console.log) {
|
|
|
939
960
|
|
|
940
961
|
module.exports = {
|
|
941
962
|
init, sync, uninstall, printSummary, printSync, printUninstall, InitError, TOOLS, TESTED, CI, KIT_VERSION, tool, cleanEnv,
|
|
942
|
-
hookManager, hooksWired, checkProject, recorded, installedCi, emptyFolder, createApp,
|
|
963
|
+
hookManager, hooksWired, kitRun, checkProject, recorded, installedCi, emptyFolder, createApp,
|
|
943
964
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-mobile-kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"description": "One setup for AI-assisted development of React Native apps, bare or Expo: shared rules and workflows for Claude Code, Codex and Antigravity, git hooks, device checks with screenshots, and release tooling for the App Store and Google Play.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "prakashpro1",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Runs one of the kit's git hooks from the project's hook manager (husky, lefthook, simple-git-hooks).
|
|
3
|
+
# Usage: sh scripts/amk/run-hook.sh .githooks/<hook> [args…]
|
|
4
|
+
# A team may keep .githooks out of git, so a fresh clone has none until it runs sync: then this says so and lets the
|
|
5
|
+
# commit or push go on, as failing every one of them would leave only git commit --no-verify
|
|
6
|
+
set -eu
|
|
7
|
+
hook=$1; shift
|
|
8
|
+
if [ -f "$hook" ]; then exec sh "$hook" "$@"; fi
|
|
9
|
+
echo "agentic-mobile-kit: this clone has no $hook yet, so the kit's checks were skipped: run npx agentic-mobile-kit sync" >&2
|