@hubspot/local-dev-lib 1.1.0 → 1.3.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.js CHANGED
@@ -162,13 +162,13 @@ async function cancelStagedBuild(accountId, projectName) {
162
162
  exports.cancelStagedBuild = cancelStagedBuild;
163
163
  async function fetchBuildWarnLogs(accountId, projectName, buildId) {
164
164
  return http_1.default.get(accountId, {
165
- url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${projectName}/builds/${buildId}/combined/warn`,
165
+ url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/builds/${buildId}/combined/warn`,
166
166
  });
167
167
  }
168
168
  exports.fetchBuildWarnLogs = fetchBuildWarnLogs;
169
169
  async function fetchDeployWarnLogs(accountId, projectName, deployId) {
170
170
  return http_1.default.get(accountId, {
171
- url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${projectName}/deploys/${deployId}/combined/warn`,
171
+ url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/deploys/${deployId}/combined/warn`,
172
172
  });
173
173
  }
174
174
  exports.fetchDeployWarnLogs = fetchDeployWarnLogs;
@@ -1,4 +1,4 @@
1
- import { InitiateSyncResponse, Task, SyncTask, FetchTypesResponse } from '../types/Sandbox';
2
- export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<SyncTask>, sandboxHubId: number): Promise<InitiateSyncResponse>;
3
- export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<Task>;
1
+ import { InitiateSyncResponse, FetchTypesResponse, TaskRequestData, SyncTaskStatusType } from '../types/Sandbox';
2
+ export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): Promise<InitiateSyncResponse>;
3
+ export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<SyncTaskStatusType>;
4
4
  export declare function fetchTypes(accountId: number, toHubId: number): Promise<FetchTypesResponse>;
@@ -23,7 +23,7 @@ async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
23
23
  exports.initiateSync = initiateSync;
24
24
  async function fetchTaskStatus(accountId, taskId) {
25
25
  return http_1.default.get(accountId, {
26
- url: `${SANDBOXES_SYNC_API_PATH}/tasks/${taskId}`,
26
+ url: `${SANDBOXES_SYNC_API_PATH}/tasks/${taskId}/status`,
27
27
  });
28
28
  }
29
29
  exports.fetchTaskStatus = fetchTaskStatus;
package/lang/en.json CHANGED
@@ -223,11 +223,11 @@
223
223
  }
224
224
  },
225
225
  "accountTypes": {
226
- "developmentSandbox": "development sandbox",
226
+ "developmentSandbox": "dev sandbox",
227
227
  "standardSandbox": "standard sandbox",
228
- "developerTest": "developer test account",
229
- "appDeveloper": "app developer account",
230
- "standard": "production account"
228
+ "developerTest": "test account",
229
+ "appDeveloper": "dev account",
230
+ "standard": "standard"
231
231
  }
232
232
  },
233
233
  "config": {
package/lang/lang/en.json CHANGED
@@ -223,11 +223,11 @@
223
223
  }
224
224
  },
225
225
  "accountTypes": {
226
- "developmentSandbox": "development sandbox",
226
+ "developmentSandbox": "dev sandbox",
227
227
  "standardSandbox": "standard sandbox",
228
- "developerTest": "developer test account",
229
- "appDeveloper": "app developer account",
230
- "standard": "production account"
228
+ "developerTest": "test account",
229
+ "appDeveloper": "dev account",
230
+ "standard": "standard"
231
231
  }
232
232
  },
233
233
  "config": {
@@ -21,4 +21,5 @@ export declare function createModule(moduleDefinition: ModuleDefinition, name: s
21
21
  allowExistingDir: boolean;
22
22
  }): Promise<void>;
23
23
  export declare function retrieveDefaultModule(name: string | undefined, dest: string): Promise<import("../../types/Github").GithubRepoFile[] | undefined>;
24
+ export declare const isModuleHTMLFile: (filePath: string) => boolean;
24
25
  export {};
@@ -3,7 +3,7 @@ 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.retrieveDefaultModule = exports.createModule = exports.validateSrcAndDestPaths = exports.ValidationIds = void 0;
6
+ exports.isModuleHTMLFile = exports.retrieveDefaultModule = exports.createModule = exports.validateSrcAndDestPaths = exports.ValidationIds = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_2 = require("../path");
@@ -114,7 +114,7 @@ async function createModule(moduleDefinition, name, dest, getInternalVersion, op
114
114
  external_js: [],
115
115
  global: global,
116
116
  help_text: '',
117
- host_template_types: contentTypes,
117
+ content_types: contentTypes,
118
118
  js_assets: [],
119
119
  other_assets: [],
120
120
  smart_type: 'NOT_SMART',
@@ -182,3 +182,6 @@ async function retrieveDefaultModule(name, dest) {
182
182
  await (0, github_1.downloadGithubRepoContents)('HubSpot/cms-react', `default-react-modules/src/components/modules/${name}`, dest);
183
183
  }
184
184
  exports.retrieveDefaultModule = retrieveDefaultModule;
185
+ const MODULE_HTML_EXTENSION_REGEX = new RegExp(/\.module(?:\/|\\)module\.html$/);
186
+ const isModuleHTMLFile = (filePath) => MODULE_HTML_EXTENSION_REGEX.test(filePath);
187
+ exports.isModuleHTMLFile = isModuleHTMLFile;
@@ -20,4 +20,46 @@ declare const ASSET_PATHS: {
20
20
  export declare function createTemplate(name: string, dest: string, type?: keyof typeof ASSET_PATHS, options?: {
21
21
  allowExisting: boolean;
22
22
  }): Promise<void>;
23
+ export declare const TEMPLATE_TYPES: {
24
+ unmapped: number;
25
+ email_base_template: number;
26
+ email: number;
27
+ landing_page_base_template: number;
28
+ landing_page: number;
29
+ blog_base: number;
30
+ blog: number;
31
+ blog_listing: number;
32
+ site_page: number;
33
+ blog_listing_context: number;
34
+ blog_post_context: number;
35
+ error_page: number;
36
+ subscription_preferences: number;
37
+ unsubscribe_confirmation: number;
38
+ unsubscribe_simple: number;
39
+ optin_email: number;
40
+ optin_followup_email: number;
41
+ optin_confirmation_page: number;
42
+ global_group: number;
43
+ password_prompt_page: number;
44
+ resubscribe_email: number;
45
+ unsubscribe_confirmation_email: number;
46
+ resubscribe_confirmation_email: number;
47
+ custom_module: number;
48
+ css: number;
49
+ js: number;
50
+ search_results: number;
51
+ membership_login: number;
52
+ membership_register: number;
53
+ membership_reset: number;
54
+ membership_reset_request: number;
55
+ drag_drop_email: number;
56
+ knowledge_article: number;
57
+ membership_email: number;
58
+ section: number;
59
+ global_content_partial: number;
60
+ simple_landing_page_template: number;
61
+ proposal: number;
62
+ blog_post: number;
63
+ quote: number;
64
+ };
23
65
  export {};
@@ -3,7 +3,7 @@ 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.createTemplate = exports.isCodedFile = exports.getAnnotationValue = exports.ANNOTATION_KEYS = void 0;
6
+ exports.TEMPLATE_TYPES = exports.createTemplate = exports.isCodedFile = exports.getAnnotationValue = exports.ANNOTATION_KEYS = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const github_1 = require("../github");
@@ -64,3 +64,45 @@ async function createTemplate(name, dest, type = 'page-template', options = { al
64
64
  await (0, github_1.downloadGithubRepoContents)('HubSpot/cms-sample-assets', assetPath, filePath);
65
65
  }
66
66
  exports.createTemplate = createTemplate;
67
+ exports.TEMPLATE_TYPES = {
68
+ unmapped: 0,
69
+ email_base_template: 1,
70
+ email: 2,
71
+ landing_page_base_template: 3,
72
+ landing_page: 4,
73
+ blog_base: 5,
74
+ blog: 6,
75
+ blog_listing: 42,
76
+ site_page: 8,
77
+ blog_listing_context: 9,
78
+ blog_post_context: 10,
79
+ error_page: 11,
80
+ subscription_preferences: 12,
81
+ unsubscribe_confirmation: 13,
82
+ unsubscribe_simple: 14,
83
+ optin_email: 15,
84
+ optin_followup_email: 16,
85
+ optin_confirmation_page: 17,
86
+ global_group: 18,
87
+ password_prompt_page: 19,
88
+ resubscribe_email: 20,
89
+ unsubscribe_confirmation_email: 21,
90
+ resubscribe_confirmation_email: 22,
91
+ custom_module: 23,
92
+ css: 24,
93
+ js: 25,
94
+ search_results: 27,
95
+ membership_login: 29,
96
+ membership_register: 30,
97
+ membership_reset: 31,
98
+ membership_reset_request: 32,
99
+ drag_drop_email: 34,
100
+ knowledge_article: 35,
101
+ membership_email: 36,
102
+ section: 37,
103
+ global_content_partial: 38,
104
+ simple_landing_page_template: 39,
105
+ proposal: 40,
106
+ blog_post: 41,
107
+ quote: 43,
108
+ };
@@ -13,5 +13,5 @@ type WatchOptions = {
13
13
  filePaths?: Array<string>;
14
14
  };
15
15
  type ErrorHandler = (error: AxiosError) => void;
16
- export declare function watch(accountId: number, src: string, dest: string, { mode, remove, disableInitial, notify, commandOptions, filePaths, }: WatchOptions, postInitialUploadCallback?: ((result: Array<UploadFolderResults>) => void) | null, onUploadFolderError?: ErrorHandler, onQueueAddError?: ErrorHandler): chokidar.FSWatcher;
16
+ export declare function watch(accountId: number, src: string, dest: string, { mode, remove, disableInitial, notify, commandOptions, filePaths, }: WatchOptions, postInitialUploadCallback?: ((result: Array<UploadFolderResults>) => void) | null, onUploadFolderError?: ErrorHandler, onQueueAddError?: ErrorHandler, onUploadFileError?: (file: string, dest: string, accountId: number) => ErrorHandler): chokidar.FSWatcher;
17
17
  export {};
package/lib/cms/watch.js CHANGED
@@ -35,7 +35,18 @@ function _notifyOfThemePreview(filePath, accountId) {
35
35
  }));
36
36
  }
37
37
  const notifyOfThemePreview = (0, debounce_1.default)(_notifyOfThemePreview, 1000);
38
- async function uploadFile(accountId, file, dest, options, mode = null) {
38
+ const defaultOnUploadFileError = (file, dest, accountId) => (error) => {
39
+ logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, {
40
+ file,
41
+ dest,
42
+ }));
43
+ (0, apiErrors_1.throwApiUploadError)(error, {
44
+ accountId,
45
+ request: dest,
46
+ payload: file,
47
+ });
48
+ };
49
+ async function uploadFile(accountId, file, dest, options, mode = null, onUploadFileError = defaultOnUploadFileError) {
39
50
  const src = options.src;
40
51
  const absoluteSrcPath = path_1.default.resolve((0, path_2.getCwd)(), file);
41
52
  const themeJsonPath = (0, themes_1.getThemeJSONPath)(absoluteSrcPath);
@@ -71,17 +82,7 @@ async function uploadFile(accountId, file, dest, options, mode = null) {
71
82
  .catch(() => {
72
83
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, { file, dest }));
73
84
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadRetry`, { file, dest }));
74
- return (0, fileMapper_2.upload)(accountId, file, dest, apiOptions).catch((error) => {
75
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadFailed`, {
76
- file,
77
- dest,
78
- }));
79
- (0, apiErrors_1.throwApiUploadError)(error, {
80
- accountId,
81
- request: dest,
82
- payload: file,
83
- });
84
- });
85
+ return (0, fileMapper_2.upload)(accountId, file, dest, apiOptions).catch(onUploadFileError(file, dest, accountId));
85
86
  });
86
87
  });
87
88
  }
@@ -108,7 +109,7 @@ async function deleteRemoteFile(accountId, filePath, remoteFilePath) {
108
109
  });
109
110
  });
110
111
  }
111
- function watch(accountId, src, dest, { mode, remove, disableInitial, notify, commandOptions, filePaths, }, postInitialUploadCallback = null, onUploadFolderError, onQueueAddError) {
112
+ function watch(accountId, src, dest, { mode, remove, disableInitial, notify, commandOptions, filePaths, }, postInitialUploadCallback = null, onUploadFolderError, onQueueAddError, onUploadFileError) {
112
113
  const regex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(src)}`);
113
114
  if (notify) {
114
115
  (0, ignoreRules_1.ignoreFile)(notify);
@@ -145,7 +146,7 @@ function watch(accountId, src, dest, { mode, remove, disableInitial, notify, com
145
146
  const uploadPromise = uploadFile(accountId, filePath, destPath, {
146
147
  src,
147
148
  commandOptions,
148
- }, mode);
149
+ }, mode, onUploadFileError);
149
150
  (0, notify_1.triggerNotify)(notify, 'Added', filePath, uploadPromise);
150
151
  });
151
152
  if (remove) {
@@ -185,7 +186,7 @@ function watch(accountId, src, dest, { mode, remove, disableInitial, notify, com
185
186
  const uploadPromise = uploadFile(accountId, filePath, destPath, {
186
187
  src,
187
188
  commandOptions,
188
- }, mode);
189
+ }, mode, onUploadFileError);
189
190
  (0, notify_1.triggerNotify)(notify, 'Changed', filePath, uploadPromise);
190
191
  });
191
192
  return watcher;
@@ -1,4 +1,4 @@
1
- import { InitiateSyncResponse, Sandbox, SandboxType, SyncTask, Task, Usage } from '../types/Sandbox';
1
+ import { InitiateSyncResponse, Sandbox, SandboxType, SyncTaskStatusType, TaskRequestData, Usage } from '../types/Sandbox';
2
2
  export declare function createSandbox(accountId: number, name: string, type: 1 | 2): Promise<{
3
3
  name: string;
4
4
  sandbox: Sandbox;
@@ -9,6 +9,6 @@ export declare function deleteSandbox(parentAccountId: number, sandboxAccountId:
9
9
  sandboxAccountId: number;
10
10
  }>;
11
11
  export declare function getSandboxUsageLimits(parentAccountId: number): Promise<Usage | void>;
12
- export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<SyncTask>, sandboxHubId: number): Promise<InitiateSyncResponse>;
13
- export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<Task>;
12
+ export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): Promise<InitiateSyncResponse>;
13
+ export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<SyncTaskStatusType>;
14
14
  export declare function fetchTypes(accountId: number, toHubId: number): Promise<Array<SandboxType> | void>;
package/lib/sandboxes.js CHANGED
@@ -51,7 +51,8 @@ async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
51
51
  exports.initiateSync = initiateSync;
52
52
  async function fetchTaskStatus(accountId, taskId) {
53
53
  try {
54
- return await (0, sandboxSync_1.fetchTaskStatus)(accountId, taskId);
54
+ const result = await (0, sandboxSync_1.fetchTaskStatus)(accountId, taskId);
55
+ return result;
55
56
  }
56
57
  catch (err) {
57
58
  (0, apiErrors_1.throwApiError)(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "1.1.0",
3
+ "version": "1.3.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": {
@@ -47,13 +47,18 @@ type MutationError = {
47
47
  };
48
48
  };
49
49
  };
50
- type TaskStatus = {
50
+ export type SyncTaskStatusType = {
51
+ status: string;
52
+ result?: string;
53
+ tasks: Pick<CompositeSyncTask, 'type' | 'status'>[];
54
+ };
55
+ type SyncMutationData = {
51
56
  numRequests: number;
52
57
  numSuccesses: number;
53
58
  errors: Array<TaskError>;
54
59
  mutationErrors: Array<MutationError>;
55
60
  };
56
- export type Task = {
61
+ export type CompositeSyncTask = {
57
62
  id: string;
58
63
  parentHubId: number;
59
64
  sandboxHubId: number;
@@ -70,12 +75,29 @@ export type Task = {
70
75
  startedAt: string;
71
76
  completedAt: string;
72
77
  error: MutationError;
73
- creates: TaskStatus;
74
- updates: TaskStatus;
75
- deletes: TaskStatus;
78
+ creates: SyncMutationData;
79
+ updates: SyncMutationData;
80
+ deletes: SyncMutationData;
76
81
  diffSummary: string;
77
82
  portableKeys: Array<string>;
78
83
  };
84
+ export type SyncTask = {
85
+ id: string;
86
+ parentHubId: number;
87
+ sandboxHubId: number;
88
+ fromHubId: number;
89
+ toHubId: number;
90
+ command: string;
91
+ status: string;
92
+ result: string;
93
+ sandboxType: string;
94
+ requestedAt: string;
95
+ requestedByUserId: number;
96
+ requestedByUser: User;
97
+ startedAt: string;
98
+ completedAt: string;
99
+ tasks: Array<CompositeSyncTask>;
100
+ };
79
101
  export type Sandbox = {
80
102
  sandboxHubId: number;
81
103
  parentHubId: number;
@@ -88,23 +110,7 @@ export type Sandbox = {
88
110
  domain: string;
89
111
  createdByUser: User;
90
112
  updatedByUser?: User | null;
91
- lastSync?: {
92
- id: string;
93
- parentHubId: number;
94
- sandboxHubId: number;
95
- fromHubId: number;
96
- toHubId: number;
97
- command: string;
98
- status: string;
99
- result: string;
100
- sandboxType: string;
101
- requestedAt: string;
102
- requestedByUserId: number;
103
- requestedByUser: User;
104
- startedAt: string;
105
- completedAt: string;
106
- tasks: Array<Task>;
107
- };
113
+ lastSync?: SyncTask;
108
114
  currentUserHasAccess?: boolean;
109
115
  currentUserHasSuperAdminAccess?: boolean;
110
116
  requestAccessFrom?: User | null;
@@ -129,26 +135,14 @@ export type Usage = {
129
135
  export type SandboxUsageLimitsResponse = {
130
136
  usage: Usage;
131
137
  };
132
- export type SyncTask = {
138
+ export type TaskRequestData = {
133
139
  type: string;
134
140
  };
135
141
  export type InitiateSyncResponse = {
136
142
  links: {
137
143
  status: string;
138
144
  };
139
- sync: {
140
- id: string;
141
- parentHubId: number;
142
- sandboxHubId: number;
143
- fromHubId: number;
144
- toHubId: number;
145
- command: string;
146
- status: string;
147
- sandboxType: string;
148
- requestedAt: string;
149
- requestedByUserId: number;
150
- tasks: Array<Task>;
151
- };
145
+ sync: SyncTask;
152
146
  id: string;
153
147
  };
154
148
  export type SandboxType = {