Skip to content

Commit

Permalink
chor: remove fs and path from the project and revert to esnext in sdk…
Browse files Browse the repository at this point in the history
… tsconfig
  • Loading branch information
valpinkman committed Jan 26, 2024
1 parent b327cb2 commit caed192
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 44 deletions.
2 changes: 1 addition & 1 deletion apps/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "next dev --turbo",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"turbo": "^1.11.2",
"typescript": "^5.3.3",
"zx": "^7.2.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/config/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
},
},
{
files: ["**/scripts/*.mjs"],
files: ["**/*.mjs"],
env: {
es6: true,
node: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/config/typescript/sdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"experimentalDecorators": true,
"stripInternal": true,
"emitDecoratorMetadata": true,
"moduleResolution": "NodeNext",
"module": "NodeNext"
"moduleResolution": "bundler",
"module": "esnext"
},
"exclude": ["node_modules"]
}
9 changes: 0 additions & 9 deletions packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,4 @@ module.exports = {
project: true,
tsconfigRootDir: __dirname,
},
overrides: [
{
files: "src/**/*.test.ts",
parserOptions: {
project: "tsconfig.test.json",
tsconfigRootDir: __dirname,
},
},
],
};
7 changes: 3 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
"./lib"
],
"scripts": {
"build": "rm -rf lib && tsc && tsc-alias",
"dev": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")",
"build": "rimraf lib && tsc -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.json",
"dev": "tsc && (concurrently \"tsc -w -p tsconfig.prod.json\" \"tsc-alias -w -p tsconfig.prod.json\")",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"test": "jest src",
"test:watch": "pnpm test -- --watch",
"test:coverage": "pnpm test -- --coverage",
"module:init": "zx scripts/add-module.mjs",
"run:index": "ts-node src/index.ts"
"module:init": "zx scripts/add-module.mjs"
},
"dependencies": {
"inversify": "^6.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import fs from "fs";
import { Either, Left } from "purify-ts";
import { JSONParseError, ReadFileError } from "@internal/config/di/configTypes";
import { LocalConfigDataSource } from "./ConfigDataSource";
import { FileLocalConfigDataSource } from "./LocalConfigDataSource";
import * as LocalConfig from "./LocalConfigDataSource";

const readFileSyncSpy = jest.spyOn(fs, "readFileSync");
const { FileLocalConfigDataSource } = LocalConfig;

const readFileSyncSpy = jest.spyOn(LocalConfig, "stubFsReadFile");
const jsonParse = jest.spyOn(JSON, "parse");

let datasource: LocalConfigDataSource;
Expand Down Expand Up @@ -61,4 +62,12 @@ describe("LocalConfigDataSource", () => {
expect(datasource.getConfig()).toEqual(Left(new JSONParseError(err)));
});
});

describe("stubFsReadFile", () => {
it("should return a stringified version of the version object", () => {
expect(LocalConfig.stubFsReadFile()).toEqual(
JSON.stringify({ name: "DeviceSDK", version: "0.0.0-local.1" })
);
});
});
});
13 changes: 8 additions & 5 deletions packages/core/src/internal/config/data/LocalConfigDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import fs from "fs";
import { injectable } from "inversify";
import path from "path";
import { Either } from "purify-ts";
import {
ReadFileError,
Expand All @@ -10,6 +8,13 @@ import {
import { Config } from "@internal/config/model/Config";
import { LocalConfigDataSource } from "./ConfigDataSource";

const version = {
name: "DeviceSDK",
version: "0.0.0-local.1",
};

export const stubFsReadFile = () => JSON.stringify(version);

/**
*
* class FileLocalConfigDataSource
Expand All @@ -19,9 +24,7 @@ import { LocalConfigDataSource } from "./ConfigDataSource";
@injectable()
export class FileLocalConfigDataSource implements LocalConfigDataSource {
getConfig(): Either<LocalConfigFailure, Config> {
return Either.encase(() =>
fs.readFileSync(path.join(__dirname, "version.json"), "utf-8")
)
return Either.encase(() => stubFsReadFile())
.mapLeft((error) => {
console.log("readFileSync error");
return new ReadFileError(error);
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/internal/config/data/version.json

This file was deleted.

3 changes: 1 addition & 2 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"@internal/*": ["src/internal/*"]
}
},
"include": ["src/**/*", "jest.config.ts", "jest.setup.ts"],
"exclude": ["src/**/*.test.ts"]
"include": ["src", "jest.*.ts"]
}
4 changes: 4 additions & 0 deletions packages/core/tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.test.ts", "jest.*.ts"]
}
10 changes: 0 additions & 10 deletions packages/core/tsconfig.test.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"./lib"
],
"scripts": {
"build": "rm -rf lib && tsc",
"build": "rimraf lib && tsc",
"dev": "tsc --watch",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/trusted-apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"./lib"
],
"scripts": {
"build": "rm -rf lib && tsc",
"build": "rimraf lib && tsc",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
"dev": "tsc --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"./lib"
],
"scripts": {
"build": "rm -rf lib && tsc",
"build": "rimraf lib && tsc",
"dev": "tsc --watch",
"lint": "eslint --cache --ext .ts \"src\"",
"lint:fix": "eslint --cache --fix --ext .ts \"src\"",
Expand Down
112 changes: 112 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit caed192

Please sign in to comment.