@hubspot/local-dev-lib 3.0.2 → 3.1.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 +2 -2
- package/api/projects.js +22 -1
- package/config/config_DEPRECATED.js +4 -0
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +8 -4
- package/package.json +1 -1
- package/types/Accounts.d.ts +2 -0
- package/types/Project.d.ts +4 -0
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
|
-
|
|
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
package/types/Accounts.d.ts
CHANGED