Skip to content

Commit 5fc900f

Browse files
Merge pull request #2 from BottlecapDave/develop
Initial release
2 parents c49b66d + 247db85 commit 5fc900f

File tree

73 files changed

+22905
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+22905
-1
lines changed

.build/createGithubRelease.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { readFileSync } from 'fs';
2+
import { join } from 'path';
3+
4+
const bodySuffix = "---\nEnjoying the integration? Why not make a one time or monthly [GitHub sponsorship](https://github.com/sponsors/bottlecapdave)?"
5+
6+
function getMinimumHomeAssistantVersion() {
7+
const hacsFilePath = join(__dirname, '../hacs.json');
8+
const buffer = readFileSync(hacsFilePath);
9+
const content = JSON.parse(buffer.toString());
10+
return content.homeassistant;
11+
}
12+
13+
async function createGithubRelease(githubToken: string, githubOwnerRepo: string, tag: string, notes: string) {
14+
if (!githubToken) {
15+
throw new Error('Github token not specified');
16+
}
17+
18+
if (!githubOwnerRepo) {
19+
throw new Error('Github owner/repo not specified');
20+
}
21+
22+
if (!tag) {
23+
throw new Error('Tag not specified');
24+
}
25+
26+
if (!notes) {
27+
throw new Error('Notes not specified');
28+
}
29+
30+
const isPrerelease = tag.includes('-beta.')
31+
32+
console.log(`Publishing ${tag} ${isPrerelease ? 'pre-release': 'release'} to ${githubOwnerRepo}`);
33+
34+
const body = JSON.stringify({
35+
tag_name: tag,
36+
name: tag,
37+
body: notes,
38+
draft: false,
39+
prerelease: isPrerelease
40+
});
41+
42+
const response = await fetch(
43+
`https://api.github.com/repos/${githubOwnerRepo}/releases`,
44+
{
45+
method: 'POST',
46+
headers: {
47+
"Accept": "application/vnd.github+json",
48+
"Authorization": `Bearer ${githubToken}`,
49+
"X-GitHub-Api-Version": "2022-11-28"
50+
},
51+
body
52+
}
53+
);
54+
55+
if (response.status >= 300) {
56+
throw new Error(response.statusText);
57+
}
58+
}
59+
60+
const minimumHAVersionNote = `\n**Minimum HA Version**: ${getMinimumHomeAssistantVersion()}\n\n`;
61+
createGithubRelease(
62+
process.env.GITHUB_TOKEN,
63+
process.env.GITHUB_REPOSITORY,
64+
process.argv[2],
65+
`${process.argv[3]}\n${minimumHAVersionNote}${bodySuffix}`
66+
).then(() => console.log('Success'));

.build/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true,
4+
"module": "commonjs",
5+
"noImplicitAny": true,
6+
"removeComments": true,
7+
"preserveConstEnums": true,
8+
"sourceMap": true,
9+
10+
},
11+
"include": ["**/*"]
12+
}

.build/updateVersion.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { readFileSync, writeFileSync } from 'fs';
2+
import { join } from 'path';
3+
4+
const manifestFilePath = join(__dirname, '../custom_components/target_timeframes/manifest.json');
5+
const constantFilePath = join(__dirname, '../custom_components/target_timeframes/const.py');
6+
7+
function updateManifestVersion(version: string) {
8+
const buffer = readFileSync(manifestFilePath);
9+
const content = JSON.parse(buffer.toString());
10+
content.version = version;
11+
12+
writeFileSync(manifestFilePath, JSON.stringify(content, null, 2));
13+
console.log(`Updated manifest version to '${version}'`);
14+
}
15+
16+
function updateVersionConstant(version: string) {
17+
const buffer = readFileSync(constantFilePath);
18+
const oldContent = buffer.toString();
19+
20+
const versionRegex = /INTEGRATION_VERSION = \"[^\"]+\"/g
21+
const newContent = oldContent.replace(versionRegex, `INTEGRATION_VERSION = \"${version}\"`);
22+
23+
if (oldContent != newContent) {
24+
writeFileSync(constantFilePath, newContent);
25+
console.log(`Updated constant version to '${version}'`);
26+
} else {
27+
console.log(`Failed to update constant version to '${version}'`);
28+
}
29+
}
30+
31+
updateManifestVersion(process.argv[2]);
32+
updateVersionConstant(process.argv[2]);

.cz-config.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var scopes = []
2+
3+
module.exports = {
4+
types: [
5+
{ value: 'feat', name: 'feat: A new feature' },
6+
{ value: 'fix', name: 'fix: A bug fix' },
7+
{ value: 'docs', name: 'docs: Documentation only changes' },
8+
{
9+
value: 'style',
10+
name:
11+
'style: Changes that do not affect the meaning of the code\n(white-space, formatting, missing semi-colons, etc)',
12+
},
13+
{
14+
value: 'refactor',
15+
name: 'refactor: A code change that neither fixes a bug nor adds a feature',
16+
},
17+
{
18+
value: 'perf',
19+
name: 'perf: A code change that improves performance',
20+
},
21+
{ value: 'test', name: 'test: Adding missing tests' },
22+
{ value: 'build', name: 'build: Changes to the build system' },
23+
{ value: 'chore', name: 'chore: Changes that does not fit into another category' },
24+
{ value: 'ci', name: 'ci: Changes to the ci system' },
25+
{ value: 'revert', name: 'revert: Revert to a commit' },
26+
{ value: 'release', name: 'release: a release of the project' },
27+
{ value: 'WIP', name: 'WIP: Work in progress' },
28+
{ value: 'blueprint', name: 'blueprint: A blueprint enhancing the integration' },
29+
],
30+
31+
scopes: scopes.map(x => { return { name: x }}),
32+
33+
allowTicketNumber: false,
34+
isTicketNumberRequired: false,
35+
36+
messages: {
37+
type: "Select the type of change that you're committing:",
38+
scope: '\nDenote the SCOPE of this change (optional):',
39+
// used if allowCustomScopes is true
40+
customScope: 'Denote the SCOPE of this change:',
41+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
42+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
43+
breaking: 'List any BREAKING CHANGES (optional):\n',
44+
footer: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
45+
confirmCommit: 'Are you sure you want to proceed with the commit above?',
46+
},
47+
48+
allowCustomScopes: true,
49+
allowBreakingChanges: ['feat', 'fix'],
50+
// skip any questions you want
51+
skipQuestions: ['body'],
52+
53+
// limit subject length
54+
subjectLimit: 500,
55+
};

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [BottlecapDave] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Bug/Issue Report
2+
description: Create a bug/issue detailing something that is broken or not working correctly
3+
labels: ["bug"]
4+
assignees:
5+
- BottlecapDave
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
Thanks for taking the time to fill out this bug report, and first may I say I'm sorry that you've encountered an issue.
11+
- type: textarea
12+
id: description
13+
attributes:
14+
label: Describe the bug
15+
description: Please provide a clear and concise description of what the bug/issue is
16+
placeholder: ex. target rate sensor with the following settings is not turning on
17+
validations:
18+
required: true
19+
- type: textarea
20+
id: reproduction
21+
attributes:
22+
label: Reproduction steps
23+
description: Please provide steps to reproduce the behavior
24+
validations:
25+
required: true
26+
- type: textarea
27+
id: expected
28+
attributes:
29+
label: Expected behaviour
30+
description: Please provide a clear and concise description of what you expected to happen
31+
validations:
32+
required: true
33+
- type: input
34+
id: integration-version
35+
attributes:
36+
label: Integration Version
37+
description: The version of the integration that you encountered the bug on
38+
validations:
39+
required: true
40+
- type: input
41+
id: ha-integration
42+
attributes:
43+
label: Home Assistant Version
44+
description: The version of Home Assistant you're currently running
45+
validations:
46+
required: true
47+
- type: dropdown
48+
id: freshinstall
49+
attributes:
50+
label: Fresh Install?
51+
description: What this encountered after upgrading or a fresh install
52+
options:
53+
- Not specified
54+
- Fresh install
55+
- After upgrading
56+
validations:
57+
required: true
58+
- type: textarea
59+
id: ha-logs
60+
attributes:
61+
label: Home Assistant Logs
62+
description: Paste any related Home Assistant logs here. Please follow the instructions as outlined in the [FAQ](https://bottlecapdave.github.io/homeassistant-targettimeframes/faq#how-do-i-increase-the-logs-for-the-integration)
63+
validations:
64+
required: true
65+
- type: checkboxes
66+
id: confirm
67+
attributes:
68+
label: Confirmation
69+
options:
70+
- label: I confirm that I cannot find my solution within the [documentation](https://bottlecapdave.github.io/homeassistant-targettimeframes)
71+
required: true
72+
- label: I confirm that I cannot find my solution within the [FAQ](https://bottlecapdave.github.io/homeassistant-targettimeframes/faq)
73+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Integration Support
4+
url: https://github.com/BottlecapDave/homeassistant-targettimeframes/discussions
5+
about: Please ask and answer questions here.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Feature Request
2+
description: Request a new feature to help improve the integration
3+
labels: ["enhancement"]
4+
assignees:
5+
- BottlecapDave
6+
body:
7+
- type: textarea
8+
id: description
9+
attributes:
10+
label: Describe the feature
11+
description: Please provide a clear and concise description of what the feature is
12+
validations:
13+
required: true
14+
- type: textarea
15+
id: expected
16+
attributes:
17+
label: Expected behaviour
18+
description: Please provide a clear and concise description of what you expected to happen
19+
validations:
20+
required: true
21+
- type: textarea
22+
id: usecase
23+
attributes:
24+
label: Use Case
25+
description: Please provide a use case for this new feature so that I can better understand the problem that is being solved
26+
validations:
27+
required: true
28+
- type: checkboxes
29+
id: docs
30+
attributes:
31+
label: Confirmation
32+
options:
33+
- label: By submitting this feature request, you agree that you have read the [documentation](https://bottlecapdave.github.io/homeassistant-targettimeframes) and confirmed it does not already exist
34+
required: true
35+
- label: I am willing/able to help contribute to the solution of this feature

.github/actions/setup/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Setup dependencies
2+
description: Sets up required dependencies
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Install dependencies
7+
run: sudo apt install libffi-dev libncurses5-dev zlib1g zlib1g-dev libssl-dev libreadline-dev libbz2-dev libsqlite3-dev
8+
shell: bash
9+
- name: asdf_install
10+
uses: asdf-vm/actions/install@v3
11+
- name: Install Python modules
12+
run: |
13+
pip install -r requirements.test.txt
14+
shell: bash

.github/workflows/docs.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Docs
2+
on:
3+
workflow_dispatch:
4+
push:
5+
paths:
6+
- 'mkdocs.yml'
7+
- '_docs/**'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
HUSKY: 0
16+
17+
jobs:
18+
build_docs:
19+
if: ${{ (github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main')) == false }}
20+
name: Build docs
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
sparse-checkout: |
27+
_docs
28+
- name: asdf_install
29+
uses: asdf-vm/actions/install@v3
30+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
31+
- uses: actions/cache@v4
32+
with:
33+
key: mkdocs-material-${{ env.cache_id }}
34+
path: .cache
35+
restore-keys: |
36+
mkdocs-material-
37+
- run: pip install -r requirements.txt
38+
- run: mkdocs build
39+
40+
deploy_docs:
41+
if: ${{ github.repository_owner == 'BottlecapDave' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main') }}
42+
name: Deploy docs
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
sparse-checkout: |
51+
_docs
52+
- name: asdf_install
53+
uses: asdf-vm/actions/install@v3
54+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
55+
- uses: actions/cache@v4
56+
with:
57+
key: mkdocs-material-${{ env.cache_id }}
58+
path: .cache
59+
restore-keys: |
60+
mkdocs-material-
61+
- run: pip install -r requirements.txt
62+
- run: mkdocs gh-deploy --strict --force

0 commit comments

Comments
 (0)