gscan 4.37.6 → 4.38.0
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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const Promise = require('bluebird');
|
|
2
1
|
const _ = require('lodash');
|
|
3
2
|
const requireDir = require('require-dir');
|
|
4
3
|
const debug = require('@tryghost/debug')('checker');
|
|
@@ -50,12 +49,12 @@ const check = function checkAll(themePath, options = {}) {
|
|
|
50
49
|
// set the major version to check
|
|
51
50
|
theme.checkedVersion = versions[version].major;
|
|
52
51
|
|
|
53
|
-
return Promise.
|
|
52
|
+
return Promise.all(_.values(checks).map(async (checkFunction) => {
|
|
54
53
|
const now = Date.now();
|
|
55
|
-
const result = await checkFunction(
|
|
54
|
+
const result = await checkFunction(theme, options, themePath);
|
|
56
55
|
debug(checkFunction.name, 'took', Date.now() - now, 'ms');
|
|
57
56
|
return result;
|
|
58
|
-
}
|
|
57
|
+
})).then(() => theme);
|
|
59
58
|
})
|
|
60
59
|
.catch((error) => {
|
|
61
60
|
throw new errors.ValidationError({
|
package/lib/read-theme.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
|
-
const Promise = require('bluebird');
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
const os = require('os');
|
|
5
4
|
const path = require('path');
|
|
@@ -39,35 +38,43 @@ const readThemeStructure = function readThemeFiles(themePath, subPath, arr) {
|
|
|
39
38
|
};
|
|
40
39
|
|
|
41
40
|
return fs.readdir(themePath, {withFileTypes: true}).then(function (files) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
let result = arr;
|
|
42
|
+
|
|
43
|
+
return files.reduce(function (promise, dirent) {
|
|
44
|
+
return promise.then(function () {
|
|
45
|
+
const file = dirent.name;
|
|
46
|
+
const extMatch = file.match(/.*?(\.[0-9a-z]+$)/i);
|
|
47
|
+
const subFilePath = path.join(subPath, file);
|
|
48
|
+
const newPath = path.join(themePath, file);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* don't process ignored paths, remove target file
|
|
52
|
+
*
|
|
53
|
+
* @TODO:
|
|
54
|
+
* - gscan extracts the target zip into a tmp directory
|
|
55
|
+
* - if you use gscan with `keepExtractedDir` the caller (Ghost) will use the tmp folder with the deleted ignore files
|
|
56
|
+
* - what we don't support right now is to delete the ignore files from the zip
|
|
57
|
+
*/
|
|
58
|
+
if (ignore.indexOf(file) > -1) {
|
|
59
|
+
return inTmp
|
|
60
|
+
? fs.remove(newPath)
|
|
61
|
+
.then(function () {
|
|
62
|
+
return result;
|
|
63
|
+
})
|
|
64
|
+
: Promise.resolve(result);
|
|
65
|
+
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
if (dirent.isDirectory()) {
|
|
68
|
+
return readThemeStructure(newPath, subFilePath, result)
|
|
69
|
+
.then((updatedResult) => {
|
|
70
|
+
result = updatedResult;
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
result = makeResult(result, subFilePath, extMatch !== null ? extMatch[1] : undefined, dirent.isSymbolicLink());
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, Promise.resolve()).then(() => result);
|
|
71
78
|
});
|
|
72
79
|
};
|
|
73
80
|
|
|
@@ -89,9 +96,8 @@ const readFiles = function readFiles(theme) {
|
|
|
89
96
|
// Setup the helper object
|
|
90
97
|
theme.helpers = {};
|
|
91
98
|
|
|
92
|
-
// CASE: we need the actual content of all css, hbs files, and package.json for
|
|
93
|
-
|
|
94
|
-
return Promise.map(themeFilesContent, function (themeFile) {
|
|
99
|
+
// CASE: we need the actual content of all css, hbs files, and package.json for our checks
|
|
100
|
+
return Promise.all(themeFilesContent.map((themeFile) => {
|
|
95
101
|
return fs.readFile(path.join(theme.path, themeFile.file), 'utf8').then(function (content) {
|
|
96
102
|
themeFile.content = content;
|
|
97
103
|
|
|
@@ -119,13 +125,10 @@ const readFiles = function readFiles(theme) {
|
|
|
119
125
|
const handlebarsMatch = themeFile.file.match(/\.hbs$/);
|
|
120
126
|
if (handlebarsMatch) {
|
|
121
127
|
themeFile.parsed = ASTLinter.parse(themeFile.content, themeFile.file);
|
|
122
|
-
|
|
123
128
|
processHelpers(theme, themeFile);
|
|
124
129
|
}
|
|
125
130
|
});
|
|
126
|
-
}).then(
|
|
127
|
-
return theme;
|
|
128
|
-
});
|
|
131
|
+
})).then(() => theme);
|
|
129
132
|
};
|
|
130
133
|
|
|
131
134
|
const processHelpers = function (theme, themeFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.38.0",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -40,15 +40,14 @@
|
|
|
40
40
|
"gscan": "./bin/cli.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@sentry/node": "7.
|
|
43
|
+
"@sentry/node": "7.66.0",
|
|
44
44
|
"@tryghost/config": "0.2.18",
|
|
45
|
-
"@tryghost/debug": "0.1.
|
|
45
|
+
"@tryghost/debug": "0.1.26",
|
|
46
46
|
"@tryghost/errors": "1.2.26",
|
|
47
47
|
"@tryghost/logging": "2.4.6",
|
|
48
48
|
"@tryghost/pretty-cli": "1.2.38",
|
|
49
49
|
"@tryghost/server": "0.1.36",
|
|
50
50
|
"@tryghost/zip": "1.1.37",
|
|
51
|
-
"bluebird": "3.7.2",
|
|
52
51
|
"chalk": "4.1.2",
|
|
53
52
|
"common-tags": "1.8.2",
|
|
54
53
|
"express": "4.18.2",
|
|
Binary file
|
|
Binary file
|