Skip to content

Commit

Permalink
add deprecation warnings (fixes #119, #121)
Browse files Browse the repository at this point in the history
 - wq optimize -> npm build
 - wq babel -> npm build
 - wq appcache -> Service Worker
 - wq phonegap -> React Native / Expo
 - wq scss -> Material UI theme
 - wq mustache -> JSX
  • Loading branch information
sheppard committed Sep 22, 2020
1 parent 73847a3 commit b8de442
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 32 deletions.
16 changes: 11 additions & 5 deletions build/appcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
import click
import os
import re
import time


@wq.command()
@click.argument('version')
@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
Expand Down
51 changes: 36 additions & 15 deletions build/builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from wq.core import wq
import click
import subprocess
import os

from .collect import collectjson
from .setversion import setversion
Expand All @@ -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, {})
Expand All @@ -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)
33 changes: 23 additions & 10 deletions build/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions build/phonegap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import pystache
from .icons import icons, SIZES
import time


@wq.command()
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down

0 comments on commit b8de442

Please sign in to comment.