build: Move scripts out. Make generated files obv.

To speed up builds, typedoc is now run in the background, which means
that the build won't fail if typedoc fails.
This commit is contained in:
Colin Caine 2017-11-08 18:09:20 +00:00
parent b2ee48ef00
commit 7697072be1
7 changed files with 14 additions and 14 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@ build
node_modules
src/excmds_background.ts
src/excmds_content.ts
generated
web-ext-artifacts

View file

@ -25,8 +25,8 @@
"webpack-shell-plugin": "^0.5.0"
},
"scripts": {
"build": "typedoc --out src/static/docs src --ignoreCompilerErrors; webpack",
"watch": "chokidar src --initial --silent -i 'src/excmds_{background,content}.ts' -i 'src/static/docs/modules/_excmds_.html' -c 'webpack --display errors-only'",
"build": "webpack",
"watch": "chokidar src --initial --silent -i 'src/excmds_{background,content}.ts' -i 'src/static/docs' -c 'webpack --display errors-only'",
"clean": "rm -rf build",
"test": "npm run build && jest --silent",
"update-buildsystem": "rm -rf src/node_modules; npm run clean"

14
src/excmds_macros.py → scripts/excmds_macros.py Normal file → Executable file
View file

@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
"""Force reflection upon an unwilling world.
Processes a single excmds.ts to produce a background and content version.
@ -134,11 +134,6 @@ def omit_line_factory(desired_context):
def main():
"""Iterate over the file, dispatching to appropriate macro handlers."""
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
macros = {
"content": content,
"background": background,
@ -149,8 +144,8 @@ def main():
}
for context in ("background", "content"):
with open("excmds.ts") as source:
output = ""
with open("src/excmds.ts") as source:
output = PRELUDE
lines = iter(source)
for line in lines:
if line.startswith("//#"):
@ -162,8 +157,9 @@ def main():
else:
output += line
# print(output.rstrip())
with open("excmds_{context}.ts".format(**locals()), "w") as sink:
with open("src/excmds_{context}.ts".format(**locals()), "w") as sink:
print(output.rstrip(), file=sink)
PRELUDE = "/** Generated from excmds.ts. Don't edit this file! */"
main()

3
scripts/make_docs.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
typedoc --out generated/static/docs/ src --ignoreCompilerErrors
./scripts/commandline_injector.sh generated/static/docs/modules/_excmds_.html

View file

@ -1,2 +0,0 @@
#!/bin/sh
../node_modules/.bin/typedoc --out static/docs/ . --ignoreCompilerErrors

View file

@ -38,7 +38,8 @@ module.exports = {
// }
// }),
new WebpackShellPlugin({onBuildStart: [
'python3 src/excmds_macros.py', './src/commandline_injector.sh src/static/docs/modules/_excmds_.html'
'scripts/excmds_macros.py',
'scripts/make_docs.sh &',
]}),
new CopyWebPackPlugin([
{ from: "src/manifest.json" },