@hubspot/local-dev-lib 0.0.4 → 0.0.6

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.
Files changed (178) hide show
  1. package/api/customObjects.d.ts +7 -0
  2. package/api/customObjects.js +48 -0
  3. package/api/designManager.d.ts +13 -0
  4. package/api/designManager.js +21 -0
  5. package/api/fileManager.d.ts +5 -0
  6. package/api/fileManager.js +62 -0
  7. package/api/fileMapper.d.ts +10 -0
  8. package/api/fileMapper.js +104 -0
  9. package/api/functions.d.ts +4 -0
  10. package/api/functions.js +32 -0
  11. package/api/hubdb.d.ts +10 -0
  12. package/api/hubdb.js +61 -0
  13. package/api/lighthouseScore.d.ts +5 -0
  14. package/api/lighthouseScore.js +29 -0
  15. package/api/localDevAuth.d.ts +12 -0
  16. package/api/localDevAuth.js +38 -0
  17. package/api/marketplaceValidation.d.ts +5 -0
  18. package/api/marketplaceValidation.js +29 -0
  19. package/api/projects.d.ts +27 -0
  20. package/api/projects.js +126 -0
  21. package/api/sandboxHubs.d.ts +6 -0
  22. package/api/sandboxHubs.js +50 -0
  23. package/api/sandboxSync.d.ts +4 -0
  24. package/api/sandboxSync.js +35 -0
  25. package/api/secrets.d.ts +8 -0
  26. package/api/secrets.js +40 -0
  27. package/api/validateHubl.d.ts +2 -0
  28. package/api/validateHubl.js +18 -0
  29. package/config/CLIConfiguration.d.ts +22 -16
  30. package/config/CLIConfiguration.js +39 -9
  31. package/config/configFile.d.ts +4 -4
  32. package/config/configFile.js +2 -2
  33. package/config/configUtils.d.ts +8 -8
  34. package/config/config_DEPRECATED.d.ts +78 -0
  35. package/config/config_DEPRECATED.js +636 -0
  36. package/config/environment.d.ts +2 -3
  37. package/config/environment.js +11 -17
  38. package/config/index.d.ts +38 -0
  39. package/config/index.js +232 -0
  40. package/constants/api.d.ts +17 -0
  41. package/constants/api.js +20 -0
  42. package/constants/auth.d.ts +13 -0
  43. package/constants/auth.js +8 -1
  44. package/constants/config.d.ts +0 -4
  45. package/constants/config.js +1 -5
  46. package/constants/environments.d.ts +1 -0
  47. package/constants/environments.js +1 -0
  48. package/constants/extensions.d.ts +2 -0
  49. package/constants/extensions.js +4 -1
  50. package/constants/files.d.ts +16 -0
  51. package/constants/files.js +17 -1
  52. package/enums/build.d.ts +36 -0
  53. package/enums/build.js +39 -0
  54. package/enums/deploy.d.ts +11 -0
  55. package/enums/deploy.js +14 -0
  56. package/enums/project.d.ts +6 -0
  57. package/enums/project.js +9 -0
  58. package/errors/HubSpotAuthError.d.ts +8 -2
  59. package/errors/HubSpotAuthError.js +14 -0
  60. package/errors/apiErrors.d.ts +9 -0
  61. package/errors/apiErrors.js +182 -0
  62. package/errors/errors_DEPRECATED.d.ts +7 -0
  63. package/errors/errors_DEPRECATED.js +73 -0
  64. package/errors/fileSystemErrors.d.ts +1 -7
  65. package/errors/standardErrors.d.ts +7 -1
  66. package/errors/standardErrors.js +20 -23
  67. package/http/getAxiosConfig.d.ts +6 -0
  68. package/http/getAxiosConfig.js +22 -0
  69. package/http/index.d.ts +18 -0
  70. package/http/index.js +175 -0
  71. package/lang/en.lyaml +247 -0
  72. package/lib/cms/functions.d.ts +13 -0
  73. package/lib/cms/functions.js +181 -0
  74. package/lib/cms/handleFieldsJS.d.ts +2 -1
  75. package/lib/cms/handleFieldsJS.js +4 -3
  76. package/lib/cms/modules.js +3 -3
  77. package/lib/cms/processFieldsJs.d.ts +1 -0
  78. package/lib/cms/processFieldsJs.js +122 -0
  79. package/lib/cms/templates.d.ts +25 -0
  80. package/lib/cms/templates.js +62 -0
  81. package/lib/cms/themes.js +2 -2
  82. package/lib/cms/uploadFolder.d.ts +18 -0
  83. package/lib/cms/uploadFolder.js +182 -0
  84. package/lib/cms/watch.d.ts +20 -0
  85. package/lib/cms/watch.js +194 -0
  86. package/lib/customObjects.d.ts +5 -0
  87. package/lib/customObjects.js +36 -0
  88. package/lib/environment.d.ts +2 -1
  89. package/lib/fileMapper.d.ts +13 -0
  90. package/lib/fileMapper.js +322 -0
  91. package/lib/github.d.ts +6 -3
  92. package/lib/github.js +36 -27
  93. package/lib/gitignore.js +1 -46
  94. package/lib/hubdb.d.ts +16 -0
  95. package/lib/hubdb.js +130 -0
  96. package/lib/ignoreRules.d.ts +3 -0
  97. package/lib/ignoreRules.js +69 -0
  98. package/lib/logging/git.d.ts +2 -0
  99. package/lib/logging/git.js +54 -0
  100. package/lib/logging/logger.d.ts +44 -0
  101. package/lib/logging/logger.js +146 -0
  102. package/lib/logging/logs.d.ts +22 -0
  103. package/lib/logging/logs.js +82 -0
  104. package/lib/logging/table.d.ts +3 -0
  105. package/lib/logging/table.js +47 -0
  106. package/lib/oauth.d.ts +7 -0
  107. package/lib/oauth.js +44 -0
  108. package/lib/path.d.ts +2 -1
  109. package/lib/path.js +8 -3
  110. package/lib/personalAccessKey.d.ts +13 -0
  111. package/lib/personalAccessKey.js +135 -0
  112. package/lib/sandboxes.d.ts +14 -0
  113. package/lib/sandboxes.js +71 -0
  114. package/lib/trackUsage.d.ts +1 -0
  115. package/lib/trackUsage.js +53 -0
  116. package/lib/validate.d.ts +2 -0
  117. package/lib/validate.js +40 -0
  118. package/models/OAuth2Manager.d.ts +34 -0
  119. package/models/OAuth2Manager.js +126 -0
  120. package/package.json +25 -13
  121. package/types/Accounts.d.ts +66 -21
  122. package/types/Activity.d.ts +20 -0
  123. package/types/Activity.js +2 -0
  124. package/types/Api.d.ts +2 -0
  125. package/types/Api.js +2 -0
  126. package/types/Build.d.ts +41 -0
  127. package/types/Build.js +2 -0
  128. package/types/CLIOptions.d.ts +5 -0
  129. package/types/ComponentStructure.d.ts +20 -0
  130. package/types/ComponentStructure.js +2 -0
  131. package/types/Config.d.ts +17 -4
  132. package/types/Deploy.d.ts +42 -0
  133. package/types/Deploy.js +2 -0
  134. package/types/Error.d.ts +32 -7
  135. package/types/FileManager.d.ts +66 -0
  136. package/types/FileManager.js +2 -0
  137. package/types/Files.d.ts +33 -1
  138. package/types/Functions.d.ts +40 -0
  139. package/types/Functions.js +2 -0
  140. package/types/Github.d.ts +6 -0
  141. package/types/Http.d.ts +33 -0
  142. package/types/Http.js +2 -0
  143. package/types/Hubdb.d.ts +90 -0
  144. package/types/Hubdb.js +2 -0
  145. package/types/HublValidation.d.ts +59 -0
  146. package/types/HublValidation.js +2 -0
  147. package/types/Lighthouse.d.ts +25 -0
  148. package/types/Lighthouse.js +2 -0
  149. package/types/MarketplaceValidation.d.ts +28 -0
  150. package/types/MarketplaceValidation.js +2 -0
  151. package/types/Project.d.ts +38 -0
  152. package/types/Project.js +2 -0
  153. package/types/Sandbox.d.ts +165 -0
  154. package/types/Sandbox.js +2 -0
  155. package/types/Schemas.d.ts +42 -0
  156. package/types/Schemas.js +2 -0
  157. package/utils/{modules.d.ts → cms/modules.d.ts} +1 -1
  158. package/utils/{modules.js → cms/modules.js} +3 -3
  159. package/utils/getAccountIdentifier.d.ts +10 -0
  160. package/utils/getAccountIdentifier.js +40 -0
  161. package/utils/git.d.ts +7 -2
  162. package/utils/git.js +54 -7
  163. package/utils/lang.d.ts +4 -0
  164. package/utils/lang.js +9 -2
  165. package/utils/notify.d.ts +1 -0
  166. package/utils/notify.js +42 -0
  167. package/utils/objectUtils.d.ts +8 -0
  168. package/utils/objectUtils.js +33 -0
  169. package/constants/index.d.ts +0 -16
  170. package/constants/index.js +0 -12
  171. package/http/requestOptions.d.ts +0 -20
  172. package/http/requestOptions.js +0 -27
  173. package/lib/cms/index.d.ts +0 -10
  174. package/lib/cms/index.js +0 -13
  175. package/lib/index.d.ts +0 -11
  176. package/lib/index.js +0 -14
  177. /package/utils/{fieldsJS.d.ts → cms/fieldsJS.d.ts} +0 -0
  178. /package/utils/{fieldsJS.js → cms/fieldsJS.js} +0 -0
@@ -0,0 +1,59 @@
1
+ export type HublValidationOptions = {
2
+ is_available_for_new_content?: boolean;
3
+ template_type?: string;
4
+ template_path?: string;
5
+ module_path?: string;
6
+ };
7
+ export type HubLValidationError = {
8
+ reason: string;
9
+ message: string;
10
+ lineno: number;
11
+ startPosition: number;
12
+ categoryErrors: {
13
+ fullName?: string;
14
+ path?: string;
15
+ };
16
+ category: string;
17
+ severity?: string;
18
+ };
19
+ export type LintResult = {
20
+ file: string;
21
+ validation: Validation | null;
22
+ };
23
+ export type Validation = {
24
+ meta: {
25
+ all_widgets: Array<string>;
26
+ widgets_in_rich_text: Array<string>;
27
+ editable_flex_areas: Array<string>;
28
+ editable_layout_sections: {
29
+ key: string;
30
+ } | null;
31
+ email_style_settings: {
32
+ key: string;
33
+ } | null;
34
+ sms_flex_area: Array<string>;
35
+ google_font_variations: {
36
+ key: string;
37
+ } | null;
38
+ custom_font_variations: Array<string>;
39
+ has_style_tag: boolean;
40
+ has_header_tag: boolean;
41
+ output_html: string;
42
+ has_menu_tag: boolean;
43
+ has_theme_setting_function: boolean;
44
+ template_source: string;
45
+ attribute_defaults?: {
46
+ key: string;
47
+ } | null;
48
+ template_errors: Array<HubLValidationError>;
49
+ path_dependencies: Array<string>;
50
+ theme_field_dependencies: Array<string>;
51
+ template_type_ids?: {
52
+ key: string;
53
+ } | null;
54
+ exact_path_references: Array<string>;
55
+ required_scopes_to_render: Array<string>;
56
+ };
57
+ renderingErrors: Array<HubLValidationError>;
58
+ html: string;
59
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ export type RequestLighthouseScoreResponse = {
2
+ desktopId: number;
3
+ mobileId: number;
4
+ };
5
+ export type GetLighthouseScoreResponse = {
6
+ portalId: number;
7
+ themePath: string;
8
+ status: string;
9
+ scores: [
10
+ {
11
+ accessibilityScore: number;
12
+ bestPracticesScore: number;
13
+ performanceScore: number;
14
+ pwaScore: number;
15
+ seoScore: number;
16
+ runWarnings: Array<string>;
17
+ auditDetails: null;
18
+ emulatedFormFactor: string;
19
+ templatePath: string | null;
20
+ link: string | null;
21
+ }
22
+ ];
23
+ failedTemplatePaths: Array<string>;
24
+ error: Error | null;
25
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,28 @@
1
+ type Check = {
2
+ check: string;
3
+ status: string;
4
+ title: string;
5
+ documentationLink: string;
6
+ message: string | null;
7
+ description: string;
8
+ line: number | null;
9
+ file: string;
10
+ };
11
+ export type GetValidationResultsResponse = {
12
+ validationRequestId: number;
13
+ assetPath: string;
14
+ assetType: string;
15
+ results: {
16
+ REQUIRED: {
17
+ status: string;
18
+ results: Array<Check>;
19
+ };
20
+ RECOMMENDED: {
21
+ status: string;
22
+ results: Array<Check>;
23
+ };
24
+ };
25
+ errors: Array<Error>;
26
+ requestedAt: string;
27
+ };
28
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,38 @@
1
+ import { Build } from './Build';
2
+ import { GithubSourceData } from './Github';
3
+ export type Project = {
4
+ createdAt: number;
5
+ deletedAt: number;
6
+ deployedBuild?: Build;
7
+ deployedBuildId?: number;
8
+ id: number;
9
+ isLocked: boolean;
10
+ latestBuild?: Build;
11
+ name: string;
12
+ portalId: number;
13
+ sourceIntegration?: GithubSourceData;
14
+ updatedAt: number;
15
+ };
16
+ export type FetchProjectResponse = {
17
+ results: Array<Project>;
18
+ };
19
+ export type UploadProjectResponse = {
20
+ buildId: number;
21
+ projectTree: {
22
+ path: string;
23
+ name: string;
24
+ parentPath: string;
25
+ updatedAt: number;
26
+ children: Array<UploadProjectResponse>;
27
+ folder: boolean;
28
+ };
29
+ buildStatusTaskLocator: {
30
+ id: string;
31
+ links: {
32
+ status: string;
33
+ };
34
+ };
35
+ };
36
+ export type ProjectSettings = {
37
+ isAutoDeployEnabled: boolean;
38
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,165 @@
1
+ export type SandboxHubData = {
2
+ type?: string | null;
3
+ parentHubId?: number;
4
+ };
5
+ type User = {
6
+ userId: number;
7
+ firstName: string;
8
+ lastName: string;
9
+ gdprDeleted: boolean;
10
+ removed: boolean;
11
+ deactivated: boolean;
12
+ };
13
+ type TaskError = {
14
+ message: string;
15
+ in: string;
16
+ code: string;
17
+ subCategory: string;
18
+ context: {
19
+ missingScopes: Array<string>;
20
+ };
21
+ };
22
+ type MutationError = {
23
+ message: string;
24
+ portableKey: string;
25
+ subResource: {
26
+ type: string;
27
+ key: string;
28
+ };
29
+ standardError: {
30
+ status: string;
31
+ id: string;
32
+ category: string;
33
+ subCategory: {
34
+ [key: string]: string;
35
+ };
36
+ message: string;
37
+ errors: Array<TaskError>;
38
+ context: {
39
+ additionalProp1: Array<string>;
40
+ additionalProp2: Array<string>;
41
+ additionalProp3: Array<string>;
42
+ };
43
+ links: {
44
+ additionalProp1: string;
45
+ additionalProp2: string;
46
+ additionalProp3: string;
47
+ };
48
+ };
49
+ };
50
+ type TaskStatus = {
51
+ numRequests: number;
52
+ numSuccesses: number;
53
+ errors: Array<TaskError>;
54
+ mutationErrors: Array<MutationError>;
55
+ };
56
+ export type Task = {
57
+ id: string;
58
+ parentHubId: number;
59
+ sandboxHubId: number;
60
+ fromHubId: number;
61
+ toHubId: number;
62
+ command: string;
63
+ type: string;
64
+ status: string;
65
+ result: string;
66
+ sandboxType: string;
67
+ requestedAt: string;
68
+ requestedByUserId: number;
69
+ requestedByUser: User;
70
+ startedAt: string;
71
+ completedAt: string;
72
+ error: MutationError;
73
+ creates: TaskStatus;
74
+ updates: TaskStatus;
75
+ deletes: TaskStatus;
76
+ diffSummary: string;
77
+ portableKeys: Array<string>;
78
+ };
79
+ export type Sandbox = {
80
+ sandboxHubId: number;
81
+ parentHubId: number;
82
+ createdAt: string;
83
+ updatedAt: string | null;
84
+ archivedAt: string | null;
85
+ type: string;
86
+ archived: boolean;
87
+ name: string;
88
+ domain: string;
89
+ createdByUser: User;
90
+ 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
+ };
108
+ currentUserHasAccess: boolean | null;
109
+ currentUserHasSuperAdminAccess: boolean | null;
110
+ requestAccessFrom: User | null;
111
+ superAdminsInSandbox: number | null;
112
+ };
113
+ export type SandboxResponse = {
114
+ sandbox: Sandbox;
115
+ personalAccessKey: string;
116
+ };
117
+ export type Usage = {
118
+ STANDARD: {
119
+ used: number;
120
+ available: number;
121
+ limit: number;
122
+ };
123
+ DEVELOPER: {
124
+ used: number;
125
+ available: number;
126
+ limit: number;
127
+ };
128
+ };
129
+ export type SandboxUsageLimitsResponse = {
130
+ usage: Usage;
131
+ };
132
+ export type SyncTask = {
133
+ type: string;
134
+ };
135
+ export type InitiateSyncResponse = {
136
+ links: {
137
+ status: string;
138
+ };
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
+ };
152
+ id: string;
153
+ };
154
+ export type SandboxType = {
155
+ name: string;
156
+ dependsOn: Array<string>;
157
+ pushToParentEnabled: boolean;
158
+ isBeta: boolean;
159
+ diffEnabled: boolean;
160
+ groupType: string;
161
+ };
162
+ export type FetchTypesResponse = {
163
+ results: Array<SandboxType>;
164
+ };
165
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,42 @@
1
+ export type Schema = {
2
+ id: string;
3
+ createdAt: string;
4
+ updatedAt: string | null;
5
+ properties?: [
6
+ {
7
+ updatedAt: string | null;
8
+ createdAt: string;
9
+ name: string;
10
+ label: string;
11
+ type: string;
12
+ fieldType: string;
13
+ groupName: string;
14
+ displayOrder: number;
15
+ calculated: boolean;
16
+ externalOptions: boolean;
17
+ archived: boolean;
18
+ hasUniqueValue: boolean;
19
+ }
20
+ ];
21
+ associations?: [
22
+ {
23
+ id: string;
24
+ fromObjectTypeId: string;
25
+ toObjectTypeId: string;
26
+ name: string;
27
+ }
28
+ ];
29
+ labels: {
30
+ singular: string;
31
+ plural: string;
32
+ };
33
+ requiredProperties: Array<string>;
34
+ searchableProperties: Array<string>;
35
+ primaryDisplayProperty: Array<string>;
36
+ metaType: string;
37
+ fullyQualifiedName: string;
38
+ name: string;
39
+ };
40
+ export type FetchSchemasResponse = {
41
+ results: Array<Schema>;
42
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { PathInput } from '../types/Modules';
1
+ import { PathInput } from '../../types/Modules';
2
2
  export declare function isPathInput(pathInput?: PathInput): boolean;
3
3
  export declare function isModuleFolder(pathInput: PathInput): boolean;
4
4
  export declare function isModuleFolderChild(pathInput: PathInput, ignoreLocales?: boolean): boolean;
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isModuleFolderChild = exports.isModuleFolder = exports.isPathInput = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const path_2 = require("../lib/path");
9
- const extensions_1 = require("../constants/extensions");
10
- const standardErrors_1 = require("../errors/standardErrors");
8
+ const path_2 = require("../../lib/path");
9
+ const extensions_1 = require("../../constants/extensions");
10
+ const standardErrors_1 = require("../../errors/standardErrors");
11
11
  const isBool = (x) => !!x === x;
12
12
  function isPathInput(pathInput) {
13
13
  return !!(pathInput &&
@@ -0,0 +1,10 @@
1
+ import { CLIAccount } from '../types/Accounts';
2
+ import { CLIConfig } from '../types/Config';
3
+ type Account = {
4
+ portalId?: number;
5
+ accountId?: number;
6
+ };
7
+ export declare function getAccountIdentifier(account?: Account | null): number | undefined;
8
+ export declare function getAccounts(config?: CLIConfig | null): Array<CLIAccount>;
9
+ export declare function getDefaultAccount(config?: CLIConfig | null): string | number | undefined;
10
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultAccount = exports.getAccounts = exports.getAccountIdentifier = void 0;
4
+ function getAccountIdentifier(account) {
5
+ if (!account) {
6
+ return undefined;
7
+ }
8
+ else if (Object.hasOwn(account, 'portalId')) {
9
+ return account.portalId;
10
+ }
11
+ else if (Object.hasOwn(account, 'accountId')) {
12
+ return account.accountId;
13
+ }
14
+ }
15
+ exports.getAccountIdentifier = getAccountIdentifier;
16
+ function getAccounts(config) {
17
+ if (!config) {
18
+ return [];
19
+ }
20
+ else if (Object.hasOwn(config, 'portals')) {
21
+ return config.portals;
22
+ }
23
+ else if (Object.hasOwn(config, 'accounts')) {
24
+ return config.accounts;
25
+ }
26
+ return [];
27
+ }
28
+ exports.getAccounts = getAccounts;
29
+ function getDefaultAccount(config) {
30
+ if (!config) {
31
+ return undefined;
32
+ }
33
+ else if (Object.hasOwn(config, 'defaultPortal')) {
34
+ return config.defaultPortal;
35
+ }
36
+ else if (Object.hasOwn(config, 'defaultAccount')) {
37
+ return config.defaultAccount;
38
+ }
39
+ }
40
+ exports.getDefaultAccount = getDefaultAccount;
package/utils/git.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- export declare function makeComparisonDir(filepath: string | null): string | null;
2
- export declare const getGitComparisonDir: () => string | null;
3
1
  export declare function isConfigPathInGitRepo(configPath: string): boolean;
4
2
  export declare function configFilenameIsIgnoredByGitignore(ignoreFiles: Array<string>, configPath: string): boolean;
3
+ type GitInclusionResult = {
4
+ inGit: boolean;
5
+ configIgnored: boolean;
6
+ gitignoreFiles: Array<string>;
7
+ };
8
+ export declare function checkGitInclusion(configPath: string): GitInclusionResult;
9
+ export {};
package/utils/git.js CHANGED
@@ -3,22 +3,52 @@ 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.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = exports.getGitComparisonDir = exports.makeComparisonDir = void 0;
7
- const fs_extra_1 = require("fs-extra");
6
+ exports.checkGitInclusion = exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = void 0;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const ignore_1 = __importDefault(require("ignore"));
10
10
  const findup_sync_1 = __importDefault(require("findup-sync"));
11
+ const GITIGNORE_FILE = '.gitignore';
11
12
  function makeComparisonDir(filepath) {
12
13
  if (typeof filepath !== 'string')
13
14
  return null;
14
15
  // Append sep to make comparisons easier e.g. 'foos'.startsWith('foo')
15
16
  return path_1.default.dirname(path_1.default.resolve(filepath)).toLowerCase() + path_1.default.sep;
16
17
  }
17
- exports.makeComparisonDir = makeComparisonDir;
18
- const getGitComparisonDir = () => makeComparisonDir((0, findup_sync_1.default)('.git'));
19
- exports.getGitComparisonDir = getGitComparisonDir;
18
+ function getGitComparisonDir() {
19
+ return makeComparisonDir((0, findup_sync_1.default)('.git'));
20
+ }
21
+ // Get all .gitignore files since they can cascade down directory structures
22
+ function getGitignoreFiles(configPath) {
23
+ const gitDir = getGitComparisonDir();
24
+ const files = [];
25
+ if (!gitDir) {
26
+ // Not in git
27
+ return files;
28
+ }
29
+ // Start findup from config dir
30
+ let cwd = configPath && path_1.default.dirname(configPath);
31
+ while (cwd) {
32
+ const ignorePath = (0, findup_sync_1.default)(GITIGNORE_FILE, { cwd });
33
+ const cmpIgnorePath = makeComparisonDir(ignorePath);
34
+ const cmpGitDir = makeComparisonDir(gitDir);
35
+ if (ignorePath &&
36
+ cmpIgnorePath &&
37
+ cmpGitDir &&
38
+ // Stop findup after .git dir is reached
39
+ cmpIgnorePath.startsWith(cmpGitDir)) {
40
+ const file = path_1.default.resolve(ignorePath);
41
+ files.push(file);
42
+ cwd = path_1.default.resolve(path_1.default.dirname(file) + '..');
43
+ }
44
+ else {
45
+ cwd = null;
46
+ }
47
+ }
48
+ return files;
49
+ }
20
50
  function isConfigPathInGitRepo(configPath) {
21
- const gitDir = (0, exports.getGitComparisonDir)();
51
+ const gitDir = getGitComparisonDir();
22
52
  if (!gitDir)
23
53
  return false;
24
54
  const configDir = makeComparisonDir(configPath);
@@ -29,7 +59,7 @@ function isConfigPathInGitRepo(configPath) {
29
59
  exports.isConfigPathInGitRepo = isConfigPathInGitRepo;
30
60
  function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
31
61
  return ignoreFiles.some(gitignore => {
32
- const gitignoreContents = (0, fs_extra_1.readFileSync)(gitignore).toString();
62
+ const gitignoreContents = fs_extra_1.default.readFileSync(gitignore).toString();
33
63
  const gitignoreConfig = (0, ignore_1.default)().add(gitignoreContents);
34
64
  if (gitignoreConfig.ignores(path_1.default.relative(path_1.default.dirname(gitignore), configPath))) {
35
65
  return true;
@@ -38,3 +68,20 @@ function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
38
68
  });
39
69
  }
40
70
  exports.configFilenameIsIgnoredByGitignore = configFilenameIsIgnoredByGitignore;
71
+ function checkGitInclusion(configPath) {
72
+ const result = {
73
+ inGit: false,
74
+ configIgnored: false,
75
+ gitignoreFiles: [],
76
+ };
77
+ if (isConfigPathInGitRepo(configPath)) {
78
+ result.inGit = true;
79
+ result.gitignoreFiles = getGitignoreFiles(configPath);
80
+ if (configFilenameIsIgnoredByGitignore(result.gitignoreFiles, configPath)) {
81
+ // Found ignore statement in .gitignore that matches config filename
82
+ result.configIgnored = true;
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+ exports.checkGitInclusion = checkGitInclusion;
package/utils/lang.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ type LanguageObject = {
2
+ [key: string]: LanguageObject | string;
3
+ };
1
4
  type InterpolationData = {
2
5
  [identifier: string]: string | number;
3
6
  };
@@ -5,4 +8,5 @@ export declare function interpolate(stringValue: string, interpolationData: Inte
5
8
  export declare function i18n(lookupDotNotation: string, options?: {
6
9
  [identifier: string]: string | number;
7
10
  }): string;
11
+ export declare const setLangData: (newLocale: string, newLangObj: LanguageObject) => void;
8
12
  export {};
package/utils/lang.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.i18n = exports.interpolate = void 0;
3
+ exports.setLangData = exports.i18n = exports.interpolate = void 0;
4
4
  const path_1 = require("path");
5
5
  const fs_extra_1 = require("fs-extra");
6
6
  const js_yaml_1 = require("js-yaml");
@@ -72,6 +72,9 @@ function interpolate(stringValue, interpolationData) {
72
72
  }
73
73
  exports.interpolate = interpolate;
74
74
  function i18n(lookupDotNotation, options = {}) {
75
+ if (!languageObj) {
76
+ loadLanguageFromYaml();
77
+ }
75
78
  if (typeof lookupDotNotation !== 'string') {
76
79
  throw new Error(`i18n must be passed a string value for lookupDotNotation, received ${typeof lookupDotNotation}`);
77
80
  }
@@ -80,4 +83,8 @@ function i18n(lookupDotNotation, options = {}) {
80
83
  return shouldInterpolate ? interpolate(textValue, options) : textValue;
81
84
  }
82
85
  exports.i18n = i18n;
83
- loadLanguageFromYaml();
86
+ const setLangData = (newLocale, newLangObj) => {
87
+ locale = newLocale;
88
+ languageObj = newLangObj;
89
+ };
90
+ exports.setLangData = setLangData;
@@ -0,0 +1 @@
1
+ export declare function triggerNotify(filePathToNotify: string | undefined, actionType: string, filePath: string, actionPromise: Promise<void>): void;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.triggerNotify = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const moment_1 = __importDefault(require("moment"));
9
+ const debounce_1 = __importDefault(require("debounce"));
10
+ const standardErrors_1 = require("../errors/standardErrors");
11
+ const notifyQueue = [];
12
+ const notifyPromises = [];
13
+ const debouncedWaitForActionsToCompleteAndWriteQueueToFile = (0, debounce_1.default)(waitForActionsToCompleteAndWriteQueueToFile, 500);
14
+ // Collects actions that have been taken on files and the corresponding Promise
15
+ // for the remote action that is in-process
16
+ function triggerNotify(filePathToNotify, actionType, filePath, actionPromise) {
17
+ if (filePathToNotify) {
18
+ notifyQueue.push(`${(0, moment_1.default)().toISOString()} ${actionType}: ${filePath}\n`);
19
+ notifyPromises.push(actionPromise);
20
+ debouncedWaitForActionsToCompleteAndWriteQueueToFile(filePathToNotify);
21
+ }
22
+ }
23
+ exports.triggerNotify = triggerNotify;
24
+ // Clears both the notifyQueue and notifyPromises array, generates the output
25
+ // string that will be eventually logged, and waits for all promises currently
26
+ // in the notifyPromises array to resolve before logging the output
27
+ function waitForActionsToCompleteAndWriteQueueToFile(filePathToNotify) {
28
+ const actionOutput = notifyQueue.splice(0, notifyQueue.length).join('');
29
+ const allNotifyPromisesResolution = Promise.all(notifyPromises.splice(0, notifyPromises.length));
30
+ allNotifyPromisesResolution.then(() => notifyFilePath(filePathToNotify, actionOutput));
31
+ }
32
+ // Logs output to the "notify" file
33
+ function notifyFilePath(filePathToNotify, outputToWrite) {
34
+ if (filePathToNotify) {
35
+ try {
36
+ fs_1.default.appendFileSync(filePathToNotify, outputToWrite);
37
+ }
38
+ catch (e) {
39
+ (0, standardErrors_1.throwErrorWithMessage)('utils.notify.filePath', { filePath: filePathToNotify }, e);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,8 @@
1
+ export declare function isObject(value: object): boolean;
2
+ export declare function mergeDeep(target: {
3
+ [key: string]: any;
4
+ }, ...sources: Array<{
5
+ [key: string]: any;
6
+ }>): {
7
+ [key: string]: any;
8
+ };