diff --git a/build/appcache.py b/build/appcache.py index 3c9acfa5..a4861961 100644 --- a/build/appcache.py +++ b/build/appcache.py @@ -2,6 +2,7 @@ import click import os import re +import time @wq.command() @@ -9,13 +10,18 @@ @wq.pass_config def appcache(config, version): """ - Generate an HTML5 appcache manifest. Should be run after wq optimize, as - some of the manifest entries will be inferred from the build log. + (DEPRECATED) Generate an HTML5 appcache. Should be run after + wq optimize, as some of the manifest entries will be inferred from the + build log. - A manifest will be created for both the source directory and the build - directory, so you can test offline capabilities even when running off of - the source AMD files. + Note that browser vendors are deprecating support for Application Cache + in favor of Service Workers. The `wq appcache` command will be removed in + wq.app 2.0. """ + + click.echo("Warning: Application Cache is deprecated by browser vendors.") + time.sleep(10) + if 'appcache' not in config: raise click.UsageError( "appcache section not found in %s" % config.filename diff --git a/build/builder.py b/build/builder.py index 32982315..ec96a20e 100644 --- a/build/builder.py +++ b/build/builder.py @@ -1,5 +1,7 @@ from wq.core import wq import click +import subprocess +import os from .collect import collectjson from .setversion import setversion @@ -23,14 +25,27 @@ def build(ctx, config, version): wq collectjson (if configured) wq scss (if configured) wq mustache (if configured) - wq optimize - wq babel (if configured) - wq appcache (if configured) + + \b + Followed by either: + wq optimize + wq babel + wq appcache + Or: + npm build """ - if 'optimize' not in config: - raise click.UsageError( - "optimize section not found in %s" % config.filename - ) + + has_package_json = os.path.exists( + os.path.join(os.path.dirname(config.filename), 'package.json') + ) + if has_package_json: + if 'optimize' in config: + raise click.UsageError( + "optimize section is not used for npm build" + ) + else: + if 'optimize' not in config: + raise click.UsageError( + "optimize section not found in %s" % config.filename + ) def run(command, **kwargs): confs = config.get(command.name, {}) @@ -49,13 +64,19 @@ def run(command, **kwargs): if command.name in config: run(command) - # Compile Javascript / CSS (using r.js) - ctx.invoke(optimize) + if has_package_json: + subprocess.check_call( + ['npm', 'build'], + cwd=os.path.abspath(os.path.dirname(config.filename)) + ) + else: + # Compile Javascript / CSS (using r.js) + ctx.invoke(optimize) - # Convert to ES5 via babel.js - if 'babel' in config: - ctx.invoke(babel) + # Convert to ES5 via babel.js + if 'babel' in config: + ctx.invoke(babel) - # Generate HTML5 Cache manifests - if 'appcache' in config: - ctx.invoke(appcache, version=version) + # Generate HTML5 Cache manifests + if 'appcache' in config: + ctx.invoke(appcache, version=version) diff --git a/build/compilers.py b/build/compilers.py index 9faf0e5c..eb85242b 100644 --- a/build/compilers.py +++ b/build/compilers.py @@ -17,10 +17,14 @@ @wq.pass_config def optimize(config): """ - Use r.js to optimize JS and CSS assets. This command requires an - "optimize" section in your configuration file, which will be passed as-is - to r.js for compilation. See http://requirejs.org/docs/optimization.html - for available configuration options. + (DEPRECATED) Use r.js to optimize JS and CSS. This command requires an + "optimize" section in your configuration file, which will be passed to + r.js for compilation. See http://requirejs.org/docs/optimization.html + for available options. + + Note that r.js-based compilation is deprecated and will be removed in + wq.app 2.0. For full control over the compilation process, use + `wq start --with-npm` instead. """ conf = config.get('optimize', None) if not conf: @@ -42,10 +46,14 @@ def optimize(config): @wq.pass_config def babel(config): """ - Use babel.js to compile ES6/2015+. Generates ES5-compatible JavaScript for - older browsers. Note that wq babel is run after wq optimize, on the - compiled modules created by r.js. Support for running babel at other - stages of the build process may be added in a future version of wq.app. + (DEPRECATED) Use babel.js with ES6/2015+. Generates ES5-compatible + JavaScript for older browsers. Note that wq babel is run after + wq optimize, on the compiled modules created by r.js. For more control + over the compilation process, use `wq start --with-npm` instead of + an r.js-based build. + + Note that this command will be removed in wq.app 2.0 in favor of + `wq start --with-npm`. """ rconf = config.get('optimize', None) if not rconf: @@ -93,9 +101,12 @@ def babel(config): ) def scss(**conf): """ - Render all SCSS/SASS files into CSS. The input directory will be searched + (DEPRECATED) Render SCSS/SASS into CSS. The input folder will be searched for *.scss files, which will be compiled to corresponding *.css files in the output directory. + + Note: This command will be removed in wq.app 2.0 in favor of + Material UI themes. """ compiler = pyScss.Scss(scss_opts={'compress': 0}) logging.getLogger("scss").addHandler(logging.StreamHandler()) @@ -133,7 +144,7 @@ def compile(path, source): ) def mustache(**conf): """ - Render a mustache template into static HTML. The template context can be + (DEPRECATED) Render mustache into HTML files. The template context can be provided via a nexted object in wq.yml, or by pointing to a folder containing JSON or YAML files. Similarly, the partials can be defined as a nested object in wq.yml or by a folder path. @@ -154,6 +165,8 @@ def mustache(**conf): Example command line configuration: wq mustache --template tmpl.html --partials partials/ --context conf/ + + Note: This command will be removed in wq.app 2.0 in favor of JSX. """ template = conf['template'] if template is None: diff --git a/build/phonegap.py b/build/phonegap.py index 5ae49e03..a809be23 100644 --- a/build/phonegap.py +++ b/build/phonegap.py @@ -7,6 +7,7 @@ import shutil import pystache from .icons import icons, SIZES +import time @wq.command() @@ -37,7 +38,7 @@ @click.pass_context def phonegap(ctx, config, version, **conf): """ - Upload application to PhoneGap Build. Specifically, + (DEPRECATED) Package app for PhoneGap Build. Specifically, \b 1. Create a working directory, if not present. @@ -48,9 +49,16 @@ def phonegap(ctx, config, version, **conf): 6. Upload the zip file to PhoneGap build. 7. Save the returned app ID for future builds. \b - (Inspired by, but not dependent on, the `phonegap remote` api) + Note that PhoneGap Build is no longer online. The `wq phonegap` command + will be removed in wq.app 2.0. @wq/react and @wq/material support using + React Native and/or Expo to deploy native apps. """ + click.echo( + "Warning: PhoneGap Build is offline; this command will likely fail." + ) + time.sleep(10) + if conf['source']: source = conf['source'] else: