rtgl 0.0.9 → 0.0.10

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 (2) hide show
  1. package/cli.js +38 -33
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -8,14 +8,18 @@ import { readFileSync, existsSync } from "fs";
8
8
  import { resolve } from "path";
9
9
  import yaml from "js-yaml";
10
10
 
11
+ const packageJson = JSON.parse(
12
+ readFileSync(new URL("./package.json", import.meta.url)),
13
+ );
14
+
11
15
  // Function to read config file
12
16
  function readConfig() {
13
17
  const configPath = resolve(process.cwd(), "rettangoli.config.yaml");
14
-
18
+
15
19
  if (!existsSync(configPath)) {
16
20
  return null;
17
21
  }
18
-
22
+
19
23
  try {
20
24
  const configContent = readFileSync(configPath, "utf8");
21
25
  return yaml.load(configContent);
@@ -25,13 +29,12 @@ function readConfig() {
25
29
  }
26
30
  }
27
31
 
28
-
29
32
  const program = new Command();
30
33
 
31
34
  program
32
35
  .name("rtgl")
33
36
  .description("CLI tool for Rettangoli development")
34
- .version("0.0.1");
37
+ .version(packageJson.version);
35
38
 
36
39
  // Add examples to main program
37
40
  program.addHelpText(
@@ -63,30 +66,32 @@ Examples:
63
66
  )
64
67
  .action((options) => {
65
68
  const config = readConfig();
66
-
69
+
67
70
  if (!config) {
68
71
  throw new Error("rettangoli.config.yaml not found");
69
72
  }
70
-
73
+
71
74
  if (!config.fe?.dirs?.length) {
72
75
  throw new Error("fe.dirs not found or empty in config");
73
76
  }
74
-
77
+
75
78
  // Validate that directories exist
76
- const missingDirs = config.fe.dirs.filter(dir => !existsSync(resolve(process.cwd(), dir)));
79
+ const missingDirs = config.fe.dirs.filter(
80
+ (dir) => !existsSync(resolve(process.cwd(), dir)),
81
+ );
77
82
  if (missingDirs.length > 0) {
78
83
  throw new Error(`Directories do not exist: ${missingDirs.join(", ")}`);
79
84
  }
80
-
85
+
81
86
  // Pass dirs, setup, and outfile from config
82
87
  options.dirs = config.fe.dirs;
83
- options.setup = config.fe.setup || 'setup.js';
84
-
88
+ options.setup = config.fe.setup || "setup.js";
89
+
85
90
  // Use config outfile if not specified via CLI option
86
91
  if (!options.outfile && config.fe.outfile) {
87
92
  options.outfile = config.fe.outfile;
88
93
  }
89
-
94
+
90
95
  build(options);
91
96
  });
92
97
 
@@ -131,39 +136,39 @@ Examples:
131
136
  )
132
137
  .action((options) => {
133
138
  const config = readConfig();
134
-
139
+
135
140
  if (!config) {
136
141
  throw new Error("rettangoli.config.yaml not found");
137
142
  }
138
-
143
+
139
144
  if (!config.fe?.dirs?.length) {
140
145
  throw new Error("fe.dirs not found or empty in config");
141
146
  }
142
-
147
+
143
148
  // Validate that directories exist
144
- const missingDirs = config.fe.dirs.filter(dir => !existsSync(resolve(process.cwd(), dir)));
149
+ const missingDirs = config.fe.dirs.filter(
150
+ (dir) => !existsSync(resolve(process.cwd(), dir)),
151
+ );
145
152
  if (missingDirs.length > 0) {
146
153
  throw new Error(`Directories do not exist: ${missingDirs.join(", ")}`);
147
154
  }
148
-
155
+
149
156
  // Pass dirs and setup from config
150
157
  options.dirs = config.fe.dirs;
151
- options.setup = config.fe.setup || 'setup.js';
158
+ options.setup = config.fe.setup || "setup.js";
152
159
  watch(options);
153
160
  });
154
161
 
155
-
156
- feCommand.command("examples")
162
+ feCommand
163
+ .command("examples")
157
164
  .description("Generate examples")
158
165
  .action((options) => {
159
166
  const config = readConfig();
160
167
  options.dirs = config.fe.dirs;
161
- options.outputDir = config.fe?.examples?.outputDir || './vt/specs/examples';
168
+ options.outputDir = config.fe?.examples?.outputDir || "./vt/specs/examples";
162
169
  examples(options);
163
170
  });
164
171
 
165
-
166
-
167
172
  const vtCommand = program
168
173
  .command("vt")
169
174
  .description("Rettangoli Visual Testing");
@@ -175,14 +180,14 @@ vtCommand
175
180
  .option("--screenshot-wait-time <time>", "Wait time between screenshots", "0")
176
181
  .action((options) => {
177
182
  const config = readConfig();
178
-
183
+
179
184
  if (!config) {
180
185
  throw new Error("rettangoli.config.yaml not found");
181
186
  }
182
-
187
+
183
188
  // Use vt.path from config, default to 'vt'
184
- options.vizPath = config.vt?.path || 'vt';
185
-
189
+ options.vizPath = config.vt?.path || "vt";
190
+
186
191
  generate(options);
187
192
  });
188
193
 
@@ -191,12 +196,12 @@ vtCommand
191
196
  .description("Create reports")
192
197
  .action(() => {
193
198
  const config = readConfig();
194
-
199
+
195
200
  if (!config) {
196
201
  throw new Error("rettangoli.config.yaml not found");
197
202
  }
198
-
199
- const vizPath = config.vt?.path || 'vt';
203
+
204
+ const vizPath = config.vt?.path || "vt";
200
205
  report({ vizPath });
201
206
  });
202
207
 
@@ -205,12 +210,12 @@ vtCommand
205
210
  .description("Accept changes")
206
211
  .action(() => {
207
212
  const config = readConfig();
208
-
213
+
209
214
  if (!config) {
210
215
  throw new Error("rettangoli.config.yaml not found");
211
216
  }
212
-
213
- const vizPath = config.vt?.path || 'vt';
217
+
218
+ const vizPath = config.vt?.path || "vt";
214
219
  accept({ vizPath });
215
220
  });
216
221
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rtgl",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "CLI tool for Rettangoli - A frontend framework and development toolkit",
5
5
  "type": "module",
6
6
  "bin": {
@@ -49,6 +49,6 @@
49
49
  "js-yaml": "^4.1.0",
50
50
  "@rettangoli/fe": "0.0.6",
51
51
  "@rettangoli/sites": "0.1.0",
52
- "@rettangoli/vt": "0.0.1"
52
+ "@rettangoli/vt": "0.0.2-rc1"
53
53
  }
54
54
  }