Skip to content

Commit

Permalink
dynamic ids
Browse files Browse the repository at this point in the history
  • Loading branch information
zoe-codez committed Apr 16, 2024
1 parent 0af08b5 commit ce781aa
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 148 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@digital-alchemy/type-writer",
"repository": "https://github.com/Digital-Alchemy-TS/type-writer",
"homepage": "https://docs.digital-alchemy.app/Type-Writer",
"version": "0.3.5",
"version": "0.3.6",
"scripts": {
"build": "rm -rf dist/; tsc",
"lint": "eslint src",
Expand All @@ -26,7 +26,7 @@
"license": "MIT",
"dependencies": {
"@digital-alchemy/core": "^0.3.11",
"@digital-alchemy/hass": "^0.3.8",
"@digital-alchemy/hass": "^0.3.10",
"js-yaml": "^4.1.0"
},
"devDependencies": {
Expand Down
15 changes: 9 additions & 6 deletions src/build.extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { is, TServiceParams } from "@digital-alchemy/core";
import { existsSync, writeFileSync } from "fs";
import { join } from "path";
import { exit } from "process";

export function BuildTypes({
logger,
Expand Down Expand Up @@ -37,12 +38,13 @@ export function BuildTypes({
} catch (error) {
logger.fatal({ error }, `failed to write type definitions file`);
}
setImmediate(() => exit());
});

// see file - libs/home-assistant/src/dynamic.ts
async function DoBuild() {
logger.info(`Pulling information`);
const typeInterface = await type_writer.type_writer();
const typeInterface = await type_writer.call_service();
const entities = await hass.fetch.getAllEntities();
const entitySetup = {};
entities.forEach(i =>
Expand All @@ -51,13 +53,14 @@ export function BuildTypes({
return [
`// This file is generated, and is automatically updated as a npm post install step`,
"// Do not edit this file, it will only affect type definitions, not functional code",
"",
`import { PICK_ENTITY } from "./helpers";`,
"",
`export const ENTITY_SETUP = ${JSON.stringify(entitySetup, undefined, " ")};`,
"",
typeInterface,
"",
].join(`\n`);
type_writer.identifiers.area(),
type_writer.identifiers.device(),
type_writer.identifiers.floor(),
type_writer.identifiers.label(),
type_writer.identifiers.zone(),
].join(`\n\n`);
}
}
Loading

0 comments on commit ce781aa

Please sign in to comment.