gscan 4.28.0 → 4.29.2

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/specs/v3.js CHANGED
@@ -2,8 +2,9 @@ const _ = require('lodash');
2
2
  const oneLineTrim = require('common-tags/lib/oneLineTrim');
3
3
  const previousSpec = require('./v2');
4
4
  const ghostVersions = require('../utils').versions;
5
- const docsBaseUrl = `https://ghost.org/docs/api/handlebars-themes/`;
6
- const faqBaseUrl = `https://ghost.org/faq/`;
5
+ const docsBaseUrl = `https://ghost.org/docs/themes/`;
6
+ // TODO: we don't use versioned docs anymore and the previous rules should only contain
7
+ // correct links. The usage of replacing the previousBaseUrl can probably be removed
7
8
  const prevDocsBaseUrl = `https://themes.ghost.org/v${ghostVersions.v2.docs}/docs/`;
8
9
  const prevDocsBaseUrlRegEx = new RegExp(prevDocsBaseUrl, 'g');
9
10
 
@@ -21,14 +22,14 @@ let rules = {
21
22
  rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is recommended. Otherwise, it falls back to "v3"',
22
23
  details: oneLineTrim`Please add <code>"ghost-api"</code> to your <code>package.json</code>. E.g. <code>{"engines": {"ghost-api": "v3"}}</code>.<br>
23
24
  If no <code>"ghost-api"</code> property is provided, Ghost will use its default setting of "v3" Ghost API.<br>
24
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
25
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
25
26
  },
26
27
  'GS010-PJ-GHOST-API-V01': {
27
28
  level: 'error',
28
29
  rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is incompatible with current version of Ghost API and will fall back to "v3"',
29
30
  details: oneLineTrim`Please change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v3"}}</code>.<br>
30
31
  If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v3".<br>
31
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
32
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
32
33
  },
33
34
  'GS001-DEPR-ESC': {
34
35
  level: 'error',
@@ -43,7 +44,7 @@ let rules = {
43
44
  level: 'error',
44
45
  rule: 'The v0.1 API and <code>ghost.url.api()</code> JavaScript helper have been removed.',
45
46
  details: oneLineTrim`The v0.1 API & Public API Beta have been removed, along with the <code>public/ghost-sdk.min.js</code> file & the <code>ghost.url.api()</code> helper.<br>
46
- All code relying on the v0.1 API must be upgraded to use the <a href="${faqBaseUrl}upgrades/" target=_blank>new API</a>.`,
47
+ All code relying on the v0.1 API must be upgraded to use the <a href="https://ghost.org/docs/changes/" target=_blank>new API</a>.`,
47
48
  regex: /ghost\.url\.api/g
48
49
  },
49
50
  'GS070-VALID-TRANSLATIONS': {
@@ -68,5 +69,6 @@ rules = _.each(_.merge({}, previousRules, rules), function replaceDocsUrl(value)
68
69
  module.exports = {
69
70
  knownHelpers: knownHelpers,
70
71
  templates: templates,
71
- rules: rules
72
+ rules: rules,
73
+ defaultPackageJSON: previousSpec.defaultPackageJSON
72
74
  };
package/lib/specs/v4.js CHANGED
@@ -3,6 +3,8 @@ const oneLineTrim = require('common-tags/lib/oneLineTrim');
3
3
  const previousSpec = require('./v3');
4
4
  const ghostVersions = require('../utils').versions;
5
5
  const docsBaseUrl = `https://ghost.org/docs/themes/`;
6
+ // TODO: we don't use versioned docs anymore and the previous rules should only contain
7
+ // correct links. The usage of replacing the previousBaseUrl can probably be removed
6
8
  const prevDocsBaseUrl = `https://themes.ghost.org/v${ghostVersions.v3.docs}/docs/`;
7
9
  const prevDocsBaseUrlRegEx = new RegExp(prevDocsBaseUrl, 'g');
8
10
 
@@ -15,7 +17,7 @@ function cssCardRule(cardName, className) {
15
17
  level: 'warning',
16
18
  rule: `The <code>.${className}</code> CSS class is required to appear styled in your theme`,
17
19
  details: oneLineTrim`The <code>.${className}</code> CSS class is required otherwise the ${cardName} card will appear unstyled.
18
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/" target=_blank>here</a>.`,
20
+ Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}content/" target=_blank>here</a>.`,
19
21
  regex: new RegExp(`\\.${className}`, 'g'),
20
22
  className: `.${className}`,
21
23
  css: true,
@@ -33,75 +35,75 @@ let rules = {
33
35
  rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is deprecated.',
34
36
  details: oneLineTrim`Remove <code>"ghost-api"</code> from your <code>package.json</code>.<br>
35
37
  The <code>ghost-api</code> support will be removed in next major version of Ghost and should not be used.
36
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
38
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
37
39
  },
38
40
  'GS010-PJ-GHOST-API-V01': {
39
41
  level: 'error',
40
42
  rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is incompatible with current version of Ghost API and will fall back to "v4"',
41
43
  details: oneLineTrim`Change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v4"}}</code>.<br>
42
44
  If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v4".<br>
43
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
45
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
44
46
  },
45
47
  'GS010-PJ-GHOST-API-V2': {
46
48
  level: 'warning',
47
49
  rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is using a deprecated version of Ghost API',
48
50
  details: oneLineTrim`Change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v4"}}</code>.<br>
49
51
  If <code>"ghost-api"</code> property is left at "v2", it will stop working with next major version upgrade and default to v5.<br>
50
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
52
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
51
53
  },
52
54
  'GS010-PJ-CUST-THEME-TOTAL-SETTINGS': {
53
55
  level: 'error',
54
56
  rule: '<code>package.json</code> property <code>"config.custom"</code> contains too many settings',
55
57
  details: oneLineTrim`Remove key from <code>"config.custom"</code> in your <code>package.json</code> to have less than or exactly 15 settings.<br>
56
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
58
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
57
59
  },
58
60
  'GS010-PJ-CUST-THEME-SETTINGS-CASE': {
59
61
  level: 'error',
60
62
  rule: '<code>package.json</code> property <code>"config.custom"</code> contains a property that isn\'t snake-cased',
61
63
  details: oneLineTrim`Rewrite all property in <code>"config.custom"</code> in your <code>package.json</code> in snake case.<br>
62
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
64
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
63
65
  },
64
66
  'GS010-PJ-CUST-THEME-SETTINGS-TYPE': {
65
67
  level: 'error',
66
68
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"type"</code>.',
67
69
  details: oneLineTrim`Only use the following types: <code>"select"</code>, <code>"boolean"</code>, <code>"color"</code>, <code>"image"</code>, <code>"text"</code>.<br>
68
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
70
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
69
71
  },
70
72
  'GS010-PJ-CUST-THEME-SETTINGS-GROUP': {
71
73
  level: 'recommendation',
72
74
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"group"</code>.',
73
75
  details: oneLineTrim`Only use the following groups: <code>"post"</code>, <code>"homepage"</code>.<br>
74
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
76
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
75
77
  },
76
78
  'GS010-PJ-CUST-THEME-SETTINGS-SELECT-OPTIONS': {
77
79
  level: 'error',
78
80
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"select"</code> need to have at least 2 <code>"options"</code>.',
79
81
  details: oneLineTrim`Make sure there is at least 2 <code>"options"</code> in each <code>"select"</code> custom theme property.<br>
80
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
82
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
81
83
  },
82
84
  'GS010-PJ-CUST-THEME-SETTINGS-SELECT-DEFAULT': {
83
85
  level: 'error',
84
86
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"select"</code> need to have a valid <code>"default"</code>.',
85
87
  details: oneLineTrim`Make sure the <code>"default"</code> property matches a value in <code>"options"</code> of the same <code>"select"</code>.<br>
86
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
88
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
87
89
  },
88
90
  'GS010-PJ-CUST-THEME-SETTINGS-BOOLEAN-DEFAULT': {
89
91
  level: 'error',
90
92
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"boolean"</code> need to have a valid <code>"default"</code>.',
91
93
  details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>true</code> or <code>false</code>.<br>
92
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
94
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
93
95
  },
94
96
  'GS010-PJ-CUST-THEME-SETTINGS-COLOR-DEFAULT': {
95
97
  level: 'error',
96
98
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"color"</code> need to have a valid <code>"default"</code>.',
97
99
  details: oneLineTrim`Make sure the <code>"default"</code> property is a valid 6-hexadecimal-digit color code like <code>#15171a</code>.<br>
98
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
100
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
99
101
  },
100
102
  'GS010-PJ-CUST-THEME-SETTINGS-IMAGE-DEFAULT': {
101
103
  level: 'error',
102
104
  rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"image"</code> can\'t have a <code>"default"</code> value.',
103
105
  details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>null</code>, an empty string <code>''</code> or isn't present.<br>
104
- Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
106
+ Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
105
107
  },
106
108
  'GS001-DEPR-LABS-MEMBERS': {
107
109
  level: 'warning',
@@ -114,8 +116,8 @@ let rules = {
114
116
  },
115
117
  'GS080-FEACH-POSTS': {
116
118
  level: 'warning',
117
- rule: 'The default visibility for posts in <code>{{#foreach}}</code> block helper has changed in v4.',
118
- details: oneLineTrim`The default visibility for posts in <code>{{#foreach}}</code> block helper has changed from <code>public</code> to <code>all</code> in Ghost v4.
119
+ rule: 'The default visibility for posts in <code>{{#foreach}}</code> block helper changed in Ghost v4.',
120
+ details: oneLineTrim`The default visibility for posts in <code>{{#foreach}}</code> block helper changed from <code>public</code> to <code>all</code>.<br>
119
121
  Find more information about the <code>{{foreach}}</code> helper <a href="${docsBaseUrl}helpers/foreach/" target=_blank>here</a>.`,
120
122
  regex: /{{\s*?#foreach\s*?\w*?\s*?}}/g,
121
123
  helper: '{{#foreach}}',
@@ -133,7 +135,7 @@ let rules = {
133
135
  'GS080-FEACH-PV': {
134
136
  level: 'recommendation',
135
137
  rule: 'The use of <code>visibility="all"</code> is no longer required for posts in <code>{{#foreach}}</code> helper.',
136
- details: oneLineTrim`The default visibility in <code>{{#foreach}}</code> helper for posts has changed in v4 from "public" to "all" and is no longer required when looping over posts.
138
+ details: oneLineTrim`The default visibility in <code>{{#foreach}}</code> helper for posts changed in v4 from <code>public</code> to <code>all</code> and is no longer required when looping over posts.<br>
137
139
  Check out the documentation for <code>{{#foreach}}</code> <a href="${docsBaseUrl}helpers/foreach/" target=_blank>here</a>.`,
138
140
  regex: /{{\s*?#foreach\b[\w\s='"]*?visibility=("|')all("|')[\w\s='"]*?}}/g,
139
141
  helper: '{{#foreach}}',
@@ -149,7 +151,7 @@ let rules = {
149
151
  },
150
152
  'GS001-DEPR-SITE-LANG': {
151
153
  level: 'warning',
152
- rule: 'The <code>{{@site.lang}}</code> helper should be replaced with <code>{{@site.locale}}</code>',
154
+ rule: 'Replace <code>{{@site.lang}}</code> with <code>{{@site.locale}}</code>',
153
155
  details: oneLineTrim`Replace <code>{{@site.lang}}</code> helper with <code>{{@site.locale}}</code>.<br>
154
156
  The <code>{{@site.lang}}</code> helper will be removed in next version of Ghost and should not be used.
155
157
  Find more information about the <code>@site</code> property <a href="${docsBaseUrl}helpers/site/" target=_blank>here</a>.`,
@@ -182,7 +184,7 @@ let rules = {
182
184
  },
183
185
  'GS090-NO-PRODUCTS-HELPER': {
184
186
  level: 'warning',
185
- rule: 'The <code>{{products}}</code> helper should be replaces with <code>{{tiers}}</code>',
187
+ rule: 'Replace <code>{{products}}</code> with <code>{{tiers}}</code>',
186
188
  details: oneLineTrim`The <code>{{products}}</code> helper has been deprecated in favor of <code>{{tiers}}</code><br>
187
189
  The <code>{{products}}</code> helper will be removed in Ghost v5 and should not be used.
188
190
  Find more information about the <code>{{tiers}}</code> property <a href="${docsBaseUrl}helpers/tiers/" target=_blank>here</a>.`,
@@ -190,7 +192,7 @@ let rules = {
190
192
  },
191
193
  'GS090-NO-PRODUCT-DATA-HELPER': {
192
194
  level: 'warning',
193
- rule: 'The <code>{{@product}}</code> data helper should be replaces with <code>{{#get "tiers"}}</code>',
195
+ rule: 'Replace <code>{{@product}}</code> with <code>{{#get "tiers"}}</code>',
194
196
  details: oneLineTrim`The <code>{{@product}}</code> data helper has been deprecated in favor of <code>{{#get "tiers"}}</code><br>
195
197
  The <code>{{@product}}</code> data helper will be removed in Ghost v5 and should not be used.
196
198
  Find more information about the <code>{{#get "tiers"}}</code> property <a href="${docsBaseUrl}helpers/tiers/" target=_blank>here</a>.`,
@@ -198,7 +200,7 @@ let rules = {
198
200
  },
199
201
  'GS090-NO-PRODUCTS-DATA-HELPER': {
200
202
  level: 'warning',
201
- rule: 'The <code>{{@products}}</code> data helper should be replaces with <code>{{#get "tiers"}}</code>',
203
+ rule: 'Replace <code>{{@products}}</code> with <code>{{#get "tiers"}}</code>',
202
204
  details: oneLineTrim`The <code>{{@products}}</code> data helper has been deprecated in favor of <code>{{#get "tiers"}}</code><br>
203
205
  The <code>{{@products}}</code> data helper will be removed in Ghost v5 and should not be used.
204
206
  Find more information about the <code>{{#get "tiers"}}</code> property <a href="${docsBaseUrl}helpers/tiers/" target=_blank>here</a>.`,
@@ -331,5 +333,6 @@ rules = _.each(rules, function replaceDocsUrl(value) {
331
333
  module.exports = {
332
334
  knownHelpers: knownHelpers,
333
335
  templates: templates,
334
- rules: rules
336
+ rules: rules,
337
+ defaultPackageJSON: previousSpec.defaultPackageJSON
335
338
  };
@@ -1,22 +1,13 @@
1
- /**
2
- * Copy of Ghost defaults for https://github.com/TryGhost/Ghost/blob/e25f1df0ae551c447da0d319bae06eadf9665444/core/frontend/services/theme-engine/config/defaults.json
3
- */
4
- const defaultConfig = {
5
- posts_per_page: 5,
6
- card_assets: {
7
- exclude: ['bookmark', 'gallery']
8
- }
9
- };
10
-
11
1
  /**
12
2
  * Extracts the package.json JSON content. Note that this function never throws,
13
3
  * even when there is a JSON parsing error.
14
4
  * This function uses the default `config` property to match Ghost implementation.
15
5
  * @param {Object} theme The theme to extract package.json from.
6
+ * @param {Object} defaultConfig JSON matching the default theme configuration for the checked Ghost version
16
7
  * @returns {Object} The content of the package.json file, or `null` if
17
8
  * something happened (no file, JSON parsing error...).
18
9
  */
19
- function getJSON(theme) {
10
+ function getJSON(theme, defaultConfig) {
20
11
  let packageJSON = theme.files.find(item => item.file === 'package.json');
21
12
  if (packageJSON && packageJSON.content) {
22
13
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gscan",
3
- "version": "4.28.0",
3
+ "version": "4.29.2",
4
4
  "description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
5
5
  "keywords": [
6
6
  "ghost",
@@ -8,7 +8,7 @@
8
8
  "validator",
9
9
  "lint"
10
10
  ],
11
- "homepage": "https://ghost.org",
11
+ "homepage": "https://ghost.org/",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git@github.com:TryGhost/gscan.git"
@@ -22,7 +22,7 @@
22
22
  "author": {
23
23
  "name": "Ghost Foundation",
24
24
  "email": "hello@ghost.org",
25
- "web": "https://ghost.org"
25
+ "web": "https://ghost.org/"
26
26
  },
27
27
  "main": "lib",
28
28
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "express": "4.18.1",
55
55
  "express-hbs": "2.4.0",
56
56
  "fs-extra": "10.1.0",
57
- "glob": "7.2.2",
57
+ "glob": "7.2.3",
58
58
  "lodash": "4.17.21",
59
59
  "multer": "1.4.4",
60
60
  "pluralize": "8.0.0",