Comparing version 0.4.0 to 0.5.0
@@ -26,74 +26,2 @@ # Contributing guidelines | ||
If you want to create your own plugin, be sure to check our [sample plugin](https://github.com/stackbithq/sourcebit-sample-plugin), which includes a fully-annotated source to explain all the methods that you can implement, their arguments and the expected return values. | ||
### Adding plugin to registry | ||
If you'd like your plugin to appear as an option within the [interactive setup process](https://github.com/stackbithq/create-sourcebit), you'll need to add your plugin to [`plugins.json`](https://github.com/stackbithq/create-sourcebit/blob/master/plugins.json) (including all the properties described [here](https://github.com/stackbithq/create-sourcebit#plugin-registry)) and submit a pull request. | ||
### Conventions for source plugins | ||
Source plugins are expected to add data to two specific data buckets. | ||
#### `models` | ||
Products like content management systems typically have the concept of models or content types. Source plugins are expected to add information about these models to the `models` data bucket, as objects with the following properties: | ||
| Property | Type | Description | Example | | ||
| -------------------- | ------ | ----------------------------------------------------------- | ----------------------------- | | ||
| `source` | String | The name of the source plugin as used in its `package.json` | `sourcebit-source-contentful` | | ||
| `modelName` | String | The ID or machine-friendly name of the model | `blog` | | ||
| `modelLabel` | String | The human-friendly name of the model | `Blog Posts` | | ||
| `projectId` | String | The ID of the project within the source platform | Contentful space ID | | ||
| `projectEnvironment` | String | The environment within the source platform | Contentful space environment | | ||
#### `objects` | ||
The `objects` data bucket contains all entries coming from the various data sources. Source plugins must normalize all entries before adding them to the data bucket. This normalization consists of adding a property called `__metadata`, containing an object with the following properties: | ||
| Property | Type | Description | Example | | ||
| -------------------- | ------ | ----------------------------------------------------------- | ----------------------------- | | ||
| `source` | String | The name of the source plugin as used in its `package.json` | `sourcebit-source-contentful` | | ||
| `modelName` | String | The ID or machine-friendly name of the model | `blog` | | ||
| `modelLabel` | String | The human-friendly name of the model | `Blog Posts` | | ||
| `projectId` | String | The ID of the project within the source platform | Contentful space ID | | ||
| `projectEnvironment` | String | The environment within the source platform | Contentful space environment | | ||
| `createdAt` | String | The ISO 8601 representation of the entry's creation date | `2011-10-05T14:48:00.000Z` | | ||
| `updatedAt` | String | The ISO 8601 representation of the entry's last update date | `2011-10-05T15:30:00.000Z` | | ||
Additionally, all content fields should be placed at the root level of the entry object with the ID field named `id`. | ||
- 🚫 | ||
```json | ||
{ | ||
"type": "blog", | ||
"meta": { | ||
"_id": "123456789", | ||
"created_at": "2011-10-05T14:48:00.000Z", | ||
"updated_at": "2011-10-05T15:30:00.000Z" | ||
}, | ||
"fields": { | ||
"title": "Normalizing entries", | ||
"subtitle": "Because normal is good" | ||
} | ||
} | ||
``` | ||
- ✅ | ||
```json | ||
{ | ||
"id": "123456789", | ||
"title": "Normalizing entries", | ||
"subtitle": "Because normal is good", | ||
"__metadata": { | ||
"source": "source-source-contentful", | ||
"modelName": "blog", | ||
"modelLabel": "Blog posts", | ||
"projectId": "1q2w3e4r", | ||
"projectEnvironment": "master", | ||
"createdAt": "2011-10-05T14:48:00.000Z", | ||
"updatedAt": "2011-10-05T15:30:00.000Z" | ||
} | ||
} | ||
``` | ||
If you want to create your own plugin, be sure to check our [sample plugin](https://github.com/stackbithq/sourcebit-sample-plugin) and the [documentation wiki](https://github.com/stackbithq/sourcebit/wiki). |
@@ -80,3 +80,3 @@ const debug = require("debug"); | ||
getNameOfPluginAtIndex(index) { | ||
return this.pluginModules[index].name || `plugin_${index}`; | ||
return this.pluginModules[index].name || `plugin-${index}`; | ||
} | ||
@@ -98,3 +98,4 @@ | ||
plugins.forEach((plugin, index) => { | ||
this.pluginModules[index] = plugin.module; | ||
this.pluginModules[index] = | ||
typeof plugin === "function" ? { transform: plugin } : plugin.module; | ||
}); | ||
@@ -101,0 +102,0 @@ } |
{ | ||
"name": "sourcebit", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Sourcebit helps developers build data-driven JAMstack sites by pulling data from any third-party resource", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,17 @@ <img alt="Sourcebit logo" src="https://raw.githubusercontent.com/stackbithq/sourcebit/master/Sourcebit.svg?sanitize=true" width="300"> | ||
## Table of contents | ||
- [Introduction](#introduction) | ||
- [Getting started](#getting-started) | ||
- [Manual installation](#manual-installation) | ||
- [Manual configuration](#manual-configuration) | ||
- [Usage](#usage) | ||
- [As a CommonJS module](#as-a-commonjs-module) | ||
- [As a command-line tool](#as-a-command-line-tool) | ||
- [Disabling cache](#disabling-cache) | ||
- [Plugin directory](#plugin-directory) | ||
- [Source plugins](#source-plugins) | ||
- [Target plugins](#target-plugins) | ||
- [Contributing](#contributing) | ||
## Introduction | ||
@@ -19,41 +34,6 @@ | ||
``` | ||
+----------------+ +---------------+ +-----------------+ | ||
| | | | | | | ||
| Contentful | | DatoCMS | | Airtable | | ||
| | | | | | | ||
+--------\-------+ +-------|-------+ +--------/--------+ | ||
\ | / | ||
\ | / | ||
\ | / | ||
\ | / | ||
+--------------|-------------|--------------|-------------+ | ||
| | | | | | ||
| +-----|-----+ +-----------+ +-----|-----+ | | ||
S | | (Plugin) | | (Plugin) | | (Plugin) | | S | ||
O | | | | | | | | O | ||
U | +-----|-----+ +-----|-----+ +-----|-----+ | U | ||
R | | | | | R | ||
C | | | | | C | ||
E | +-----|-----+ +-----|-----+ +-----|-----+ | E | ||
B | | (Plugin) | | (Plugin) | | (Plugin) | | B | ||
I | | | | | | | | I | ||
T | +-----|-----+ +-----|-----+ +-----|-----+ | T | ||
| | | | | | ||
+--------------|-------------|--------------|-------------+ | ||
/ | \ | ||
/ | \ | ||
/ | \ | ||
/ | \ | ||
/ | \ | ||
+--------/--------+ +--------|-------+ +----------------+ | ||
| | | | | | | ||
| Next.js | | Jekyll | | Hugo | | ||
| | | | | | | ||
+-----------------+ +----------------+ +----------------+ | ||
[![Diagram of data flow between plugins](https://user-images.githubusercontent.com/4162329/73833982-ccb88280-4802-11ea-8320-10538296e33b.png)](https://user-images.githubusercontent.com/4162329/73833982-ccb88280-4802-11ea-8320-10538296e33b.png) | ||
``` | ||
## Getting started | ||
## Getting Started | ||
To ease the process of configuring Sourcebit, we've created a command-line tool that provides an interactive setup process that will install the project and any necessary plugins. It asks a series of questions defined by each plugin and generates the necessary configuration file (`sourcebit.js`) so that you can get up and running in no time. | ||
@@ -63,3 +43,3 @@ | ||
### Manual Installation | ||
### Manual installation | ||
@@ -72,3 +52,3 @@ Sourcebit is distributed as an [npm module](https://www.npmjs.com/package/sourcebit). We recommend using the interactive setup process, but if you would like to manually install it and add it as a dependency to your project, run: | ||
### Manual Configuration | ||
### Manual configuration | ||
@@ -141,3 +121,3 @@ The interactive setup process will generate the necessary configuration for you. Manual configuration can be useful in scenarios where you need to customize the existing behavior generated by the setup process or if you are creating a specific configuration that the setup process does not yet support. | ||
## Plugins | ||
## Plugin directory | ||
@@ -144,0 +124,0 @@ ### Source plugins |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274
18985
131