- Add basic webpack example
- Improve error messages
- Add XSRF headers
- Allow the usage of hyphens in
sourcePath
andtargetPath
.
viewport-uploader
is the newgulp-viewport
.
Version 3.0.0 of viewport-uploader
is the biggest update it has seen yet. An update so big that it needed to change its name. "Why would a package need to change its name?" you might wonder. Well, gulp-viewport
was actually never a good gulp plugin. To be a gulp plugin, you have to do something useful in the pipe. In other words you have to modify the file stream, otherwise you are just useless for the pipe and could just as well be a separate task. Now all methods of gulp-viewport
except upload()
didn't even support piping, and the latter didn't do anything with the stream other than to give it back. And not only that, but upload()
also buffered the files from the stream to only upload them at once after the stream has went through, defying the whole purpose of having a stream in the first place.
Rule No. 1 of the Gulp plugin guidelines states it quite clearly:
Your plugin should not do something that can be done easily with an existing node module
- For example: deleting a folder does not need to be a gulp plugin. Use a module like del within a task instead.
- Wrapping every possible thing just for the sake of wrapping it will pollute the ecosystem with low quality plugins that don't make sense within the gulp paradigm.
- gulp plugins are for file-based operations! If you find yourself shoehorning a complex process into streams just make a normal node module instead.
- A good example of a gulp plugin would be something like gulp-coffee. The coffee-script module does not work with Vinyl out of the box, so we wrap it to add this functionality and abstract away pain points to make it work well within gulp.
Now it took us some time to realise our mistakes, but we don't want to be a bad plugin and we don't want to pollute a nice ecosystem. The problem is that the name of an existing package can't be changed without breaking existing projects. So the only sensible choice was to deprecate the existing package in favour of a new package. The new package viewport-uploader
is now proudly admitting to not be a gulp plugin, but instead an ordinary node module. Its methods don't support piping, as it should have always been.
"Now what happens with my gulp workflow" you might ask? Nothing! viewport-uploader
can still be used with gulp, as can any other node module out there. It just won't be in a pipe but instead in a separate task. As viewport-uploader
doesn't manipulate the file stream it really makes no sense to be in it. The main purpose of uploading files to Scroll Viewport can as well be done from outside the pipe. Imagine you could select files using globs just like with src()
and use its methods asynchronously in series()
or parallel()
calls. Wouldn't that be great? Well, we thought so too and rewrote viewport-uploader
from the ground up to be asynchronous and to support globs. Now the reason to be in a pipe to get the files nicely delivered from src
becomes obsolete, because you can just reuse the same globs as arguments for upload()
. Also viewport-uploader
is compatible with the newest versions of Node (v13 at time of writing) and the new viewport-cli
v1 which has undergone a similarly big update and replace viewport-tools
. Further the code is cleaned up and uses contemporary dependencies. It gives us also more freedom, like that in a pipe one can't throw errors, since it breaks the whole pipe for everyone, but outside we can. Or that the class instance the upload()
method is called upon couldn't be manipulated after the upload is done since we needed to wrap everything in the stream object that was returned. In the end this was the right call and we call it viewport-uploader
.
- Rewritten from scratch
- with ES6 syntax, strict mode,
const
variables - much cleaner code, split into modules
- with ES6 syntax, strict mode,
- All methods are async and return promises
- Integrates with new
.vpconfig.json
created byviewport-cli
(seeviewport-cli
for full documentation on changes)- accepts only
envName
andthemeName
, target environment is then loaded from.vpconfig.json
, much easier forviewport-cli
to create themes - add more robust validation check (same as in
viewport-cli
) - remove nested properties, e.g.
mytheme.options.target.confluenceBaseUrl
in favor of flat properties
- accepts only
- Old dependencies have been replaced or removed if possible
- replaced
request
withnode-fetch
andform-data
- removed
gulp-utils
,through2
(no streams!),home-config
, and some others
- replaced
- Removed "example" theme (see
viewport-cli
"default" theme instead)
- Removed
themeId
argument in favor of loading it on firstcreate()
call, less complex to have only one variable (doesThemeExist) instead of two (doesThemeExist, themeId) for which need to check independently before can safely run any method.
- Removed piping support for Vinyl stream (see intro above)
- Takes globs,
targetPath
andsourcePath
as arguments, replaces hardcoded ones in config file, can change for each call - Remove event emitter, don't need anymore, promises already do the notification when they're done