@hubspot/local-dev-lib 0.1.7-experimental.0 → 0.1.9-experimental.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/customObjects.d.ts +1 -2
- package/config/migrate.d.ts +7 -0
- package/config/migrate.js +144 -0
- package/constants/config.d.ts +1 -0
- package/constants/config.js +6 -1
- package/lang/en.json +6 -0
- package/lib/github.d.ts +3 -0
- package/lib/github.js +9 -3
- package/package.json +2 -2
- package/types/Github.d.ts +1 -0
- package/types/Schemas.d.ts +23 -0
- package/types/CustomObject.d.ts +0 -23
- package/types/CustomObject.js +0 -2
package/api/customObjects.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FetchSchemasResponse, Schema, SchemaDefinition, CreateObjectsResponse } from '../types/Schemas';
|
|
1
|
+
import { FetchSchemasResponse, Schema, SchemaDefinition, ObjectDefinition, CreateObjectsResponse } from '../types/Schemas';
|
|
2
2
|
import { HubSpotPromise } from '../types/Http';
|
|
3
|
-
import { ObjectDefinition } from '../types/CustomObject';
|
|
4
3
|
export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: ObjectDefinition): HubSpotPromise<CreateObjectsResponse>;
|
|
5
4
|
export declare function createObjectSchema(accountId: number, schema: SchemaDefinition): HubSpotPromise<Schema>;
|
|
6
5
|
export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: SchemaDefinition): HubSpotPromise<Schema>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CLIConfig, CLIConfig_DEPRECATED, CLIConfig_NEW } from '../types/Config';
|
|
2
|
+
export declare function getConfig(useHiddenConfig?: boolean): Partial<CLIConfig> | null;
|
|
3
|
+
export declare function getConfigPath(path?: string, useHiddenConfig?: boolean): string | null;
|
|
4
|
+
export declare function configFileExists(useHiddenConfig?: boolean, configPath?: string): boolean;
|
|
5
|
+
export declare function deleteConfigFile(useHiddenConfig?: boolean): void;
|
|
6
|
+
export declare function migrateConfig(deprecatedConfig: CLIConfig_DEPRECATED | null): void;
|
|
7
|
+
export declare function mergeExistingConfigs(globalConfig: CLIConfig_NEW, deprecatedConfig: CLIConfig_DEPRECATED): void;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.mergeExistingConfigs = exports.migrateConfig = exports.deleteConfigFile = exports.configFileExists = exports.getConfigPath = exports.getConfig = void 0;
|
|
27
|
+
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
28
|
+
const CLIConfiguration_1 = require("./CLIConfiguration");
|
|
29
|
+
const index_1 = require("./index");
|
|
30
|
+
const configFile_1 = require("./configFile");
|
|
31
|
+
const config_1 = require("../constants/config");
|
|
32
|
+
const lang_1 = require("../utils/lang");
|
|
33
|
+
const logger_1 = require("../lib/logger");
|
|
34
|
+
const i18nKey = 'config.migrate';
|
|
35
|
+
function getConfig(useHiddenConfig = false) {
|
|
36
|
+
if (useHiddenConfig) {
|
|
37
|
+
return CLIConfiguration_1.CLIConfiguration.config;
|
|
38
|
+
}
|
|
39
|
+
return config_DEPRECATED.getAndLoadConfigIfNeeded();
|
|
40
|
+
}
|
|
41
|
+
exports.getConfig = getConfig;
|
|
42
|
+
function getConfigPath(path, useHiddenConfig = false) {
|
|
43
|
+
if (useHiddenConfig) {
|
|
44
|
+
return (0, configFile_1.getConfigFilePath)();
|
|
45
|
+
}
|
|
46
|
+
return config_DEPRECATED.getConfigPath(path);
|
|
47
|
+
}
|
|
48
|
+
exports.getConfigPath = getConfigPath;
|
|
49
|
+
function configFileExists(useHiddenConfig, configPath) {
|
|
50
|
+
return useHiddenConfig
|
|
51
|
+
? (0, configFile_1.configFileExists)()
|
|
52
|
+
: Boolean(config_DEPRECATED.getConfigPath(configPath));
|
|
53
|
+
}
|
|
54
|
+
exports.configFileExists = configFileExists;
|
|
55
|
+
function deleteConfigFile(useHiddenConfig = false) {
|
|
56
|
+
if (useHiddenConfig) {
|
|
57
|
+
(0, configFile_1.deleteConfigFile)();
|
|
58
|
+
}
|
|
59
|
+
config_DEPRECATED.deleteConfigFile();
|
|
60
|
+
}
|
|
61
|
+
exports.deleteConfigFile = deleteConfigFile;
|
|
62
|
+
function writeGlobalConfigFile(updatedConfig) {
|
|
63
|
+
const updatedConfigJson = JSON.stringify(updatedConfig);
|
|
64
|
+
(0, index_1.createEmptyConfigFile)({}, true);
|
|
65
|
+
(0, index_1.loadConfig)('');
|
|
66
|
+
try {
|
|
67
|
+
(0, index_1.writeConfig)({ source: updatedConfigJson });
|
|
68
|
+
deleteConfigFile();
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
(0, index_1.deleteEmptyConfigFile)();
|
|
72
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.writeConfig`, { configPath: config_1.GLOBAL_CONFIG_PATH }), { cause: error });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function migrateConfig(deprecatedConfig) {
|
|
76
|
+
if (!deprecatedConfig) {
|
|
77
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noDefaultConfig`));
|
|
78
|
+
}
|
|
79
|
+
const { defaultPortal, portals, ...rest } = deprecatedConfig;
|
|
80
|
+
const updatedConfig = {
|
|
81
|
+
...rest,
|
|
82
|
+
defaultAccount: defaultPortal,
|
|
83
|
+
accounts: portals
|
|
84
|
+
.filter(({ portalId }) => portalId !== undefined)
|
|
85
|
+
.map(({ portalId, ...rest }) => ({
|
|
86
|
+
...rest,
|
|
87
|
+
accountId: portalId,
|
|
88
|
+
})),
|
|
89
|
+
};
|
|
90
|
+
writeGlobalConfigFile(updatedConfig);
|
|
91
|
+
}
|
|
92
|
+
exports.migrateConfig = migrateConfig;
|
|
93
|
+
function mergeConfigPropertes(globalConfig, deprecatedConfig) {
|
|
94
|
+
const propertiesToCheck = [
|
|
95
|
+
'defaultCmsPublishMode',
|
|
96
|
+
'httpTimeout',
|
|
97
|
+
'allowUsageTracking',
|
|
98
|
+
'env',
|
|
99
|
+
];
|
|
100
|
+
const conflicts = [];
|
|
101
|
+
propertiesToCheck.forEach(prop => {
|
|
102
|
+
if (prop in globalConfig && prop in deprecatedConfig) {
|
|
103
|
+
if (globalConfig[prop] !== deprecatedConfig[prop]) {
|
|
104
|
+
conflicts.push({
|
|
105
|
+
property: prop,
|
|
106
|
+
oldValue: deprecatedConfig[prop],
|
|
107
|
+
newValue: globalConfig[prop],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// @ts-expect-error TODO
|
|
113
|
+
globalConfig[prop] = deprecatedConfig[prop];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (conflicts.length > 0) {
|
|
117
|
+
logger_1.logger.log(`The following properties have different values in the deprecated and global config files:\n${conflicts
|
|
118
|
+
.map(({ property, oldValue, newValue }) => `${property}: ${oldValue} (deprecated) vs ${newValue} (global)`)
|
|
119
|
+
.join('\n')}`);
|
|
120
|
+
return globalConfig;
|
|
121
|
+
}
|
|
122
|
+
return globalConfig;
|
|
123
|
+
}
|
|
124
|
+
function mergeAccounts(globalConfig, deprecatedConfig) {
|
|
125
|
+
if (globalConfig.accounts && deprecatedConfig.portals) {
|
|
126
|
+
const existingPortalIds = new Set(globalConfig.accounts.map(account => account.accountId));
|
|
127
|
+
const newAccounts = deprecatedConfig.portals
|
|
128
|
+
.filter(portal => !existingPortalIds.has(portal.portalId))
|
|
129
|
+
.map(({ portalId, ...rest }) => ({
|
|
130
|
+
...rest,
|
|
131
|
+
accountId: portalId,
|
|
132
|
+
}));
|
|
133
|
+
if (newAccounts.length > 0) {
|
|
134
|
+
globalConfig.accounts.push(...newAccounts);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return globalConfig;
|
|
138
|
+
}
|
|
139
|
+
function mergeExistingConfigs(globalConfig, deprecatedConfig) {
|
|
140
|
+
const updatedConfig = mergeConfigPropertes(globalConfig, deprecatedConfig);
|
|
141
|
+
const finalConfig = mergeAccounts(updatedConfig, deprecatedConfig);
|
|
142
|
+
writeGlobalConfigFile(finalConfig);
|
|
143
|
+
}
|
|
144
|
+
exports.mergeExistingConfigs = mergeExistingConfigs;
|
package/constants/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
|
|
2
2
|
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
|
|
3
3
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
|
+
export declare const GLOBAL_CONFIG_PATH: string;
|
|
4
5
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = ".hsaccount";
|
|
5
6
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID";
|
|
6
7
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND";
|
package/constants/config.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
6
|
+
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
4
7
|
const lang_1 = require("../utils/lang");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
5
9
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
6
10
|
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
|
|
7
11
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
12
|
+
exports.GLOBAL_CONFIG_PATH = `${os_1.default.homedir()}/${exports.HUBSPOT_CONFIGURATION_FOLDER}/${exports.HUBSPOT_CONFIGURATION_FILE}`;
|
|
8
13
|
exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = '.hsaccount';
|
|
9
14
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID';
|
|
10
15
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND';
|
package/lang/en.json
CHANGED
|
@@ -311,6 +311,12 @@
|
|
|
311
311
|
"missingEnv": "Unable to load config from environment variables: Missing env",
|
|
312
312
|
"unknownAuthType": "Unable to load config from environment variables: Unknown auth type"
|
|
313
313
|
}
|
|
314
|
+
},
|
|
315
|
+
"migrate": {
|
|
316
|
+
"errors": {
|
|
317
|
+
"writeConfig": "Unable to write global configuration file at {{ configPath }}",
|
|
318
|
+
"noDefaultConfig": "No default configuration file found. Skipping migration to global config."
|
|
319
|
+
}
|
|
314
320
|
}
|
|
315
321
|
},
|
|
316
322
|
"models": {
|
package/lib/github.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { GithubReleaseData, GithubRepoFile, RepoPath, CloneGithubRepoOptions } from '../types/Github';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `fetchRepoFile` instead - this util is a thin wrapper around it
|
|
5
|
+
*/
|
|
3
6
|
export declare function fetchFileFromRepository<T = Buffer>(repoPath: RepoPath, filePath: string, ref: string): Promise<T>;
|
|
4
7
|
export declare function fetchReleaseData(repoPath: RepoPath, tag?: string): Promise<GithubReleaseData>;
|
|
5
8
|
export declare function cloneGithubRepo(repoPath: RepoPath, dest: string, options?: CloneGithubRepoOptions): Promise<boolean>;
|
package/lib/github.js
CHANGED
|
@@ -12,6 +12,9 @@ const github_1 = require("../api/github");
|
|
|
12
12
|
const lang_1 = require("../utils/lang");
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const i18nKey = 'lib.github';
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `fetchRepoFile` instead - this util is a thin wrapper around it
|
|
17
|
+
*/
|
|
15
18
|
async function fetchFileFromRepository(repoPath, filePath, ref) {
|
|
16
19
|
try {
|
|
17
20
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.fetchFileFromRepository.fetching`, {
|
|
@@ -75,14 +78,17 @@ async function downloadGithubRepoZip(repoPath, isRelease = false, options = {})
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
async function cloneGithubRepo(repoPath, dest, options = {}) {
|
|
78
|
-
const { tag, isRelease, branch, sourceDir, type } = options;
|
|
81
|
+
const { tag, isRelease, branch, sourceDir, type, hideLogs } = options;
|
|
79
82
|
const zip = await downloadGithubRepoZip(repoPath, isRelease, {
|
|
80
83
|
tag,
|
|
81
84
|
branch,
|
|
82
85
|
});
|
|
83
86
|
const repoName = repoPath.split('/')[1];
|
|
84
|
-
const success = await (0, archive_1.extractZipArchive)(zip, repoName, dest, {
|
|
85
|
-
|
|
87
|
+
const success = await (0, archive_1.extractZipArchive)(zip, repoName, dest, {
|
|
88
|
+
sourceDir,
|
|
89
|
+
hideLogs,
|
|
90
|
+
});
|
|
91
|
+
if (success && !hideLogs) {
|
|
86
92
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.cloneGithubRepo.success`, {
|
|
87
93
|
type: type || '',
|
|
88
94
|
dest,
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9-experimental.0",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "https://github.com/HubSpot/hubspot-local-dev-lib"
|
|
@@ -51,6 +50,7 @@
|
|
|
51
50
|
"./http": "./http/index.js",
|
|
52
51
|
"./http/*": "./http/*.js",
|
|
53
52
|
"./config/getAccountIdentifier": "./config/getAccountIdentifier.js",
|
|
53
|
+
"./config/migrate": "./config/migrate.js",
|
|
54
54
|
"./config": "./config/index.js",
|
|
55
55
|
"./constants/*": "./constants/*.js",
|
|
56
56
|
"./models/*": "./models/*.js",
|
package/types/Github.d.ts
CHANGED
package/types/Schemas.d.ts
CHANGED
|
@@ -58,3 +58,26 @@ export type SchemaDefinition = {
|
|
|
58
58
|
];
|
|
59
59
|
requiredProperties: Array<string>;
|
|
60
60
|
};
|
|
61
|
+
export type ObjectDefinition = {
|
|
62
|
+
inputs: [
|
|
63
|
+
{
|
|
64
|
+
associations?: [
|
|
65
|
+
{
|
|
66
|
+
types: [
|
|
67
|
+
{
|
|
68
|
+
associationCategory: string;
|
|
69
|
+
associationTypeId: number;
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
to: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
objectWriteTraceId?: number;
|
|
78
|
+
properties: {
|
|
79
|
+
[key: string]: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
};
|
package/types/CustomObject.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type ObjectDefinition = {
|
|
2
|
-
inputs: [
|
|
3
|
-
{
|
|
4
|
-
associations?: [
|
|
5
|
-
{
|
|
6
|
-
types: [
|
|
7
|
-
{
|
|
8
|
-
associationCategory: string;
|
|
9
|
-
associationTypeId: number;
|
|
10
|
-
}
|
|
11
|
-
];
|
|
12
|
-
to: {
|
|
13
|
-
id: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
];
|
|
17
|
-
objectWriteTraceId?: number;
|
|
18
|
-
properties: {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
};
|
package/types/CustomObject.js
DELETED