-
Notifications
You must be signed in to change notification settings - Fork 35
@W-18741334: remove hard coded api names for download #200
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
Changes from all commits
3144d24
8fd1284
ec6ddda
62ebc3d
f2ae3a4
0555bf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ import path from 'path'; | |
| import fs from 'fs-extra'; | ||
| import dotenv from 'dotenv'; | ||
| import {downloadLatestApis} from './utils'; | ||
| import {API_LIST} from './config'; | ||
|
|
||
| dotenv.config(); | ||
|
|
||
|
|
@@ -26,7 +25,9 @@ const PRODUCTION_API_PATH = path.join(__dirname, '../apis'); | |
| fs.moveSync(PRODUCTION_API_PATH, OLD_APIS_PATH, {overwrite: true}); | ||
| fs.ensureDirSync(PRODUCTION_API_PATH); | ||
|
|
||
| API_LIST.forEach(name => { | ||
| // eslint-disable-next-line no-console | ||
| downloadLatestApis(name, PRODUCTION_API_PATH).catch(console.error); | ||
| }); | ||
| // eslint-disable-next-line no-console | ||
|
|
||
| downloadLatestApis( | ||
| 'category:Visibility = "External" category:"SDK Type" = "Commerce" category:"SDK Type" = "Isomorphic"', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why we have SDK type as both wondering if we should remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just Isomorphic is enough. I remember Kay mentioning to use both. This is kind of ensuring we don't download non-commerce specs that are tagged as Isomorphic (as this is a generic term)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dumb question, but how does this query guarantee that we only pull in the oas specs and not the raml specs? |
||
| PRODUCTION_API_PATH | ||
| ).catch(console.error); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,31 +29,24 @@ import {download} from '@commerce-apps/raml-toolkit'; | |
| * We should have some followup to figure out how to cover it. | ||
| * Ive spent hours trying to mock download | ||
| * | ||
| * @param name - Api name to search for | ||
| * @param searchQuery - Query to search exchange | ||
| * @param rootPath - Root path to download to | ||
| * | ||
| * @returns a promise that we will complete | ||
| */ | ||
| export async function downloadLatestApis( | ||
| name: string, | ||
| rootPath: string, | ||
| isOAS = true | ||
| searchQuery: string, | ||
| rootPath: string | ||
| ): Promise<void> { | ||
| const matchedApis = await download.search(`"${name}"`); | ||
| const matchedApis = await download.search(searchQuery, undefined, true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a small comment on why we're passing |
||
| if (!(matchedApis?.length > 0)) { | ||
| throw new Error(`No results in Exchange for '${name}'`); | ||
| } | ||
| const api = matchedApis.find( | ||
| (matchedApi: {assetId: string}) => matchedApi?.assetId === name | ||
| ); | ||
| if (!api) { | ||
| throw new Error(`No exact match in Exchange for '${name}'`); | ||
| throw new Error(`No results in Exchange for '${searchQuery}'`); | ||
| } | ||
| try { | ||
| await download.downloadRestApis([api], rootPath, isOAS); | ||
| await download.downloadRestApis(matchedApis, rootPath, true); | ||
| } catch (err: unknown) { | ||
| if (err instanceof Error) { | ||
| err.message = `Failed to download ${name}: ${err.message}`; | ||
| err.message = `Failed to download API specs: ${err.message}`; | ||
| } | ||
| throw err; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT