@platformos/platformos-check-node 0.0.7 → 0.0.9
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/configs/all.yml +2 -119
- package/configs/recommended.yml +2 -97
- package/dist/autofix.d.ts +3 -3
- package/dist/autofix.js +1 -1
- package/dist/backfill-docs/argument-collector.d.ts +2 -2
- package/dist/backfill-docs/index.js +7 -8
- package/dist/cli.js +8 -8
- package/dist/commands/generate-docs.d.ts +24 -0
- package/dist/commands/generate-docs.js +136 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +7 -0
- package/dist/config/load-config-description.js +0 -1
- package/dist/config/load-third-party-checks.d.ts +1 -1
- package/dist/config/load-third-party-checks.js +5 -5
- package/dist/config/resolve/merge-fragments.js +0 -2
- package/dist/config/resolve/read-yaml.js +1 -7
- package/dist/config/types.d.ts +3 -5
- package/dist/index.d.ts +13 -9
- package/dist/index.js +38 -65
- package/dist/test/test-helpers.js +2 -2
- package/package.json +3 -3
package/configs/all.yml
CHANGED
|
@@ -3,91 +3,33 @@
|
|
|
3
3
|
# Do not modify manually. Your changes will be overwritten.
|
|
4
4
|
ignore:
|
|
5
5
|
- node_modules/**
|
|
6
|
-
AppBlockMissingSchema:
|
|
7
|
-
enabled: false
|
|
8
|
-
severity: 0
|
|
9
|
-
AppBlockValidTags:
|
|
10
|
-
enabled: false
|
|
11
|
-
severity: 0
|
|
12
|
-
AssetPreload:
|
|
13
|
-
enabled: true
|
|
14
|
-
severity: 1
|
|
15
|
-
AssetSizeAppBlockCSS:
|
|
16
|
-
enabled: false
|
|
17
|
-
severity: 0
|
|
18
|
-
thresholdInBytes: 100000
|
|
19
|
-
AssetSizeAppBlockJavaScript:
|
|
20
|
-
enabled: false
|
|
21
|
-
severity: 0
|
|
22
|
-
thresholdInBytes: 10000
|
|
23
|
-
AssetSizeCSS:
|
|
24
|
-
enabled: true
|
|
25
|
-
severity: 0
|
|
26
|
-
thresholdInBytes: 100000
|
|
27
|
-
AssetSizeJavaScript:
|
|
28
|
-
enabled: true
|
|
29
|
-
severity: 0
|
|
30
|
-
thresholdInBytes: 10000
|
|
31
|
-
BlockIdUsage:
|
|
32
|
-
enabled: true
|
|
33
|
-
severity: 1
|
|
34
|
-
CdnPreconnect:
|
|
35
|
-
enabled: true
|
|
36
|
-
severity: 0
|
|
37
|
-
ContentForHeaderModification:
|
|
38
|
-
enabled: true
|
|
39
|
-
severity: 0
|
|
40
|
-
DeprecateBgsizes:
|
|
41
|
-
enabled: true
|
|
42
|
-
severity: 1
|
|
43
|
-
DeprecateLazysizes:
|
|
44
|
-
enabled: true
|
|
45
|
-
severity: 1
|
|
46
6
|
DeprecatedFilter:
|
|
47
7
|
enabled: true
|
|
48
8
|
severity: 1
|
|
49
|
-
DeprecatedFontsOnSectionsAndBlocks:
|
|
50
|
-
enabled: true
|
|
51
|
-
severity: 1
|
|
52
|
-
DeprecatedFontsOnSettingsSchema:
|
|
53
|
-
enabled: true
|
|
54
|
-
severity: 1
|
|
55
9
|
DeprecatedTag:
|
|
56
10
|
enabled: true
|
|
57
11
|
severity: 1
|
|
58
|
-
|
|
12
|
+
DuplicateFunctionArguments:
|
|
59
13
|
enabled: true
|
|
60
14
|
severity: 1
|
|
61
15
|
DuplicateRenderPartialArguments:
|
|
62
16
|
enabled: true
|
|
63
17
|
severity: 1
|
|
64
|
-
EmptyBlockContent:
|
|
65
|
-
enabled: true
|
|
66
|
-
severity: 1
|
|
67
18
|
GraphQLCheck:
|
|
68
19
|
enabled: true
|
|
69
20
|
severity: 0
|
|
70
21
|
GraphQLVariablesCheck:
|
|
71
22
|
enabled: true
|
|
72
23
|
severity: 0
|
|
73
|
-
HardcodedRoutes:
|
|
74
|
-
enabled: true
|
|
75
|
-
severity: 1
|
|
76
24
|
ImgWidthAndHeight:
|
|
77
25
|
enabled: true
|
|
78
26
|
severity: 0
|
|
79
27
|
InvalidHashAssignTarget:
|
|
80
28
|
enabled: true
|
|
81
29
|
severity: 0
|
|
82
|
-
JSONMissingBlock:
|
|
83
|
-
enabled: true
|
|
84
|
-
severity: 0
|
|
85
30
|
JSONSyntaxError:
|
|
86
31
|
enabled: true
|
|
87
32
|
severity: 0
|
|
88
|
-
LiquidFreeSettings:
|
|
89
|
-
enabled: true
|
|
90
|
-
severity: 1
|
|
91
33
|
LiquidHTMLSyntaxError:
|
|
92
34
|
enabled: true
|
|
93
35
|
severity: 0
|
|
@@ -100,39 +42,16 @@ MetadataParamsCheck:
|
|
|
100
42
|
MissingAsset:
|
|
101
43
|
enabled: true
|
|
102
44
|
severity: 0
|
|
103
|
-
|
|
104
|
-
enabled: true
|
|
105
|
-
severity: 1
|
|
106
|
-
MissingTemplate:
|
|
45
|
+
MissingPartial:
|
|
107
46
|
enabled: true
|
|
108
47
|
severity: 0
|
|
109
48
|
ignoreMissing: []
|
|
110
49
|
OrphanedPartial:
|
|
111
50
|
enabled: true
|
|
112
51
|
severity: 1
|
|
113
|
-
PaginationSize:
|
|
114
|
-
enabled: true
|
|
115
|
-
severity: 1
|
|
116
|
-
minSize: 1
|
|
117
|
-
maxSize: 250
|
|
118
52
|
ParserBlockingScript:
|
|
119
53
|
enabled: true
|
|
120
54
|
severity: 0
|
|
121
|
-
RemoteAsset:
|
|
122
|
-
enabled: true
|
|
123
|
-
severity: 1
|
|
124
|
-
ReservedDocParamNames:
|
|
125
|
-
enabled: true
|
|
126
|
-
severity: 0
|
|
127
|
-
SchemaPresetsBlockOrder:
|
|
128
|
-
enabled: true
|
|
129
|
-
severity: 1
|
|
130
|
-
SchemaPresetsStaticBlocks:
|
|
131
|
-
enabled: true
|
|
132
|
-
severity: 0
|
|
133
|
-
StaticStylesheetAndJavascriptTags:
|
|
134
|
-
enabled: true
|
|
135
|
-
severity: 0
|
|
136
55
|
TranslationKeyExists:
|
|
137
56
|
enabled: true
|
|
138
57
|
severity: 0
|
|
@@ -145,21 +64,12 @@ UndefinedObject:
|
|
|
145
64
|
UniqueDocParamNames:
|
|
146
65
|
enabled: true
|
|
147
66
|
severity: 0
|
|
148
|
-
UniqueSettingId:
|
|
149
|
-
enabled: true
|
|
150
|
-
severity: 0
|
|
151
|
-
UniqueStaticBlockId:
|
|
152
|
-
enabled: true
|
|
153
|
-
severity: 0
|
|
154
67
|
UnknownFilter:
|
|
155
68
|
enabled: true
|
|
156
69
|
severity: 0
|
|
157
70
|
UnknownProperty:
|
|
158
71
|
enabled: true
|
|
159
72
|
severity: 0
|
|
160
|
-
UnrecognizedContentForArguments:
|
|
161
|
-
enabled: true
|
|
162
|
-
severity: 1
|
|
163
73
|
UnrecognizedRenderPartialArguments:
|
|
164
74
|
enabled: true
|
|
165
75
|
severity: 1
|
|
@@ -169,15 +79,6 @@ UnusedAssign:
|
|
|
169
79
|
UnusedDocParam:
|
|
170
80
|
enabled: true
|
|
171
81
|
severity: 1
|
|
172
|
-
ValidBlockTarget:
|
|
173
|
-
enabled: true
|
|
174
|
-
severity: 0
|
|
175
|
-
ValidContentForArgumentTypes:
|
|
176
|
-
enabled: true
|
|
177
|
-
severity: 1
|
|
178
|
-
ValidContentForArguments:
|
|
179
|
-
enabled: true
|
|
180
|
-
severity: 0
|
|
181
82
|
ValidDocParamTypes:
|
|
182
83
|
enabled: true
|
|
183
84
|
severity: 0
|
|
@@ -187,27 +88,9 @@ ValidHTMLTranslation:
|
|
|
187
88
|
ValidJSON:
|
|
188
89
|
enabled: true
|
|
189
90
|
severity: 0
|
|
190
|
-
ValidLocalBlocks:
|
|
191
|
-
enabled: true
|
|
192
|
-
severity: 0
|
|
193
91
|
ValidRenderPartialArgumentTypes:
|
|
194
92
|
enabled: true
|
|
195
93
|
severity: 1
|
|
196
|
-
ValidSchema:
|
|
197
|
-
enabled: true
|
|
198
|
-
severity: 0
|
|
199
|
-
ValidSchemaName:
|
|
200
|
-
enabled: true
|
|
201
|
-
severity: 0
|
|
202
|
-
ValidSettingsKey:
|
|
203
|
-
enabled: true
|
|
204
|
-
severity: 0
|
|
205
|
-
ValidStaticBlockType:
|
|
206
|
-
enabled: true
|
|
207
|
-
severity: 0
|
|
208
|
-
ValidVisibleIf:
|
|
209
|
-
enabled: true
|
|
210
|
-
severity: 0
|
|
211
94
|
VariableName:
|
|
212
95
|
enabled: true
|
|
213
96
|
severity: 1
|
package/configs/recommended.yml
CHANGED
|
@@ -3,69 +3,33 @@
|
|
|
3
3
|
# Do not modify manually. Your changes will be overwritten.
|
|
4
4
|
ignore:
|
|
5
5
|
- node_modules/**
|
|
6
|
-
AssetPreload:
|
|
7
|
-
enabled: true
|
|
8
|
-
severity: 1
|
|
9
|
-
BlockIdUsage:
|
|
10
|
-
enabled: true
|
|
11
|
-
severity: 1
|
|
12
|
-
CdnPreconnect:
|
|
13
|
-
enabled: true
|
|
14
|
-
severity: 0
|
|
15
|
-
ContentForHeaderModification:
|
|
16
|
-
enabled: true
|
|
17
|
-
severity: 0
|
|
18
|
-
DeprecateBgsizes:
|
|
19
|
-
enabled: true
|
|
20
|
-
severity: 1
|
|
21
|
-
DeprecateLazysizes:
|
|
22
|
-
enabled: true
|
|
23
|
-
severity: 1
|
|
24
6
|
DeprecatedFilter:
|
|
25
7
|
enabled: true
|
|
26
8
|
severity: 1
|
|
27
|
-
DeprecatedFontsOnSectionsAndBlocks:
|
|
28
|
-
enabled: true
|
|
29
|
-
severity: 1
|
|
30
|
-
DeprecatedFontsOnSettingsSchema:
|
|
31
|
-
enabled: true
|
|
32
|
-
severity: 1
|
|
33
9
|
DeprecatedTag:
|
|
34
10
|
enabled: true
|
|
35
11
|
severity: 1
|
|
36
|
-
|
|
12
|
+
DuplicateFunctionArguments:
|
|
37
13
|
enabled: true
|
|
38
14
|
severity: 1
|
|
39
15
|
DuplicateRenderPartialArguments:
|
|
40
16
|
enabled: true
|
|
41
17
|
severity: 1
|
|
42
|
-
EmptyBlockContent:
|
|
43
|
-
enabled: true
|
|
44
|
-
severity: 1
|
|
45
18
|
GraphQLCheck:
|
|
46
19
|
enabled: true
|
|
47
20
|
severity: 0
|
|
48
21
|
GraphQLVariablesCheck:
|
|
49
22
|
enabled: true
|
|
50
23
|
severity: 0
|
|
51
|
-
HardcodedRoutes:
|
|
52
|
-
enabled: true
|
|
53
|
-
severity: 1
|
|
54
24
|
ImgWidthAndHeight:
|
|
55
25
|
enabled: true
|
|
56
26
|
severity: 0
|
|
57
27
|
InvalidHashAssignTarget:
|
|
58
28
|
enabled: true
|
|
59
29
|
severity: 0
|
|
60
|
-
JSONMissingBlock:
|
|
61
|
-
enabled: true
|
|
62
|
-
severity: 0
|
|
63
30
|
JSONSyntaxError:
|
|
64
31
|
enabled: true
|
|
65
32
|
severity: 0
|
|
66
|
-
LiquidFreeSettings:
|
|
67
|
-
enabled: true
|
|
68
|
-
severity: 1
|
|
69
33
|
LiquidHTMLSyntaxError:
|
|
70
34
|
enabled: true
|
|
71
35
|
severity: 0
|
|
@@ -78,39 +42,16 @@ MetadataParamsCheck:
|
|
|
78
42
|
MissingAsset:
|
|
79
43
|
enabled: true
|
|
80
44
|
severity: 0
|
|
81
|
-
|
|
82
|
-
enabled: true
|
|
83
|
-
severity: 1
|
|
84
|
-
MissingTemplate:
|
|
45
|
+
MissingPartial:
|
|
85
46
|
enabled: true
|
|
86
47
|
severity: 0
|
|
87
48
|
ignoreMissing: []
|
|
88
49
|
OrphanedPartial:
|
|
89
50
|
enabled: true
|
|
90
51
|
severity: 1
|
|
91
|
-
PaginationSize:
|
|
92
|
-
enabled: true
|
|
93
|
-
severity: 1
|
|
94
|
-
minSize: 1
|
|
95
|
-
maxSize: 250
|
|
96
52
|
ParserBlockingScript:
|
|
97
53
|
enabled: true
|
|
98
54
|
severity: 0
|
|
99
|
-
RemoteAsset:
|
|
100
|
-
enabled: true
|
|
101
|
-
severity: 1
|
|
102
|
-
ReservedDocParamNames:
|
|
103
|
-
enabled: true
|
|
104
|
-
severity: 0
|
|
105
|
-
SchemaPresetsBlockOrder:
|
|
106
|
-
enabled: true
|
|
107
|
-
severity: 1
|
|
108
|
-
SchemaPresetsStaticBlocks:
|
|
109
|
-
enabled: true
|
|
110
|
-
severity: 0
|
|
111
|
-
StaticStylesheetAndJavascriptTags:
|
|
112
|
-
enabled: true
|
|
113
|
-
severity: 0
|
|
114
55
|
TranslationKeyExists:
|
|
115
56
|
enabled: true
|
|
116
57
|
severity: 0
|
|
@@ -123,21 +64,12 @@ UndefinedObject:
|
|
|
123
64
|
UniqueDocParamNames:
|
|
124
65
|
enabled: true
|
|
125
66
|
severity: 0
|
|
126
|
-
UniqueSettingId:
|
|
127
|
-
enabled: true
|
|
128
|
-
severity: 0
|
|
129
|
-
UniqueStaticBlockId:
|
|
130
|
-
enabled: true
|
|
131
|
-
severity: 0
|
|
132
67
|
UnknownFilter:
|
|
133
68
|
enabled: true
|
|
134
69
|
severity: 0
|
|
135
70
|
UnknownProperty:
|
|
136
71
|
enabled: true
|
|
137
72
|
severity: 0
|
|
138
|
-
UnrecognizedContentForArguments:
|
|
139
|
-
enabled: true
|
|
140
|
-
severity: 1
|
|
141
73
|
UnrecognizedRenderPartialArguments:
|
|
142
74
|
enabled: true
|
|
143
75
|
severity: 1
|
|
@@ -147,15 +79,6 @@ UnusedAssign:
|
|
|
147
79
|
UnusedDocParam:
|
|
148
80
|
enabled: true
|
|
149
81
|
severity: 1
|
|
150
|
-
ValidBlockTarget:
|
|
151
|
-
enabled: true
|
|
152
|
-
severity: 0
|
|
153
|
-
ValidContentForArgumentTypes:
|
|
154
|
-
enabled: true
|
|
155
|
-
severity: 1
|
|
156
|
-
ValidContentForArguments:
|
|
157
|
-
enabled: true
|
|
158
|
-
severity: 0
|
|
159
82
|
ValidDocParamTypes:
|
|
160
83
|
enabled: true
|
|
161
84
|
severity: 0
|
|
@@ -165,27 +88,9 @@ ValidHTMLTranslation:
|
|
|
165
88
|
ValidJSON:
|
|
166
89
|
enabled: true
|
|
167
90
|
severity: 0
|
|
168
|
-
ValidLocalBlocks:
|
|
169
|
-
enabled: true
|
|
170
|
-
severity: 0
|
|
171
91
|
ValidRenderPartialArgumentTypes:
|
|
172
92
|
enabled: true
|
|
173
93
|
severity: 1
|
|
174
|
-
ValidSchema:
|
|
175
|
-
enabled: true
|
|
176
|
-
severity: 0
|
|
177
|
-
ValidSchemaName:
|
|
178
|
-
enabled: true
|
|
179
|
-
severity: 0
|
|
180
|
-
ValidSettingsKey:
|
|
181
|
-
enabled: true
|
|
182
|
-
severity: 0
|
|
183
|
-
ValidStaticBlockType:
|
|
184
|
-
enabled: true
|
|
185
|
-
severity: 0
|
|
186
|
-
ValidVisibleIf:
|
|
187
|
-
enabled: true
|
|
188
|
-
severity: 0
|
|
189
94
|
VariableName:
|
|
190
95
|
enabled: true
|
|
191
96
|
severity: 1
|
package/dist/autofix.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Offense,
|
|
1
|
+
import { Offense, App, FixApplicator } from '@platformos/platformos-check-common';
|
|
2
2
|
export declare const saveToDiskFixApplicator: FixApplicator;
|
|
3
3
|
/**
|
|
4
|
-
* Apply and save to disk the safe fixes for a set of offenses on
|
|
4
|
+
* Apply and save to disk the safe fixes for a set of offenses on an app.
|
|
5
5
|
*/
|
|
6
|
-
export declare function autofix(sourceCodes:
|
|
6
|
+
export declare function autofix(sourceCodes: App, offenses: Offense[]): Promise<void>;
|
package/dist/autofix.js
CHANGED
|
@@ -10,7 +10,7 @@ const saveToDiskFixApplicator = async (sourceCode, fix) => {
|
|
|
10
10
|
};
|
|
11
11
|
exports.saveToDiskFixApplicator = saveToDiskFixApplicator;
|
|
12
12
|
/**
|
|
13
|
-
* Apply and save to disk the safe fixes for a set of offenses on
|
|
13
|
+
* Apply and save to disk the safe fixes for a set of offenses on an app.
|
|
14
14
|
*/
|
|
15
15
|
async function autofix(sourceCodes, offenses) {
|
|
16
16
|
await (0, platformos_check_common_1.autofix)(sourceCodes, offenses, exports.saveToDiskFixApplicator);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { App } from '@platformos/platformos-check-common';
|
|
2
2
|
import { PartialUsage } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Collect all partial usages from a theme by visiting function, render, and include tags.
|
|
5
5
|
*/
|
|
6
|
-
export declare function collectPartialUsages(theme:
|
|
6
|
+
export declare function collectPartialUsages(theme: App, verbose?: boolean, log?: (message: string) => void): Promise<Map<string, PartialUsage>>;
|
|
@@ -55,11 +55,10 @@ async function backfillDocs(options, log = console.log) {
|
|
|
55
55
|
errors: [],
|
|
56
56
|
};
|
|
57
57
|
log('Scanning for partial usages (function, render, include)...');
|
|
58
|
-
// Load theme configuration
|
|
59
58
|
const config = await (0, index_1.loadConfig)(undefined, rootPath);
|
|
60
|
-
const
|
|
61
|
-
// Collect all partial usages from the
|
|
62
|
-
const usageMap = await (0, argument_collector_1.collectPartialUsages)(
|
|
59
|
+
const app = await (0, index_1.getApp)(config);
|
|
60
|
+
// Collect all partial usages from the app
|
|
61
|
+
const usageMap = await (0, argument_collector_1.collectPartialUsages)(app, verbose, log);
|
|
63
62
|
const totalCalls = Array.from(usageMap.values()).reduce((sum, usage) => sum + Array.from(usage.arguments.values()).reduce((s, a) => s + a.usageCount, 0), 0);
|
|
64
63
|
log(`Found ${totalCalls} partial calls referencing ${usageMap.size} partials\n`);
|
|
65
64
|
if (usageMap.size === 0) {
|
|
@@ -210,7 +209,7 @@ async function runBackfillDocsCLI(args) {
|
|
|
210
209
|
}
|
|
211
210
|
function printHelp() {
|
|
212
211
|
console.log(`
|
|
213
|
-
Usage:
|
|
212
|
+
Usage: platformos-check backfill-docs [path] [options]
|
|
214
213
|
|
|
215
214
|
Scans a platformOS project for partial usages (function, render, include tags)
|
|
216
215
|
and backfills or updates {% doc %} tags in the corresponding partial files.
|
|
@@ -225,9 +224,9 @@ Options:
|
|
|
225
224
|
--help, -h Show this help message
|
|
226
225
|
|
|
227
226
|
Examples:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
platformos-check backfill-docs
|
|
228
|
+
platformos-check backfill-docs ./my-project --dry-run
|
|
229
|
+
platformos-check backfill-docs --verbose --required
|
|
231
230
|
`);
|
|
232
231
|
}
|
|
233
232
|
//# sourceMappingURL=index.js.map
|
package/dist/cli.js
CHANGED
|
@@ -6,23 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const index_1 = require("./index");
|
|
7
7
|
const backfill_docs_1 = require("./backfill-docs");
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
async function
|
|
9
|
+
async function runCheck(args) {
|
|
10
10
|
const root = node_path_1.default.resolve(args[0] || '.');
|
|
11
11
|
const configPath = args[1] ? node_path_1.default.resolve(args[1]) : undefined;
|
|
12
|
-
const {
|
|
12
|
+
const { app, config, offenses } = await (0, index_1.appCheckRun)(root, configPath, console.error.bind(console));
|
|
13
13
|
console.log(JSON.stringify(offenses, null, 2));
|
|
14
14
|
console.log(JSON.stringify(config, null, 2));
|
|
15
|
-
console.log(JSON.stringify(
|
|
15
|
+
console.log(JSON.stringify(app.map((x) => x.uri), null, 2));
|
|
16
16
|
}
|
|
17
17
|
function printUsage() {
|
|
18
18
|
console.log(`
|
|
19
|
-
Usage:
|
|
19
|
+
Usage: platformos-check [command] [options]
|
|
20
20
|
|
|
21
21
|
Commands:
|
|
22
|
-
<path> Run
|
|
22
|
+
<path> Run platformos checks on the specified path (default)
|
|
23
23
|
backfill-docs Backfill doc tags in partial files based on usage
|
|
24
24
|
|
|
25
|
-
Run '
|
|
25
|
+
Run 'platformos-check <command> --help' for more information on a command.
|
|
26
26
|
`);
|
|
27
27
|
}
|
|
28
28
|
async function main() {
|
|
@@ -40,8 +40,8 @@ async function main() {
|
|
|
40
40
|
await (0, backfill_docs_1.runBackfillDocsCLI)(args.slice(1));
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
// Default: run
|
|
44
|
-
await
|
|
43
|
+
// Default: run platformos check
|
|
44
|
+
await runCheck(args);
|
|
45
45
|
}
|
|
46
46
|
main();
|
|
47
47
|
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface GenerateDocsOptions {
|
|
2
|
+
dryRun?: boolean;
|
|
3
|
+
output?: 'inline' | 'stdout' | 'json';
|
|
4
|
+
}
|
|
5
|
+
export interface GenerateDocsResult {
|
|
6
|
+
uri: string;
|
|
7
|
+
relativePath: string;
|
|
8
|
+
parameters: Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
type: string | null;
|
|
11
|
+
isOptional: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
docBlockText: string;
|
|
14
|
+
hasExistingDocBlock: boolean;
|
|
15
|
+
updated: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate doc blocks for all partials and blocks in a theme.
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateDocsCommand(root: string, options?: GenerateDocsOptions): Promise<GenerateDocsResult[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate doc block for a single file.
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateDocForFile(absolutePath: string, options?: GenerateDocsOptions): Promise<GenerateDocsResult | null>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateDocsCommand = generateDocsCommand;
|
|
7
|
+
exports.generateDocForFile = generateDocForFile;
|
|
8
|
+
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
9
|
+
const platformos_check_docs_updater_1 = require("@platformos/platformos-check-docs-updater");
|
|
10
|
+
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
11
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const node_util_1 = require("node:util");
|
|
14
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
15
|
+
const glob = require("glob");
|
|
16
|
+
const asyncGlob = (0, node_util_1.promisify)(glob);
|
|
17
|
+
/**
|
|
18
|
+
* Generate doc blocks for all partials and blocks in a theme.
|
|
19
|
+
*/
|
|
20
|
+
async function generateDocsCommand(root, options = {}) {
|
|
21
|
+
const { dryRun = false, output = 'inline' } = options;
|
|
22
|
+
const rootUri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(root));
|
|
23
|
+
const themeLiquidDocsManager = new platformos_check_docs_updater_1.ThemeLiquidDocsManager(console.error.bind(console));
|
|
24
|
+
// Find all liquid files that support doc blocks (partials and blocks)
|
|
25
|
+
const partialsGlob = node_path_1.default
|
|
26
|
+
.normalize(node_path_1.default.join(root, 'app/views/partials/**/*.liquid'))
|
|
27
|
+
.replace(/\\/g, '/');
|
|
28
|
+
const blocksGlob = node_path_1.default
|
|
29
|
+
.normalize(node_path_1.default.join(root, 'blocks/**/*.liquid'))
|
|
30
|
+
.replace(/\\/g, '/');
|
|
31
|
+
const [partialPaths, blockPaths] = await Promise.all([
|
|
32
|
+
asyncGlob(partialsGlob, { absolute: true }),
|
|
33
|
+
asyncGlob(blocksGlob, { absolute: true }),
|
|
34
|
+
]);
|
|
35
|
+
const allPaths = [...partialPaths, ...blockPaths];
|
|
36
|
+
const results = [];
|
|
37
|
+
for (const absolutePath of allPaths) {
|
|
38
|
+
const uri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(absolutePath));
|
|
39
|
+
// Double-check this file supports doc blocks
|
|
40
|
+
if (!(0, platformos_check_common_1.filePathSupportsLiquidDoc)(uri))
|
|
41
|
+
continue;
|
|
42
|
+
// Read and parse the file
|
|
43
|
+
const source = await promises_1.default.readFile(absolutePath, 'utf8');
|
|
44
|
+
const sourceCode = (0, platformos_check_common_1.toSourceCode)(uri, source);
|
|
45
|
+
if (!sourceCode || sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
|
|
46
|
+
continue;
|
|
47
|
+
const ast = sourceCode.ast;
|
|
48
|
+
if (!(0, liquid_html_parser_1.isLiquidHtmlNode)(ast))
|
|
49
|
+
continue;
|
|
50
|
+
// Generate doc block
|
|
51
|
+
const docResult = await (0, platformos_check_common_1.generateDocBlock)(ast, uri, themeLiquidDocsManager);
|
|
52
|
+
const relativePath = node_path_1.default.relative(root, absolutePath);
|
|
53
|
+
const result = {
|
|
54
|
+
uri,
|
|
55
|
+
relativePath,
|
|
56
|
+
parameters: docResult.parameters,
|
|
57
|
+
docBlockText: docResult.docBlockText,
|
|
58
|
+
hasExistingDocBlock: docResult.hasExistingDocBlock,
|
|
59
|
+
updated: false,
|
|
60
|
+
};
|
|
61
|
+
// Skip files that already have doc blocks
|
|
62
|
+
if (docResult.hasExistingDocBlock) {
|
|
63
|
+
results.push(result);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Skip files with no detected parameters
|
|
67
|
+
if (docResult.parameters.length === 0) {
|
|
68
|
+
results.push(result);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// If not dry run and output is inline, write the doc block to the file
|
|
72
|
+
if (!dryRun && output === 'inline') {
|
|
73
|
+
const newSource = docResult.docBlockText + '\n\n' + source;
|
|
74
|
+
await promises_1.default.writeFile(absolutePath, newSource, 'utf8');
|
|
75
|
+
result.updated = true;
|
|
76
|
+
}
|
|
77
|
+
results.push(result);
|
|
78
|
+
}
|
|
79
|
+
// Output based on mode
|
|
80
|
+
if (output === 'stdout') {
|
|
81
|
+
for (const result of results) {
|
|
82
|
+
if (result.hasExistingDocBlock) {
|
|
83
|
+
console.log(`[SKIP] ${result.relativePath} - already has doc block`);
|
|
84
|
+
}
|
|
85
|
+
else if (result.parameters.length === 0) {
|
|
86
|
+
console.log(`[SKIP] ${result.relativePath} - no parameters detected`);
|
|
87
|
+
}
|
|
88
|
+
else if (dryRun) {
|
|
89
|
+
console.log(`[DRY-RUN] ${result.relativePath}`);
|
|
90
|
+
console.log(result.docBlockText);
|
|
91
|
+
console.log('');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.log(`[UPDATED] ${result.relativePath}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (output === 'json') {
|
|
99
|
+
console.log(JSON.stringify(results, null, 2));
|
|
100
|
+
}
|
|
101
|
+
return results;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Generate doc block for a single file.
|
|
105
|
+
*/
|
|
106
|
+
async function generateDocForFile(absolutePath, options = {}) {
|
|
107
|
+
const { dryRun = false } = options;
|
|
108
|
+
const uri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(absolutePath));
|
|
109
|
+
if (!(0, platformos_check_common_1.filePathSupportsLiquidDoc)(uri)) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const themeLiquidDocsManager = new platformos_check_docs_updater_1.ThemeLiquidDocsManager(console.error.bind(console));
|
|
113
|
+
const source = await promises_1.default.readFile(absolutePath, 'utf8');
|
|
114
|
+
const sourceCode = (0, platformos_check_common_1.toSourceCode)(uri, source);
|
|
115
|
+
if (!sourceCode || sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
|
|
116
|
+
return null;
|
|
117
|
+
const ast = sourceCode.ast;
|
|
118
|
+
if (!(0, liquid_html_parser_1.isLiquidHtmlNode)(ast))
|
|
119
|
+
return null;
|
|
120
|
+
const docResult = await (0, platformos_check_common_1.generateDocBlock)(ast, uri, themeLiquidDocsManager);
|
|
121
|
+
const result = {
|
|
122
|
+
uri,
|
|
123
|
+
relativePath: absolutePath,
|
|
124
|
+
parameters: docResult.parameters,
|
|
125
|
+
docBlockText: docResult.docBlockText,
|
|
126
|
+
hasExistingDocBlock: docResult.hasExistingDocBlock,
|
|
127
|
+
updated: false,
|
|
128
|
+
};
|
|
129
|
+
if (!docResult.hasExistingDocBlock && docResult.parameters.length > 0 && !dryRun) {
|
|
130
|
+
const newSource = docResult.docBlockText + '\n\n' + source;
|
|
131
|
+
await promises_1.default.writeFile(absolutePath, newSource, 'utf8');
|
|
132
|
+
result.updated = true;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=generate-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateDocsCommand, generateDocForFile, GenerateDocsOptions, GenerateDocsResult, } from './generate-docs';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDocForFile = exports.generateDocsCommand = void 0;
|
|
4
|
+
var generate_docs_1 = require("./generate-docs");
|
|
5
|
+
Object.defineProperty(exports, "generateDocsCommand", { enumerable: true, get: function () { return generate_docs_1.generateDocsCommand; } });
|
|
6
|
+
Object.defineProperty(exports, "generateDocForFile", { enumerable: true, get: function () { return generate_docs_1.generateDocForFile; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -33,7 +33,6 @@ async function loadConfigDescription(configDescription, root) {
|
|
|
33
33
|
const rootUri = vscode_uri_1.URI.file(root);
|
|
34
34
|
return {
|
|
35
35
|
settings: unaliasedSettings(configDescription.checkSettings, checks),
|
|
36
|
-
context: configDescription.context ?? 'theme',
|
|
37
36
|
checks,
|
|
38
37
|
ignore: configDescription.ignore,
|
|
39
38
|
rootUri: resolveRoot(rootUri, configDescription.root),
|
|
@@ -8,7 +8,7 @@ function loadThirdPartyChecks(
|
|
|
8
8
|
* An array of require()-able paths.
|
|
9
9
|
* @example
|
|
10
10
|
* [
|
|
11
|
-
* '@acme/
|
|
11
|
+
* '@acme/platformos-check-extension',
|
|
12
12
|
* '/absolute/path/to/checks.js',
|
|
13
13
|
* './lib/checks.js',
|
|
14
14
|
* ]
|
|
@@ -39,14 +39,14 @@ modulePaths = []) {
|
|
|
39
39
|
}
|
|
40
40
|
async function findThirdPartyChecks(nodeModuleRoot) {
|
|
41
41
|
const paths = [
|
|
42
|
-
globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/
|
|
43
|
-
globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/@*/
|
|
42
|
+
globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/platformos-check-*/'),
|
|
43
|
+
globJoin(nodeModuleRoot.replace(/\\/g, '/'), '/node_modules/@*/platformos-check-*/'),
|
|
44
44
|
];
|
|
45
45
|
const results = await Promise.all(paths.map((path) => (0, glob_1.glob)(path)));
|
|
46
46
|
return results
|
|
47
47
|
.flat()
|
|
48
|
-
.filter((x) => !/\@
|
|
49
|
-
!/
|
|
48
|
+
.filter((x) => !/\@platformos\/platformos-check-(node|common|browser|docs-updater)/.test(x) &&
|
|
49
|
+
!/platformos-check-vscode/.test(x));
|
|
50
50
|
}
|
|
51
51
|
function globJoin(...parts) {
|
|
52
52
|
return parts.flatMap((x) => x.replace(/\\/g, '/').replace(/\/+$/, '')).join('/');
|
|
@@ -25,8 +25,6 @@ function mergeFragments(baseConfigs, config) {
|
|
|
25
25
|
.map((b) => b.checkSettings)
|
|
26
26
|
.concat(config.checkSettings)
|
|
27
27
|
.reduce(mergeDeep),
|
|
28
|
-
// We use the last one defined, or default to 'theme'
|
|
29
|
-
context: selectLatest(baseConfigs.map((b) => b.context), config.context) ?? 'theme',
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
function selectLatest(base, curr) {
|
|
@@ -81,12 +81,6 @@ isRootConfig = false) {
|
|
|
81
81
|
else if (isRootConfig) {
|
|
82
82
|
config.extends = [resolveExtends(root, 'platformos-check:recommended')];
|
|
83
83
|
}
|
|
84
|
-
if (yamlFile.context) {
|
|
85
|
-
if (platformos_check_common_1.Modes.includes(yamlFile.context)) {
|
|
86
|
-
config.context = yamlFile.context;
|
|
87
|
-
}
|
|
88
|
-
delete yamlFile.context;
|
|
89
|
-
}
|
|
90
84
|
// legacy settings that screw up assumptions
|
|
91
85
|
if (yamlFile.include_categories)
|
|
92
86
|
delete yamlFile.include_categories;
|
|
@@ -143,7 +137,7 @@ pathLike) {
|
|
|
143
137
|
if (pathLike.startsWith('.')) {
|
|
144
138
|
return node_path_1.default.resolve(root, pathLike);
|
|
145
139
|
}
|
|
146
|
-
return (0, node_fs_1.realpathSync)(require.resolve(pathLike, { paths: getAncestorNodeModules(root) }));
|
|
140
|
+
return (0, node_fs_1.realpathSync)(require.resolve(/* webpackIgnore: true */ pathLike, { paths: getAncestorNodeModules(root) }));
|
|
147
141
|
}
|
|
148
142
|
/**
|
|
149
143
|
* Resolves the check settings. Will also camelCase the snake_case settings
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChecksSettings,
|
|
1
|
+
import { ChecksSettings, Severity } from '@platformos/platformos-check-common';
|
|
2
2
|
/**
|
|
3
3
|
* The pipeline goes like this:
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ import { ChecksSettings, Mode, Severity } from '@platformos/platformos-check-com
|
|
|
6
6
|
* -> ConfigFragment # an intermediate representation of the file
|
|
7
7
|
* -> ConfigFragment[] # the file and its extends
|
|
8
8
|
* -> ConfigDescription # the flattened config (no extends)
|
|
9
|
-
* -> Config # the
|
|
9
|
+
* -> Config # the platformos-check config
|
|
10
10
|
*
|
|
11
11
|
* Our goal is to support more than one config file format, so what we'll
|
|
12
12
|
* do is have one adapter per file format that outputs a ConfigFragment.
|
|
@@ -20,12 +20,10 @@ export interface ConfigFragment {
|
|
|
20
20
|
extends: string[];
|
|
21
21
|
require: string[];
|
|
22
22
|
checkSettings: ChecksSettings;
|
|
23
|
-
context?: Mode;
|
|
24
23
|
}
|
|
25
24
|
/** A ConfigDescription is a ConfigFragment that doesn't extend anything. */
|
|
26
|
-
export type ConfigDescription = Omit<ConfigFragment, 'extends'
|
|
25
|
+
export type ConfigDescription = Omit<ConfigFragment, 'extends'> & {
|
|
27
26
|
extends: [];
|
|
28
|
-
context: Mode;
|
|
29
27
|
};
|
|
30
28
|
export declare const ModernIdentifiers: readonly ["platformos-check:nothing", "platformos-check:recommended", "platformos-check:all"];
|
|
31
29
|
export type ModernIdentifier = (typeof ModernIdentifiers)[number];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, GraphQLSourceCode, JSONSourceCode, LiquidSourceCode, Offense,
|
|
1
|
+
import { Config, GraphQLSourceCode, JSONSourceCode, LiquidSourceCode, Offense, App, YAMLSourceCode } from '@platformos/platformos-check-common';
|
|
2
2
|
import { loadConfig as resolveConfig } from './config';
|
|
3
3
|
import { NodeFileSystem } from './NodeFileSystem';
|
|
4
4
|
export * from '@platformos/platformos-check-common';
|
|
@@ -6,18 +6,22 @@ export * from './config/types';
|
|
|
6
6
|
export { NodeFileSystem };
|
|
7
7
|
export { runBackfillDocsCLI } from './backfill-docs';
|
|
8
8
|
export declare const loadConfig: typeof resolveConfig;
|
|
9
|
-
export type
|
|
10
|
-
|
|
9
|
+
export type AppCheckRun = {
|
|
10
|
+
app: App;
|
|
11
11
|
config: Config;
|
|
12
12
|
offenses: Offense[];
|
|
13
13
|
};
|
|
14
|
-
export declare function toSourceCode(absolutePath: string): Promise<LiquidSourceCode | JSONSourceCode | GraphQLSourceCode | undefined>;
|
|
14
|
+
export declare function toSourceCode(absolutePath: string): Promise<LiquidSourceCode | JSONSourceCode | GraphQLSourceCode | YAMLSourceCode | undefined>;
|
|
15
15
|
export declare function check(root: string, configPath?: string): Promise<Offense[]>;
|
|
16
16
|
export declare function checkAndAutofix(root: string, configPath?: string): Promise<void>;
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
|
|
17
|
+
export declare function appCheckRun(root: string, configPath?: string, log?: (message: string) => void): Promise<AppCheckRun>;
|
|
18
|
+
export declare function getAppAndConfig(root: string, configPath?: string): Promise<{
|
|
19
|
+
app: App;
|
|
20
20
|
config: Config;
|
|
21
21
|
}>;
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
22
|
+
export declare function getApp(config: Config): Promise<App>;
|
|
23
|
+
export declare function getAppFilesPathPattern(rootUri: string): string;
|
|
24
|
+
/** @deprecated Use appCheckRun instead */
|
|
25
|
+
export declare const runCheck: typeof appCheckRun;
|
|
26
|
+
/** @deprecated Use appCheckRun instead */
|
|
27
|
+
export declare const themeCheckRun: typeof appCheckRun;
|
package/dist/index.js
CHANGED
|
@@ -17,14 +17,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.loadConfig = exports.runBackfillDocsCLI = exports.NodeFileSystem = void 0;
|
|
20
|
+
exports.themeCheckRun = exports.runCheck = exports.loadConfig = exports.runBackfillDocsCLI = exports.NodeFileSystem = void 0;
|
|
21
21
|
exports.toSourceCode = toSourceCode;
|
|
22
22
|
exports.check = check;
|
|
23
23
|
exports.checkAndAutofix = checkAndAutofix;
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
24
|
+
exports.appCheckRun = appCheckRun;
|
|
25
|
+
exports.getAppAndConfig = getAppAndConfig;
|
|
26
|
+
exports.getApp = getApp;
|
|
27
|
+
exports.getAppFilesPathPattern = getAppFilesPathPattern;
|
|
28
28
|
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
29
29
|
const platformos_check_docs_updater_1 = require("@platformos/platformos-check-docs-updater");
|
|
30
30
|
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
@@ -56,50 +56,18 @@ async function toSourceCode(absolutePath) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
async function check(root, configPath) {
|
|
59
|
-
const run = await
|
|
59
|
+
const run = await appCheckRun(root, configPath);
|
|
60
60
|
return run.offenses;
|
|
61
61
|
}
|
|
62
62
|
async function checkAndAutofix(root, configPath) {
|
|
63
|
-
const {
|
|
64
|
-
await (0, autofix_1.autofix)(
|
|
63
|
+
const { app, offenses } = await appCheckRun(root, configPath);
|
|
64
|
+
await (0, autofix_1.autofix)(app, offenses);
|
|
65
65
|
}
|
|
66
|
-
async function
|
|
67
|
-
const {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Ultimately, I want to be able to have type safety on the parsed content
|
|
72
|
-
// of the {% schema %} tags if the schema is known to be valid. This should make
|
|
73
|
-
// {% schema %} related theme checks much easier to write than having to write visitor
|
|
74
|
-
// code and doing null checks all over the place. `ThemeBlock.Schema` is much more specific
|
|
75
|
-
// than `any` ever could be.
|
|
76
|
-
//
|
|
77
|
-
// I also want to have the option of passing down the getSectionSchema &
|
|
78
|
-
// getBlockSchema functions as dependencies. This will enable me to cache the
|
|
79
|
-
// results in the language server and avoid redoing validation between runs if
|
|
80
|
-
// we know the schema of a file that didn't change is valid.
|
|
81
|
-
//
|
|
82
|
-
// The crux of my problem is that I want to be passing down the json validation set
|
|
83
|
-
// as dependencies and not a full blown language service. But the easiest way
|
|
84
|
-
// is to have a `isValidSchema` is to have the language service do the
|
|
85
|
-
// validation of the JSON schema... We're technically going to have two
|
|
86
|
-
// JSONValidator running in theme check (node). We already have two in the
|
|
87
|
-
// language server.
|
|
88
|
-
const validator = await platformos_check_common_1.JSONValidator.create(themeLiquidDocsManager, config);
|
|
89
|
-
const isValidSchema = validator?.isValid;
|
|
90
|
-
// We can assume that all files are loaded when running themeCheckRun
|
|
91
|
-
const schemas = theme.map((source) => (0, platformos_check_common_1.toSchema)(config.context, source.uri, source, isValidSchema));
|
|
92
|
-
// prettier-ignore
|
|
93
|
-
const blockSchemas = new Map(theme.filter(source => (0, platformos_check_common_1.isBlock)(source.uri)).map((source) => [
|
|
94
|
-
node_path_1.default.basename(source.uri, '.liquid'),
|
|
95
|
-
(0, platformos_check_common_1.memo)(async () => (0, platformos_check_common_1.toSchema)(config.context, source.uri, source, isValidSchema))
|
|
96
|
-
]));
|
|
97
|
-
// prettier-ignore
|
|
98
|
-
const sectionSchemas = new Map(theme.filter(source => (0, platformos_check_common_1.isSection)(source.uri)).map((source) => [
|
|
99
|
-
node_path_1.default.basename(source.uri, '.liquid'),
|
|
100
|
-
(0, platformos_check_common_1.memo)(async () => (0, platformos_check_common_1.toSchema)(config.context, source.uri, source, isValidSchema))
|
|
101
|
-
]));
|
|
102
|
-
const docDefinitions = new Map(theme.map((file) => [
|
|
66
|
+
async function appCheckRun(root, configPath, log = () => { }) {
|
|
67
|
+
const { app, config } = await getAppAndConfig(root, configPath);
|
|
68
|
+
const platformOSLiquidDocsManager = new platformos_check_docs_updater_1.PlatformOSLiquidDocsManager(log);
|
|
69
|
+
const validator = await platformos_check_common_1.JSONValidator.create(platformOSLiquidDocsManager, config);
|
|
70
|
+
const docDefinitions = new Map(app.map((file) => [
|
|
103
71
|
node_path_1.default.relative(vscode_uri_1.URI.file(root).toString(), file.uri),
|
|
104
72
|
(0, platformos_check_common_1.memo)(async () => {
|
|
105
73
|
const ast = file.ast;
|
|
@@ -112,47 +80,52 @@ async function themeCheckRun(root, configPath, log = () => { }) {
|
|
|
112
80
|
return (0, platformos_check_common_1.extractDocDefinition)(file.uri, ast);
|
|
113
81
|
}),
|
|
114
82
|
]));
|
|
115
|
-
const offenses = await (0, platformos_check_common_1.check)(
|
|
83
|
+
const offenses = await (0, platformos_check_common_1.check)(app, config, {
|
|
116
84
|
fs: NodeFileSystem_1.NodeFileSystem,
|
|
117
|
-
|
|
118
|
-
jsonValidationSet:
|
|
119
|
-
// This is kind of gross, but we want those things to be lazy and called by name so...
|
|
120
|
-
// In the language server, this is memo'ed in DocumentManager, but we don't have that kind
|
|
121
|
-
// of luxury in CLI-mode.
|
|
122
|
-
getSectionSchema: async (name) => sectionSchemas.get(name)?.(),
|
|
123
|
-
getBlockSchema: async (name) => blockSchemas.get(name)?.(),
|
|
124
|
-
getAppBlockSchema: async (name) => blockSchemas.get(name)?.(), // cheating... but TODO
|
|
85
|
+
platformosDocset: platformOSLiquidDocsManager,
|
|
86
|
+
jsonValidationSet: platformOSLiquidDocsManager,
|
|
125
87
|
getDocDefinition: async (relativePath) => docDefinitions.get(relativePath)?.(),
|
|
126
88
|
});
|
|
127
89
|
return {
|
|
128
|
-
|
|
90
|
+
app,
|
|
129
91
|
config,
|
|
130
92
|
offenses,
|
|
131
93
|
};
|
|
132
94
|
}
|
|
133
|
-
async function
|
|
95
|
+
async function getAppAndConfig(root, configPath) {
|
|
134
96
|
const config = await (0, exports.loadConfig)(configPath, root);
|
|
135
|
-
const
|
|
97
|
+
const app = await getApp(config);
|
|
136
98
|
return {
|
|
137
|
-
|
|
99
|
+
app,
|
|
138
100
|
config,
|
|
139
101
|
};
|
|
140
102
|
}
|
|
141
|
-
async function
|
|
103
|
+
async function getApp(config) {
|
|
142
104
|
// On windows machines - the separator provided by path.join is '\'
|
|
143
105
|
// however the glob function fails silently since '\' is used to escape glob charater
|
|
144
106
|
// as mentioned in the documentation of node-glob
|
|
145
107
|
// the path is normalised and '\' are replaced with '/' and then passed to the glob function
|
|
146
|
-
let normalizedGlob =
|
|
147
|
-
const paths = await (0, glob_1.glob)(normalizedGlob, { absolute: true }).then((result) =>
|
|
148
|
-
|
|
149
|
-
|
|
108
|
+
let normalizedGlob = getAppFilesPathPattern(config.rootUri);
|
|
109
|
+
const paths = await (0, glob_1.glob)(normalizedGlob, { absolute: true }).then((result) => result.filter((filePath) => {
|
|
110
|
+
// Global ignored paths should not be part of the app
|
|
111
|
+
if ((0, platformos_check_common_1.isIgnored)(filePath, config))
|
|
112
|
+
return false;
|
|
113
|
+
// Only lint .liquid files that belong to a recognized platformOS directory.
|
|
114
|
+
// Generator templates, build artifacts, etc. are excluded.
|
|
115
|
+
if (filePath.endsWith('.liquid') && !(0, platformos_check_common_1.isKnownLiquidFile)(filePath))
|
|
116
|
+
return false;
|
|
117
|
+
return true;
|
|
118
|
+
}));
|
|
150
119
|
const sourceCodes = await Promise.all(paths.map(toSourceCode));
|
|
151
120
|
return sourceCodes.filter((x) => x !== undefined);
|
|
152
121
|
}
|
|
153
|
-
function
|
|
122
|
+
function getAppFilesPathPattern(rootUri) {
|
|
154
123
|
return node_path_1.default
|
|
155
|
-
.normalize(node_path_1.default.join((0, node_url_1.fileURLToPath)(rootUri), '**/*.{liquid,json,graphql}'))
|
|
124
|
+
.normalize(node_path_1.default.join((0, node_url_1.fileURLToPath)(rootUri), '**/*.{liquid,json,graphql,yml,yaml}'))
|
|
156
125
|
.replace(/\\/g, '/');
|
|
157
126
|
}
|
|
127
|
+
/** @deprecated Use appCheckRun instead */
|
|
128
|
+
exports.runCheck = appCheckRun;
|
|
129
|
+
/** @deprecated Use appCheckRun instead */
|
|
130
|
+
exports.themeCheckRun = appCheckRun;
|
|
158
131
|
//# sourceMappingURL=index.js.map
|
|
@@ -21,7 +21,7 @@ async function makeTmpFolder() {
|
|
|
21
21
|
async function removeTmpFolder(tempDir) {
|
|
22
22
|
return promises_1.default.rm(tempDir, { recursive: true, force: true });
|
|
23
23
|
}
|
|
24
|
-
async function createMockConfigFile(tempDir, contents = 'dummy content', relativePath = '.
|
|
24
|
+
async function createMockConfigFile(tempDir, contents = 'dummy content', relativePath = '.platformos-check.yml') {
|
|
25
25
|
const filePath = node_path_1.default.join(tempDir, relativePath);
|
|
26
26
|
await promises_1.default.writeFile(filePath, contents, 'utf8');
|
|
27
27
|
return filePath;
|
|
@@ -57,7 +57,7 @@ async function createMockNodeModule(tempDir, moduleName, moduleContent = exports
|
|
|
57
57
|
return nodeModuleRoot;
|
|
58
58
|
}
|
|
59
59
|
async function makeTempWorkspace(structure) {
|
|
60
|
-
const root = await promises_1.default.mkdtemp(node_path_1.default.join(
|
|
60
|
+
const root = await promises_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'platformos-check-'));
|
|
61
61
|
if (!root)
|
|
62
62
|
throw new Error('Could not create temp dir for temp workspace');
|
|
63
63
|
await createFiles(structure, [root]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/platformos-check-node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "platformOS",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"type-check": "tsc --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@platformos/platformos-check-common": "0.0.
|
|
37
|
-
"@platformos/platformos-check-docs-updater": "0.0.
|
|
36
|
+
"@platformos/platformos-check-common": "0.0.9",
|
|
37
|
+
"@platformos/platformos-check-docs-updater": "0.0.9",
|
|
38
38
|
"glob": "^13.0.0",
|
|
39
39
|
"vscode-uri": "^3.1.0",
|
|
40
40
|
"yaml": "^2.8.2"
|