@bensandee/tooling 0.2.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/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +2371 -0
- package/dist/index.d.mts +102 -0
- package/dist/index.mjs +1 -0
- package/package.json +46 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/json.d.ts
|
|
4
|
+
declare const PackageJsonSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodOptional<z.ZodString>;
|
|
6
|
+
version: z.ZodOptional<z.ZodString>;
|
|
7
|
+
private: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
type: z.ZodOptional<z.ZodString>;
|
|
9
|
+
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
10
|
+
dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
11
|
+
devDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
bin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
13
|
+
exports: z.ZodOptional<z.ZodUnknown>;
|
|
14
|
+
main: z.ZodOptional<z.ZodString>;
|
|
15
|
+
types: z.ZodOptional<z.ZodString>;
|
|
16
|
+
typings: z.ZodOptional<z.ZodString>;
|
|
17
|
+
engines: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
18
|
+
}, z.core.$loose>;
|
|
19
|
+
type PackageJson = z.infer<typeof PackageJsonSchema>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/types.d.ts
|
|
22
|
+
type CiPlatform = "github" | "forgejo" | "none";
|
|
23
|
+
type ReleaseStrategy = "release-it" | "commit-and-tag-version" | "changesets" | "none";
|
|
24
|
+
/** User's answers from the interactive prompt or CLI flags. */
|
|
25
|
+
interface ProjectConfig {
|
|
26
|
+
/** Project name (from package.json name or user input) */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Whether this is a new project or existing */
|
|
29
|
+
isNew: boolean;
|
|
30
|
+
/** Project structure */
|
|
31
|
+
structure: "single" | "monorepo";
|
|
32
|
+
/** Include @bensandee/lint-rules oxlint plugin */
|
|
33
|
+
useLintRules: boolean;
|
|
34
|
+
/** Formatter choice */
|
|
35
|
+
formatter: "oxfmt" | "prettier";
|
|
36
|
+
/** Set up vitest with a starter test */
|
|
37
|
+
setupVitest: boolean;
|
|
38
|
+
/** CI platform choice */
|
|
39
|
+
ci: CiPlatform;
|
|
40
|
+
/** Set up Renovate for automated dependency updates */
|
|
41
|
+
setupRenovate: boolean;
|
|
42
|
+
/** Release management strategy */
|
|
43
|
+
releaseStrategy: ReleaseStrategy;
|
|
44
|
+
/** Project type determines tsconfig base configuration */
|
|
45
|
+
projectType: "default" | "node" | "react" | "library";
|
|
46
|
+
/** Auto-detect and configure tsconfig bases for monorepo packages */
|
|
47
|
+
detectPackageTypes: boolean;
|
|
48
|
+
/** Target directory (default: cwd) */
|
|
49
|
+
targetDir: string;
|
|
50
|
+
}
|
|
51
|
+
/** Result from a single generator: what file was written and how. */
|
|
52
|
+
interface GeneratorResult {
|
|
53
|
+
filePath: string;
|
|
54
|
+
action: "created" | "updated" | "skipped";
|
|
55
|
+
/** Human-readable description of what changed */
|
|
56
|
+
description: string;
|
|
57
|
+
}
|
|
58
|
+
/** Context passed to each generator function. */
|
|
59
|
+
interface GeneratorContext {
|
|
60
|
+
config: ProjectConfig;
|
|
61
|
+
/** Absolute path to target directory */
|
|
62
|
+
targetDir: string;
|
|
63
|
+
/** Pre-parsed package.json from the target directory, or undefined if missing/invalid */
|
|
64
|
+
packageJson: PackageJson | undefined;
|
|
65
|
+
/** Check whether a file exists in the target directory */
|
|
66
|
+
exists: (relativePath: string) => boolean;
|
|
67
|
+
/** Read an existing file from the target directory, returns undefined if not found */
|
|
68
|
+
read: (relativePath: string) => string | undefined;
|
|
69
|
+
/** Write a file to the target directory (creating directories as needed) */
|
|
70
|
+
write: (relativePath: string, content: string) => void;
|
|
71
|
+
/** Prompt user for conflict resolution on non-mergeable files */
|
|
72
|
+
confirmOverwrite: (relativePath: string) => Promise<"overwrite" | "skip">;
|
|
73
|
+
}
|
|
74
|
+
/** Generator function signature. */
|
|
75
|
+
type Generator = (ctx: GeneratorContext) => Promise<GeneratorResult>;
|
|
76
|
+
/** State detected from an existing project directory. */
|
|
77
|
+
interface DetectedProjectState {
|
|
78
|
+
hasPackageJson: boolean;
|
|
79
|
+
hasTsconfig: boolean;
|
|
80
|
+
hasOxlintConfig: boolean;
|
|
81
|
+
/** Legacy .oxlintrc.json found (should be migrated to oxlint.config.ts) */
|
|
82
|
+
hasLegacyOxlintJson: boolean;
|
|
83
|
+
hasGitignore: boolean;
|
|
84
|
+
hasVitestConfig: boolean;
|
|
85
|
+
hasTsdownConfig: boolean;
|
|
86
|
+
hasPnpmWorkspace: boolean;
|
|
87
|
+
hasKnipConfig: boolean;
|
|
88
|
+
hasRenovateConfig: boolean;
|
|
89
|
+
hasReleaseItConfig: boolean;
|
|
90
|
+
hasCommitAndTagVersionConfig: boolean;
|
|
91
|
+
hasChangesetsConfig: boolean;
|
|
92
|
+
/** Legacy tooling configs found */
|
|
93
|
+
legacyConfigs: LegacyConfig[];
|
|
94
|
+
}
|
|
95
|
+
declare const LEGACY_TOOLS: readonly ["eslint", "prettier", "jest", "webpack", "rollup"];
|
|
96
|
+
type LegacyTool = (typeof LEGACY_TOOLS)[number];
|
|
97
|
+
interface LegacyConfig {
|
|
98
|
+
tool: LegacyTool;
|
|
99
|
+
files: string[];
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { type DetectedProjectState, type Generator, type GeneratorContext, type GeneratorResult, type LegacyConfig, type ProjectConfig };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bensandee/tooling",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
|
|
5
|
+
"bin": {
|
|
6
|
+
"tooling": "./dist/bin.mjs"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.mjs",
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#src/*": "./src/*.ts"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.mts",
|
|
21
|
+
"import": "./dist/index.mjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@clack/prompts": "^1.0.1",
|
|
29
|
+
"citty": "^0.2.1",
|
|
30
|
+
"jsonc-parser": "^3.3.1",
|
|
31
|
+
"zod": "^4.3.6"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "24.10.11",
|
|
35
|
+
"tsdown": "0.20.3",
|
|
36
|
+
"typescript": "5.9.3",
|
|
37
|
+
"vitest": "4.0.18",
|
|
38
|
+
"@bensandee/config": "0.2.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"dev": "tsdown --watch",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "vitest run"
|
|
45
|
+
}
|
|
46
|
+
}
|