Skip to content

Commit

Permalink
Start converting lib/projects to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Dec 10, 2024
1 parent 7a50ab5 commit 5b559df
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 42 deletions.
77 changes: 35 additions & 42 deletions lib/projects.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
// @ts-nocheck
const fs = require('fs-extra');
const path = require('path');
const archiver = require('archiver');
const tmp = require('tmp');
const chalk = require('chalk');
const findup = require('findup-sync');
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getEnv } = require('@hubspot/local-dev-lib/config');
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
const { fetchFileFromRepository } = require('@hubspot/local-dev-lib/github');
const {
ENVIRONMENTS,
} = require('@hubspot/local-dev-lib/constants/environments');
const {
FEEDBACK_INTERVAL,
POLLING_DELAY,
PROJECT_BUILD_TEXT,
PROJECT_DEPLOY_TEXT,
PROJECT_CONFIG_FILE,
PROJECT_TASK_TYPES,
PROJECT_ERROR_TYPES,
HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
PROJECT_COMPONENT_TYPES,
} = require('./constants');
const {
import fs from 'fs-extra';
import path from 'path';
import archiver from 'archiver';
import tmp from 'tmp';
import chalk from 'chalk';
import findup from 'findup-sync';
import { logger } from '@hubspot/local-dev-lib/logger';
import { getEnv } from '@hubspot/local-dev-lib/config';
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
import { fetchFileFromRepository } from '@hubspot/local-dev-lib/github';
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
import {
createProject,
getBuildStatus,
getBuildStructure,
Expand All @@ -33,22 +19,29 @@ const {
uploadProject,
fetchBuildWarnLogs,
fetchDeployWarnLogs,
} = require('@hubspot/local-dev-lib/api/projects');
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
const { downloadGithubRepoContents } = require('@hubspot/local-dev-lib/github');
const { promptUser } = require('./prompts/promptUtils');
const { EXIT_CODES } = require('./enums/exitCodes');
const {
uiLine,
uiLink,
uiAccountDescription,
uiCommandReference,
} = require('./ui');
const { i18n } = require('./lang');
const SpinniesManager = require('./ui/SpinniesManager');
const { logError, ApiErrorContext } = require('./errorHandlers/index');
} from '@hubspot/local-dev-lib/api/projects';
import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
import { shouldIgnoreFile } from '@hubspot/local-dev-lib/ignoreRules';
import { getCwd, getAbsoluteFilePath } from '@hubspot/local-dev-lib/path';
import { downloadGithubRepoContents } from '@hubspot/local-dev-lib/github';

import {
FEEDBACK_INTERVAL,
POLLING_DELAY,
PROJECT_BUILD_TEXT,
PROJECT_DEPLOY_TEXT,
PROJECT_CONFIG_FILE,
PROJECT_TASK_TYPES,
PROJECT_ERROR_TYPES,
HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
PROJECT_COMPONENT_TYPES,
} from './constants';
import { promptUser } from './prompts/promptUtils';
import { EXIT_CODES } from './enums/exitCodes';
import { uiLine, uiLink, uiAccountDescription, uiCommandReference } from './ui';
import { i18n } from './lang';
import SpinniesManager from './ui/SpinniesManager';
import { logError, ApiErrorContext } from './errorHandlers/index';

const i18nKey = 'lib.projects';

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
"yargs-parser": "^21.1.1"
},
"devDependencies": {
"@types/archiver": "^6.0.3",
"@types/express": "^5.0.0",
"@types/findup-sync": "^4.0.5",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/semver": "^7.5.8",
"@types/tmp": "^0.2.6",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
Expand Down
38 changes: 38 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3224,6 +3224,13 @@
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9"
integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==

"@types/archiver@^6.0.3":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@types/archiver/-/archiver-6.0.3.tgz#074eb6f4febc0128c25a205a8263da3d4688df53"
integrity sha512-a6wUll6k3zX6qs5KlxIggs1P1JcYJaTCx2gnlr+f0S1yd2DoaEwoIK10HmBaLnZwWneBz+JBm0dwcZu0zECBcQ==
dependencies:
"@types/readdir-glob" "*"

"@types/aria-query@^5.0.1":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-5.0.4.tgz#1a31c3d378850d2778dabb6374d036dcba4ba708"
Expand Down Expand Up @@ -3270,6 +3277,11 @@
"@types/connect" "*"
"@types/node" "*"

"@types/braces@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/braces/-/braces-3.0.4.tgz#403488dc1c8d0db288270d3bbf0ce5f9c45678b4"
integrity sha512-0WR3b8eaISjEW7RpZnclONaLFDf7buaowRHdqLp4vLj54AsSAYWfh3DRbfiYJY9XDxMgx1B4sE1Afw2PGpuHOA==

"@types/connect@*":
version "3.4.38"
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858"
Expand Down Expand Up @@ -3364,6 +3376,13 @@
resolved "https://registry.yarnpkg.com/@types/find-cache-dir/-/find-cache-dir-3.2.1.tgz#7b959a4b9643a1e6a1a5fe49032693cc36773501"
integrity sha512-frsJrz2t/CeGifcu/6uRo4b+SzAwT4NYCVPu1GN8IB9XTzrpPkGuV0tmh9mN+/L0PklAlsC3u5Fxt0ju00LXIw==

"@types/findup-sync@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/findup-sync/-/findup-sync-4.0.5.tgz#df25b72fb256a65b346bc66e2dcd7de04393ec84"
integrity sha512-Y4NCs+7uDZ3SFF0GWowN2IANqOJr+Cdvp9hfMSGzQYqJkyvAEJIq/s0/8AP88fq+yswykWPWZRBrqWPEhCLsgg==
dependencies:
"@types/micromatch" "^4.0.0"

"@types/fs-extra@^11.0.4":
version "11.0.4"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.4.tgz#e16a863bb8843fba8c5004362b5a73e17becca45"
Expand Down Expand Up @@ -3458,6 +3477,13 @@
resolved "https://registry.yarnpkg.com/@types/mdx/-/mdx-2.0.13.tgz#68f6877043d377092890ff5b298152b0a21671bd"
integrity sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==

"@types/micromatch@^4.0.0":
version "4.0.9"
resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.9.tgz#8e5763a8c1fc7fbf26144d9215a01ab0ff702dbb"
integrity sha512-7V+8ncr22h4UoYRLnLXSpTxjQrNUXtWHGeMPRJt1nULXI57G9bIcpyrHlmrQ7QK24EyyuXvYcSSWAM8GA9nqCg==
dependencies:
"@types/braces" "*"

"@types/mime-types@^2.1.0":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.4.tgz#93a1933e24fed4fb9e4adc5963a63efcbb3317a2"
Expand Down Expand Up @@ -3538,6 +3564,13 @@
"@types/prop-types" "*"
csstype "^3.0.2"

"@types/readdir-glob@*":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@types/readdir-glob/-/readdir-glob-1.1.5.tgz#21a4a98898fc606cb568ad815f2a0eedc24d412a"
integrity sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==
dependencies:
"@types/node" "*"

"@types/semver@^7.3.4", "@types/semver@^7.5.8":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
Expand Down Expand Up @@ -3565,6 +3598,11 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"
integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==

"@types/tmp@^0.2.6":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.6.tgz#d785ee90c52d7cc020e249c948c36f7b32d1e217"
integrity sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==

"@types/unist@^2.0.0":
version "2.0.11"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.11.tgz#11af57b127e32487774841f7a4e54eab166d03c4"
Expand Down

0 comments on commit 5b559df

Please sign in to comment.