@contentstorage/core 0.3.9 → 0.3.10
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to define your application configuration.
|
|
3
|
+
* Provides autocompletion and type-checking for contentstorage.config.js files.
|
|
4
|
+
*/
|
|
5
|
+
export function defineConfig(config) {
|
|
6
|
+
// You can add basic runtime validation here if desired,
|
|
7
|
+
// e.g., check if contentUrl is a valid URL format,
|
|
8
|
+
// or if languageCodes is not empty.
|
|
9
|
+
if (!config.languageCodes || config.languageCodes.length === 0) {
|
|
10
|
+
console.warn('Warning: languageCodes array is empty or missing in the configuration.');
|
|
11
|
+
}
|
|
12
|
+
if (!config.contentDir) {
|
|
13
|
+
// This would typically be a hard error, but defineConfig is more for type safety at edit time.
|
|
14
|
+
// Runtime validation (see point 3) is better for hard errors.
|
|
15
|
+
console.warn('Warning: contentDir is missing in the configuration.');
|
|
16
|
+
}
|
|
17
|
+
// ... other checks
|
|
18
|
+
return config;
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineConfig } from './helpers/defineConfig.js';
|
|
2
|
+
export { defineConfig };
|
package/dist/lib/configLoader.js
CHANGED
|
@@ -2,8 +2,8 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
const DEFAULT_CONFIG = {
|
|
4
4
|
languageCodes: [],
|
|
5
|
-
contentDir: path.join('src', '
|
|
6
|
-
typesOutputFile: path.join('src', '
|
|
5
|
+
contentDir: path.join('src', 'content', 'json'),
|
|
6
|
+
typesOutputFile: path.join('src', 'content', 'content-types.ts'),
|
|
7
7
|
};
|
|
8
8
|
export async function loadConfig() {
|
|
9
9
|
const configPath = path.resolve(process.cwd(), 'contentstorage.config.js'); // Look in user's current working dir
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@contentstorage/core",
|
|
3
3
|
"author": "Kaido Hussar <kaidohus@gmail.com>",
|
|
4
4
|
"homepage": "https://contentstorage.app",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.10",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Fetch content from contentstorage and generate TypeScript types",
|
|
8
8
|
"module": "dist/index.js",
|