Skip to content

Commit 6ff2a39

Browse files
Merge pull request #14 from stackbithq/prettier-update
Update Prettier settings
2 parents fb371e4 + 842bfeb commit 6ff2a39

File tree

11 files changed

+7802
-7941
lines changed

11 files changed

+7802
-7941
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ This repository uses [Prettier](https://prettier.io/) to standardize code format
88

99
1. Clone the repository and install the project's dependencies
1010

11-
```
12-
git clone https://github.com/stackbithq/sourcebit.git /Users/foobar/sourcebit
13-
cd /Users/foobar/sourcebit
14-
npm install
15-
```
11+
```
12+
git clone https://github.com/stackbithq/sourcebit.git /Users/foobar/sourcebit
13+
cd /Users/foobar/sourcebit
14+
npm install
15+
```
1616
1717
2. Navigate to a directory where there's a [`sourcebit.js` configuration file](https://github.com/stackbithq/sourcebit#manual-configuration) and run the Sourcebit binary
1818
19-
```
20-
cd /Users/foobar/my-project
21-
node /Users/foobar/sourcebit/bin/sourcebit.js fetch
22-
```
19+
```
20+
cd /Users/foobar/my-project
21+
node /Users/foobar/sourcebit/bin/sourcebit.js fetch
22+
```
2323
2424
## Creating a plugin
2525

README.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
99
## Table of contents
1010

11-
- [Introduction](#introduction)
12-
- [Getting started](#getting-started)
13-
- [Manual installation](#manual-installation)
14-
- [Manual configuration](#manual-configuration)
15-
- [Usage](#usage)
16-
- [As a CommonJS module](#as-a-commonjs-module)
17-
- [As a command-line tool](#as-a-command-line-tool)
18-
- [Disabling cache](#disabling-cache)
19-
- [Plugin directory](#plugin-directory)
20-
- [Source plugins](#source-plugins)
21-
- [Target plugins](#target-plugins)
22-
- [Other plugins](#other-plugins)
23-
- [Contributing](#contributing)
11+
- [Introduction](#introduction)
12+
- [Getting started](#getting-started)
13+
- [Manual installation](#manual-installation)
14+
- [Manual configuration](#manual-configuration)
15+
- [Usage](#usage)
16+
- [As a CommonJS module](#as-a-commonjs-module)
17+
- [As a command-line tool](#as-a-command-line-tool)
18+
- [Disabling cache](#disabling-cache)
19+
- [Plugin directory](#plugin-directory)
20+
- [Source plugins](#source-plugins)
21+
- [Target plugins](#target-plugins)
22+
- [Other plugins](#other-plugins)
23+
- [Contributing](#contributing)
2424

2525
## Introduction
2626

@@ -30,8 +30,8 @@ Sourcebit connects to multiple data sources, for example data in a headless CMS
3030

3131
Sourcebit works through the use of two types of plugins:
3232

33-
- _Source plugins_ are responsible for fetching data, normalizing it to a standard format, and placing the resulting entries on sets of data called _data buckets_. Subsequently, any combination of plugins may consume, transform and persist these data buckets in any way they like.
34-
- _Target plugins_ are tasked with writing data into a format and location that other programs – such as static site generators – expect. A target plugin is not required, however. This is useful for situations where the source will be called via code, such as in a site built with tools like Next.js.
33+
- _Source plugins_ are responsible for fetching data, normalizing it to a standard format, and placing the resulting entries on sets of data called _data buckets_. Subsequently, any combination of plugins may consume, transform and persist these data buckets in any way they like.
34+
- _Target plugins_ are tasked with writing data into a format and location that other programs – such as static site generators – expect. A target plugin is not required, however. This is useful for situations where the source will be called via code, such as in a site built with tools like Next.js.
3535

3636
Read more about the [anatomy of a plugin](https://github.com/stackbithq/sourcebit/wiki/Anatomy-of-a-plugin).
3737

@@ -61,21 +61,21 @@ It looks something like this:
6161

6262
```js
6363
module.exports = {
64-
plugins: [
65-
{
66-
module: require("sourcebit-some-plugin-1"),
67-
options: {
68-
pluginOption1: "foo",
69-
pluginOptino2: "bar"
70-
}
71-
},
72-
{
73-
module: require("sourcebit-some-plugin-2"),
74-
options: {
75-
pluginFunction1: (a, b) => a + b
76-
}
77-
}
78-
]
64+
plugins: [
65+
{
66+
module: require('sourcebit-some-plugin-1'),
67+
options: {
68+
pluginOption1: 'foo',
69+
pluginOptino2: 'bar'
70+
}
71+
},
72+
{
73+
module: require('sourcebit-some-plugin-2'),
74+
options: {
75+
pluginFunction1: (a, b) => a + b
76+
}
77+
}
78+
]
7979
};
8080
```
8181

@@ -88,12 +88,12 @@ It's important to note that while every plugin block is defined with the `module
8888
To use Sourcebit as a CommonJS module, include it in your project and call its `fetch` method.
8989

9090
```js
91-
const sourcebit = require("sourcebit");
92-
const config = require("./sourcebit.js");
91+
const sourcebit = require('sourcebit');
92+
const config = require('./sourcebit.js');
9393
const options = {};
9494

9595
sourcebit.fetch(config, options).then(data => {
96-
console.log(data);
96+
console.log(data);
9797
});
9898
```
9999

@@ -125,32 +125,32 @@ To disable cache, add the flag `--no-cache` to the `sourcebit fetch` command if
125125

126126
Sourcebit is designed to be completely extensible. Documentation on how to build plugins can be found on our [wiki](https://github.com/stackbithq/sourcebit/wiki).
127127

128-
- [Anatomy of a plugin](https://github.com/stackbithq/sourcebit/wiki/Anatomy-of-a-plugin)
129-
- [Configuration](https://github.com/stackbithq/sourcebit/wiki/Configuration)
130-
- [Data normalization](https://github.com/stackbithq/sourcebit/wiki/Data-normalization)
131-
- [Debugging](https://github.com/stackbithq/sourcebit/wiki/Debugging)
132-
- [Plugin API](https://github.com/stackbithq/sourcebit/wiki/Plugin-API)
133-
- [Plugin registry](https://github.com/stackbithq/sourcebit/wiki/Plugin-registry)
134-
- [Writing files to disk](https://github.com/stackbithq/sourcebit/wiki/Writing-files-to-disk)
128+
- [Anatomy of a plugin](https://github.com/stackbithq/sourcebit/wiki/Anatomy-of-a-plugin)
129+
- [Configuration](https://github.com/stackbithq/sourcebit/wiki/Configuration)
130+
- [Data normalization](https://github.com/stackbithq/sourcebit/wiki/Data-normalization)
131+
- [Debugging](https://github.com/stackbithq/sourcebit/wiki/Debugging)
132+
- [Plugin API](https://github.com/stackbithq/sourcebit/wiki/Plugin-API)
133+
- [Plugin registry](https://github.com/stackbithq/sourcebit/wiki/Plugin-registry)
134+
- [Writing files to disk](https://github.com/stackbithq/sourcebit/wiki/Writing-files-to-disk)
135135

136136
### Plugin directory
137137

138138
#### Source plugins
139139

140-
- [`sourcebit-sample-plugin`](http://npmjs.com/package/sourcebit-sample-plugin): A sample plugin with mock data, for demonstration/educational purposes.
141-
- [`sourcebit-source-contentful`](http://npmjs.com/package/sourcebit-source-contentful): A source plugin for [Contentful](https://www.contentful.com/).
142-
- [`sourcebit-source-sanity`](http://npmjs.com/package/sourcebit-source-sanity): A source plugin for [Sanity](https://sanity.io/).
143-
- [`@kentico/sourcebit-source-kontent`](https://www.npmjs.com/package/@kentico/sourcebit-source-kontent): A source plugin for [Kontent](https://bit.ly/2yvEEWs).
140+
- [`sourcebit-sample-plugin`](http://npmjs.com/package/sourcebit-sample-plugin): A sample plugin with mock data, for demonstration/educational purposes.
141+
- [`sourcebit-source-contentful`](http://npmjs.com/package/sourcebit-source-contentful): A source plugin for [Contentful](https://www.contentful.com/).
142+
- [`sourcebit-source-sanity`](http://npmjs.com/package/sourcebit-source-sanity): A source plugin for [Sanity](https://sanity.io/).
143+
- [`@kentico/sourcebit-source-kontent`](https://www.npmjs.com/package/@kentico/sourcebit-source-kontent): A source plugin for [Kontent](https://bit.ly/2yvEEWs).
144144

145145
#### Target plugins
146146

147-
- [`sourcebit-target-hugo`](http://npmjs.com/package/sourcebit-target-hugo): A target plugin for the [Hugo](https://gohugo.io/) static site generator.
148-
- [`sourcebit-target-jekyll`](http://npmjs.com/package/sourcebit-target-jekyll): A target plugin for the [Jekyll](https://www.jekyllrb.com/) static site generator.
149-
- [`sourcebit-target-next`](https://www.npmjs.com/package/sourcebit-target-next): A target plugin for the [Next.js](https://nextjs.org/) framework.
147+
- [`sourcebit-target-hugo`](http://npmjs.com/package/sourcebit-target-hugo): A target plugin for the [Hugo](https://gohugo.io/) static site generator.
148+
- [`sourcebit-target-jekyll`](http://npmjs.com/package/sourcebit-target-jekyll): A target plugin for the [Jekyll](https://www.jekyllrb.com/) static site generator.
149+
- [`sourcebit-target-next`](https://www.npmjs.com/package/sourcebit-target-next): A target plugin for the [Next.js](https://nextjs.org/) framework.
150150

151151
#### Other plugins
152152

153-
- [`sourcebit-transform-assets`](https://github.com/stackbithq/sourcebit-transform-assets): A plugin for downloading remote assets
153+
- [`sourcebit-transform-assets`](https://github.com/stackbithq/sourcebit-transform-assets): A plugin for downloading remote assets
154154

155155
## Contributing
156156

bin/sourcebit.js

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
11
#!/usr/bin/env node
2-
const commander = require("commander");
3-
const sourcebit = require("../index");
4-
const path = require("path");
5-
const pkg = require("../package.json");
2+
const commander = require('commander');
3+
const sourcebit = require('../index');
4+
const path = require('path');
5+
const pkg = require('../package.json');
66

77
commander
8-
.version(pkg.version)
9-
.command("fetch")
10-
.option("-c, --configPath", "specify the location of the configuration file")
11-
.option(
12-
"-C, --cache",
13-
"force Sourcebit to use a filesystem cache, even when `watch` is disabled"
14-
)
15-
.option("-w, --watch", "run continuously in watch mode")
16-
.option("-q, --quiet", "disable logging messages to the console")
17-
.action(({ cache, configPath: customConfigPath, quiet, watch }) => {
18-
const configPath = path.resolve(
19-
process.cwd(),
20-
customConfigPath || "sourcebit.js"
21-
);
22-
const config = require(configPath);
23-
const runtimeParameters = {
24-
cache,
25-
quiet,
26-
watch
27-
};
8+
.version(pkg.version)
9+
.command('fetch')
10+
.option('-c, --configPath', 'specify the location of the configuration file')
11+
.option('-C, --cache', 'force Sourcebit to use a filesystem cache, even when `watch` is disabled')
12+
.option('-w, --watch', 'run continuously in watch mode')
13+
.option('-q, --quiet', 'disable logging messages to the console')
14+
.action(({ cache, configPath: customConfigPath, quiet, watch }) => {
15+
const configPath = path.resolve(process.cwd(), customConfigPath || 'sourcebit.js');
16+
const config = require(configPath);
17+
const runtimeParameters = {
18+
cache,
19+
quiet,
20+
watch
21+
};
2822

29-
sourcebit.fetch(config, runtimeParameters);
30-
});
23+
sourcebit.fetch(config, runtimeParameters);
24+
});
3125

32-
commander.on("command:*", () => {
33-
console.error(
34-
"Invalid command: %s\nSee --help for a list of available commands.",
35-
commander.args.join(" ")
36-
);
26+
commander.on('command:*', () => {
27+
console.error('Invalid command: %s\nSee --help for a list of available commands.', commander.args.join(' '));
3728

38-
process.exit(1);
29+
process.exit(1);
3930
});
4031

4132
commander.parse(process.argv);

index.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
require("dotenv").config();
2-
const Sourcebit = require("./lib/sourcebit");
1+
require('dotenv').config();
2+
const Sourcebit = require('./lib/sourcebit');
33

44
module.exports.fetch = (config, runtimeParameters, transformCallback) => {
5-
if (!config) {
6-
throw new Error(
7-
"ERROR: Could not find a valid `sourcebit.js` configuration file."
8-
);
9-
}
5+
if (!config) {
6+
throw new Error('ERROR: Could not find a valid `sourcebit.js` configuration file.');
7+
}
108

11-
if (typeof runtimeParameters === "function") {
12-
transformCallback = runtimeParameters;
13-
runtimeParameters = {};
14-
}
9+
if (typeof runtimeParameters === 'function') {
10+
transformCallback = runtimeParameters;
11+
runtimeParameters = {};
12+
}
1513

16-
const instance = new Sourcebit({ runtimeParameters, transformCallback });
17-
const { plugins = [] } = config;
14+
const instance = new Sourcebit({ runtimeParameters, transformCallback });
15+
const { plugins = [] } = config;
1816

19-
instance.loadPlugins(plugins);
17+
instance.loadPlugins(plugins);
2018

21-
const transformData = instance
22-
.bootstrapAll()
23-
.then(() => instance.transform());
19+
const transformData = instance.bootstrapAll().then(() => instance.transform());
2420

25-
if (typeof transformCallback !== "function") {
26-
return transformData;
27-
}
21+
if (typeof transformCallback !== 'function') {
22+
return transformData;
23+
}
2824
};
2925

3026
module.exports.Sourcebit = Sourcebit;

0 commit comments

Comments
 (0)