readyup 0.0.0 → 0.13.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/bin/rdy.js +11 -0
  4. package/dist/esm/.cache +1 -0
  5. package/dist/esm/assertIsPreflightCollection.d.ts +2 -0
  6. package/dist/esm/assertIsPreflightCollection.js +27 -0
  7. package/dist/esm/assertIsRdyKit.d.ts +2 -0
  8. package/dist/esm/assertIsRdyKit.js +27 -0
  9. package/dist/esm/authoring.d.ts +6 -0
  10. package/dist/esm/authoring.js +22 -0
  11. package/dist/esm/bin/preflight.d.ts +1 -0
  12. package/dist/esm/bin/preflight.js +12 -0
  13. package/dist/esm/bin/rdy.d.ts +1 -0
  14. package/dist/esm/bin/rdy.js +12 -0
  15. package/dist/esm/bin/route.d.ts +1 -0
  16. package/dist/esm/bin/route.js +202 -0
  17. package/dist/esm/check-utils/filesystem.d.ts +4 -0
  18. package/dist/esm/check-utils/filesystem.js +26 -0
  19. package/dist/esm/check-utils/index.d.ts +3 -0
  20. package/dist/esm/check-utils/index.js +14 -0
  21. package/dist/esm/check-utils/package-json.d.ts +6 -0
  22. package/dist/esm/check-utils/package-json.js +40 -0
  23. package/dist/esm/check-utils/semver.d.ts +1 -0
  24. package/dist/esm/check-utils/semver.js +12 -0
  25. package/dist/esm/cli.d.ts +36 -0
  26. package/dist/esm/cli.js +285 -0
  27. package/dist/esm/compile/compileCommand.d.ts +1 -0
  28. package/dist/esm/compile/compileCommand.js +121 -0
  29. package/dist/esm/compile/compileConfig.d.ts +5 -0
  30. package/dist/esm/compile/compileConfig.js +52 -0
  31. package/dist/esm/compile/validateCompiledOutput.d.ts +1 -0
  32. package/dist/esm/compile/validateCompiledOutput.js +29 -0
  33. package/dist/esm/config.d.ts +2 -0
  34. package/dist/esm/config.js +28 -0
  35. package/dist/esm/expandGitHubShorthand.d.ts +1 -0
  36. package/dist/esm/expandGitHubShorthand.js +26 -0
  37. package/dist/esm/formatCombinedSummary.d.ts +2 -0
  38. package/dist/esm/formatCombinedSummary.js +40 -0
  39. package/dist/esm/formatJsonError.d.ts +1 -0
  40. package/dist/esm/formatJsonError.js +6 -0
  41. package/dist/esm/formatJsonReport.d.ts +10 -0
  42. package/dist/esm/formatJsonReport.js +90 -0
  43. package/dist/esm/index.d.ts +4 -0
  44. package/dist/esm/index.js +37 -0
  45. package/dist/esm/init/initCommand.d.ts +6 -0
  46. package/dist/esm/init/initCommand.js +33 -0
  47. package/dist/esm/init/scaffold.d.ts +11 -0
  48. package/dist/esm/init/scaffold.js +15 -0
  49. package/dist/esm/init/templates.d.ts +2 -0
  50. package/dist/esm/init/templates.js +37 -0
  51. package/dist/esm/isRecord.d.ts +1 -0
  52. package/dist/esm/isRecord.js +6 -0
  53. package/dist/esm/jitiImport.d.ts +1 -0
  54. package/dist/esm/jitiImport.js +23 -0
  55. package/dist/esm/loadConfig.d.ts +2 -0
  56. package/dist/esm/loadConfig.js +74 -0
  57. package/dist/esm/loadRemoteCollection.d.ts +6 -0
  58. package/dist/esm/loadRemoteCollection.js +40 -0
  59. package/dist/esm/loadRemoteKit.d.ts +6 -0
  60. package/dist/esm/loadRemoteKit.js +40 -0
  61. package/dist/esm/parseArgs.d.ts +15 -0
  62. package/dist/esm/parseArgs.js +93 -0
  63. package/dist/esm/reportPreflight.d.ts +7 -0
  64. package/dist/esm/reportPreflight.js +105 -0
  65. package/dist/esm/reportRdy.d.ts +7 -0
  66. package/dist/esm/reportRdy.js +105 -0
  67. package/dist/esm/resolveCollectionExports.d.ts +1 -0
  68. package/dist/esm/resolveCollectionExports.js +20 -0
  69. package/dist/esm/resolveGitHubToken.d.ts +1 -0
  70. package/dist/esm/resolveGitHubToken.js +22 -0
  71. package/dist/esm/resolveKitExports.d.ts +1 -0
  72. package/dist/esm/resolveKitExports.js +20 -0
  73. package/dist/esm/resolveRequestedNames.d.ts +2 -0
  74. package/dist/esm/resolveRequestedNames.js +38 -0
  75. package/dist/esm/runPreflight.d.ts +7 -0
  76. package/dist/esm/runPreflight.js +157 -0
  77. package/dist/esm/runRdy.d.ts +7 -0
  78. package/dist/esm/runRdy.js +157 -0
  79. package/dist/esm/terminal.d.ts +6 -0
  80. package/dist/esm/terminal.js +55 -0
  81. package/dist/esm/types.d.ts +139 -0
  82. package/dist/esm/types.js +10 -0
  83. package/dist/esm/validateCollection.d.ts +2 -0
  84. package/dist/esm/validateCollection.js +27 -0
  85. package/dist/esm/validateKit.d.ts +2 -0
  86. package/dist/esm/validateKit.js +27 -0
  87. package/dist/esm/version.d.ts +1 -0
  88. package/dist/esm/version.js +4 -0
  89. package/dist/esm/writeFileWithCheck.d.ts +10 -0
  90. package/dist/esm/writeFileWithCheck.js +41 -0
  91. package/package.json +56 -10
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 William Thorsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # readyup
2
+
3
+ Run pre-deployment verification checks against your environment and configuration. Define checklists in TypeScript kits, run them locally or from a remote source, and get clear pass/fail reporting with remediation hints.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D readyup
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ Scaffold a starter config and kit:
14
+
15
+ ```bash
16
+ rdy init
17
+ ```
18
+
19
+ This creates two files:
20
+
21
+ **`.config/rdy.config.ts`** — repo-level settings:
22
+
23
+ ```ts
24
+ import { defineRdyConfig } from 'readyup';
25
+
26
+ export default defineRdyConfig({
27
+ compile: {
28
+ srcDir: '.rdy/kits',
29
+ outDir: '.rdy/kits',
30
+ },
31
+ });
32
+ ```
33
+
34
+ **`.rdy/kits/default.ts`** — starter kit:
35
+
36
+ ```ts
37
+ import { defineRdyKit } from 'readyup';
38
+
39
+ export default defineRdyKit({
40
+ checklists: [
41
+ {
42
+ name: 'deploy',
43
+ checks: [
44
+ {
45
+ name: 'environment variables set',
46
+ check: () => Boolean(process.env['NODE_ENV']),
47
+ fix: 'Set NODE_ENV before deploying',
48
+ },
49
+ ],
50
+ },
51
+ ],
52
+ });
53
+ ```
54
+
55
+ Run the checks:
56
+
57
+ ```bash
58
+ rdy run
59
+ ```
60
+
61
+ ## CLI reference
62
+
63
+ ```
64
+ rdy [names...] [options]
65
+ rdy <command> [options]
66
+ ```
67
+
68
+ ### Commands
69
+
70
+ | Command | Description |
71
+ | ---------------- | ------------------------------------------------ |
72
+ | `run [names...]` | Run checklists (default) |
73
+ | `compile [file]` | Bundle TypeScript kit(s) into self-contained ESM |
74
+ | `init` | Scaffold a starter config and kit |
75
+
76
+ ### Run options
77
+
78
+ | Option | Description |
79
+ | ------------------------------- | ----------------------------------------- |
80
+ | `--file, -f <path>` | Path to a local kit file |
81
+ | `--github, -g <org/repo[@ref]>` | Fetch kit from a GitHub repository |
82
+ | `--local, -l <path>` | Load compiled kit from a local repository |
83
+ | `--url, -u <url>` | Fetch kit from a URL |
84
+ | `--kit, -k <name>` | Kit name (default: `"default"`) |
85
+ | `--json, -j` | Output results as JSON |
86
+ | `--fail-on, -F <severity>` | Fail on this severity or above |
87
+ | `--report-on, -R <severity>` | Report this severity or above |
88
+
89
+ ## Authoring API
90
+
91
+ All helpers are type-safe identity functions that provide editor autocomplete without runtime overhead. Import them from `readyup`.
92
+
93
+ | Helper | Description |
94
+ | -------------------------- | ------------------------------------ |
95
+ | `defineRdyConfig` | Repo-level config |
96
+ | `defineRdyKit` | Kit (collection of checklists) |
97
+ | `defineRdyChecklist` | Flat checklist |
98
+ | `defineRdyStagedChecklist` | Staged checklist (sequential groups) |
99
+ | `defineChecklists` | Array of checklists |
100
+
101
+ ## Check utilities
102
+
103
+ Reusable check functions for common assertions:
104
+
105
+ ```ts
106
+ import { fileExists, fileContains, hasPackageJsonField } from 'readyup';
107
+ ```
108
+
109
+ | Function | Description |
110
+ | ------------------------------------------- | ------------------------------------------------------ |
111
+ | `fileExists(path)` | File exists at path |
112
+ | `fileContains(path, pattern)` | File matches a string or regex |
113
+ | `fileDoesNotContain(path, pattern)` | File does not match |
114
+ | `readFile(path)` | Read file contents (returns `undefined` if missing) |
115
+ | `hasPackageJsonField(field, value?)` | package.json has a field (optionally matching a value) |
116
+ | `hasDevDependency(name)` | package.json has a dev dependency |
117
+ | `hasMinDevDependencyVersion(name, version)` | Dev dependency meets minimum version |
118
+ | `readPackageJson()` | Parse package.json |
119
+ | `compareVersions(a, b)` | Compare semver strings |
120
+
121
+ ## License
122
+
123
+ MIT
package/bin/rdy.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ try {
3
+ await import('../dist/esm/bin/rdy.js');
4
+ } catch (error) {
5
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
6
+ process.stderr.write('rdy: build output not found — run `pnpm run build` first\n');
7
+ } else {
8
+ process.stderr.write(`rdy: failed to load: ${error.message}\n`);
9
+ }
10
+ process.exit(1);
11
+ }
@@ -0,0 +1 @@
1
+ 904e9f3de206169e1dd9a08d2da490bb5bc2197691c2b1f6695536e33ae207d2
@@ -0,0 +1,2 @@
1
+ import type { PreflightCollection } from './types.ts';
2
+ export declare function assertIsPreflightCollection(raw: unknown): asserts raw is PreflightCollection;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ const SeveritySchema = z.enum(["error", "warn", "recommend"]);
3
+ const FlatChecklistSchema = z.looseObject({
4
+ name: z.string().min(1),
5
+ checks: z.array(z.unknown())
6
+ });
7
+ const StagedChecklistSchema = z.looseObject({
8
+ name: z.string().min(1),
9
+ groups: z.array(z.unknown())
10
+ });
11
+ const ChecklistSchema = z.union([FlatChecklistSchema, StagedChecklistSchema]).refine((val) => !("checks" in val && "groups" in val), {
12
+ message: "Checklist cannot have both 'checks' and 'groups'"
13
+ });
14
+ const PreflightCollectionSchema = z.looseObject({
15
+ checklists: z.array(ChecklistSchema),
16
+ defaultSeverity: SeveritySchema.optional(),
17
+ failOn: SeveritySchema.optional(),
18
+ fixLocation: z.enum(["inline", "end"]).optional(),
19
+ reportOn: SeveritySchema.optional(),
20
+ suites: z.record(z.string(), z.array(z.string())).optional()
21
+ });
22
+ function assertIsPreflightCollection(raw) {
23
+ PreflightCollectionSchema.parse(raw);
24
+ }
25
+ export {
26
+ assertIsPreflightCollection
27
+ };
@@ -0,0 +1,2 @@
1
+ import type { RdyKit } from './types.ts';
2
+ export declare function assertIsRdyKit(raw: unknown): asserts raw is RdyKit;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ const SeveritySchema = z.enum(["error", "warn", "recommend"]);
3
+ const FlatChecklistSchema = z.looseObject({
4
+ name: z.string().min(1),
5
+ checks: z.array(z.unknown())
6
+ });
7
+ const StagedChecklistSchema = z.looseObject({
8
+ name: z.string().min(1),
9
+ groups: z.array(z.unknown())
10
+ });
11
+ const ChecklistSchema = z.union([FlatChecklistSchema, StagedChecklistSchema]).refine((val) => !("checks" in val && "groups" in val), {
12
+ message: "Checklist cannot have both 'checks' and 'groups'"
13
+ });
14
+ const RdyKitSchema = z.looseObject({
15
+ checklists: z.array(ChecklistSchema),
16
+ defaultSeverity: SeveritySchema.optional(),
17
+ failOn: SeveritySchema.optional(),
18
+ fixLocation: z.enum(["inline", "end"]).optional(),
19
+ reportOn: SeveritySchema.optional(),
20
+ suites: z.record(z.string(), z.array(z.string())).optional()
21
+ });
22
+ function assertIsRdyKit(raw) {
23
+ RdyKitSchema.parse(raw);
24
+ }
25
+ export {
26
+ assertIsRdyKit
27
+ };
@@ -0,0 +1,6 @@
1
+ import type { RdyChecklist, RdyConfig, RdyKit, RdyStagedChecklist } from './types.ts';
2
+ export declare function defineRdyConfig(config: RdyConfig): RdyConfig;
3
+ export declare function defineRdyKit(kit: RdyKit): RdyKit;
4
+ export declare function defineChecklists(checklists: Array<RdyChecklist | RdyStagedChecklist>): Array<RdyChecklist | RdyStagedChecklist>;
5
+ export declare function defineRdyChecklist(checklist: RdyChecklist): RdyChecklist;
6
+ export declare function defineRdyStagedChecklist(checklist: RdyStagedChecklist): RdyStagedChecklist;
@@ -0,0 +1,22 @@
1
+ function defineRdyConfig(config) {
2
+ return config;
3
+ }
4
+ function defineRdyKit(kit) {
5
+ return kit;
6
+ }
7
+ function defineChecklists(checklists) {
8
+ return checklists;
9
+ }
10
+ function defineRdyChecklist(checklist) {
11
+ return checklist;
12
+ }
13
+ function defineRdyStagedChecklist(checklist) {
14
+ return checklist;
15
+ }
16
+ export {
17
+ defineChecklists,
18
+ defineRdyChecklist,
19
+ defineRdyConfig,
20
+ defineRdyKit,
21
+ defineRdyStagedChecklist
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import process from "node:process";
2
+ import { routeCommand } from "./route.js";
3
+ let exitCode;
4
+ try {
5
+ exitCode = await routeCommand(process.argv.slice(2));
6
+ } catch (error) {
7
+ const message = error instanceof Error ? error.message : String(error);
8
+ process.stderr.write(`preflight: unexpected error: ${message}
9
+ `);
10
+ exitCode = 1;
11
+ }
12
+ process.exit(exitCode);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import process from "node:process";
2
+ import { routeCommand } from "./route.js";
3
+ let exitCode;
4
+ try {
5
+ exitCode = await routeCommand(process.argv.slice(2));
6
+ } catch (error) {
7
+ const message = error instanceof Error ? error.message : String(error);
8
+ process.stderr.write(`rdy: unexpected error: ${message}
9
+ `);
10
+ exitCode = 1;
11
+ }
12
+ process.exit(exitCode);
@@ -0,0 +1 @@
1
+ export declare function routeCommand(args: string[]): Promise<number>;
@@ -0,0 +1,202 @@
1
+ import process from "node:process";
2
+ import { parseRunArgs, resolveKitSource, runCommand } from "../cli.js";
3
+ import { compileCommand } from "../compile/compileCommand.js";
4
+ import { initCommand } from "../init/initCommand.js";
5
+ import { loadConfig } from "../loadConfig.js";
6
+ import { parseArgs, translateParseError } from "../parseArgs.js";
7
+ import { VERSION } from "../version.js";
8
+ const SUBCOMMANDS = ["compile", "init"];
9
+ const MIN_PREFIX_LENGTH = 3;
10
+ function extractMessage(error) {
11
+ return error instanceof Error ? error.message : String(error);
12
+ }
13
+ function showHelp() {
14
+ console.info(`
15
+ Usage: rdy [names...] [options]
16
+ rdy <command> [options]
17
+
18
+ Commands:
19
+ run [names...] Run rdy checklists (default)
20
+ compile [file] Bundle TypeScript kit(s) into self-contained ESM file(s)
21
+ init Scaffold a starter config and kit
22
+
23
+ Run options:
24
+ --file, -f <path> Path to a local kit file
25
+ --github, -g <org/repo[@ref]> Fetch kit from a GitHub repository
26
+ --local, -l <path> Load compiled kit from a local repository
27
+ --url, -u <url> Fetch kit from a URL
28
+ --kit, -k <name> Kit name (default: "default")
29
+ --json, -j Output results as JSON
30
+ --fail-on, -F <severity> Fail on this severity or above (error, warn, recommend)
31
+ --report-on, -R <severity> Report this severity or above (error, warn, recommend)
32
+
33
+ Global options:
34
+ --help, -h Show this help message
35
+ --version, -V Show version number
36
+ `);
37
+ }
38
+ function showRunHelp() {
39
+ console.info(`
40
+ Usage: rdy run [names...] [options]
41
+
42
+ Run rdy checklists. If no names are given, all checklists are run.
43
+
44
+ Kit source (mutually exclusive):
45
+ --file, -f <path> Path to a local kit file
46
+ --github, -g <org/repo[@ref]> Fetch kit from a GitHub repository
47
+ --local, -l <path> Load compiled kit from a local repository
48
+ --url, -u <url> Fetch kit from a URL
49
+
50
+ Options:
51
+ --kit, -k <name> Kit name (default: "default")
52
+ --json, -j Output results as JSON
53
+ --fail-on, -F <severity> Fail on this severity or above (error, warn, recommend)
54
+ --report-on, -R <severity> Report this severity or above (error, warn, recommend)
55
+ --help, -h Show this help message
56
+
57
+ --kit accepts relative paths (e.g., --kit shared/deploy).
58
+ Defaults to .rdy/kits/default.ts when no source is given.
59
+ `);
60
+ }
61
+ function showCompileHelp() {
62
+ console.info(`
63
+ Usage: rdy compile [<file>] [options]
64
+
65
+ Bundle TypeScript kit(s) into self-contained ESM bundle(s).
66
+ If no file is given, all sources from the config's srcDir are compiled.
67
+
68
+ Modes:
69
+ rdy compile Compile all sources from the config's srcDir
70
+ rdy compile <file> Compile a single file
71
+
72
+ Options:
73
+ --output, -o <path> Output file path (single-file mode only)
74
+ --help, -h Show this help message
75
+ `);
76
+ }
77
+ function showInitHelp() {
78
+ console.info(`
79
+ Usage: rdy init [options]
80
+
81
+ Scaffold a starter config and kit file.
82
+
83
+ Options:
84
+ --dry-run, -n Preview changes without writing files
85
+ --force, -f Overwrite existing files
86
+ --help, -h Show this help message
87
+ `);
88
+ }
89
+ function findTypoMatch(input) {
90
+ if (input.length < MIN_PREFIX_LENGTH || input.startsWith("-")) {
91
+ return void 0;
92
+ }
93
+ for (const cmd of SUBCOMMANDS) {
94
+ if (cmd !== input && cmd.startsWith(input)) {
95
+ return cmd;
96
+ }
97
+ }
98
+ return void 0;
99
+ }
100
+ async function routeCommand(args) {
101
+ const command = args[0];
102
+ if (command === void 0 || command === "--help" || command === "-h") {
103
+ showHelp();
104
+ return 0;
105
+ }
106
+ if (command === "--version" || command === "-V") {
107
+ console.info(VERSION);
108
+ return 0;
109
+ }
110
+ if (command === "run") {
111
+ return handleRun(args.slice(1));
112
+ }
113
+ if (command === "compile") {
114
+ const flags = args.slice(1);
115
+ if (flags.some((f) => f === "--help" || f === "-h")) {
116
+ showCompileHelp();
117
+ return 0;
118
+ }
119
+ try {
120
+ return await compileCommand(flags);
121
+ } catch (error) {
122
+ process.stderr.write(`Error: ${extractMessage(error)}
123
+ `);
124
+ return 1;
125
+ }
126
+ }
127
+ if (command === "init") {
128
+ const flags = args.slice(1);
129
+ if (flags.some((f) => f === "--help" || f === "-h")) {
130
+ showInitHelp();
131
+ return 0;
132
+ }
133
+ const initFlagSchema = {
134
+ dryRun: { long: "--dry-run", type: "boolean", short: "-n" },
135
+ force: { long: "--force", type: "boolean", short: "-f" }
136
+ };
137
+ let parsed;
138
+ try {
139
+ parsed = parseArgs(flags, initFlagSchema);
140
+ } catch (error) {
141
+ process.stderr.write(`Error: ${translateParseError(error)}
142
+ `);
143
+ return 1;
144
+ }
145
+ return initCommand({ dryRun: parsed.flags.dryRun, force: parsed.flags.force });
146
+ }
147
+ const typoMatch = findTypoMatch(command);
148
+ if (typoMatch !== void 0) {
149
+ process.stderr.write(`Error: Unknown command '${command}'. Did you mean 'rdy ${typoMatch}'?
150
+ `);
151
+ return 1;
152
+ }
153
+ return handleRun(args);
154
+ }
155
+ async function handleRun(flags) {
156
+ if (flags.some((f) => f === "--help" || f === "-h")) {
157
+ showRunHelp();
158
+ return 0;
159
+ }
160
+ let parsed;
161
+ try {
162
+ parsed = parseRunArgs(flags);
163
+ } catch (error) {
164
+ process.stderr.write(`Error: ${extractMessage(error)}
165
+ `);
166
+ return 1;
167
+ }
168
+ let config;
169
+ try {
170
+ config = await loadConfig();
171
+ } catch (error) {
172
+ process.stderr.write(`Error: ${extractMessage(error)}
173
+ `);
174
+ return 1;
175
+ }
176
+ let kitSource;
177
+ try {
178
+ kitSource = resolveKitSource({
179
+ filePath: parsed.filePath,
180
+ githubValue: parsed.githubValue,
181
+ localValue: parsed.localValue,
182
+ urlValue: parsed.urlValue,
183
+ kitName: parsed.kitName,
184
+ internalDir: config.internal.dir,
185
+ internalExtension: config.internal.extension
186
+ });
187
+ } catch (error) {
188
+ process.stderr.write(`Error: ${extractMessage(error)}
189
+ `);
190
+ return 1;
191
+ }
192
+ return runCommand({
193
+ kitSource,
194
+ json: parsed.json,
195
+ names: parsed.names,
196
+ ...parsed.failOn !== void 0 && { failOn: parsed.failOn },
197
+ ...parsed.reportOn !== void 0 && { reportOn: parsed.reportOn }
198
+ });
199
+ }
200
+ export {
201
+ routeCommand
202
+ };
@@ -0,0 +1,4 @@
1
+ export declare function fileExists(relativePath: string): boolean;
2
+ export declare function readFile(relativePath: string): string | undefined;
3
+ export declare function fileContains(relativePath: string, pattern: RegExp): boolean;
4
+ export declare function fileDoesNotContain(relativePath: string, pattern: RegExp): boolean;
@@ -0,0 +1,26 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ function fileExists(relativePath) {
4
+ return existsSync(join(process.cwd(), relativePath));
5
+ }
6
+ function readFile(relativePath) {
7
+ const fullPath = join(process.cwd(), relativePath);
8
+ if (!existsSync(fullPath)) return void 0;
9
+ return readFileSync(fullPath, "utf8");
10
+ }
11
+ function fileContains(relativePath, pattern) {
12
+ const content = readFile(relativePath);
13
+ if (content === void 0) return false;
14
+ return pattern.test(content);
15
+ }
16
+ function fileDoesNotContain(relativePath, pattern) {
17
+ const content = readFile(relativePath);
18
+ if (content === void 0) return true;
19
+ return !pattern.test(content);
20
+ }
21
+ export {
22
+ fileContains,
23
+ fileDoesNotContain,
24
+ fileExists,
25
+ readFile
26
+ };
@@ -0,0 +1,3 @@
1
+ export { fileContains, fileDoesNotContain, fileExists, readFile } from './filesystem.ts';
2
+ export { hasDevDependency, hasMinDevDependencyVersion, hasPackageJsonField, readPackageJson } from './package-json.ts';
3
+ export { compareVersions } from './semver.ts';
@@ -0,0 +1,14 @@
1
+ import { fileContains, fileDoesNotContain, fileExists, readFile } from "./filesystem.js";
2
+ import { hasDevDependency, hasMinDevDependencyVersion, hasPackageJsonField, readPackageJson } from "./package-json.js";
3
+ import { compareVersions } from "./semver.js";
4
+ export {
5
+ compareVersions,
6
+ fileContains,
7
+ fileDoesNotContain,
8
+ fileExists,
9
+ hasDevDependency,
10
+ hasMinDevDependencyVersion,
11
+ hasPackageJsonField,
12
+ readFile,
13
+ readPackageJson
14
+ };
@@ -0,0 +1,6 @@
1
+ export declare function readPackageJson(): Record<string, unknown> | undefined;
2
+ export declare function hasPackageJsonField(field: string, expectedValue?: string): boolean;
3
+ export declare function hasDevDependency(name: string): boolean;
4
+ export declare function hasMinDevDependencyVersion(name: string, minVersion: string, options?: {
5
+ exempt?: (range: string) => boolean;
6
+ }): boolean;
@@ -0,0 +1,40 @@
1
+ import { isRecord } from "../isRecord.js";
2
+ import { readFile } from "./filesystem.js";
3
+ import { compareVersions } from "./semver.js";
4
+ function readPackageJson() {
5
+ const content = readFile("package.json");
6
+ if (content === void 0) return void 0;
7
+ const parsed = JSON.parse(content);
8
+ if (!isRecord(parsed)) return void 0;
9
+ return Object.fromEntries(Object.entries(parsed));
10
+ }
11
+ function hasPackageJsonField(field, expectedValue) {
12
+ const pkg = readPackageJson();
13
+ if (pkg === void 0) return false;
14
+ if (expectedValue !== void 0) return pkg[field] === expectedValue;
15
+ return field in pkg;
16
+ }
17
+ function hasDevDependency(name) {
18
+ const pkg = readPackageJson();
19
+ if (pkg === void 0) return false;
20
+ const devDeps = pkg.devDependencies;
21
+ return isRecord(devDeps) && name in devDeps;
22
+ }
23
+ function hasMinDevDependencyVersion(name, minVersion, options) {
24
+ const pkg = readPackageJson();
25
+ if (pkg === void 0) return false;
26
+ const devDeps = pkg.devDependencies;
27
+ if (!isRecord(devDeps) || !(name in devDeps)) return false;
28
+ const range = devDeps[name];
29
+ if (typeof range !== "string") return false;
30
+ if (options?.exempt?.(range)) return true;
31
+ const versionMatch = /(\d+\.\d+\.\d+)/.exec(range)?.[1];
32
+ if (versionMatch === void 0) return false;
33
+ return compareVersions(versionMatch, minVersion) >= 0;
34
+ }
35
+ export {
36
+ hasDevDependency,
37
+ hasMinDevDependencyVersion,
38
+ hasPackageJsonField,
39
+ readPackageJson
40
+ };
@@ -0,0 +1 @@
1
+ export declare function compareVersions(a: string, b: string): number;
@@ -0,0 +1,12 @@
1
+ function compareVersions(a, b) {
2
+ const partsA = a.split(".").map(Number);
3
+ const partsB = b.split(".").map(Number);
4
+ for (let i = 0; i < 3; i++) {
5
+ const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);
6
+ if (diff !== 0) return diff;
7
+ }
8
+ return 0;
9
+ }
10
+ export {
11
+ compareVersions
12
+ };
@@ -0,0 +1,36 @@
1
+ import type { Severity } from './types.ts';
2
+ export type KitSource = {
3
+ path: string;
4
+ } | {
5
+ url: string;
6
+ };
7
+ interface ParsedRunArgs {
8
+ kitName: string | undefined;
9
+ failOn?: Severity;
10
+ filePath: string | undefined;
11
+ githubValue: string | undefined;
12
+ json: boolean;
13
+ localValue: string | undefined;
14
+ names: string[];
15
+ reportOn?: Severity;
16
+ urlValue: string | undefined;
17
+ }
18
+ export declare function parseRunArgs(flags: string[]): ParsedRunArgs;
19
+ export declare function resolveKitSource({ filePath, githubValue, localValue, urlValue, kitName, internalDir, internalExtension, }: {
20
+ filePath: string | undefined;
21
+ githubValue: string | undefined;
22
+ localValue: string | undefined;
23
+ urlValue: string | undefined;
24
+ kitName: string | undefined;
25
+ internalDir: string;
26
+ internalExtension: string;
27
+ }): KitSource;
28
+ interface RunCommandOptions {
29
+ kitSource: KitSource;
30
+ json: boolean;
31
+ names: string[];
32
+ failOn?: Severity;
33
+ reportOn?: Severity;
34
+ }
35
+ export declare function runCommand({ names, kitSource, json, failOn, reportOn }: RunCommandOptions): Promise<number>;
36
+ export {};