diff --git a/bs/README.md b/bs/README.md
index 7bb265d..ab5c031 100644
--- a/bs/README.md
+++ b/bs/README.md
@@ -4,9 +4,6 @@ This project uses [jaandrle/bs: The simplest possible build system using executa
## Available executables
If it makes sense, arguments are passed to internally used commands (e.g. `tsc`), e. g. `--help`.
-### bs/lint
-This lints the project using `tsc`.
-
### bs/test
This lints the project and runs tests using `wtr`.
@@ -19,8 +16,17 @@ This builds the project using `rollup`.
### bs/analyze
This analyze Custom Element manifest using the `@custom-elements-manifest/analyzer`.
+### bs/dev/assets
+Copies assets using `cp` into proper destination in `.tmp`.
+
+### bs/dev/tsc
+Builds typescript files using `tsc`.
+
+### bs/dev/lint
+Lints the project using `tsc`.
+
### bs/npm/lint
-Linted projects’ npm dependencies.
+Lints projects’ npm dependencies.
### bs/npm/update
Updates projects’ npm dependencies.
diff --git a/bs/analyze b/bs/analyze
index 366e78a..9d55be5 100755
--- a/bs/analyze
+++ b/bs/analyze
@@ -5,8 +5,12 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
exit 1;
}
# depends on
-declare -r app='src/app-cfpodcasts.ts'
-declare -r cem='node_modules/.bin/cem'
+declare -r app=(
+ 'src/**/c-*.ts'
+ 'src/**/app-*/index.ts'
+ 'src/index.ts'
+)
+declare -r cem='node_modules/.bin/custom-elements-manifest'
help(){
if ! isHelp "${@}"; then return 0; fi
@@ -17,7 +21,7 @@ help(){
}
main(){
help "${@}"
- $cem analyze --litelement --globs "$app" "${@}"
+ $cem analyze --litelement --globs "${app[@]}" "${@}"
}
main "${@}"
diff --git a/bs/build b/bs/build
index 8b43cab..761ccad 100755
--- a/bs/build
+++ b/bs/build
@@ -5,7 +5,8 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
exit 1;
}
# depends on
-declare -r lint='bs/lint'
+declare -r tsc='bs/dev/tsc'
+declare -r assets='bs/dev/assets'
declare -r rollup='node_modules/.bin/rollup'
declare -r analyze='bs/analyze'
declare -r config='rollup.config.js'
@@ -21,7 +22,8 @@ help(){
main(){
help "${@}"
- $lint
+ $tsc
+ $assets
rm -rf "$dist"
$rollup -c $config "${@}"
$analyze --exclude "$dist"
diff --git a/bs/dev/assets b/bs/dev/assets
new file mode 100755
index 0000000..02647ac
--- /dev/null
+++ b/bs/dev/assets
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3Ml53kvc
+. bs/.common || {
+ echo 'Please run this script from the project root directory' >&2;
+ exit 1;
+}
+# depends on
+declare -r paths='bs/dev/paths.js'
+declare -r assets="$($paths 'src')/**/assets"
+declare -r target="$($paths 'tscoutput')"
+
+help(){
+ if ! isHelp "${@}"; then return 0; fi
+ echoReadmeInfo
+ echo
+ exit 0
+}
+main(){
+ help "${@}"
+ shopt -s globstar nullglob
+ for dir in $assets; do
+ cp -r "$dir" "$target/$dir"
+ done
+}
+
+main "${@}"
diff --git a/bs/lint b/bs/dev/lint
similarity index 75%
rename from bs/lint
rename to bs/dev/lint
index 37a0e9a..b5a3313 100755
--- a/bs/lint
+++ b/bs/dev/lint
@@ -6,21 +6,17 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
}
# depends on
declare -r tsc='node_modules/.bin/tsc'
-declare -r tscAlias='node_modules/.bin/tsc-alias'
help(){
if ! isHelp "${@}"; then return 0; fi
echoReadmeInfo
echo
$tsc --help
- $tscAlias --help
exit 0
}
main(){
help "${@}"
- $tsc "${@}"
- echo "$tscAlias ${@}"
- $tscAlias "${@}"
+ $tsc --noEmit "${@}"
}
main "${@}"
diff --git a/bs/dev/paths.js b/bs/dev/paths.js
new file mode 100755
index 0000000..e56e4cf
--- /dev/null
+++ b/bs/dev/paths.js
@@ -0,0 +1,44 @@
+#!/bin/env node
+import tsconfig from "../../tsconfig.json" with { type: "json" };
+export const paths = {
+ /** code source */
+ src: "src",
+ /** code processed by tsc */
+ tscoutput: tsconfig.compilerOptions.outDir,
+ /** code processed by tsc and rollup */
+ dist: "dist",
+ /** tempral results of tsc, tests, … */
+ tmp: ".tmp",
+};
+export default paths;
+
+import { argv, exit } from "node:process";
+import { fileURLToPath } from "node:url";
+const [ _, script ] = argv;
+if (script === fileURLToPath(import.meta.url))
+ main(argv.slice(2));
+
+function main(args) {
+ if(args.includes("--help") || args.includes("-h")){
+ console.log(`
+Usage: ${script} [options]
+
+ Options:
+ [type] … if omitted, echo all
+`);
+ exit(0);
+ }
+ if(args.length === 0){
+ console.log(paths);
+ exit(0);
+ }
+ for(const arg of args){
+ const path = paths[arg];
+ if(!path){
+ console.error(`Unknown path: ${arg}`);
+ exit(1);
+ }
+ console.log(path);
+ }
+}
+
diff --git a/bs/dev/tsc b/bs/dev/tsc
new file mode 100755
index 0000000..f39ed9d
--- /dev/null
+++ b/bs/dev/tsc
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3Ml53kvc
+. bs/.common || {
+ echo 'Please run this script from the project root directory' >&2;
+ exit 1;
+}
+# depends on
+declare -r tsc='node_modules/.bin/tsc'
+declare -r tscAlias='node_modules/.bin/tsc-alias'
+
+help(){
+ if ! isHelp "${@}"; then return 0; fi
+ echoReadmeInfo
+ echo
+ $tsc --help
+ $tscAlias --help
+ exit 0
+}
+main(){
+ help "${@}"
+ $tsc "${@}"
+ $tscAlias "${@}"
+}
+
+main "${@}"
diff --git a/bs/start b/bs/start
index 71362e4..620c2a6 100755
--- a/bs/start
+++ b/bs/start
@@ -6,7 +6,9 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
}
# depends on
declare -r server='node_modules/.bin/web-dev-server'
-declare -r lint='bs/lint'
+declare -r lint='bs/dev/lint'
+declare -r tsc='bs/dev/tsc'
+declare -r assets='bs/dev/assets'
declare -r server_config='web-dev-server.config.js'
help(){
@@ -25,12 +27,14 @@ EOF
main(){
help "${@}"
+ $lint
local -r target="${1:-./src}" # ./src or ./dist
if [[ "$target" =~ 'dist' ]]; then
# console warns because of config file, use npx serve?
$server "${@}"
else
- $lint --watch --preserveWatchOutput &
+ $assets
+ $tsc --watch --preserveWatchOutput &
$server "${@}" &
wait
fi
diff --git a/bs/test b/bs/test
index c4a602b..1dd30d8 100755
--- a/bs/test
+++ b/bs/test
@@ -5,8 +5,8 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
exit 1;
}
# depends on
-declare -r lint='bs/lint'
-declare -r wtr='node_modules/.bin/wtr'
+declare -r tsc='bs/dev/tsc'
+declare -r wtr='node_modules/.bin/web-test-runner'
help(){
if ! isHelp "${@}"; then return 0; fi
@@ -20,12 +20,12 @@ EOF
main(){
help "$1"
if [[ "$1" != "--watch" ]]; then
- $lint
+ $tsc
$wtr "$@" --coverage
exit
fi
- $lint --watch --preserveWatchOutput &
+ $tsc --watch --preserveWatchOutput &
$wtr "${*}" &
wait
}
diff --git a/index.html b/index.html
index ec6ed8e..61afdad 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,7 @@
-
+