@zpress/core 0.3.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -98,21 +98,15 @@ export declare type ConfigResult<T> = readonly [ConfigError, null] | readonly [n
98
98
  export declare function createPaths(dir: string): Paths;
99
99
 
100
100
  /**
101
- * Type-safe config helper with validation.
101
+ * Type-safe config helper for user config files.
102
102
  *
103
- * Validates the config structure and exits with a clear error message
104
- * if any issues are found. This is the primary entry point for user-
105
- * provided config validation happens at the boundary.
106
- *
107
- * `defineConfig` is called in user config files (e.g. `zpress.config.ts`)
108
- * where the return value is consumed by the c12 config loader, which
109
- * expects a plain `ZpressConfig` object — not a `Result` tuple.
110
- * Because this is the outermost user-facing boundary (not a library
111
- * function), `process.exit(1)` is acceptable here: the user must fix
112
- * their config before any downstream code can run.
103
+ * This is a passthrough that provides type safety and editor
104
+ * autocompletion in `zpress.config.ts`. Validation is deferred to
105
+ * `loadConfig` at CLI runtime, so errors surface with structured
106
+ * feedback rather than a raw `process.exit`.
113
107
  *
114
108
  * @param config - Raw zpress config object
115
- * @returns The validated config (unchanged)
109
+ * @returns The config (unchanged)
116
110
  */
117
111
  export declare function defineConfig(config: ZpressConfig): ZpressConfig;
118
112
 
@@ -251,6 +245,11 @@ export declare interface Entry {
251
245
  * @default "overview"
252
246
  */
253
247
  readonly indexFile?: string;
248
+ /**
249
+ * Iconify icon identifier (e.g. `"pixelarticons:speed-fast"`).
250
+ * Used on home page feature cards when auto-generated from sections.
251
+ */
252
+ readonly icon?: string;
254
253
  /**
255
254
  * Card display metadata for the parent section's auto-generated landing page.
256
255
  *
@@ -395,10 +394,14 @@ declare type GlobPattern = string;
395
394
  export declare function hasGlobChars(s: string): boolean;
396
395
 
397
396
  /**
398
- * Load zpress config at runtime via c12.
397
+ * Load and validate zpress config at runtime via c12.
399
398
  *
400
- * Returns a `ConfigResult` tuple instead of calling `process.exit` the
401
- * CLI boundary is responsible for surfacing the error and exiting.
399
+ * Returns a `ConfigResult` tuple the CLI boundary is responsible for
400
+ * surfacing any error and exiting. Validation runs here (not in
401
+ * `defineConfig`) so every consumer gets structured error feedback.
402
+ *
403
+ * @param dir - Repository root directory to search for `zpress.config.*`
404
+ * @returns A `ConfigResult` tuple — `[null, config]` on success or `[ConfigError, null]` on failure
402
405
  */
403
406
  export declare function loadConfig(dir: string): Promise<ConfigResult<ZpressConfig>>;
404
407
 
@@ -752,6 +755,14 @@ export declare interface SyncResult {
752
755
  */
753
756
  declare type UrlPath = string;
754
757
 
758
+ /**
759
+ * Validate the entire config, returning the first error found.
760
+ *
761
+ * @param config - Raw zpress config object to validate
762
+ * @returns A `ConfigResult` tuple — `[null, config]` on success or `[ConfigError, null]` on failure
763
+ */
764
+ export declare function validateConfig(config: ZpressConfig): ConfigResult<ZpressConfig>;
765
+
755
766
  /**
756
767
  * A named group of workspace items for custom workspace categories.
757
768
  *
package/dist/index.mjs CHANGED
@@ -48,11 +48,6 @@ function collectResults(results) {
48
48
  ]);
49
49
  }
50
50
  function defineConfig(config) {
51
- const [err] = validateConfig(config);
52
- if (err) {
53
- process.stderr.write(`[zpress] ${err.message}\n`);
54
- process.exit(1);
55
- }
56
51
  return config;
57
52
  }
58
53
  function validateConfig(config) {
@@ -235,10 +230,7 @@ async function config_loadConfig(dir) {
235
230
  configError('empty_sections', 'Failed to load zpress.config — no sections found'),
236
231
  null
237
232
  ];
238
- return [
239
- null,
240
- config
241
- ];
233
+ return validateConfig(config);
242
234
  }
243
235
  const FIGLET_CHARS = Object.freeze({
244
236
  A: [
@@ -1429,7 +1421,7 @@ function buildFeatures(sections, repoRoot) {
1429
1421
  return Promise.all(sections.slice(0, 3).map(async (section, index)=>{
1430
1422
  const link = section.link ?? findFirstChildLink(section);
1431
1423
  const details = await extractSectionDescription(section, repoRoot);
1432
- const iconId = null;
1424
+ const iconId = section.icon ?? null;
1433
1425
  const iconColor = ICON_COLORS[index % ICON_COLORS.length];
1434
1426
  return {
1435
1427
  title: section.text,
@@ -2839,4 +2831,4 @@ function createPaths(dir) {
2839
2831
  cacheDir: node_path.resolve(outputRoot, 'cache')
2840
2832
  };
2841
2833
  }
2842
- export { configError, config_loadConfig as loadConfig, createPaths, defineConfig, generateAssets, generateBannerSvg, generateIconSvg, generateLogoSvg, hasGlobChars, loadManifest, resolveEntries, sync, syncError };
2834
+ export { configError, config_loadConfig as loadConfig, createPaths, defineConfig, generateAssets, generateBannerSvg, generateIconSvg, generateLogoSvg, hasGlobChars, loadManifest, resolveEntries, sync, syncError, validateConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zpress/core",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Config loading, sync engine, and asset utilities for zpress",
5
5
  "keywords": [
6
6
  "config",