Skip to content

Commit

Permalink
Merge pull request #307 from Exabyte-io/update/SOF-7299
Browse files Browse the repository at this point in the history
SOF-7299: update tsconfig and timestampable
  • Loading branch information
k0stik committed Mar 25, 2024
2 parents 9f9ad68 + 9defda2 commit c954ec4
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 667 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ jobs:
shell: bash -l {0}
run: |
npm install
echo "Building Schemas and Examples"
npm run build:assets-with-docs
echo "List build directory ./docs/js"
ls -l docs/js
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lib/
*.egg-info/
*.py[cod]

dist/
# "dist" folder is not ignored on purpose to be able to install intermediate changes from github commits

.npmignore
.nyc_output
Expand Down
8 changes: 6 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ if git diff --cached --name-only | grep --quiet -E "$SRC_PATTERN"
then
echo "JSON assets changed. Running build scripts."
echo "Re-building JS and PY assets using JS script."
npm run build:js-and-python-modules
npm run transpile-and-build-assets
fi

npx lint-staged
npx lint-staged --allow-empty

npm run lint:fix
npm run transpile

5 changes: 3 additions & 2 deletions build_schemas.js → build_schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* at build time and writes them out to a single schemas.js file for
* downstream consumption to avoid FS calls in the browser.
*/
const fs = require("fs");
const JSONSchemasGenerator = require("./dist/js/esse/JSONSchemasGenerator").default;
import * as fs from "fs";

import JSONSchemasGenerator from "./src/js/esse/JSONSchemasGenerator";

// JS Modules

Expand Down
5 changes: 0 additions & 5 deletions modules.d.ts

This file was deleted.

1,150 changes: 547 additions & 603 deletions package-lock.json

Large diffs are not rendered by default.

53 changes: 25 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
"description": "Mat3ra's Excellent Source of Schemas and Examples (ESSE) for Digital Materials R&D",
"scripts": {
"prepublishOnly": "rm -rf dist; npm run transpile",
"transpile": "tsc && BUILD_ASSETS=true BUILD_PATH='./dist/js' node build_schemas.js",
"transpile-and-build-assets": "npm run transpile && ts-node compile_ts.ts",
"build:assets": "node build_schemas.js",
"build:js-and-python-modules": "BUILD_PYTHON_MODULES=true node build_schemas.js",
"build:assets-with-docs": "BUILD_ASSETS=true node build_schemas.js",
"test": "nyc --reporter=text mocha --recursive --bail tests/js",
"test-only": "nyc --reporter=text mocha --bail",
"transpile": "tsc -p tsconfig-transpile.json",
"build-schemas": "BUILD_ASSETS=true BUILD_PYTHON_MODULES=true BUILD_PATH='./dist/js' ts-node build_schemas.ts",
"compile-types": "ts-node compile_ts.ts",
"transpile-and-build-assets": "npm run transpile && npm run build-schemas && npm run compile-types",
"test": "npm run build-schemas && nyc --reporter=text mocha --recursive --bail tests/js",
"test-only": "nyc --reporter=text mocha --recursive --bail tests/js",
"lint": "eslint src/js && prettier --write src/js",
"lint:fix": "eslint --fix --cache src/js && prettier --write src/js",
"prettier": "prettier --check src/js",
"postinstall": "npm run transpile-and-build-assets",
"prepare": "husky install || exit 0",
"set-schema-ids": "ts-node set_schema_ids.ts"
},
Expand All @@ -31,7 +29,7 @@
"homepage": "https://github.com/Exabyte-io/esse",
"devDependencies": {
"@exabyte-io/eslint-config": "^2023.8.29-1",
"@mat3ra/tsconfig": "^2024.3.21-5",
"@mat3ra/tsconfig": "^2024.3.25-3",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"chai": "4.3.4",
Expand Down Expand Up @@ -69,13 +67,12 @@
"@babel/preset-typescript": "^7.22.5",
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@tsconfig/node14": "^14.1.0",
"@tsconfig/node20": "^20.1.2",
"@types/chai": "^4.3.11",
"@types/js-yaml": "^4.0.9",
"@types/json-schema-merge-allof": "^0.6.5",
"@types/mocha": "^10.0.6",
"@types/js-yaml": "^4.0.9",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"js-yaml": "^4.1.0",
"json-schema": "^0.4.0",
"json-schema-deref-sync": "0.14.0",
Expand All @@ -91,21 +88,21 @@
"*.{js,css}": "prettier --write"
},
"exports": {
"./lib/js/schema/*": "./dist/schema/*",
"./lib/js/example/*": "./dist/example/*",
"./lib/js/utils/*": "./dist/utils/*.js",
"./lib/js/esse/*": "./dist/esse/*.js",
"./lib/js/json_include/*": "./dist/json_include/*.js",
"./lib/js/scripts/*": "./dist/scripts/*.js",
"./lib/js/types.ts": "./dist/types.ts",
"./lib/js/schemas.json": "./dist/schemas.ts",
"./dist/schema/*": "./dist/schema/*",
"./dist/example/*": "./dist/example/*",
"./dist/utils/*": "./dist/utils/*.js",
"./dist/esse/*": "./dist/esse/*.js",
"./dist/json_include/*": "./dist/json_include/*.js",
"./dist/scripts/*": "./dist/scripts/*.js",
"./dist/types.ts": "./dist/types.ts",
"./dist/schemas.json": "./dist/js/schemas.ts"
"./lib/js/schema/*.json": "./dist/js/schema/*.json",
"./lib/js/example/*": "./dist/js/example/*.js",
"./lib/js/utils/*": "./dist/js/utils/*.js",
"./lib/js/esse/*": "./dist/js/esse/*.js",
"./lib/js/json_include/*": "./dist/js/json_include/*.js",
"./lib/js/scripts/*": "./dist/js/scripts/*.js",
"./lib/js/types": "./dist/js/types.ts",
"./lib/js/schemas.json": "./dist/js/schemas.json",
"./dist/schema/*.json": "./dist/js/schema/*.json",
"./dist/example/*": "./dist/js/example/*.js",
"./dist/utils/*": "./dist/js/utils/*.js",
"./dist/esse/*": "./dist/js/esse/*.js",
"./dist/json_include/*": "./dist/js/json_include/*.js",
"./dist/scripts/*": "./dist/js/scripts/*.js",
"./dist/types": "./dist/js/types.ts",
"./dist/schemas.json": "./dist/js/schemas.json"
}
}
18 changes: 2 additions & 16 deletions schema/system/timestampable.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,10 @@
"format": "date-time"
},
"createdBy": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
"type": "string"
},
"updatedBy": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
"type": "string"
}
}
}
6 changes: 5 additions & 1 deletion src/js/utils/ajv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {} from "ajv"; // @see https://github.com/microsoft/TypeScript/issues/47663
import Ajv, { SchemaObject } from "ajv";
import { AnyValidateFunction } from "ajv/dist/core";
import addFormats from "ajv-formats";

import { mapObjectDeep } from "../esse/schemaUtils";
import { AnyObject } from "../esse/types";
Expand Down Expand Up @@ -43,6 +43,10 @@ const ajvValidatorAndCleanerWithCoercingTypes = new Ajv({
coerceTypes: true,
});

addFormats(ajvValidator);
addFormats(ajvValidatorAndCleaner);
addFormats(ajvValidatorAndCleanerWithCoercingTypes);

interface AjvInstanceOptions {
clean: boolean;
coerceTypes: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/py/mat3ra/esse/data/schemas.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/js/JSONSchemasInterface.tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert, expect } from "chai";
import * as path from "path";

import JSONSchemasInterface from "../../dist/js/esse/JSONSchemasInterfaceServer";
import allSchemas from "../../dist/js/schemas.json";
import JSONSchemasInterface from "../../src/js/esse/JSONSchemasInterfaceServer";
import { JSONSchema } from "../../src/js/esse/utils";

function assertSystemInSetSchema(schema?: JSONSchema) {
Expand Down
3 changes: 3 additions & 0 deletions tsconfig-transpile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@mat3ra/tsconfig/tsconfig-js-py-transpile.json"
}
6 changes: 1 addition & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"extends": "@mat3ra/tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "./dist/js",
"resolveJsonModule": true
}
"extends": "@mat3ra/tsconfig/tsconfig-js-py-dev.json"
}

0 comments on commit c954ec4

Please sign in to comment.