Skip to content

Commit

Permalink
Merge pull request #9 from CloudCannon/fix/decouple-ssg
Browse files Browse the repository at this point in the history
Remove ssg field and separate build-coupled configuration
  • Loading branch information
rphillips-cc authored Aug 1, 2024
2 parents b99c518 + b88b7ac commit ec0c4a0
Show file tree
Hide file tree
Showing 10 changed files with 1,784 additions and 1,765 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ npm run ajv validate -s node_modules/@cloudcannon/configuration-types/cloudcanno
For a CommonJS formatted configuration file (e.g. `/cloudcannon.config.cjs`), you can use a JSDoc comment to indicate the type of the module export:

```javascript
/** @type {import("@cloudcannon/configuration-types").DefaultConfiguration} */
/** @type {import("@cloudcannon/configuration-types").Configuration} */
const config = {
collections_config: {
posts: {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"email": "[email protected]"
},
"scripts": {
"build:unknown": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type Configuration --out build/cloudcannon-config.json",
"build:default": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type DefaultConfiguration --out build/cloudcannon-config-default.json",
"build:eleventy": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type EleventyConfiguration --out build/cloudcannon-config-eleventy.json",
"build:jekyll": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type JekyllConfiguration --out build/cloudcannon-config-jekyll.json",
"build:hugo": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type HugoConfiguration --out build/cloudcannon-config-hugo.json",
"build:default": "ts-json-schema-generator --markdown-description --path src/index.d.ts --type Configuration --out build/cloudcannon-config.json",
"build:reader": "ts-json-schema-generator --markdown-description --path src/build-coupled.d.ts --type ReaderConfiguration --out build/cloudcannon-config-reader.json",
"build:eleventy": "ts-json-schema-generator --markdown-description --path src/build-coupled.d.ts --type EleventyConfiguration --out build/cloudcannon-config-eleventy.json",
"build:jekyll": "ts-json-schema-generator --markdown-description --path src/build-coupled.d.ts --type JekyllConfiguration --out build/cloudcannon-config-jekyll.json",
"build:hugo": "ts-json-schema-generator --markdown-description --path src/build-coupled.d.ts --type HugoConfiguration --out build/cloudcannon-config-hugo.json",
"build": "run-p build:*",
"prebuild": "mkdir -p build && rimraf --glob 'build/*.json'",
"test": "exit 0"
Expand All @@ -47,4 +47,4 @@
"prettier-plugin-jsdoc": "^1.3.0",
"rimraf": "^5.0.7"
}
}
}
181 changes: 181 additions & 0 deletions src/build-coupled.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import { CollectionConfig, Configuration, Parseable } from './configuration';

export type FilterBase = 'none' | 'all' | 'strict';

export interface Filter {
/**
* Defines the initial set of visible files in the collection file list. Defaults to "all", or
* "strict" for the auto-discovered `pages` collection in Jekyll, Hugo, and Eleventy.
*/
base?: FilterBase;
/**
* Add to the visible files set with `base`. Paths must be relative to the containing collection
* `path`.
*/
include?: string[];
/**
* Remove from the visible files set with `base`. Paths must be relative to the containing
* collection `path`.
*/
exclude?: string[];
}

interface Filterable {
/**
* Controls which files are displayed in the collection list. Does not change which files are
* assigned to this collection.
*/
filter?: Filter | FilterBase;
}

interface WithCollectionsConfigOverride {
/**
* Prevents CloudCannon from automatically discovering collections for supported SSGs if true.
* Defaults to false.
*/
collections_config_override?: boolean;
}

/**
* The `collections_config` entry format for build-coupled non-Jekyll/Hugo/Eleventy sites.
*/
export interface ReaderCollectionConfig extends CollectionConfig, Parseable, Filterable {}

/**
* The configuration format for build-coupled non-Jekyll/Hugo/Eleventy sites.
*/
export interface ReaderConfiguration extends Configuration {
collections_config?: Record<string, ReaderCollectionConfig>;
/**
* Generates the integration file in another folder. Not applicable to Jekyll, Hugo, and Eleventy.
* Defaults to the root folder.
*/
output?: string;
}

export interface BuildCoupledCollectionConfig extends Omit<CollectionConfig, 'url'>, Filterable {}

interface BuildCoupledConfiguration
extends Omit<Configuration, 'data_config'>,
WithCollectionsConfigOverride {}

/**
* The `collections_config` entry format for build-coupled Hugo sites.
*/
export interface HugoCollectionConfig extends BuildCoupledCollectionConfig {
/**
* Controls whether branch index files (e.g. `_index.md`) are assigned to this collection or not.
* The "pages" collection defaults this to true, and false otherwise.
*/
parse_branch_index?: boolean;
}

/**
* The configuration format for build-coupled Hugo sites.
*/
export interface HugoConfiguration extends BuildCoupledConfiguration {
collections_config?: Record<string, HugoCollectionConfig>;
data_config?: Record<string, boolean>;
}

/**
* The configuration format for build-coupled Jekyll sites.
*/
export interface JekyllConfiguration extends BuildCoupledConfiguration {
collections_config?: Record<string, BuildCoupledCollectionConfig>;
data_config?: Record<string, boolean>;
}

/**
* The configuration format for build-coupled Eleventy sites.
*/
export type EleventyConfiguration = JekyllConfiguration;

export type ParsedDataset =
| string[]
| Record<string, string>
| Record<string, Record<string, any>>
| Record<string, any>[];

interface ParsedCollectionItem {
[index: string]: any;
/**
* The path to the file this was parsed from.
*/
path: 'string';
/**
* The collection key this is assigned to. Matches keys in `collections_config`.
*/
collection: 'string';
/**
* The URL this file is served at once built.
*/
url?: 'string';
}

interface WithIntegrationOutput {
/**
* The error code encountered when attempting to create the integration output file.
*/
error?: 'NO_CONTENT' | string;
/**
* The time this file was generated.
*/
time?: string;
/**
* The schema version of the integration output file.
*
* @deprecated No longer used.
*/
version?: string; // This refers to an old schema, replaced by the IntegrationOutput type.
/**
* Details about the integration tool used to generate the integration output file.
*/
cloudcannon?: {
/**
* Name of the integration tool used to generate the integration output file.
*/
name: string;
/**
* Version of the integration tool used to generate the integration output file.
*/
version: string;
};
/**
* Map of data keys to parsed datasets. Keys match keys in `data_config`.
*/
data?: Record<string, ParsedDataset>;
/**
* Map of collection keys to parsed collection files. Keys match keys in `collections_config`.
*/
collections?: Record<string, ParsedCollectionItem>;
/**
* Map of build file paths to MD5s.
*/
files?: Record<string, string>;
}

/**
* The output from build-coupled non-Jekyll/Hugo/Eleventy sites.
*/
export interface IntegrationOutput extends Configuration, WithIntegrationOutput {}

/**
* The output from build-coupled Hugo sites.
*/
export interface HugoIntegrationOutput extends HugoConfiguration, WithIntegrationOutput {}

/**
* The output from build-coupled Jekyll sites.
*/
export interface JekyllIntegrationOutput extends JekyllConfiguration, WithIntegrationOutput {
/**
* @deprecated Do not use.
*/
defaults: any;
}

/**
* The output from build-coupled Eleventy sites.
*/
export interface EleventyIntegrationOutput extends EleventyConfiguration, WithIntegrationOutput {}
Loading

0 comments on commit ec0c4a0

Please sign in to comment.