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

Converts clasp clone to inquirer #132

Merged
merged 2 commits into from Apr 25, 2018
Merged

Converts clasp clone to inquirer #132

merged 2 commits into from Apr 25, 2018

Conversation

campionfellin
Copy link
Collaborator

If user does clasp clone without a scriptId, it will get the 10 most recent scripts and prompt the user to choose one.

Also adds test for this new functionality.

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

Goes towards Clasp 2.0

  • npm run test succeeds.
    brings test coverage > %50
  • Appropriate changes to README are included in PR.

If user does clasp clone without a scriptId, it will
get the 10 most recent scripts and prompt the user
to choose one.

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

coveralls commented Apr 24, 2018

Pull Request Test Coverage Report for Build 96

  • 0 of 0 (NaN%) changed or added relevant lines in 0 files are covered.
  • 289 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.4%) to 10.448%

Files with Coverage Reduction New Missed Lines %
tests/test.js 9 44.16%
index.js 280 7.65%
Totals Coverage Status
Change from base Build 93: -0.4%
Covered Lines: 98
Relevant Lines: 703

💛 - Coveralls

Copy link
Contributor

@grant grant left a comment

Choose a reason for hiding this comment

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

Great! LGTM.

Before we dive deeper into inquirer, let's create some plans:

  • We should abstract out the interface of each method with the implementation
  • We might want to take the opportunity to break apart clasp into multiple files in the next PR.

I know I was resistant to multi-files before, but I think it'd be smart for testing and extensibility.

  • Files
    • src/commands.ts (module.export each command as a function)
    • src/utils.ts (settings, OAuth, dotfiles)
    • index.ts (tie everything together)

Like #106, but be sure to not utils.*, just import { DOTFILE } from 'utils.ts';.

Aside, it would be great if each command had a gif (it's not too hard to record): https://giphy.com/apps/giphycapture

index.ts Outdated
@@ -218,6 +218,14 @@ const createQuestions = [{
default: LOG.UNTITLED_SCRIPT_TITLE,
}];

// Questions (prompts) for clasp clone
const cloneQuestions = [{
Copy link
Contributor

Choose a reason for hiding this comment

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

Inline this const to increase locality and reduce the number of identifiers.

index.ts Outdated
const drive = google.drive({version: 'v3', auth: oauth2Client});
const res = await drive.files.list({
pageSize: 10,
fields: 'nextPageToken, files(id, name)',
Copy link
Contributor

Choose a reason for hiding this comment

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

nextPageToken not used.

index.ts Outdated
if (!scriptId) {
getAPICredentials(async () => {
const drive = google.drive({version: 'v3', auth: oauth2Client});
const res = await drive.files.list({
Copy link
Contributor

Choose a reason for hiding this comment

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

const { data } =

index.ts Outdated
console.log(err);
});
} else {
console.log('No script files found.');
Copy link
Contributor

Choose a reason for hiding this comment

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

No strings in files.
Use LOG.FINDING_SCRIPTS_DNE.

@campionfellin
Copy link
Collaborator Author

campionfellin commented Apr 24, 2018

Sounds good, quite a few steps there so I'm going to break it into a few issues just for better tracking (in no particular order):

  1. Create gifs and add to readme (Modernize README #103)
  2. Move commands to src/commands.ts (Move commands to src/commands.ts #134)
  3. Move utils to src/utils.ts (Move utility functions to src/utils.ts #133)
  4. Investigate vorpal and create plan for how to use it

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

Changes should be addressed now.

@grant grant merged commit 618b4db into google:master Apr 25, 2018
@campionfellin campionfellin deleted the clone-inquirer branch April 25, 2018 05:06
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.

None yet

4 participants