handoff-app 2.0.0-7 → 2.0.0-8

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 (98) hide show
  1. package/README.md +111 -11
  2. package/UPGRADE.md +20 -0
  3. package/dist/app-builder/build.js +10 -2
  4. package/dist/app-builder/client-config.js +3 -1
  5. package/dist/app-builder/watchers.js +17 -7
  6. package/dist/cache/build-cache.js +5 -1
  7. package/dist/cli/auth/device.d.ts +6 -1
  8. package/dist/cli/auth/device.js +5 -2
  9. package/dist/cli/auth/store.d.ts +15 -6
  10. package/dist/cli/auth/store.js +72 -19
  11. package/dist/commands/login/index.d.ts +5 -0
  12. package/dist/commands/login/index.js +18 -6
  13. package/dist/commands/logout/index.d.ts +5 -0
  14. package/dist/commands/logout/index.js +54 -15
  15. package/dist/commands/types.d.ts +2 -0
  16. package/dist/commands/utils.d.ts +21 -7
  17. package/dist/commands/utils.js +11 -10
  18. package/dist/config/catalog-include.d.ts +2 -2
  19. package/dist/config/defaults.d.ts +3 -3
  20. package/dist/config/defaults.js +54 -48
  21. package/dist/config/env.d.ts +9 -0
  22. package/dist/config/env.js +43 -0
  23. package/dist/config/errors.d.ts +4 -0
  24. package/dist/config/errors.js +11 -0
  25. package/dist/config/from-env.d.ts +24 -0
  26. package/dist/config/from-env.js +7 -0
  27. package/dist/config/helpers.d.ts +2 -0
  28. package/dist/config/helpers.js +3 -1
  29. package/dist/config/index.d.ts +2 -1
  30. package/dist/config/index.js +6 -1
  31. package/dist/config/loader.d.ts +29 -11
  32. package/dist/config/loader.js +119 -46
  33. package/dist/config/resolve-env.d.ts +5 -0
  34. package/dist/config/resolve-env.js +102 -0
  35. package/dist/config/runtime.d.ts +3 -3
  36. package/dist/config/validator.d.ts +2 -2
  37. package/dist/config/validator.js +2 -4
  38. package/dist/index.d.ts +33 -4
  39. package/dist/index.js +60 -16
  40. package/dist/pipeline/index.d.ts +1 -1
  41. package/dist/pipeline/index.js +1 -1
  42. package/dist/registry/asset-storage/adapters/vercel-blob.js +1 -1
  43. package/dist/registry/asset-storage/resolve.d.ts +2 -2
  44. package/dist/registry/asset-storage/resolve.js +4 -1
  45. package/dist/registry/checkout/index.js +4 -4
  46. package/dist/registry/connection.d.ts +28 -24
  47. package/dist/registry/connection.js +53 -67
  48. package/dist/registry/db/driver.d.ts +4 -11
  49. package/dist/registry/db/driver.js +4 -16
  50. package/dist/registry/db/index.d.ts +1 -1
  51. package/dist/registry/db/index.js +1 -2
  52. package/dist/registry/publish/index.js +4 -4
  53. package/dist/store/filesystem.d.ts +2 -2
  54. package/dist/types/config.d.ts +48 -29
  55. package/docs/api.md +31 -0
  56. package/docs/cli.md +2 -2
  57. package/package.json +1 -1
  58. package/src/app/pages/account/tokens.tsx +3 -1
  59. package/src/app-builder/build.ts +10 -2
  60. package/src/app-builder/client-config.ts +5 -3
  61. package/src/app-builder/watchers.ts +18 -8
  62. package/src/cache/build-cache.ts +5 -1
  63. package/src/cli/auth/device.ts +8 -3
  64. package/src/cli/auth/store.ts +75 -18
  65. package/src/commands/login/index.ts +20 -6
  66. package/src/commands/logout/index.ts +74 -20
  67. package/src/commands/types.ts +2 -0
  68. package/src/commands/utils.ts +14 -5
  69. package/src/config/README.md +61 -1
  70. package/src/config/catalog-include.ts +2 -2
  71. package/src/config/defaults.ts +24 -14
  72. package/src/config/env.ts +41 -0
  73. package/src/config/errors.ts +7 -0
  74. package/src/config/from-env.ts +26 -0
  75. package/src/config/helpers.ts +4 -2
  76. package/src/config/index.ts +4 -1
  77. package/src/config/loader.ts +156 -50
  78. package/src/config/resolve-env.ts +94 -0
  79. package/src/config/runtime.ts +3 -3
  80. package/src/config/validator.ts +4 -6
  81. package/src/index.d.ts +2 -2
  82. package/src/index.ts +85 -8
  83. package/src/pipeline/index.ts +1 -1
  84. package/src/registry/asset-storage/adapters/vercel-blob.ts +1 -1
  85. package/src/registry/asset-storage/resolve.ts +6 -3
  86. package/src/registry/checkout/index.ts +5 -5
  87. package/src/registry/connection.ts +72 -71
  88. package/src/registry/db/driver.ts +6 -17
  89. package/src/registry/db/index.ts +0 -1
  90. package/src/registry/publish/index.ts +5 -5
  91. package/src/store/filesystem.ts +2 -2
  92. package/src/types/config.ts +45 -29
  93. package/templates/default/env.tpl +10 -0
  94. package/templates/default/gitignore.tpl +7 -0
  95. package/templates/default/handoff.config.js.tpl +21 -172
  96. package/templates/default/handoff.config.ts.tpl +21 -156
  97. package/templates/default/handoff.config.with-examples.js.tpl +20 -171
  98. package/templates/default/handoff.config.with-examples.ts.tpl +20 -155
@@ -1,4 +1,4 @@
1
- const { defineConfig } = require('handoff-app');
1
+ const { defineConfig, fromEnv } = require('handoff-app');
2
2
  /** @typedef {import('handoff-app').Config} HandoffConfig */
3
3
 
4
4
  /** @type {HandoffConfig} */
@@ -42,183 +42,32 @@ const config = {
42
42
  }
43
43
  },
44
44
 
45
+ // A path is either an item directory, or a collection directory whose subdirectories are each an
46
+ // item.
45
47
  catalog: {
46
- /**
47
- * Directories to search for catalog items. A path is either an item directory or a collection
48
- * directory whose subdirectories are each treated as an item. An item declares an
49
- * implementation (React, Handlebars) or a composition of other items.
50
- *
51
- * @example include: ["components", "patterns"]
52
- */
53
48
  include: ["components/button"],
54
49
  },
55
50
 
56
- // Runtime settings, all optional. The default is workspace mode with the MCP endpoint served.
57
- // `mcp: false` leaves the /api/mcp/ endpoint, and the connect affordance in the docs header, out
58
- // of the build; the route then answers 404.
59
- // The registry block is only needed when deploying a hosted registry, and is used by
60
- // `build --target registry` and `db:migrate`. The default workspace mode uses no database.
61
- // Handoff runs on PostgreSQL, and `driver` just picks the connection driver to use, not
62
- // the database engine. Secrets are referenced by env var name and never written here.
63
- // runtime: {
64
- // mode: "registry",
65
- // mcp: false,
66
- // registry: {
67
- // databaseUrlEnv: "DATABASE_URL",
68
- // database: { driver: "pg" }, // 'pg' | 'neon'
69
- // },
70
- // },
71
-
72
- // Optional handoff-docgen settings used by component docs generation
73
- // reactDocgen: {
74
- // maxDepth: 7,
75
- // excludeDirectories: ["dist", "build", ".next"]
76
- // },
77
-
78
- hooks: {
79
- /**
80
- * Optional validation callback for components
81
- * @param component - The component instance to validate
82
- * @returns A record of validation results where keys are validation types and values are detailed validation results
83
- *
84
- * @example
85
- * validateComponent: async (component) => ({
86
- * a11y: {
87
- * description: 'Accessibility validation check',
88
- * passed: true,
89
- * messages: ['No accessibility issues found']
90
- * },
91
- * responsive: {
92
- * description: 'Responsive design validation',
93
- * passed: false,
94
- * messages: ['Component breaks at mobile breakpoint']
95
- * }
96
- * })
97
- */
98
- // validateComponent: async (component) => {
99
- // // Add your custom validation logic here
100
- // return {};
101
- // },
102
-
103
- /**
104
- * Optional hook to override the SSR build configuration used in the ssrRenderPlugin
105
- * @param config - The default esbuild configuration
106
- * @returns Modified esbuild configuration
107
- *
108
- * @example
109
- * ssrBuildConfig: (config) => {
110
- * // Modify the esbuild config as needed
111
- * return config;
112
- * }
113
- */
114
- // ssrBuildConfig: (config) => {
115
- // // Add your custom SSR build configuration here
116
- // return config;
117
- // },
118
-
119
- /**
120
- * Optional hook to override the client-side build configuration used in the ssrRenderPlugin
121
- * @param config - The default esbuild configuration
122
- * @returns Modified esbuild configuration
123
- *
124
- * @example
125
- * clientBuildConfig: (config) => {
126
- * // Modify the esbuild config as needed
127
- * return config;
128
- * }
129
- */
130
- // clientBuildConfig: (config) => {
131
- // // Add your custom client build configuration here
132
- // return config;
133
- // },
134
-
135
- /**
136
- * Optional hook to specify which export property contains the schema
137
- * @param exports - The module exports object containing the schema
138
- * @returns The schema object from the exports
139
- *
140
- * @example
141
- * getSchemaFromExports: (exports) => exports.customSchema || exports.default
142
- */
143
- // getSchemaFromExports: (exports) => {
144
- // // Add your custom schema extraction logic here
145
- // return exports.default;
146
- // },
147
-
148
- /**
149
- * Optional hook to transform the schema into properties
150
- * @param schema - The schema object to transform
151
- * @returns The transformed properties object
152
- */
153
- // schemaToProperties: (schema) => {
154
- // // Add your custom schema to properties transformation here
155
- // return {};
156
- // },
157
-
158
- /**
159
- * Optional hook to override the JavaScript Vite configuration
160
- * @param config - The default Vite configuration
161
- * @returns Modified Vite configuration
162
- *
163
- * @example
164
- * jsBuildConfig: (config) => {
165
- * // Modify the Vite config as needed
166
- * return config;
167
- * }
168
- */
169
- // jsBuildConfig: (config) => {
170
- // // Add your custom JavaScript build configuration here
171
- // return config;
172
- // },
173
-
174
- /**
175
- * Optional hook to override the CSS Vite configuration
176
- * @param config - The default Vite configuration
177
- * @returns Modified Vite configuration
178
- *
179
- * @example
180
- * cssBuildConfig: (config) => {
181
- * // Modify the Vite config as needed
182
- * return config;
183
- * }
184
- */
185
- // cssBuildConfig: (config) => {
186
- // // Add your custom CSS build configuration here
187
- // return config;
51
+ // `mode` selects the runtime: "workspace" (no database) or "registry" (Postgres). The registry
52
+ // block is read only by `build --target registry` and `db:migrate`, and secrets are referenced by
53
+ // env var name. A named profile (`handoff.config.registry.*`, `--profile registry`) is a good home
54
+ // for it.
55
+ runtime: {
56
+ mode: "workspace",
57
+ // mcp: false,
58
+ // registry: {
59
+ // databaseUrl: fromEnv("DATABASE_URL"),
60
+ // database: { driver: "pg" }, // 'pg' | 'neon'
188
61
  // },
62
+ },
189
63
 
190
- /**
191
- * Optional hook to override the HTML Vite configuration
192
- * @param config - The default Vite configuration
193
- * @returns Modified Vite configuration
194
- *
195
- * @example
196
- * htmlBuildConfig: (config) => {
197
- * // Modify the Vite config as needed
198
- * return config;
199
- * }
200
- */
201
- // htmlBuildConfig: (config) => {
202
- // // Add your custom HTML build configuration here
203
- // return config;
204
- // },
64
+ // reactDocgen: { maxDepth: 7, excludeDirectories: ["dist", "build", ".next"] },
205
65
 
206
- /**
207
- * Optional hook run after built-in Handlebars helpers (`field`, `eq`) for preview HTML.
208
- * @param context.handlebars - Handlebars module (use registerHelper)
209
- * @param context.componentId - Current component id
210
- * @param context.properties - Slot metadata map from the schema
211
- * @param context.injectFieldWrappers - True when generating inspect-mode previews
212
- *
213
- * @example
214
- * registerHandlebarsHelpers: ({ handlebars, componentId }) => {
215
- * handlebars.registerHelper('upperId', () => componentId.toUpperCase());
216
- * }
217
- */
218
- // registerHandlebarsHelpers: ({ handlebars, componentId, properties, injectFieldWrappers }) => {
219
- // // Add your custom Handlebars helpers here
220
- // },
221
- },
66
+ // Optional build hooks: component validation, esbuild and Vite config overrides, Handlebars
67
+ // helper registration. Signatures and examples are on the `Config` type.
68
+ // hooks: {
69
+ // validateComponent: async (component) => ({}),
70
+ // },
222
71
  };
223
72
 
224
73
  module.exports = defineConfig(config);
@@ -1,4 +1,4 @@
1
- import { defineConfig } from 'handoff-app';
1
+ import { defineConfig, fromEnv } from 'handoff-app';
2
2
 
3
3
  export default defineConfig({
4
4
  app: {
@@ -40,165 +40,30 @@ export default defineConfig({
40
40
  }
41
41
  },
42
42
 
43
+ // A path is either an item directory, or a collection directory whose subdirectories are each an
44
+ // item.
43
45
  catalog: {
44
- /**
45
- * Directories to search for catalog items. A path is either an item directory or a collection
46
- * directory whose subdirectories are each treated as an item. An item declares an
47
- * implementation (React, Handlebars) or a composition of other items.
48
- *
49
- * @example include: ["components", "patterns"]
50
- */
51
46
  include: ["components/button"],
52
47
  },
53
48
 
54
- // Runtime settings, all optional. The default is workspace mode with the MCP endpoint served.
55
- // `mcp: false` leaves the /api/mcp/ endpoint, and the connect affordance in the docs header, out
56
- // of the build; the route then answers 404.
57
- // The registry block is only needed when deploying a hosted registry, and is used by
58
- // `build --target registry` and `db:migrate`. The default workspace mode uses no database.
59
- // Handoff runs on PostgreSQL, and `driver` just picks the connection driver to use, not
60
- // the database engine. Secrets are referenced by env var name and never written here.
61
- // runtime: {
62
- // mode: "registry",
63
- // mcp: false,
64
- // registry: {
65
- // databaseUrlEnv: "DATABASE_URL",
66
- // database: { driver: "pg" }, // 'pg' | 'neon'
67
- // },
68
- // },
69
-
70
- // Optional handoff-docgen settings used by component docs generation
71
- // reactDocgen: {
72
- // maxDepth: 7,
73
- // excludeDirectories: ["dist", "build", ".next"]
74
- // },
75
-
76
- hooks: {
77
- /**
78
- * Optional validation callback for components
79
- * @param component - The component instance to validate
80
- * @returns A record of validation results where keys are validation types and values are detailed validation results
81
- *
82
- * @example
83
- * validateComponent: async (component) => ({
84
- * a11y: {
85
- * description: 'Accessibility validation check',
86
- * passed: true,
87
- * messages: ['No accessibility issues found']
88
- * },
89
- * responsive: {
90
- * description: 'Responsive design validation',
91
- * passed: false,
92
- * messages: ['Component breaks at mobile breakpoint']
93
- * }
94
- * })
95
- */
96
- // validateComponent: async (component) => {
97
- // // Add your custom validation logic here
98
- // return {};
99
- // },
100
-
101
- /**
102
- * Optional hook to override the SSR build configuration used in the ssrRenderPlugin
103
- * @param config - The default esbuild configuration
104
- * @returns Modified esbuild configuration
105
- *
106
- * @example
107
- * ssrBuildConfig: (config) => {
108
- * // Modify the esbuild config as needed
109
- * return config;
110
- * }
111
- */
112
- // ssrBuildConfig: (config) => {
113
- // // Add your custom SSR build configuration here
114
- // return config;
115
- // },
116
-
117
- /**
118
- * Optional hook to override the client-side build configuration used in the ssrRenderPlugin
119
- * @param config - The default esbuild configuration
120
- * @returns Modified esbuild configuration
121
- *
122
- * @example
123
- * clientBuildConfig: (config) => {
124
- * // Modify the esbuild config as needed
125
- * return config;
126
- * }
127
- */
128
- // clientBuildConfig: (config) => {
129
- // // Add your custom client build configuration here
130
- // return config;
131
- // },
132
-
133
- /**
134
- * Optional hook to specify which export property contains the schema
135
- * @param exports - The module exports object containing the schema
136
- * @returns The schema object from the exports
137
- *
138
- * @example
139
- * getSchemaFromExports: (exports) => exports.customSchema || exports.default
140
- */
141
- // getSchemaFromExports: (exports) => {
142
- // // Add your custom schema extraction logic here
143
- // return exports.default;
49
+ // `mode` selects the runtime: "workspace" (no database) or "registry" (Postgres). The registry
50
+ // block is read only by `build --target registry` and `db:migrate`, and secrets are referenced by
51
+ // env var name. A named profile (`handoff.config.registry.*`, `--profile registry`) is a good home
52
+ // for it.
53
+ runtime: {
54
+ mode: "workspace",
55
+ // mcp: false,
56
+ // registry: {
57
+ // databaseUrl: fromEnv("DATABASE_URL"),
58
+ // database: { driver: "pg" }, // 'pg' | 'neon'
144
59
  // },
60
+ },
145
61
 
146
- /**
147
- * Optional hook to transform the schema into properties
148
- * @param schema - The schema object to transform
149
- * @returns The transformed properties object
150
- */
151
- // schemaToProperties: (schema) => {
152
- // // Add your custom schema to properties transformation here
153
- // return {};
154
- // },
62
+ // reactDocgen: { maxDepth: 7, excludeDirectories: ["dist", "build", ".next"] },
155
63
 
156
- /**
157
- * Optional hook to override the JavaScript Vite configuration
158
- * @param config - The default Vite configuration
159
- * @returns Modified Vite configuration
160
- *
161
- * @example
162
- * jsBuildConfig: (config) => {
163
- * // Modify the Vite config as needed
164
- * return config;
165
- * }
166
- */
167
- // jsBuildConfig: (config) => {
168
- // // Add your custom JavaScript build configuration here
169
- // return config;
170
- // },
171
-
172
- /**
173
- * Optional hook to override the CSS Vite configuration
174
- * @param config - The default Vite configuration
175
- * @returns Modified Vite configuration
176
- *
177
- * @example
178
- * cssBuildConfig: (config) => {
179
- * // Modify the Vite config as needed
180
- * return config;
181
- * }
182
- */
183
- // cssBuildConfig: (config) => {
184
- // // Add your custom CSS build configuration here
185
- // return config;
186
- // },
187
-
188
- /**
189
- * Optional hook to override the HTML Vite configuration
190
- * @param config - The default Vite configuration
191
- * @returns Modified Vite configuration
192
- *
193
- * @example
194
- * htmlBuildConfig: (config) => {
195
- * // Modify the Vite config as needed
196
- * return config;
197
- * }
198
- */
199
- // htmlBuildConfig: (config) => {
200
- // // Add your custom HTML build configuration here
201
- // return config;
202
- // },
203
- },
64
+ // Optional build hooks: component validation, esbuild and Vite config overrides, Handlebars
65
+ // helper registration. Signatures and examples are on the `Config` type.
66
+ // hooks: {
67
+ // validateComponent: async (component) => ({}),
68
+ // },
204
69
  });