Skip to content

Commit

Permalink
Merge branch 'proper-package.json'
Browse files Browse the repository at this point in the history
* Branch commit log:
  doc/copyright.ini: fix package.json path
  ui/Makefile.mk: adjust paths for the typescript compiler invocation
  ui/Makefile.mk: adjust paths for the eslint invocation
  ui/Makefile.mk: adjust paths for the stylelint invocation
  ui/Makefile.mk: adjust build stamp paths
  ui/tsconfig.json: use full path to source files
  Makefile.mk: fix missing CLEANFILES
  ui/xbcomments.js: use ES6 imports
  ui/jsextract.js: use ES6 imports
  ui/Makefile.mk: adjust eslint to run in project root
  ui/sfc-compile.js: use ES6 imports
  ui/eslintrc.cjs: add comment about why this is CJS
  ui/eslintrc.cjs: convert to CJS to be loadable from eslint
  package.json: use paths relative to project root
  doc/jsdoc-slashes.cjs: add comment about why this is CJS
  doc/jsdoc-slashes.cjs: convert to CJS to be loadable from jsdoc
  doc/jsdoc2md.js: convert to ES6 module
  ui/Makefile.mk: use node_modules/ in project root
  x11test/replay.sh: use node_modules/ in project root
  doc/*: use node_modules/ in project root
  electron/Makefile.mk: use node_modules/ in project root
  Makefile.mk: install node_modules/ in project root
  package.json: move NPM package configuration here
  misc/package.json.in: use exec in scripts to spare shell wrappers

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Mar 1, 2024
2 parents f6ea63f + 0e8f3fd commit 19e5948
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 125 deletions.
25 changes: 10 additions & 15 deletions Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ $>/ls-tree.d: $(GITCOMMITDEPS) | $>/
$Q test ! -e .git || git submodule update --init --recursive
$Q touch $@
Makefile.mk: .submodule-stamp
CLEANFILES += .submodule-stamp

# == enduser targets ==
all: FORCE
Expand Down Expand Up @@ -247,30 +248,24 @@ $>/config.sh: $(wildcard config-defaults.mk) | $>/
$Q mv $@.tmp $@
ALL_TARGETS += $>/config.sh

# == package.json ==
$>/package.json: misc/package.json.in | $>/
$(QGEN)
$Q $(CP) $< $@.tmp
$Q mv $@.tmp $@
CLEANDIRS += $>/node_modules/

# == npm.done ==
$>/node_modules/.npm.done: $(if $(NPMBLOCK),, $>/package.json) | $>/
node_modules/.npm.done: $(if $(NPMBLOCK),, package.json) | $>/
$(QGEN)
$Q rm -f -r $>/node_modules/
$Q rm -f -r node_modules/
@: # Install all node_modules and anonymize build path
$Q cd $>/ \
$Q : \
&& { POFFLINE= && test ! -d node_modules/ || POFFLINE=--prefer-offline ; } \
&& $(NPM_INSTALL) $$POFFLINE
@: # Anonymize build paths in node_modules
$Q find $>/node_modules/ -name package.json -print0 | xargs -0 sed -r "\|$$PWD|s|^(\s*(\"_where\":\s*)?)\"$$PWD|\1\"/...|" -i
$Q find node_modules/ -name package.json -print0 | xargs -0 sed -r "\|$$PWD|s|^(\s*(\"_where\":\s*)?)\"$$PWD|\1\"/...|" -i
@: # Fix bun installation, see: https://github.com/oven-sh/bun/pull/5077
$Q test ! -d $>/node_modules/sharp/ -o -d $>/node_modules/sharp/build/Release/ || (cd $>/node_modules/sharp/ && $(NPM_INSTALL))
$Q test -d $>/node_modules/electron/dist/ || (cd $>/node_modules/electron/ && $(NPM_INSTALL))
$Q: # add newer nodejs API to browserify-url.js, needed for e.g. postcss error messages
$Q test ! -d node_modules/sharp/ -o -d node_modules/sharp/build/Release/ || (cd node_modules/sharp/ && $(NPM_INSTALL))
$Q test -d node_modules/electron/dist/ || (cd node_modules/electron/ && $(NPM_INSTALL))
$Q touch $@
NODE_PATH ::= $(abspath $>/node_modules/)
NODE_PATH ::= $(abspath node_modules/)
export NODE_PATH
CLEANDIRS += node_modules/
CLEANFILES += bun.lockb package-lock.json

# == uninstall ==
uninstall:
Expand Down
4 changes: 2 additions & 2 deletions doc/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $>/doc/copyright: misc/mkcopyright.py doc/copyright.ini $>/ls-tree.lst | $>/doc/
doc/jsdocs_js := $(wildcard ui/*.js ui/b/*.js)
doc/jsdocs_md := $(doc/jsdocs_js:ui/%.js=$>/doc/jsdocsmd/%.md)
$(doc/jsdocs_md): doc/jsdoc2md.js
$>/doc/jsdocsmd/%.md: ui/%.js | $>/node_modules/.npm.done $>/doc/jsdocsmd/b/
$>/doc/jsdocsmd/%.md: ui/%.js | node_modules/.npm.done $>/doc/jsdocsmd/b/
$(QGEN)
$Q node doc/jsdoc2md.js -d 2 $< > $@.tmp
$Q grep -q '[^[:space:]]' $@.tmp && mv $@.tmp $@ || { rm -f $@.tmp && touch $@ ; }
Expand All @@ -80,7 +80,7 @@ $>/doc/jsdocs.md: $(doc/jsdocs_md) doc/Makefile.mk
$Q mv $@.tmp2 $@

# == doc/scripting-docs.md ==
$>/doc/scripting-docs.md: ui/host.js doc/ch-scripting.md $(doc/jsdoc.deps) doc/Makefile.mk $>/node_modules/.npm.done | $>/doc/
$>/doc/scripting-docs.md: ui/host.js doc/ch-scripting.md $(doc/jsdoc.deps) doc/Makefile.mk node_modules/.npm.done | $>/doc/
$(QGEN)
$Q cat doc/ch-scripting.md > $@.tmp
$Q echo -e '\n## Reference for $<' >> $@.tmp
Expand Down
6 changes: 3 additions & 3 deletions doc/copyright.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ files =
README.md
devices/blepsynth/TODO
doc/highlights.theme
doc/jsdocrc.json
doc/template.diff
images/README.md
misc/anklang-mime.xml
misc/package.json.in
doc/jsdocrc.json
package.json
patterns =
doc/.*\.1\.md
.*/ch-.*\.md
doc/.*\.1\.md
x11test/.*\.json
2 changes: 2 additions & 0 deletions doc/jsdoc-slashes.js → doc/jsdoc-slashes.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
"use strict";

/* This fils is loaded as CJS module from jsdoc, via jsdocrc.json */

/// Export jsdoc plugin to convert '/// comment\n' into '/** comment */\n'
exports.handlers = {
beforeParse: (arg) => {
Expand Down
4 changes: 2 additions & 2 deletions doc/jsdoc2md.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
"use strict";

const fs = require ('fs');
const jsdoc = require ('jsdoc-api');
import * as fs from 'fs';
import * as jsdoc from 'jsdoc-api';

function usage (full = false) {
const prog = process.argv[1].replace (/.*\//, '');
Expand Down
2 changes: 1 addition & 1 deletion doc/jsdocrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"plugins": [
"jsdoc-tsimport-plugin",
"doc/jsdoc-slashes"
"doc/jsdoc-slashes.cjs"
]
}
6 changes: 3 additions & 3 deletions doc/poxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ test -e ase/api.hh || die "must run in anklang/"
test -e out/doc/anklang-manual.html || die "a fully build project is required"

# Find node_modules
test -d out/node_modules/jsdoc-api || die "a fully build project is required"
export NODE_PATH=out/node_modules/
test -d node_modules/jsdoc-api || die "a fully build project is required"
export NODE_PATH=node_modules/

# Parse args
VERSION=(`misc/version.sh`)
Expand Down Expand Up @@ -102,7 +102,7 @@ __EOF
done

# Extract JS docs
make out/node_modules/.npm.done
make node_modules/.npm.done
MARKDOWN_FLAVOUR="-f markdown+compact_definition_lists+autolink_bare_uris+emoji+lists_without_preceding_blankline-smart-raw_html"
HTML_FLAGS="--highlight-style doc/highlights.theme --html-q-tags --section-divs --email-obfuscation=references"
for f in ui/*.js ui/b/*.js ; do
Expand Down
20 changes: 10 additions & 10 deletions doc/style/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@ doc/style/install.files ::=
doc/style/faketex.css ::= $>/doc/style/faketex.css

# == doc/style/mathjax ==
$>/doc/style/mathjax-tex-svg.js: doc/style/mathjax-config.js $>/node_modules/.npm.done | $>/doc/style/
$>/doc/style/mathjax-tex-svg.js: doc/style/mathjax-config.js node_modules/.npm.done | $>/doc/style/
$(QGEN)
$Q cat $< $>/node_modules/mathjax/es5/tex-svg-full.js > $@.tmp
$Q cat $< node_modules/mathjax/es5/tex-svg-full.js > $@.tmp
$Q mv $@.tmp $@
doc/style/install.files += $>/doc/style/mathjax-tex-svg.js

# == doc/style/faketex.css ==
$(doc/style/faketex.css): doc/style/faketex.scss doc/style/features.scss $>/node_modules/.npm.done | $>/doc/style/
$(doc/style/faketex.css): doc/style/faketex.scss doc/style/features.scss node_modules/.npm.done | $>/doc/style/
$(QGEN)
$Q $>/node_modules/.bin/sass --embed-source-map $< $@.tmp
$Q node_modules/.bin/sass --embed-source-map $< $@.tmp
$Q mv $@.tmp $@
doc/style/install.files += $(doc/style/faketex.css)

DOC/STYLE/SEDFONTS ::= -e "s/, *url('[^()']*\.woff') *format('woff')//" -e "s|url('\./files|url('./|"

# == doc/style/charis-sil.css ==
$>/doc/style/charis-sil.css: $>/node_modules/.npm.done | $>/doc/style/
$>/doc/style/charis-sil.css: node_modules/.npm.done | $>/doc/style/
$(QGEN)
$Q $(CP) $>/node_modules/@fontsource/charis-sil/files/*.woff2 $>/doc/style/
$Q sed $>/node_modules/@fontsource/charis-sil/index.css $(DOC/STYLE/SEDFONTS) > $@.tmp
$Q $(CP) node_modules/@fontsource/charis-sil/files/*.woff2 $>/doc/style/
$Q sed node_modules/@fontsource/charis-sil/index.css $(DOC/STYLE/SEDFONTS) > $@.tmp
$Q mv $@.tmp $@
doc/style/install.files += $>/doc/style/charis-sil.css

# == doc/style/inconsolata.css ==
$>/doc/style/inconsolata.css: $>/node_modules/.npm.done | $>/doc/style/
$>/doc/style/inconsolata.css: node_modules/.npm.done | $>/doc/style/
$(QGEN)
$Q $(CP) $>/node_modules/@fontsource/inconsolata/files/inconsolata-latin-ext-*-normal.woff2 $>/doc/style/
$Q sed $>/node_modules/@fontsource/inconsolata/latin-ext.css $(DOC/STYLE/SEDFONTS) > $@.tmp
$Q $(CP) node_modules/@fontsource/inconsolata/files/inconsolata-latin-ext-*-normal.woff2 $>/doc/style/
$Q sed node_modules/@fontsource/inconsolata/latin-ext.css $(DOC/STYLE/SEDFONTS) > $@.tmp
$Q mv $@.tmp $@
doc/style/install.files += $>/doc/style/inconsolata.css

Expand Down
4 changes: 2 additions & 2 deletions electron/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ electron/all:
electron/js.sources ::= electron/main.js electron/preload.js $>/ui/anklang.png

# == electron/anklang ==
$>/electron/anklang: $(electron/js.sources) electron/Makefile.mk $>/node_modules/.npm.done
$>/electron/anklang: $(electron/js.sources) electron/Makefile.mk node_modules/.npm.done
$(QGEN)
$Q rm -f -r $(@D)
$Q $(CP) -r $>/node_modules/electron/dist/ $(@D)
$Q $(CP) -r node_modules/electron/dist/ $(@D)
$Q chmod -x $>/electron/lib*.so*
$Q rm $(@D)/resources/default_app.asar
$Q mkdir -p $(@D)/resources/app
Expand Down
8 changes: 4 additions & 4 deletions misc/package.json.in → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"private": true,
"type": "module",
"scripts": {
"serve": "run-p sound-engine monitor",
"sound-engine": "lib/AnklangSynthEngine $ASEOPT",
"monitor": "nodemon --ext '*' --watch ../ui/ --delay 2500ms --on-change-only --exec 'npm run -s ui/rebuild' --exitcrash",
"ui/rebuild": "make ui/rebuild -C .. -j`nproc`"
"serve": "exec run-p sound-engine monitor",
"sound-engine": "exec out/lib/AnklangSynthEngine $ASEOPT",
"monitor": "exec nodemon --ext '*' --watch ui/ --delay 1000ms --on-change-only --exec 'npm run -s ui/rebuild' --exitcrash",
"ui/rebuild": "exec make ui/rebuild -j`nproc`"
},
"dependencies": {
"vue": "=3.3.7"
Expand Down
Loading

0 comments on commit 19e5948

Please sign in to comment.