@gtkx/cli 0.2.1 → 0.2.3

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/dist/create.js +24 -9
  2. package/package.json +3 -3
package/dist/create.js CHANGED
@@ -1,4 +1,4 @@
1
- import { execSync } from "node:child_process";
1
+ import { spawn } from "node:child_process";
2
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
3
  import { join, resolve } from "node:path";
4
4
  import * as p from "@clack/prompts";
@@ -12,11 +12,11 @@ const TESTING_DEV_DEPENDENCIES = {
12
12
  const getTestScript = (testing) => {
13
13
  switch (testing) {
14
14
  case "vitest":
15
- return "vitest";
15
+ return "GDK_BACKEND=x11 xvfb-run -a vitest";
16
16
  case "jest":
17
- return "jest";
17
+ return "GDK_BACKEND=x11 xvfb-run -a jest";
18
18
  case "node":
19
- return "node --import tsx --test tests/**/*.test.ts";
19
+ return "GDK_BACKEND=x11 xvfb-run -a node --import tsx --test tests/**/*.test.ts";
20
20
  case "none":
21
21
  return undefined;
22
22
  }
@@ -116,7 +116,7 @@ ${afterEachFn}(async () => {
116
116
 
117
117
  describe("App", () => {
118
118
  it("renders the increment button", async () => {
119
- await render(<App />);
119
+ await render(<App />, { wrapper: false });
120
120
  const button = await screen.findByRole("button", { name: "Increment" });
121
121
  ${assertion}
122
122
  });
@@ -191,6 +191,13 @@ const isValidProjectName = (name) => {
191
191
  const isValidAppId = (appId) => {
192
192
  return /^[a-zA-Z][a-zA-Z0-9]*(\.[a-zA-Z][a-zA-Z0-9]*)+$/.test(appId);
193
193
  };
194
+ const runCommand = (command, cwd) => {
195
+ return new Promise((resolve, reject) => {
196
+ const proc = spawn(command, { cwd, stdio: "pipe", shell: true });
197
+ proc.on("close", (code) => code === 0 ? resolve() : reject(new Error(`Command failed with exit code ${code}`)));
198
+ proc.on("error", reject);
199
+ });
200
+ };
194
201
  const suggestAppId = (name) => {
195
202
  const sanitized = name.replace(/-/g, "");
196
203
  return `org.gtkx.${sanitized}`;
@@ -302,9 +309,9 @@ export const createApp = async (options = {}) => {
302
309
  }
303
310
  try {
304
311
  const addCmd = getAddCommand(packageManager, DEPENDENCIES, false);
305
- execSync(addCmd, { cwd: projectPath, stdio: "pipe" });
312
+ await runCommand(addCmd, projectPath);
306
313
  const addDevCmd = getAddCommand(packageManager, devDeps, true);
307
- execSync(addDevCmd, { cwd: projectPath, stdio: "pipe" });
314
+ await runCommand(addDevCmd, projectPath);
308
315
  installSpinner.stop("Dependencies installed!");
309
316
  }
310
317
  catch (error) {
@@ -316,6 +323,14 @@ export const createApp = async (options = {}) => {
316
323
  p.log.info(` ${getAddCommand(packageManager, devDeps, true)}`);
317
324
  }
318
325
  const runCmd = getRunCommand(packageManager);
319
- p.note(`cd ${name}\n${runCmd}`, "Next steps");
320
- p.outro("Happy hacking!");
326
+ const nextSteps = `cd ${name}
327
+ ${runCmd}`;
328
+ const testingNote = testing !== "none"
329
+ ? `
330
+
331
+ To run tests, you need xvfb installed:
332
+ Fedora: sudo dnf install xorg-x11-server-Xvfb
333
+ Ubuntu: sudo apt install xvfb`
334
+ : "";
335
+ p.note(`${nextSteps}${testingNote}`, "Next steps");
321
336
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "CLI for GTKX - create and develop GTK4 React applications",
5
5
  "license": "MPL-2.0",
6
6
  "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
@@ -47,8 +47,8 @@
47
47
  "@vitejs/plugin-react": "5.1.2",
48
48
  "citty": "0.1.6",
49
49
  "vite": "7.2.7",
50
- "@gtkx/ffi": "0.2.1",
51
- "@gtkx/react": "0.2.1"
50
+ "@gtkx/ffi": "0.2.3",
51
+ "@gtkx/react": "0.2.3"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "^19"