-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/hackathon may 18 migrate to es6 and make npm #1
base: develop
Are you sure you want to change the base?
Feature/hackathon may 18 migrate to es6 and make npm #1
Conversation
- Convert ES5 constructor funtion to ES6 Classes - Added JsDoc - Added JsDoc rules to eslint - Retrieve BUILD_NUMBER from package.json ( one source of truth) ( bundle tested successfully with QBO v3 on simulator )
…g package.json as source of truth - Remove DefinePligin from webpack.config, we need the build number to be available when building from connectors - Importing i18n json instead of using json-loader ( avoiding conflicts when consumed as npm package from other building strategies ) - Smoke test pass as local npm package with QBO v3 and simulator
- improve messageHandlers.wdcHandler verification, and log a message if absent - Avoid double casting in condition
- disable no-unused-vars eslint rule on 2 lines for legacy documentation purpose
…ore build and converting to es5 before uglification - convert webpack-production script to ES6 - increments minor version (temporarily, will ask for that later)
- update package.json to run make_version script with babel cli, maintaining the ´previous ux - fix missing separator on VersionNumber.toString method body
- include babel-polyfill ( let's discuss about file size, IMHO the min version has a decent size and by including it we won't care anymore about accidental introduction of unsupported features on IE and Edge ... until we deprecate support for them ) - add information "engines" property to package json
…oid polluting the test output - add NativeDispatcher unit tests
"parser": "babel-eslint", | ||
"extends": ["eslint:recommended", "standard"], | ||
"rules": { | ||
"no-console": 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately we have to leave the no-console rule set off globally because it's part of the application flow.
I'd like to improve this later.
Later I'll go through all the jsdocs and validate the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great!
I wrote some comments to discuss further.
* @returns {*} | ||
*/ | ||
function _getApprovedOriginsValue () { | ||
let result = CookiesLib.get(APPROVED_ORIGINS_KEY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to have an assignation here? If CookiesLib.get
returns a primitive type, we could avoid a copy just returning: return CookiesLib.get(APPROVED_ORIGINS_KEY);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good point. The 2 reasons are:
- I tried to keep things as less modified as possible
- Probably the original code's intent was to have a potential breakpoint for debugging
ApprovedOrigins.js
Outdated
return []; | ||
} | ||
/** | ||
* Adds an approved origins to the list already saved in a session cookie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think origins should be singular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
// pass along the output of the private function | ||
return _saveApprovedOrigins(origins); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to return something to comply with the JSDoc (or change the JSDoc which I know is a pending task)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I'll change it to {Object|Undefined}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
let originsString = _getApprovedOriginsValue(); | ||
|
||
if (!originsString || originsString.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like originsString.length === 0
is redundant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, same thing here, just trying to keep as much as possible untouched
DevUtils/BuildNumber.js
Outdated
compare (other) { | ||
let majorDiff = this.major - other.major; | ||
let minorDiff = this.minor - other.minor; | ||
let fixDiff = this.patch - other.fix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a copy paste error here? patch
vs fix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, patch is the correct definition for the third number on the semver definition, I left the fix word for the input to ask Ben about that, I'd go for both to be patch for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
DevUtils/BuildNumber.js
Outdated
*/ | ||
export function getBuildNumber ({ showLog = false } = {}) { | ||
// Grab the version number from the package json property ( one static source of truth ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it miss some code here? It is not clear how the version number is retrieved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, it's explaining the BUILD_NUMBER
constant origin, but it's not clear, I'll improve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Shared.js
Outdated
_triggerDataGathering (tablesAndIncrementValues) { | ||
|
||
if (tablesAndIncrementValues.length !== 1) { | ||
throw new Error(`Unexpected number of tables specified. Expected 1, actual ${tablesAndIncrementValues.length.toString()}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ${tablesAndIncrementValues.length.toString()}
, the .toString()
is not necessary anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Shared.js
Outdated
throw new Error(`Unexpected number of tables specified. Expected 1, actual ${tablesAndIncrementValues.length.toString()}`); | ||
} | ||
|
||
let tableAndIncremntValue = tablesAndIncrementValues[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a small typo in the variable name: tableAndIncremntValue
(misses an e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, the code is very clear.
I added some comments about minor things like typos in comments and alike.
Utilities.js
Outdated
if (typeof src[key] === 'function') { | ||
dest[key] = src[key]; | ||
/** | ||
* WARNIG - copies are BY REFERENCE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Table.js
Outdated
// note: add boolean return for testing purpose | ||
|
||
// Do some quick validation that this data is the format we expect | ||
// is this validation enought? shouldn't we throw an error? (Jax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo in this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh enought
-> enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Table.js
Outdated
|
||
if (!Array.isArray(data)) { | ||
// Log a warning because the data is not an array like we expected | ||
// is this validation enought? shouldn't we throw an error? (Jax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied typo here
Utilities.test.js
Outdated
|
||
describe('UNIT - Utilities', () => { | ||
|
||
it('copyFunctions to copy funtions from source to target', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo in funtions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
let execSync = require('child_process').execSync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't it possible to import
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even try, will do
let versionNumber = new VersionNumber(getBuildNumber()); | ||
|
||
// Build up the name for the regular and minified versions of the file | ||
let fullVersionName = `${WDC_LIB_PREFIX}${versionNumber.toString()}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think toString()
wouldn't be necessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is necessary because it's calling the toString()
met6hod of the class explicitly .... you never know :P
import SimulatorDispatcher from './SimulatorDispatcher'; | ||
import { getBuildNumber } from './DevUtils/BuildNumber'; | ||
|
||
let qwebchannel = require('qwebchannel'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't it go an import
here?
if (runningOnTableau()) { | ||
// Running on Tableau | ||
// We have the tableau object defined | ||
console.log(`Initializing NativeDispatcher, Reporting version number`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, I've seen it's better to not use String templates when not needed, but I think it's a matter of tastes though.
@@ -0,0 +1,12 @@ | |||
import webpack from 'webpack'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure we can do tree shaking here.
- add @see links to online documentation for SImulator and Native dispatchers - add some tweaks to linting rules
@benlower and @LGraber : This pull request is merely informative, any feedback is hugely welcome. The merging target is sill OUR FORK, we need to talk and discuss before considering it for targeting the official repo.
Notes:
Since we don’t have Samm and Brendan maintaining the shim, and is a critical piece of code for our wdc’s I took the initiative to fork it and make this changes as a POC to match our development standards, this way might gain more collaborators.
I'd be great to define more specific tests:
Tested this with local Anaplan connector as a standalone lib and with local QBO as part of the connector’s build, both in the simulator and Tableau desktop 10.5