@spwig/theme-validator 1.0.0 → 2.0.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/README.md +0 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/schemas/theme_manifest_schema.json +7 -65
- package/dist/types/manifest.d.ts +50 -82
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/manifest.js +1 -1
- package/dist/types/manifest.js.map +0 -0
- package/dist/types/validation-result.d.ts +0 -0
- package/dist/types/validation-result.d.ts.map +0 -0
- package/dist/types/validation-result.js +0 -0
- package/dist/types/validation-result.js.map +0 -0
- package/dist/validators/design-tokens-validator.d.ts +16 -0
- package/dist/validators/design-tokens-validator.d.ts.map +1 -1
- package/dist/validators/design-tokens-validator.js +208 -0
- package/dist/validators/design-tokens-validator.js.map +1 -1
- package/dist/validators/manifest-validator.d.ts +0 -0
- package/dist/validators/manifest-validator.d.ts.map +0 -0
- package/dist/validators/manifest-validator.js +0 -0
- package/dist/validators/manifest-validator.js.map +0 -0
- package/dist/validators/theme-validator.d.ts +11 -7
- package/dist/validators/theme-validator.d.ts.map +1 -1
- package/dist/validators/theme-validator.js +110 -84
- package/dist/validators/theme-validator.js.map +1 -1
- package/package.json +1 -1
- package/dist/schemas/component_manifest_schema.json +0 -221
- package/dist/validators/component-validator.d.ts +0 -50
- package/dist/validators/component-validator.d.ts.map +0 -1
- package/dist/validators/component-validator.js +0 -235
- package/dist/validators/component-validator.js.map +0 -1
- package/dist/validators/template-validator.d.ts +0 -34
- package/dist/validators/template-validator.d.ts.map +0 -1
- package/dist/validators/template-validator.js +0 -170
- package/dist/validators/template-validator.js.map +0 -1
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Component Manifest Schema",
|
|
4
|
-
"description": "Schema for Spwig component package manifests",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": [
|
|
7
|
-
"name",
|
|
8
|
-
"version",
|
|
9
|
-
"display_name",
|
|
10
|
-
"description",
|
|
11
|
-
"author",
|
|
12
|
-
"tier_compatibility",
|
|
13
|
-
"regions"
|
|
14
|
-
],
|
|
15
|
-
"properties": {
|
|
16
|
-
"name": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"pattern": "^[a-z][a-z0-9_]*$",
|
|
19
|
-
"minLength": 2,
|
|
20
|
-
"maxLength": 50,
|
|
21
|
-
"description": "Component identifier (lowercase, alphanumeric with underscores)"
|
|
22
|
-
},
|
|
23
|
-
"version": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
|
|
26
|
-
"description": "Semantic version (e.g., 1.0.0)"
|
|
27
|
-
},
|
|
28
|
-
"display_name": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"minLength": 1,
|
|
31
|
-
"maxLength": 100,
|
|
32
|
-
"description": "Human-readable component name"
|
|
33
|
-
},
|
|
34
|
-
"description": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"minLength": 10,
|
|
37
|
-
"maxLength": 500,
|
|
38
|
-
"description": "Component description for marketplace listing"
|
|
39
|
-
},
|
|
40
|
-
"author": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"minLength": 1,
|
|
43
|
-
"maxLength": 100,
|
|
44
|
-
"description": "Component author/vendor name"
|
|
45
|
-
},
|
|
46
|
-
"tier_compatibility": {
|
|
47
|
-
"type": "array",
|
|
48
|
-
"minItems": 1,
|
|
49
|
-
"uniqueItems": true,
|
|
50
|
-
"items": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"enum": ["A", "B", "C"]
|
|
53
|
-
},
|
|
54
|
-
"description": "Security tiers this component is compatible with"
|
|
55
|
-
},
|
|
56
|
-
"regions": {
|
|
57
|
-
"type": "array",
|
|
58
|
-
"minItems": 1,
|
|
59
|
-
"uniqueItems": true,
|
|
60
|
-
"items": {
|
|
61
|
-
"type": "string",
|
|
62
|
-
"pattern": "^[a-z][a-z0-9_]*$"
|
|
63
|
-
},
|
|
64
|
-
"description": "Page regions this component can be placed in"
|
|
65
|
-
},
|
|
66
|
-
"props_schema": {
|
|
67
|
-
"type": "object",
|
|
68
|
-
"description": "JSON Schema defining component properties",
|
|
69
|
-
"required": ["type", "properties"],
|
|
70
|
-
"properties": {
|
|
71
|
-
"type": {
|
|
72
|
-
"const": "object"
|
|
73
|
-
},
|
|
74
|
-
"properties": {
|
|
75
|
-
"type": "object"
|
|
76
|
-
},
|
|
77
|
-
"required": {
|
|
78
|
-
"type": "array",
|
|
79
|
-
"items": {
|
|
80
|
-
"type": "string"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"assets": {
|
|
86
|
-
"type": "object",
|
|
87
|
-
"properties": {
|
|
88
|
-
"css": {
|
|
89
|
-
"type": "array",
|
|
90
|
-
"items": {
|
|
91
|
-
"type": "string",
|
|
92
|
-
"pattern": "^assets/.*\\.css$"
|
|
93
|
-
},
|
|
94
|
-
"description": "CSS files relative to component root"
|
|
95
|
-
},
|
|
96
|
-
"js": {
|
|
97
|
-
"type": "array",
|
|
98
|
-
"items": {
|
|
99
|
-
"type": "string",
|
|
100
|
-
"pattern": "^assets/.*\\.js$"
|
|
101
|
-
},
|
|
102
|
-
"description": "JavaScript files relative to component root"
|
|
103
|
-
},
|
|
104
|
-
"images": {
|
|
105
|
-
"type": "array",
|
|
106
|
-
"items": {
|
|
107
|
-
"type": "string",
|
|
108
|
-
"pattern": "^assets/.*\\.(png|jpg|jpeg|svg|gif|webp)$"
|
|
109
|
-
},
|
|
110
|
-
"description": "Image files relative to component root"
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
"additionalProperties": false
|
|
114
|
-
},
|
|
115
|
-
"dependencies": {
|
|
116
|
-
"type": "array",
|
|
117
|
-
"items": {
|
|
118
|
-
"type": "object",
|
|
119
|
-
"required": ["name", "min_version"],
|
|
120
|
-
"properties": {
|
|
121
|
-
"name": {
|
|
122
|
-
"type": "string",
|
|
123
|
-
"pattern": "^[a-z][a-z0-9_]*$"
|
|
124
|
-
},
|
|
125
|
-
"min_version": {
|
|
126
|
-
"type": "string",
|
|
127
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
|
|
128
|
-
},
|
|
129
|
-
"max_version": {
|
|
130
|
-
"type": "string",
|
|
131
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
"description": "Component dependencies on other components"
|
|
136
|
-
},
|
|
137
|
-
"locales": {
|
|
138
|
-
"type": "array",
|
|
139
|
-
"items": {
|
|
140
|
-
"type": "string",
|
|
141
|
-
"pattern": "^[a-z]{2}(_[A-Z]{2})?$"
|
|
142
|
-
},
|
|
143
|
-
"description": "Supported locale codes (e.g., en, es, fr, en_US)"
|
|
144
|
-
},
|
|
145
|
-
"preview": {
|
|
146
|
-
"type": "string",
|
|
147
|
-
"pattern": "^preview\\.(png|jpg|jpeg|webp)$",
|
|
148
|
-
"description": "Preview image filename"
|
|
149
|
-
},
|
|
150
|
-
"category": {
|
|
151
|
-
"type": "string",
|
|
152
|
-
"enum": [
|
|
153
|
-
"hero",
|
|
154
|
-
"header",
|
|
155
|
-
"footer",
|
|
156
|
-
"content",
|
|
157
|
-
"product",
|
|
158
|
-
"collection",
|
|
159
|
-
"cart",
|
|
160
|
-
"checkout",
|
|
161
|
-
"marketing",
|
|
162
|
-
"social",
|
|
163
|
-
"navigation",
|
|
164
|
-
"utility"
|
|
165
|
-
],
|
|
166
|
-
"description": "Component category for marketplace organization"
|
|
167
|
-
},
|
|
168
|
-
"tags": {
|
|
169
|
-
"type": "array",
|
|
170
|
-
"maxItems": 10,
|
|
171
|
-
"items": {
|
|
172
|
-
"type": "string",
|
|
173
|
-
"pattern": "^[a-z][a-z0-9-]*$",
|
|
174
|
-
"maxLength": 30
|
|
175
|
-
},
|
|
176
|
-
"description": "Searchable tags for marketplace"
|
|
177
|
-
},
|
|
178
|
-
"license": {
|
|
179
|
-
"type": "string",
|
|
180
|
-
"enum": ["MIT", "Apache-2.0", "GPL-3.0", "Proprietary"],
|
|
181
|
-
"default": "Proprietary",
|
|
182
|
-
"description": "Component license type"
|
|
183
|
-
},
|
|
184
|
-
"changelog": {
|
|
185
|
-
"type": "array",
|
|
186
|
-
"items": {
|
|
187
|
-
"type": "object",
|
|
188
|
-
"required": ["version", "date", "changes"],
|
|
189
|
-
"properties": {
|
|
190
|
-
"version": {
|
|
191
|
-
"type": "string",
|
|
192
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
|
|
193
|
-
},
|
|
194
|
-
"date": {
|
|
195
|
-
"type": "string",
|
|
196
|
-
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
|
197
|
-
},
|
|
198
|
-
"changes": {
|
|
199
|
-
"type": "array",
|
|
200
|
-
"minItems": 1,
|
|
201
|
-
"items": {
|
|
202
|
-
"type": "string"
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
"description": "Version history and changes"
|
|
208
|
-
},
|
|
209
|
-
"min_platform_version": {
|
|
210
|
-
"type": "string",
|
|
211
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
|
|
212
|
-
"description": "Minimum platform version required"
|
|
213
|
-
},
|
|
214
|
-
"max_platform_version": {
|
|
215
|
-
"type": "string",
|
|
216
|
-
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
|
|
217
|
-
"description": "Maximum platform version supported"
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
"additionalProperties": false
|
|
221
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component Validator
|
|
3
|
-
* Validates component packages against manifest schema and file structure
|
|
4
|
-
*/
|
|
5
|
-
import { ManifestValidator } from './manifest-validator.js';
|
|
6
|
-
import { ValidationResult } from '../types/validation-result.js';
|
|
7
|
-
export declare class ComponentValidator extends ManifestValidator {
|
|
8
|
-
private componentDir;
|
|
9
|
-
private manifest;
|
|
10
|
-
private static readonly REQUIRED_FILES;
|
|
11
|
-
private static readonly OPTIONAL_FILES;
|
|
12
|
-
constructor(componentDir: string);
|
|
13
|
-
/**
|
|
14
|
-
* Validate complete component package
|
|
15
|
-
*/
|
|
16
|
-
validate(): Promise<ValidationResult>;
|
|
17
|
-
/**
|
|
18
|
-
* Validate required files exist
|
|
19
|
-
*/
|
|
20
|
-
private validateRequiredFiles;
|
|
21
|
-
/**
|
|
22
|
-
* Validate template.html file
|
|
23
|
-
*/
|
|
24
|
-
private validateTemplate;
|
|
25
|
-
/**
|
|
26
|
-
* Validate props schema file
|
|
27
|
-
*/
|
|
28
|
-
private validatePropsSchema;
|
|
29
|
-
/**
|
|
30
|
-
* Validate declared asset files exist
|
|
31
|
-
*/
|
|
32
|
-
private validateAssets;
|
|
33
|
-
/**
|
|
34
|
-
* Validate locale files exist for declared locales
|
|
35
|
-
*/
|
|
36
|
-
private validateLocales;
|
|
37
|
-
/**
|
|
38
|
-
* Validate preview image file exists
|
|
39
|
-
*/
|
|
40
|
-
private validatePreview;
|
|
41
|
-
/**
|
|
42
|
-
* Validate dependency format
|
|
43
|
-
*/
|
|
44
|
-
private validateDependencies;
|
|
45
|
-
/**
|
|
46
|
-
* Build validation result
|
|
47
|
-
*/
|
|
48
|
-
private buildResult;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=component-validator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-validator.d.ts","sourceRoot":"","sources":["../../src/validators/component-validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,gBAAgB,EAGjB,MAAM,+BAA+B,CAAC;AAGvC,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAkC;IAElD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAIpC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAKpC;gBAEU,YAAY,EAAE,MAAM;IAKhC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA6D3C;;OAEG;YACW,qBAAqB;IAcnC;;OAEG;YACW,gBAAgB;IAiB9B;;OAEG;YACW,mBAAmB;IA+CjC;;OAEG;YACW,cAAc;IAsB5B;;OAEG;YACW,eAAe;IA+B7B;;OAEG;YACW,eAAe;IA0B7B;;OAEG;YACW,oBAAoB;IAqBlC;;OAEG;IACH,OAAO,CAAC,WAAW;CAQpB"}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component Validator
|
|
3
|
-
* Validates component packages against manifest schema and file structure
|
|
4
|
-
*/
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
import { ManifestValidator } from './manifest-validator.js';
|
|
8
|
-
import { createError, createWarning, } from '../types/validation-result.js';
|
|
9
|
-
export class ComponentValidator extends ManifestValidator {
|
|
10
|
-
componentDir;
|
|
11
|
-
manifest = null;
|
|
12
|
-
static REQUIRED_FILES = [
|
|
13
|
-
'manifest.json',
|
|
14
|
-
'template.html',
|
|
15
|
-
'schema.json',
|
|
16
|
-
];
|
|
17
|
-
static OPTIONAL_FILES = [
|
|
18
|
-
'preview.png',
|
|
19
|
-
'preview.jpg',
|
|
20
|
-
'preview.jpeg',
|
|
21
|
-
'preview.webp',
|
|
22
|
-
];
|
|
23
|
-
constructor(componentDir) {
|
|
24
|
-
super();
|
|
25
|
-
this.componentDir = path.resolve(componentDir);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Validate complete component package
|
|
29
|
-
*/
|
|
30
|
-
async validate() {
|
|
31
|
-
this.reset();
|
|
32
|
-
// 1. Check directory exists
|
|
33
|
-
if (!(await this.directoryExists(this.componentDir))) {
|
|
34
|
-
this.addError(createError('directory_not_found', `Component directory does not exist: ${this.componentDir}`));
|
|
35
|
-
return this.buildResult();
|
|
36
|
-
}
|
|
37
|
-
// 2. Check required files
|
|
38
|
-
if (!(await this.validateRequiredFiles())) {
|
|
39
|
-
return this.buildResult();
|
|
40
|
-
}
|
|
41
|
-
// 3. Load and validate manifest
|
|
42
|
-
const manifestPath = path.join(this.componentDir, 'manifest.json');
|
|
43
|
-
try {
|
|
44
|
-
this.manifest = await this.loadJSON(manifestPath);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return this.buildResult();
|
|
48
|
-
}
|
|
49
|
-
// Load component manifest schema
|
|
50
|
-
const schemaPath = path.join(__dirname, '../../schemas/component_manifest_schema.json');
|
|
51
|
-
const schema = await this.loadSchema(schemaPath);
|
|
52
|
-
if (!this.validateAgainstSchema(this.manifest, schema, 'component manifest')) {
|
|
53
|
-
return this.buildResult();
|
|
54
|
-
}
|
|
55
|
-
// 4. Validate template file
|
|
56
|
-
await this.validateTemplate();
|
|
57
|
-
// 5. Validate props schema file
|
|
58
|
-
await this.validatePropsSchema();
|
|
59
|
-
// 6. Validate assets if declared
|
|
60
|
-
if (this.manifest.assets) {
|
|
61
|
-
await this.validateAssets();
|
|
62
|
-
}
|
|
63
|
-
// 7. Validate locales if declared
|
|
64
|
-
if (this.manifest.locales) {
|
|
65
|
-
await this.validateLocales();
|
|
66
|
-
}
|
|
67
|
-
// 8. Validate preview image if declared
|
|
68
|
-
if (this.manifest.preview) {
|
|
69
|
-
await this.validatePreview();
|
|
70
|
-
}
|
|
71
|
-
// 9. Validate dependencies format
|
|
72
|
-
if (this.manifest.dependencies) {
|
|
73
|
-
await this.validateDependencies();
|
|
74
|
-
}
|
|
75
|
-
return this.buildResult();
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Validate required files exist
|
|
79
|
-
*/
|
|
80
|
-
async validateRequiredFiles() {
|
|
81
|
-
let allExist = true;
|
|
82
|
-
for (const filename of ComponentValidator.REQUIRED_FILES) {
|
|
83
|
-
const filePath = path.join(this.componentDir, filename);
|
|
84
|
-
if (!(await this.fileExists(filePath))) {
|
|
85
|
-
this.addError(createError('missing_file', `Required file missing: ${filename}`));
|
|
86
|
-
allExist = false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return allExist;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Validate template.html file
|
|
93
|
-
*/
|
|
94
|
-
async validateTemplate() {
|
|
95
|
-
const templatePath = path.join(this.componentDir, 'template.html');
|
|
96
|
-
if (!(await this.fileExists(templatePath))) {
|
|
97
|
-
this.addError(createError('missing_file', 'Template file (template.html) does not exist'));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// Check file is not empty
|
|
101
|
-
if (!(await this.validateFileNotEmpty(templatePath, 'Template'))) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// Check it's valid UTF-8
|
|
105
|
-
await this.validateUTF8(templatePath, 'Template');
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Validate props schema file
|
|
109
|
-
*/
|
|
110
|
-
async validatePropsSchema() {
|
|
111
|
-
const schemaPath = path.join(this.componentDir, 'schema.json');
|
|
112
|
-
if (!(await this.fileExists(schemaPath))) {
|
|
113
|
-
this.addError(createError('missing_file', 'Props schema file (schema.json) does not exist'));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
// Load and validate it's valid JSON
|
|
117
|
-
let propsSchema;
|
|
118
|
-
try {
|
|
119
|
-
propsSchema = await this.loadJSON(schemaPath);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
// Error already added by loadJSON
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// Check it matches the props_schema in manifest (if present)
|
|
126
|
-
if (this.manifest?.props_schema) {
|
|
127
|
-
const manifestSchema = JSON.stringify(this.manifest.props_schema, null, 2);
|
|
128
|
-
const fileSchema = JSON.stringify(propsSchema, null, 2);
|
|
129
|
-
if (manifestSchema !== fileSchema) {
|
|
130
|
-
this.addError(createError('schema_mismatch', 'Props schema in schema.json does not match manifest.props_schema'));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Validate it's a valid JSON Schema (basic check)
|
|
135
|
-
if (!propsSchema.$schema && !propsSchema.type) {
|
|
136
|
-
this.addWarning(createWarning('invalid_schema', 'Props schema may not be a valid JSON Schema (missing $schema or type)', {
|
|
137
|
-
suggestion: 'Add "$schema": "http://json-schema.org/draft-07/schema#" to schema.json',
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Validate declared asset files exist
|
|
143
|
-
*/
|
|
144
|
-
async validateAssets() {
|
|
145
|
-
if (!this.manifest?.assets)
|
|
146
|
-
return;
|
|
147
|
-
const validAssetTypes = ['css', 'js', 'images'];
|
|
148
|
-
for (const [assetType, assetPaths] of Object.entries(this.manifest.assets)) {
|
|
149
|
-
if (!validAssetTypes.includes(assetType)) {
|
|
150
|
-
this.addError(createError('invalid_asset_type', `Unknown asset type: ${assetType}`));
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
for (const assetPath of assetPaths) {
|
|
154
|
-
const fullPath = path.join(this.componentDir, assetPath);
|
|
155
|
-
if (!(await this.fileExists(fullPath))) {
|
|
156
|
-
this.addError(createError('missing_asset', `Asset file does not exist: ${assetPath}`));
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Validate locale files exist for declared locales
|
|
164
|
-
*/
|
|
165
|
-
async validateLocales() {
|
|
166
|
-
if (!this.manifest?.locales)
|
|
167
|
-
return;
|
|
168
|
-
const localesDir = path.join(this.componentDir, 'locales');
|
|
169
|
-
if (!(await this.directoryExists(localesDir))) {
|
|
170
|
-
this.addError(createError('missing_directory', 'Locales declared but locales/ directory does not exist'));
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
for (const locale of this.manifest.locales) {
|
|
174
|
-
const localeFile = path.join(localesDir, `${locale}.json`);
|
|
175
|
-
if (!(await this.fileExists(localeFile))) {
|
|
176
|
-
this.addError(createError('missing_locale', `Locale file does not exist: locales/${locale}.json`));
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
// Validate it's valid JSON
|
|
180
|
-
try {
|
|
181
|
-
await this.loadJSON(localeFile);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
// Error already added by loadJSON
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Validate preview image file exists
|
|
190
|
-
*/
|
|
191
|
-
async validatePreview() {
|
|
192
|
-
if (!this.manifest?.preview)
|
|
193
|
-
return;
|
|
194
|
-
const previewPath = path.join(this.componentDir, this.manifest.preview);
|
|
195
|
-
if (!(await this.fileExists(previewPath))) {
|
|
196
|
-
this.addError(createError('missing_preview', `Preview image does not exist: ${this.manifest.preview}`));
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
// Check file size is reasonable (not too large)
|
|
200
|
-
const maxSize = 5 * 1024 * 1024; // 5 MB
|
|
201
|
-
const stats = await fs.stat(previewPath);
|
|
202
|
-
if (stats.size > maxSize) {
|
|
203
|
-
this.addError(createError('file_too_large', `Preview image is too large (max 5MB): ${this.manifest.preview}`));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Validate dependency format
|
|
208
|
-
*/
|
|
209
|
-
async validateDependencies() {
|
|
210
|
-
if (!this.manifest?.dependencies)
|
|
211
|
-
return;
|
|
212
|
-
for (const dep of this.manifest.dependencies) {
|
|
213
|
-
const minVer = dep.min_version;
|
|
214
|
-
const maxVer = dep.max_version;
|
|
215
|
-
if (minVer && maxVer) {
|
|
216
|
-
// Compare versions
|
|
217
|
-
if (this.compareVersions(minVer, maxVer) > 0) {
|
|
218
|
-
this.addError(createError('invalid_dependency', `Dependency ${dep.name}: min_version (${minVer}) is greater than max_version (${maxVer})`));
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Build validation result
|
|
225
|
-
*/
|
|
226
|
-
buildResult() {
|
|
227
|
-
return {
|
|
228
|
-
isValid: this.getErrors().length === 0,
|
|
229
|
-
errors: this.getErrors(),
|
|
230
|
-
warnings: this.getWarnings(),
|
|
231
|
-
componentInfo: this.manifest,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
//# sourceMappingURL=component-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-validator.js","sourceRoot":"","sources":["../../src/validators/component-validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAEL,WAAW,EACX,aAAa,GACd,MAAM,+BAA+B,CAAC;AAGvC,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAC/C,YAAY,CAAS;IACrB,QAAQ,GAA6B,IAAI,CAAC;IAE1C,MAAM,CAAU,cAAc,GAAG;QACvC,eAAe;QACf,eAAe;QACf,aAAa;KACd,CAAC;IAEM,MAAM,CAAU,cAAc,GAAG;QAC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WAAW;QACjB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,KAAK,CAAC;YACtC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;YACxB,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE;YAC5B,aAAa,EAAE,IAAI,CAAC,QAAQ;SAC7B,CAAC;IACJ,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template Validator
|
|
3
|
-
* Validates Django/Jinja2 template files
|
|
4
|
-
*/
|
|
5
|
-
import { ValidationResult } from '../types/validation-result.js';
|
|
6
|
-
export declare class TemplateValidator {
|
|
7
|
-
private errors;
|
|
8
|
-
private warnings;
|
|
9
|
-
/**
|
|
10
|
-
* Validate a template file
|
|
11
|
-
*/
|
|
12
|
-
validate(templatePath: string): Promise<ValidationResult>;
|
|
13
|
-
/**
|
|
14
|
-
* Check file exists
|
|
15
|
-
*/
|
|
16
|
-
private fileExists;
|
|
17
|
-
/**
|
|
18
|
-
* Read template content
|
|
19
|
-
*/
|
|
20
|
-
private readTemplate;
|
|
21
|
-
/**
|
|
22
|
-
* Check basic template syntax
|
|
23
|
-
*/
|
|
24
|
-
private checkTemplateSyntax;
|
|
25
|
-
/**
|
|
26
|
-
* Check for common template issues
|
|
27
|
-
*/
|
|
28
|
-
private checkCommonIssues;
|
|
29
|
-
/**
|
|
30
|
-
* Build validation result
|
|
31
|
-
*/
|
|
32
|
-
private buildResult;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=template-validator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-validator.d.ts","sourceRoot":"","sources":["../../src/validators/template-validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,gBAAgB,EAKjB,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,QAAQ,CAA2B;IAE3C;;OAEG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2B/D;;OAEG;YACW,UAAU;IASxB;;OAEG;YACW,YAAY;IA0B1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAwE3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6CzB;;OAEG;IACH,OAAO,CAAC,WAAW;CAOpB"}
|