@hubspot/local-dev-lib 3.0.2-beta.0 → 3.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/projects.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  import { HubSpotPromise, QueryParams } from '../types/Http';
3
- import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse } from '../types/Project';
3
+ import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } from '../types/Project';
4
4
  import { Build, FetchProjectBuildsResponse } from '../types/Build';
5
5
  import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure';
6
6
  import { Deploy, ProjectDeployResponse } from '../types/Deploy';
7
7
  import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration';
8
8
  export declare function fetchProjects(accountId: number): HubSpotPromise<FetchProjectResponse>;
9
9
  export declare function createProject(accountId: number, name: string): HubSpotPromise<Project>;
10
- export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): HubSpotPromise<UploadProjectResponse>;
10
+ export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string, intermediateRepresentation?: unknown): HubSpotPromise<UploadProjectResponse | UploadIRResponse>;
11
11
  export declare function fetchProject(accountId: number, projectName: string): HubSpotPromise<Project>;
12
12
  export declare function fetchProjectComponentsMetadata(accountId: number, projectId: number): HubSpotPromise<ProjectComponentsMetadata>;
13
13
  export declare function downloadProject(accountId: number, projectName: string, buildId: number): HubSpotPromise<Buffer>;
package/api/projects.js CHANGED
@@ -12,6 +12,7 @@ const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
12
12
  const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
13
13
  const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
14
14
  const MIGRATIONS_API_PATH = 'dfs/migrations/v1';
15
+ const PROJECTS_V3_API_PATH = 'project-components-external/v3';
15
16
  function fetchProjects(accountId) {
16
17
  return http_1.http.get(accountId, {
17
18
  url: DEVELOPER_PROJECTS_API_PATH,
@@ -27,7 +28,27 @@ function createProject(accountId, name) {
27
28
  });
28
29
  }
29
30
  exports.createProject = createProject;
30
- function uploadProject(accountId, projectName, projectFile, uploadMessage, platformVersion) {
31
+ async function uploadProject(accountId, projectName, projectFile, uploadMessage, platformVersion, intermediateRepresentation) {
32
+ if (intermediateRepresentation) {
33
+ const formData = {
34
+ projectFilesZip: fs_1.default.createReadStream(projectFile),
35
+ platformVersion,
36
+ uploadRequest: JSON.stringify({
37
+ ...intermediateRepresentation,
38
+ projectName,
39
+ buildMessage: uploadMessage,
40
+ }),
41
+ };
42
+ const response = await http_1.http.post(accountId, {
43
+ url: `${PROJECTS_V3_API_PATH}/upload/new-api`,
44
+ timeout: 60_000,
45
+ data: formData,
46
+ headers: { 'Content-Type': 'multipart/form-data' },
47
+ });
48
+ // Remap the response to match the expected shape
49
+ response.data.buildId = response.data.createdBuildId;
50
+ return response;
51
+ }
31
52
  const formData = {
32
53
  file: fs_1.default.createReadStream(projectFile),
33
54
  uploadMessage,
@@ -78,6 +78,10 @@ function validateConfig() {
78
78
  logger_1.logger.error('config.portals[] is not defined');
79
79
  return false;
80
80
  }
81
+ if (accounts.length === 0) {
82
+ logger_1.logger.error('There are no accounts defined in the configuration file');
83
+ return false;
84
+ }
81
85
  const accountIdsHash = {};
82
86
  const accountNamesHash = {};
83
87
  return accounts.every(cfg => {
package/lib/fs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { FileData } from '../types/Files';
2
2
  export declare function getFileInfoAsync(dir: string, file: string): Promise<FileData>;
3
3
  export declare function flattenAndRemoveSymlinks(filesData: Array<FileData>): Array<string>;
4
- export declare function walk(dir: string): Promise<Array<string>>;
4
+ export declare function walk(dir: string, ignoreDirs?: string[]): Promise<Array<string>>;
package/lib/fs.js CHANGED
@@ -42,11 +42,11 @@ function flattenAndRemoveSymlinks(filesData) {
42
42
  }, []);
43
43
  }
44
44
  exports.flattenAndRemoveSymlinks = flattenAndRemoveSymlinks;
45
- const generateRecursiveFilePromise = async (dir, file) => {
45
+ const generateRecursiveFilePromise = async (dir, file, ignoreDirs) => {
46
46
  return getFileInfoAsync(dir, file).then(fileData => {
47
47
  return new Promise(resolve => {
48
48
  if (fileData.type === files_1.STAT_TYPES.DIRECTORY) {
49
- walk(fileData.filepath).then(files => {
49
+ walk(fileData.filepath, ignoreDirs).then(files => {
50
50
  resolve({ ...fileData, files });
51
51
  });
52
52
  }
@@ -56,9 +56,13 @@ const generateRecursiveFilePromise = async (dir, file) => {
56
56
  });
57
57
  });
58
58
  };
59
- async function walk(dir) {
59
+ async function walk(dir, ignoreDirs) {
60
60
  function processFiles(files) {
61
- return Promise.all(files.map(file => generateRecursiveFilePromise(dir, file)));
61
+ // If the directory is in the ignore list, return an empty array to skip the directory contents
62
+ if (ignoreDirs?.some(ignored => dir.includes(ignored))) {
63
+ return [];
64
+ }
65
+ return Promise.all(files.map(file => generateRecursiveFilePromise(dir, file, ignoreDirs)));
62
66
  }
63
67
  return fs_1.default.promises
64
68
  .readdir(dir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "3.0.2-beta.0",
3
+ "version": "3.1.0-beta.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -29,6 +29,8 @@ export interface CLIAccount_DEPRECATED {
29
29
  authType?: AuthType;
30
30
  auth?: {
31
31
  tokenInfo?: TokenInfo;
32
+ clientId?: string;
33
+ clientSecret?: string;
32
34
  };
33
35
  sandboxAccountType?: string | null;
34
36
  parentAccountId?: number | null;
@@ -34,6 +34,10 @@ export type UploadProjectResponse = {
34
34
  };
35
35
  };
36
36
  };
37
+ export type UploadIRResponse = {
38
+ buildId?: number;
39
+ createdBuildId: number;
40
+ };
37
41
  export type ProjectSettings = {
38
42
  isAutoDeployEnabled: boolean;
39
43
  };