Skip to content

Commit 5e0882f

Browse files
Adebesin-Cellclaude
andcommitted
fix: remove download dependencies script option from download button
Keep only the package tarball download option and remove the Node.js script generation for downloading dependencies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c76c15c commit 5e0882f

File tree

4 files changed

+4
-108
lines changed

4 files changed

+4
-108
lines changed

app/components/Package/DownloadButton.vue

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<script setup lang="ts">
2-
import type { SlimPackumentVersion, DependencySize } from '#shared/types'
2+
import type { SlimPackumentVersion } from '#shared/types'
33
import { onClickOutside, useEventListener, useMediaQuery } from '@vueuse/core'
44
55
const props = withDefaults(
66
defineProps<{
77
packageName: string
88
version: SlimPackumentVersion
9-
dependencies: DependencySize[] | null
10-
dependenciesLoading?: boolean
119
size?: 'small' | 'medium'
1210
}>(),
1311
{
14-
dependenciesLoading: false,
1512
size: 'medium',
1613
},
1714
)
@@ -27,19 +24,6 @@ const menuItems = computed(() => {
2724
const items: { id: string; icon: string; disabled: boolean }[] = [
2825
{ id: 'package', icon: 'i-lucide:package', disabled: false },
2926
]
30-
if (props.dependenciesLoading) {
31-
items.push({
32-
id: 'dependencies',
33-
icon: 'i-lucide:loader-circle',
34-
disabled: true,
35-
})
36-
} else if (props.dependencies?.length) {
37-
items.push({
38-
id: 'dependencies',
39-
icon: 'i-lucide:list-tree',
40-
disabled: false,
41-
})
42-
}
4327
return items
4428
})
4529
@@ -115,8 +99,6 @@ function handleAction(item: (typeof menuItems.value)[number] | undefined) {
11599
if (!item || item.disabled) return
116100
if (item.id === 'package') {
117101
downloadPackage()
118-
} else if (item.id === 'dependencies') {
119-
downloadDependenciesScript()
120102
}
121103
close()
122104
}
@@ -150,79 +132,6 @@ async function downloadPackage() {
150132
}
151133
}
152134
153-
function downloadDependenciesScript() {
154-
if (!props.dependencies?.length) return
155-
156-
const tarballs: { name: string; version: string; url: string }[] = []
157-
158-
const rootTarball = props.version.dist.tarball
159-
if (rootTarball) {
160-
tarballs.push({ name: props.packageName, version: props.version.version, url: rootTarball })
161-
}
162-
163-
props.dependencies.forEach(dep => {
164-
if (!dep.tarballUrl) return
165-
tarballs.push({ name: dep.name, version: dep.version, url: dep.tarballUrl })
166-
})
167-
168-
const sanitize = (name: string) => name.replace(/\//g, '__')
169-
170-
// Node.js script — works on all platforms
171-
const lines = [
172-
'#!/usr/bin/env node',
173-
`// Download dependencies for ${props.packageName}@${props.version.version}`,
174-
'// Run: node <filename>',
175-
'',
176-
"const { mkdirSync, createWriteStream } = require('fs');",
177-
"const https = require('https');",
178-
"const http = require('http');",
179-
"const { basename } = require('path');",
180-
'',
181-
"const dir = 'tarballs';",
182-
'mkdirSync(dir, { recursive: true });',
183-
'',
184-
'const tarballs = [',
185-
...tarballs.map(t => ` { name: '${t.name}', version: '${t.version}', url: '${t.url}' },`),
186-
'];',
187-
'',
188-
'function download(url, dest) {',
189-
' return new Promise((resolve, reject) => {',
190-
" const client = url.startsWith('https') ? https : http;",
191-
' client.get(url, (res) => {',
192-
' if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {',
193-
' return download(res.headers.location, dest).then(resolve, reject);',
194-
' }',
195-
' if (res.statusCode !== 200) {',
196-
' return reject(new Error(`HTTP ${res.statusCode} for ${url}`));',
197-
' }',
198-
' const file = createWriteStream(dest);',
199-
" res.pipe(file).on('finish', () => file.close(resolve));",
200-
' }).on("error", reject);',
201-
' });',
202-
'}',
203-
'',
204-
'(async () => {',
205-
' for (const t of tarballs) {',
206-
" const filename = `${t.name.replace(/\\//g, '__')}-${t.version}.tgz`;",
207-
' const dest = `${dir}/${filename}`;',
208-
' console.log(`Downloading ${t.name}@${t.version}...`);',
209-
' await download(t.url, dest);',
210-
' }',
211-
' console.log(`Done! ${tarballs.length} tarball(s) saved to ${dir}/`);',
212-
'})();',
213-
]
214-
215-
const blob = new Blob([lines.join('\n')], { type: 'application/javascript' })
216-
const url = URL.createObjectURL(blob)
217-
const link = document.createElement('a')
218-
link.href = url
219-
link.download = `download-${sanitize(props.packageName)}-deps.js`
220-
document.body.appendChild(link)
221-
link.click()
222-
document.body.removeChild(link)
223-
URL.revokeObjectURL(url)
224-
}
225-
226135
useEventListener('scroll', () => isOpen.value && close(), { passive: true })
227136
228137
defineOptions({
@@ -292,18 +201,11 @@ defineOptions({
292201
@mouseenter="highlightedIndex = index"
293202
>
294203
<span
295-
:class="[
296-
item.icon,
297-
{ 'animate-spin': item.id === 'dependencies' && dependenciesLoading },
298-
]"
204+
:class="item.icon"
299205
class="w-4 h-4"
300206
aria-hidden="true"
301207
/>
302-
{{
303-
item.id === 'package'
304-
? $t('package.download.package')
305-
: $t('package.download.dependencies')
306-
}}
208+
{{ $t('package.download.package') }}
307209
</li>
308210
</ul>
309211
</Transition>

app/pages/package/[[org]]/[name].vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,6 @@ const showSkeleton = shallowRef(false)
777777
v-if="displayVersion"
778778
:package-name="pkg.name"
779779
:version="displayVersion"
780-
:dependencies="installSize?.dependencies ?? null"
781-
:dependencies-loading="installSizeStatus === 'pending'"
782780
size="small"
783781
/>
784782
<PackageManagerSelect />

i18n/locales/en.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,7 @@
608608
},
609609
"download": {
610610
"button": "Download",
611-
"package": "Download Package (.tgz)",
612-
"dependencies": "Download Dependencies (.js)"
611+
"package": "Download Package (.tgz)"
613612
}
614613
},
615614
"connector": {

i18n/schema.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,9 +1830,6 @@
18301830
},
18311831
"package": {
18321832
"type": "string"
1833-
},
1834-
"dependencies": {
1835-
"type": "string"
18361833
}
18371834
},
18381835
"additionalProperties": false

0 commit comments

Comments
 (0)