codify-schemas 1.0.38 → 1.0.40

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.
@@ -4,6 +4,14 @@
4
4
  "title": "Config file Schema",
5
5
  "type": "array",
6
6
  "items": {
7
- "$ref": "resource-schema.json"
7
+ "type": "object",
8
+ "properties": {
9
+ "type": {
10
+ "type": "string",
11
+ "description": "All config blocks must contain the keyword type",
12
+ "pattern": "^[a-zA-Z][\\w-]+$"
13
+ }
14
+ },
15
+ "required": ["type"]
8
16
  }
9
17
  }
@@ -7,12 +7,12 @@
7
7
  "type": {
8
8
  "description": "The resource type",
9
9
  "type": "string",
10
- "pattern": "^[a-zA-Z-_][\\w-]+$"
10
+ "pattern": "^[a-zA-Z][\\w-]+$"
11
11
  },
12
12
  "name": {
13
13
  "description": "Optional name. Useful for specifying multiple resources of the same type",
14
14
  "type": "string",
15
- "pattern": "^[a-zA-Z-_][\\w-]+$"
15
+ "pattern": "^[\\w-]+$"
16
16
  },
17
17
  "dependsOn": {
18
18
  "type": "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-schemas",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -4,6 +4,14 @@
4
4
  "title": "Config file Schema",
5
5
  "type": "array",
6
6
  "items": {
7
- "$ref": "resource-schema.json"
7
+ "type": "object",
8
+ "properties": {
9
+ "type": {
10
+ "type": "string",
11
+ "description": "All config blocks must contain the keyword type",
12
+ "pattern": "^[a-zA-Z][\\w-]+$"
13
+ }
14
+ },
15
+ "required": ["type"]
8
16
  }
9
17
  }
@@ -1,20 +1,20 @@
1
- import configSchema from './config-file-schema.json';
2
- import resourceSchema from './resource-schema.json';
1
+ import configFileSchema from './config-file-schema.json';
3
2
  import { describe, it, expect } from 'vitest'
4
3
  import Ajv2020 from 'ajv/dist/2020.js'
5
4
 
6
5
  const ajv = new Ajv2020.default({
7
6
  strict: true,
8
7
  })
9
- ajv.addSchema(resourceSchema);
10
8
 
11
- describe("config file schema tests", () => {
12
- it('compiles', () => {
13
- ajv.compile(configSchema);
9
+ describe("Config file schema tests", () => {
10
+ it('Compiles', () => {
11
+ ajv.compile(configFileSchema);
14
12
  })
15
13
 
16
- it('accepts resource blocks', () => {
17
- const validator = ajv.compile(configSchema);
14
+ it('And successfully validate blocks with type', () => {
15
+ const validator = ajv.compile(configFileSchema);
16
+
17
+ expect(validator([])).to.be.true;
18
18
 
19
19
  expect(validator([
20
20
  {
@@ -33,18 +33,37 @@ describe("config file schema tests", () => {
33
33
  expect(validator([
34
34
  {
35
35
  "type": "resource1",
36
- },
37
- {}
38
- ])).to.be.false;
36
+ }
37
+ ])).to.be.true;
39
38
 
40
39
  expect(validator([
41
40
  {
42
41
  "type": "project",
43
- },
44
- {
45
- "type": "resource2"
42
+ "description": "description",
46
43
  }
47
44
  ])).to.be.true;
48
45
  })
49
46
 
47
+ it('And errors on improper json', () => {
48
+ const validator = ajv.compile(configFileSchema);
49
+
50
+ expect(validator({
51
+ "a": {},
52
+ "b": {},
53
+ })).to.be.false;
54
+
55
+ expect(validator([
56
+ {
57
+ "type": "resource1"
58
+ },
59
+ "homebrew"
60
+ ])).to.be.false;
61
+
62
+ expect(validator([
63
+ {
64
+ "type": "resource1"
65
+ },
66
+ {}
67
+ ])).to.be.false;
68
+ })
50
69
  })
@@ -7,12 +7,12 @@
7
7
  "type": {
8
8
  "description": "The resource type",
9
9
  "type": "string",
10
- "pattern": "^[a-zA-Z-_][\\w-]+$"
10
+ "pattern": "^[a-zA-Z][\\w-]+$"
11
11
  },
12
12
  "name": {
13
13
  "description": "Optional name. Useful for specifying multiple resources of the same type",
14
14
  "type": "string",
15
- "pattern": "^[a-zA-Z-_][\\w-]+$"
15
+ "pattern": "^[\\w-]+$"
16
16
  },
17
17
  "dependsOn": {
18
18
  "type": "array",
@@ -24,7 +24,8 @@ describe("Resource schema tests", () => {
24
24
  expect(validate({ type: "ABCDEF$"})).to.be.false;
25
25
 
26
26
  expect(validate({ type: "type", name: "a234abcDEF_-"})).to.be.true;
27
- expect(validate({ type: "type", name: "234"})).to.be.false;
27
+ expect(validate({ type: "type", name: "0"})).to.be.true;
28
+ expect(validate({ type: "type", name: "[]"})).to.be.false;
28
29
  expect(validate({ type: "type", name: "ABCDEF$"})).to.be.false;
29
30
  });
30
31
 
@@ -1,4 +1,4 @@
1
- import { SpawnOptions } from "node:child_process";
1
+ import {SpawnOptions} from "node:child_process";
2
2
 
3
3
  export interface StringIndexedObject {
4
4
  [x: string]: unknown;
@@ -1,32 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "Config file Schema",
4
- "type": "object",
5
- "properties": {
6
- "$id": {
7
- "type": "string",
8
- "pattern": "^https://www.codify.com/"
9
- },
10
- "type": {
11
- "const": "object"
12
- },
13
- "properties": {
14
- "type": "object",
15
- "properties": {
16
- "type": false,
17
- "name": false,
18
- "dependsOn": false,
19
- "$ref": {
20
- "const": "https://www.codify.com/resource-schema.json#properties"
21
- }
22
- }
23
- },
24
- "$ref": {
25
- "const": "https://www.codify.com/resource-schema.json"
26
- },
27
- "unevaluatedProperties": {
28
- "const": false
29
- }
30
- },
31
- "required": ["unevaluatedProperties", "$ref"]
32
- }