slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno
https://api.slack.com/automation
MIT License
158 stars 27 forks source link

Fix circular import in builtin generation script #211

Closed WilliamBergamin closed 1 year ago

WilliamBergamin commented 1 year ago

Summary

In the builtin generation script there seems to be a circular import where src/schema/slack/functions/_scripts/src/write_function_files.ts indirectly imports src/schema/slack/functions/mod.ts. The issue steams from src/schema/slack/functions/_scripts/generate since it is cleaning all the files from src/schema/slack/functions before executing src/schema/slack/functions/_scripts/src/write_function_files.ts which lead to the following error.

error: Module not found "file:///~/deno-slack-sdk/src/schema/slack/functions/mod.ts".
    at file:///~/deno-slack-sdk/src/schema/slack/mod.ts:2:28

This PR introduces a change to _scripts/generate that temporarily creates a dummy functions/mod.ts file before executing _scripts/src/write_function_files.ts

testing

  1. Ensure you are using Deno 1.36.0 or higher (deno -V)
  2. Pull the test-builtin-generation branch
  3. Follow the instructions in src/schema/slack/functions/_scripts/README.md to generate the latest builtin
  4. The generation should work properly

Special notes

I also updated the comment generation function to point users to the correct README.md file path

Requirements

codecov[bot] commented 1 year ago

Codecov Report

Merging #211 (4ad391f) into main (384252c) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #211   +/-   ##
=======================================
  Coverage   99.24%   99.24%           
=======================================
  Files          56       56           
  Lines        2125     2128    +3     
  Branches      136      136           
=======================================
+ Hits         2109     2112    +3     
  Misses         15       15           
  Partials        1        1           
Files Changed Coverage Δ
...functions/_scripts/src/templates/template_utils.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/add_pin.ts 100.00% <100.00%> (ø)
...rc/schema/slack/functions/add_user_to_usergroup.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/archive_channel.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/create_channel.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/create_usergroup.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/delay.ts 100.00% <100.00%> (ø)
...c/schema/slack/functions/invite_user_to_channel.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/mod.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/open_form.ts 100.00% <100.00%> (ø)
... and 6 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

:loudspeaker: Have feedback on the report? Share it here.