Skip to content

Commit

Permalink
fix(studio): fix libraries (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Mar 3, 2022
1 parent 43f2b71 commit c13b5c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/studio-be/src/studio/libraries/libraries-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ export class LibrariesRouter extends CustomStudioRouter {
})
)

router.get(
'/search/:name',
router.post(
'/search',
this.asyncMiddleware(async (req: any, res: any) => {
const { data } = await axios.get(`https://www.npmjs.com/search/suggestions?q=${req.params.name}`)
const { data } = await axios.get(`https://www.npmjs.com/search/suggestions?q=${req.body.name}`)
res.send(data)
})
)

router.get(
'/details/:name',
router.post(
'/details',
this.asyncMiddleware(async (req: any, res: any) => {
const { data } = await axios.get(`https://registry.npmjs.org/${req.params.name}`, {
const { data } = await axios.get(`https://registry.npmjs.org/${req.body.name}`, {
headers: {
accept: 'application/vnd.npm.install-v1+json'
}
Expand Down
5 changes: 4 additions & 1 deletion packages/studio-be/src/studio/libraries/libraries-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class LibrariesService {
return
}

const archivePath = await createArchive(`${nodeModules}.tgz`, nodeModules, glob.sync('**/*', { cwd: nodeModules }))
// @ is a special character in tar and must be prepended
const files = glob.sync('**/*', { cwd: nodeModules }).map((name) => (name.startsWith('@') ? `./${name}` : name))

const archivePath = await createArchive(`${nodeModules}.tgz`, nodeModules, files)

if (process.BPFS_STORAGE === 'disk') {
return
Expand Down
2 changes: 1 addition & 1 deletion packages/studio-ui/src/web/views/Libraries/AddLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const AddLibrary = (props) => {
const searchChanged = async (query, event) => {
if (event) {
try {
const { data } = await axios.get(`${window.STUDIO_API_PATH}/libraries/search/${query}`)
const { data } = await axios.post(`${window.STUDIO_API_PATH}/libraries/search`, { name: query })

setItems(data)
setRepoName('')
Expand Down

0 comments on commit c13b5c4

Please sign in to comment.