Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

feat(version): add dynamic versioning #8

Merged
merged 4 commits into from
Feb 1, 2018
Merged

Conversation

francoischalifour
Copy link
Member

This feature is needed for a guide I'm working on 😁

  • Fetch instantsearch.js version based on the npm-search Algolia index
  • Add prompt choice to use the instantsearch.js version (defaults to the latest one), rejects if the version doesn't exist
  • If offline, default the instantsearch.js@2 (jsDelivr resolves it to the actual latest version, 2.4.1 as of now)
  • Inject the version in the HTML template

Let me know if there are other ways to solve it!

Note: Node >= 7.6 is necessary because I've used async functions.

@bobylito
Copy link
Contributor

This is excellent @francoischalifour. I'd choose the version automatically for the user and later I'd add a new command line option to force a specific version. If I'm a newcomer to IS I won't know about versions that I should get.

@francoischalifour
Copy link
Member Author

Makes sense.

So no option for the user yet, we only inject the latest version in the template?

@francoischalifour
Copy link
Member Author

Ready for review @bobylito.

let libVersion;

try {
const results = await index.search('instantsearch.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.getObject('instantsearch.js')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#mindblown package name are objectID's?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

config/index.js Outdated
@@ -0,0 +1,7 @@
module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this file to something more specific like yarn_search-credential.js or something in this spirit that actually describes the kind of config you're doing here. Also we might not need a config file for that. It's an implementation detail of the version fetcher IMHO.

Copy link
Contributor

@bobylito bobylito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool feature 👍 Thanks a lot @francoischalifour

@bobylito bobylito merged commit decf54c into master Feb 1, 2018
@bobylito bobylito deleted the feat/dynamic-versioning branch February 1, 2018 13:55
aymeric-giraudet pushed a commit to algolia/instantsearch that referenced this pull request Dec 14, 2022
…pp#8)

* feat(version): add dynamic versioning
* feat(version): fetch latest version all the time
* chore: inline Algolia config
* chore: use `getObject()` to get the index

fix algolia/create-instantsearch-app#1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants