skir 0.0.6 → 0.0.8
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/command_line_parser.d.ts +2 -2
- package/dist/command_line_parser.d.ts.map +1 -1
- package/dist/command_line_parser.js +105 -36
- package/dist/command_line_parser.js.map +1 -1
- package/dist/command_line_parser.test.js +166 -39
- package/dist/command_line_parser.test.js.map +1 -1
- package/dist/compiler.js +51 -54
- package/dist/compiler.js.map +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -5
- package/dist/config.js.map +1 -1
- package/dist/config_parser.d.ts +6 -0
- package/dist/config_parser.d.ts.map +1 -1
- package/dist/config_parser.js +55 -31
- package/dist/config_parser.js.map +1 -1
- package/dist/config_parser.test.js +53 -20
- package/dist/config_parser.test.js.map +1 -1
- package/dist/error_renderer.d.ts +1 -0
- package/dist/error_renderer.d.ts.map +1 -1
- package/dist/error_renderer.js +6 -3
- package/dist/error_renderer.js.map +1 -1
- package/dist/exit_error.d.ts +8 -0
- package/dist/exit_error.d.ts.map +1 -0
- package/dist/exit_error.js +8 -0
- package/dist/exit_error.js.map +1 -0
- package/dist/io.d.ts +2 -0
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +22 -3
- package/dist/io.js.map +1 -1
- package/dist/module_collector.d.ts.map +1 -1
- package/dist/module_collector.js +12 -7
- package/dist/module_collector.js.map +1 -1
- package/dist/module_set.js +4 -4
- package/dist/parser.js +6 -6
- package/dist/project_initializer.d.ts.map +1 -1
- package/dist/project_initializer.js +97 -15
- package/dist/project_initializer.js.map +1 -1
- package/dist/snapshotter.d.ts +9 -2
- package/dist/snapshotter.d.ts.map +1 -1
- package/dist/snapshotter.js +35 -17
- package/dist/snapshotter.js.map +1 -1
- package/package.json +8 -6
- package/src/command_line_parser.ts +134 -42
- package/src/compiler.ts +65 -60
- package/src/config.ts +4 -6
- package/src/config_parser.ts +66 -32
- package/src/error_renderer.ts +11 -3
- package/src/exit_error.ts +6 -0
- package/src/io.ts +22 -3
- package/src/module_collector.ts +21 -7
- package/src/module_set.ts +4 -4
- package/src/parser.ts +6 -6
- package/src/project_initializer.ts +97 -15
- package/src/snapshotter.ts +49 -30
|
@@ -4,11 +4,11 @@ export type ParsedArgs = {
|
|
|
4
4
|
root?: string;
|
|
5
5
|
} | {
|
|
6
6
|
kind: "format";
|
|
7
|
-
subcommand?: "
|
|
7
|
+
subcommand?: "ci";
|
|
8
8
|
root?: string;
|
|
9
9
|
} | {
|
|
10
10
|
kind: "snapshot";
|
|
11
|
-
subcommand?: "
|
|
11
|
+
subcommand?: "ci" | "view" | "dry-run";
|
|
12
12
|
root?: string;
|
|
13
13
|
} | {
|
|
14
14
|
kind: "init";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command_line_parser.d.ts","sourceRoot":"","sources":["../src/command_line_parser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"command_line_parser.d.ts","sourceRoot":"","sources":["../src/command_line_parser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA0C3D;AAqCD,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -45,30 +45,36 @@ export function parseCommandLine(args) {
|
|
|
45
45
|
}
|
|
46
46
|
const COMMAND_BASE = "npx skir";
|
|
47
47
|
const HELP_TEXT = `
|
|
48
|
-
Usage: ${COMMAND_BASE} <command> [
|
|
48
|
+
Usage: ${COMMAND_BASE} <command> [options]
|
|
49
49
|
|
|
50
50
|
Commands:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
format
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
view: Display the last snapshot
|
|
58
|
-
init Initialize a new Skir project with a minimal skir.yml file
|
|
59
|
-
help Display this help message
|
|
51
|
+
init Initialize a new Skir project in the current directory
|
|
52
|
+
gen Generate code from .skir files to target languages
|
|
53
|
+
format Format all .skir files in the source directory
|
|
54
|
+
snapshot Take a snapshot of the source directory, look for
|
|
55
|
+
breaking changes since the last snapshot
|
|
56
|
+
help Display this help message
|
|
60
57
|
|
|
61
58
|
Options:
|
|
62
|
-
--root, -r <path>
|
|
59
|
+
--root, -r <path> Path to the directory containing the skir.yml file
|
|
60
|
+
--watch, -w Automatically run code generation when .skir files change
|
|
61
|
+
(gen only)
|
|
62
|
+
--ci Fail if code is not properly formatted (format) or if code
|
|
63
|
+
has changed since the last snapshot (snapshot)
|
|
64
|
+
--dry-run Look for breaking changes since the last snapshot without
|
|
65
|
+
taking a new snapshot (snapshot only)
|
|
66
|
+
--view Display the last snapshot (snapshot only)
|
|
63
67
|
|
|
64
68
|
Examples:
|
|
69
|
+
${COMMAND_BASE} init
|
|
65
70
|
${COMMAND_BASE} gen
|
|
66
|
-
${COMMAND_BASE} gen watch
|
|
71
|
+
${COMMAND_BASE} gen --watch
|
|
67
72
|
${COMMAND_BASE} format --root path/to/root/dir
|
|
68
|
-
${COMMAND_BASE} format
|
|
73
|
+
${COMMAND_BASE} format --ci -r path/to/root/dir
|
|
69
74
|
${COMMAND_BASE} snapshot
|
|
70
|
-
${COMMAND_BASE} snapshot
|
|
71
|
-
${COMMAND_BASE} snapshot
|
|
75
|
+
${COMMAND_BASE} snapshot --ci
|
|
76
|
+
${COMMAND_BASE} snapshot --dry-run
|
|
77
|
+
${COMMAND_BASE} snapshot --view --root path/to/root/dir
|
|
72
78
|
`;
|
|
73
79
|
export class CommandLineParseError extends Error {
|
|
74
80
|
constructor(message) {
|
|
@@ -84,7 +90,18 @@ function parseOptions(args) {
|
|
|
84
90
|
const arg = args[i];
|
|
85
91
|
if (!arg)
|
|
86
92
|
continue;
|
|
87
|
-
|
|
93
|
+
// Check for --option=value syntax
|
|
94
|
+
if (arg.startsWith("--root=") || arg.startsWith("-r=")) {
|
|
95
|
+
const value = arg.substring(arg.indexOf("=") + 1);
|
|
96
|
+
if (!value) {
|
|
97
|
+
throw new CommandLineParseError(`Option ${arg.split("=")[0]} requires a value`);
|
|
98
|
+
}
|
|
99
|
+
if (options.root !== undefined) {
|
|
100
|
+
throw new CommandLineParseError(`Option ${arg.split("=")[0]} specified multiple times`);
|
|
101
|
+
}
|
|
102
|
+
options.root = value;
|
|
103
|
+
}
|
|
104
|
+
else if (arg === "--root" || arg === "-r") {
|
|
88
105
|
if (i + 1 >= args.length) {
|
|
89
106
|
throw new CommandLineParseError(`Option ${arg} requires a value`);
|
|
90
107
|
}
|
|
@@ -94,60 +111,112 @@ function parseOptions(args) {
|
|
|
94
111
|
options.root = args[i + 1];
|
|
95
112
|
i++; // Skip the next argument as it's the value
|
|
96
113
|
}
|
|
114
|
+
else if (arg === "--watch" || arg === "-w") {
|
|
115
|
+
if (options.watch) {
|
|
116
|
+
throw new CommandLineParseError(`Option ${arg} specified multiple times`);
|
|
117
|
+
}
|
|
118
|
+
options.watch = true;
|
|
119
|
+
}
|
|
120
|
+
else if (arg === "--ci") {
|
|
121
|
+
if (options.ci) {
|
|
122
|
+
throw new CommandLineParseError(`Option --ci specified multiple times`);
|
|
123
|
+
}
|
|
124
|
+
options.ci = true;
|
|
125
|
+
}
|
|
126
|
+
else if (arg === "--dry-run") {
|
|
127
|
+
if (options.dryRun) {
|
|
128
|
+
throw new CommandLineParseError(`Option --dry-run specified multiple times`);
|
|
129
|
+
}
|
|
130
|
+
options.dryRun = true;
|
|
131
|
+
}
|
|
132
|
+
else if (arg === "--view") {
|
|
133
|
+
if (options.view) {
|
|
134
|
+
throw new CommandLineParseError(`Option --view specified multiple times`);
|
|
135
|
+
}
|
|
136
|
+
options.view = true;
|
|
137
|
+
}
|
|
97
138
|
else if (arg.startsWith("-")) {
|
|
98
139
|
options.unknown.push(arg);
|
|
99
140
|
}
|
|
100
141
|
else {
|
|
101
|
-
// Positional argument -
|
|
102
|
-
|
|
103
|
-
throw new CommandLineParseError(`Unexpected argument: ${arg}`);
|
|
104
|
-
}
|
|
105
|
-
options.subcommand = arg;
|
|
142
|
+
// Positional argument - not allowed anymore
|
|
143
|
+
throw new CommandLineParseError(`Unexpected argument: ${arg}`);
|
|
106
144
|
}
|
|
107
145
|
}
|
|
108
146
|
return options;
|
|
109
147
|
}
|
|
110
148
|
function buildGenCommand(options) {
|
|
111
149
|
validateNoUnknownOptions(options, "gen");
|
|
112
|
-
if (options.
|
|
113
|
-
throw new CommandLineParseError(`
|
|
150
|
+
if (options.ci) {
|
|
151
|
+
throw new CommandLineParseError(`Option --ci is not valid for 'gen' command`);
|
|
152
|
+
}
|
|
153
|
+
if (options.dryRun) {
|
|
154
|
+
throw new CommandLineParseError(`Option --dry-run is not valid for 'gen' command`);
|
|
155
|
+
}
|
|
156
|
+
if (options.view) {
|
|
157
|
+
throw new CommandLineParseError(`Option --view is not valid for 'gen' command`);
|
|
114
158
|
}
|
|
115
159
|
return {
|
|
116
160
|
kind: "gen",
|
|
117
161
|
root: options.root,
|
|
118
|
-
subcommand: options.
|
|
162
|
+
subcommand: options.watch ? "watch" : undefined,
|
|
119
163
|
};
|
|
120
164
|
}
|
|
121
165
|
function buildFormatCommand(options) {
|
|
122
166
|
validateNoUnknownOptions(options, "format");
|
|
123
|
-
if (options.
|
|
124
|
-
throw new CommandLineParseError(`
|
|
167
|
+
if (options.watch) {
|
|
168
|
+
throw new CommandLineParseError(`Option --watch is not valid for 'format' command`);
|
|
169
|
+
}
|
|
170
|
+
if (options.dryRun) {
|
|
171
|
+
throw new CommandLineParseError(`Option --dry-run is not valid for 'format' command`);
|
|
172
|
+
}
|
|
173
|
+
if (options.view) {
|
|
174
|
+
throw new CommandLineParseError(`Option --view is not valid for 'format' command`);
|
|
125
175
|
}
|
|
126
176
|
return {
|
|
127
177
|
kind: "format",
|
|
128
178
|
root: options.root,
|
|
129
|
-
subcommand: options.
|
|
179
|
+
subcommand: options.ci ? "ci" : undefined,
|
|
130
180
|
};
|
|
131
181
|
}
|
|
132
182
|
function buildSnapshotCommand(options) {
|
|
133
183
|
validateNoUnknownOptions(options, "snapshot");
|
|
134
|
-
if (options.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
184
|
+
if (options.watch) {
|
|
185
|
+
throw new CommandLineParseError(`Option --watch is not valid for 'snapshot' command`);
|
|
186
|
+
}
|
|
187
|
+
const activeOptions = [
|
|
188
|
+
options.ci && "--ci",
|
|
189
|
+
options.dryRun && "--dry-run",
|
|
190
|
+
options.view && "--view",
|
|
191
|
+
].filter(Boolean);
|
|
192
|
+
if (activeOptions.length > 1) {
|
|
193
|
+
throw new CommandLineParseError(`Options ${activeOptions.join(" and ")} cannot be used together`);
|
|
138
194
|
}
|
|
139
195
|
return {
|
|
140
196
|
kind: "snapshot",
|
|
141
197
|
root: options.root,
|
|
142
|
-
subcommand: options.
|
|
143
|
-
?
|
|
144
|
-
:
|
|
198
|
+
subcommand: options.ci
|
|
199
|
+
? "ci"
|
|
200
|
+
: options.dryRun
|
|
201
|
+
? "dry-run"
|
|
202
|
+
: options.view
|
|
203
|
+
? "view"
|
|
204
|
+
: undefined,
|
|
145
205
|
};
|
|
146
206
|
}
|
|
147
207
|
function buildInitCommand(options) {
|
|
148
208
|
validateNoUnknownOptions(options, "init");
|
|
149
|
-
if (options.
|
|
150
|
-
throw new CommandLineParseError(`
|
|
209
|
+
if (options.watch) {
|
|
210
|
+
throw new CommandLineParseError(`Option --watch is not valid for 'init' command`);
|
|
211
|
+
}
|
|
212
|
+
if (options.ci) {
|
|
213
|
+
throw new CommandLineParseError(`Option --ci is not valid for 'init' command`);
|
|
214
|
+
}
|
|
215
|
+
if (options.dryRun) {
|
|
216
|
+
throw new CommandLineParseError(`Option --dry-run is not valid for 'init' command`);
|
|
217
|
+
}
|
|
218
|
+
if (options.view) {
|
|
219
|
+
throw new CommandLineParseError(`Option --view is not valid for 'init' command`);
|
|
151
220
|
}
|
|
152
221
|
return {
|
|
153
222
|
kind: "init",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command_line_parser.js","sourceRoot":"","sources":["../src/command_line_parser.ts"],"names":[],"mappings":"AA6BA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC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,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,CAAC,KAAK,CAAC,UAAU,OAAO,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -22,17 +22,38 @@ describe("command_line_parser", () => {
|
|
|
22
22
|
root: "path/to/dir",
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
it("should parse gen with
|
|
26
|
-
const result = parseCommandLine(["gen", "
|
|
25
|
+
it("should parse gen with --root=value syntax", () => {
|
|
26
|
+
const result = parseCommandLine(["gen", "--root=path/to/dir"]);
|
|
27
|
+
expect(result).toMatch({
|
|
28
|
+
kind: "gen",
|
|
29
|
+
root: "path/to/dir",
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
it("should parse gen with -r=value syntax", () => {
|
|
33
|
+
const result = parseCommandLine(["gen", "-r=path/to/dir"]);
|
|
34
|
+
expect(result).toMatch({
|
|
35
|
+
kind: "gen",
|
|
36
|
+
root: "path/to/dir",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
it("should parse gen with --watch option", () => {
|
|
40
|
+
const result = parseCommandLine(["gen", "--watch"]);
|
|
27
41
|
expect(result).toMatch({
|
|
28
42
|
kind: "gen",
|
|
29
43
|
subcommand: "watch",
|
|
30
44
|
});
|
|
31
45
|
});
|
|
32
|
-
it("should parse gen with
|
|
46
|
+
it("should parse gen with -w option", () => {
|
|
47
|
+
const result = parseCommandLine(["gen", "-w"]);
|
|
48
|
+
expect(result).toMatch({
|
|
49
|
+
kind: "gen",
|
|
50
|
+
subcommand: "watch",
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it("should parse gen with --watch and --root option", () => {
|
|
33
54
|
const result = parseCommandLine([
|
|
34
55
|
"gen",
|
|
35
|
-
"watch",
|
|
56
|
+
"--watch",
|
|
36
57
|
"--root",
|
|
37
58
|
"path/to/dir",
|
|
38
59
|
]);
|
|
@@ -42,15 +63,15 @@ describe("command_line_parser", () => {
|
|
|
42
63
|
subcommand: "watch",
|
|
43
64
|
});
|
|
44
65
|
});
|
|
45
|
-
it("should parse gen with
|
|
46
|
-
const result = parseCommandLine(["gen", "
|
|
66
|
+
it("should parse gen with -w and -r option", () => {
|
|
67
|
+
const result = parseCommandLine(["gen", "-w", "-r", "path/to/dir"]);
|
|
47
68
|
expect(result).toMatch({
|
|
48
69
|
kind: "gen",
|
|
49
70
|
root: "path/to/dir",
|
|
50
71
|
subcommand: "watch",
|
|
51
72
|
});
|
|
52
73
|
});
|
|
53
|
-
it("should return error if
|
|
74
|
+
it("should return error if positional argument is used with gen", () => {
|
|
54
75
|
const result = parseCommandLine(["gen", "build"]);
|
|
55
76
|
expect(result).toMatch({ kind: "error" });
|
|
56
77
|
});
|
|
@@ -62,6 +83,10 @@ describe("command_line_parser", () => {
|
|
|
62
83
|
const result = parseCommandLine(["gen", "--root"]);
|
|
63
84
|
expect(result).toMatch({ kind: "error" });
|
|
64
85
|
});
|
|
86
|
+
it("should return error if --root= is missing value", () => {
|
|
87
|
+
const result = parseCommandLine(["gen", "--root="]);
|
|
88
|
+
expect(result).toMatch({ kind: "error" });
|
|
89
|
+
});
|
|
65
90
|
it("should return error if --root is specified multiple times", () => {
|
|
66
91
|
const result = parseCommandLine([
|
|
67
92
|
"gen",
|
|
@@ -72,6 +97,35 @@ describe("command_line_parser", () => {
|
|
|
72
97
|
]);
|
|
73
98
|
expect(result).toMatch({ kind: "error" });
|
|
74
99
|
});
|
|
100
|
+
it("should return error if --root is specified multiple times with = syntax", () => {
|
|
101
|
+
const result = parseCommandLine([
|
|
102
|
+
"gen",
|
|
103
|
+
"--root=path1",
|
|
104
|
+
"--root=path2",
|
|
105
|
+
]);
|
|
106
|
+
expect(result).toMatch({ kind: "error" });
|
|
107
|
+
});
|
|
108
|
+
it("should return error if --root is specified with both syntaxes", () => {
|
|
109
|
+
const result = parseCommandLine([
|
|
110
|
+
"gen",
|
|
111
|
+
"--root",
|
|
112
|
+
"path1",
|
|
113
|
+
"--root=path2",
|
|
114
|
+
]);
|
|
115
|
+
expect(result).toMatch({ kind: "error" });
|
|
116
|
+
});
|
|
117
|
+
it("should return error if --ci is used with gen", () => {
|
|
118
|
+
const result = parseCommandLine(["gen", "--ci"]);
|
|
119
|
+
expect(result).toMatch({ kind: "error" });
|
|
120
|
+
});
|
|
121
|
+
it("should return error if --dry-run is used with gen", () => {
|
|
122
|
+
const result = parseCommandLine(["gen", "--dry-run"]);
|
|
123
|
+
expect(result).toMatch({ kind: "error" });
|
|
124
|
+
});
|
|
125
|
+
it("should return error if --view is used with gen", () => {
|
|
126
|
+
const result = parseCommandLine(["gen", "--view"]);
|
|
127
|
+
expect(result).toMatch({ kind: "error" });
|
|
128
|
+
});
|
|
75
129
|
});
|
|
76
130
|
describe("format command", () => {
|
|
77
131
|
it("should parse basic format command", () => {
|
|
@@ -92,40 +146,40 @@ describe("command_line_parser", () => {
|
|
|
92
146
|
root: "path/to/dir",
|
|
93
147
|
});
|
|
94
148
|
});
|
|
95
|
-
it("should parse format with
|
|
96
|
-
const result = parseCommandLine(["format", "
|
|
149
|
+
it("should parse format with --ci option", () => {
|
|
150
|
+
const result = parseCommandLine(["format", "--ci"]);
|
|
97
151
|
expect(result).toMatch({
|
|
98
152
|
kind: "format",
|
|
99
|
-
subcommand: "
|
|
153
|
+
subcommand: "ci",
|
|
100
154
|
});
|
|
101
155
|
});
|
|
102
|
-
it("should parse format with
|
|
156
|
+
it("should parse format with --ci and --root option", () => {
|
|
103
157
|
const result = parseCommandLine([
|
|
104
158
|
"format",
|
|
105
|
-
"
|
|
159
|
+
"--ci",
|
|
106
160
|
"--root",
|
|
107
161
|
"path/to/dir",
|
|
108
162
|
]);
|
|
109
163
|
expect(result).toMatch({
|
|
110
164
|
kind: "format",
|
|
111
165
|
root: "path/to/dir",
|
|
112
|
-
subcommand: "
|
|
166
|
+
subcommand: "ci",
|
|
113
167
|
});
|
|
114
168
|
});
|
|
115
|
-
it("should parse format with
|
|
169
|
+
it("should parse format with --ci and -r option", () => {
|
|
116
170
|
const result = parseCommandLine([
|
|
117
171
|
"format",
|
|
118
|
-
"
|
|
172
|
+
"--ci",
|
|
119
173
|
"-r",
|
|
120
174
|
"path/to/dir",
|
|
121
175
|
]);
|
|
122
176
|
expect(result).toMatch({
|
|
123
177
|
kind: "format",
|
|
124
178
|
root: "path/to/dir",
|
|
125
|
-
subcommand: "
|
|
179
|
+
subcommand: "ci",
|
|
126
180
|
});
|
|
127
181
|
});
|
|
128
|
-
it("should return error if
|
|
182
|
+
it("should return error if positional argument is used with format", () => {
|
|
129
183
|
const result = parseCommandLine(["format", "fix"]);
|
|
130
184
|
expect(result).toMatch({ kind: "error" });
|
|
131
185
|
});
|
|
@@ -133,6 +187,18 @@ describe("command_line_parser", () => {
|
|
|
133
187
|
const result = parseCommandLine(["format", "--verbose"]);
|
|
134
188
|
expect(result).toMatch({ kind: "error" });
|
|
135
189
|
});
|
|
190
|
+
it("should return error if --dry-run is used with format", () => {
|
|
191
|
+
const result = parseCommandLine(["format", "--dry-run"]);
|
|
192
|
+
expect(result).toMatch({ kind: "error" });
|
|
193
|
+
});
|
|
194
|
+
it("should return error if --watch is used with format", () => {
|
|
195
|
+
const result = parseCommandLine(["format", "--watch"]);
|
|
196
|
+
expect(result).toMatch({ kind: "error" });
|
|
197
|
+
});
|
|
198
|
+
it("should return error if --view is used with format", () => {
|
|
199
|
+
const result = parseCommandLine(["format", "--view"]);
|
|
200
|
+
expect(result).toMatch({ kind: "error" });
|
|
201
|
+
});
|
|
136
202
|
});
|
|
137
203
|
describe("snapshot command", () => {
|
|
138
204
|
it("should parse basic snapshot command", () => {
|
|
@@ -153,41 +219,41 @@ describe("command_line_parser", () => {
|
|
|
153
219
|
root: "path/to/dir",
|
|
154
220
|
});
|
|
155
221
|
});
|
|
156
|
-
it("should return error if
|
|
222
|
+
it("should return error if positional argument is used with snapshot", () => {
|
|
157
223
|
const result = parseCommandLine(["snapshot", "build"]);
|
|
158
224
|
expect(result).toMatch({ kind: "error" });
|
|
159
225
|
});
|
|
160
|
-
it("should parse snapshot with
|
|
161
|
-
const result = parseCommandLine(["snapshot", "
|
|
226
|
+
it("should parse snapshot with --ci option", () => {
|
|
227
|
+
const result = parseCommandLine(["snapshot", "--ci"]);
|
|
162
228
|
expect(result).toMatch({
|
|
163
229
|
kind: "snapshot",
|
|
164
|
-
subcommand: "
|
|
230
|
+
subcommand: "ci",
|
|
165
231
|
});
|
|
166
232
|
});
|
|
167
|
-
it("should parse snapshot with view
|
|
168
|
-
const result = parseCommandLine(["snapshot", "view"]);
|
|
233
|
+
it("should parse snapshot with --view option", () => {
|
|
234
|
+
const result = parseCommandLine(["snapshot", "--view"]);
|
|
169
235
|
expect(result).toMatch({
|
|
170
236
|
kind: "snapshot",
|
|
171
237
|
subcommand: "view",
|
|
172
238
|
});
|
|
173
239
|
});
|
|
174
|
-
it("should parse snapshot with
|
|
240
|
+
it("should parse snapshot with --ci and --root option", () => {
|
|
175
241
|
const result = parseCommandLine([
|
|
176
242
|
"snapshot",
|
|
177
|
-
"
|
|
243
|
+
"--ci",
|
|
178
244
|
"--root",
|
|
179
245
|
"path/to/dir",
|
|
180
246
|
]);
|
|
181
247
|
expect(result).toMatch({
|
|
182
248
|
kind: "snapshot",
|
|
183
249
|
root: "path/to/dir",
|
|
184
|
-
subcommand: "
|
|
250
|
+
subcommand: "ci",
|
|
185
251
|
});
|
|
186
252
|
});
|
|
187
|
-
it("should parse snapshot with view and -r option", () => {
|
|
253
|
+
it("should parse snapshot with --view and -r option", () => {
|
|
188
254
|
const result = parseCommandLine([
|
|
189
255
|
"snapshot",
|
|
190
|
-
"view",
|
|
256
|
+
"--view",
|
|
191
257
|
"-r",
|
|
192
258
|
"path/to/dir",
|
|
193
259
|
]);
|
|
@@ -197,6 +263,51 @@ describe("command_line_parser", () => {
|
|
|
197
263
|
subcommand: "view",
|
|
198
264
|
});
|
|
199
265
|
});
|
|
266
|
+
it("should return error if both --ci and --view are used with snapshot", () => {
|
|
267
|
+
const result = parseCommandLine(["snapshot", "--ci", "--view"]);
|
|
268
|
+
expect(result).toMatch({ kind: "error" });
|
|
269
|
+
});
|
|
270
|
+
it("should parse snapshot with --dry-run option", () => {
|
|
271
|
+
const result = parseCommandLine(["snapshot", "--dry-run"]);
|
|
272
|
+
expect(result).toMatch({
|
|
273
|
+
kind: "snapshot",
|
|
274
|
+
subcommand: "dry-run",
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
it("should parse snapshot with --dry-run and --root option", () => {
|
|
278
|
+
const result = parseCommandLine([
|
|
279
|
+
"snapshot",
|
|
280
|
+
"--dry-run",
|
|
281
|
+
"--root",
|
|
282
|
+
"path/to/dir",
|
|
283
|
+
]);
|
|
284
|
+
expect(result).toMatch({
|
|
285
|
+
kind: "snapshot",
|
|
286
|
+
root: "path/to/dir",
|
|
287
|
+
subcommand: "dry-run",
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
it("should return error if both --ci and --dry-run are used with snapshot", () => {
|
|
291
|
+
const result = parseCommandLine(["snapshot", "--ci", "--dry-run"]);
|
|
292
|
+
expect(result).toMatch({ kind: "error" });
|
|
293
|
+
});
|
|
294
|
+
it("should return error if both --dry-run and --view are used with snapshot", () => {
|
|
295
|
+
const result = parseCommandLine(["snapshot", "--dry-run", "--view"]);
|
|
296
|
+
expect(result).toMatch({ kind: "error" });
|
|
297
|
+
});
|
|
298
|
+
it("should return error if all three options are used with snapshot", () => {
|
|
299
|
+
const result = parseCommandLine([
|
|
300
|
+
"snapshot",
|
|
301
|
+
"--ci",
|
|
302
|
+
"--dry-run",
|
|
303
|
+
"--view",
|
|
304
|
+
]);
|
|
305
|
+
expect(result).toMatch({ kind: "error" });
|
|
306
|
+
});
|
|
307
|
+
it("should return error if --watch is used with snapshot", () => {
|
|
308
|
+
const result = parseCommandLine(["snapshot", "--watch"]);
|
|
309
|
+
expect(result).toMatch({ kind: "error" });
|
|
310
|
+
});
|
|
200
311
|
});
|
|
201
312
|
describe("init command", () => {
|
|
202
313
|
it("should parse basic init command", () => {
|
|
@@ -217,10 +328,26 @@ describe("command_line_parser", () => {
|
|
|
217
328
|
root: "path/to/dir",
|
|
218
329
|
});
|
|
219
330
|
});
|
|
220
|
-
it("should return error if
|
|
331
|
+
it("should return error if positional argument is used with init", () => {
|
|
221
332
|
const result = parseCommandLine(["init", "template"]);
|
|
222
333
|
expect(result).toMatch({ kind: "error" });
|
|
223
334
|
});
|
|
335
|
+
it("should return error if --watch is used with init", () => {
|
|
336
|
+
const result = parseCommandLine(["init", "--watch"]);
|
|
337
|
+
expect(result).toMatch({ kind: "error" });
|
|
338
|
+
});
|
|
339
|
+
it("should return error if --dry-run is used with init", () => {
|
|
340
|
+
const result = parseCommandLine(["init", "--dry-run"]);
|
|
341
|
+
expect(result).toMatch({ kind: "error" });
|
|
342
|
+
});
|
|
343
|
+
it("should return error if --ci is used with init", () => {
|
|
344
|
+
const result = parseCommandLine(["init", "--ci"]);
|
|
345
|
+
expect(result).toMatch({ kind: "error" });
|
|
346
|
+
});
|
|
347
|
+
it("should return error if --view is used with init", () => {
|
|
348
|
+
const result = parseCommandLine(["init", "--view"]);
|
|
349
|
+
expect(result).toMatch({ kind: "error" });
|
|
350
|
+
});
|
|
224
351
|
});
|
|
225
352
|
describe("help command", () => {
|
|
226
353
|
it("should return help for help command", () => {
|
|
@@ -246,7 +373,7 @@ describe("command_line_parser", () => {
|
|
|
246
373
|
expect(result).toMatch({ kind: "error" });
|
|
247
374
|
});
|
|
248
375
|
it("should return error for unexpected positional argument", () => {
|
|
249
|
-
const result = parseCommandLine(["gen", "watch", "extra-arg"]);
|
|
376
|
+
const result = parseCommandLine(["gen", "--watch", "extra-arg"]);
|
|
250
377
|
expect(result).toMatch({ kind: "error" });
|
|
251
378
|
});
|
|
252
379
|
it("should return error for option with missing value at end", () => {
|
|
@@ -254,18 +381,18 @@ describe("command_line_parser", () => {
|
|
|
254
381
|
expect(result).toMatch({ kind: "error" });
|
|
255
382
|
});
|
|
256
383
|
it("should return error if --watch specified multiple times", () => {
|
|
257
|
-
const result = parseCommandLine(["gen", "watch", "watch"]);
|
|
384
|
+
const result = parseCommandLine(["gen", "--watch", "--watch"]);
|
|
258
385
|
expect(result).toMatch({ kind: "error" });
|
|
259
386
|
});
|
|
260
|
-
it("should return error if --
|
|
261
|
-
const result = parseCommandLine(["format", "
|
|
387
|
+
it("should return error if --ci specified multiple times", () => {
|
|
388
|
+
const result = parseCommandLine(["format", "--ci", "--ci"]);
|
|
262
389
|
expect(result).toMatch({ kind: "error" });
|
|
263
390
|
});
|
|
264
391
|
});
|
|
265
392
|
describe("option order", () => {
|
|
266
393
|
it("should parse options in any order for gen", () => {
|
|
267
|
-
const result1 = parseCommandLine(["gen", "watch", "--root", "dir"]);
|
|
268
|
-
const result2 = parseCommandLine(["gen", "--root", "dir", "watch"]);
|
|
394
|
+
const result1 = parseCommandLine(["gen", "--watch", "--root", "dir"]);
|
|
395
|
+
const result2 = parseCommandLine(["gen", "--root", "dir", "--watch"]);
|
|
269
396
|
expect(result1).toMatch({
|
|
270
397
|
kind: "gen",
|
|
271
398
|
root: "dir",
|
|
@@ -278,17 +405,17 @@ describe("command_line_parser", () => {
|
|
|
278
405
|
});
|
|
279
406
|
});
|
|
280
407
|
it("should parse options in any order for format", () => {
|
|
281
|
-
const result1 = parseCommandLine(["format", "
|
|
282
|
-
const result2 = parseCommandLine(["format", "--root", "dir", "
|
|
408
|
+
const result1 = parseCommandLine(["format", "--ci", "--root", "dir"]);
|
|
409
|
+
const result2 = parseCommandLine(["format", "--root", "dir", "--ci"]);
|
|
283
410
|
expect(result1).toMatch({
|
|
284
411
|
kind: "format",
|
|
285
412
|
root: "dir",
|
|
286
|
-
subcommand: "
|
|
413
|
+
subcommand: "ci",
|
|
287
414
|
});
|
|
288
415
|
expect(result2).toMatch({
|
|
289
416
|
kind: "format",
|
|
290
417
|
root: "dir",
|
|
291
|
-
subcommand: "
|
|
418
|
+
subcommand: "ci",
|
|
292
419
|
});
|
|
293
420
|
});
|
|
294
421
|
});
|