chore: Repository cleanup and re-structure

This commit is contained in:
Britton Hayes 2021-12-24 14:13:55 -08:00
parent 298a8f153c
commit 77cf0d80af
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 922B4F3652980643
16 changed files with 724 additions and 747 deletions

View file

@ -1,4 +1,3 @@
dist/
lib/
node_modules/
jest.config.js

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
# Dependency directory
node_modules
dist
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs

View file

@ -1,9 +0,0 @@
import {validateYAML} from '../src/validate'
import {expect, test} from '@jest/globals'
test('valid yaml files', async () => {
const files: string[] = ['__tests__/valid.yaml']
const schemaPath: string = '__tests__/schema.json'
await expect(validateYAML(files, schemaPath)).resolves.toBe(0)
})

120
dist/index.js generated vendored
View file

@ -1,7 +1,7 @@
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 822:
/***/ 283:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
@ -36,13 +36,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(186));
const validate_1 = __nccwpck_require__(997);
const validate_1 = __nccwpck_require__(751);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const files = core.getMultilineInput('files');
const schemaPath = core.getInput('schemaPath');
yield (0, validate_1.validateYAML)(files, schemaPath);
const validator = new validate_1.Validator({
files: core.getMultilineInput('files'),
schemaPath: core.getInput('schemaPath')
});
yield validator.ValidateYAML();
}
catch (error) {
core.setFailed(error.message);
@ -54,7 +56,7 @@ run();
/***/ }),
/***/ 997:
/***/ 751:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
@ -72,28 +74,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.validateYAML = void 0;
exports.Validator = void 0;
const yaml_validator_1 = __importDefault(__nccwpck_require__(551));
const fs_1 = __importDefault(__nccwpck_require__(747));
function validateYAML(files, schemaPath) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const structure = fs_1.default.readFileSync(schemaPath, { encoding: 'utf-8' });
const options = {
log: 'validator.log',
onWarning: (err, file) => {
reject(new Error(`File: ${file} - ${err.message}`));
},
structure: JSON.parse(structure),
writeJson: false
};
const validator = new yaml_validator_1.default(options);
validator.validate(files);
resolve(validator.report());
const fs_1 = __importDefault(__nccwpck_require__(147));
class Validator {
constructor(props) {
this.props = props;
}
ValidateYAML() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const structure = fs_1.default.readFileSync(this.props.schemaPath, { encoding: 'utf-8' });
const validator = new yaml_validator_1.default({
log: 'validator.log',
structure: JSON.parse(structure),
writeJson: false,
onWarning: (err, file) => {
reject(new Error(`File: ${file} - ${err.message}`));
},
});
validator.validate((this.props.files));
resolve(validator.report());
});
});
});
}
}
exports.validateYAML = validateYAML;
exports.Validator = Validator;
/***/ }),
@ -124,7 +130,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issue = exports.issueCommand = void 0;
const os = __importStar(__nccwpck_require__(87));
const os = __importStar(__nccwpck_require__(37));
const utils_1 = __nccwpck_require__(278);
/**
* Commands
@ -235,8 +241,8 @@ exports.getIDToken = exports.getState = exports.saveState = exports.group = expo
const command_1 = __nccwpck_require__(351);
const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(278);
const os = __importStar(__nccwpck_require__(87));
const path = __importStar(__nccwpck_require__(622));
const os = __importStar(__nccwpck_require__(37));
const path = __importStar(__nccwpck_require__(17));
const oidc_utils_1 = __nccwpck_require__(41);
/**
* The code to exit an action
@ -545,8 +551,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issueCommand = void 0;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__nccwpck_require__(747));
const os = __importStar(__nccwpck_require__(87));
const fs = __importStar(__nccwpck_require__(147));
const os = __importStar(__nccwpck_require__(37));
const utils_1 = __nccwpck_require__(278);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
@ -768,8 +774,8 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
const http = __nccwpck_require__(605);
const https = __nccwpck_require__(211);
const http = __nccwpck_require__(685);
const https = __nccwpck_require__(687);
const pm = __nccwpck_require__(443);
let tunnel;
var HttpCodes;
@ -1423,7 +1429,7 @@ module.exports.types = {
int: __nccwpck_require__(615),
merge: __nccwpck_require__(104),
omap: __nccwpck_require__(46),
seq: __nccwpck_require__(283),
seq: __nccwpck_require__(546),
str: __nccwpck_require__(619)
};
@ -4435,7 +4441,7 @@ module.exports = __nccwpck_require__(35);
module.exports = __nccwpck_require__(11).extend({
module.exports = (__nccwpck_require__(11).extend)({
implicit: [
__nccwpck_require__(212),
__nccwpck_require__(104)
@ -4468,7 +4474,7 @@ var Schema = __nccwpck_require__(82);
module.exports = new Schema({
explicit: [
__nccwpck_require__(619),
__nccwpck_require__(283),
__nccwpck_require__(546),
__nccwpck_require__(150)
]
});
@ -4491,7 +4497,7 @@ module.exports = new Schema({
module.exports = __nccwpck_require__(562).extend({
module.exports = (__nccwpck_require__(562).extend)({
implicit: [
__nccwpck_require__(721),
__nccwpck_require__(993),
@ -5323,7 +5329,7 @@ module.exports = new Type('tag:yaml.org,2002:pairs', {
/***/ }),
/***/ 283:
/***/ 546:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
@ -5502,13 +5508,13 @@ module.exports = __nccwpck_require__(219);
"use strict";
var net = __nccwpck_require__(631);
var tls = __nccwpck_require__(16);
var http = __nccwpck_require__(605);
var https = __nccwpck_require__(211);
var events = __nccwpck_require__(614);
var assert = __nccwpck_require__(357);
var util = __nccwpck_require__(669);
var net = __nccwpck_require__(808);
var tls = __nccwpck_require__(404);
var http = __nccwpck_require__(685);
var https = __nccwpck_require__(687);
var events = __nccwpck_require__(361);
var assert = __nccwpck_require__(491);
var util = __nccwpck_require__(837);
exports.httpOverHttp = httpOverHttp;
@ -7127,10 +7133,10 @@ exports.debug = debug; // for test
* Licensed under the MIT license.
*/
const fs = __nccwpck_require__(747);
const fs = __nccwpck_require__(147);
const yaml = __nccwpck_require__(917);
const check = __nccwpck_require__(34).init();
const check = (__nccwpck_require__(34).init)();
const FIND_LINENUMBER = /line (\d+)/u;
@ -7354,7 +7360,7 @@ module.exports = YamlValidatore;
/***/ }),
/***/ 357:
/***/ 491:
/***/ ((module) => {
"use strict";
@ -7362,7 +7368,7 @@ module.exports = require("assert");
/***/ }),
/***/ 614:
/***/ 361:
/***/ ((module) => {
"use strict";
@ -7370,7 +7376,7 @@ module.exports = require("events");
/***/ }),
/***/ 747:
/***/ 147:
/***/ ((module) => {
"use strict";
@ -7378,7 +7384,7 @@ module.exports = require("fs");
/***/ }),
/***/ 605:
/***/ 685:
/***/ ((module) => {
"use strict";
@ -7386,7 +7392,7 @@ module.exports = require("http");
/***/ }),
/***/ 211:
/***/ 687:
/***/ ((module) => {
"use strict";
@ -7394,7 +7400,7 @@ module.exports = require("https");
/***/ }),
/***/ 631:
/***/ 808:
/***/ ((module) => {
"use strict";
@ -7402,7 +7408,7 @@ module.exports = require("net");
/***/ }),
/***/ 87:
/***/ 37:
/***/ ((module) => {
"use strict";
@ -7410,7 +7416,7 @@ module.exports = require("os");
/***/ }),
/***/ 622:
/***/ 17:
/***/ ((module) => {
"use strict";
@ -7418,7 +7424,7 @@ module.exports = require("path");
/***/ }),
/***/ 16:
/***/ 404:
/***/ ((module) => {
"use strict";
@ -7426,7 +7432,7 @@ module.exports = require("tls");
/***/ }),
/***/ 669:
/***/ 837:
/***/ ((module) => {
"use strict";
@ -7476,7 +7482,7 @@ module.exports = require("util");
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(822);
/******/ var __webpack_exports__ = __nccwpck_require__(283);
/******/ module.exports = __webpack_exports__;
/******/
/******/ })()

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

36
dist/validate.js generated vendored Normal file
View file

@ -0,0 +1,36 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateYAML = void 0;
const yaml_validator_1 = __importDefault(require("yaml-validator"));
const fs_1 = __importDefault(require("fs"));
function validateYAML(files, schemaPath) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const structure = fs_1.default.readFileSync(schemaPath, { encoding: 'utf-8' });
const options = {
log: 'validator.log',
onWarning: (err, file) => {
reject(new Error(`File: ${file} - ${err.message}`));
},
structure: JSON.parse(structure),
writeJson: false
};
const validator = new yaml_validator_1.default(options);
validator.validate(files);
resolve(validator.report());
});
});
}
exports.validateYAML = validateYAML;

View file

@ -1,13 +1,13 @@
{
"name": "validate-yaml",
"version": "0.0.0",
"private": true,
"private": false,
"description": "Validate YAML against a schema using github actions",
"main": "lib/index.js",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"format:check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
@ -15,13 +15,13 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/brittonhayes/wails-build-action.git"
"url": "git+https://github.com/brittonhayes/validate-yaml.git"
},
"keywords": [
"actions",
"node",
"go",
"wails"
"typescript",
"yaml"
],
"author": "Britton Hayes",
"license": "MIT",

View file

@ -0,0 +1,12 @@
// eslint-disable-next-line filenames/match-regex
import * as t from '@jest/globals'
import {Validator} from '../lib/validate'
t.test('valid yaml files', async () => {
const validator = new Validator({
files: ['src/__tests__/valid.yaml'],
schemaPath: 'src/__tests__/schema.json'
})
await t.expect(validator.ValidateYAML()).resolves.toBe(0)
})

View file

@ -1,12 +1,14 @@
import * as core from '@actions/core'
import {validateYAML} from './validate'
import {Validator} from './lib/validate'
async function run(): Promise<void> {
try {
const files: string[] = core.getMultilineInput('files')
const schemaPath: string = core.getInput('schemaPath')
const validator = new Validator({
files: core.getMultilineInput('files'),
schemaPath: core.getInput('schemaPath')
})
await validateYAML(files, schemaPath)
await validator.ValidateYAML()
} catch (error) {
core.setFailed((error as Error).message)
}

33
src/lib/validate.ts Normal file
View file

@ -0,0 +1,33 @@
import YamlValidator from 'yaml-validator'
import fs from 'fs'
export interface ValidatorProps {
files: string[]
schemaPath: string
}
export class Validator {
props: ValidatorProps
constructor(props: ValidatorProps) {
this.props = props
}
async ValidateYAML(): Promise<Number> {
return new Promise((resolve, reject) => {
const structure = fs.readFileSync(this.props.schemaPath, { encoding: 'utf-8' })
const validator = new YamlValidator({
log: 'validator.log',
structure: JSON.parse(structure),
writeJson: false,
onWarning: (err, file) => {
reject(new Error(`File: ${file} - ${err.message}`))
},
})
validator.validate((this.props.files))
resolve(validator.report())
})
}
}

View file

@ -1,23 +0,0 @@
import YamlValidator, {IYamlValidatorOptions} from 'yaml-validator'
import fs from 'fs'
export async function validateYAML(
files: string[],
schemaPath: string
): Promise<number> {
return new Promise((resolve, reject) => {
const structure = fs.readFileSync(schemaPath, {encoding: 'utf-8'})
const options: IYamlValidatorOptions = {
log: 'validator.log',
onWarning: (err, file) => {
reject(new Error(`File: ${file} - ${err.message}`))
},
structure: JSON.parse(structure),
writeJson: false
}
const validator = new YamlValidator(options)
validator.validate(files)
resolve(validator.report())
})
}

View file

@ -1,12 +1,14 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}
"exclude": [
"node_modules",
]
}

1190
yarn.lock

File diff suppressed because it is too large Load diff