@projitect/blueprint-react 0.0.0-stage → 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kapil Easwar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@projitect/blueprint-react",
3
+ "version": "1.0.0",
4
+ "description": "React + Vite + TypeScript app blueprint for projitect — composes tsconfig, gitignore and vitest, owns vite.config.ts and the package.json scaffolding, seeds the starter source.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/projitect/projitect.git",
8
+ "directory": "packages/blueprint-react"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/src/index.d.ts",
15
+ "import": "./dist/src/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src",
21
+ "!**/*.tsbuildinfo"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc --build",
25
+ "build:clean": "tsc --build --clean",
26
+ "tc": "tsc --build"
27
+ },
28
+ "devDependencies": {
29
+ "@projitect/blueprint": "workspace:*",
30
+ "@projitect/blueprint-gitignore": "workspace:*",
31
+ "@projitect/blueprint-tsconfig": "workspace:*",
32
+ "@projitect/blueprint-vitest": "workspace:*",
33
+ "@projitect/core": "workspace:*",
34
+ "@projitect/test-kit": "workspace:*",
35
+ "effect": "4.0.0-rc.111",
36
+ "typescript": "5.9.3"
37
+ },
38
+ "peerDependencies": {
39
+ "@projitect/blueprint": "workspace:*",
40
+ "@projitect/blueprint-gitignore": "workspace:*",
41
+ "@projitect/blueprint-tsconfig": "workspace:*",
42
+ "@projitect/blueprint-vitest": "workspace:*",
43
+ "@projitect/core": "workspace:*",
44
+ "effect": "4.0.0-rc.111"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.12.0"
48
+ },
49
+ "projitect": {
50
+ "type": "blueprint",
51
+ "import": "import { react } from \"@projitect/blueprint-react\"",
52
+ "call": "react()"
53
+ }
54
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @projitect/blueprint-react
3
+ *
4
+ * One composite blueprint that scaffolds a React + Vite + TypeScript app:
5
+ *
6
+ * 1. Composes the existing `tsconfig` (DOM lib, `react-jsx`, bundler resolution), `gitignore`
7
+ * (`node` section) and `vitest` (jsdom) blueprints, so each stays the single owner of its
8
+ * files.
9
+ * 2. Owns `vite.config.ts`. Owned mode — projitect rewrites it on every `remodel`. It holds no
10
+ * `test` block; `vitest.config.ts` (owned by the vitest blueprint) takes precedence for tests.
11
+ * 3. Merges the `dev` / `build` / `preview` scripts, the React dependencies and the Vite /
12
+ * TypeScript / testing devDependencies into `package.json`. Merge mode — user keys survive.
13
+ * 4. Adds `dist/` to `.gitignore`. Region mode.
14
+ * 5. Seeds the starter source (`index.html`, `src/main.tsx`, `src/App.tsx`, `src/App.test.tsx`,
15
+ * `src/index.css`). Seed mode — written once, never enforced, so the app is yours to edit.
16
+ */
17
+ import type { Blueprint } from "@projitect/core";
18
+ /**
19
+ * Build the composite React blueprint. Every operation is attributed to its own sub-blueprint
20
+ * (`pjt:tsconfig`, `pjt:vitest`, `pjt:react`, …); removing `react()` from `.pjt.ts` removes the
21
+ * maintained scaffolding and managed keys but leaves the seeded source and the user's own
22
+ * `package.json` keys in place.
23
+ */
24
+ export declare const react: () => Blueprint.Blueprint;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AA2BhD;;;;;GAKG;AACH,eAAO,MAAM,KAAK,QAAO,SAAS,CAAC,SAsFlC,CAAA"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @projitect/blueprint-react
3
+ *
4
+ * One composite blueprint that scaffolds a React + Vite + TypeScript app:
5
+ *
6
+ * 1. Composes the existing `tsconfig` (DOM lib, `react-jsx`, bundler resolution), `gitignore`
7
+ * (`node` section) and `vitest` (jsdom) blueprints, so each stays the single owner of its
8
+ * files.
9
+ * 2. Owns `vite.config.ts`. Owned mode — projitect rewrites it on every `remodel`. It holds no
10
+ * `test` block; `vitest.config.ts` (owned by the vitest blueprint) takes precedence for tests.
11
+ * 3. Merges the `dev` / `build` / `preview` scripts, the React dependencies and the Vite /
12
+ * TypeScript / testing devDependencies into `package.json`. Merge mode — user keys survive.
13
+ * 4. Adds `dist/` to `.gitignore`. Region mode.
14
+ * 5. Seeds the starter source (`index.html`, `src/main.tsx`, `src/App.tsx`, `src/App.test.tsx`,
15
+ * `src/index.css`). Seed mode — written once, never enforced, so the app is yours to edit.
16
+ */
17
+ import { Effect } from "effect";
18
+ import { ignoreSection, jsonMerge, ownFile, seedFile } from "@projitect/blueprint";
19
+ import { gitignores } from "@projitect/blueprint-gitignore";
20
+ import { tsconfig } from "@projitect/blueprint-tsconfig";
21
+ import { vitest } from "@projitect/blueprint-vitest";
22
+ import { ChangeSet as CS } from "@projitect/core";
23
+ import manifest from "../package.json" with { type: "json" };
24
+ import * as templates from "./templates.js";
25
+ // Read the version from the package manifest (emitted next to `dist/src`) so a release bump
26
+ // reaches `.pjt.lock` and `pjt inspect` can report a real upgrade.
27
+ const PACKAGE_VERSION = manifest.version;
28
+ const REACT_DEP_RANGE = "^19.2.0";
29
+ const VITE_DEP_RANGE = "^7.3.0";
30
+ const PLUGIN_REACT_DEP_RANGE = "^5.2.0";
31
+ const TYPESCRIPT_DEP_RANGE = "^5.9.0";
32
+ const TYPES_REACT_DEP_RANGE = "^19.2.0";
33
+ const JSDOM_DEP_RANGE = "^27.4.0";
34
+ const TESTING_LIBRARY_REACT_DEP_RANGE = "^16.3.0";
35
+ const TESTING_LIBRARY_DOM_DEP_RANGE = "^10.4.0";
36
+ /** Starter files, written once and never enforced. */
37
+ const STARTER_FILES = {
38
+ "index.html": templates.indexHtml,
39
+ "src/main.tsx": templates.mainTsx,
40
+ "src/App.tsx": templates.appTsx,
41
+ "src/App.test.tsx": templates.appTestTsx,
42
+ "src/index.css": templates.indexCss,
43
+ };
44
+ /**
45
+ * Build the composite React blueprint. Every operation is attributed to its own sub-blueprint
46
+ * (`pjt:tsconfig`, `pjt:vitest`, `pjt:react`, …); removing `react()` from `.pjt.ts` removes the
47
+ * maintained scaffolding and managed keys but leaves the seeded source and the user's own
48
+ * `package.json` keys in place.
49
+ */
50
+ export const react = () => {
51
+ const id = "pjt:react";
52
+ const packageJsonMerge = jsonMerge({
53
+ id,
54
+ version: PACKAGE_VERSION,
55
+ description: "React scripts, dependencies and Vite / TypeScript devDependencies",
56
+ path: "package.json",
57
+ ownedKeys: [
58
+ "scripts.dev",
59
+ "scripts.build",
60
+ "scripts.preview",
61
+ "dependencies.react",
62
+ "dependencies.react-dom",
63
+ "devDependencies.@testing-library/dom",
64
+ "devDependencies.@testing-library/react",
65
+ "devDependencies.@types/react",
66
+ "devDependencies.@types/react-dom",
67
+ "devDependencies.@vitejs/plugin-react",
68
+ "devDependencies.jsdom",
69
+ "devDependencies.typescript",
70
+ "devDependencies.vite",
71
+ ],
72
+ value: {
73
+ scripts: {
74
+ dev: "vite",
75
+ build: "tsc --noEmit && vite build",
76
+ preview: "vite preview",
77
+ },
78
+ dependencies: {
79
+ react: REACT_DEP_RANGE,
80
+ "react-dom": REACT_DEP_RANGE,
81
+ },
82
+ devDependencies: {
83
+ "@testing-library/dom": TESTING_LIBRARY_DOM_DEP_RANGE,
84
+ "@testing-library/react": TESTING_LIBRARY_REACT_DEP_RANGE,
85
+ "@types/react": TYPES_REACT_DEP_RANGE,
86
+ "@types/react-dom": TYPES_REACT_DEP_RANGE,
87
+ "@vitejs/plugin-react": PLUGIN_REACT_DEP_RANGE,
88
+ jsdom: JSDOM_DEP_RANGE,
89
+ typescript: TYPESCRIPT_DEP_RANGE,
90
+ vite: VITE_DEP_RANGE,
91
+ },
92
+ },
93
+ });
94
+ const viteConfig = ownFile({
95
+ id,
96
+ version: PACKAGE_VERSION,
97
+ description: "Vite configuration",
98
+ path: "vite.config.ts",
99
+ content: templates.viteConfig,
100
+ });
101
+ const gitignoreDist = ignoreSection({
102
+ id,
103
+ version: PACKAGE_VERSION,
104
+ description: "ignore Vite build output",
105
+ path: ".gitignore",
106
+ content: "dist/\n",
107
+ });
108
+ const starter = Object.entries(STARTER_FILES).map(([path, content]) => seedFile({ id, version: PACKAGE_VERSION, description: `starter ${path}`, path, content }));
109
+ const parts = [
110
+ tsconfig({ module: "ESNext", dom: true, jsx: "react-jsx" }),
111
+ gitignores.node(),
112
+ vitest({ environment: "jsdom" }),
113
+ packageJsonMerge,
114
+ viteConfig,
115
+ gitignoreDist,
116
+ ...starter,
117
+ ];
118
+ return {
119
+ id,
120
+ version: PACKAGE_VERSION,
121
+ description: "React + Vite + TypeScript app (config, scripts, dependencies and starter source)",
122
+ permissions: parts.flatMap((part) => part.permissions),
123
+ plan: Effect.gen(function* () {
124
+ const changeSets = yield* Effect.forEach(parts, (part) => part.plan);
125
+ return CS.Reducer.combineAll(changeSets);
126
+ }),
127
+ };
128
+ };
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAEpD,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,QAAQ,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,4FAA4F;AAC5F,mEAAmE;AACnE,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAA;AAExC,MAAM,eAAe,GAAG,SAAS,CAAA;AACjC,MAAM,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAM,sBAAsB,GAAG,QAAQ,CAAA;AACvC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AACrC,MAAM,qBAAqB,GAAG,SAAS,CAAA;AACvC,MAAM,eAAe,GAAG,SAAS,CAAA;AACjC,MAAM,+BAA+B,GAAG,SAAS,CAAA;AACjD,MAAM,6BAA6B,GAAG,SAAS,CAAA;AAE/C,sDAAsD;AACtD,MAAM,aAAa,GAAG;IACpB,YAAY,E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1
+ /**
2
+ * Starter source for the React app. Every file here is seeded: written once, never enforced.
3
+ */
4
+ export declare const indexHtml = "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>React app</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n";
5
+ export declare const mainTsx = "import { StrictMode } from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport App from \"./App\"\nimport \"./index.css\"\n\nconst root = document.getElementById(\"root\")\nif (root === null) {\n throw new Error(\"Missing #root element in index.html\")\n}\n\ncreateRoot(root).render(\n <StrictMode>\n <App />\n </StrictMode>,\n)\n";
6
+ export declare const appTsx = "import { useState } from \"react\"\n\nexport default function App() {\n const [count, setCount] = useState(0)\n\n return (\n <main>\n <h1>Hello from projitect</h1>\n <button\n type=\"button\"\n onClick={() => {\n setCount((current) => current + 1)\n }}\n >\n Count is {count}\n </button>\n </main>\n )\n}\n";
7
+ export declare const appTestTsx = "import { cleanup, fireEvent, render, screen } from \"@testing-library/react\"\nimport { afterEach, describe, expect, it } from \"vitest\"\nimport App from \"./App\"\n\nafterEach(cleanup)\n\ndescribe(\"App\", () => {\n it(\"renders the starter heading\", () => {\n render(<App />)\n expect(screen.getByRole(\"heading\", { name: \"Hello from projitect\" })).toBeTruthy()\n })\n\n it(\"counts button clicks\", () => {\n render(<App />)\n fireEvent.click(screen.getByRole(\"button\"))\n expect(screen.getByText(\"Count is 1\")).toBeTruthy()\n })\n})\n";
8
+ export declare const indexCss = ":root {\n font-family: system-ui, sans-serif;\n color-scheme: light dark;\n}\n\nbody {\n margin: 0;\n display: grid;\n min-height: 100vh;\n place-items: center;\n}\n\nbutton {\n font: inherit;\n padding: 0.5rem 1rem;\n cursor: pointer;\n}\n";
9
+ export declare const viteConfig = "import react from \"@vitejs/plugin-react\"\nimport { defineConfig } from \"vite\"\n\n/**\n * Vite configuration scaffolded by `@projitect/blueprint-react`.\n *\n * Owned mode \u2014 projitect rewrites this file on every `pjt remodel`. Test settings live in\n * `vitest.config.ts`, which Vitest prefers over this file.\n */\nexport default defineConfig({\n plugins: [react()],\n})\n";
10
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/templates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,SAAS,uUAYrB,CAAA;AAED,eAAO,MAAM,OAAO,oWAenB,CAAA;AAED,eAAO,MAAM,MAAM,yXAmBlB,CAAA;AAED,eAAO,MAAM,UAAU,2jBAkBtB,CAAA;AAED,eAAO,MAAM,QAAQ,8PAiBpB,CAAA;AAED,eAAO,MAAM,UAAU,mYAYtB,CAAA"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Starter source for the React app. Every file here is seeded: written once, never enforced.
3
+ */
4
+ export const indexHtml = `<!doctype html>
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="UTF-8" />
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
+ <title>React app</title>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script type="module" src="/src/main.tsx"></script>
14
+ </body>
15
+ </html>
16
+ `;
17
+ export const mainTsx = `import { StrictMode } from "react"
18
+ import { createRoot } from "react-dom/client"
19
+ import App from "./App"
20
+ import "./index.css"
21
+
22
+ const root = document.getElementById("root")
23
+ if (root === null) {
24
+ throw new Error("Missing #root element in index.html")
25
+ }
26
+
27
+ createRoot(root).render(
28
+ <StrictMode>
29
+ <App />
30
+ </StrictMode>,
31
+ )
32
+ `;
33
+ export const appTsx = `import { useState } from "react"
34
+
35
+ export default function App() {
36
+ const [count, setCount] = useState(0)
37
+
38
+ return (
39
+ <main>
40
+ <h1>Hello from projitect</h1>
41
+ <button
42
+ type="button"
43
+ onClick={() => {
44
+ setCount((current) => current + 1)
45
+ }}
46
+ >
47
+ Count is {count}
48
+ </button>
49
+ </main>
50
+ )
51
+ }
52
+ `;
53
+ export const appTestTsx = `import { cleanup, fireEvent, render, screen } from "@testing-library/react"
54
+ import { afterEach, describe, expect, it } from "vitest"
55
+ import App from "./App"
56
+
57
+ afterEach(cleanup)
58
+
59
+ describe("App", () => {
60
+ it("renders the starter heading", () => {
61
+ render(<App />)
62
+ expect(screen.getByRole("heading", { name: "Hello from projitect" })).toBeTruthy()
63
+ })
64
+
65
+ it("counts button clicks", () => {
66
+ render(<App />)
67
+ fireEvent.click(screen.getByRole("button"))
68
+ expect(screen.getByText("Count is 1")).toBeTruthy()
69
+ })
70
+ })
71
+ `;
72
+ export const indexCss = `:root {
73
+ font-family: system-ui, sans-serif;
74
+ color-scheme: light dark;
75
+ }
76
+
77
+ body {
78
+ margin: 0;
79
+ display: grid;
80
+ min-height: 100vh;
81
+ place-items: center;
82
+ }
83
+
84
+ button {
85
+ font: inherit;
86
+ padding: 0.5rem 1rem;
87
+ cursor: pointer;
88
+ }
89
+ `;
90
+ export const viteConfig = `import react from "@vitejs/plugin-react"
91
+ import { defineConfig } from "vite"
92
+
93
+ /**
94
+ * Vite configuration scaffolded by \`@projitect/blueprint-react\`.
95
+ *
96
+ * Owned mode — projitect rewrites this file on every \`pjt remodel\`. Test settings live in
97
+ * \`vitest.config.ts\`, which Vitest prefers over this file.
98
+ */
99
+ export default defineConfig({
100
+ plugins: [react()],
101
+ })
102
+ `;
103
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/templates.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;CAYxB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;CAetB,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;CAmBrB,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;CAkBzB,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;CAiBvB,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;CAYzB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@projitect/blueprint-react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "React + Vite + TypeScript app blueprint for projitect — composes tsconfig, gitignore and vitest, owns vite.config.ts and the package.json scaffolding, seeds the starter source.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/projitect/projitect.git",
8
+ "directory": "packages/blueprint-react"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/src/index.d.ts",
15
+ "import": "./dist/src/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src",
21
+ "!**/*.tsbuildinfo"
22
+ ],
23
+ "devDependencies": {
24
+ "effect": "4.0.0-rc.111",
25
+ "typescript": "5.9.3",
26
+ "@projitect/blueprint": "1.0.0",
27
+ "@projitect/blueprint-gitignore": "1.0.0",
28
+ "@projitect/blueprint-tsconfig": "1.0.0",
29
+ "@projitect/blueprint-vitest": "1.0.0",
30
+ "@projitect/core": "1.0.0",
31
+ "@projitect/test-kit": "1.0.0"
32
+ },
33
+ "peerDependencies": {
34
+ "effect": "4.0.0-rc.111",
35
+ "@projitect/blueprint": "1.0.0",
36
+ "@projitect/blueprint-gitignore": "1.0.0",
37
+ "@projitect/blueprint-tsconfig": "1.0.0",
38
+ "@projitect/blueprint-vitest": "1.0.0",
39
+ "@projitect/core": "1.0.0"
40
+ },
41
+ "engines": {
42
+ "node": ">=22.12.0"
43
+ },
44
+ "projitect": {
45
+ "type": "blueprint",
46
+ "import": "import { react } from \"@projitect/blueprint-react\"",
47
+ "call": "react()"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc --build",
51
+ "build:clean": "tsc --build --clean",
52
+ "tc": "tsc --build"
53
+ }
6
54
  }
package/src/index.ts ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @projitect/blueprint-react
3
+ *
4
+ * One composite blueprint that scaffolds a React + Vite + TypeScript app:
5
+ *
6
+ * 1. Composes the existing `tsconfig` (DOM lib, `react-jsx`, bundler resolution), `gitignore`
7
+ * (`node` section) and `vitest` (jsdom) blueprints, so each stays the single owner of its
8
+ * files.
9
+ * 2. Owns `vite.config.ts`. Owned mode — projitect rewrites it on every `remodel`. It holds no
10
+ * `test` block; `vitest.config.ts` (owned by the vitest blueprint) takes precedence for tests.
11
+ * 3. Merges the `dev` / `build` / `preview` scripts, the React dependencies and the Vite /
12
+ * TypeScript / testing devDependencies into `package.json`. Merge mode — user keys survive.
13
+ * 4. Adds `dist/` to `.gitignore`. Region mode.
14
+ * 5. Seeds the starter source (`index.html`, `src/main.tsx`, `src/App.tsx`, `src/App.test.tsx`,
15
+ * `src/index.css`). Seed mode — written once, never enforced, so the app is yours to edit.
16
+ */
17
+
18
+ import { Effect } from "effect"
19
+ import { ignoreSection, jsonMerge, ownFile, seedFile } from "@projitect/blueprint"
20
+ import { gitignores } from "@projitect/blueprint-gitignore"
21
+ import { tsconfig } from "@projitect/blueprint-tsconfig"
22
+ import { vitest } from "@projitect/blueprint-vitest"
23
+ import type { Blueprint } from "@projitect/core"
24
+ import { ChangeSet as CS } from "@projitect/core"
25
+ import manifest from "../package.json" with { type: "json" }
26
+ import * as templates from "./templates.js"
27
+
28
+ // Read the version from the package manifest (emitted next to `dist/src`) so a release bump
29
+ // reaches `.pjt.lock` and `pjt inspect` can report a real upgrade.
30
+ const PACKAGE_VERSION = manifest.version
31
+
32
+ const REACT_DEP_RANGE = "^19.2.0"
33
+ const VITE_DEP_RANGE = "^7.3.0"
34
+ const PLUGIN_REACT_DEP_RANGE = "^5.2.0"
35
+ const TYPESCRIPT_DEP_RANGE = "^5.9.0"
36
+ const TYPES_REACT_DEP_RANGE = "^19.2.0"
37
+ const JSDOM_DEP_RANGE = "^27.4.0"
38
+ const TESTING_LIBRARY_REACT_DEP_RANGE = "^16.3.0"
39
+ const TESTING_LIBRARY_DOM_DEP_RANGE = "^10.4.0"
40
+
41
+ /** Starter files, written once and never enforced. */
42
+ const STARTER_FILES = {
43
+ "index.html": templates.indexHtml,
44
+ "src/main.tsx": templates.mainTsx,
45
+ "src/App.tsx": templates.appTsx,
46
+ "src/App.test.tsx": templates.appTestTsx,
47
+ "src/index.css": templates.indexCss,
48
+ } as const
49
+
50
+ /**
51
+ * Build the composite React blueprint. Every operation is attributed to its own sub-blueprint
52
+ * (`pjt:tsconfig`, `pjt:vitest`, `pjt:react`, …); removing `react()` from `.pjt.ts` removes the
53
+ * maintained scaffolding and managed keys but leaves the seeded source and the user's own
54
+ * `package.json` keys in place.
55
+ */
56
+ export const react = (): Blueprint.Blueprint => {
57
+ const id = "pjt:react"
58
+
59
+ const packageJsonMerge = jsonMerge({
60
+ id,
61
+ version: PACKAGE_VERSION,
62
+ description: "React scripts, dependencies and Vite / TypeScript devDependencies",
63
+ path: "package.json",
64
+ ownedKeys: [
65
+ "scripts.dev",
66
+ "scripts.build",
67
+ "scripts.preview",
68
+ "dependencies.react",
69
+ "dependencies.react-dom",
70
+ "devDependencies.@testing-library/dom",
71
+ "devDependencies.@testing-library/react",
72
+ "devDependencies.@types/react",
73
+ "devDependencies.@types/react-dom",
74
+ "devDependencies.@vitejs/plugin-react",
75
+ "devDependencies.jsdom",
76
+ "devDependencies.typescript",
77
+ "devDependencies.vite",
78
+ ],
79
+ value: {
80
+ scripts: {
81
+ dev: "vite",
82
+ build: "tsc --noEmit && vite build",
83
+ preview: "vite preview",
84
+ },
85
+ dependencies: {
86
+ react: REACT_DEP_RANGE,
87
+ "react-dom": REACT_DEP_RANGE,
88
+ },
89
+ devDependencies: {
90
+ "@testing-library/dom": TESTING_LIBRARY_DOM_DEP_RANGE,
91
+ "@testing-library/react": TESTING_LIBRARY_REACT_DEP_RANGE,
92
+ "@types/react": TYPES_REACT_DEP_RANGE,
93
+ "@types/react-dom": TYPES_REACT_DEP_RANGE,
94
+ "@vitejs/plugin-react": PLUGIN_REACT_DEP_RANGE,
95
+ jsdom: JSDOM_DEP_RANGE,
96
+ typescript: TYPESCRIPT_DEP_RANGE,
97
+ vite: VITE_DEP_RANGE,
98
+ },
99
+ },
100
+ })
101
+
102
+ const viteConfig = ownFile({
103
+ id,
104
+ version: PACKAGE_VERSION,
105
+ description: "Vite configuration",
106
+ path: "vite.config.ts",
107
+ content: templates.viteConfig,
108
+ })
109
+
110
+ const gitignoreDist = ignoreSection({
111
+ id,
112
+ version: PACKAGE_VERSION,
113
+ description: "ignore Vite build output",
114
+ path: ".gitignore",
115
+ content: "dist/\n",
116
+ })
117
+
118
+ const starter = Object.entries(STARTER_FILES).map(([path, content]) =>
119
+ seedFile({ id, version: PACKAGE_VERSION, description: `starter ${path}`, path, content }),
120
+ )
121
+
122
+ const parts = [
123
+ tsconfig({ module: "ESNext", dom: true, jsx: "react-jsx" }),
124
+ gitignores.node(),
125
+ vitest({ environment: "jsdom" }),
126
+ packageJsonMerge,
127
+ viteConfig,
128
+ gitignoreDist,
129
+ ...starter,
130
+ ]
131
+
132
+ return {
133
+ id,
134
+ version: PACKAGE_VERSION,
135
+ description: "React + Vite + TypeScript app (config, scripts, dependencies and starter source)",
136
+ permissions: parts.flatMap((part) => part.permissions),
137
+ plan: Effect.gen(function* () {
138
+ const changeSets = yield* Effect.forEach(parts, (part) => part.plan)
139
+ return CS.Reducer.combineAll(changeSets)
140
+ }),
141
+ }
142
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Starter source for the React app. Every file here is seeded: written once, never enforced.
3
+ */
4
+
5
+ export const indexHtml = `<!doctype html>
6
+ <html lang="en">
7
+ <head>
8
+ <meta charset="UTF-8" />
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
+ <title>React app</title>
11
+ </head>
12
+ <body>
13
+ <div id="root"></div>
14
+ <script type="module" src="/src/main.tsx"></script>
15
+ </body>
16
+ </html>
17
+ `
18
+
19
+ export const mainTsx = `import { StrictMode } from "react"
20
+ import { createRoot } from "react-dom/client"
21
+ import App from "./App"
22
+ import "./index.css"
23
+
24
+ const root = document.getElementById("root")
25
+ if (root === null) {
26
+ throw new Error("Missing #root element in index.html")
27
+ }
28
+
29
+ createRoot(root).render(
30
+ <StrictMode>
31
+ <App />
32
+ </StrictMode>,
33
+ )
34
+ `
35
+
36
+ export const appTsx = `import { useState } from "react"
37
+
38
+ export default function App() {
39
+ const [count, setCount] = useState(0)
40
+
41
+ return (
42
+ <main>
43
+ <h1>Hello from projitect</h1>
44
+ <button
45
+ type="button"
46
+ onClick={() => {
47
+ setCount((current) => current + 1)
48
+ }}
49
+ >
50
+ Count is {count}
51
+ </button>
52
+ </main>
53
+ )
54
+ }
55
+ `
56
+
57
+ export const appTestTsx = `import { cleanup, fireEvent, render, screen } from "@testing-library/react"
58
+ import { afterEach, describe, expect, it } from "vitest"
59
+ import App from "./App"
60
+
61
+ afterEach(cleanup)
62
+
63
+ describe("App", () => {
64
+ it("renders the starter heading", () => {
65
+ render(<App />)
66
+ expect(screen.getByRole("heading", { name: "Hello from projitect" })).toBeTruthy()
67
+ })
68
+
69
+ it("counts button clicks", () => {
70
+ render(<App />)
71
+ fireEvent.click(screen.getByRole("button"))
72
+ expect(screen.getByText("Count is 1")).toBeTruthy()
73
+ })
74
+ })
75
+ `
76
+
77
+ export const indexCss = `:root {
78
+ font-family: system-ui, sans-serif;
79
+ color-scheme: light dark;
80
+ }
81
+
82
+ body {
83
+ margin: 0;
84
+ display: grid;
85
+ min-height: 100vh;
86
+ place-items: center;
87
+ }
88
+
89
+ button {
90
+ font: inherit;
91
+ padding: 0.5rem 1rem;
92
+ cursor: pointer;
93
+ }
94
+ `
95
+
96
+ export const viteConfig = `import react from "@vitejs/plugin-react"
97
+ import { defineConfig } from "vite"
98
+
99
+ /**
100
+ * Vite configuration scaffolded by \`@projitect/blueprint-react\`.
101
+ *
102
+ * Owned mode — projitect rewrites this file on every \`pjt remodel\`. Test settings live in
103
+ * \`vitest.config.ts\`, which Vitest prefers over this file.
104
+ */
105
+ export default defineConfig({
106
+ plugins: [react()],
107
+ })
108
+ `
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.