gscan 4.37.5 → 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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/checker.js +3 -4
- package/lib/checks/010-package-json.js +4 -4
- package/lib/checks/110-page-builder-usage.js +2 -1
- package/lib/read-theme.js +39 -36
- package/lib/read-zip.js +0 -1
- package/lib/specs/canary.js +4 -4
- package/lib/specs/v4.js +1 -1
- package/package.json +10 -11
- package/app/uploads/6caebb4b217a1ac54be19902abae7cbb +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -115,4 +115,4 @@ gscan.checkZip({
|
|
|
115
115
|
|
|
116
116
|
# Copyright & License
|
|
117
117
|
|
|
118
|
-
Copyright (c) 2013-
|
|
118
|
+
Copyright (c) 2013-2023 Ghost Foundation - Released under the [MIT license](LICENSE). Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our [trademark policy](https://ghost.org/trademark/) for info on acceptable usage.
|
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({
|
|
@@ -44,8 +44,8 @@ const v4PackageJSONValidationRules = _.extend({},
|
|
|
44
44
|
{isPresentEngineGhostAPI: 'GS010-PJ-GHOST-API-PRESENT'},
|
|
45
45
|
{hasTooManyCustomThemeSettings: 'GS010-PJ-CUST-THEME-TOTAL-SETTINGS'},
|
|
46
46
|
{customThemeSettingsMustBeSnakecased: 'GS010-PJ-CUST-THEME-SETTINGS-CASE'},
|
|
47
|
-
{
|
|
48
|
-
{
|
|
47
|
+
{unknownCustomThemeSettingsType: 'GS010-PJ-CUST-THEME-SETTINGS-TYPE'},
|
|
48
|
+
{unknownCustomThemeSettingsGroup: 'GS010-PJ-CUST-THEME-SETTINGS-GROUP'},
|
|
49
49
|
{missingCustomThemeSettingsSelectOptions: 'GS010-PJ-CUST-THEME-SETTINGS-SELECT-OPTIONS'},
|
|
50
50
|
{missingCustomThemeSettingsSelectDefault: 'GS010-PJ-CUST-THEME-SETTINGS-SELECT-DEFAULT'},
|
|
51
51
|
{invalidCustomThemeSetingBooleanDefault: 'GS010-PJ-CUST-THEME-SETTINGS-BOOLEAN-DEFAULT'},
|
|
@@ -160,14 +160,14 @@ _private.validatePackageJSONFields = function validatePackageJSONFields(packageJ
|
|
|
160
160
|
|
|
161
161
|
const knownSettingsTypes = new Set(['select', 'boolean', 'color', 'image', 'text']);
|
|
162
162
|
if (customSettingsKeys.some(key => !knownSettingsTypes.has(packageJSON.config.custom[key].type))) {
|
|
163
|
-
markFailed('
|
|
163
|
+
markFailed('unknownCustomThemeSettingsType');
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
const knownSettingsGroups = new Set(['post', 'homepage']);
|
|
167
167
|
// Ignore undefined values as "groups" is an optional property
|
|
168
168
|
if (customSettingsKeys.some(key => typeof packageJSON.config.custom[key].group !== 'undefined'
|
|
169
169
|
&& !knownSettingsGroups.has(packageJSON.config.custom[key].group))) {
|
|
170
|
-
markFailed('
|
|
170
|
+
markFailed('unknownCustomThemeSettingsGroup');
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
for (const key of customSettingsKeys) {
|
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/lib/read-zip.js
CHANGED
package/lib/specs/canary.js
CHANGED
|
@@ -716,19 +716,19 @@ let rules = {
|
|
|
716
716
|
'GS110-NO-MISSING-PAGE-BUILDER-USAGE': {
|
|
717
717
|
level: 'error',
|
|
718
718
|
rule: 'Not all page features are being used',
|
|
719
|
-
details: oneLineTrim
|
|
719
|
+
details: oneLineTrim`<b>This error only applies to pages created with the Beta editor.</b> Some page features used by Ghost via the <code>{{@page}}</code> global are not implemented in this theme.
|
|
720
720
|
Find more information about the <code>{{@page}}</code> global <a href="${docsBaseUrl}helpers/page/" target=_blank>here</a>.`
|
|
721
721
|
},
|
|
722
722
|
'GS110-NO-UNKNOWN-PAGE-BUILDER-USAGE': {
|
|
723
723
|
level: 'error',
|
|
724
724
|
fatal: true,
|
|
725
725
|
rule: 'Unsupported page builder feature used',
|
|
726
|
-
details: oneLineTrim`A page feature used via the <code>{{@page}}</code> global was detected but
|
|
727
|
-
|
|
726
|
+
details: oneLineTrim`A page feature used via the <code>{{@page}}</code> global was detected but is not supported by this version of Ghost. Please upgrade to the latest version for full access.
|
|
727
|
+
You can find more information about the <code>{{@page}}</code> global <a href="${docsBaseUrl}helpers/page/" target=_blank>here</a>.`
|
|
728
728
|
},
|
|
729
729
|
'GS120-NO-UNKNOWN-GLOBALS': {
|
|
730
730
|
level: 'error',
|
|
731
|
-
rule: '
|
|
731
|
+
rule: 'No unknown global helper used',
|
|
732
732
|
details: oneLineTrim`A global helper was detected that is not supported by this version of Ghost. Check the
|
|
733
733
|
<a href="${docsBaseUrl}helpers/" target=_blank>helpers documentation</a> for further information.`
|
|
734
734
|
}
|
package/lib/specs/v4.js
CHANGED
|
@@ -172,7 +172,7 @@ let rules = {
|
|
|
172
172
|
},
|
|
173
173
|
'GS090-NO-UNKNOWN-CUSTOM-THEME-SETTINGS': {
|
|
174
174
|
level: 'error',
|
|
175
|
-
rule: 'An
|
|
175
|
+
rule: 'An unknown custom theme setting has been used.',
|
|
176
176
|
fatal: false,
|
|
177
177
|
details: oneLineTrim`The custom theme setting should all be defined in the package.json <code>config.custom</code> object.`
|
|
178
178
|
},
|
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,19 +40,18 @@
|
|
|
40
40
|
"gscan": "./bin/cli.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@sentry/node": "7.
|
|
44
|
-
"@tryghost/config": "0.2.
|
|
45
|
-
"@tryghost/debug": "0.1.
|
|
46
|
-
"@tryghost/errors": "1.2.
|
|
47
|
-
"@tryghost/logging": "2.4.
|
|
48
|
-
"@tryghost/pretty-cli": "1.2.
|
|
49
|
-
"@tryghost/server": "0.1.
|
|
50
|
-
"@tryghost/zip": "1.1.
|
|
51
|
-
"bluebird": "3.7.2",
|
|
43
|
+
"@sentry/node": "7.66.0",
|
|
44
|
+
"@tryghost/config": "0.2.18",
|
|
45
|
+
"@tryghost/debug": "0.1.26",
|
|
46
|
+
"@tryghost/errors": "1.2.26",
|
|
47
|
+
"@tryghost/logging": "2.4.6",
|
|
48
|
+
"@tryghost/pretty-cli": "1.2.38",
|
|
49
|
+
"@tryghost/server": "0.1.36",
|
|
50
|
+
"@tryghost/zip": "1.1.37",
|
|
52
51
|
"chalk": "4.1.2",
|
|
53
52
|
"common-tags": "1.8.2",
|
|
54
53
|
"express": "4.18.2",
|
|
55
|
-
"express-hbs": "2.4.
|
|
54
|
+
"express-hbs": "2.4.1",
|
|
56
55
|
"fs-extra": "11.1.1",
|
|
57
56
|
"glob": "8.1.0",
|
|
58
57
|
"lodash": "4.17.21",
|
|
Binary file
|