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

Refactor clasp push #514

Merged
merged 7 commits into from
Feb 11, 2019
Merged

Refactor clasp push #514

merged 7 commits into from
Feb 11, 2019

Conversation

campionfellin
Copy link
Collaborator

Pulled clasp push out and refactored its internal functions a bit.

Signed-off-by: campionfellin campionfellin@gmail.com

Works on #501

  • npm run test succeeds.
  • npm run lint succeeds.
  • Appropriate changes to README are included in PR.

Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
@campionfellin
Copy link
Collaborator Author

We also get a lot more granular info on code coverage by separating out each command

screen shot 2019-01-30 at 9 02 37 pm

@grant
Copy link
Contributor

grant commented Jan 31, 2019

Cool!
I'll let @erickoledadevrel review the PR.


Can we figure out how to use absolute import paths rather than relative (tsconfig?)?

} from '/commands/auth'
// Rather than
} from './../auth'

@campionfellin
Copy link
Collaborator Author

I looked into using absolute paths, but it doesn't look feasible at this time.

We could use absolute path mappings:

    "baseUrl": ".",
    "paths": {
      "*": ["*"],
      "src/auth": ["src/auth"],
      "commands/*": ["commands/*"],
    },
  },
  "moduleResolution": "node",

as suggested by TS documentation (see https://www.typescriptlang.org/docs/handbook/module-resolution.html).

However, take a look here at the clone.js compiled code:

var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var auth_1 = require("src/auth");
var urls_1 = require("src/urls");
var utils_1 = require("src/utils");
var files_1 = require("src/files");

This actually now tries to resolve the modules in the node_modules directory.

There's a bunch of discussion here about the issue microsoft/TypeScript#10866

We could use a 3rd party library, but I'd prefer not to.

@campionfellin
Copy link
Collaborator Author

@erickoledadevrel have you had a chance to give this a look? Thanks!

Copy link
Contributor

@erickoledadevrel erickoledadevrel left a comment

Choose a reason for hiding this comment

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

Sorry for the delay!

@@ -0,0 +1,105 @@
import {
loadAPICredentials,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Should this be collapsed into one line, since there is only one import happening?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It could be. I figured to keep it multi-line to stay with the style of the other imports. I can change to one-line.

@@ -0,0 +1,105 @@
import {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given all the imports added to this new file, are there now any unused imports in commands.ts? I can't tell just by looking at this PR, but feels like there is a good chance that at least a few of these imports aren't needed by the remaining 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.

There are many unused imports in commands.ts (unrelated).

The only one that was moved over from commands.ts to push.ts that is now unused in commands.ts is PROJECT_MANIFEST_FILENAME from utils. I can remove it.

* TODO: Only push the specific files that changed (rather than all files).
* @param cmd.watch {boolean} If true, runs `clasp push` when any local file changes. Exit with ^C.
*/
export default async (cmd: { watch: boolean, force: boolean }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there any changes made to the actual code, or was it just copied and pasted as-is? Hard to tell with the diff view.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, great question.

The constants manifestHasChanges and confirmManifestUpdate were extracted to the bottom of the file and comments were added to them.

My thought is that it improves code readability. Additionally, if we wanted in the future, we could export these and test them individually.

Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Signed-off-by: campionfellin <campionfellin@gmail.com>
Copy link
Contributor

@erickoledadevrel erickoledadevrel left a comment

Choose a reason for hiding this comment

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

Looks good!

@erickoledadevrel erickoledadevrel merged commit b6a57db into google:master Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants