Coder Social home page Coder Social logo

sethwebster / ember-cli-new-version Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 26.0 1.81 MB

A convention based update notification for Ember. With this addon, you can detect a new version and notify the user to refresh the page

Home Page: http://sethwebster.github.io/ember-cli-new-version/

License: MIT License

JavaScript 87.49% HTML 7.08% CSS 3.09% Handlebars 2.34%
ember ember-cli module notifications npm

ember-cli-new-version's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @sethwebster
  • ๐Ÿ‘€ Iโ€™m interested in React, Aviation, Non-profits.
  • ๐ŸŒฑ Iโ€™m currently learning Expo, React Native, Elixir, Rust
  • ๐Ÿ’ž๏ธ Iโ€™m looking to collaborate on ยฏ_(ใƒ„)_/ยฏ - have an idea?
  • ๐Ÿ“ซ How to reach me @sethwebster on twitter.

ember-cli-new-version's People

Contributors

amilkey avatar barelyknown avatar basz avatar bgentry avatar colenso avatar ctjhoa avatar dependabot[bot] avatar devotox avatar elidupuis avatar hoyaboya avatar initram avatar jakesjews avatar jrjohnson avatar knownasilya avatar medokin avatar pbernery avatar pgengler avatar sethwebster avatar shijistar avatar st-h avatar subtletree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-new-version's Issues

allow disabling build-time logic

I'd like to use this library, but have all of the current-version logic handled somewhere else; I don't want it to write a VERSION.txt, nor to populate currentVersion in the built app. It seems like there's no way to do this without explicitly setting APP.version to null, which has other side-effects. What would you think about adding a config value or special sentinel value for config.currentVersion which would disable this logic.

Republish without debugger statement

The currently published version has a debugger statement in the url computed function. I see it's not in the current source code so can you republish? It's a bit of a pain when developing

thanks

 url: Ember.computed('versionFileName', function () {
      debugger;
      const config = Ember.getOwner(this).resolveRegistration('config:environment');
      const versionFileName = Ember.get(config, 'newVersion.fileName') || this.get('versionFileName');
      const baseUrl = Ember.get(config, 'newVersion.prepend') || config.rootURL || config.baseURL;

Provide options for fetch (cors)

Hi, i use my app in another app, and i can't do CORS request to /VERSION.txt because fetch method do request without option (mode: 'cors') can you allow setup options for fetch?

New Release

Would it be possible to get a release published with the changes from #19?

Cannot read property 'browsers' of undefined

After upgrading to v1.4.2, I can't run my development server any more. It crashes with the following error when attempting to start:

Cannot read property 'browsers' of undefined

The app is running on ember 3.4.4

Is removing ember-concurrency a viable option?

As ember concurrency adds quite a bit to an applications bundle size, it would be great if this addon wouldn't necessarily depend on it. If this is an option, I'll be happy to put together a PR once I can find the time to do so.

It is worthy to mention deployment script modifications for VERSION.txt in the documentation

As many would use ember-cli-deploy, VERSION.txt should go in separate step, e.g.

// ./config/deploy.js
  let ENV = {
    pipeline: {
      alias: {
        s3: { as: ['s3-version', 's3'] },
      },
    's3-version': {
      bucket: '***',
      region: '**',
      filePattern: 'VERSION.txt',
      cacheControl: 'max-age=0, no-cache',
      expires: 1525781737
    },
...
    },

It is good idea to have the same bucket as index file.

Deprecation message from ember-getowner-polyfill

Is it possible to remove this deprecation message? I'm using Ember 2.10.0.

DEPRECATION: ember-getowner-polyfill is now a true polyfill. Use Ember.getOwner directly instead of importing from ember-getowner-polyfill [deprecation id: ember-getowner-polyfill.import]
        at logDeprecationStackTrace (http://s_insight2.udesk.cn/site/assets/vendor.js:27268:19)
        at HANDLERS.(anonymous function) (http://s_insight2.udesk.cn/site/assets/vendor.js:27378:7)
        at raiseOnDeprecation (http://s_insight2.udesk.cn/site/assets/vendor.js:27298:12)
        at HANDLERS.(anonymous function) (http://s_insight2.udesk.cn/site/assets/vendor.js:27378:7)
        at handleDeprecationWorkflow (http://s_insight2.udesk.cn/site/assets/vendor.js:80665:9)
        at HANDLERS.(anonymous function) (http://s_insight2.udesk.cn/site/assets/vendor.js:27378:7)
        at deprecationCollector (http://s_insight2.udesk.cn/site/assets/vendor.js:80690:5)
        at HANDLERS.(anonymous function) (http://s_insight2.udesk.cn/site/assets/vendor.js:27378:7)
        at invoke (http://s_insight2.udesk.cn/site/assets/vendor.js:27394:7)

Close button does not close

ignoredVersions is an array

pushing an ignored version to it does not trigger a recalculation of the message.

i suggest to change it to

@tracked ignoredVersions = [];

and use

  ignoreVersion(version) {
    this.ignoredVersions = [...this.ignoredVersions, version];
  }

to add a version to be ignored.

Perform is not a function

Hi, I'm getting on error

services/new-version.js

Uncaught (in promise) TypeError: this.updateVersion.perform is not a function
Property 'perform' does not exist on type '() => Generator<any, void, unknown>'.ts

Have you considered moving fetch and logic to a service?

I like this addon and consider using it in my app, however I'd like to automatically refresh the app in some conditions, so that the user does not have to think about refreshing the app.

For this purpose, having the fetch of version.txt and the logic in a service would make sense, and let the component just show when the service detects a new version.

I saw there were some short discussions about this in #18 and it has been set aside at that time.

Do you believe it would make sense to move the code in a service now? I may do the work if you believe it is. I saw you started a migration to Octane, I guess I'd start from this PR in that case.

calling set on destroyed object

I am on 1.6.0, but it appears that this is still an issue on master due to sets being done inside then instead of using yield and letting ember-concurrency cancel it on destroy. While this error seems to also be swallowed by ember-cli-new-version, it appears to be throwing the following error:

"calling set on destroyed object: <app-ember@component:new-version-notifier::ember608>.version = v2.19.1-1-g8c28df4d"

I only noticed this error due to a breakpoint in ember where exceptions are logged. I believe this error would disappear by using ember-concurreny to handle all async operations (since it cancels the operations when an object is destroyed), for example:

      const response = yield fetch(url + '?_=' + Date.now());
      if(!response.ok) { throw new Error(response.statusText); }

      const res = yield response.text();
      const currentVersion = this.get('version');
      const newVersion = res && res.trim();

      if (this.updateNeeded(currentVersion, newVersion)) {
        const message = this.get('updateMessage')
          .replace('{oldVersion}', currentVersion)
          .replace('{newVersion}', newVersion);

        this.setProperties({
          message,
          lastVersion: currentVersion
        });
        this.onNewVersion(newVersion, currentVersion);
      }

      this.set('version', newVersion);

The current source code can be seen at https://github.com/sethwebster/ember-cli-new-version/blob/master/addon/components/new-version-notifier/component.js#L83. If this update is acceptable, I'll happily open a PR.

Thanks for the awesome addon!

Default updateMessage is showing extra `{}` characters

Hi,

In 2.0.0 there was a change to use {newVersion} instead of {{newVersion}} in templates, but the following line was never changed, so the default is now displaying those extra { and } characters, see:

updateMessage : "This application has been updated from version {{oldVersion}} to {{newVersion}}. Please save any work, then refresh browser to see changes.",

For apps that use the default, this changes the message in the browser to:

This application has been updated from version {v2.58.0} to {v2.58.0-test}. Please save any work, then refresh browser to see changes.

I'll fix this in my application by passing a custom message, but wanted to report it anyway.

Thanks!

Sometimes the yield block is written before the HTML tag

I'm seeing a case where the stuff in the template block isn't writing correctly to the document.

{{#new-version-notifier as |newVersion oldVersion reload close|}}
    <div class="update-notification">
        <span class='bold'>New features and fixes</span> are only a browser reload away!  <small class="light mr-3">({{oldVersion}} {{fa-icon "arrow-right"}} {{newVersion}})</small> 
        <a href="javascript:void(0)" class="btn btn-success"  onclick={{action reload}}>Give me the good stuff now!</a>
        <a href="javascript:void(0)" class="btn btn-outline-dark" onclick={{action close}}>Ignore for now</a>
    </div>
{{/new-version-notifier}}

What I see happen is the "Give me the new stuff" is writing before the "DOCTYPE HTML" tag and then the hrefs happen after the HTML tag.

It's not consistently broken, but seems to happen after I step away from the keyboard for a while. I have it defined in my application.hbs at the top level, but there may be some user session stuff going on and I need to move it elsewhere or only show it when the user is logged in.

How am I supposed to write acceptance tests for apps that use this addon?

When I try to run my acceptance tests using the latest version (1.1.5) then they timeout on visit calls as the test waits for all promises to resolve.

Is there a way to disable version polling during testing? (I don't really care about testing that part of my app)

What do other people do that use this addon? are there any examples of acceptance tests from "real" apps that use this addon?

Issues with ember-cli-deploy

It seems like this did not work for a much longer time, but I never noticed it because on previous ember-cli-new-version versions a version.txt containing an invalid version number, would not trigger a notification. (at least that was what I observed when deploying an older version which depends on ember-cli-new-version:2.0.2)

I have configured ember-cli-deploy to host my ember app on an s3 bucket, which uses a prefix:

ENV.s3.prefix = 'app';

However, ember-cli-new-version tries to look it up under the root domain.com/version.txt. I tried to look into it a bit, but I know very little about the ember-cli-deploy internals, and it seems that the cli-deploy config is not available at runtime. I am not even sure if we can get the information added in deploy.js from within a regular addon. Long story short, I don't know if ember-cli-deploy support is even possible without making it a ember-cli-deploy-plugin.

I tried to add ENV.prepend = "/app/"; to my deploy.js but when debugging into the ember-cli-new-version service, it was undefined

However, it probably would be possible to add a prepend config to the ember-cli-new-version config, which allows to specify a prefix, that does not influence the brocolli-asset-rev behaviour.

What are your thoughts on this issue?

How to test in development? (ember serve)

Hi, really not sure what I'm doing wrong here, but how do I run ember serve and test this out?
I see the VERSION.txt copied to /dist.
I edit dist/VERSION.txt but every time it gets requested, the change isn't picked up.

Thanks!

missing ember-concurrency when using version 1.1.4

After upgrading from version 1.1.1 to version 1.1.4, we are getting the following message when browsing to the site:

Could not find module ember-concurrency imported from ember-cli-new-version/components/new-version-notifier/component

It seems that ember-concurrency have not been added as a dependency, even though it is used after development.

Auto-generate VERSION file

Any interest in this addon having an option to automatically generating the VERSION.txt file during the build process? I have something similar in an app that uses the treeForPublic addon hook to create a version file in the public/ directory.

Default interval too short

5 seconds seems like a bit much.
I'd default to something like every 5 minutes (300000), since deploys don't
happen that often, and doing an ajax request that often will just eat the user's bandwidth (small, but it adds up).

Error: The ajax operation was aborted

If I leave my app running while the connection is unstable (perhaps on a Mac which is regularly sleeping) I see lots of these errors thrown from failed version checks:

Error: The ajax operation was aborted

These bubble up to my app's error handler and get reported to my bug tracking service. That's not ideal as I'd basically need to create a permanent exception for them so I never get notified about it. And also there's no real way for a user of this addon to decide what to catch vs. bubble up.

Maybe there's a higher level question here: which errors, if any, should be swallowed by this version notifier component, and which should bubble up to the app?

One possible interface to help with this would be an onError() closure input similar to the onNewVersion() that I just added. That might be the most flexible in terms of letting the developer choose what to handle.

Anybody have thoughts or other proposals?

Overriding `this.options.babel` no longer supported

During Ember builds the following deprecation is shown:

[INFO] DEPRECATION: Ember CLI addons manage their own module transpilation during the `treeForAddon` processing. `ember-cli-new-version` (found at `(...)\node_modules\ember-cli-new-version`) has overridden the `this.options.babel` options which conflicts with the addons ability to transpile its `addon/` files properly. Falling back to default babel configuration options.

Ember CLI: v2.12.1
ember-cli-new-version: v1.0.8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.