cc-swap 0.1.0
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/.claude/settings.local.json +30 -0
- package/README.md +416 -0
- package/dist/cli.js +275 -0
- package/docs/superpowers/plans/2026-03-22-cc-switch.md +55 -0
- package/docs/superpowers/specs/2026-03-22-cc-switch-design.md +117 -0
- package/package.json +31 -0
- package/src/accounts.ts +105 -0
- package/src/cli.ts +158 -0
- package/src/index.ts +4 -0
- package/src/items.ts +57 -0
- package/src/paths.ts +11 -0
- package/src/symlink.ts +34 -0
- package/src/validate.ts +10 -0
- package/tests/accounts.test.ts +186 -0
- package/tests/cli.test.ts +76 -0
- package/tests/symlink.test.ts +127 -0
- package/tests/validate.test.ts +33 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +9 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { validateName } from "../src/validate.js";
|
|
3
|
+
|
|
4
|
+
describe("validateName", () => {
|
|
5
|
+
it("accepts valid names", () => {
|
|
6
|
+
expect(validateName("work")).toBeNull();
|
|
7
|
+
expect(validateName("my_account")).toBeNull();
|
|
8
|
+
expect(validateName("account-2")).toBeNull();
|
|
9
|
+
expect(validateName("A1")).toBeNull();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("rejects empty name", () => {
|
|
13
|
+
expect(validateName("")).toMatch(/cannot be empty/i);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("rejects names starting with dot", () => {
|
|
17
|
+
expect(validateName(".hidden")).toMatch(/cannot start with/i);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("rejects names starting with hyphen", () => {
|
|
21
|
+
expect(validateName("-bad")).toMatch(/cannot start with/i);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("rejects names with invalid characters", () => {
|
|
25
|
+
expect(validateName("has space")).toMatch(/only contain/i);
|
|
26
|
+
expect(validateName("has/slash")).toMatch(/only contain/i);
|
|
27
|
+
expect(validateName("a@b")).toMatch(/only contain/i);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("rejects names over 50 chars", () => {
|
|
31
|
+
expect(validateName("a".repeat(51))).toMatch(/50 characters/i);
|
|
32
|
+
});
|
|
33
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"sourceMap": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
15
|
+
}
|