Skip to content

Commit

Permalink
Merge pull request #39 from HubSpot/br-add-deprecation-comments
Browse files Browse the repository at this point in the history
Add deprecation annotations to ported utils
  • Loading branch information
brandenrodgers authored Jan 4, 2024
2 parents 745916e + a987c16 commit a29e889
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Deprecated

This library is deprecated and is currently being replaced by the new [local-dev-lib](https://github.com/HubSpot/hubspot-local-dev-lib) library. This library will remain available for use, but no new functionality will be added to it

## Table of Contents

- [Overview](#what-is-cli-lib-for)
Expand Down
4 changes: 4 additions & 0 deletions api/fileMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ async function deleteFolder(accountId, folderPath, options = {}) {
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib (@hubspot/local-dev-lib/trackUsage)
* https://github.com/HubSpot/hubspot-local-dev-lib
*
* Track CMS CLI usage
*
* @async
Expand Down
5 changes: 5 additions & 0 deletions archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ function cleanupTempDir(tmpDir) {
}
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
async function extractZipArchive(
zip,
name,
Expand Down
21 changes: 21 additions & 0 deletions ignoreRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const ignoreRules = ignore().add(ignoreList);

let searchDomain = null;
let loaded = false;

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
function loadIgnoreConfig(isInProject = false) {
if (loaded) {
return;
Expand All @@ -54,6 +60,11 @@ function loadIgnoreConfig(isInProject = false) {
loaded = true;
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
function shouldIgnoreFile(file, isInProject) {
loadIgnoreConfig(isInProject);
const relativeTo = searchDomain || '/';
Expand All @@ -62,11 +73,21 @@ function shouldIgnoreFile(file, isInProject) {
return !!relativePath && ignoreRules.ignores(relativePath);
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
function createIgnoreFilter(isInProject) {
loadIgnoreConfig(isInProject);
return file => !shouldIgnoreFile(file);
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
function ignoreFile(filePath) {
ignoreRules.add(filePath);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const { ENVIRONMENTS } = require('./constants');

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
* Returns environment constant for QA and PROD or optional masked value for PROD
* @param {string} env Environment string, can be any case
* @param {(boolean|object)} shouldMaskProduction Returning alternate value for PROD
Expand Down
10 changes: 10 additions & 0 deletions lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const { getEnv } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('./urls');
const { ENVIRONMENTS } = require('./constants');

/**
* @deprecated
* Use the corresponding export from local-dev-lib (renamed to @hubspot/local-dev-lib/cms/themes)
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getThemeJSONPath = path =>
findup('theme.json', {
cwd: path,
Expand All @@ -18,6 +23,11 @@ const getThemeNameFromPath = filePath => {
return pathParts[pathParts.length - 2];
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib (renamed to @hubspot/local-dev-lib/cms/themes)
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getThemePreviewUrl = (filePath, accountId) => {
const themeName = getThemeNameFromPath(filePath);
if (!themeName) return;
Expand Down
5 changes: 5 additions & 0 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ const checkAndWarnGitInclusion = configPath => {
}
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib (renamed to @hubspot/local-dev-lib/gitignore)
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const checkAndUpdateGitignore = configPath => {
try {
const { configIgnored, gitignoreFiles } = checkGitInclusion(configPath);
Expand Down
10 changes: 10 additions & 0 deletions lib/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ const tableConfigDefaults = {
},
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getTableContents = (tableData = [], tableConfig = {}) => {
const mergedConfig = mergeDeep({}, tableConfigDefaults, tableConfig);

return table(tableData, mergedConfig);
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getTableHeader = headerItems => {
return headerItems.map(headerItem => chalk.bold(headerItem));
};
Expand Down
5 changes: 5 additions & 0 deletions lib/text.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const commaSeparatedValues = (arr, conjunction = 'and', ifempty = '') => {
let l = arr.length;
if (!l) return ifempty;
Expand Down
10 changes: 10 additions & 0 deletions lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ const getEnvUrlString = env => {
return env.toLowerCase() === ENVIRONMENTS.QA ? ENVIRONMENTS.QA : '';
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getHubSpotWebsiteOrigin = env => {
return `https://app.hubspot${getEnvUrlString(env)}.com`;
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getHubSpotApiOrigin = (env, useLocalHost) => {
let domain = process.env.HUBAPI_DOMAIN_OVERRIDE;

Expand Down
5 changes: 5 additions & 0 deletions lib/walk.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const generateRecursiveFilePromise = async (dir, file) => {
});
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib (@hubspot/local-dev-lib/fs)
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
async function walk(dir) {
const processFiles = files =>
Promise.all(files.map(file => generateRecursiveFilePromise(dir, file)));
Expand Down
54 changes: 54 additions & 0 deletions path.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@ const path = require('path');
const unixify = require('unixify');
const { ALLOWED_EXTENSIONS } = require('./lib/constants');

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const convertToUnixPath = _path => {
return unixify(path.normalize(_path));
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const convertToWindowsPath = _path => {
const rgx = new RegExp(`\\${path.posix.sep}`, 'g');
return path.normalize(_path).replace(rgx, path.win32.sep);
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
* Converts a Win32 path to Posix, retaining the drive letter (ex. 'c:')
*
* @param {string} _path
Expand All @@ -23,6 +36,11 @@ const convertToImportPath = _path => {
return _path;
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const convertToLocalFileSystemPath = _path => {
switch (path.sep) {
case path.posix.sep:
Expand All @@ -45,6 +63,9 @@ const removeTrailingSlashFromSplits = parts => {
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
* Splits a filepath for local file system sources.
*
* @param {string} filepath
Expand All @@ -64,6 +85,9 @@ const splitLocalPath = (filepath, pathImplementation = path) => {
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
* Splits a filepath for remote sources (HubSpot).
*
* @param {string} filepath
Expand All @@ -80,13 +104,23 @@ const splitHubSpotPath = filepath => {
return removeTrailingSlashFromSplits(parts);
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getCwd = () => {
if (process.env.INIT_CWD) {
return process.env.INIT_CWD;
}
return process.cwd();
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
function getExt(filepath) {
if (typeof filepath !== 'string') return '';
const ext = path
Expand All @@ -96,18 +130,38 @@ function getExt(filepath) {
return ext[0] === '.' ? ext.slice(1) : ext;
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getAllowedExtensions = (allowList = []) => {
return new Set([...Array.from(ALLOWED_EXTENSIONS), ...allowList]);
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const isAllowedExtension = (filepath, allowList = []) => {
const ext = getExt(filepath);
const allowedExtensions = getAllowedExtensions(allowList);
return allowedExtensions.has(ext);
};

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const getAbsoluteFilePath = _path => path.resolve(getCwd(), _path);

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
const isRelativePath = _path => !path.isAbsolute(_path);

module.exports = {
Expand Down
14 changes: 14 additions & 0 deletions personalAccessKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function getRefreshKey(personalAccessKey, expiration) {
return `${personalAccessKey}-${expiration || 'fresh'}`;
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
async function getAccessToken(
personalAccessKey,
env = ENVIRONMENTS.PROD,
Expand Down Expand Up @@ -98,6 +103,11 @@ async function getNewAccessToken(accountId, personalAccessKey, expiresAt, env) {
return accessToken;
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*/
async function accessTokenForPersonalAccessKey(accountId) {
const { auth, personalAccessKey, env } = getAccountConfig(accountId);
const authTokenInfo = auth && auth.tokenInfo;
Expand All @@ -121,6 +131,10 @@ async function accessTokenForPersonalAccessKey(accountId) {
}

/**
* @deprecated
* Use the corresponding export from local-dev-lib
* https://github.com/HubSpot/hubspot-local-dev-lib
*
* Adds a account to the config using authType: personalAccessKey
*
* @param {object} configData Data containing personalAccessKey and name properties
Expand Down
Loading

0 comments on commit a29e889

Please sign in to comment.