@fragno-dev/create 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragno-dev/create",
3
3
  "description": "A library for creating Fragno fragments",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "exports": {
6
6
  ".": {
7
7
  "bun": "./src/index.ts",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "type": "module",
23
23
  "dependencies": {
24
- "zod": "^4.0.5"
24
+ "zod": "^4.1.12"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@fragno-private/typescript-config": "0.0.1",
package/src/index.ts CHANGED
@@ -3,17 +3,34 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { copy, merge } from "./utils.ts";
5
5
  import { buildToolPkg } from "./package-json.ts";
6
+ import { z } from "zod";
6
7
 
7
- type TemplateTypes = "fragment";
8
- // TODO: the others
9
- export type BuildTools = "esbuild" | "tsdown" | "vite" | "rollup" | "webpack" | "rspack" | "none";
8
+ const templateTypesSchema = z.literal("fragment");
9
+ export type TemplateTypes = z.infer<typeof templateTypesSchema>;
10
10
 
11
- interface CreateOptions {
12
- path: string;
13
- buildTool: BuildTools;
14
- name: string;
15
- template: TemplateTypes;
16
- }
11
+ const buildToolsSchema = z.enum([
12
+ "esbuild",
13
+ "tsdown",
14
+ "vite",
15
+ "rollup",
16
+ "webpack",
17
+ "rspack",
18
+ "none",
19
+ ]);
20
+ export type BuildTools = z.infer<typeof buildToolsSchema>;
21
+
22
+ const agentDocsSchema = z.enum(["AGENTS.md", "CLAUDE.md", "none"]);
23
+ export type AgentDocs = z.infer<typeof agentDocsSchema>;
24
+
25
+ export const createOptionsSchema = z.object({
26
+ path: z.string(),
27
+ buildTool: buildToolsSchema,
28
+ name: z.string(),
29
+ template: templateTypesSchema,
30
+ agentDocs: agentDocsSchema,
31
+ });
32
+
33
+ type CreateOptions = z.infer<typeof createOptionsSchema>;
17
34
 
18
35
  export function create(options: CreateOptions) {
19
36
  let pkgOverride: Record<string, unknown> = { name: options.name };
@@ -49,6 +66,17 @@ export function create(options: CreateOptions) {
49
66
  case "none":
50
67
  break;
51
68
  }
69
+
70
+ switch (options.agentDocs) {
71
+ case "AGENTS.md":
72
+ writeOptionalTemplate(options.path, "agent/AGENTS.md");
73
+ break;
74
+ case "CLAUDE.md":
75
+ writeOptionalTemplate(options.path, "agent/AGENTS.md", "CLAUDE.md");
76
+ break;
77
+ case "none":
78
+ break;
79
+ }
52
80
  }
53
81
 
54
82
  function getTemplateDir(): string {
@@ -56,9 +84,10 @@ function getTemplateDir(): string {
56
84
  return path.join(__dirname, "..", "templates");
57
85
  }
58
86
 
59
- function writeOptionalTemplate(targetPath: string, template: string) {
87
+ function writeOptionalTemplate(targetPath: string, template: string, rename?: string) {
60
88
  const templatePath = path.join(getTemplateDir(), "optional", template);
61
- const targetFile = path.join(targetPath, path.basename(template));
89
+ const targetFileName = rename ? rename : path.basename(template);
90
+ const targetFile = path.join(targetPath, targetFileName);
62
91
 
63
92
  copy(templatePath, targetFile);
64
93
  }
@@ -27,6 +27,7 @@ describe.concurrent.each(["tsdown", "esbuild", "vite", "rollup", "webpack", "rsp
27
27
  name: "@myorg/test",
28
28
  template: "fragment" as const,
29
29
  buildTool,
30
+ agentDocs: "AGENTS.md" as const,
30
31
  };
31
32
 
32
33
  beforeAll(async () => {
@@ -46,6 +47,11 @@ describe.concurrent.each(["tsdown", "esbuild", "vite", "rollup", "webpack", "rsp
46
47
  expect(pkgContent).toContain(testConfig.name);
47
48
  });
48
49
 
50
+ test("agent file copied", async () => {
51
+ const agentFile = path.join(tempDir, "AGENTS.md");
52
+ await expect(fs.access(agentFile)).resolves.toBeUndefined();
53
+ });
54
+
49
55
  test("installs", { timeout: 10000 }, async () => {
50
56
  const { stdout } = await execAsync("bun install", {
51
57
  cwd: tempDir,
@@ -2,7 +2,7 @@
2
2
  "description": "A Fragno fragment",
3
3
  "version": "0.0.1",
4
4
  "files": ["dist"],
5
- "keywords": ["fragno", "typescript", "react", "vue", "svelte"],
5
+ "keywords": ["fragno", "typescript", "react", "vue", "svelte", "solidjs"],
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/node/index.d.ts",
@@ -32,6 +32,14 @@
32
32
  "types": "./dist/browser/client/svelte.d.ts",
33
33
  "default": "./dist/browser/client/svelte.js"
34
34
  },
35
+ "./solid": {
36
+ "development": {
37
+ "browser": "./dist/browser/client/solid.js",
38
+ "default": "./src/client/solid.ts"
39
+ },
40
+ "types": "./dist/browser/client/solid.d.ts",
41
+ "default": "./dist/browser/client/solid.js"
42
+ },
35
43
  "./vanilla": {
36
44
  "development": {
37
45
  "browser": "./dist/browser/client/vanilla.js",
@@ -49,7 +57,7 @@
49
57
  },
50
58
  "type": "module",
51
59
  "dependencies": {
52
- "@fragno-dev/core": "^0.0.6",
60
+ "@fragno-dev/core": "^0.0.7",
53
61
  "zod": "^4.0.5"
54
62
  },
55
63
  "devDependencies": {
@@ -60,6 +68,7 @@
60
68
  "typescript": "^5",
61
69
  "react": ">=18.0.0",
62
70
  "svelte": ">=4.0.0",
71
+ "solid-js": ">=1.0.0",
63
72
  "vue": ">=3.0.0"
64
73
  }
65
74
  }
@@ -0,0 +1,7 @@
1
+ import { useFragno } from "@fragno-dev/core/solid";
2
+ import { createExampleFragmentClients } from "..";
3
+ import type { FragnoPublicClientConfig } from "@fragno-dev/core";
4
+
5
+ export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
6
+ return useFragno(createExampleFragmentClients(config));
7
+ }
@@ -13,19 +13,19 @@ import { createClientBuilder } from "@fragno-dev/core/client";
13
13
  // https://github.com/standard-schema/standard-schema#what-schema-libraries-implement-the-spec
14
14
  import { z } from "zod";
15
15
 
16
- export interface ExampleFragmentServerConfig {
16
+ export interface ExampleConfig {
17
17
  initialData?: string;
18
18
  }
19
19
 
20
- type ExampleRouteConfig = {
21
- initialData: string;
20
+ type ExampleServices = {
21
+ getData: () => string;
22
22
  };
23
23
 
24
- type ExampleRouteDeps = {
24
+ type ExampleDeps = {
25
25
  serverSideData: { value: string };
26
26
  };
27
27
 
28
- const exampleRoutesFactory = defineRoutes<ExampleRouteConfig, ExampleRouteDeps>().create(
28
+ const exampleRoutesFactory = defineRoutes<ExampleConfig, ExampleDeps, ExampleServices>().create(
29
29
  ({ deps }) => {
30
30
  const { serverSideData } = deps;
31
31
 
@@ -55,8 +55,8 @@ const exampleRoutesFactory = defineRoutes<ExampleRouteConfig, ExampleRouteDeps>(
55
55
  },
56
56
  );
57
57
 
58
- const exampleFragmentDefinition = defineFragment<ExampleFragmentServerConfig>("example-fragment")
59
- .withDependencies((config: ExampleFragmentServerConfig) => {
58
+ const exampleFragmentDefinition = defineFragment<ExampleConfig>("example-fragment")
59
+ .withDependencies((config: ExampleConfig) => {
60
60
  return {
61
61
  serverSideData: { value: config.initialData ?? "Hello World! This is a server-side data." },
62
62
  };
@@ -68,19 +68,10 @@ const exampleFragmentDefinition = defineFragment<ExampleFragmentServerConfig>("e
68
68
  });
69
69
 
70
70
  export function createExampleFragment(
71
- serverConfig: ExampleFragmentServerConfig = {},
71
+ config: ExampleConfig = {},
72
72
  fragnoConfig: FragnoPublicConfig = {},
73
73
  ) {
74
- const config: ExampleRouteConfig = {
75
- initialData: serverConfig.initialData ?? "Hello World! This is a server-side data.",
76
- };
77
-
78
- return createFragment(
79
- exampleFragmentDefinition,
80
- { ...serverConfig, ...config },
81
- [exampleRoutesFactory],
82
- fragnoConfig,
83
- );
74
+ return createFragment(exampleFragmentDefinition, config, [exampleRoutesFactory], fragnoConfig);
84
75
  }
85
76
 
86
77
  export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientConfig) {
@@ -9,6 +9,7 @@ export default defineConfig([
9
9
  "./src/index.ts",
10
10
  "./src/client/react.ts",
11
11
  "./src/client/svelte.ts",
12
+ "./src/client/solid.ts",
12
13
  "./src/client/vanilla.ts",
13
14
  "./src/client/vue.ts",
14
15
  ],