-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #759 [ci skip]
- Loading branch information
Showing
3 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const errors = require('../errors'); | ||
|
||
module.exports = function majorSupport(options = {}) { | ||
const path = require('path'); | ||
|
||
if (!options.dir) { | ||
return Promise.reject(new errors.CliError({ | ||
message: '`dir` is required.' | ||
})) | ||
} | ||
|
||
if (!options.database) { | ||
return Promise.reject(new errors.CliError({ | ||
message: '`database` is required.' | ||
})) | ||
} | ||
|
||
const knexPath = options.knexPath || path.resolve(options.dir, 'current/node_modules/knex'); | ||
const gscanPath = options.gscanPath || path.resolve(options.dir, 'current/node_modules/gscan'); | ||
|
||
const knex = require(knexPath); | ||
const gscan = require(gscanPath); | ||
|
||
const connection = knex(Object.assign({useNullAsDefault: true}, options.database)); | ||
|
||
const themeFolder = options.contentPath || path.resolve(options.dir, 'content', 'themes'); | ||
let activeTheme; | ||
let gscanReport; | ||
|
||
return connection.raw('SELECT * FROM settings WHERE `key`="active_theme";') | ||
.then((response) => { | ||
activeTheme = response[0].value; | ||
|
||
return gscan.check(path.resolve(themeFolder, activeTheme)); | ||
}) | ||
.then((report) => { | ||
gscanReport = gscan.format(report); | ||
|
||
return connection.raw('SELECT uuid FROM posts WHERE slug="v2-demo-post";') | ||
}) | ||
.then((demoPost) => { | ||
if (demoPost.length) { | ||
demoPost = demoPost[0]; | ||
} | ||
|
||
return { | ||
gscanReport: gscanReport, | ||
demoPost: demoPost | ||
} | ||
}) | ||
.finally(() => { | ||
return new Promise((resolve) => { | ||
connection.destroy(() => { | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}; |