create-disposabl-app 0.20.4 → 0.20.5
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/dist/disposabl.js +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/default/.githooks/install +23 -0
- package/dist/templates/default/.githooks/pre-commit +5 -0
- package/dist/templates/default/package.json +2 -0
- package/dist/templates/default/packages/tests/git-hooks.test.ts +84 -0
- package/dist/templates/default/packages/tests/package.json +2 -1
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1563,7 +1563,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
1563
1563
|
import { Command, CommanderError } from "commander";
|
|
1564
1564
|
import * as p2 from "@clack/prompts";
|
|
1565
1565
|
// package.json
|
|
1566
|
-
var version = "0.20.
|
|
1566
|
+
var version = "0.20.5";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
current=$(git config --get core.hooksPath) || {
|
|
5
|
+
status=$?
|
|
6
|
+
[ "$status" -eq 1 ] || exit "$status"
|
|
7
|
+
}
|
|
8
|
+
if [ -n "$current" ] && [ "$current" != .githooks ]; then
|
|
9
|
+
echo "Git already uses hooks from $current; configure hooks manually to preserve them." >&2
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
if [ -z "$current" ]; then
|
|
13
|
+
hooks=$(git rev-parse --git-path hooks)
|
|
14
|
+
for hook in "$hooks"/*; do
|
|
15
|
+
case "$hook" in *.sample) continue ;; esac
|
|
16
|
+
if [ -f "$hook" ] && [ -x "$hook" ]; then
|
|
17
|
+
echo "Git already has an active hook at $hook; combine hooks manually to preserve it." >&2
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
done
|
|
21
|
+
fi
|
|
22
|
+
git config --local core.hooksPath .githooks
|
|
23
|
+
echo "Installed hooks from .githooks (shared by this repository's worktrees)."
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
5
|
"check": "bun run generate && turbo run typecheck lint && bun fmt --check",
|
|
6
|
+
"hooks:install": ".githooks/install",
|
|
6
7
|
"test": "bun run --cwd packages/tests test",
|
|
8
|
+
"test:unit": "bun run --cwd packages/tests test:unit",
|
|
7
9
|
"e2e": "bun run --cwd packages/tests e2e",
|
|
8
10
|
"build": "turbo build",
|
|
9
11
|
"dev": "turbo dev",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import {
|
|
4
|
+
chmodSync,
|
|
5
|
+
copyFileSync,
|
|
6
|
+
mkdtempSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
test("installed hook checks the index without changing partially staged files", () => {
|
|
18
|
+
const dir = mkdtempSync(join(tmpdir(), "disposabl-hooks-"));
|
|
19
|
+
const root = fileURLToPath(new URL("../../", import.meta.url));
|
|
20
|
+
const run = (...args: string[]) =>
|
|
21
|
+
spawnSync(args[0], args.slice(1), { cwd: dir, encoding: "utf8" });
|
|
22
|
+
const git = (...args: string[]) => run("git", ...args);
|
|
23
|
+
try {
|
|
24
|
+
assert.equal(git("init", "-q").status, 0);
|
|
25
|
+
assert.equal(git("config", "user.name", "Hook Test").status, 0);
|
|
26
|
+
assert.equal(
|
|
27
|
+
git("config", "user.email", "hook-test@example.invalid").status,
|
|
28
|
+
0,
|
|
29
|
+
);
|
|
30
|
+
mkdirSync(join(dir, ".githooks"));
|
|
31
|
+
for (const file of ["install", "pre-commit"]) {
|
|
32
|
+
copyFileSync(join(root, ".githooks", file), join(dir, ".githooks", file));
|
|
33
|
+
}
|
|
34
|
+
writeFileSync(
|
|
35
|
+
join(dir, "package.json"),
|
|
36
|
+
JSON.stringify({ scripts: { "hooks:install": ".githooks/install" } }),
|
|
37
|
+
);
|
|
38
|
+
assert.equal(git("config", "core.hooksPath", "custom-hooks").status, 0);
|
|
39
|
+
assert.notEqual(run("bun", "run", "hooks:install").status, 0);
|
|
40
|
+
assert.equal(
|
|
41
|
+
git("config", "--get", "core.hooksPath").stdout.trim(),
|
|
42
|
+
"custom-hooks",
|
|
43
|
+
);
|
|
44
|
+
assert.equal(git("config", "--unset", "core.hooksPath").status, 0);
|
|
45
|
+
const existing = join(dir, ".git/hooks/pre-push");
|
|
46
|
+
writeFileSync(existing, "#!/bin/sh\nexit 0\n");
|
|
47
|
+
chmodSync(existing, 0o755);
|
|
48
|
+
assert.notEqual(run("bun", "run", "hooks:install").status, 0);
|
|
49
|
+
assert.equal(git("config", "--get", "core.hooksPath").status, 1);
|
|
50
|
+
assert.equal(readFileSync(existing, "utf8"), "#!/bin/sh\nexit 0\n");
|
|
51
|
+
rmSync(existing);
|
|
52
|
+
assert.equal(run("bun", "run", "hooks:install").status, 0);
|
|
53
|
+
assert.equal(
|
|
54
|
+
git("config", "--get", "core.hooksPath").stdout.trim(),
|
|
55
|
+
".githooks",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const path = join(dir, "example.ts");
|
|
59
|
+
writeFileSync(path, "const value=1\n");
|
|
60
|
+
assert.equal(git("add", "example.ts").status, 0);
|
|
61
|
+
const unstaged = "const value = 2;\n";
|
|
62
|
+
writeFileSync(path, unstaged);
|
|
63
|
+
const failure = git("commit", "-m", "bad staged formatting");
|
|
64
|
+
assert.notEqual(failure.status, 0);
|
|
65
|
+
assert.ok((failure.stdout + failure.stderr).includes("example.ts"));
|
|
66
|
+
assert.equal(git("show", ":example.ts").stdout, "const value=1\n");
|
|
67
|
+
assert.equal(readFileSync(path, "utf8"), unstaged);
|
|
68
|
+
|
|
69
|
+
writeFileSync(path, "const value = 1;\n");
|
|
70
|
+
assert.equal(git("add", "example.ts").status, 0);
|
|
71
|
+
writeFileSync(path, "const value=3\n");
|
|
72
|
+
const success = git("commit", "-m", "valid staged formatting");
|
|
73
|
+
assert.equal(success.status, 0);
|
|
74
|
+
assert.equal(git("show", "HEAD:example.ts").stdout, "const value = 1;\n");
|
|
75
|
+
assert.equal(readFileSync(path, "utf8"), "const value=3\n");
|
|
76
|
+
|
|
77
|
+
writeFileSync(path, "const value = 3;\n");
|
|
78
|
+
assert.equal(git("add", "example.ts").status, 0);
|
|
79
|
+
assert.equal(git("commit", "-m", "clean commit").status, 0);
|
|
80
|
+
assert.equal(git("status", "--porcelain", "example.ts").stdout, "");
|
|
81
|
+
} finally {
|
|
82
|
+
rmSync(dir, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "bun
|
|
6
|
+
"test": "bun run test:unit && bun run e2e run",
|
|
7
|
+
"test:unit": "bun test *.test.ts",
|
|
7
8
|
"setup:browser": "E2E_TELEMETRY_DISABLED=1 e2e-web install chromium --with-deps",
|
|
8
9
|
"e2e": "E2E_TELEMETRY_DISABLED=1 e2e",
|
|
9
10
|
"typecheck": "tsc --noEmit",
|