Skip to content

Commit 9db55c3

Browse files
authored
Upgrade to work with spike@next (#7)
* upgrade to work with spike@next * 0.4.0-0 * update deps
1 parent c37ed52 commit 9db55c3

File tree

5 files changed

+1519
-1149
lines changed

5 files changed

+1519
-1149
lines changed

lib/index.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,28 @@ class SpikeCollections {
4949
cwd: compiler.options.context,
5050
nodir: true,
5151
realpath: true,
52-
ignore: compiler.options.spike.ignore
52+
ignore: this.util.getSpikeOptions().ignore
5353
})
5454
})
5555

56+
// all files as a straight array, no categories
57+
this.allFiles = reduce(this.files, (m, v) => m.push(...v) && m, [])
58+
59+
// add loader alias so that frontmatter loader can be resolved
60+
const resolveLoader = compiler.options.resolveLoader
61+
if (!resolveLoader.alias) resolveLoader.alias = {}
62+
resolveLoader.alias.frontmatter = path.join(__dirname, 'frontmatter_loader.js')
63+
64+
// add frontmatter loader with pattern converted to regex
65+
compiler.options.module.rules.push({
66+
test: this.util.pathsToRegex(this.allFiles),
67+
use: [{
68+
loader: 'frontmatter',
69+
// NOTE: this *could* be configurable
70+
options: { _spikeExtension: 'html' }
71+
}]
72+
})
73+
5674
// add each of the files to webpack's pipeline
5775
compiler.plugin('make', this.addCollectionFiles.bind(this, compiler))
5876

@@ -74,7 +92,7 @@ class SpikeCollections {
7492
compiler.plugin('emit', (compilation, cb) => {
7593
// modify output if permalinks dictates
7694
// potentially create folders if needed
77-
compiler.options.spike.files.process.map((f) => {
95+
this.util.getSpikeOptions().files.process.map((f) => {
7896
const matchedFile = this._modifiedOutputs.find((x) => x.path === f.path)
7997
if (matchedFile) {
8098
this.util.modifyOutputPath(f.path, matchedFile.out)
@@ -87,20 +105,7 @@ class SpikeCollections {
87105

88106
addCollectionFiles (compiler, compilation, done) {
89107
// add each collection file to the pipeline
90-
const allFiles = reduce(this.files, (m, v) => m.push(...v) && m, [])
91-
const fileAdd = this.util.addFilesAsWebpackEntries(compilation, allFiles)
92-
93-
// add loader alias so that frontmatter loader can be resolved
94-
const resolveLoader = compiler.options.resolveLoader
95-
if (!resolveLoader.alias) resolveLoader.alias = {}
96-
resolveLoader.alias.frontmatter = path.join(__dirname, 'frontmatter_loader.js')
97-
98-
// add frontmatter loader with pattern converted to regex
99-
compiler.options.module.loaders.push({
100-
test: this.util.pathsToRegex(allFiles),
101-
loader: 'frontmatter', // NOTE: this *could* be configurable
102-
extension: 'html'
103-
})
108+
const fileAdd = this.util.addFilesAsWebpackEntries(compilation, this.allFiles)
104109

105110
// We need to read the front matter out of each of these files so that it
106111
// can be made available to any other view.
@@ -218,7 +223,7 @@ class SpikeCollections {
218223
// Go through each of the pagination pages and write it out
219224
return keys.map(this._pagination, (pages, _) => {
220225
return keys.map(pages, (opts, p) => {
221-
const reshapeOpts = loader.parseOptions.call(opts.loaderContext, compiler.options.reshape, {})
226+
const reshapeOpts = loader.parseOptions.call(opts.loaderContext, this.util.getSpikeOptions().reshape, {})
222227
return reshape(reshapeOpts)
223228
.process(tpl)
224229
.then(((locals, res) => {

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"name": "spike-collections",
33
"description": "jekyll-esque features for spike",
4-
"version": "0.3.0",
4+
"version": "0.4.0-0",
55
"author": "Jeff Escalante",
66
"ava": {
77
"verbose": "true"
88
},
99
"bugs": "https://github.com/static-dev/spike-collections/issues",
1010
"devDependencies": {
1111
"ava": "^0.19.0",
12-
"coveralls": "^2.11.14",
13-
"nyc": "^10.1.2",
14-
"reshape-standard": "^0.5.0",
15-
"rimraf": "^2.5.4",
12+
"coveralls": "^2.13.0",
13+
"nyc": "^10.2.0",
14+
"reshape-standard": "^1.0.0",
15+
"rimraf": "^2.6.1",
1616
"snazzy": "^6.0.0",
1717
"source-loader": "^0.2.0",
18-
"spike-core": "^0.13.3",
18+
"spike-core": "^1.0.0",
1919
"standard": "^10.0.0",
20-
"webpack": "^1.13.2"
20+
"webpack": "^2.3.3"
2121
},
2222
"engines": {
2323
"node": ">= 6"
@@ -36,13 +36,13 @@
3636
"es6bindall": "^0.0.9",
3737
"filewrap": "^0.1.0",
3838
"glob": "^7.1.0",
39-
"joi": "^10.2.0",
40-
"js-yaml": "^3.6.1",
39+
"joi": "^10.4.1",
40+
"js-yaml": "^3.8.3",
4141
"lodash.bindall": "^4.4.0",
4242
"objectfn": "^2.0.0",
4343
"reshape": "^0.4.1",
44-
"reshape-loader": "^0.4.2",
45-
"spike-util": "^0.4.0",
46-
"when": "^3.7.7"
44+
"reshape-loader": "^1.0.0",
45+
"spike-util": "^1.0.0",
46+
"when": "^3.7.8"
4747
}
4848
}
Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,83 @@
11
/******/ (function(modules) { // webpackBootstrap
22
/******/ // The module cache
33
/******/ var installedModules = {};
4-
4+
/******/
55
/******/ // The require function
66
/******/ function __webpack_require__(moduleId) {
7-
7+
/******/
88
/******/ // Check if module is in cache
99
/******/ if(installedModules[moduleId])
1010
/******/ return installedModules[moduleId].exports;
11-
11+
/******/
1212
/******/ // Create a new module (and put it into the cache)
1313
/******/ var module = installedModules[moduleId] = {
14-
/******/ exports: {},
15-
/******/ id: moduleId,
16-
/******/ loaded: false
14+
/******/ i: moduleId,
15+
/******/ l: false,
16+
/******/ exports: {}
1717
/******/ };
18-
18+
/******/
1919
/******/ // Execute the module function
2020
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21-
21+
/******/
2222
/******/ // Flag the module as loaded
23-
/******/ module.loaded = true;
24-
23+
/******/ module.l = true;
24+
/******/
2525
/******/ // Return the exports of the module
2626
/******/ return module.exports;
2727
/******/ }
28-
29-
28+
/******/
29+
/******/
3030
/******/ // expose the modules object (__webpack_modules__)
3131
/******/ __webpack_require__.m = modules;
32-
32+
/******/
3333
/******/ // expose the module cache
3434
/******/ __webpack_require__.c = installedModules;
35-
35+
/******/
36+
/******/ // identity function for calling harmony imports with the correct context
37+
/******/ __webpack_require__.i = function(value) { return value; };
38+
/******/
39+
/******/ // define getter function for harmony exports
40+
/******/ __webpack_require__.d = function(exports, name, getter) {
41+
/******/ if(!__webpack_require__.o(exports, name)) {
42+
/******/ Object.defineProperty(exports, name, {
43+
/******/ configurable: false,
44+
/******/ enumerable: true,
45+
/******/ get: getter
46+
/******/ });
47+
/******/ }
48+
/******/ };
49+
/******/
50+
/******/ // getDefaultExport function for compatibility with non-harmony modules
51+
/******/ __webpack_require__.n = function(module) {
52+
/******/ var getter = module && module.__esModule ?
53+
/******/ function getDefault() { return module['default']; } :
54+
/******/ function getModuleExports() { return module; };
55+
/******/ __webpack_require__.d(getter, 'a', getter);
56+
/******/ return getter;
57+
/******/ };
58+
/******/
59+
/******/ // Object.prototype.hasOwnProperty.call
60+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
61+
/******/
3662
/******/ // __webpack_public_path__
3763
/******/ __webpack_require__.p = "";
38-
64+
/******/
3965
/******/ // Load entry module and return exports
40-
/******/ return __webpack_require__(0);
66+
/******/ return __webpack_require__(__webpack_require__.s = 1);
4167
/******/ })
4268
/************************************************************************/
4369
/******/ ([
4470
/* 0 */
45-
/***/ function(module, exports, __webpack_require__) {
46-
47-
__webpack_require__(1)
71+
/***/ (function(module, exports) {
4872

73+
module.exports = "hello there!\n"
4974

50-
/***/ },
75+
/***/ }),
5176
/* 1 */
52-
/***/ function(module, exports) {
77+
/***/ (function(module, exports, __webpack_require__) {
78+
79+
__webpack_require__(0)
5380

54-
module.exports = "hello there!\n"
5581

56-
/***/ }
82+
/***/ })
5783
/******/ ]);

test/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,12 @@ function spikeCompile (t, root, locals, options, cb) {
215215
const proj = new Spike({
216216
root,
217217
ignore: ['**/_*'],
218-
reshape: (ctx) => {
219-
return htmlStandards({
220-
parser: false,
221-
webpack: ctx,
222-
locals: collections.locals(ctx, locals)
223-
})
224-
},
218+
reshape: htmlStandards({
219+
parser: false,
220+
locals: (ctx) => {
221+
return collections.locals(ctx, locals)
222+
}
223+
}),
225224
plugins: [collections]
226225
})
227226

0 commit comments

Comments
 (0)