@gtkx/cli 0.2.0 → 0.2.2
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/create.js +14 -6
- package/dist/dev-server.js +4 -0
- package/package.json +3 -3
package/dist/create.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
@@ -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}`;
|
|
@@ -291,7 +298,8 @@ export const createApp = async (options = {}) => {
|
|
|
291
298
|
writeFileSync(join(projectPath, "tests", "app.test.tsx"), generateExampleTest(testing));
|
|
292
299
|
}
|
|
293
300
|
s.stop("Project structure created!");
|
|
294
|
-
|
|
301
|
+
const installSpinner = p.spinner();
|
|
302
|
+
installSpinner.start("Installing dependencies...");
|
|
295
303
|
const devDeps = [...DEV_DEPENDENCIES];
|
|
296
304
|
if (testing !== "none") {
|
|
297
305
|
devDeps.push(...TESTING_DEV_DEPENDENCIES[testing]);
|
|
@@ -301,13 +309,13 @@ export const createApp = async (options = {}) => {
|
|
|
301
309
|
}
|
|
302
310
|
try {
|
|
303
311
|
const addCmd = getAddCommand(packageManager, DEPENDENCIES, false);
|
|
304
|
-
|
|
312
|
+
await runCommand(addCmd, projectPath);
|
|
305
313
|
const addDevCmd = getAddCommand(packageManager, devDeps, true);
|
|
306
|
-
|
|
307
|
-
|
|
314
|
+
await runCommand(addDevCmd, projectPath);
|
|
315
|
+
installSpinner.stop("Dependencies installed!");
|
|
308
316
|
}
|
|
309
317
|
catch (error) {
|
|
310
|
-
|
|
318
|
+
installSpinner.stop("Failed to install dependencies");
|
|
311
319
|
p.log.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
312
320
|
p.log.info("You can install dependencies manually by running:");
|
|
313
321
|
p.log.info(` cd ${name}`);
|
package/dist/dev-server.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { events } from "@gtkx/ffi";
|
|
2
3
|
import { update } from "@gtkx/react";
|
|
3
4
|
import react from "@vitejs/plugin-react";
|
|
4
5
|
import { createServer } from "vite";
|
|
@@ -33,6 +34,9 @@ export const createDevServer = async (options) => {
|
|
|
33
34
|
server.moduleGraph.invalidateModule(module);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
37
|
+
events.on("stop", () => {
|
|
38
|
+
server.close();
|
|
39
|
+
});
|
|
36
40
|
server.watcher.on("change", async (changedPath) => {
|
|
37
41
|
console.log(`[gtkx] File changed: ${changedPath}`);
|
|
38
42
|
invalidateAllModules();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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.
|
|
51
|
-
"@gtkx/react": "0.2.
|
|
50
|
+
"@gtkx/ffi": "0.2.2",
|
|
51
|
+
"@gtkx/react": "0.2.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "^19"
|