maasglobal-schema-generator-io-ts
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -0,2 +1,3 @@ | ||
import { SchemaPackage } from 'maasglobal-schema-package'; | ||
export declare const logHeader = "# io-ts code generation log\n\n"; | ||
export declare function generateCodecs(sourceDir: string): Promise<void>; | ||
export declare function generateCodecs(pkg: SchemaPackage): Promise<void>; |
@@ -106,12 +106,10 @@ "use strict"; | ||
exports.logHeader = '# io-ts code generation log\n\n'; | ||
var relativeLogPath = path_1.default.posix.join('src', 'io-ts', '_translation.log'); | ||
function runConverter(sourceDir) { | ||
var relativeLogPath = path_1.default.posix.join('io-ts', '_translation.log'); | ||
function runConverter(pkg) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var schemaGlob, typesDir, manifestPath, manifest, base, deps, importArgs, imports, args, logPath, errStream; | ||
return __generator(this, function (_a) { | ||
schemaGlob = path_1.default.posix.join(sourceDir, 'schemas', '**', '*.json'); | ||
typesDir = path_1.default.posix.join(sourceDir, 'src', 'io-ts', '_types'); | ||
manifestPath = path_1.default.resolve(__dirname, path_1.default.join(sourceDir, 'schemas.json')); | ||
manifest = require(manifestPath); | ||
base = manifest.base, deps = manifest.deps; | ||
var schemaGlob, typesDir, _a, base, deps, importArgs, imports, args, logPath, errStream; | ||
return __generator(this, function (_b) { | ||
schemaGlob = path_1.default.posix.join(pkg.paths.schemas, '**', '*.json'); | ||
typesDir = path_1.default.posix.join(pkg.paths.src, 'io-ts', '_types'); | ||
_a = pkg.manifest, base = _a.base, deps = _a.deps; | ||
importArgs = Object.entries(deps).map(function (_a) { | ||
@@ -134,3 +132,3 @@ var _b = __read(_a, 2), depBase = _b[0], dep = _b[1]; | ||
], false); | ||
logPath = path_1.default.posix.join(sourceDir, relativeLogPath); | ||
logPath = path_1.default.posix.join(pkg.paths.src, relativeLogPath); | ||
errStream = fs_.createWriteStream(logPath); | ||
@@ -148,7 +146,7 @@ errStream.write(exports.logHeader); | ||
} | ||
function getLog(sourceDir) { | ||
function getLog(pkg) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var logPath; | ||
return __generator(this, function (_a) { | ||
logPath = path_1.default.posix.join(sourceDir, relativeLogPath); | ||
logPath = path_1.default.posix.join(pkg.paths.src, relativeLogPath); | ||
return [2 /*return*/, fs_.readFileSync(logPath, 'utf8')]; | ||
@@ -189,3 +187,3 @@ }); | ||
} | ||
function generateCodecs(sourceDir) { | ||
function generateCodecs(pkg) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -195,3 +193,3 @@ var log, lines; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, runConverter(sourceDir)]; | ||
case 0: return [4 /*yield*/, runConverter(pkg)]; | ||
case 1: | ||
@@ -203,3 +201,3 @@ _a.sent(); | ||
if (!(log.length < exports.logHeader.length)) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, getLog(sourceDir)]; | ||
return [4 /*yield*/, getLog(pkg)]; | ||
case 3: | ||
@@ -206,0 +204,0 @@ // eslint-disable-next-line fp/no-mutation |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -43,2 +66,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
exports.main = void 0; | ||
var fs_ = __importStar(require("fs")); | ||
var maasglobal_schema_package_1 = require("maasglobal-schema-package"); | ||
var path_1 = __importDefault(require("path")); | ||
@@ -48,10 +73,15 @@ var yargs_1 = __importDefault(require("yargs")); | ||
var update_interfaces_1 = require("./update-interfaces"); | ||
function _main(sourceDir) { | ||
function _main(rootDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var pkg, targetDir; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, generate_codecs_1.generateCodecs)(sourceDir)]; | ||
case 0: | ||
pkg = (0, maasglobal_schema_package_1.parseSchemaPackage)(rootDir); | ||
targetDir = path_1.default.posix.join(pkg.paths.src, 'io-ts'); | ||
fs_.mkdirSync(targetDir, { recursive: true }); | ||
return [4 /*yield*/, (0, generate_codecs_1.generateCodecs)(pkg)]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, (0, update_interfaces_1.updateInterfaces)(sourceDir)]; | ||
return [4 /*yield*/, (0, update_interfaces_1.updateInterfaces)(pkg)]; | ||
case 2: | ||
@@ -58,0 +88,0 @@ _a.sent(); |
@@ -1,1 +0,2 @@ | ||
export declare function updateInterfaces(sourceDir: string): Promise<void>; | ||
import { SchemaPackage } from 'maasglobal-schema-package'; | ||
export declare function updateInterfaces(pkg: SchemaPackage): Promise<void>; |
@@ -102,3 +102,3 @@ "use strict"; | ||
var path_ = __importStar(require("path")); | ||
function updateInterfaces(sourceDir) { | ||
function updateInterfaces(pkg) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -247,3 +247,3 @@ function unsafeReportDone(pathPrefix) { | ||
dirTest = '__tests__'; | ||
root = path_.join(sourceDir, 'src', 'io-ts'); | ||
root = path_.join(pkg.paths.src, 'io-ts'); | ||
rootTypes = path_.join(root, dirTypes); | ||
@@ -250,0 +250,0 @@ rootUtils = path_.join(root, dirUtils); |
{ | ||
"name": "maasglobal-schema-generator-io-ts", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -15,2 +15,3 @@ "license": "MIT", | ||
"io-ts-from-json-schema": "^0.0.23", | ||
"maasglobal-schema-package": "^0.0.1", | ||
"yargs": "^17.6.2" | ||
@@ -35,3 +36,2 @@ }, | ||
"jest": "^26.6.3", | ||
"maasglobal-json-schema-validator": "^0.0.6", | ||
"prettier": "^2.2.1", | ||
@@ -38,0 +38,0 @@ "ts-jest": "^26.5.5", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
33769
19
631
3
1
+ Addedmaasglobal-schema-package@0.0.1(transitive)