Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions dist/LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

undici:7.22.0 -- MIT License
undici:7.24.7 -- MIT License

Copyright (c) Matteo Collina and Undici contributors

Expand Down Expand Up @@ -331,7 +331,7 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@octokit/request:10.0.7 -- The MIT License
@octokit/request:10.0.8 -- The MIT License

Copyright (c) 2018 Octokit contributors

Expand Down Expand Up @@ -450,7 +450,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


@actions/github:9.0.0 -- The MIT License (MIT)
@actions/github:9.1.0 -- The MIT License (MIT)

Copyright 2019 GitHub

Expand Down Expand Up @@ -489,7 +489,7 @@ Permission to use, copy, modify, and/or distribute this software for any purpose

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

@octokit/endpoint:11.0.2 -- The MIT License
@octokit/endpoint:11.0.3 -- The MIT License

Copyright (c) 2018 Octokit contributors

Expand Down Expand Up @@ -535,6 +535,28 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
json-with-bigint:3.5.8 -- MIT License

Copyright (c) 2023 Ivan Korolenko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@octokit/auth-token:6.0.0 -- The MIT License

Copyright (c) 2019 Octokit contributors
Expand Down
2 changes: 1 addition & 1 deletion dist/ajv-QtvvyOqs.mjs.map

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions dist/github-30evUmUL.mjs

This file was deleted.

1 change: 0 additions & 1 deletion dist/github-30evUmUL.mjs.map

This file was deleted.

19 changes: 19 additions & 0 deletions dist/github-D91hw1gk.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/github-D91hw1gk.mjs.map

Large diffs are not rendered by default.

217 changes: 125 additions & 92 deletions dist/github.d.mts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/github.d.mts.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/github.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import{t as e}from"./github-30evUmUL.mjs";const t=`<!-- happy-commit -->`;function n(e){return`${t}\n${e}`}function r(e,t){return e?e.body===t?{type:`noop`}:{type:`update`,commentId:e.id,body:t}:{type:`create`,body:t}}function i(e,t){return t.lucky?r(e,n(t.body)):e?{type:`delete`,commentId:e.id}:{type:`noop`}}async function a(t,n,r,a){let s=e,c=i(await o(t,n,r),a);switch(c.type){case`update`:await t.issues.updateComment({...s.repo,comment_id:c.commentId,body:c.body});return;case`create`:await t.issues.createComment({...s.repo,issue_number:n,body:c.body});return;case`delete`:await t.issues.deleteComment({...s.repo,comment_id:c.commentId});return;case`noop`:return}}async function o(t,n,r){let i=e,a=(await t.issues.listComments({...i.repo,issue_number:n})).data.find(e=>s(e,r));return a?{id:a.id,body:a.body_text||``}:null}function s(e,n){return e.user?.login===n&&(e.body||e.body_text||``).includes(t)}async function c(t){let n=e;return(await t.pulls.listCommits({...n.repo,pull_number:n.issue.number})).data.map(e=>e.sha)}async function l(t,n){let r=e,i=(await t.graphql(`
import{t as e}from"./github-D91hw1gk.mjs";const t=`<!-- happy-commit -->`;function n(e){return`${t}\n${e}`}function r(e,t){return e?e.body===t?{type:`noop`}:{type:`update`,commentId:e.id,body:t}:{type:`create`,body:t}}function i(e,t){return t.lucky?r(e,n(t.body)):e?{type:`delete`,commentId:e.id}:{type:`noop`}}async function a(t,n,r,a){let s=e,c=i(await o(t,n,r),a);switch(c.type){case`update`:await t.issues.updateComment({...s.repo,comment_id:c.commentId,body:c.body});return;case`create`:await t.issues.createComment({...s.repo,issue_number:n,body:c.body});return;case`delete`:await t.issues.deleteComment({...s.repo,comment_id:c.commentId});return;case`noop`:return}}async function o(t,n,r){let i=e,a=(await t.issues.listComments({...i.repo,issue_number:n})).data.find(e=>s(e,r));return a?{id:a.id,body:a.body_text||``}:null}function s(e,n){return e.user?.login===n&&(e.body||e.body_text||``).includes(t)}async function c(t){let n=e;return(await t.pulls.listCommits({...n.repo,pull_number:n.issue.number})).data.map(e=>e.sha)}async function l(t,n){let r=e,i=(await t.graphql(`
query ($owner: String!, $repo: String!, $expression: String!) {
repository(owner: $owner, name: $repo) {
object(expression: $expression) {
Expand Down
18 changes: 9 additions & 9 deletions dist/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mustache-BhZz4e-Z.mjs.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions dist/validate.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.d.ts
//#region node_modules/ajv/dist/compile/codegen/code.d.ts
declare abstract class _CodeOrName {
abstract readonly str: string;
abstract readonly names: UsedNames;
Expand Down Expand Up @@ -26,7 +26,7 @@ type CodeItem = Name | string | number | boolean | null;
type UsedNames = Record<string, number | undefined>;
type Code = _Code | Name;
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.d.ts
//#region node_modules/ajv/dist/compile/codegen/scope.d.ts
interface NameGroup {
prefix: string;
index: number;
Expand Down Expand Up @@ -98,7 +98,7 @@ declare class ValueScope extends Scope {
private _reduceValues;
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.d.ts
//#region node_modules/ajv/dist/compile/codegen/index.d.ts
type SafeExpr = Code | number | boolean | null;
type Block = Code | (() => void);
interface CodeGenOptions {
Expand Down Expand Up @@ -159,7 +159,7 @@ declare class CodeGen {
private set _currNode(value);
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.d.ts
//#region node_modules/ajv/dist/compile/rules.d.ts
declare const _jsonTypes: readonly ["string", "number", "integer", "boolean", "null", "object", "array"];
type JSONType$1 = (typeof _jsonTypes)[number];
type ValidationTypes = { [K in JSONType$1]: boolean | RuleGroup | undefined };
Expand All @@ -179,13 +179,13 @@ interface Rule {
definition: AddedKeywordDefinition;
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.d.ts
//#region node_modules/ajv/dist/compile/util.d.ts
declare enum Type {
Num = 0,
Str = 1
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.d.ts
//#region node_modules/ajv/dist/compile/validate/subschema.d.ts
type SubschemaArgs = Partial<{
keyword: string;
schemaProp: string | number;
Expand All @@ -206,14 +206,14 @@ type SubschemaArgs = Partial<{
allErrors: boolean;
}>;
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.d.ts
//#region node_modules/ajv/dist/compile/errors.d.ts
interface ErrorPaths {
instancePath?: Code;
schemaPath?: string;
parentSchema?: boolean;
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.d.ts
//#region node_modules/ajv/dist/compile/validate/index.d.ts
declare class KeywordCxt implements KeywordErrorCxt {
readonly gen: CodeGen;
readonly allErrors?: boolean;
Expand Down Expand Up @@ -249,7 +249,7 @@ declare class KeywordCxt implements KeywordErrorCxt {
mergeValidEvaluated(schemaCxt: SchemaCxt, valid: Name): boolean | void;
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/types/json-schema.d.ts
//#region node_modules/ajv/dist/types/json-schema.d.ts
type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends ((_: infer I) => void) ? I : never;
type UncheckedPartialSchema<T> = Partial<UncheckedJSONSchemaType<T, true>>;
Expand Down Expand Up @@ -359,7 +359,7 @@ type Nullable<T> = undefined extends T ? {
default?: T;
};
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/types/jtd-schema.d.ts
//#region node_modules/ajv/dist/types/jtd-schema.d.ts
/** numeric strings */
type NumberType = "float32" | "float64" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32";
/** string strings */
Expand Down Expand Up @@ -502,22 +502,22 @@ type JTDDataType<S> = S extends {
definitions: Record<string, unknown>;
} ? JTDDataDef<S, S["definitions"]> : JTDDataDef<S, Record<string, never>>;
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.d.ts
//#region node_modules/ajv/dist/runtime/validation_error.d.ts
declare class ValidationError extends Error {
readonly errors: Partial<ErrorObject>[];
readonly ajv: true;
readonly validation: true;
constructor(errors: Partial<ErrorObject>[]);
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.d.ts
//#region node_modules/ajv/dist/compile/ref_error.d.ts
declare class MissingRefError extends Error {
readonly missingRef: string;
readonly missingSchema: string;
constructor(resolver: UriResolver, baseId: string, ref: string, msg?: string);
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts
//#region node_modules/ajv/dist/core.d.ts
type Options = CurrentOptions & DeprecatedOptions;
interface CurrentOptions {
strict?: boolean | "log";
Expand Down Expand Up @@ -664,10 +664,10 @@ interface ErrorsTextOptions {
dataVar?: string;
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.d.ts
//#region node_modules/ajv/dist/compile/resolve.d.ts
type LocalRefs = { [Ref in string]?: AnySchemaObject };
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.d.ts
//#region node_modules/ajv/dist/compile/index.d.ts
type SchemaRefs = { [Ref in string]?: SchemaEnv | AnySchema };
interface SchemaCxt {
readonly gen: CodeGen;
Expand Down Expand Up @@ -733,7 +733,7 @@ declare class SchemaEnv implements SchemaEnvArgs {
constructor(env: SchemaEnvArgs);
}
//#endregion
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/types/index.d.ts
//#region node_modules/ajv/dist/types/index.d.ts
interface _SchemaObject {
id?: string;
$id?: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/validate.d.mts.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/validate.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import{r as e}from"./chunk-Bwx8J3ba.mjs";import{t}from"./ajv-QtvvyOqs.mjs";const n=new(e(t())).default().compile({$schema:`http://json-schema.org/draft-07/schema#`,items:{additionalProperties:!1,properties:{kind:{enum:[`commit`,`pr`],type:`string`},message:{type:`string`},rule:{type:`string`}},type:`object`},type:`array`});export{n as validateRules};
import{r as e}from"./chunk-Bwx8J3ba.mjs";import{t}from"./ajv-QtvvyOqs.mjs";const n=new(e(t())).default().compile({$schema:`http://json-schema.org/draft-07/schema#`,items:{additionalProperties:!1,properties:{kind:{enum:[`commit`,`pr`],type:`string`},message:{type:`string`},rule:{type:`string`}},required:[`kind`,`rule`,`message`],type:`object`},type:`array`});export{n as validateRules};
//# sourceMappingURL=validate.mjs.map
2 changes: 1 addition & 1 deletion dist/validate.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"test": "vitest run --coverage",
"lint": "biome check ./",
"format": "biome check --write ./",
"generate-json-schema": "typescript-json-schema --strictNullChecks true --noExtraProps true src/rules.ts RuleStringPatterns > ./schema.json"
"generate-json-schema": "typescript-json-schema --strictNullChecks true --noExtraProps true --required src/rules.ts RuleStringPatterns > ./schema.json"
},
"dependencies": {
"@actions/core": "^3.0.0",
Expand Down
1 change: 1 addition & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"type": "string"
}
},
"required": ["kind", "message", "rule"],
"type": "object"
},
"type": "array"
Expand Down
18 changes: 18 additions & 0 deletions src/rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ describe('parseRules', () => {
).toThrowError('Invalid rules')
})

it('throws when passed rules missing required fields', () => {
expect(() =>
parseRules(
'[{"rule": "(?:[1]0+)", "message": "Now pull request issue number reaches **{{prNum}}**. It\'s time to celebrate!"}]'
)
).toThrowError('Invalid rules')

expect(() =>
parseRules(
'[{"kind": "pr", "message": "Now pull request issue number reaches **{{prNum}}**. It\'s time to celebrate!"}]'
)
).toThrowError('Invalid rules')

expect(() =>
parseRules('[{"kind": "pr", "rule": "(?:[1]0+)"}]')
).toThrowError('Invalid rules')
})

it('throws when passed broken regexp pattern', () => {
expect(() =>
parseRules(
Expand Down
1 change: 1 addition & 0 deletions src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const schema = {
type: 'string',
},
},
required: ['kind', 'rule', 'message'],
type: 'object',
},
type: 'array',
Expand Down
Loading