@functional-examples/test 0.0.0-alpha.1

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 (52) hide show
  1. package/dist/commands/index.d.ts +41 -0
  2. package/dist/commands/index.d.ts.map +1 -0
  3. package/dist/commands/index.js +9 -0
  4. package/dist/commands/index.js.map +1 -0
  5. package/dist/commands/list.d.ts +10 -0
  6. package/dist/commands/list.d.ts.map +1 -0
  7. package/dist/commands/list.js +57 -0
  8. package/dist/commands/list.js.map +1 -0
  9. package/dist/commands/test.d.ts +19 -0
  10. package/dist/commands/test.d.ts.map +1 -0
  11. package/dist/commands/test.js +110 -0
  12. package/dist/commands/test.js.map +1 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +74 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/integration.spec.d.ts +1 -0
  18. package/dist/reporters/index.d.ts +5 -0
  19. package/dist/reporters/index.d.ts.map +1 -0
  20. package/dist/reporters/index.js +4 -0
  21. package/dist/reporters/index.js.map +1 -0
  22. package/dist/reporters/pretty.d.ts +3 -0
  23. package/dist/reporters/pretty.d.ts.map +1 -0
  24. package/dist/reporters/pretty.js +58 -0
  25. package/dist/reporters/pretty.js.map +1 -0
  26. package/dist/reporters/resolve.d.ts +7 -0
  27. package/dist/reporters/resolve.d.ts.map +1 -0
  28. package/dist/reporters/resolve.js +39 -0
  29. package/dist/reporters/resolve.js.map +1 -0
  30. package/dist/reporters/tap.d.ts +3 -0
  31. package/dist/reporters/tap.d.ts.map +1 -0
  32. package/dist/reporters/tap.js +53 -0
  33. package/dist/reporters/tap.js.map +1 -0
  34. package/dist/reporters/types.d.ts +50 -0
  35. package/dist/reporters/types.d.ts.map +1 -0
  36. package/dist/reporters/types.js +2 -0
  37. package/dist/reporters/types.js.map +1 -0
  38. package/dist/runner.d.ts +15 -0
  39. package/dist/runner.d.ts.map +1 -0
  40. package/dist/runner.js +232 -0
  41. package/dist/runner.js.map +1 -0
  42. package/dist/runner.spec.d.ts +1 -0
  43. package/dist/schema.d.ts +298 -0
  44. package/dist/schema.d.ts.map +1 -0
  45. package/dist/schema.js +115 -0
  46. package/dist/schema.js.map +1 -0
  47. package/dist/schema.spec.d.ts +1 -0
  48. package/dist/types.d.ts +37 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +2 -0
  51. package/dist/types.js.map +1 -0
  52. package/package.json +54 -0
package/dist/schema.js ADDED
@@ -0,0 +1,115 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Assertions for stdout/stderr output
4
+ */
5
+ const stdioAssertionsSchema = z
6
+ .strictObject({
7
+ contains: z.string().optional(),
8
+ matches: z.string().optional(),
9
+ })
10
+ .optional();
11
+ /**
12
+ * Single file assertion — existence and optional content checks
13
+ */
14
+ const fileAssertionSchema = z.strictObject({
15
+ path: z.string(),
16
+ contains: z.string().optional(),
17
+ matches: z.string().optional(),
18
+ });
19
+ const fileAssertionsSchema = fileAssertionSchema.optional();
20
+ /**
21
+ * Single directory assertion — existence check
22
+ */
23
+ const dirAssertionSchema = z.strictObject({
24
+ path: z.string(),
25
+ });
26
+ const dirAssertionsSchema = dirAssertionSchema.optional();
27
+ /**
28
+ * Test assertions
29
+ *
30
+ * Uses z.lazy() for the `not` field to allow recursive self-reference
31
+ * (e.g. `not: { file: { path: 'foo' } }` negates inner assertions).
32
+ */
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ const assertionsSchema = z
35
+ .strictObject({
36
+ exitCode: z.number().int().optional(),
37
+ stdout: stdioAssertionsSchema,
38
+ stderr: stdioAssertionsSchema,
39
+ file: fileAssertionsSchema,
40
+ files: z.array(fileAssertionSchema).optional(),
41
+ dir: dirAssertionsSchema,
42
+ directories: z.array(dirAssertionSchema).optional(),
43
+ not: z.lazy(() => assertionsSchema).optional(),
44
+ })
45
+ .optional();
46
+ /**
47
+ * Shared execution defaults (cwd, env, timeout) — no command
48
+ */
49
+ const testDefaultsSchema = z.strictObject({
50
+ /** Working directory relative to example */
51
+ cwd: z.string().optional(),
52
+ /** Environment variables */
53
+ env: z.record(z.string(), z.string()).optional(),
54
+ /** Timeout in milliseconds */
55
+ timeout: z.number().int().positive().optional(),
56
+ });
57
+ /**
58
+ * Test execution options (single-command format)
59
+ */
60
+ const testOptionsSchema = testDefaultsSchema.extend({
61
+ /** Command to execute */
62
+ command: z.string(),
63
+ });
64
+ /**
65
+ * A command step in a multi-step sequence
66
+ */
67
+ export const commandStepSchema = z.strictObject({
68
+ /** Command to execute */
69
+ command: z.string(),
70
+ /** Working directory relative to example */
71
+ cwd: z.string().optional(),
72
+ /** Environment variables */
73
+ env: z.record(z.string(), z.string()).optional(),
74
+ /** Timeout in milliseconds */
75
+ timeout: z.number().int().positive().optional(),
76
+ /** Assertions for this step (defaults to exitCode === 0 if omitted) */
77
+ assertions: assertionsSchema,
78
+ });
79
+ /**
80
+ * Step union — currently only command steps, extensible later
81
+ */
82
+ const testStepSchema = commandStepSchema;
83
+ /**
84
+ * Single test case — supports either options+assertions or steps format
85
+ */
86
+ const optionsTestCaseSchema = z.strictObject({
87
+ /** Test name */
88
+ name: z.string(),
89
+ options: testOptionsSchema,
90
+ assertions: assertionsSchema,
91
+ });
92
+ const stepsTestCaseSchema = z.strictObject({
93
+ /** Test name */
94
+ name: z.string(),
95
+ /** Default cwd, env, timeout inherited by all steps */
96
+ options: testDefaultsSchema.optional(),
97
+ steps: z.array(testStepSchema).min(1),
98
+ });
99
+ export const testCaseSchema = z.union([
100
+ optionsTestCaseSchema,
101
+ stepsTestCaseSchema,
102
+ ]);
103
+ /**
104
+ * Test field can be single test or array
105
+ */
106
+ const testFieldSchema = z.union([testCaseSchema, z.array(testCaseSchema)]);
107
+ /**
108
+ * Metadata extension for test plugin
109
+ */
110
+ export const testMetadataSchema = z.object({
111
+ test: testFieldSchema.optional(),
112
+ });
113
+ // JSON Schema for plugin registration
114
+ export const TEST_METADATA_JSON_SCHEMA = z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AAE;IAC/C,uEAAuE;IACvE,UAAU,EAAE,gBAAgB;CAC7B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC3C,gBAAgB;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,iBAAiB;IAC1B,UAAU,EAAE,gBAAgB;CAC7B,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,gBAAgB;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,uDAAuD;IACvD,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IACtC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC;IACpC,qBAAqB;IACrB,mBAAmB;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAeH,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { ReporterConfig, ReporterFactory } from './reporters/types.js';
2
+ /**
3
+ * Options for the test plugin
4
+ */
5
+ export interface TestPluginOptions {
6
+ /**
7
+ * Default timeout for tests in ms
8
+ * @default 30000
9
+ */
10
+ timeout?: number;
11
+ /**
12
+ * Custom reporters keyed by name.
13
+ * Can be a factory function or module path string.
14
+ * Built-in: 'pretty', 'tap'
15
+ */
16
+ reporters?: Record<string, ReporterConfig>;
17
+ /**
18
+ * Default reporter when not in CI
19
+ * @default 'pretty'
20
+ */
21
+ defaultReporter?: string;
22
+ /**
23
+ * Default reporter when in CI
24
+ * @default 'tap'
25
+ */
26
+ ciReporter?: string;
27
+ }
28
+ /**
29
+ * Resolved options with reporter factories
30
+ */
31
+ export interface ResolvedTestPluginOptions {
32
+ timeout: number;
33
+ reporters: Record<string, ReporterFactory>;
34
+ defaultReporter: string;
35
+ ciReporter: string;
36
+ }
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE3C;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@functional-examples/test",
3
+ "version": "0.0.0-alpha.1",
4
+ "type": "module",
5
+ "description": "Test runner plugin for functional-examples",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "peerDependencies": {
22
+ "functional-examples": "0.0.0-alpha.1"
23
+ },
24
+ "dependencies": {
25
+ "zod": "4.3.6",
26
+ "cli-forge": "1.2.0",
27
+ "@functional-examples/devkit": "0.0.0-alpha.1"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "22.19.8",
31
+ "typescript": "^5.7.2",
32
+ "vitest": "^1.3.1",
33
+ "@functional-examples/devkit": "0.0.0-alpha.1",
34
+ "functional-examples": "0.0.0-alpha.1"
35
+ },
36
+ "license": "MIT",
37
+ "author": {
38
+ "name": "Craigory Coppola",
39
+ "url": "https://craigory.dev"
40
+ },
41
+ "homepage": "https://craigory.dev/functional-examples",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/AgentEnder/functional-examples.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/AgentEnder/functional-examples/issues"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc -p tsconfig.lib.json",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest"
53
+ }
54
+ }