chrisdmacrae / atomic-algolia

An NPM package for running atomic updates to an Algolia indices
67 stars 13 forks source link

Undefined Hits issue resolved #32

Closed varun-raj closed 4 years ago

varun-raj commented 4 years ago

Signed-off-by: Varun Raj varun@skcript.com

DirtyF commented 4 years ago

Fix #31

nhoizey commented 4 years ago

I also had the hits issue, so I tried to use this PR with npm i --save-dev chrisdmacrae/atomic-algolia#pull/32/head

But it gave me this error:

> atomic-algolia@0.3.18 prepack /Users/nhoizey/.npm/_cacache/tmp/git-clone-4b059f5c
> npm run build

> atomic-algolia@0.3.18 build /Users/nhoizey/.npm/_cacache/tmp/git-clone-4b059f5c
> npm run babel

> atomic-algolia@0.3.18 babel /Users/nhoizey/.npm/_cacache/tmp/git-clone-4b059f5c
> npx babel src -d lib

npx : 1 installé(s) en 2.75s
You have mistakenly installed the `babel` package, which is a no-op in Babel 6.
Babel's CLI commands have been moved from the `babel` package to the `babel-cli` package.

    npm uninstall -g babel
    npm install --save-dev babel-cli

See http://babeljs.io/docs/usage/cli/ for setup instructions.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! atomic-algolia@0.3.18 babel: `npx babel src -d lib`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the atomic-algolia@0.3.18 babel script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nhoizey/.npm/_logs/2020-07-29T17_34_48_046Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! atomic-algolia@0.3.18 build: `npm run babel`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the atomic-algolia@0.3.18 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

I don't know why it needs babel-cli

wataash commented 4 years ago

It works, thanks!

Just directly editing getRemoteIndex.js worked.

$ ALGOLIA_APP_ID=... atomic-algolia
(node:8122) UnhandledPromiseRejectionWarning: ReferenceError: hits is not defined
    at /home/wsh/.npm-global/lib/node_modules/atomic-algolia/lib/utils/getRemoteIndex.js:50:10
...

$ vim /home/wsh/.npm-global/lib/node_modules/atomic-algolia/lib/utils/getRemoteIndex.js
(apply this patch)

$ ALGOLIA_APP_ID=... atomic-algolia
[Algolia] Adding 11 hits to prod_blog
...
bwklein commented 4 years ago

I can confirm that editing the getRemoteIndex.js file fixed the problem. Can this be released soon, as I would like to pull this into a CI/CD system and can't edit the file for every build?

nhoizey commented 4 years ago

🎉

Thanks @chrisdmacrae ! 👍