Skip to content

Commit

Permalink
docs(get): generate docs for get function only
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Dec 1, 2023
1 parent 61871da commit 0977eea
Showing 1 changed file with 27 additions and 59 deletions.
86 changes: 27 additions & 59 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,26 @@ import * as util from "./util.js";
const { log } = logger;
const { ARCH_KV, PLATFORM_KV, replaceFfmpeg } = util;

/**
* @typedef {object} GetOptions
* @property {string | "latest" | "stable" | "lts"} [options.version = "latest"] Runtime version
* @property {"normal" | "sdk"} [options.flavor = "normal"] Build flavor
* @property {"linux" | "osx" | "win"} [options.platform] Target platform
* @property {"ia32" | "x64" | "arm64"} [options.arch] Target arch
* @property {string} [options.downloadUrl = "https://dl.nwjs.io"] Download server
* @property {string} [options.cacheDir = "./cache"] Cache directory
* @property {string} [options.outDir = "./out"] Out directory
* @property {boolean} [options.cache = true] If false, remove cache and redownload.
* @property {boolean} [options.ffmpeg = false] If true, ffmpeg is not downloaded.
* @property {false | "gyp"} [options.nativeAddon = false] Rebuild native modules
*/

/**
* Get binaries.
*
* _Note: This an internal function which is not called directly. Please see example usage below._
* @function
* @param {GetOptions} options
* @return {Promise<void>}
*
* @example
* // Minimal Usage (uses default values)
Expand Down Expand Up @@ -59,23 +75,11 @@ const { ARCH_KV, PLATFORM_KV, replaceFfmpeg } = util;
* });
*
* @example
* // Node headers
* // Get Node headers
* nwbuild({
* mode: "get",
* nativeAddon: "gyp",
* });
*
* @param {object} options Get mode options
* @param {string} options.version NW.js runtime version. Defaults to "latest".
* @param {"normal" | "sdk"} options.flavor NW.js build flavor. Defaults to "normal".
* @param {"linux" | "osx" | "win"} options.platform Target platform. Defaults to host platform.
* @param {"ia32" | "x64" | "arm64"} options.arch Target architecture. Defaults to host architecture.
* @param {string} options.downloadUrl File server to download from. Defaults to "https://dl.nwjs.io". Set "https://npm.taobao.org/mirrors/nwjs" for China mirror or "https://cnpmjs.org/mirrors/nwjs/" for Singapore mirror.
* @param {string} options.cacheDir Cache directory path. Defaults to "./cache"
* @param {boolean} options.cache If false, remove cache before download. Defaults to true.
* @param {boolean} options.ffmpeg If true, ffmpeg is not downloaded. Defaults to false.
* @param {false | "gyp"} options.nativeAddon Rebuilds native modules. Defaults to false.
* @return {Promise<void>}
*/
export async function get({
version = "latest",
Expand Down Expand Up @@ -119,28 +123,15 @@ export async function get({
}
}

/**
* Get NW.js binaries
*
* @param {object} options Get mode options
* @param {string} options.version NW.js runtime version. Defaults to "latest".
* @param {"normal" | "sdk"} options.flavor NW.js build flavor. Defaults to "normal".
* @param {"linux" | "osx" | "win"} options.platform Target platform. Defaults to host platform.
* @param {"ia32" | "x64" | "arm64"} options.arch Target architecture. Defaults to host architecture.
* @param {string} options.downloadUrl File server to download from. Defaults to "https://dl.nwjs.io". Set "https://npm.taobao.org/mirrors/nwjs" for China mirror or "https://cnpmjs.org/mirrors/nwjs/" for Singapore mirror.
* @param {string} options.cacheDir Cache directory path. Defaults to "./cache"
* @param {boolean} options.cache If false, remove cache before download. Defaults to true.
* @return {Promise<void>}
*/
async function getNwjs({
const getNwjs = async ({
version = "latest",
flavor = "normal",
platform = PLATFORM_KV[process.platform],
arch = ARCH_KV[process.arch],
downloadUrl = "https://dl.nwjs.io",
cacheDir = "./cache",
cache = true,
}) {
}) => {
const bar = new progress.SingleBar({}, progress.Presets.rect);
const out = path.resolve(
cacheDir,
Expand Down Expand Up @@ -277,28 +268,16 @@ async function getNwjs({
);
}
});
}
};

/**
* Get FFmpeg binary.
*
* @param {object} options Get mode options
* @param {string} options.version NW.js runtime version. Defaults to "latest".
* @param {"normal" | "sdk"} options.flavor NW.js build flavor. Defaults to "normal".
* @param {"linux" | "osx" | "win"} options.platform Target platform. Defaults to host platform.
* @param {"ia32" | "x64" | "arm64"} options.arch Target architecture. Defaults to host architecture.
* @param {string} options.cacheDir Cache directory path. Defaults to "./cache"
* @param {boolean} options.cache If false, remove cache before download. Defaults to true.
* @return {Promise<void>}
*/
async function getFfmpeg({
const getFfmpeg = async ({
version = "latest",
flavor = "normal",
platform = PLATFORM_KV[process.platform],
arch = ARCH_KV[process.arch],
cacheDir = "./cache",
cache = true,
}) {
}) => {
const nwDir = path.resolve(
cacheDir,
`nwjs${flavor === "sdk" ? "-sdk" : ""}-v${version}-${platform}-${arch}`,
Expand Down Expand Up @@ -371,26 +350,15 @@ async function getFfmpeg({
await compressing.zip.uncompress(out, nwDir);
await replaceFfmpeg(platform, nwDir);
});
}
};

/**
* Get Node headers
*
* @param {object} options Get mode options
* @param {string} options.version NW.js runtime version. Defaults to "latest".
* @param {"linux" | "osx" | "win"} options.platform Target platform. Defaults to host platform.
* @param {"ia32" | "x64" | "arm64"} options.arch Target architecture. Defaults to host architecture.
* @param {string} options.cacheDir Cache directory path. Defaults to "./cache"
* @param {string} options.cache If false, remove cache before download. Defaults to true.
* @return {Promise<void>}
*/
async function getNodeHeaders({
const getNodeHeaders = async ({
version = "latest",
platform = PLATFORM_KV[process.platform],
arch = ARCH_KV[process.arch],
cacheDir = "./cache",
cache = true,
}) {
}) => {
const bar = new progress.SingleBar({}, progress.Presets.rect);
const out = path.resolve(
cacheDir,
Expand Down Expand Up @@ -474,4 +442,4 @@ async function getNodeHeaders({
path.resolve(cacheDir, `node-v${version}-${platform}-${arch}`),
);
});
}
};

0 comments on commit 0977eea

Please sign in to comment.