@movable/rollup-plugin-manifest-validator 3.2.0-app-validation
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/.mocharc.yml +3 -0
- package/babel.config.json +11 -0
- package/dist/apps/index.js +15 -0
- package/dist/apps/plugins/app-manifest-validator.js +44 -0
- package/dist/apps/utils/app-manifest-validator.js +44 -0
- package/dist/apps/validators/ajvCompiler.js +43 -0
- package/dist/apps/validators/erroringValidator.js +16 -0
- package/dist/apps/validators/index.js +23 -0
- package/dist/apps/validators/warningValidator.js +16 -0
- package/dist/index.js +21 -0
- package/dist/packages/index.js +15 -0
- package/dist/packages/plugins/package-manifest-validator.js +44 -0
- package/dist/packages/utils/package-manifest-validator.js +44 -0
- package/dist/packages/validators/ajvCompiler.js +43 -0
- package/dist/packages/validators/erroringValidator.js +16 -0
- package/dist/packages/validators/index.js +23 -0
- package/dist/packages/validators/warningValidator.js +16 -0
- package/dist/schemas/enums.js +14 -0
- package/dist/schemas/erroringSchemaApps.js +809 -0
- package/dist/schemas/erroringSchemaPackages.js +17 -0
- package/dist/schemas/index.js +39 -0
- package/dist/schemas/warningSchemaApps.js +8 -0
- package/dist/schemas/warningSchemaPackages.js +504 -0
- package/package.json +42 -0
- package/src/apps/index.js +3 -0
- package/src/apps/plugins/app-manifest-validator.js +22 -0
- package/src/apps/utils/app-manifest-validator.js +31 -0
- package/src/apps/validators/ajvCompiler.js +28 -0
- package/src/apps/validators/erroringValidator.js +4 -0
- package/src/apps/validators/index.js +4 -0
- package/src/apps/validators/warningValidator.js +4 -0
- package/src/index.js +4 -0
- package/src/packages/index.js +3 -0
- package/src/packages/plugins/package-manifest-validator.js +19 -0
- package/src/packages/utils/package-manifest-validator.js +31 -0
- package/src/packages/validators/ajvCompiler.js +28 -0
- package/src/packages/validators/erroringValidator.js +4 -0
- package/src/packages/validators/index.js +4 -0
- package/src/packages/validators/warningValidator.js +4 -0
- package/src/schemas/enums.js +130 -0
- package/src/schemas/erroringSchemaApps.js +468 -0
- package/src/schemas/erroringSchemaPackages.js +8 -0
- package/src/schemas/index.js +6 -0
- package/src/schemas/warningSchemaApps.js +1 -0
- package/src/schemas/warningSchemaPackages.js +304 -0
- package/test/fixtures/blankFile.js +0 -0
- package/test/fixtures/invalidField.yml +3 -0
- package/test/fixtures/master-app-manifest.yml +72 -0
- package/test/fixtures/master-package-manifest.yml +100 -0
- package/test/fixtures/noName.yml +1 -0
- package/test/helpers/lib.js +10 -0
- package/test/plugins/app-manifest-validation.js +34 -0
- package/test/plugins/package-manifest-validation.js +62 -0
- package/test/utils/app-manifest-validation.js +785 -0
- package/test/utils/package-manifest-validation.js +1515 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import YAML from 'yamljs';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import packageManifestValidator from '../utils/package-manifest-validator';
|
|
4
|
+
|
|
5
|
+
const formatJSON = (j) => JSON.stringify(j, null, 1);
|
|
6
|
+
|
|
7
|
+
export default ({ manifestPath }) => ({
|
|
8
|
+
buildStart() {
|
|
9
|
+
this.addWatchFile(manifestPath);
|
|
10
|
+
const manifest = YAML.parse(readFileSync(manifestPath).toString('utf-8'));
|
|
11
|
+
const { warnings, errors } = packageManifestValidator(manifest);
|
|
12
|
+
if (errors.length) {
|
|
13
|
+
this.error({ message: `INVALID PACKAGE MANIFEST: ${formatJSON(errors)}` });
|
|
14
|
+
}
|
|
15
|
+
warnings.forEach((w) =>
|
|
16
|
+
this.warn({ message: `'PACKAGE MANIFEST VALIDATION WARNING': ${formatJSON(w)}` })
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { warningValidator, erroringValidator } from '../validators';
|
|
2
|
+
|
|
3
|
+
export const TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE =
|
|
4
|
+
'Manifest has a prohibited keyword at the top level.';
|
|
5
|
+
const TOP_LEVEL_PATH = 'package-manifest.yml';
|
|
6
|
+
|
|
7
|
+
const parseValidationItem = ({ message, dataPath, params, keyword }) => {
|
|
8
|
+
const validation = {
|
|
9
|
+
message,
|
|
10
|
+
dataPath,
|
|
11
|
+
params
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
if (!dataPath) {
|
|
15
|
+
validation.dataPath = TOP_LEVEL_PATH;
|
|
16
|
+
if (keyword === 'prohibited') validation.message = TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return validation;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default function validateManifest(manifest) {
|
|
23
|
+
warningValidator(manifest);
|
|
24
|
+
erroringValidator(manifest);
|
|
25
|
+
const warnings = warningValidator.errors ?? [];
|
|
26
|
+
const errors = erroringValidator.errors ?? [];
|
|
27
|
+
return {
|
|
28
|
+
warnings: warnings.map(parseValidationItem),
|
|
29
|
+
errors: errors.map(parseValidationItem)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import ajvKeywords from 'ajv-keywords';
|
|
3
|
+
|
|
4
|
+
const compiler = new Ajv({ allErrors: true });
|
|
5
|
+
ajvKeywords(compiler);
|
|
6
|
+
|
|
7
|
+
compiler.addKeyword('name', {
|
|
8
|
+
schema: false,
|
|
9
|
+
validate: function validation(data) {
|
|
10
|
+
const { name: packageName } = data;
|
|
11
|
+
const propertyGroup = data.studio_options?.property_groups?.[0];
|
|
12
|
+
if (propertyGroup?.name) {
|
|
13
|
+
validation.errors = [
|
|
14
|
+
{
|
|
15
|
+
message: 'property_group name must match package name',
|
|
16
|
+
keyword: 'invalidPropertyGroupName',
|
|
17
|
+
params: { name: propertyGroup.name },
|
|
18
|
+
dataPath: '.studio_options.propertyGroups[0]'
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
return propertyGroup.name === packageName;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
errors: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default compiler;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const contextOptionTypes = ['select', 'text', 'hidden'];
|
|
2
|
+
|
|
3
|
+
const propertyTypes = ['text', 'image', 'link', 'api', 'boolean'];
|
|
4
|
+
|
|
5
|
+
const fieldTypes = [
|
|
6
|
+
'asset',
|
|
7
|
+
'checkbox',
|
|
8
|
+
'color',
|
|
9
|
+
'data-source',
|
|
10
|
+
'data-source-package',
|
|
11
|
+
'date',
|
|
12
|
+
'datetime',
|
|
13
|
+
'dynamic-text',
|
|
14
|
+
'font',
|
|
15
|
+
'image',
|
|
16
|
+
'map',
|
|
17
|
+
'number',
|
|
18
|
+
'oauth2',
|
|
19
|
+
'oAuthAccount',
|
|
20
|
+
'radio',
|
|
21
|
+
'select',
|
|
22
|
+
'text',
|
|
23
|
+
'token',
|
|
24
|
+
'upload',
|
|
25
|
+
'url'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const studioIcons = [
|
|
29
|
+
'align-bottom',
|
|
30
|
+
'align-center',
|
|
31
|
+
'align-left',
|
|
32
|
+
'align-middle',
|
|
33
|
+
'align-right',
|
|
34
|
+
'align-top',
|
|
35
|
+
'arrange-center',
|
|
36
|
+
'arrange-left',
|
|
37
|
+
'arrange-right',
|
|
38
|
+
'arrows-select',
|
|
39
|
+
'avatar',
|
|
40
|
+
'bar-chart',
|
|
41
|
+
'barcode',
|
|
42
|
+
'calendar',
|
|
43
|
+
'cart',
|
|
44
|
+
'chatter',
|
|
45
|
+
'clock',
|
|
46
|
+
'code',
|
|
47
|
+
'condensed-view',
|
|
48
|
+
'copy',
|
|
49
|
+
'countdown-timer',
|
|
50
|
+
'countdown',
|
|
51
|
+
'crop',
|
|
52
|
+
'cursor-grab',
|
|
53
|
+
'cursor-move',
|
|
54
|
+
'cursor',
|
|
55
|
+
'distribute-horizontal',
|
|
56
|
+
'distribute-vertical',
|
|
57
|
+
'dropdown-arrow',
|
|
58
|
+
'duplicate',
|
|
59
|
+
'expanded-view',
|
|
60
|
+
'external-link',
|
|
61
|
+
'globe',
|
|
62
|
+
'grab',
|
|
63
|
+
'image-layer',
|
|
64
|
+
'image',
|
|
65
|
+
'images',
|
|
66
|
+
'instagram',
|
|
67
|
+
'local-time',
|
|
68
|
+
'locked',
|
|
69
|
+
'map-helper',
|
|
70
|
+
'maps',
|
|
71
|
+
'media-library',
|
|
72
|
+
'minus',
|
|
73
|
+
'move',
|
|
74
|
+
'olapic',
|
|
75
|
+
'param',
|
|
76
|
+
'personal',
|
|
77
|
+
'picture',
|
|
78
|
+
'pie-chart',
|
|
79
|
+
'pin',
|
|
80
|
+
'pinterest',
|
|
81
|
+
'plus',
|
|
82
|
+
'polling',
|
|
83
|
+
'proximity-pin',
|
|
84
|
+
'QR',
|
|
85
|
+
'qr-code',
|
|
86
|
+
'redo',
|
|
87
|
+
'rotate',
|
|
88
|
+
'rss',
|
|
89
|
+
'settings',
|
|
90
|
+
'shape',
|
|
91
|
+
'sharing',
|
|
92
|
+
'square',
|
|
93
|
+
'text-center',
|
|
94
|
+
'text-justify',
|
|
95
|
+
'text-layer',
|
|
96
|
+
'text-left',
|
|
97
|
+
'text-right',
|
|
98
|
+
'text-tool',
|
|
99
|
+
'text-vector',
|
|
100
|
+
'text',
|
|
101
|
+
'tools',
|
|
102
|
+
'trash',
|
|
103
|
+
'twitter-favorite',
|
|
104
|
+
'twitter-retweet',
|
|
105
|
+
'twitter-username',
|
|
106
|
+
'twitter',
|
|
107
|
+
'undo',
|
|
108
|
+
'unlocked',
|
|
109
|
+
'vector-square',
|
|
110
|
+
'vector-tool',
|
|
111
|
+
'video',
|
|
112
|
+
'weather-average',
|
|
113
|
+
'weather-city',
|
|
114
|
+
'weather-day',
|
|
115
|
+
'weather-description',
|
|
116
|
+
'weather-high-temp',
|
|
117
|
+
'weather-icon',
|
|
118
|
+
'weather',
|
|
119
|
+
'workspace-barcode',
|
|
120
|
+
'workspace-favorites',
|
|
121
|
+
'workspace-instagram',
|
|
122
|
+
'workspace-olapic',
|
|
123
|
+
'workspace-picture',
|
|
124
|
+
'workspace-pinterest',
|
|
125
|
+
'workspace-qr-code',
|
|
126
|
+
'workspace-retweets',
|
|
127
|
+
'workspace-weather'
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
export { studioIcons, fieldTypes, propertyTypes, contextOptionTypes };
|