Skip to content

Commit

Permalink
ESM upgrades (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez authored Nov 16, 2024
1 parent ed7c946 commit 0652403
Show file tree
Hide file tree
Showing 25 changed files with 1,719 additions and 2,614 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 @@ -68,6 +68,10 @@ export default [
"sonarjs/prefer-single-boolean-return": "off",
"unicorn/no-array-callback-reference": "off",
"sonarjs/prefer-nullish-coalescing": "off",
"sonarjs/no-empty-function": "off",
"sonarjs/no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "off",
"unicorn/expiring-todo-comments": "off",
"sonarjs/hashing": "off",
"unicorn/no-process-exit": "off",
"sonarjs/function-return-type": "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
51 changes: 22 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"name": "@digital-alchemy/automation",
"repository": "https://github.com/Digital-Alchemy-TS/automation",
"homepage": "https://docs.digital-alchemy.app/Automation",
"version": "24.9.3",
"version": "24.11.1",
"scripts": {
"build": "rm -rf dist/; tsc",
"lint": "eslint src",
"test": "./scripts/test.sh",
"prepublishOnly": "npm run build",
"upgrade": "yarn up '@digital-alchemy/*'"
},
Expand All @@ -22,7 +21,7 @@
"node": ">=20"
},
"exports": {
".": "./dist/index.js"
".": "./dist/index.mjs"
},
"license": "MIT",
"peerDependencies": {
Expand All @@ -32,39 +31,33 @@
"dayjs": "^1"
},
"devDependencies": {
"@cspell/eslint-plugin": "^8.14.4",
"@digital-alchemy/core": "^24.9.5",
"@digital-alchemy/hass": "^24.9.4",
"@digital-alchemy/synapse": "^24.9.4",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@types/jest": "^29.5.13",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.7.4",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "8.8.0",
"@typescript-eslint/parser": "8.7.0",
"@cspell/eslint-plugin": "^8.16.0",
"@digital-alchemy/core": "^24.11.3",
"@digital-alchemy/hass": "^24.11.3",
"@digital-alchemy/synapse": "^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.11.1",
"eslint": "9.15.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsonc": "^2.16.0",
"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.3",
"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.

2 changes: 1 addition & 1 deletion src/automation.module.ts → src/automation.module.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SequenceWatcher,
SolarCalculator,
Time,
} from "./extensions";
} from "./services/index.mts";

export const LIB_AUTOMATION = CreateLibrary({
configuration: {
Expand Down
8 changes: 0 additions & 8 deletions src/extensions/index.ts

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions src/helpers/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./events.mts";
export * from "./managed-switch.mts";
export * from "./scene.mts";
export * from "./sequence.mts";
export * from "./solar.mts";
5 changes: 0 additions & 5 deletions src/helpers/index.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/index.ts → src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import isBetween from "dayjs/plugin/isBetween";
dayjs.extend(isBetween);
dayjs.extend(duration);

export * from "./automation.module";
export * from "./extensions";
export * from "./helpers";
export * from "./automation.module.mts";
export * from "./helpers/index.mts";
export * from "./services/index.mts";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RoomScene,
SceneDefinition,
SceneSwitchState,
} from "../helpers";
} from "../helpers/index.mts";

type TValidateOptions<ROOM extends TAreaId> = {
context: TContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CronExpression, TServiceParams } from "@digital-alchemy/core";
import dayjs from "dayjs";

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

const MIN = 0;
const MAX = 1;
Expand Down
8 changes: 8 additions & 0 deletions src/services/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from "./aggressive-scenes.service.mts";
export * from "./circadian.service.mts";
export * from "./light-manager.service.mts";
export * from "./managed-switch.service.mts";
export * from "./room.service.mts";
export * from "./sequence-matcher.service.mts";
export * from "./solar-calc.service.mts";
export * from "./time.service.mts";
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import {
TAreaId,
} from "@digital-alchemy/hass";

import { RoomDefinition } from "..";
import {
AggressiveScenesAdjustmentTypes,
SceneDefinition,
SceneLightState,
SceneLightStateOn,
} from "../helpers";
} from "../helpers/index.mts";
import { RoomDefinition } from "./room.service.mts";

type ColorModes = "color_temp" | "xy" | "brightness";
export type ColorLight = GenericEntityDTO<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CronExpression, is, SINGLE, TContext, TServiceParams } from "@digital-alchemy/core";

import { ManagedSwitchOptions, PickASwitch } from "../helpers";
import { ManagedSwitchOptions, PickASwitch } from "../helpers/index.mts";

export function ManagedSwitch({ logger, hass, scheduler, lifecycle }: TServiceParams) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
TAreaId,
} from "@digital-alchemy/hass";

import { RoomConfiguration, RoomScene, SceneDefinition, SceneLightState } from "..";
import {
RoomConfiguration,
RoomScene,
SceneDefinition,
SceneLightState,
} from "../helpers/index.mts";

function toHassId<DOMAIN extends ALL_DOMAINS>(domain: DOMAIN, ...parts: string[]) {
const name = parts.join(" ").toLowerCase().replaceAll(/\s+/g, "_").replaceAll(/\W/g, "");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { is, sleep, START, TServiceParams } from "@digital-alchemy/core";

import { ActiveWatcher, GenericFilter, SequenceWatchOptions, TrackedOptions } from "..";
import { ActiveWatcher, GenericFilter, SequenceWatchOptions, TrackedOptions } from "../index.mts";

export function SequenceWatcher({ logger, hass, config, internal }: TServiceParams) {
const ACTIVE = new Map<object, ActiveWatcher>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dayjs, { Dayjs } from "dayjs";
import { Duration, DurationUnitsObjectType, DurationUnitType } from "dayjs/plugin/duration";
import EventEmitter from "events";

import { calcSolNoon, calcSunriseSet } from "..";
import { calcSolNoon, calcSunriseSet } from "../index.mts";

export type SolarEvents =
| "dawn"
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"outDir": "./dist",
"strict": false,
"strictBindCallApply": true,
"rewriteRelativeImportExtensions": true,
"strictFunctionTypes": true,
"target": "ESNext",
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*.ts"
"src/**/*.mts"
],
"exclude": [
"node_modules",
Expand Down
Loading

0 comments on commit 0652403

Please sign in to comment.