runspec-node 0.3.0 → 0.7.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/cli.d.ts.map +1 -1
- package/dist/cli.js +427 -172
- package/dist/cli.js.map +1 -1
- package/dist/finder.d.ts +0 -2
- package/dist/finder.d.ts.map +1 -1
- package/dist/finder.js +2 -40
- package/dist/finder.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +2 -21
- package/dist/loader.js.map +1 -1
- package/dist/models.d.ts +0 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/parser.js +3 -3
- package/dist/parser.js.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +58 -22
- package/dist/serve.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +448 -180
- package/src/finder.ts +3 -41
- package/src/loader.ts +2 -20
- package/src/models.ts +0 -1
- package/src/parser.ts +4 -4
- package/src/serve.ts +61 -20
- package/tests/test_cli_init.test.ts +210 -0
- package/tests/test_integration.test.ts +21 -21
- package/tests/test_loader.test.ts +8 -43
|
@@ -11,26 +11,26 @@ const COMPLEX = path.join(FIXTURES, 'complex.toml');
|
|
|
11
11
|
|
|
12
12
|
describe('simple.toml', () => {
|
|
13
13
|
test('loads config section', () => {
|
|
14
|
-
const raw = loadRaw(SIMPLE
|
|
14
|
+
const raw = loadRaw(SIMPLE);
|
|
15
15
|
expect(raw.config.autonomyDefault).toBe('confirm');
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('greet runnable present', () => {
|
|
19
|
-
const raw = loadRaw(SIMPLE
|
|
19
|
+
const raw = loadRaw(SIMPLE);
|
|
20
20
|
expect(raw.runnables['greet']).toBeDefined();
|
|
21
21
|
expect(raw.runnables['greet'].description).toBe('Greet someone from the command line');
|
|
22
22
|
expect(raw.runnables['greet'].autonomy).toBe('autonomous');
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('greet args: name is str and required', () => {
|
|
26
|
-
const raw = loadRaw(SIMPLE
|
|
26
|
+
const raw = loadRaw(SIMPLE);
|
|
27
27
|
const inferred = inferScript(raw.runnables['greet'], raw.config.autonomyDefault);
|
|
28
28
|
expect(inferred.args['name'].type).toBe('str');
|
|
29
29
|
expect(inferred.args['name'].required).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('greet args: loud inferred as flag', () => {
|
|
33
|
-
const raw = loadRaw(SIMPLE
|
|
33
|
+
const raw = loadRaw(SIMPLE);
|
|
34
34
|
const inferred = inferScript(raw.runnables['greet'], raw.config.autonomyDefault);
|
|
35
35
|
expect(inferred.args['loud'].type).toBe('flag');
|
|
36
36
|
expect(inferred.args['loud'].required).toBe(false);
|
|
@@ -38,7 +38,7 @@ describe('simple.toml', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
test('greet args: times inferred as int', () => {
|
|
41
|
-
const raw = loadRaw(SIMPLE
|
|
41
|
+
const raw = loadRaw(SIMPLE);
|
|
42
42
|
const inferred = inferScript(raw.runnables['greet'], raw.config.autonomyDefault);
|
|
43
43
|
expect(inferred.args['times'].type).toBe('int');
|
|
44
44
|
expect(inferred.args['times'].default).toBe(1);
|
|
@@ -49,27 +49,27 @@ describe('simple.toml', () => {
|
|
|
49
49
|
|
|
50
50
|
describe('complex.toml', () => {
|
|
51
51
|
test('loads config section', () => {
|
|
52
|
-
const raw = loadRaw(COMPLEX
|
|
52
|
+
const raw = loadRaw(COMPLEX);
|
|
53
53
|
expect(raw.config.autonomyDefault).toBe('confirm');
|
|
54
54
|
expect(raw.config.lang).toBe('python');
|
|
55
55
|
expect(raw.config.version).toBe('1');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
test('pipeline runnable present', () => {
|
|
59
|
-
const raw = loadRaw(COMPLEX
|
|
59
|
+
const raw = loadRaw(COMPLEX);
|
|
60
60
|
expect(raw.runnables['pipeline']).toBeDefined();
|
|
61
61
|
expect(raw.runnables['pipeline'].description).toBe('Process and validate data pipeline files');
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
test('pipeline has run and validate subcommands', () => {
|
|
65
|
-
const raw = loadRaw(COMPLEX
|
|
65
|
+
const raw = loadRaw(COMPLEX);
|
|
66
66
|
const cmds = raw.runnables['pipeline'].commands;
|
|
67
67
|
expect(cmds['run']).toBeDefined();
|
|
68
68
|
expect(cmds['validate']).toBeDefined();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
test('run subcommand: input is path and required', () => {
|
|
72
|
-
const raw = loadRaw(COMPLEX
|
|
72
|
+
const raw = loadRaw(COMPLEX);
|
|
73
73
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
74
74
|
const run = inferred.commands['run'];
|
|
75
75
|
expect(run.args['input'].type).toBe('path');
|
|
@@ -77,7 +77,7 @@ describe('complex.toml', () => {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
test('run subcommand: format is choice with default', () => {
|
|
80
|
-
const raw = loadRaw(COMPLEX
|
|
80
|
+
const raw = loadRaw(COMPLEX);
|
|
81
81
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
82
82
|
const run = inferred.commands['run'];
|
|
83
83
|
expect(run.args['format'].type).toBe('choice');
|
|
@@ -87,7 +87,7 @@ describe('complex.toml', () => {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('run subcommand: workers inferred as int with range', () => {
|
|
90
|
-
const raw = loadRaw(COMPLEX
|
|
90
|
+
const raw = loadRaw(COMPLEX);
|
|
91
91
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
92
92
|
const run = inferred.commands['run'];
|
|
93
93
|
expect(run.args['workers'].type).toBe('int');
|
|
@@ -96,7 +96,7 @@ describe('complex.toml', () => {
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
test('run subcommand: dry-run inferred as flag', () => {
|
|
99
|
-
const raw = loadRaw(COMPLEX
|
|
99
|
+
const raw = loadRaw(COMPLEX);
|
|
100
100
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
101
101
|
const run = inferred.commands['run'];
|
|
102
102
|
expect(run.args['dry-run'].type).toBe('flag');
|
|
@@ -104,7 +104,7 @@ describe('complex.toml', () => {
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
test('run subcommand: tag is multiple', () => {
|
|
107
|
-
const raw = loadRaw(COMPLEX
|
|
107
|
+
const raw = loadRaw(COMPLEX);
|
|
108
108
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
109
109
|
const run = inferred.commands['run'];
|
|
110
110
|
expect(run.args['tag'].multiple).toBe(true);
|
|
@@ -112,7 +112,7 @@ describe('complex.toml', () => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
test('run subcommand: fields has delimiter', () => {
|
|
115
|
-
const raw = loadRaw(COMPLEX
|
|
115
|
+
const raw = loadRaw(COMPLEX);
|
|
116
116
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
117
117
|
const run = inferred.commands['run'];
|
|
118
118
|
expect(run.args['fields'].delimiter).toBe(',');
|
|
@@ -120,7 +120,7 @@ describe('complex.toml', () => {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
test('run subcommand: api-key has env and autonomy', () => {
|
|
123
|
-
const raw = loadRaw(COMPLEX
|
|
123
|
+
const raw = loadRaw(COMPLEX);
|
|
124
124
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
125
125
|
const run = inferred.commands['run'];
|
|
126
126
|
expect(run.args['api-key'].env).toBe('PIPELINE_API_KEY');
|
|
@@ -128,21 +128,21 @@ describe('complex.toml', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
test('run subcommand: verbose has short flag', () => {
|
|
131
|
-
const raw = loadRaw(COMPLEX
|
|
131
|
+
const raw = loadRaw(COMPLEX);
|
|
132
132
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
133
133
|
const run = inferred.commands['run'];
|
|
134
134
|
expect(run.args['verbose'].short).toBe('-v');
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
test('run subcommand: threads has deprecated field', () => {
|
|
138
|
-
const raw = loadRaw(COMPLEX
|
|
138
|
+
const raw = loadRaw(COMPLEX);
|
|
139
139
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
140
140
|
const run = inferred.commands['run'];
|
|
141
141
|
expect(run.args['threads'].deprecated).toBe('use --workers instead');
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
test('run subcommand: groups defined', () => {
|
|
145
|
-
const raw = loadRaw(COMPLEX
|
|
145
|
+
const raw = loadRaw(COMPLEX);
|
|
146
146
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
147
147
|
const run = inferred.commands['run'];
|
|
148
148
|
expect(run.groups['input-format']).toBeDefined();
|
|
@@ -152,21 +152,21 @@ describe('complex.toml', () => {
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
test('validate subcommand: is autonomous', () => {
|
|
155
|
-
const raw = loadRaw(COMPLEX
|
|
155
|
+
const raw = loadRaw(COMPLEX);
|
|
156
156
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
157
157
|
const validate = inferred.commands['validate'];
|
|
158
158
|
expect(validate.autonomy).toBe('autonomous');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
test('validate subcommand: format is choice', () => {
|
|
162
|
-
const raw = loadRaw(COMPLEX
|
|
162
|
+
const raw = loadRaw(COMPLEX);
|
|
163
163
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
164
164
|
const validate = inferred.commands['validate'];
|
|
165
165
|
expect(validate.args['format'].type).toBe('choice');
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
test('run subcommand: autonomy-reason preserved', () => {
|
|
169
|
-
const raw = loadRaw(COMPLEX
|
|
169
|
+
const raw = loadRaw(COMPLEX);
|
|
170
170
|
const inferred = inferScript(raw.runnables['pipeline'], raw.config.autonomyDefault);
|
|
171
171
|
const run = inferred.commands['run'];
|
|
172
172
|
expect(run.autonomyReason).toBe('Writes output files and may call external APIs');
|
|
@@ -25,7 +25,7 @@ autonomy = "autonomous"
|
|
|
25
25
|
name = {type = "str"}
|
|
26
26
|
loud = {default = false}
|
|
27
27
|
`);
|
|
28
|
-
const raw = loadRaw(file
|
|
28
|
+
const raw = loadRaw(file);
|
|
29
29
|
expect(raw.runnables['greet']).toBeDefined();
|
|
30
30
|
expect(raw.runnables['greet'].description).toBe('Greet someone');
|
|
31
31
|
expect(raw.runnables['greet'].args['name'].type).toBe('str');
|
|
@@ -39,7 +39,7 @@ test('normalises hyphenated field names', () => {
|
|
|
39
39
|
[deploy]
|
|
40
40
|
autonomy-reason = "Irreversible"
|
|
41
41
|
`);
|
|
42
|
-
const raw = loadRaw(file
|
|
42
|
+
const raw = loadRaw(file);
|
|
43
43
|
expect(raw.runnables['deploy'].autonomyReason).toBe('Irreversible');
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -54,7 +54,7 @@ version = "1"
|
|
|
54
54
|
[greet]
|
|
55
55
|
description = "hi"
|
|
56
56
|
`);
|
|
57
|
-
const raw = loadRaw(file
|
|
57
|
+
const raw = loadRaw(file);
|
|
58
58
|
expect(raw.config.autonomyDefault).toBe('autonomous');
|
|
59
59
|
expect(raw.config.version).toBe('1');
|
|
60
60
|
});
|
|
@@ -69,46 +69,11 @@ autonomy-default = "confirm"
|
|
|
69
69
|
[greet]
|
|
70
70
|
description = "hi"
|
|
71
71
|
`);
|
|
72
|
-
const raw = loadRaw(file
|
|
72
|
+
const raw = loadRaw(file);
|
|
73
73
|
expect('config' in raw.runnables).toBe(false);
|
|
74
74
|
expect('greet' in raw.runnables).toBe(true);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
// ── pyproject.toml format ─────────────────────────────────────────────────────
|
|
78
|
-
|
|
79
|
-
test('loads pyproject.toml format', () => {
|
|
80
|
-
const dir = tmpDir();
|
|
81
|
-
const file = path.join(dir, 'pyproject.toml');
|
|
82
|
-
fs.writeFileSync(file, `
|
|
83
|
-
[project]
|
|
84
|
-
name = "myproject"
|
|
85
|
-
|
|
86
|
-
[tool.runspec.greet]
|
|
87
|
-
description = "Greet"
|
|
88
|
-
autonomy = "confirm"
|
|
89
|
-
|
|
90
|
-
[tool.runspec.greet.args]
|
|
91
|
-
name = {type = "str"}
|
|
92
|
-
`);
|
|
93
|
-
const raw = loadRaw(file, 'pyproject');
|
|
94
|
-
expect(raw.runnables['greet']).toBeDefined();
|
|
95
|
-
expect(raw.runnables['greet'].args['name'].type).toBe('str');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('reads entry points from pyproject.toml', () => {
|
|
99
|
-
const dir = tmpDir();
|
|
100
|
-
const file = path.join(dir, 'pyproject.toml');
|
|
101
|
-
fs.writeFileSync(file, `
|
|
102
|
-
[project.scripts]
|
|
103
|
-
greet = "myapp.greet:main"
|
|
104
|
-
|
|
105
|
-
[tool.runspec.greet]
|
|
106
|
-
description = "Greet"
|
|
107
|
-
`);
|
|
108
|
-
const raw = loadRaw(file, 'pyproject');
|
|
109
|
-
expect(raw.entryPoints['greet']).toBe('myapp.greet:main');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
77
|
// ── arg normalisation ─────────────────────────────────────────────────────────
|
|
113
78
|
|
|
114
79
|
test('normalises bare value shorthand', () => {
|
|
@@ -122,7 +87,7 @@ description = "hi"
|
|
|
122
87
|
loud = false
|
|
123
88
|
times = 1
|
|
124
89
|
`);
|
|
125
|
-
const raw = loadRaw(file
|
|
90
|
+
const raw = loadRaw(file);
|
|
126
91
|
expect(raw.runnables['greet'].args['loud'].default).toBe(false);
|
|
127
92
|
expect(raw.runnables['greet'].args['times'].default).toBe(1);
|
|
128
93
|
});
|
|
@@ -137,7 +102,7 @@ description = "hi"
|
|
|
137
102
|
[greet.args]
|
|
138
103
|
workers = {default = 4, range = [1, 32]}
|
|
139
104
|
`);
|
|
140
|
-
const raw = loadRaw(file
|
|
105
|
+
const raw = loadRaw(file);
|
|
141
106
|
expect(raw.runnables['greet'].args['workers'].range).toEqual([1, 32]);
|
|
142
107
|
});
|
|
143
108
|
|
|
@@ -152,7 +117,7 @@ description = "hi"
|
|
|
152
117
|
exclusive = true
|
|
153
118
|
args = ["json", "csv"]
|
|
154
119
|
`);
|
|
155
|
-
const raw = loadRaw(file
|
|
120
|
+
const raw = loadRaw(file);
|
|
156
121
|
const group = raw.runnables['pipeline'].groups['formats'];
|
|
157
122
|
expect(group.exclusive).toBe(true);
|
|
158
123
|
expect(group.args).toEqual(['json', 'csv']);
|
|
@@ -164,6 +129,6 @@ test('autonomy-default falls back to confirm', () => {
|
|
|
164
129
|
const dir = tmpDir();
|
|
165
130
|
const file = path.join(dir, 'runspec.toml');
|
|
166
131
|
fs.writeFileSync(file, `[greet]\ndescription = "hi"\n`);
|
|
167
|
-
const raw = loadRaw(file
|
|
132
|
+
const raw = loadRaw(file);
|
|
168
133
|
expect(raw.config.autonomyDefault).toBe('confirm');
|
|
169
134
|
});
|