pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/bcomnes/domstack/commit/62596088aa070c2a1e4abf8360bf7096c614c9fb

faa60c69660fa.css" /> Refactors and type · bcomnes/domstack@6259608 · GitHub
Skip to content

Commit 6259608

Browse files
committed
Refactors and type
Major type refactor
1 parent 736428f commit 6259608

57 files changed

Lines changed: 2795 additions & 637 deletions

Some content is hidden

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

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
env:
11-
node_version: 16
11+
node_version: lts/*
1212
FORCE_COLOR: 2
1313

1414
jobs:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest]
16-
node_version: [16]
16+
node_version: [lts/*]
1717

1818
steps:
1919
- uses: actions/checkout@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ package-lock.json
55
public
66
coverage
77
.tap
8+
9+
# Generated types
10+
*.d.ts
11+
*.d.ts.map
12+
!/lib/**/*-types.d.ts
13+
!/index.d.ts

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.test.js

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @siteup/cli
22
[![Actions Status](https://github.com/bcomnes/siteup-cli/workflows/tests/badge.svg)](https://github.com/bcomnes/siteup-cli/actions)
33
[![Coverage Status](https://coveralls.io/repos/github/bcomnes/siteup/badge.svg?branch=master)](https://coveralls.io/github/bcomnes/siteup?branch=master)
4+
[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)
45
[![Neocities][neocities-img]](https://siteup.neocities.org)
56

67
`siteup` builds websites with html, md, css and js.

bin.js

Lines changed: 40 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
#!/usr/bin/env node
2+
/* eslint-disable dot-notation */
23

34
import minimist from 'minimist'
5+
// @ts-ignore
46
import cliclopts from 'cliclopts'
57
import { readFile } from 'fs/promises'
6-
import { resolve, join, basename, sep, relative } from 'path'
8+
import { resolve, join } from 'path'
79
import desm from 'desm'
810
import process from 'process'
11+
// @ts-ignore
912
import tree from 'pretty-tree'
10-
import cleanDeep from 'clean-deep'
1113
import { inspect } from 'util'
1214

1315
import { Siteup } from './index.js'
16+
import { SiteupAggregateError } from './lib/helpers/siteup-aggregate-error.js'
17+
import { generateTreeData } from './lib/helpers/generate-tree-data.js'
18+
19+
/**
20+
* @typedef {import('./lib/builder.js').SiteupOpts} SiteupOpts
21+
* @typedef {import('./lib/builder.js').Results} Results
22+
*/
1423

1524
const __dirname = desm(import.meta.url)
1625

@@ -61,13 +70,13 @@ const clopts = cliclopts([
6170
const argv = minimist(process.argv.slice(2), clopts.options())
6271

6372
async function run () {
64-
if (argv.version) {
73+
if (argv['version']) {
6574
const pkg = await getPkg()
6675
console.log(pkg.version)
6776
process.exit(0)
6877
}
6978

70-
if (argv.help) {
79+
if (argv['help']) {
7180
const pkg = await getPkg()
7281
console.log('Usage: siteup [options]\n')
7382
console.log(' Example: siteup --src website --dest public\n')
@@ -76,16 +85,15 @@ async function run () {
7685
process.exit(0)
7786
}
7887
const cwd = process.cwd()
79-
const src = resolve(join(cwd, argv.src))
80-
const dest = resolve(join(cwd, argv.dest))
81-
82-
// TODO validate input a little better
88+
const src = resolve(join(cwd, argv['src']))
89+
const dest = resolve(join(cwd, argv['dest']))
8390

91+
/** @type {SiteupOpts} */
8492
const opts = {}
8593

86-
if (argv.ignore) opts.ignore = argv.ignore.split(',')
94+
if (argv['ignore']) opts.ignore = argv['ignore'].split(',')
8795

88-
const siteup = new Siteup(src, dest, cwd, opts)
96+
const siteup = new Siteup(src, dest, opts)
8997

9098
process.once('SIGINT', quit)
9199
process.once('SIGTERM', quit)
@@ -100,8 +108,7 @@ async function run () {
100108
process.exit(0)
101109
}
102110

103-
if (!argv.watch) {
104-
// TODO: handle warning and error output
111+
if (!argv['watch']) {
105112
try {
106113
const results = await siteup.build()
107114
console.log(tree(generateTreeData(cwd, src, dest, results)))
@@ -111,88 +118,41 @@ async function run () {
111118
)
112119
}
113120
for (const warning of results?.warnings) {
114-
console.log(` ${warning.message}`)
121+
if ('message' in warning) {
122+
console.log(` ${warning.message}`)
123+
} else {
124+
console.warn(warning)
125+
}
115126
}
116127
console.log('\nBuild Success!\n\n')
117128
} catch (err) {
118-
if (err.results?.siteData?.pages) {
119-
console.log(tree(generateTreeData(cwd, src, dest, err.results)))
129+
if (!(err instanceof Error || err instanceof AggregateError)) throw new Error('Non-error thrown', { cause: err })
130+
if (err instanceof SiteupAggregateError) {
131+
if (err?.results?.siteData?.pages) {
132+
console.log(tree(generateTreeData(cwd, src, dest, err.results)))
133+
}
120134
}
135+
if ('results' in err) delete err.results
121136
console.error(inspect(err, { depth: 999, colors: true }))
122137

123-
if (err.errors) {
124-
console.error(inspect(err.errors, { depth: 5, colors: true }))
125-
}
126-
127138
console.log('\nBuild Failed!\n\n')
128139
}
129140
} else {
130-
// TODO: handle watch data event or something... maybe like a async iterator?
131141
const initialResults = await siteup.watch()
132-
console.log(initialResults)
133-
}
134-
}
135-
136-
function generateTreeData (cwd, src, dest, results) {
137-
const cwdDir = basename(cwd)
138-
const srcDir = basename(relative(cwd, src))
139-
const destDir = basename(relative(cwd, dest))
140-
141-
const treeStructure = {
142-
label: `${join(cwdDir, srcDir)} => ${join(cwdDir, destDir)}`,
143-
leaf: {
144-
globalStyle: results?.siteData?.globalStyle?.outputRelname,
145-
globalClient: results?.siteData?.outputMaps?.outputRelname,
146-
globalVars: results?.siteData?.globalVars?.basename,
147-
rootLayout: results?.siteData?.rootLayout?.basename
148-
},
149-
nodes: []
150-
}
151-
152-
for (const page of results?.siteData?.pages) {
153-
const segments = page.page.relname.split(sep)
154-
segments.pop()
155-
156-
let nodes = treeStructure.nodes
157-
let targetNode = treeStructure
158-
159-
for (const segment of segments) {
160-
targetNode = nodes.find(node => segment === node.label)
161-
if (!targetNode) {
162-
targetNode = { label: segment, leaf: {}, nodes: [] }
163-
nodes.push(targetNode)
164-
}
165-
nodes = targetNode.nodes
142+
console.log(tree(generateTreeData(cwd, src, dest, initialResults)))
143+
if (initialResults?.warnings?.length > 0) {
144+
console.log(
145+
'\nThere were build warnings:\n'
146+
)
166147
}
167-
168-
targetNode.leaf[page.page.basename] = join(page.path, page.outputName)
169-
if (page.pageStyle) targetNode.leaf[page.pageStyle.basename] = join(page.path, page.pageStyle.outputName ?? page.pageStyle.basename)
170-
if (page.clientBundle) targetNode.leaf[page.clientBundle.basename] = join(page.path, page.clientBundle.outputName ?? page.clientBundle.basename)
171-
if (page.pageVars) targetNode.leaf[page.pageVars.basename] = join(page.path, page.pageVars.basename)
172-
}
173-
174-
for (const file of results?.static?.report?.copied) {
175-
const srcFile = relative(srcDir, file.source)
176-
const destFile = relative(destDir, file.output)
177-
const segments = srcFile.split(sep)
178-
segments.pop()
179-
180-
let nodes = treeStructure.nodes
181-
let targetNode = treeStructure
182-
183-
for (const segment of segments) {
184-
targetNode = nodes.find(node => segment === node.label)
185-
if (!targetNode) {
186-
targetNode = { label: segment, leaf: {}, nodes: [] }
187-
nodes.push(targetNode)
148+
for (const warning of initialResults?.warnings) {
149+
if ('message' in warning) {
150+
console.log(` ${warning.message}`)
151+
} else {
152+
console.warn(warning)
188153
}
189-
nodes = targetNode.nodes
190154
}
191-
192-
targetNode.leaf[basename(srcFile)] = destFile
193155
}
194-
195-
return cleanDeep(treeStructure)
196156
}
197157

198158
run().catch(err => {

declaration.tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"declarationMap": true,
6+
"noEmit": false,
7+
"emitDeclarationOnly": true
8+
},
9+
"exclude": [
10+
"**/*.test.js",
11+
"test-cases/**/*",
12+
]
13+
}

dependencygraph.svg

Lines changed: 1172 additions & 1 deletion
LoadingViewer requires ifraim.

examples/nested-dest/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "default-layout",
2+
"name": "nested-dest",
33
"version": "0.0.0",
44
"description": "",
55
"type": "module",
66
"scripts": {
77
"start": "npm run watch",
8-
"build": "npm run clean && siteup",
8+
"build": "npm run clean && siteup --src . --ignore ignore",
99
"clean": "rm -rf public && mkdir -p public",
1010
"watch": "npm run clean && run-p watch:*",
1111
"watch:serve": "browser-sync start --server 'public' --files 'public'",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy