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

Initial code commit #1

Merged
2 commits merged into from
Jun 2, 2020
Merged

Initial code commit #1

2 commits merged into from
Jun 2, 2020

Conversation

thgreasi
Copy link
Collaborator

Along with balena-io-modules/fetch-google-apps-script-ponyfill#1 this enables us to use pineclient in Google Apps Script environments (for example use pine inside google sheets to populate fields) 🎉

Change-type: minor
See: https://www.flowdock.com/app/rulemotion/p-billing/threads/cNz2yByrqr3g-5QDsusLJAY-RwZ

@thgreasi thgreasi self-assigned this May 14, 2020
@thgreasi
Copy link
Collaborator Author

@balena-ci retest

src/index.ts Outdated Show resolved Hide resolved
@thgreasi thgreasi force-pushed the initial-pr branch 2 times, most recently from 4f4323e to 5b49474 Compare May 18, 2020 11:49
src/index.ts Outdated
public backendParams: BackendParams,
) {
super(params);
if (!backendParams?.fetch && typeof fetch === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to also add a check for typeof backendParams.fetch === 'function'

src/index.ts Outdated
Comment on lines 49 to 53
typeof body === 'object'
? JSON.stringify(body)
: body == null
? null
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to reorder these because

console.log(typeof null) // 'object'

but in case you're wondering

console.log(typeof undefined) // 'undefined'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch 👍

src/index.ts Outdated
return fetchImplementation(url, {
...options,
body: normalizedBody,
}).then((response) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use async/await for new code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me try whether the transpiled umd build still works on google apps script environment :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like it still works 👍

@@ -9,6 +9,9 @@
"sourceMap": true,
"strictNullChecks": true,
"target": "es5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we target such an old version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The initial reason I made this is to have it running in google sheets where the environment is a bit weird (even though it's V8). For example we can't use const/let there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd appreciate seeing @balena/es-version used but for now this is ok

tsconfig.json Outdated
@@ -9,6 +9,9 @@
"sourceMap": true,
"strictNullChecks": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible it'd be nice to make this

Suggested change
"strictNullChecks": true,
"strict": true,

as it's all new code so we should be able to conform to fully strict ts

tests/chai.ts Outdated
Comment on lines 7 to 8
const { expect } = chai;
export { expect };
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { expect } = chai;
export { expect };
export const { expect } = chai;

src/index.ts Outdated

type PromiseObj = Promise<{}>;

class RequestError extends Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to export this so downstream can do err instanceof RequestError as necessary to check for the specific error class rather than trying to infer it from the properties - especially since I don't think the typing will be exported currently

package.json Outdated
"mocha": "^7.2.0",
"rollup": "^2.10.0",
"ts-node": "^8.10.1",
"typescript": "^3.9.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"typescript": "^3.9.2"
"typescript": "^3.9.3"

package.json Outdated
"lint-fix": "balena-lint --typescript --fix src tests",
"test:node": "mocha -r ts-node/register --reporter spec tests/**/*.spec.ts",
"test:browser": "karma start",
"test": "npm run build && npm run lint && npm run test:node && npm run test:browser",
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to put linting last / as a "posttest" because when developing it's nice to be able to run the tests without worrying about linting for fast iteration

@thgreasi thgreasi requested a review from Page- May 26, 2020 18:28
@thgreasi
Copy link
Collaborator Author

@balena-ci retest

@@ -9,6 +9,9 @@
"sourceMap": true,
"strictNullChecks": true,
"target": "es5",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd appreciate seeing @balena/es-version used but for now this is ok

Change-type: minor
Change-type: patch
@ghost ghost merged commit dd558ec into master Jun 2, 2020
@ghost ghost deleted the initial-pr branch June 2, 2020 12:30
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants