Skip to content

Commit 4d9a16e

Browse files
committed
More updates
1 parent ea68263 commit 4d9a16e

File tree

23 files changed

+150
-1111
lines changed

23 files changed

+150
-1111
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
11
# dev
22

33
My development tool. It helps with creating new projects from a template, managing the configuration of those projects, and more!
4-
5-
**Linting**
6-
7-
- changelog
8-
- `npm-package-json-lint`
9-
- packageJson
10-
- accurate license (read file system)
11-
- accurate description (read from github?)
12-
- packageJson.bin alphabetical if object
13-
- Function like `filesMustHaveContent`, but renames lefthook.yml, lefthook.json to lefthook.yaml, etc.
Lines changed: 22 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,38 @@
11
import { fileExists } from '#common'
22
import type { Issues } from '#types'
3+
import fs from 'node:fs/promises'
34

45
export const skip = true
56

67
export const issues: Issues = async function* issues({ project }) {
78
const configFile = '.gitattributes'
89

9-
// TODO
10-
// let attributes = ''
11-
// try {
12-
// attributes = await fs.readFile(configFile, 'utf-8')
13-
// } catch (err) {
14-
// if (err.code !== 'ENOENT') {
15-
// throw err
16-
// }
17-
// }
18-
//
19-
// const newAttributes = await minimalGitAttributes(attributes)
20-
//
21-
// if (newAttributes !== attributes) {
22-
// yield {
23-
// message: [`File "${configFile}" does not have the expected contents`],
24-
// fix
25-
// }
26-
// }
27-
//
28-
// async function fix() {
29-
// let attributes: string = ''
30-
// try {
31-
// attributes = await fs.readFile(configFile, 'utf-8')
32-
// } catch (err) {
33-
// if (err.code !== 'ENOENT') {
34-
// throw err
35-
// }
36-
// }
37-
// const newAttributes = await minimalGitAttributes(attributes)
38-
//
39-
// if (typeof newAttributes === 'string') {
40-
// await fs.writeFile(configFile, newAttributes)
41-
// } else {
42-
// await fs.rm(configFile).catch((err) => {
43-
// if (err.code === 'ENOENT') {
44-
// return
45-
// }
46-
// throw err
47-
// })
48-
// }
49-
// }
50-
}
51-
52-
async function minimalGitAttributes(input: string) {
53-
let content = input
54-
content = content.replaceAll(/# foxxo /gu, '#section:fox-tools/fix ')
55-
56-
if (!content.includes('#section:fox-tools/fix start')) {
57-
content = `#section:fox-tools/fix start
58-
#section:fox-tools/fix end\n` + content
59-
}
60-
61-
let newContent = ''
62-
let canRemove = false
63-
for (const line of content.split('\n')) {
64-
if (line.startsWith('#section:fox-tools/fix start')) {
65-
canRemove = true
66-
newContent += line + '\n'
67-
continue
68-
} else if (line.startsWith('#section:fox-tools/fix end')) {
69-
if ((await fileExists('bake')) && !content.includes('bake linguist-generated')) {
70-
newContent += 'bake linguist-generated\n'
71-
}
72-
73-
canRemove = false
74-
newContent += line + '\n'
75-
continue
10+
let content = ''
11+
try {
12+
content = await fs.readFile(configFile, 'utf-8')
13+
} catch (err) {
14+
if (err.code !== 'ENOENT') {
15+
throw err
7616
}
17+
}
7718

78-
if (canRemove) {
79-
if (line.includes('text=auto') || line.includes('eol=lf')) {
80-
continue
81-
}
82-
83-
if (line === 'bake linguist-generated') {
84-
if (!(await fileExists('bake'))) {
85-
continue
86-
}
19+
const badStrings = ['# foxxo', '#section:fox-tools']
20+
for (const string of badStrings) {
21+
if (content.includes(string)) {
22+
yield {
23+
message: [
24+
`Expected to find no line that contains "${string}"`,
25+
],
8726
}
8827
}
89-
90-
newContent += line + '\n'
9128
}
92-
content = newContent
93-
content = content.trimEnd()
94-
content += '\n'
9529

96-
if (
97-
content ===
98-
`#section:fox-tools/fix start
99-
#section:fox-tools/fix end
100-
`
101-
) {
102-
return null
30+
if (await fileExists('bake') && !content.includes('bake linguist-generated')) {
31+
yield {
32+
message: [
33+
`Expected to find a line that contains "bake linguist-generated"`,
34+
`The file "bake" exists.`,
35+
],
36+
}
10337
}
104-
105-
return content
10638
}

config/lint-rules/300-remote-url/10-local-metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { octokit } from '#common'
22
import type { Issues } from '#types'
3+
import { execa } from 'execa'
34

45
export const issues: Issues = async function* issues({ project }) {
56
if (project.type !== 'with-remote-url') {

config/lint-rules/400-ecosystem/_/lefthook.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ export const issues: Issues = async function* issues({ project }) {
3636
PropertyKey,
3737
unknown
3838
>
39-
if (!('pre-commit' in lefthookConfig)) {
40-
yield {
41-
message: [
42-
`Expected to find property "pre-commit" in file "./.lefthook.yaml"`,
43-
],
44-
}
45-
}
4639
if (lefthookConfig.assert_lefthook_installed != true) {
4740
yield {
4841
message: [
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
import * as v from 'valibot'
2-
import { Routes as Routes1 } from '#pages/projects/settings.ts'
1+
import * as v from "valibot";
32

4-
const routes = { ...Routes1 }
3+
const routes = {};
54

65
export async function f<
7-
T extends keyof typeof routes,
8-
U extends (typeof routes)[T]['request'],
9-
V extends (typeof routes)[T]['response'],
6+
T extends keyof typeof routes,
7+
U extends (typeof routes)[T]["request"],
8+
V extends (typeof routes)[T]["response"],
109
>(url: T, params?: v.InferInput<U>): Promise<v.InferInput<V>> {
11-
const result1 = v.safeParse(routes[url].request, params)
12-
if (!result1.success) {
13-
throw result1.issues
14-
}
15-
const res = await fetch(url, {
16-
method: 'POST',
17-
headers: {
18-
'content-type': 'application/json',
19-
},
20-
body: JSON.stringify(result1.output, null, '\t'),
21-
})
22-
const output = await res.json()
23-
const result2 = v.safeParse(routes[url].response, output)
24-
if (!result2.success) {
25-
throw result2.issues
26-
}
27-
return result2.output
10+
const result1 = v.safeParse(routes[url].request, params);
11+
if (!result1.success) {
12+
throw result1.issues;
13+
}
14+
const res = await fetch(url, {
15+
method: "POST",
16+
headers: {
17+
"content-type": "application/json",
18+
},
19+
body: JSON.stringify(result1.output, null, "\t"),
20+
});
21+
const output = await res.json();
22+
const result2 = v.safeParse(routes[url].response, output);
23+
if (!result2.success) {
24+
throw result2.issues;
25+
}
26+
return result2.output;
2827
}
2928

3029
export function throwBadMeta(property: string): never {
31-
throw new Error(`Bad value for "import.meta.${property}"`)
30+
throw new Error(`Bad value for "import.meta.${property}"`);
3231
}

devserver/components/Navigation.ts

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,48 @@
11
import { h } from 'preact'
2-
import { useState, useCallback } from 'preact/hooks'
2+
import { useCallback, useState } from 'preact/hooks'
33
import { html } from 'htm/preact'
44

55
export function Navigation() {
66
const [isActive, setActive] = useState(false)
77

8-
return html`<nav
9-
class="navbar"
10-
role="navigation"
11-
aria-label="main navigation"
12-
style="border-bottom: 1px solid lightgray"
13-
>
14-
<div class="navbar-brand">
15-
<a
16-
role="button"
17-
class="navbar-burger"
18-
onClick=${() => setActive(!isActive)}
19-
aria-label="menu"
20-
aria-expanded="false"
21-
data-target="navbarBasicExample"
22-
>
23-
<span aria-hidden="true"></span>
24-
<span aria-hidden="true"></span>
25-
<span aria-hidden="true"></span>
26-
<span aria-hidden="true"></span>
27-
</a>
28-
</div>
29-
30-
<div
31-
id="navbarBasicExample"
32-
class="${isActive ? 'navbar-menu is-active' : 'navbar-menu'}"
8+
return html`
9+
<nav
10+
class="navbar"
11+
role="navigation"
12+
aria-label="main navigation"
13+
style="border-bottom: 1px solid lightgray"
3314
>
34-
<div class="navbar-start has-dropdown">
35-
<a class="navbar-item" href="/">Home</a>
36-
<div class="navbar-item has-dropdown is-hoverable">
37-
<a href="/projects" class="navbar-link">Tools</a>
15+
<div class="navbar-brand">
16+
<a
17+
role="button"
18+
class="navbar-burger"
19+
onClick="${() => setActive(!isActive)}"
20+
aria-label="menu"
21+
aria-expanded="false"
22+
data-target="navbarBasicExample"
23+
>
24+
<span aria-hidden="true"></span>
25+
<span aria-hidden="true"></span>
26+
<span aria-hidden="true"></span>
27+
<span aria-hidden="true"></span>
28+
</a>
29+
</div>
3830
39-
<div class="navbar-dropdown">
40-
<a href="/tools/dictionary-watcher" class="navbar-item">Dictionary Watcher</a>
41-
</div>
42-
</div>
43-
<a class="navbar-item" href="/services">Services</a>
44-
<div class="navbar-item has-dropdown is-hoverable">
45-
<a href="/projects" class="navbar-link">Projects</a>
31+
<div
32+
id="navbarBasicExample"
33+
class="${isActive ? 'navbar-menu is-active' : 'navbar-menu'}"
34+
>
35+
<div class="navbar-start has-dropdown">
36+
<a class="navbar-item" href="/">Home</a>
37+
<div class="navbar-item has-dropdown is-hoverable">
38+
<a href="/tools" class="navbar-item">Tools</a>
4639
47-
<div class="navbar-dropdown">
48-
<a href="/projects/edit-queries" class="navbar-item">Edit Queries</a>
49-
<a href="/projects/settings" class="navbar-item">Settings</a>
40+
<div class="navbar-dropdown">
41+
<a href="/tools/dictionary-watcher" class="navbar-item">Dictionary Watcher</a>
42+
</div>
5043
</div>
5144
</div>
5245
</div>
53-
</div>
54-
</nav>`
46+
</nav>
47+
`
5548
}

devserver/pages/index.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,31 @@ export function Page({ services }: PageSchemaT) {
1616
<h1 class="title mb-0">Services</h1>
1717
<div class="content">
1818
<ul class="index-ul" style="margin-inline-start: 18px;">
19-
${services
20-
? services.map(
21-
(service) =>
22-
html`<li>
23-
<a
24-
class="hover-bold"
25-
style="${service.isActive
26-
? 'color: lightgreen'
27-
: 'color: red'}"
28-
href="/services#${service.name}"
29-
>
30-
${service.name}
31-
</a>
32-
</li>`,
33-
)
34-
: ''}
19+
${
20+
services
21+
? services.map(
22+
(service) =>
23+
html`
24+
<li>
25+
<a
26+
class="hover-bold"
27+
style="${service.isActive ? 'color: lightgreen' : 'color: red'}"
28+
href="/services#${service.name}"
29+
>
30+
${service.name}
31+
</a>
32+
</li>
33+
`,
34+
)
35+
: ''
36+
}
3537
</ul>
3638
</div>
3739
</div>
3840
<div class="p-1" style="background-color: aliceblue">
3941
<h1 class="title mb-0">Recent Projects</h1>
4042
</div>
4143
</div>
42-
<div
43-
class="p-1"
44-
style="background-color: wheat; border-block: 1px solid lightgray;"
45-
>
46-
<h1 class="mb-0 title">Projects</h1>
47-
<p><a href="/projects">View All Projects</a></p>
48-
</div>
4944
</div>
5045
<//>
5146
`

devserver/pages/lint.server.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)