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

feat: Convert gitmoji commands & flags to ts #1277

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

shravan20
Copy link

Description

  • Issue: Phase 1 - Transition commands codebase from js to ts

Tests

  • All tests passed.
Launching Flow server for /Users/shravan20/Projects/gitmoji-cli
Spawned flow server (pid=31079)
Logs will go to /private/tmp/flow/zSUserszSshravan20zSProjectszSgitmoji-cli.log
Monitor logs will go to /private/tmp/flow/zSUserszSshravan20zSProjectszSgitmoji-cli.monitor_log
No errors!
✨  Done in 8.37s.
yarn run v1.22.21
$ FORCE_COLOR=1 jest
(node:31247) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/commands/search.spec.js
(node:31250) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/utils/buildFetchOptions.spec.js
(node:31249) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/commands/update.spec.js
(node:31248) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/utils/getEmojis.spec.js
 PASS  test/utils/isHookCreated.spec.js
 PASS  test/commands/hook.spec.js
 PASS  test/commands/list.spec.js
 PASS  test/utils/getAbsoluteHooksPath.spec.js
 PASS  test/utils/emojisCache.spec.js
 PASS  test/utils/filterGitmojis.spec.js
 PASS  test/utils/getDefaultCommitContent.spec.js
 PASS  test/utils/configurationVault/vault.spec.js
 PASS  test/utils/configurationVault/getConfiguration.spec.js
 PASS  test/utils/printEmojis.spec.js
(node:31246) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/commands/config.spec.js
 PASS  test/utils/configurationVault/defaults.spec.js
(node:31245) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/commands/commands.spec.js
(node:31244) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 PASS  test/commands/commit.spec.js
  ● Console

    console.log
      
      Error: Seems that you're trying to commit with the cli but you have the hook created.
      If you want to use the `gitmoji -c` command you have to remove the hook with the command `gitmoji -r`. 
      The hook must be used only when you want to commit with the instruction `git commit`
      

      at log (src/commands/commit/withClient/index.js:16:22)

-----------------------------|---------|----------|---------|---------|-------------------
File                         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------------|---------|----------|---------|---------|-------------------
All files                    |   91.96 |    86.73 |   90.76 |   92.01 |                   
 commands                    |       0 |        0 |       0 |       0 |                   
  index.js                   |       0 |        0 |       0 |       0 |                   
 commands/commit             |   82.14 |    72.72 |   66.66 |   80.76 |                   
  guard.js                   |     100 |      100 |     100 |     100 |                   
  index.js                   |   94.11 |    83.33 |   85.71 |   93.75 | 24                
  prompts.js                 |      50 |    64.28 |      25 |      50 | 41-65             
 commands/commit/withClient  |     100 |       90 |     100 |     100 |                   
  index.js                   |     100 |       90 |     100 |     100 | 34                
 commands/commit/withHook    |   94.11 |    89.47 |     100 |   93.93 |                   
  index.js                   |   94.11 |    89.47 |     100 |   93.93 | 19-20             
 commands/config             |     100 |      100 |     100 |     100 |                   
  guard.js                   |     100 |      100 |     100 |     100 |                   
  index.js                   |     100 |      100 |     100 |     100 |                   
  prompts.js                 |     100 |      100 |     100 |     100 |                   
 commands/hook               |     100 |      100 |     100 |     100 |                   
  hook.js                    |     100 |      100 |     100 |     100 |                   
  index.js                   |       0 |        0 |       0 |       0 |                   
 commands/hook/create        |   85.71 |      100 |     100 |   85.71 |                   
  index.js                   |   85.71 |      100 |     100 |   85.71 | 17                
 commands/hook/remove        |   85.71 |      100 |     100 |   85.71 |                   
  index.js                   |   85.71 |      100 |     100 |   85.71 | 17                
 commands/list               |     100 |      100 |     100 |     100 |                   
  index.js                   |     100 |      100 |     100 |     100 |                   
 commands/search             |   71.42 |       50 |   66.66 |   71.42 |                   
  index.js                   |   71.42 |       50 |   66.66 |   71.42 | 14,21             
 commands/update             |     100 |      100 |     100 |     100 |                   
  index.js                   |     100 |      100 |     100 |     100 |                   
 constants                   |     100 |      100 |     100 |     100 |                   
  commit.js                  |     100 |      100 |     100 |     100 |                   
  configuration.js           |     100 |      100 |     100 |     100 |                   
 utils                       |   90.47 |    89.65 |    92.3 |   91.52 |                   
  buildFetchOptions.js       |     100 |      100 |     100 |     100 |                   
  emojisCache.js             |     100 |      100 |     100 |     100 |                   
  filterGitmojis.js          |     100 |      100 |     100 |     100 |                   
  getAbsoluteHooksPath.js    |     100 |      100 |     100 |     100 |                   
  getDefaultCommitContent.js |     100 |    91.66 |     100 |     100 | 36                
  getEmojis.js               |   72.22 |    71.42 |      50 |      75 | 29-36             
  isHookCreated.js           |   85.71 |      100 |     100 |   85.71 | 17                
  printEmojis.js             |     100 |      100 |     100 |     100 |                   
 utils/configurationVault    |   97.77 |      100 |     100 |   97.77 |                   
  getConfiguration.js        |      95 |      100 |     100 |      95 | 52                
  index.js                   |     100 |      100 |     100 |     100 |                   
-----------------------------|---------|----------|---------|---------|-------------------

Test Suites: 18 passed, 18 total
Tests:       104 passed, 104 total
Snapshots:   17 passed, 17 total
Time:        6.294 s
Ran all test suites.
✨  Done in 7.26s.

@@ -0,0 +1,86 @@
// @flow
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
// @flow

Copy link
Owner

Choose a reason for hiding this comment

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

Prettier didn't run for this file it is full of ; I believe CI will complain!

Copy link
Author

Choose a reason for hiding this comment

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

Checking formatting...
All matched files use Prettier code style!

Has this been added as rule in prettier config? I don't see any prettierConfig as such.

Copy link
Author

Choose a reason for hiding this comment

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

Add lint-fix command that autofixes any linter/prettier issues.

src/utils/findGitmojiCommand.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.20%. Comparing base (150a350) to head (f9ea3df).
Report is 1 commits behind head on master.

❗ Current head f9ea3df differs from pull request most recent head 1bc9714. Consider uploading reports for the commit 1bc9714 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1277      +/-   ##
==========================================
- Coverage   91.72%   91.20%   -0.53%     
==========================================
  Files          28       26       -2     
  Lines         278      250      -28     
  Branches       66       54      -12     
==========================================
- Hits          255      228      -27     
+ Misses         22       21       -1     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shravan20
Copy link
Author

Requested for rereview

package.json Outdated Show resolved Hide resolved
src/utils/findGitmojiCommand.ts Outdated Show resolved Hide resolved
Comment on lines +4 to +6
type Options = {
[key: string]: object
}
Copy link
Collaborator

@segersniels segersniels Mar 22, 2024

Choose a reason for hiding this comment

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

Don't use object as a type. If you really want to specify a generic object opt for something like this instead:

Suggested change
type Options = {
[key: string]: object
}
type Options = Record<string, any>;

Copy link
Collaborator

@segersniels segersniels Mar 22, 2024

Choose a reason for hiding this comment

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

Actually no, would probably be better if you imported options from cli.ts and specified this as type Options = typeof options.

}

type Cli = {
flags: Record<string, object>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

@@ -1,19 +1,35 @@
// @flow
import COMMIT_MODES from '@constants/commit'
import { CommitModes } from '@constants/commit'
Copy link
Collaborator

Choose a reason for hiding this comment

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

You apparently changed the import but you didn't include the actual enum change

@segersniels
Copy link
Collaborator

Just checking if this is still necessary to keep open or if this can be closed since there hasn't been any recent activity.

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