@gtkx/cli 0.10.4 → 0.10.5
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.js +2 -2
- package/dist/create.d.ts +4 -4
- package/dist/create.js +9 -32
- package/dist/templates.d.ts +2 -2
- package/package.json +4 -4
- package/templates/config/vitest.config.ts.ejs +2 -4
- package/templates/package.json.ejs +2 -2
- package/templates/tests/app.test.tsx.ejs +1 -12
- package/templates/config/jest.config.js.ejs +0 -19
package/dist/cli.js
CHANGED
|
@@ -60,11 +60,11 @@ const create = defineCommand({
|
|
|
60
60
|
},
|
|
61
61
|
pm: {
|
|
62
62
|
type: "string",
|
|
63
|
-
description: "Package manager (pnpm, npm, yarn
|
|
63
|
+
description: "Package manager (pnpm, npm, yarn)",
|
|
64
64
|
},
|
|
65
65
|
testing: {
|
|
66
66
|
type: "string",
|
|
67
|
-
description: "Testing
|
|
67
|
+
description: "Testing setup (vitest, none)",
|
|
68
68
|
},
|
|
69
69
|
"claude-skills": {
|
|
70
70
|
type: "boolean",
|
package/dist/create.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Supported package managers for GTKX projects.
|
|
3
3
|
*/
|
|
4
|
-
export type PackageManager = "pnpm" | "npm" | "yarn"
|
|
4
|
+
export type PackageManager = "pnpm" | "npm" | "yarn";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Whether to include testing setup in GTKX projects.
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type TestingOption = "vitest" | "none";
|
|
9
9
|
/**
|
|
10
10
|
* Options for creating a new GTKX project.
|
|
11
11
|
*
|
|
@@ -15,7 +15,7 @@ export type CreateOptions = {
|
|
|
15
15
|
name?: string;
|
|
16
16
|
appId?: string;
|
|
17
17
|
packageManager?: PackageManager;
|
|
18
|
-
testing?:
|
|
18
|
+
testing?: TestingOption;
|
|
19
19
|
claudeSkills?: boolean;
|
|
20
20
|
};
|
|
21
21
|
export declare const getAddCommand: (pm: PackageManager, deps: string[], dev: boolean) => string;
|
package/dist/create.js
CHANGED
|
@@ -5,11 +5,7 @@ import * as p from "@clack/prompts";
|
|
|
5
5
|
import { renderFile } from "./templates.js";
|
|
6
6
|
const DEPENDENCIES = ["@gtkx/css", "@gtkx/ffi", "@gtkx/react", "react"];
|
|
7
7
|
const DEV_DEPENDENCIES = ["@gtkx/cli", "@types/react", "typescript"];
|
|
8
|
-
const TESTING_DEV_DEPENDENCIES =
|
|
9
|
-
vitest: ["@gtkx/testing", "vitest"],
|
|
10
|
-
jest: ["@gtkx/testing", "jest", "@types/jest", "ts-jest"],
|
|
11
|
-
node: ["@gtkx/testing", "@types/node"],
|
|
12
|
-
};
|
|
8
|
+
const TESTING_DEV_DEPENDENCIES = ["@gtkx/testing", "@gtkx/vitest", "vitest"];
|
|
13
9
|
const createTemplateContext = (name, appId, testing) => {
|
|
14
10
|
const title = name
|
|
15
11
|
.split("-")
|
|
@@ -27,8 +23,6 @@ export const getAddCommand = (pm, deps, dev) => {
|
|
|
27
23
|
return `yarn add ${parts}`;
|
|
28
24
|
case "pnpm":
|
|
29
25
|
return `pnpm add ${parts}`;
|
|
30
|
-
case "bun":
|
|
31
|
-
return `bun add ${parts}`;
|
|
32
26
|
}
|
|
33
27
|
};
|
|
34
28
|
export const getRunCommand = (pm) => {
|
|
@@ -39,8 +33,6 @@ export const getRunCommand = (pm) => {
|
|
|
39
33
|
return "yarn dev";
|
|
40
34
|
case "pnpm":
|
|
41
35
|
return "pnpm dev";
|
|
42
|
-
case "bun":
|
|
43
|
-
return "bun dev";
|
|
44
36
|
}
|
|
45
37
|
};
|
|
46
38
|
export const isValidProjectName = (name) => {
|
|
@@ -104,21 +96,16 @@ const promptForOptions = async (options) => {
|
|
|
104
96
|
{ value: "pnpm", label: "pnpm", hint: "recommended" },
|
|
105
97
|
{ value: "npm", label: "npm" },
|
|
106
98
|
{ value: "yarn", label: "yarn" },
|
|
107
|
-
{ value: "bun", label: "bun" },
|
|
108
99
|
],
|
|
109
100
|
initialValue: "pnpm",
|
|
110
101
|
}));
|
|
111
102
|
const testing = options.testing ??
|
|
112
|
-
checkCancelled(await p.
|
|
113
|
-
message: "
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{ value: "none", label: "None" },
|
|
119
|
-
],
|
|
120
|
-
initialValue: "vitest",
|
|
121
|
-
}));
|
|
103
|
+
(checkCancelled(await p.confirm({
|
|
104
|
+
message: "Include testing setup (Vitest)?",
|
|
105
|
+
initialValue: true,
|
|
106
|
+
}))
|
|
107
|
+
? "vitest"
|
|
108
|
+
: "none");
|
|
122
109
|
const claudeSkills = options.claudeSkills ??
|
|
123
110
|
checkCancelled(await p.confirm({
|
|
124
111
|
message: "Include Claude Code skills?",
|
|
@@ -151,21 +138,11 @@ const scaffoldProject = (projectPath, resolved) => {
|
|
|
151
138
|
writeFileSync(join(projectPath, "vitest.config.ts"), renderFile("config/vitest.config.ts.ejs", context));
|
|
152
139
|
writeFileSync(join(projectPath, "tests", "app.test.tsx"), renderFile("tests/app.test.tsx.ejs", context));
|
|
153
140
|
}
|
|
154
|
-
else if (testing === "jest") {
|
|
155
|
-
writeFileSync(join(projectPath, "jest.config.js"), renderFile("config/jest.config.js.ejs", context));
|
|
156
|
-
writeFileSync(join(projectPath, "tests", "app.test.tsx"), renderFile("tests/app.test.tsx.ejs", context));
|
|
157
|
-
}
|
|
158
|
-
else if (testing === "node") {
|
|
159
|
-
writeFileSync(join(projectPath, "tests", "app.test.tsx"), renderFile("tests/app.test.tsx.ejs", context));
|
|
160
|
-
}
|
|
161
141
|
};
|
|
162
142
|
const getDevDependencies = (testing) => {
|
|
163
143
|
const devDeps = [...DEV_DEPENDENCIES];
|
|
164
|
-
if (testing
|
|
165
|
-
devDeps.push(...TESTING_DEV_DEPENDENCIES
|
|
166
|
-
if (testing === "node") {
|
|
167
|
-
devDeps.push("tsx");
|
|
168
|
-
}
|
|
144
|
+
if (testing === "vitest") {
|
|
145
|
+
devDeps.push(...TESTING_DEV_DEPENDENCIES);
|
|
169
146
|
}
|
|
170
147
|
return devDeps;
|
|
171
148
|
};
|
package/dist/templates.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TestingOption } from "./create.js";
|
|
2
2
|
export interface TemplateContext {
|
|
3
3
|
name: string;
|
|
4
4
|
appId: string;
|
|
5
5
|
title: string;
|
|
6
|
-
testing:
|
|
6
|
+
testing: TestingOption;
|
|
7
7
|
}
|
|
8
8
|
export declare const renderFile: (templateName: string, context: TemplateContext) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "CLI for GTKX - create and develop GTK4 React applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clack/prompts": "^0.11.0",
|
|
52
|
-
"@swc/core": "^1.15.
|
|
52
|
+
"@swc/core": "^1.15.8",
|
|
53
53
|
"citty": "^0.1.6",
|
|
54
54
|
"ejs": "^3.1.10",
|
|
55
55
|
"react-refresh": "^0.18.0",
|
|
56
56
|
"vite": "^7.3.0",
|
|
57
|
-
"@gtkx/ffi": "0.10.
|
|
58
|
-
"@gtkx/react": "0.10.
|
|
57
|
+
"@gtkx/ffi": "0.10.5",
|
|
58
|
+
"@gtkx/react": "0.10.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/ejs": "^3.1.5",
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import gtkx from "@gtkx/vitest";
|
|
1
2
|
import { defineConfig } from "vitest/config";
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
5
|
+
plugins: [gtkx()],
|
|
4
6
|
test: {
|
|
5
7
|
include: ["tests/**/*.test.{ts,tsx}"],
|
|
6
8
|
globals: false,
|
|
7
9
|
bail: 1,
|
|
8
|
-
pool: "forks",
|
|
9
|
-
},
|
|
10
|
-
esbuild: {
|
|
11
|
-
jsx: "automatic",
|
|
12
10
|
},
|
|
13
11
|
});
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "gtkx dev src/dev.tsx",
|
|
8
8
|
"build": "tsc -b",
|
|
9
|
-
"start": "node dist/index.js"<% if (testing
|
|
10
|
-
"test": "
|
|
9
|
+
"start": "node dist/index.js"<% if (testing === 'vitest') { %>,
|
|
10
|
+
"test": "vitest"<% } %>
|
|
11
11
|
},
|
|
12
12
|
"gtkx": {
|
|
13
13
|
"appId": "<%= appId %>"
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
<% if (testing === 'vitest') { -%>
|
|
2
1
|
import { describe, it, expect, afterEach } from "vitest";
|
|
3
|
-
<% } else if (testing === 'jest') { -%>
|
|
4
|
-
import { describe, it, expect, afterEach } from "@jest/globals";
|
|
5
|
-
<% } else { -%>
|
|
6
|
-
import { describe, it, after } from "node:test";
|
|
7
|
-
import { strict as assert } from "node:assert";
|
|
8
|
-
<% } -%>
|
|
9
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
10
3
|
import { cleanup, render, screen } from "@gtkx/testing";
|
|
11
4
|
import App from "../src/app.js";
|
|
12
5
|
|
|
13
|
-
|
|
6
|
+
afterEach(async () => {
|
|
14
7
|
await cleanup();
|
|
15
8
|
});
|
|
16
9
|
|
|
@@ -18,10 +11,6 @@ describe("App", () => {
|
|
|
18
11
|
it("renders the increment button", async () => {
|
|
19
12
|
await render(<App />, { wrapper: false });
|
|
20
13
|
const button = await screen.findByRole(Gtk.AccessibleRole.BUTTON, { name: "Increment" });
|
|
21
|
-
<% if (testing === 'node') { -%>
|
|
22
|
-
assert.ok(button, "Button should be rendered");
|
|
23
|
-
<% } else { -%>
|
|
24
14
|
expect(button).toBeDefined();
|
|
25
|
-
<% } -%>
|
|
26
15
|
});
|
|
27
16
|
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** @type {import('jest').Config} */
|
|
2
|
-
export default {
|
|
3
|
-
preset: "ts-jest/presets/default-esm",
|
|
4
|
-
testEnvironment: "node",
|
|
5
|
-
testMatch: ["**/tests/**/*.test.ts"],
|
|
6
|
-
extensionsToTreatAsEsm: [".ts", ".tsx"],
|
|
7
|
-
moduleNameMapper: {
|
|
8
|
-
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
9
|
-
},
|
|
10
|
-
transform: {
|
|
11
|
-
"^.+\\.tsx?$": [
|
|
12
|
-
"ts-jest",
|
|
13
|
-
{
|
|
14
|
-
useESM: true,
|
|
15
|
-
tsconfig: "tsconfig.json",
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
};
|