@platformos/platformos-check-node 0.0.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/README.md +9 -0
- package/configs/all.yml +214 -0
- package/configs/nothing.yml +3 -0
- package/configs/recommended.yml +192 -0
- package/dist/NodeFileSystem.d.ts +2 -0
- package/dist/NodeFileSystem.js +37 -0
- package/dist/autofix.d.ts +6 -0
- package/dist/autofix.js +18 -0
- package/dist/backfill-docs/argument-collector.d.ts +6 -0
- package/dist/backfill-docs/argument-collector.js +167 -0
- package/dist/backfill-docs/doc-generator.d.ts +18 -0
- package/dist/backfill-docs/doc-generator.js +31 -0
- package/dist/backfill-docs/doc-updater.d.ts +13 -0
- package/dist/backfill-docs/doc-updater.js +154 -0
- package/dist/backfill-docs/index.d.ts +14 -0
- package/dist/backfill-docs/index.js +233 -0
- package/dist/backfill-docs/types.d.ts +32 -0
- package/dist/backfill-docs/types.js +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +47 -0
- 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/find-config-path.d.ts +1 -0
- package/dist/config/find-config-path.js +22 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +8 -0
- package/dist/config/installation-location.d.ts +1 -0
- package/dist/config/installation-location.js +20 -0
- package/dist/config/load-config-description.d.ts +10 -0
- package/dist/config/load-config-description.js +97 -0
- package/dist/config/load-config.d.ts +18 -0
- package/dist/config/load-config.js +30 -0
- package/dist/config/load-third-party-checks.d.ts +16 -0
- package/dist/config/load-third-party-checks.js +69 -0
- package/dist/config/resolve/index.d.ts +1 -0
- package/dist/config/resolve/index.js +6 -0
- package/dist/config/resolve/merge-fragments.d.ts +11 -0
- package/dist/config/resolve/merge-fragments.js +52 -0
- package/dist/config/resolve/read-yaml.d.ts +11 -0
- package/dist/config/resolve/read-yaml.js +205 -0
- package/dist/config/resolve/resolve-config.d.ts +8 -0
- package/dist/config/resolve/resolve-config.js +37 -0
- package/dist/config/types.d.ts +35 -0
- package/dist/config/types.js +19 -0
- package/dist/config/validation.d.ts +2 -0
- package/dist/config/validation.js +85 -0
- package/dist/file-utils.d.ts +1 -0
- package/dist/file-utils.js +17 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +160 -0
- package/dist/temp.d.ts +2 -0
- package/dist/temp.js +3 -0
- package/dist/test/test-helpers.d.ts +14 -0
- package/dist/test/test-helpers.js +119 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `@platformos/theme-check-node`
|
|
2
|
+
|
|
3
|
+
This is the Node.js wrapper of the runtime-agnostic [`@platformos/theme-check-common`](https://npm.im/@platformos/theme-check-common) package. It comes with batteries included.
|
|
4
|
+
|
|
5
|
+
See the [@platformos/theme-check-common README](../theme-check-common) for more details.
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
MIT.
|
package/configs/all.yml
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# WARNING:
|
|
2
|
+
# This file was generated automatically by running "scripts/generate-factory-configs"
|
|
3
|
+
# Do not modify manually. Your changes will be overwritten.
|
|
4
|
+
ignore:
|
|
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
|
+
DeprecatedFilter:
|
|
47
|
+
enabled: true
|
|
48
|
+
severity: 1
|
|
49
|
+
DeprecatedFontsOnSectionsAndBlocks:
|
|
50
|
+
enabled: true
|
|
51
|
+
severity: 1
|
|
52
|
+
DeprecatedFontsOnSettingsSchema:
|
|
53
|
+
enabled: true
|
|
54
|
+
severity: 1
|
|
55
|
+
DeprecatedTag:
|
|
56
|
+
enabled: true
|
|
57
|
+
severity: 1
|
|
58
|
+
DuplicateContentForArguments:
|
|
59
|
+
enabled: true
|
|
60
|
+
severity: 1
|
|
61
|
+
DuplicateRenderPartialArguments:
|
|
62
|
+
enabled: true
|
|
63
|
+
severity: 1
|
|
64
|
+
EmptyBlockContent:
|
|
65
|
+
enabled: true
|
|
66
|
+
severity: 1
|
|
67
|
+
GraphQLCheck:
|
|
68
|
+
enabled: true
|
|
69
|
+
severity: 0
|
|
70
|
+
GraphQLVariablesCheck:
|
|
71
|
+
enabled: true
|
|
72
|
+
severity: 0
|
|
73
|
+
HardcodedRoutes:
|
|
74
|
+
enabled: true
|
|
75
|
+
severity: 1
|
|
76
|
+
ImgWidthAndHeight:
|
|
77
|
+
enabled: true
|
|
78
|
+
severity: 0
|
|
79
|
+
InvalidHashAssignTarget:
|
|
80
|
+
enabled: true
|
|
81
|
+
severity: 0
|
|
82
|
+
JSONMissingBlock:
|
|
83
|
+
enabled: true
|
|
84
|
+
severity: 0
|
|
85
|
+
JSONSyntaxError:
|
|
86
|
+
enabled: true
|
|
87
|
+
severity: 0
|
|
88
|
+
LiquidFreeSettings:
|
|
89
|
+
enabled: true
|
|
90
|
+
severity: 1
|
|
91
|
+
LiquidHTMLSyntaxError:
|
|
92
|
+
enabled: true
|
|
93
|
+
severity: 0
|
|
94
|
+
MatchingTranslations:
|
|
95
|
+
enabled: true
|
|
96
|
+
severity: 0
|
|
97
|
+
MetadataParamsCheck:
|
|
98
|
+
enabled: true
|
|
99
|
+
severity: 0
|
|
100
|
+
MissingAsset:
|
|
101
|
+
enabled: true
|
|
102
|
+
severity: 0
|
|
103
|
+
MissingContentForArguments:
|
|
104
|
+
enabled: true
|
|
105
|
+
severity: 1
|
|
106
|
+
MissingTemplate:
|
|
107
|
+
enabled: true
|
|
108
|
+
severity: 0
|
|
109
|
+
ignoreMissing: []
|
|
110
|
+
OrphanedPartial:
|
|
111
|
+
enabled: true
|
|
112
|
+
severity: 1
|
|
113
|
+
PaginationSize:
|
|
114
|
+
enabled: true
|
|
115
|
+
severity: 1
|
|
116
|
+
minSize: 1
|
|
117
|
+
maxSize: 250
|
|
118
|
+
ParserBlockingScript:
|
|
119
|
+
enabled: true
|
|
120
|
+
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
|
+
TranslationKeyExists:
|
|
137
|
+
enabled: true
|
|
138
|
+
severity: 0
|
|
139
|
+
UnclosedHTMLElement:
|
|
140
|
+
enabled: true
|
|
141
|
+
severity: 1
|
|
142
|
+
UndefinedObject:
|
|
143
|
+
enabled: true
|
|
144
|
+
severity: 1
|
|
145
|
+
UniqueDocParamNames:
|
|
146
|
+
enabled: true
|
|
147
|
+
severity: 0
|
|
148
|
+
UniqueSettingId:
|
|
149
|
+
enabled: true
|
|
150
|
+
severity: 0
|
|
151
|
+
UniqueStaticBlockId:
|
|
152
|
+
enabled: true
|
|
153
|
+
severity: 0
|
|
154
|
+
UnknownFilter:
|
|
155
|
+
enabled: true
|
|
156
|
+
severity: 0
|
|
157
|
+
UnknownProperty:
|
|
158
|
+
enabled: true
|
|
159
|
+
severity: 0
|
|
160
|
+
UnrecognizedContentForArguments:
|
|
161
|
+
enabled: true
|
|
162
|
+
severity: 1
|
|
163
|
+
UnrecognizedRenderPartialArguments:
|
|
164
|
+
enabled: true
|
|
165
|
+
severity: 1
|
|
166
|
+
UnusedAssign:
|
|
167
|
+
enabled: true
|
|
168
|
+
severity: 1
|
|
169
|
+
UnusedDocParam:
|
|
170
|
+
enabled: true
|
|
171
|
+
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
|
+
ValidDocParamTypes:
|
|
182
|
+
enabled: true
|
|
183
|
+
severity: 0
|
|
184
|
+
ValidHTMLTranslation:
|
|
185
|
+
enabled: true
|
|
186
|
+
severity: 1
|
|
187
|
+
ValidJSON:
|
|
188
|
+
enabled: true
|
|
189
|
+
severity: 0
|
|
190
|
+
ValidLocalBlocks:
|
|
191
|
+
enabled: true
|
|
192
|
+
severity: 0
|
|
193
|
+
ValidRenderPartialArgumentTypes:
|
|
194
|
+
enabled: true
|
|
195
|
+
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
|
+
VariableName:
|
|
212
|
+
enabled: true
|
|
213
|
+
severity: 1
|
|
214
|
+
format: snake_case
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# WARNING:
|
|
2
|
+
# This file was generated automatically by running "scripts/generate-factory-configs"
|
|
3
|
+
# Do not modify manually. Your changes will be overwritten.
|
|
4
|
+
ignore:
|
|
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
|
+
DeprecatedFilter:
|
|
25
|
+
enabled: true
|
|
26
|
+
severity: 1
|
|
27
|
+
DeprecatedFontsOnSectionsAndBlocks:
|
|
28
|
+
enabled: true
|
|
29
|
+
severity: 1
|
|
30
|
+
DeprecatedFontsOnSettingsSchema:
|
|
31
|
+
enabled: true
|
|
32
|
+
severity: 1
|
|
33
|
+
DeprecatedTag:
|
|
34
|
+
enabled: true
|
|
35
|
+
severity: 1
|
|
36
|
+
DuplicateContentForArguments:
|
|
37
|
+
enabled: true
|
|
38
|
+
severity: 1
|
|
39
|
+
DuplicateRenderPartialArguments:
|
|
40
|
+
enabled: true
|
|
41
|
+
severity: 1
|
|
42
|
+
EmptyBlockContent:
|
|
43
|
+
enabled: true
|
|
44
|
+
severity: 1
|
|
45
|
+
GraphQLCheck:
|
|
46
|
+
enabled: true
|
|
47
|
+
severity: 0
|
|
48
|
+
GraphQLVariablesCheck:
|
|
49
|
+
enabled: true
|
|
50
|
+
severity: 0
|
|
51
|
+
HardcodedRoutes:
|
|
52
|
+
enabled: true
|
|
53
|
+
severity: 1
|
|
54
|
+
ImgWidthAndHeight:
|
|
55
|
+
enabled: true
|
|
56
|
+
severity: 0
|
|
57
|
+
InvalidHashAssignTarget:
|
|
58
|
+
enabled: true
|
|
59
|
+
severity: 0
|
|
60
|
+
JSONMissingBlock:
|
|
61
|
+
enabled: true
|
|
62
|
+
severity: 0
|
|
63
|
+
JSONSyntaxError:
|
|
64
|
+
enabled: true
|
|
65
|
+
severity: 0
|
|
66
|
+
LiquidFreeSettings:
|
|
67
|
+
enabled: true
|
|
68
|
+
severity: 1
|
|
69
|
+
LiquidHTMLSyntaxError:
|
|
70
|
+
enabled: true
|
|
71
|
+
severity: 0
|
|
72
|
+
MatchingTranslations:
|
|
73
|
+
enabled: true
|
|
74
|
+
severity: 0
|
|
75
|
+
MetadataParamsCheck:
|
|
76
|
+
enabled: true
|
|
77
|
+
severity: 0
|
|
78
|
+
MissingAsset:
|
|
79
|
+
enabled: true
|
|
80
|
+
severity: 0
|
|
81
|
+
MissingContentForArguments:
|
|
82
|
+
enabled: true
|
|
83
|
+
severity: 1
|
|
84
|
+
MissingTemplate:
|
|
85
|
+
enabled: true
|
|
86
|
+
severity: 0
|
|
87
|
+
ignoreMissing: []
|
|
88
|
+
OrphanedPartial:
|
|
89
|
+
enabled: true
|
|
90
|
+
severity: 1
|
|
91
|
+
PaginationSize:
|
|
92
|
+
enabled: true
|
|
93
|
+
severity: 1
|
|
94
|
+
minSize: 1
|
|
95
|
+
maxSize: 250
|
|
96
|
+
ParserBlockingScript:
|
|
97
|
+
enabled: true
|
|
98
|
+
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
|
+
TranslationKeyExists:
|
|
115
|
+
enabled: true
|
|
116
|
+
severity: 0
|
|
117
|
+
UnclosedHTMLElement:
|
|
118
|
+
enabled: true
|
|
119
|
+
severity: 1
|
|
120
|
+
UndefinedObject:
|
|
121
|
+
enabled: true
|
|
122
|
+
severity: 1
|
|
123
|
+
UniqueDocParamNames:
|
|
124
|
+
enabled: true
|
|
125
|
+
severity: 0
|
|
126
|
+
UniqueSettingId:
|
|
127
|
+
enabled: true
|
|
128
|
+
severity: 0
|
|
129
|
+
UniqueStaticBlockId:
|
|
130
|
+
enabled: true
|
|
131
|
+
severity: 0
|
|
132
|
+
UnknownFilter:
|
|
133
|
+
enabled: true
|
|
134
|
+
severity: 0
|
|
135
|
+
UnknownProperty:
|
|
136
|
+
enabled: true
|
|
137
|
+
severity: 0
|
|
138
|
+
UnrecognizedContentForArguments:
|
|
139
|
+
enabled: true
|
|
140
|
+
severity: 1
|
|
141
|
+
UnrecognizedRenderPartialArguments:
|
|
142
|
+
enabled: true
|
|
143
|
+
severity: 1
|
|
144
|
+
UnusedAssign:
|
|
145
|
+
enabled: true
|
|
146
|
+
severity: 1
|
|
147
|
+
UnusedDocParam:
|
|
148
|
+
enabled: true
|
|
149
|
+
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
|
+
ValidDocParamTypes:
|
|
160
|
+
enabled: true
|
|
161
|
+
severity: 0
|
|
162
|
+
ValidHTMLTranslation:
|
|
163
|
+
enabled: true
|
|
164
|
+
severity: 1
|
|
165
|
+
ValidJSON:
|
|
166
|
+
enabled: true
|
|
167
|
+
severity: 0
|
|
168
|
+
ValidLocalBlocks:
|
|
169
|
+
enabled: true
|
|
170
|
+
severity: 0
|
|
171
|
+
ValidRenderPartialArgumentTypes:
|
|
172
|
+
enabled: true
|
|
173
|
+
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
|
+
VariableName:
|
|
190
|
+
enabled: true
|
|
191
|
+
severity: 1
|
|
192
|
+
format: snake_case
|
|
@@ -0,0 +1,37 @@
|
|
|
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.NodeFileSystem = void 0;
|
|
7
|
+
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
8
|
+
const platformos_common_1 = require("@platformos/platformos-common");
|
|
9
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
10
|
+
exports.NodeFileSystem = {
|
|
11
|
+
async readFile(uri) {
|
|
12
|
+
// I'm intentionally leaving these comments here for debugging purposes :)
|
|
13
|
+
// console.error('fs/readFile', uri);
|
|
14
|
+
return promises_1.default.readFile(platformos_check_common_1.path.fsPath(uri), 'utf8');
|
|
15
|
+
},
|
|
16
|
+
async readDirectory(uri) {
|
|
17
|
+
// console.error('fs/readDirectory', uri);
|
|
18
|
+
const files = await promises_1.default.readdir(platformos_check_common_1.path.fsPath(uri), { withFileTypes: true });
|
|
19
|
+
return files.map((file) => {
|
|
20
|
+
return [platformos_check_common_1.path.join(uri, file.name), file.isDirectory() ? platformos_common_1.FileType.Directory : platformos_common_1.FileType.File];
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
async stat(uri) {
|
|
24
|
+
// console.error('fs/stat', uri);
|
|
25
|
+
try {
|
|
26
|
+
const stats = await promises_1.default.stat(platformos_check_common_1.path.fsPath(uri));
|
|
27
|
+
return {
|
|
28
|
+
type: stats.isDirectory() ? platformos_common_1.FileType.Directory : platformos_common_1.FileType.File,
|
|
29
|
+
size: stats.size,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
throw new Error(`Failed to get file stat: ${e}`);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=NodeFileSystem.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Offense, Theme, FixApplicator } from '@platformos/platformos-check-common';
|
|
2
|
+
export declare const saveToDiskFixApplicator: FixApplicator;
|
|
3
|
+
/**
|
|
4
|
+
* Apply and save to disk the safe fixes for a set of offenses on a theme.
|
|
5
|
+
*/
|
|
6
|
+
export declare function autofix(sourceCodes: Theme, offenses: Offense[]): Promise<void>;
|
package/dist/autofix.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveToDiskFixApplicator = void 0;
|
|
4
|
+
exports.autofix = autofix;
|
|
5
|
+
const promises_1 = require("fs/promises");
|
|
6
|
+
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
7
|
+
const saveToDiskFixApplicator = async (sourceCode, fix) => {
|
|
8
|
+
const updatedSource = (0, platformos_check_common_1.applyFixToString)(sourceCode.source, fix);
|
|
9
|
+
await (0, promises_1.writeFile)(platformos_check_common_1.path.fsPath(sourceCode.uri), updatedSource, 'utf8');
|
|
10
|
+
};
|
|
11
|
+
exports.saveToDiskFixApplicator = saveToDiskFixApplicator;
|
|
12
|
+
/**
|
|
13
|
+
* Apply and save to disk the safe fixes for a set of offenses on a theme.
|
|
14
|
+
*/
|
|
15
|
+
async function autofix(sourceCodes, offenses) {
|
|
16
|
+
await (0, platformos_check_common_1.autofix)(sourceCodes, offenses, exports.saveToDiskFixApplicator);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=autofix.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Theme } from '@platformos/platformos-check-common';
|
|
2
|
+
import { PartialUsage } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Collect all partial usages from a theme by visiting function, render, and include tags.
|
|
5
|
+
*/
|
|
6
|
+
export declare function collectPartialUsages(theme: Theme, verbose?: boolean, log?: (message: string) => void): Promise<Map<string, PartialUsage>>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectPartialUsages = collectPartialUsages;
|
|
4
|
+
const liquid_html_parser_1 = require("@platformos/liquid-html-parser");
|
|
5
|
+
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
6
|
+
const liquid_html_parser_2 = require("@platformos/liquid-html-parser");
|
|
7
|
+
/**
|
|
8
|
+
* Extract the partial name from a RenderMarkup or FunctionMarkup node.
|
|
9
|
+
* Returns undefined if the partial path is dynamic (VariableLookup).
|
|
10
|
+
*/
|
|
11
|
+
function getPartialName(node) {
|
|
12
|
+
if (node.type === liquid_html_parser_1.NodeTypes.RenderMarkup) {
|
|
13
|
+
if (node.snippet.type === liquid_html_parser_1.NodeTypes.String) {
|
|
14
|
+
return node.snippet.value;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (node.type === liquid_html_parser_1.NodeTypes.FunctionMarkup) {
|
|
19
|
+
if (node.partial.type === liquid_html_parser_1.NodeTypes.String) {
|
|
20
|
+
return node.partial.value;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Merge a new argument into the existing usage map.
|
|
28
|
+
* When the same argument has different types across calls, use 'object'.
|
|
29
|
+
*/
|
|
30
|
+
function mergeArgument(existingArgs, arg) {
|
|
31
|
+
const inferredType = (0, platformos_check_common_1.inferArgumentType)(arg.value);
|
|
32
|
+
const existing = existingArgs.get(arg.name);
|
|
33
|
+
if (existing) {
|
|
34
|
+
existing.usageCount++;
|
|
35
|
+
// If types differ, use 'object' as the fallback
|
|
36
|
+
if (existing.inferredType !== inferredType) {
|
|
37
|
+
existing.inferredType = platformos_check_common_1.BasicParamTypes.Object;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
existingArgs.set(arg.name, {
|
|
42
|
+
name: arg.name,
|
|
43
|
+
inferredType,
|
|
44
|
+
usageCount: 1,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a unique key for a partial that includes its tag type.
|
|
50
|
+
* This is needed because 'function' and 'render' tags search different directories.
|
|
51
|
+
*/
|
|
52
|
+
function makeUsageKey(partialPath, tagType) {
|
|
53
|
+
return `${tagType}:${partialPath}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse a usage key back into its components.
|
|
57
|
+
*/
|
|
58
|
+
function parseUsageKey(key) {
|
|
59
|
+
const colonIndex = key.indexOf(':');
|
|
60
|
+
return {
|
|
61
|
+
tagType: key.slice(0, colonIndex),
|
|
62
|
+
partialPath: key.slice(colonIndex + 1),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Collect all partial usages from a theme by visiting function, render, and include tags.
|
|
67
|
+
*/
|
|
68
|
+
async function collectPartialUsages(theme, verbose = false, log = console.log) {
|
|
69
|
+
const usageMap = new Map();
|
|
70
|
+
for (const sourceCode of theme) {
|
|
71
|
+
if (sourceCode.type !== platformos_check_common_1.SourceCodeType.LiquidHtml)
|
|
72
|
+
continue;
|
|
73
|
+
if (!(0, liquid_html_parser_2.isLiquidHtmlNode)(sourceCode.ast))
|
|
74
|
+
continue;
|
|
75
|
+
const ast = sourceCode.ast;
|
|
76
|
+
await (0, platformos_check_common_1.visit)(ast, {
|
|
77
|
+
async LiquidTag(node) {
|
|
78
|
+
// Handle function tags
|
|
79
|
+
if (node.name === 'function' && node.markup && typeof node.markup === 'object') {
|
|
80
|
+
const markup = node.markup;
|
|
81
|
+
if (markup.type !== liquid_html_parser_1.NodeTypes.FunctionMarkup)
|
|
82
|
+
return;
|
|
83
|
+
const partialPath = getPartialName(markup);
|
|
84
|
+
if (!partialPath) {
|
|
85
|
+
if (verbose) {
|
|
86
|
+
log(` [skip] Dynamic function path in ${sourceCode.uri}`);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const key = makeUsageKey(partialPath, 'function');
|
|
91
|
+
let usage = usageMap.get(key);
|
|
92
|
+
if (!usage) {
|
|
93
|
+
usage = {
|
|
94
|
+
partialPath,
|
|
95
|
+
tagType: 'function',
|
|
96
|
+
arguments: new Map(),
|
|
97
|
+
};
|
|
98
|
+
usageMap.set(key, usage);
|
|
99
|
+
}
|
|
100
|
+
for (const arg of markup.args) {
|
|
101
|
+
if (arg.type === liquid_html_parser_1.NodeTypes.NamedArgument) {
|
|
102
|
+
mergeArgument(usage.arguments, arg);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Handle render tags
|
|
107
|
+
if (node.name === 'render' && node.markup && typeof node.markup === 'object') {
|
|
108
|
+
const markup = node.markup;
|
|
109
|
+
if (markup.type !== liquid_html_parser_1.NodeTypes.RenderMarkup)
|
|
110
|
+
return;
|
|
111
|
+
const partialPath = getPartialName(markup);
|
|
112
|
+
if (!partialPath) {
|
|
113
|
+
if (verbose) {
|
|
114
|
+
log(` [skip] Dynamic render path in ${sourceCode.uri}`);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const key = makeUsageKey(partialPath, 'render');
|
|
119
|
+
let usage = usageMap.get(key);
|
|
120
|
+
if (!usage) {
|
|
121
|
+
usage = {
|
|
122
|
+
partialPath,
|
|
123
|
+
tagType: 'render',
|
|
124
|
+
arguments: new Map(),
|
|
125
|
+
};
|
|
126
|
+
usageMap.set(key, usage);
|
|
127
|
+
}
|
|
128
|
+
for (const arg of markup.args) {
|
|
129
|
+
if (arg.type === liquid_html_parser_1.NodeTypes.NamedArgument) {
|
|
130
|
+
mergeArgument(usage.arguments, arg);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Handle include tags (same markup type as render)
|
|
135
|
+
if (node.name === 'include' && node.markup && typeof node.markup === 'object') {
|
|
136
|
+
const markup = node.markup;
|
|
137
|
+
if (markup.type !== liquid_html_parser_1.NodeTypes.RenderMarkup)
|
|
138
|
+
return;
|
|
139
|
+
const partialPath = getPartialName(markup);
|
|
140
|
+
if (!partialPath) {
|
|
141
|
+
if (verbose) {
|
|
142
|
+
log(` [skip] Dynamic include path in ${sourceCode.uri}`);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const key = makeUsageKey(partialPath, 'include');
|
|
147
|
+
let usage = usageMap.get(key);
|
|
148
|
+
if (!usage) {
|
|
149
|
+
usage = {
|
|
150
|
+
partialPath,
|
|
151
|
+
tagType: 'include',
|
|
152
|
+
arguments: new Map(),
|
|
153
|
+
};
|
|
154
|
+
usageMap.set(key, usage);
|
|
155
|
+
}
|
|
156
|
+
for (const arg of markup.args) {
|
|
157
|
+
if (arg.type === liquid_html_parser_1.NodeTypes.NamedArgument) {
|
|
158
|
+
mergeArgument(usage.arguments, arg);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return usageMap;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=argument-collector.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BasicParamTypes } from '@platformos/platformos-check-common';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a single @param line for a doc tag.
|
|
4
|
+
*
|
|
5
|
+
* @param name - The parameter name
|
|
6
|
+
* @param type - The inferred type
|
|
7
|
+
* @param isOptional - Whether to mark as optional with brackets
|
|
8
|
+
* @returns A formatted @param line like "@param {string} [name]" or "@param {string} name"
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateParamLine(name: string, type: BasicParamTypes, isOptional?: boolean): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a complete doc tag with param lines.
|
|
13
|
+
*
|
|
14
|
+
* @param params - Array of param line strings (without leading whitespace)
|
|
15
|
+
* @param indentation - The indentation to use for each line (default: 2 spaces)
|
|
16
|
+
* @returns A complete doc tag string
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateDocTag(params: string[], indentation?: string): string;
|