Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to the workbox-cli interface in v3 #865

Closed
jeffposnick opened this issue Oct 9, 2017 · 4 comments
Closed

Changes to the workbox-cli interface in v3 #865

jeffposnick opened this issue Oct 9, 2017 · 4 comments
Assignees
Labels
Breaking Change Denotes a "major" semver change. workbox-cli

Comments

@jeffposnick
Copy link
Contributor

Library Affected:
workbox-cli

Here are few ideas for changing the workbox-cli interface. Some might be controversial, so feel free to push back.

  1. Move from generate:sw and inject:manifest to generateSW and injectManifest.
  2. No longer infer whether we should be in "wizard" mode or not. Developers can use wizard as the command to enter wizard mode.
  3. Get rid of the --config-file optional flag in favor of making it a required argument for all the modes. For "wizard" mode, it would be the file to write to, and for the other modes, it would be the file to read from.
  4. No longer take in build configuration via command-line flags. It's always been confusing understanding whether the flags or the config file options took precedence, and it's also not ideal that CLI flags can only be strings, while the underlying config options might be arbitrary JS types. Developers who need to use different configurations for different modes can specify different config files rather than using different flags.

Here's the help text that I was thinking of, which should make the changes described above a bit more concrete:

$ ./bin.js --help

  The command line interface for the workbox-build module.

  Usage:
  $ workbox command path/to/workbox-config.js
  
  Arguments:
    command  Can be one of:
             - wizard: Runs the configuration wizard, which will generate a config
               file based on your local build environment.
             - generateSW: Creates a new service worker file based on the
               options in the config file. See
               https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.generateSW
             - injectManifest: Takes an existing service worker file as a
               starting point and creates a service worker file with precaching
               manifest "injected", based on the options in the config file. See
               https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.injectManifest

    path/to/workbox-config.js  In 'wizard' mode, this will be used as the
                               destination for saving your configuration.
                               In 'generateSW' or 'injectManifest' mode, it should
                               be an existing file, in CommonJS module format.
                               The exported object's properties should follow
                               https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.Configuration
                 
  Examples:
    $ workbox wizard new-workbox-config.js
    $ workbox generateSW workbox-config.js
    $ workbox injectManifest config/workbox-config.js
@jeffposnick jeffposnick added the Breaking Change Denotes a "major" semver change. label Oct 9, 2017
@jeffposnick jeffposnick self-assigned this Oct 9, 2017
@gauntface
Copy link

I'm in favor of all of the above.

  1. Will wizard mode still read the default values from the config file?
  2. This will pretty much ruin the straight convert story from sw-precache to Workbox. I'm personally ok with this, but it's worth keeping in mind.

@jeffposnick
Copy link
Contributor Author

  1. My gut is to have the wizard use some hardcoded default values, and then treat the config file as something that gets written to, but I might have more to say once I start porting over the wizard code. I'm going to focus on the other modes first.

  2. At this point, I'm happy to make a break from trying to coerce command line flags into the correct types, which plagued sw-precache. We've also officially deprecated the staticFileGlobs and dynamicUrlToDependency names, so the sw-precache => workbox v3 conversion would require some changes anyway. I think the automatic option validation in v3 + the links directly to the configuration docs should help here.

@gauntface
Copy link

@jeffposnick can this be closed now?

@gauntface gauntface reopened this Dec 1, 2017
@jeffposnick
Copy link
Contributor Author

Yup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Denotes a "major" semver change. workbox-cli
Projects
None yet
Development

No branches or pull requests

2 participants