@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.
Files changed (55) hide show
  1. package/.mocharc.yml +3 -0
  2. package/babel.config.json +11 -0
  3. package/dist/apps/index.js +15 -0
  4. package/dist/apps/plugins/app-manifest-validator.js +44 -0
  5. package/dist/apps/utils/app-manifest-validator.js +44 -0
  6. package/dist/apps/validators/ajvCompiler.js +43 -0
  7. package/dist/apps/validators/erroringValidator.js +16 -0
  8. package/dist/apps/validators/index.js +23 -0
  9. package/dist/apps/validators/warningValidator.js +16 -0
  10. package/dist/index.js +21 -0
  11. package/dist/packages/index.js +15 -0
  12. package/dist/packages/plugins/package-manifest-validator.js +44 -0
  13. package/dist/packages/utils/package-manifest-validator.js +44 -0
  14. package/dist/packages/validators/ajvCompiler.js +43 -0
  15. package/dist/packages/validators/erroringValidator.js +16 -0
  16. package/dist/packages/validators/index.js +23 -0
  17. package/dist/packages/validators/warningValidator.js +16 -0
  18. package/dist/schemas/enums.js +14 -0
  19. package/dist/schemas/erroringSchemaApps.js +809 -0
  20. package/dist/schemas/erroringSchemaPackages.js +17 -0
  21. package/dist/schemas/index.js +39 -0
  22. package/dist/schemas/warningSchemaApps.js +8 -0
  23. package/dist/schemas/warningSchemaPackages.js +504 -0
  24. package/package.json +42 -0
  25. package/src/apps/index.js +3 -0
  26. package/src/apps/plugins/app-manifest-validator.js +22 -0
  27. package/src/apps/utils/app-manifest-validator.js +31 -0
  28. package/src/apps/validators/ajvCompiler.js +28 -0
  29. package/src/apps/validators/erroringValidator.js +4 -0
  30. package/src/apps/validators/index.js +4 -0
  31. package/src/apps/validators/warningValidator.js +4 -0
  32. package/src/index.js +4 -0
  33. package/src/packages/index.js +3 -0
  34. package/src/packages/plugins/package-manifest-validator.js +19 -0
  35. package/src/packages/utils/package-manifest-validator.js +31 -0
  36. package/src/packages/validators/ajvCompiler.js +28 -0
  37. package/src/packages/validators/erroringValidator.js +4 -0
  38. package/src/packages/validators/index.js +4 -0
  39. package/src/packages/validators/warningValidator.js +4 -0
  40. package/src/schemas/enums.js +130 -0
  41. package/src/schemas/erroringSchemaApps.js +468 -0
  42. package/src/schemas/erroringSchemaPackages.js +8 -0
  43. package/src/schemas/index.js +6 -0
  44. package/src/schemas/warningSchemaApps.js +1 -0
  45. package/src/schemas/warningSchemaPackages.js +304 -0
  46. package/test/fixtures/blankFile.js +0 -0
  47. package/test/fixtures/invalidField.yml +3 -0
  48. package/test/fixtures/master-app-manifest.yml +72 -0
  49. package/test/fixtures/master-package-manifest.yml +100 -0
  50. package/test/fixtures/noName.yml +1 -0
  51. package/test/helpers/lib.js +10 -0
  52. package/test/plugins/app-manifest-validation.js +34 -0
  53. package/test/plugins/package-manifest-validation.js +62 -0
  54. package/test/utils/app-manifest-validation.js +785 -0
  55. package/test/utils/package-manifest-validation.js +1515 -0
@@ -0,0 +1,4 @@
1
+ import ajvCompiler from './ajvCompiler';
2
+ import { warningSchemaApps } from '../../schemas';
3
+
4
+ export default ajvCompiler.compile(warningSchemaApps);
package/src/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { manifestValidatorPluginPackages } from './packages';
2
+ import { manifestValidatorPluginApps } from './apps';
3
+
4
+ export { manifestValidatorPluginPackages, manifestValidatorPluginApps };
@@ -0,0 +1,3 @@
1
+ import manifestValidatorPluginPackages from './plugins/package-manifest-validator';
2
+
3
+ export { manifestValidatorPluginPackages };
@@ -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,4 @@
1
+ import ajvCompiler from './ajvCompiler';
2
+ import { erroringSchemaPackages } from '../../schemas';
3
+
4
+ export default ajvCompiler.compile(erroringSchemaPackages);
@@ -0,0 +1,4 @@
1
+ import warningValidator from './warningValidator';
2
+ import erroringValidator from './erroringValidator';
3
+
4
+ export { warningValidator, erroringValidator };
@@ -0,0 +1,4 @@
1
+ import ajvCompiler from './ajvCompiler';
2
+ import { warningSchemaPackages } from '../../schemas';
3
+
4
+ export default ajvCompiler.compile(warningSchemaPackages);
@@ -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 };