Skip to content

Conversation

@shekharkhedekar
Copy link

@shekharkhedekar shekharkhedekar commented May 1, 2022

Overview

Preparation for Typescript

  • updates "main" target
  • adds "build" and adds "watch" script
  • Adds dependencies for 3rd party types (will be used in a follow up PR)
  • Adds tsconfig

Progress towards closing #136

Checks

npm test
npm link into my app and successfully deployed

@simonh1000 simonh1000 self-requested a review May 1, 2022 16:40
@simonh1000
Copy link
Owner

Nice - you've already addressed a concern that I had about including the build directory.

I want to research how best to publish a typescript based app

  • clearly we need a compiled (and minified?) JS export for JS users
  • at present, when you use the code, you use the source js code. That would be the future way typescript users use the code I think.
  • in the short run I think that means the type script would be exposed for import while the js is exposed for require - perhaps we bump major versions now and switch to ES6 exports for both

I don't know enough about JS testing so what is the reason for changing the test suite?

@shekharkhedekar shekharkhedekar force-pushed the typescript-build-deps branch 2 times, most recently from 7c89d07 to 985afa4 Compare May 2, 2022 16:10
@shekharkhedekar
Copy link
Author

Nice - you've already addressed a concern that I had about including the build directory.

I want to research how best to publish a typescript based app

  • clearly we need a compiled (and minified?) JS export for JS users
  • at present, when you use the code, you use the source js code. That would be the future way typescript users use the code I think.
  • in the short run I think that means the type script would be exposed for import while the js is exposed for require - perhaps we bump major versions now and switch to ES6 exports for both

I don't know enough about JS testing so what is the reason for changing the test suite?

RE: JS/TS - the JS projects will import build/ftp-deploy.js - the TS projects will do the same but import from ftp-deploy.d.ts for typings.

RE: Test frameworks, Jest has some easy TS integrations, and a nice coverage option.

@shekharkhedekar
Copy link
Author

@simonh1000 lmk if you have any other feedback - I've got a few more PRs to get this TS conversion over the line.

@simonh1000
Copy link
Owner

I'll try to take a look at the weekend

return statP(remoteDir + "/test-inside-root.txt");
})
.catch((err) => done(err));
.catch((err) => Promise.reject(err));
Copy link
Owner

Choose a reason for hiding this comment

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

we do not need this line at all then?

Copy link
Author

Choose a reason for hiding this comment

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

removed

@simonh1000
Copy link
Owner

I tried to run the tests and got

Error: Jest: Failed to parse the TypeScript config file /Users/simonhampton/code/projects/ftp-deploy/jest.config.ts
Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed
Error: Cannot find module 'ts-node'

test/server.js Outdated
const port = 2121;
const homeDir =
require("os").homedir() + "/code/projects/ftp-deploy/test/remote";
const homeDir = path.join(__dirname, "../test/remote");
Copy link
Owner

Choose a reason for hiding this comment

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

I made this change so that people on windows could run the tests - is there a reason for deleting it?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, my code is in ~/src. What if we used require("os").tmpdir() instead?

Copy link
Author

Choose a reason for hiding this comment

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

Actually, if I'm not mistaken, making this consistent with this should work the same on windows/mac node?

Copy link
Owner

Choose a reason for hiding this comment

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

Can we revert this change please. I explained why before

Copy link
Author

Choose a reason for hiding this comment

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

Yes, reverted.

@simonh1000
Copy link
Owner

to be honest it feels strange to add all this typescript config stuff without there being any typescript code yet. If I merged and someone was to look at the repo then, they would wonder what on earth is happening. Can we add the TS config with at least some TS code?

@shekharkhedekar
Copy link
Author

I tried to run the tests and got

Error: Jest: Failed to parse the TypeScript config file /Users/simonhampton/code/projects/ftp-deploy/jest.config.ts
Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed
Error: Cannot find module 'ts-node'

I was able to run the tests after pulling, and rm -rf node_modules/ && rm package-lock.json && npm i

@shekharkhedekar
Copy link
Author

to be honest it feels strange to add all this typescript config stuff without there being any typescript code yet. If I merged and someone was to look at the repo then, they would wonder what on earth is happening. Can we add the TS config with at least some TS code?

Agreed. What if we used this as a base branch to merge all the subsequent TS PRs into?

@shekharkhedekar shekharkhedekar force-pushed the typescript-build-deps branch from bb5d9f1 to c170e24 Compare May 8, 2022 21:14
@simonh1000
Copy link
Owner

I was able to run the tests after pulling, and rm -rf node_modules/ && rm package-lock.json && npm i

I tried again with the same issue. I think you have a global install (of ts-node?) that i do not have

@shekharkhedekar
Copy link
Author

shekharkhedekar commented May 9, 2022

I was able to run the tests after pulling, and rm -rf node_modules/ && rm package-lock.json && npm i

I tried again with the same issue. I think you have a global install (of ts-node?) that i do not have

I was able to repro the error with this (after removing the global install of ts-node:

rm -rf node_modules && rm package-lock.json && npm i && npm test

and verify that it was fixed with this

npm i -D ts-node && npm test

@shekharkhedekar
Copy link
Author

@simonh1000 let me know if you have any updates

.then(() => {
// Should reject if file does not exist
return statP(remoteDir + "/test-inside-root.txt");
})
Copy link
Owner

Choose a reason for hiding this comment

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

what is the intention here?

Copy link
Author

Choose a reason for hiding this comment

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

removed this, it was an unnecessary change

test/server.js Outdated
const port = 2121;
const homeDir =
require("os").homedir() + "/code/projects/ftp-deploy/test/remote";
const homeDir = path.join(__dirname, "../test/remote");
Copy link
Author

Choose a reason for hiding this comment

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

Yes, my code is in ~/src. What if we used require("os").tmpdir() instead?

test/server.js Outdated
const port = 2121;
const homeDir =
require("os").homedir() + "/code/projects/ftp-deploy/test/remote";
const homeDir = path.join(__dirname, "../test/remote");
Copy link
Author

Choose a reason for hiding this comment

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

Actually, if I'm not mistaken, making this consistent with this should work the same on windows/mac node?

return statP(remoteDir + "/test-inside-root.txt");
})
.catch((err) => done(err));
.catch((err) => Promise.reject(err));
Copy link
Author

Choose a reason for hiding this comment

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

removed

test/server.js Outdated
const port = 2121;
const homeDir =
require("os").homedir() + "/code/projects/ftp-deploy/test/remote";
const homeDir = path.join(__dirname, "../test/remote");
Copy link
Author

Choose a reason for hiding this comment

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

Yes, reverted.

.then(() => {
// Should reject if file does not exist
return statP(remoteDir + "/test-inside-root.txt");
})
Copy link
Author

Choose a reason for hiding this comment

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

removed this, it was an unnecessary change

@shekharkhedekar
Copy link
Author

@simonh1000 sorry for the delays on this - lmk if you have more feedback

@simonh1000
Copy link
Owner

Thanks - I will take a look soon but things are a bit busy at the weekend, which is the only time I have available for open source. Thansk for your patience

@DEPSTRCZ
Copy link

Thanks - I will take a look soon but things are a bit busy at the weekend, which is the only time I have available for open source. Thansk for your patience

Any updates on this?

Copy link
Owner

Choose a reason for hiding this comment

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

please don't remove this file

const path = require("path");
var assert = require("assert");

const expect = require("chai").expect;
Copy link
Owner

Choose a reason for hiding this comment

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

please do not change test framework without further justification

@@ -0,0 +1,9 @@
import type { Config } from "@jest/types";
Copy link
Owner

Choose a reason for hiding this comment

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

please dont change test framework in a PR about typescript

Copy link
Owner

@simonh1000 simonh1000 left a comment

Choose a reason for hiding this comment

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

See comments below - let's stay focused on the TS part

@shekharkhedekar
Copy link
Author

closing in favor of #170

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.

3 participants