@hubspot/local-dev-lib 1.3.0 → 1.4.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
@@ -5,6 +5,7 @@ import { Build, FetchProjectBuildsResponse } from '../types/Build';
5
5
  import { ComponentMetadataResponse, ComponentStructureResponse } from '../types/ComponentStructure';
6
6
  import { Deploy, ProjectDeployResponse } from '../types/Deploy';
7
7
  import { ProjectLog } from '../types/ProjectLog';
8
+ import { MigrateAppResponse, PollAppResponse } from '../types/Migration';
8
9
  export declare function fetchProjects(accountId: number): Promise<FetchProjectResponse>;
9
10
  export declare function createProject(accountId: number, name: string): Promise<Project>;
10
11
  export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): Promise<UploadProjectResponse>;
@@ -35,4 +36,6 @@ export declare function fetchBuildWarnLogs(accountId: number, projectName: strin
35
36
  export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): Promise<{
36
37
  logs: Array<ProjectLog>;
37
38
  }>;
39
+ export declare function migrateApp(accountId: number, appId: number, projectName: string): Promise<MigrateAppResponse>;
40
+ export declare function checkMigrationStatus(accountId: number, id: number): Promise<PollAppResponse>;
38
41
  export {};
package/api/projects.js CHANGED
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
6
+ exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const PROJECTS_API_PATH = 'dfs/v1/projects';
10
10
  const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
11
11
  const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
12
12
  const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
13
+ const MIGRATIONS_API_PATH = 'dfs/migrations/v1';
13
14
  async function fetchProjects(accountId) {
14
15
  return http_1.default.get(accountId, {
15
16
  url: PROJECTS_API_PATH,
@@ -172,3 +173,20 @@ async function fetchDeployWarnLogs(accountId, projectName, deployId) {
172
173
  });
173
174
  }
174
175
  exports.fetchDeployWarnLogs = fetchDeployWarnLogs;
176
+ async function migrateApp(accountId, appId, projectName) {
177
+ return http_1.default.post(accountId, {
178
+ url: `${MIGRATIONS_API_PATH}/migrations`,
179
+ data: {
180
+ componentId: appId,
181
+ componentType: 'PUBLIC_APP_ID',
182
+ projectName,
183
+ },
184
+ });
185
+ }
186
+ exports.migrateApp = migrateApp;
187
+ async function checkMigrationStatus(accountId, id) {
188
+ return http_1.default.get(accountId, {
189
+ url: `${MIGRATIONS_API_PATH}/migrations/${id}`,
190
+ });
191
+ }
192
+ exports.checkMigrationStatus = checkMigrationStatus;
package/lib/archive.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  type CopySourceToDestOptions = {
3
3
  sourceDir?: string;
4
4
  includesRootDir?: boolean;
5
+ hideLogs?: boolean;
5
6
  };
6
- export declare function extractZipArchive(zip: Buffer, name: string, dest: string, { sourceDir, includesRootDir }?: CopySourceToDestOptions): Promise<boolean>;
7
+ export declare function extractZipArchive(zip: Buffer, name: string, dest: string, { sourceDir, includesRootDir, hideLogs }?: CopySourceToDestOptions): Promise<boolean>;
7
8
  export {};
package/lib/archive.js CHANGED
@@ -13,10 +13,12 @@ const standardErrors_1 = require("../errors/standardErrors");
13
13
  const logger_1 = require("./logger");
14
14
  const lang_1 = require("../utils/lang");
15
15
  const i18nKey = 'lib.archive';
16
- async function extractZip(name, zip) {
16
+ async function extractZip(name, zip, hideLogs = false) {
17
17
  const result = { extractDir: '', tmpDir: '' };
18
18
  const TMP_FOLDER_PREFIX = `hubspot-temp-${name}-`;
19
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.extractZip.init`));
19
+ if (!hideLogs) {
20
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.extractZip.init`));
21
+ }
20
22
  // Write zip to disk
21
23
  let tmpZipPath = '';
22
24
  try {
@@ -51,9 +53,11 @@ async function extractZip(name, zip) {
51
53
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.extractZip.success`));
52
54
  return result;
53
55
  }
54
- async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true } = {}) {
56
+ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true, hideLogs = false, } = {}) {
55
57
  try {
56
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.init`));
58
+ if (!hideLogs) {
59
+ logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.init`));
60
+ }
57
61
  const srcDirPath = [src];
58
62
  if (includesRootDir) {
59
63
  const files = await fs_extra_1.default.readdir(src);
@@ -94,14 +98,15 @@ function cleanupTempDir(tmpDir) {
94
98
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
95
99
  }
96
100
  }
97
- async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir } = {}) {
101
+ async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir, hideLogs } = {}) {
98
102
  let success = false;
99
103
  if (zip) {
100
- const { extractDir, tmpDir } = await extractZip(name, zip);
104
+ const { extractDir, tmpDir } = await extractZip(name, zip, hideLogs);
101
105
  if (extractDir !== null) {
102
106
  success = await copySourceToDest(extractDir, dest, {
103
107
  sourceDir,
104
108
  includesRootDir,
109
+ hideLogs,
105
110
  });
106
111
  }
107
112
  cleanupTempDir(tmpDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "1.3.0",
3
+ "version": "1.4.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": {
@@ -0,0 +1,24 @@
1
+ import { ValueOf } from './Utils';
2
+ import { OptionalError } from './Error';
3
+ export declare const MIGRATION_STATUS: {
4
+ readonly BUILDING: "BUILDING";
5
+ readonly FAILURE: "FAILURE";
6
+ readonly PREPARING: "PREPARING";
7
+ readonly PENDING: "PENDING";
8
+ readonly SUCCESS: "SUCCESS";
9
+ };
10
+ export type MigrateAppResponse = {
11
+ id: number;
12
+ status: ValueOf<typeof MIGRATION_STATUS>;
13
+ };
14
+ export type PollAppResponse = {
15
+ id: number;
16
+ project?: {
17
+ id: number;
18
+ name: string;
19
+ buildId: number;
20
+ deployId: number;
21
+ };
22
+ error: OptionalError;
23
+ status: ValueOf<typeof MIGRATION_STATUS>;
24
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MIGRATION_STATUS = void 0;
4
+ exports.MIGRATION_STATUS = {
5
+ BUILDING: 'BUILDING',
6
+ FAILURE: 'FAILURE',
7
+ PREPARING: 'PREPARING',
8
+ PENDING: 'PENDING',
9
+ SUCCESS: 'SUCCESS',
10
+ };