Skip to content

Commit

Permalink
Merge branch 'main' into cp/convert-ts-lib-7
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Jan 13, 2025
2 parents b4001cb + 196917c commit 1e8bc60
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
3 changes: 2 additions & 1 deletion acceptance-tests/tests/workflows/secretsFlow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async function waitForSecretsListToContainSecret(testState: TestState) {
.toContain(SECRET.name);
}

describe('Secrets Flow', () => {
// TODO: Re-enable when the caching issue is resolved on the BE
describe.skip('Secrets Flow', () => {
let testState: TestState;

beforeAll(async () => {
Expand Down
64 changes: 33 additions & 31 deletions lib/dependencyManagement.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// @ts-nocheck
const { logger } = require('@hubspot/local-dev-lib/logger');
const { getProjectConfig } = require('./projects');
const { exec: execAsync } = require('child_process');
const { walk } = require('@hubspot/local-dev-lib/fs');
const path = require('path');
const { uiLink } = require('./ui');
const util = require('util');
const { i18n } = require('./lang');
const SpinniesManager = require('./ui/SpinniesManager');
const fs = require('fs');
const pkg = require('../package.json');
const DEFAULT_PACKAGE_MANAGER = 'npm';
import { logger } from '@hubspot/local-dev-lib/logger';
import { getProjectConfig } from './projects';
import { exec as execAsync } from 'child_process';
import { walk } from '@hubspot/local-dev-lib/fs';
import path from 'path';
import { uiLink } from './ui';
import util from 'util';
import { i18n } from './lang';
import SpinniesManager from './ui/SpinniesManager';
import fs from 'fs';
import pkg from '../package.json';

const DEFAULT_PACKAGE_MANAGER = 'npm';
const i18nKey = `commands.project.subcommands.installDeps`;

class NoPackageJsonFilesError extends Error {
constructor(projectName) {
constructor(projectName: string) {
super(
i18n(`${i18nKey}.noPackageJsonInProject`, {
projectName,
Expand All @@ -28,7 +27,7 @@ class NoPackageJsonFilesError extends Error {
}
}

export async function isGloballyInstalled(command) {
export async function isGloballyInstalled(command: string): Promise<boolean> {
const exec = util.promisify(execAsync);
try {
await exec(`${command} --version`);
Expand All @@ -38,24 +37,36 @@ export async function isGloballyInstalled(command) {
}
}

export async function getLatestCliVersion(): { latest: string; next: string } {
export async function getLatestCliVersion(): Promise<{
latest: string;
next: string;
}> {
const exec = util.promisify(execAsync);
const { stdout } = await exec(`npm info ${pkg.name} dist-tags --json`);
const { latest, next } = JSON.parse(stdout);
return { latest, next };
}

async function installPackages({ packages, installLocations }) {
export async function installPackages({
packages,
installLocations,
}: {
packages?: string[];
installLocations?: string[];
}): Promise<void> {
const installDirs =
installLocations || (await getProjectPackageJsonLocations());
await Promise.all(
installDirs.map(async dir => {
await installPackagesInDirectory(packages, dir);
await installPackagesInDirectory(dir, packages);
})
);
}

async function installPackagesInDirectory(packages, directory) {
async function installPackagesInDirectory(
directory: string,
packages?: string[]
): Promise<void> {
const spinner = `installingDependencies-${directory}`;
const relativeDir = path.relative(process.cwd(), directory);
SpinniesManager.init();
Expand Down Expand Up @@ -102,7 +113,7 @@ async function installPackagesInDirectory(packages, directory) {
}
}

async function getProjectPackageJsonLocations() {
export async function getProjectPackageJsonLocations(): Promise<string[]> {
const projectConfig = await getProjectConfig();

if (
Expand Down Expand Up @@ -148,7 +159,7 @@ async function getProjectPackageJsonLocations() {
throw new NoPackageJsonFilesError(name);
}

const packageParentDirs = [];
const packageParentDirs: string[] = [];
packageJsonFiles.forEach(packageJsonFile => {
const parentDir = path.dirname(packageJsonFile);
packageParentDirs.push(parentDir);
Expand All @@ -157,19 +168,10 @@ async function getProjectPackageJsonLocations() {
return packageParentDirs;
}

export async function hasMissingPackages(directory) {
export async function hasMissingPackages(directory: string): Promise<boolean> {
const exec = util.promisify(execAsync);
const { stdout } = await exec(`npm install --ignore-scripts --dry-run`, {
cwd: directory,
});
return !stdout?.includes('up to date in');
}

module.exports = {
isGloballyInstalled,
installPackages,
DEFAULT_PACKAGE_MANAGER,
getProjectPackageJsonLocations,
getLatestCliVersion,
hasMissingPackages,
};
4 changes: 2 additions & 2 deletions lib/sandboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ export async function validateSandboxUsageLimits(
const accountId = getAccountId(id);

if (!accountId) {
throw new Error(`${i18nKey}.create.failure.usageLimitFetch`);
throw new Error(i18n(`${i18nKey}.create.failure.usageLimitFetch`));
}

const {
data: { usage },
} = await getSandboxUsageLimits(accountId);
if (!usage) {
throw new Error(`${i18nKey}.create.failure.usageLimitFetch`);
throw new Error(i18n(`${i18nKey}.create.failure.usageLimitFetch`));
}
if (sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
if (usage['DEVELOPER'].available === 0) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/cli",
"version": "7.0.1-beta.0",
"version": "7.0.1",
"description": "The official CLI for developing on HubSpot",
"license": "Apache-2.0",
"repository": "https://github.com/HubSpot/hubspot-cli",
Expand Down Expand Up @@ -64,10 +64,10 @@
"list-all-commands": "yarn ts-node ./scripts/get-all-commands.ts",
"prettier:write": "prettier --write ./**/*.{ts,js,json}",
"test": "jest",
"test-cli": "yarn --cwd 'acceptance-tests' test-ci",
"test-cli-debug": "yarn --cwd 'acceptance-tests' test-debug",
"test-cli-qa": "yarn --cwd 'acceptance-tests' test-qa",
"test-cli-latest": "yarn build-docker && docker container run -it --rm --name=hs-cli-container hs-cli-image yarn --cwd 'acceptance-tests' test-latest",
"test-cli": "yarn build && yarn --cwd 'acceptance-tests' test-ci",
"test-cli-debug": "yarn build && yarn --cwd 'acceptance-tests' test-debug",
"test-cli-qa": "yarn build && yarn --cwd 'acceptance-tests' test-qa",
"test-cli-latest": "yarn build && yarn build-docker && docker container run -it --rm --name=hs-cli-container hs-cli-image yarn --cwd 'acceptance-tests' test-latest",
"build-docker": "docker image build --tag hs-cli-image . && docker image prune -f",
"circular-deps": "yarn madge --circular .",
"release": "yarn ts-node ./scripts/release.ts release",
Expand Down

0 comments on commit 1e8bc60

Please sign in to comment.