@outfitter/tooling 0.2.1 → 0.2.2
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/.markdownlint-cli2.jsonc +55 -55
- package/README.md +7 -3
- package/biome.json +79 -72
- package/dist/cli/check.js +1 -1
- package/dist/cli/fix.js +1 -1
- package/dist/cli/index.js +527 -18
- package/dist/cli/init.js +1 -1
- package/dist/cli/pre-push.d.ts +34 -1
- package/dist/cli/pre-push.js +14 -2
- package/dist/cli/upgrade-bun.js +1 -1
- package/dist/index.d.ts +108 -2
- package/dist/index.js +21 -9
- package/dist/registry/build.d.ts +6 -0
- package/dist/registry/build.js +31 -13
- package/dist/shared/@outfitter/{tooling-xx1146e3.js → tooling-0x5q15ec.js} +2 -1
- package/dist/shared/@outfitter/tooling-8sd32ts6.js +277 -0
- package/dist/shared/@outfitter/{tooling-s4eqq91d.js → tooling-9errkcvk.js} +2 -1
- package/dist/shared/@outfitter/{tooling-75j500dv.js → tooling-9yzd08v1.js} +10 -6
- package/dist/shared/@outfitter/{tooling-xaxdr9da.js → tooling-mxwc1n8w.js} +13 -3
- package/lefthook.yml +5 -7
- package/package.json +121 -121
- package/registry/registry.json +78 -76
- package/tsconfig.preset.bun.json +5 -5
- package/tsconfig.preset.json +33 -33
- package/dist/shared/@outfitter/tooling-qm7jeg0d.js +0 -99
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/tooling/src/cli/pre-push.ts
|
|
3
|
-
var COLORS = {
|
|
4
|
-
reset: "\x1B[0m",
|
|
5
|
-
red: "\x1B[31m",
|
|
6
|
-
green: "\x1B[32m",
|
|
7
|
-
yellow: "\x1B[33m",
|
|
8
|
-
blue: "\x1B[34m"
|
|
9
|
-
};
|
|
10
|
-
function log(msg) {
|
|
11
|
-
console.log(msg);
|
|
12
|
-
}
|
|
13
|
-
function getCurrentBranch() {
|
|
14
|
-
const result = Bun.spawnSync(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
15
|
-
return result.stdout.toString().trim();
|
|
16
|
-
}
|
|
17
|
-
function isRedPhaseBranch(branch) {
|
|
18
|
-
return branch.endsWith("-tests") || branch.endsWith("/tests") || branch.endsWith("_tests");
|
|
19
|
-
}
|
|
20
|
-
function isScaffoldBranch(branch) {
|
|
21
|
-
return branch.endsWith("-scaffold") || branch.endsWith("/scaffold") || branch.endsWith("_scaffold");
|
|
22
|
-
}
|
|
23
|
-
function hasRedPhaseBranchInContext(currentBranch) {
|
|
24
|
-
let branches = [];
|
|
25
|
-
try {
|
|
26
|
-
const gtResult = Bun.spawnSync(["gt", "ls"], { stderr: "pipe" });
|
|
27
|
-
if (gtResult.exitCode === 0) {
|
|
28
|
-
branches = gtResult.stdout.toString().split(`
|
|
29
|
-
`).map((line) => line.replace(/^[\u2502\u251C\u2514\u2500\u25C9\u25EF ]*/g, "").replace(/ \(.*/, "")).filter(Boolean);
|
|
30
|
-
}
|
|
31
|
-
} catch {}
|
|
32
|
-
if (branches.length === 0) {
|
|
33
|
-
const gitResult = Bun.spawnSync([
|
|
34
|
-
"git",
|
|
35
|
-
"branch",
|
|
36
|
-
"--list",
|
|
37
|
-
"cli/*",
|
|
38
|
-
"types/*",
|
|
39
|
-
"contracts/*"
|
|
40
|
-
]);
|
|
41
|
-
branches = gitResult.stdout.toString().split(`
|
|
42
|
-
`).map((line) => line.replace(/^[* ]+/, "")).filter(Boolean);
|
|
43
|
-
}
|
|
44
|
-
for (const branch of branches) {
|
|
45
|
-
if (branch === currentBranch)
|
|
46
|
-
continue;
|
|
47
|
-
if (isRedPhaseBranch(branch))
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
function runTests() {
|
|
53
|
-
log("");
|
|
54
|
-
const result = Bun.spawnSync(["bun", "run", "test"], {
|
|
55
|
-
stdio: ["inherit", "inherit", "inherit"]
|
|
56
|
-
});
|
|
57
|
-
return result.exitCode === 0;
|
|
58
|
-
}
|
|
59
|
-
async function runPrePush(options = {}) {
|
|
60
|
-
log(`${COLORS.blue}Pre-push test${COLORS.reset} (TDD-aware)`);
|
|
61
|
-
log("");
|
|
62
|
-
const branch = getCurrentBranch();
|
|
63
|
-
if (isRedPhaseBranch(branch)) {
|
|
64
|
-
log(`${COLORS.yellow}TDD RED phase${COLORS.reset} detected: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
65
|
-
log(`${COLORS.yellow}Skipping test execution${COLORS.reset} - tests are expected to fail in RED phase`);
|
|
66
|
-
log("");
|
|
67
|
-
log("Remember: GREEN phase (implementation) must make these tests pass!");
|
|
68
|
-
process.exit(0);
|
|
69
|
-
}
|
|
70
|
-
if (isScaffoldBranch(branch)) {
|
|
71
|
-
if (hasRedPhaseBranchInContext(branch)) {
|
|
72
|
-
log(`${COLORS.yellow}Scaffold branch${COLORS.reset} with RED phase branch in context: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
73
|
-
log(`${COLORS.yellow}Skipping test execution${COLORS.reset} - RED phase tests expected to fail`);
|
|
74
|
-
log("");
|
|
75
|
-
process.exit(0);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (options.force) {
|
|
79
|
-
log(`${COLORS.yellow}Force flag set${COLORS.reset} - skipping tests`);
|
|
80
|
-
process.exit(0);
|
|
81
|
-
}
|
|
82
|
-
log(`Running tests for branch: ${COLORS.blue}${branch}${COLORS.reset}`);
|
|
83
|
-
if (runTests()) {
|
|
84
|
-
log("");
|
|
85
|
-
log(`${COLORS.green}All tests passed${COLORS.reset}`);
|
|
86
|
-
process.exit(0);
|
|
87
|
-
} else {
|
|
88
|
-
log("");
|
|
89
|
-
log(`${COLORS.red}Tests failed${COLORS.reset}`);
|
|
90
|
-
log("");
|
|
91
|
-
log("If this is intentional TDD RED phase work, name your branch:");
|
|
92
|
-
log(" - feature-tests");
|
|
93
|
-
log(" - feature/tests");
|
|
94
|
-
log(" - feature_tests");
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { runPrePush };
|