Skip to content

Commit

Permalink
ESM Upgrades (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez authored Nov 16, 2024
1 parent 4823bb1 commit 916983a
Show file tree
Hide file tree
Showing 34 changed files with 2,674 additions and 3,254 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
12 changes: 8 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export default [
"plugin:prettier/recommended",
"plugin:@cspell/recommended",
)
.map(config => ({ ...config, files: ["src/**/*.ts"] })),
.map(config => ({ ...config, files: ["src/**/*.mts"] })),
{
files: ["src/**/*.ts"],
files: ["src/**/*.mts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
Expand All @@ -58,6 +58,10 @@ export default [
},
},
rules: {
"sonarjs/no-unused-expressions": "off",
"unicorn/expiring-todo-comments": "off",
"@typescript-eslint/no-unused-expressions": "off",
"sonarjs/no-empty-function": "off",
"prettier/prettier": "error",
"unicorn/switch-case-braces": "off",
"unicorn/prefer-module": "off",
Expand Down Expand Up @@ -130,7 +134,7 @@ export default [
},
// module definitions
{
files: ["src/**/*.module.ts"],
files: ["src/**/*.module.mts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
Expand All @@ -144,7 +148,7 @@ export default [
},
},
{
files: ["src/**/*.spec.ts"],
files: ["src/**/*.spec.mts"],
languageOptions: {
globals: { ...globals.jest },
parser: tsParser,
Expand Down
58 changes: 26 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"name": "@digital-alchemy/grocy",
"repository": "https://github.com/Digital-Alchemy-TS/grocy",
"homepage": "https://docs.digital-alchemy.app/Grocy",
"version": "24.9.1",
"version": "24.11.1",
"scripts": {
"build": "tsc",
"lint": "eslint src",
"test": "./scripts/test.sh",
"prepublishOnly": "npm run build",
"test": "vitest",
"prepublishOnly": "yarn build",
"upgrade": "yarn up '@digital-alchemy/*'"
},
"author": {
Expand All @@ -22,45 +22,39 @@
"node": ">=20"
},
"exports": {
".": "./dist/index.js"
".": "./dist/index.mjs"
},
"license": "MIT",
"dependencies": {
"dayjs": "^1.11.13",
"ws": "^8.18.0"
},
"peerDependencies": {
"@digital-alchemy/core": "*"
"@digital-alchemy/core": "*",
"dayjs": "*"
},
"devDependencies": {
"@cspell/eslint-plugin": "^8.14.4",
"@digital-alchemy/core": "^24.9.3",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.0",
"@typescript-eslint/eslint-plugin": "8.7.0",
"@typescript-eslint/parser": "8.7.0",
"eslint": "9.11.1",
"@cspell/eslint-plugin": "^8.16.0",
"@digital-alchemy/core": "^24.11.3",
"@eslint/compat": "^1.2.3",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"@types/node": "^22.9.0",
"@typescript-eslint/eslint-plugin": "8.14.0",
"@typescript-eslint/parser": "8.14.0",
"dayjs": "^1.11.13",
"eslint": "9.15.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-no-unsanitized": "^4.1.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsonc": "^2.18.1",
"eslint-plugin-no-unsanitized": "^4.1.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-sonarjs": "^2.0.2",
"eslint-plugin-sonarjs": "^2.0.4",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-unicorn": "^55.0.0",
"globals": "^15.9.0",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"eslint-plugin-unicorn": "^56.0.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"tsx": "^4.19.1",
"type-fest": "^4.26.1",
"typescript": "^5.6.2"
"tsx": "^4.19.2",
"type-fest": "^4.27.0",
"typescript": "^5.7.0-beta",
"vitest": "^2.1.5"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
2 changes: 0 additions & 2 deletions scripts/test.sh

This file was deleted.

12 changes: 0 additions & 12 deletions src/extensions/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/grocy.module.ts → src/grocy.module.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
System,
Tasks,
User,
} from "./extensions";
} from "./services/index.mts";

export const LIB_GROCY = CreateLibrary({
configuration: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/helpers/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from "./api.mts";
export * from "./battery.mts";
export * from "./chores.mts";
export * from "./entities.mts";
export * from "./events.mts";
export * from "./fetch.mts";
export * from "./tasks.mts";
export * from "./users.mts";
8 changes: 0 additions & 8 deletions src/helpers/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./grocy.module.mts";
export * from "./helpers/index.mts";
export * from "./services/index.mts";
3 changes: 0 additions & 3 deletions src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
GrocyTask,
GrocyTaskUserfields,
TASK_CACHE_UPDATED,
} from "../helpers";
} from "../helpers/index.mts";

export function Aggregator({ scheduler, logger, grocy, event, config, lifecycle }: TServiceParams) {
async function refresh() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TServiceParams } from "@digital-alchemy/core";

import { Battery, GrocyBattery } from "../helpers";
import { Battery, GrocyBattery } from "../helpers/index.mts";

interface GrocyBatteryResponse {
battery: Battery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TServiceParams } from "@digital-alchemy/core";

import { GrocyChore, GrocyChoreDetails, GrocyObjectChoreDetail } from "../helpers";
import { GrocyChore, GrocyChoreDetails, GrocyObjectChoreDetail } from "../helpers/index.mts";

type ExecuteChoreRequest = {
done_by: number;
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/services/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export * from "./aggregator.service.mts";
export * from "./battery.service.mts";
export * from "./chores.service.mts";
export * from "./grocy-fetch.service.mts";
export * from "./internal.service.mts";
export * from "./misc.service.mts";
export * from "./object.service.mts";
export * from "./recipe.service.mts";
export * from "./stock.service.mts";
export * from "./system.service.mts";
export * from "./tasks.service.mts";
export * from "./user.service.mts";
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FetchWith,
MaybeHttpError,
TFetchBody,
} from "../helpers";
} from "../helpers/index.mts";

const streamPipeline = promisify(pipeline);

Expand Down Expand Up @@ -89,7 +89,7 @@ export function FetchInternals({ logger, context: parentContext }: TServiceParam
...fetchWith
}: Partial<FetchArguments<BODY>>) {
const contentType = is.object(body) ? { "Content-Type": "application/json" } : {};
const result = await global.fetch(fetchCreateUrl(fetchWith), {
const result = await globalThis.fetch(fetchCreateUrl(fetchWith), {
body: is.object(body) ? JSON.stringify(body) : body,
headers: {
...contentType,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TServiceParams } from "@digital-alchemy/core";

import { EntityTypes, GrocyEntity, UserFieldTypes } from "../helpers";
import { EntityTypes, GrocyEntity, UserFieldTypes } from "../helpers/index.mts";

type GrocyCreateObject = {
body: GrocyEntity;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TServiceParams } from "@digital-alchemy/core";
import dayjs, { Dayjs } from "dayjs";

import { GROCY_DATABASE_UPDATED } from "../helpers";
import { GROCY_DATABASE_UPDATED } from "../helpers/index.mts";

export function System({ lifecycle, grocy, logger, event, config }: TServiceParams) {
let LAST_CHANGED_TIME: Dayjs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TServiceParams } from "@digital-alchemy/core";

import { GrocyTask } from "../helpers";
import { GrocyTask } from "../helpers/index.mts";

export function Tasks({ logger, grocy }: TServiceParams) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TServiceParams } from "@digital-alchemy/core";

import { GrocyUser } from "../helpers";
import { GrocyUser } from "../helpers/index.mts";

type EditUser = {
id: string;
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"noUnusedParameters": true,
"rootDir": "./src",
"skipDefaultLibCheck": true,
"rewriteRelativeImportExtensions": true,
"skipLibCheck": true,
"noUncheckedIndexedAccess": true,
"sourceMap": true,
Expand All @@ -27,7 +28,7 @@
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts"
"src/**/*.mts"
],
"exclude": [
"node_modules",
Expand Down
12 changes: 12 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "vitest/config";
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
globals: true,
coverage: {
provider: "v8",
reporter: ["html", "lcov", "clover"],
},
},
});
Loading

0 comments on commit 916983a

Please sign in to comment.