@hubspot/local-dev-lib
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -11,5 +11,12 @@ "use strict"; | ||
const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com'; | ||
const GITHUB_AUTH_HEADERS = { | ||
authorization: global && global.githubToken ? `Bearer ${global.githubToken}` : null, | ||
}; | ||
function getAdditionalHeaders() { | ||
const headers = {}; | ||
if (global && global.githubToken) { | ||
headers.authorization = `Bearer ${global.githubToken}`; | ||
} | ||
else if (process.env.GITHUB_TOKEN) { | ||
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`; | ||
} | ||
return headers; | ||
} | ||
// Returns information about the repo's releases. Defaults to "latest" if no tag is provided | ||
@@ -20,3 +27,6 @@ // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name | ||
return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, { | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS }, | ||
headers: { | ||
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), | ||
...getAdditionalHeaders(), | ||
}, | ||
}); | ||
@@ -30,3 +40,3 @@ } | ||
responseType: 'arraybuffer', | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS }, | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() }, | ||
}); | ||
@@ -38,3 +48,6 @@ } | ||
return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, { | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS }, | ||
headers: { | ||
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), | ||
...getAdditionalHeaders(), | ||
}, | ||
}); | ||
@@ -46,3 +59,3 @@ } | ||
return axios_1.default.get(downloadUrl, { | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS }, | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() }, | ||
responseType: 'arraybuffer', | ||
@@ -57,5 +70,8 @@ }); | ||
return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, { | ||
headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS }, | ||
headers: { | ||
...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), | ||
...getAdditionalHeaders(), | ||
}, | ||
}); | ||
} | ||
exports.fetchRepoContents = fetchRepoContents; |
@@ -1,2 +0,8 @@ | ||
import { FunctionInfo, FunctionOptions } from '../../types/Functions'; | ||
import { FunctionConfig, FunctionConfigInfo, FunctionInfo, FunctionOptions } from '../../types/Functions'; | ||
export declare function isObjectOrFunction(value: object): boolean; | ||
export declare function createEndpoint(endpointMethod: string, filename: string): { | ||
method: string; | ||
file: string; | ||
}; | ||
export declare function createConfig({ endpointPath, endpointMethod, functionFile, }: FunctionConfigInfo): FunctionConfig; | ||
export declare function createFunction(functionInfo: FunctionInfo, dest: string, options?: FunctionOptions): Promise<void>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFunction = void 0; | ||
exports.createFunction = exports.createConfig = exports.createEndpoint = exports.isObjectOrFunction = void 0; | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
@@ -21,2 +21,3 @@ const path_1 = __importDefault(require("path")); | ||
} | ||
exports.isObjectOrFunction = isObjectOrFunction; | ||
function createEndpoint(endpointMethod, filename) { | ||
@@ -28,2 +29,3 @@ return { | ||
} | ||
exports.createEndpoint = createEndpoint; | ||
function createConfig({ endpointPath, endpointMethod, functionFile, }) { | ||
@@ -40,2 +42,3 @@ return { | ||
} | ||
exports.createConfig = createConfig; | ||
function writeConfig(configFilePath, config) { | ||
@@ -42,0 +45,0 @@ const configJson = JSON.stringify(config, null, ' '); |
{ | ||
"name": "@hubspot/local-dev-lib", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
412698
10332
33