gscan 4.9.0 → 4.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/checker.js
CHANGED
|
@@ -41,7 +41,7 @@ const checker = function checkAll(themePath, options = {}) {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
return readTheme(themePath
|
|
44
|
+
return readTheme(themePath)
|
|
45
45
|
.then(function (theme) {
|
|
46
46
|
// set the major version to check
|
|
47
47
|
theme.checkedVersion = versions[version].major;
|
|
@@ -4,6 +4,12 @@ const {versions, normalizePath} = require('../utils');
|
|
|
4
4
|
const ASTLinter = require('../ast-linter');
|
|
5
5
|
|
|
6
6
|
function processFileFunction(files, failures, rules) {
|
|
7
|
+
// This rule is needed to find partials
|
|
8
|
+
// Partials are needed for a full parsing
|
|
9
|
+
if (!rules['mark-used-partials']) {
|
|
10
|
+
rules['mark-used-partials'] = require(`../ast-linter/rules/mark-used-partials`);
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
return function processFile(linter, themeFile) {
|
|
8
14
|
if (themeFile.parsed.error) {
|
|
9
15
|
// Ignore parsing errors, they are handled in 005
|
|
@@ -74,6 +74,12 @@ function applyRule(rule, theme) {
|
|
|
74
74
|
function parseWithAST({theme, log, file, rules, callback}){
|
|
75
75
|
const linter = new ASTLinter();
|
|
76
76
|
|
|
77
|
+
// This rule is needed to find partials
|
|
78
|
+
// Partials are needed for a full parsing
|
|
79
|
+
if (!rules['mark-used-partials']) {
|
|
80
|
+
rules['mark-used-partials'] = require(`../ast-linter/rules/mark-used-partials`);
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
function processFile(themeFile) {
|
|
78
84
|
if (themeFile.parsed.error) {
|
|
79
85
|
// Ignore parsing errors, they are handled in 005
|
|
@@ -110,15 +116,8 @@ function parseWithAST({theme, log, file, rules, callback}){
|
|
|
110
116
|
|
|
111
117
|
const ruleImplementations = {
|
|
112
118
|
'GS100-NO-UNUSED-CUSTOM-THEME-SETTING': {
|
|
113
|
-
isEnabled: ({theme
|
|
114
|
-
|
|
115
|
-
if (packageJSON && packageJSON.content) {
|
|
116
|
-
let packageJSONParsed = JSON.parse(packageJSON.content);
|
|
117
|
-
if (packageJSONParsed.config && packageJSONParsed.config.custom) {
|
|
118
|
-
result.customThemeSettingsConfig = packageJSONParsed.config.custom;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return !!result.customThemeSettingsConfig;
|
|
119
|
+
isEnabled: ({theme}) => {
|
|
120
|
+
return !!theme.customSettings;
|
|
122
121
|
},
|
|
123
122
|
init: ({result}) => {
|
|
124
123
|
result.customThemeSettings = new Set();
|
|
@@ -136,8 +135,8 @@ const ruleImplementations = {
|
|
|
136
135
|
}});
|
|
137
136
|
}
|
|
138
137
|
},
|
|
139
|
-
done: ({log, result}) => {
|
|
140
|
-
const config = Object.keys(
|
|
138
|
+
done: ({log, theme, result}) => {
|
|
139
|
+
const config = Object.keys(theme.customSettings);
|
|
141
140
|
const notUsedVariable = config.filter(x => !result.customThemeSettings.has(x));
|
|
142
141
|
|
|
143
142
|
if (notUsedVariable.length > 0) {
|
package/lib/read-theme.js
CHANGED
|
@@ -75,11 +75,9 @@ const readThemeStructure = function readThemeFiles(themePath, subPath, arr) {
|
|
|
75
75
|
/**
|
|
76
76
|
*
|
|
77
77
|
* @param {Theme} theme
|
|
78
|
-
* @param {Object} options
|
|
79
|
-
* @param {Object=} [options.labs] object containing boolean flags for enabled labs features
|
|
80
78
|
* @returns {Promise<Theme>}
|
|
81
79
|
*/
|
|
82
|
-
const readFiles = function readFiles(theme
|
|
80
|
+
const readFiles = function readFiles(theme) {
|
|
83
81
|
const themeFilesContent = _.filter(theme.files, function (themeFile) {
|
|
84
82
|
if (themeFile && themeFile.ext) {
|
|
85
83
|
return themeFile.ext.match(/\.hbs|\.css|\.js/ig) || themeFile.file.match(/package.json/i);
|
|
@@ -98,17 +96,19 @@ const readFiles = function readFiles(theme, options = {}) {
|
|
|
98
96
|
return fs.readFile(path.join(theme.path, themeFile.file), 'utf8').then(function (content) {
|
|
99
97
|
themeFile.content = content;
|
|
100
98
|
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
99
|
+
if (!theme.customSettings) {
|
|
100
|
+
theme.customSettings = {};
|
|
101
|
+
}
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
const packageJsonMatch = themeFile.file === 'package.json';
|
|
104
|
+
if (packageJsonMatch) {
|
|
105
|
+
try {
|
|
108
106
|
const packageJson = JSON.parse(themeFile.content);
|
|
109
|
-
if (packageJson.config.custom) {
|
|
107
|
+
if (packageJson.config && packageJson.config.custom) {
|
|
110
108
|
theme.customSettings = packageJson.config.custom;
|
|
111
109
|
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
// Ignore error as they will be caught in 010-package-json.js
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -230,11 +230,9 @@ const extractTemplates = function extractTemplates(allFiles) {
|
|
|
230
230
|
/**
|
|
231
231
|
*
|
|
232
232
|
* @param {string} themePath - path to the validated theme
|
|
233
|
-
* @param {Object} options
|
|
234
|
-
* @param {Object=} [options.labs] object containing boolean flags for enabled labs features
|
|
235
233
|
* @returns {Promise<Theme>}
|
|
236
234
|
*/
|
|
237
|
-
module.exports = function readTheme(themePath
|
|
235
|
+
module.exports = function readTheme(themePath) {
|
|
238
236
|
return readThemeStructure(themePath)
|
|
239
237
|
.then(function (themeFiles) {
|
|
240
238
|
var allTemplates = extractTemplates(themeFiles);
|
|
@@ -252,7 +250,7 @@ module.exports = function readTheme(themePath, options = {}) {
|
|
|
252
250
|
pass: [],
|
|
253
251
|
fail: {}
|
|
254
252
|
}
|
|
255
|
-
}
|
|
253
|
+
});
|
|
256
254
|
});
|
|
257
255
|
};
|
|
258
256
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.4",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@sentry/node": "6.13.3",
|
|
44
|
-
"@tryghost/pretty-cli": "1.2.
|
|
45
|
-
"@tryghost/zip": "1.1.
|
|
44
|
+
"@tryghost/pretty-cli": "1.2.22",
|
|
45
|
+
"@tryghost/zip": "1.1.18",
|
|
46
46
|
"bluebird": "3.7.2",
|
|
47
47
|
"chalk": "4.1.2",
|
|
48
48
|
"common-tags": "1.8.0",
|