@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
package/.mocharc.yml ADDED
@@ -0,0 +1,3 @@
1
+ require:
2
+ - 'regenerator-runtime'
3
+ - '@babel/register'
@@ -0,0 +1,11 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": { "safari": "16" },
7
+ "bugfixes": true
8
+ }
9
+ ]
10
+ ]
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "manifestValidatorPluginApps", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _appManifestValidator.default;
10
+ }
11
+ });
12
+
13
+ var _appManifestValidator = _interopRequireDefault(require("./plugins/app-manifest-validator"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _yamljs = _interopRequireDefault(require("yamljs"));
9
+
10
+ var _fs = require("fs");
11
+
12
+ var _appManifestValidator = _interopRequireDefault(require("../utils/app-manifest-validator"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const formatJSON = j => JSON.stringify(j, null, 1);
17
+
18
+ var _default = ({
19
+ manifestPath
20
+ }) => ({
21
+ buildStart() {
22
+ this.addWatchFile(manifestPath);
23
+
24
+ const manifest = _yamljs.default.parse((0, _fs.readFileSync)(manifestPath).toString('utf-8'));
25
+
26
+ const {
27
+ warnings,
28
+ errors
29
+ } = (0, _appManifestValidator.default)(manifest);
30
+
31
+ if (errors.length) {
32
+ this.error({
33
+ message: `INVALID APP MANIFEST: ${formatJSON(errors)}`
34
+ });
35
+ }
36
+
37
+ warnings.forEach(w => this.warn({
38
+ message: `'APP MANIFEST VALIDATION WARNING': ${formatJSON(w)}`
39
+ }));
40
+ }
41
+
42
+ });
43
+
44
+ exports.default = _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = void 0;
7
+ exports.default = validateManifest;
8
+
9
+ var _validators = require("../validators");
10
+
11
+ const TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = 'Manifest has a prohibited keyword at the top level.';
12
+ exports.TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE;
13
+ const TOP_LEVEL_PATH = 'app-manifest.yml';
14
+
15
+ const parseValidationItem = ({
16
+ message,
17
+ dataPath,
18
+ params,
19
+ keyword
20
+ }) => {
21
+ const validation = {
22
+ message,
23
+ dataPath,
24
+ params
25
+ };
26
+
27
+ if (!dataPath) {
28
+ validation.dataPath = TOP_LEVEL_PATH;
29
+ if (keyword === 'prohibited') validation.message = TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE;
30
+ }
31
+
32
+ return validation;
33
+ };
34
+
35
+ function validateManifest(manifest) {
36
+ (0, _validators.warningValidator)(manifest);
37
+ (0, _validators.erroringValidator)(manifest);
38
+ const warnings = _validators.warningValidator.errors ?? [];
39
+ const errors = _validators.erroringValidator.errors ?? [];
40
+ return {
41
+ warnings: warnings.map(parseValidationItem),
42
+ errors: errors.map(parseValidationItem)
43
+ };
44
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajv = _interopRequireDefault(require("ajv"));
9
+
10
+ var _ajvKeywords = _interopRequireDefault(require("ajv-keywords"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const compiler = new _ajv.default({
15
+ allErrors: true
16
+ });
17
+ (0, _ajvKeywords.default)(compiler);
18
+ compiler.addKeyword('name', {
19
+ schema: false,
20
+ validate: function validation(data) {
21
+ const {
22
+ name: appName
23
+ } = data;
24
+ const propertyGroup = data.studio_options?.property_groups?.[0];
25
+
26
+ if (propertyGroup?.name) {
27
+ validation.errors = [{
28
+ message: 'property_group name must match app name',
29
+ keyword: 'invalidPropertyGroupName',
30
+ params: {
31
+ name: propertyGroup.name
32
+ },
33
+ dataPath: '.studio_options.propertyGroups[0]'
34
+ }];
35
+ return propertyGroup.name === appName;
36
+ }
37
+
38
+ return true;
39
+ },
40
+ errors: true
41
+ });
42
+ var _default = compiler;
43
+ exports.default = _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajvCompiler = _interopRequireDefault(require("./ajvCompiler"));
9
+
10
+ var _schemas = require("../../schemas");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = _ajvCompiler.default.compile(_schemas.erroringSchemaApps);
15
+
16
+ exports.default = _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "erroringValidator", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _erroringValidator.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "warningValidator", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _warningValidator.default;
16
+ }
17
+ });
18
+
19
+ var _warningValidator = _interopRequireDefault(require("./warningValidator"));
20
+
21
+ var _erroringValidator = _interopRequireDefault(require("./erroringValidator"));
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajvCompiler = _interopRequireDefault(require("./ajvCompiler"));
9
+
10
+ var _schemas = require("../../schemas");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = _ajvCompiler.default.compile(_schemas.warningSchemaApps);
15
+
16
+ exports.default = _default;
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "manifestValidatorPluginApps", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _apps.manifestValidatorPluginApps;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "manifestValidatorPluginPackages", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _packages.manifestValidatorPluginPackages;
16
+ }
17
+ });
18
+
19
+ var _packages = require("./packages");
20
+
21
+ var _apps = require("./apps");
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "manifestValidatorPluginPackages", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _packageManifestValidator.default;
10
+ }
11
+ });
12
+
13
+ var _packageManifestValidator = _interopRequireDefault(require("./plugins/package-manifest-validator"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _yamljs = _interopRequireDefault(require("yamljs"));
9
+
10
+ var _fs = require("fs");
11
+
12
+ var _packageManifestValidator = _interopRequireDefault(require("../utils/package-manifest-validator"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const formatJSON = j => JSON.stringify(j, null, 1);
17
+
18
+ var _default = ({
19
+ manifestPath
20
+ }) => ({
21
+ buildStart() {
22
+ this.addWatchFile(manifestPath);
23
+
24
+ const manifest = _yamljs.default.parse((0, _fs.readFileSync)(manifestPath).toString('utf-8'));
25
+
26
+ const {
27
+ warnings,
28
+ errors
29
+ } = (0, _packageManifestValidator.default)(manifest);
30
+
31
+ if (errors.length) {
32
+ this.error({
33
+ message: `INVALID PACKAGE MANIFEST: ${formatJSON(errors)}`
34
+ });
35
+ }
36
+
37
+ warnings.forEach(w => this.warn({
38
+ message: `'PACKAGE MANIFEST VALIDATION WARNING': ${formatJSON(w)}`
39
+ }));
40
+ }
41
+
42
+ });
43
+
44
+ exports.default = _default;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = void 0;
7
+ exports.default = validateManifest;
8
+
9
+ var _validators = require("../validators");
10
+
11
+ const TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = 'Manifest has a prohibited keyword at the top level.';
12
+ exports.TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE = TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE;
13
+ const TOP_LEVEL_PATH = 'package-manifest.yml';
14
+
15
+ const parseValidationItem = ({
16
+ message,
17
+ dataPath,
18
+ params,
19
+ keyword
20
+ }) => {
21
+ const validation = {
22
+ message,
23
+ dataPath,
24
+ params
25
+ };
26
+
27
+ if (!dataPath) {
28
+ validation.dataPath = TOP_LEVEL_PATH;
29
+ if (keyword === 'prohibited') validation.message = TOP_LEVEL_PROHIBITED_PROPERTY_MESSAGE;
30
+ }
31
+
32
+ return validation;
33
+ };
34
+
35
+ function validateManifest(manifest) {
36
+ (0, _validators.warningValidator)(manifest);
37
+ (0, _validators.erroringValidator)(manifest);
38
+ const warnings = _validators.warningValidator.errors ?? [];
39
+ const errors = _validators.erroringValidator.errors ?? [];
40
+ return {
41
+ warnings: warnings.map(parseValidationItem),
42
+ errors: errors.map(parseValidationItem)
43
+ };
44
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajv = _interopRequireDefault(require("ajv"));
9
+
10
+ var _ajvKeywords = _interopRequireDefault(require("ajv-keywords"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const compiler = new _ajv.default({
15
+ allErrors: true
16
+ });
17
+ (0, _ajvKeywords.default)(compiler);
18
+ compiler.addKeyword('name', {
19
+ schema: false,
20
+ validate: function validation(data) {
21
+ const {
22
+ name: packageName
23
+ } = data;
24
+ const propertyGroup = data.studio_options?.property_groups?.[0];
25
+
26
+ if (propertyGroup?.name) {
27
+ validation.errors = [{
28
+ message: 'property_group name must match package name',
29
+ keyword: 'invalidPropertyGroupName',
30
+ params: {
31
+ name: propertyGroup.name
32
+ },
33
+ dataPath: '.studio_options.propertyGroups[0]'
34
+ }];
35
+ return propertyGroup.name === packageName;
36
+ }
37
+
38
+ return true;
39
+ },
40
+ errors: true
41
+ });
42
+ var _default = compiler;
43
+ exports.default = _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajvCompiler = _interopRequireDefault(require("./ajvCompiler"));
9
+
10
+ var _schemas = require("../../schemas");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = _ajvCompiler.default.compile(_schemas.erroringSchemaPackages);
15
+
16
+ exports.default = _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "erroringValidator", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _erroringValidator.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "warningValidator", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _warningValidator.default;
16
+ }
17
+ });
18
+
19
+ var _warningValidator = _interopRequireDefault(require("./warningValidator"));
20
+
21
+ var _erroringValidator = _interopRequireDefault(require("./erroringValidator"));
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ajvCompiler = _interopRequireDefault(require("./ajvCompiler"));
9
+
10
+ var _schemas = require("../../schemas");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = _ajvCompiler.default.compile(_schemas.warningSchemaPackages);
15
+
16
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.studioIcons = exports.propertyTypes = exports.fieldTypes = exports.contextOptionTypes = void 0;
7
+ const contextOptionTypes = ['select', 'text', 'hidden'];
8
+ exports.contextOptionTypes = contextOptionTypes;
9
+ const propertyTypes = ['text', 'image', 'link', 'api', 'boolean'];
10
+ exports.propertyTypes = propertyTypes;
11
+ const fieldTypes = ['asset', 'checkbox', 'color', 'data-source', 'data-source-package', 'date', 'datetime', 'dynamic-text', 'font', 'image', 'map', 'number', 'oauth2', 'oAuthAccount', 'radio', 'select', 'text', 'token', 'upload', 'url'];
12
+ exports.fieldTypes = fieldTypes;
13
+ const studioIcons = ['align-bottom', 'align-center', 'align-left', 'align-middle', 'align-right', 'align-top', 'arrange-center', 'arrange-left', 'arrange-right', 'arrows-select', 'avatar', 'bar-chart', 'barcode', 'calendar', 'cart', 'chatter', 'clock', 'code', 'condensed-view', 'copy', 'countdown-timer', 'countdown', 'crop', 'cursor-grab', 'cursor-move', 'cursor', 'distribute-horizontal', 'distribute-vertical', 'dropdown-arrow', 'duplicate', 'expanded-view', 'external-link', 'globe', 'grab', 'image-layer', 'image', 'images', 'instagram', 'local-time', 'locked', 'map-helper', 'maps', 'media-library', 'minus', 'move', 'olapic', 'param', 'personal', 'picture', 'pie-chart', 'pin', 'pinterest', 'plus', 'polling', 'proximity-pin', 'QR', 'qr-code', 'redo', 'rotate', 'rss', 'settings', 'shape', 'sharing', 'square', 'text-center', 'text-justify', 'text-layer', 'text-left', 'text-right', 'text-tool', 'text-vector', 'text', 'tools', 'trash', 'twitter-favorite', 'twitter-retweet', 'twitter-username', 'twitter', 'undo', 'unlocked', 'vector-square', 'vector-tool', 'video', 'weather-average', 'weather-city', 'weather-day', 'weather-description', 'weather-high-temp', 'weather-icon', 'weather', 'workspace-barcode', 'workspace-favorites', 'workspace-instagram', 'workspace-olapic', 'workspace-picture', 'workspace-pinterest', 'workspace-qr-code', 'workspace-retweets', 'workspace-weather'];
14
+ exports.studioIcons = studioIcons;