<p dir="auto">(Migrated from gitter)<br>
We could potentially introduce some basic cache cleaning commands for Deno.<br>
Currently 2 super-duper simple and crude ideas:</p>
<ol dir="auto">
<li>Clean by domain, something like <code class="notranslate">deno clean https://github.com</code> deletes all cached files under that domain (this one is somewhat easy to implement)
<ul dir="auto">
<li>This could be slightly more granular:<code class="notranslate"> deno clean -d https://unpkg.com/lodash-es@4.17.11/</code></li>
<li>Rationale: assume related files to be hosted under the same domain/common path segment</li>
</ul>
</li>
<li>Clean by dependency exclusion. Since when we are building dependency tree each time we run a file, we can use such info to dictate deno to clean every file EXCEPT those that serves as dependency of a file. This also potentially allows third-party cli to create "dep lockers" to prevent certain dependency from being cleaned.
<ul dir="auto">
<li>e.g. <code class="notranslate">deno clean -p ./mydeps.ts</code>. If <code class="notranslate">mydeps.ts</code> imports from all <code class="notranslate">https://deno.land/std/</code>, running this command would delete every cached remote files except for deno_std ones</li>
</ul>
</li>
</ol>
<p dir="auto">Remove the cache files corresponding to the given targets.</p>
<ul dir="auto">
<li><code class="notranslate">deno clean src/mod.ts</code> ≈ <code class="notranslate">rm -f $DENO_DIR/gen/file$PWD/src/mod.ts.{js,map,meta}</code></li>
<li><code class="notranslate">deno clean dir1 dir2</code> ≈ <code class="notranslate">rm -rf $DENO_DIR/gen/file$PWD/{dir1,dir2}</code></li>
<li><code class="notranslate">deno clean https://deno.land</code> ≈ <code class="notranslate">rm -rf $DENO_DIR/{deps,gen}/https/deno.land</code></li>
<li><code class="notranslate">deno clean --remote</code> ≈ <code class="notranslate">rm -rf $DENO_DIR/{deps,gen}/!(file)</code></li>
<li><code class="notranslate">deno clean --history</code> ≈ <code class="notranslate">rm -f $DENO_DIR/deno_history.txt</code></li>
<li><code class="notranslate">deno clean --web-storage=&lt;URLs&gt;</code> ≈ <code class="notranslate">rm -rf $DENO_DIR/web_storage/{&lt;URLs&gt;}</code> refs <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="405972082" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/1657" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/1657/hovercard" href="https://github.com/denoland/deno/issues/1657">#1657</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="608987806" data-permission-text="Title is private" data-url="https://github.com/denoland/deno/issues/4981" data-hovercard-type="issue" data-hovercard-url="/denoland/deno/issues/4981/hovercard" href="https://github.com/denoland/deno/issues/4981">#4981</a></li>
<li><code class="notranslate">deno clean --all</code> ≈ <code class="notranslate">rm -rf $DENO_DIR</code></li>
</ul>
<p dir="auto">Due to the current cache structure, cleaning for remote modules can only be done per-domain or coarser.</p>