@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.
- package/api/customObjects.d.ts +7 -0
- package/api/customObjects.js +48 -0
- package/api/designManager.d.ts +13 -0
- package/api/designManager.js +21 -0
- package/api/fileManager.d.ts +5 -0
- package/api/fileManager.js +62 -0
- package/api/fileMapper.d.ts +10 -0
- package/api/fileMapper.js +104 -0
- package/api/functions.d.ts +4 -0
- package/api/functions.js +32 -0
- package/api/hubdb.d.ts +10 -0
- package/api/hubdb.js +61 -0
- package/api/lighthouseScore.d.ts +5 -0
- package/api/lighthouseScore.js +29 -0
- package/api/localDevAuth.d.ts +12 -0
- package/api/localDevAuth.js +38 -0
- package/api/marketplaceValidation.d.ts +5 -0
- package/api/marketplaceValidation.js +29 -0
- package/api/projects.d.ts +27 -0
- package/api/projects.js +126 -0
- package/api/sandboxHubs.d.ts +6 -0
- package/api/sandboxHubs.js +50 -0
- package/api/sandboxSync.d.ts +4 -0
- package/api/sandboxSync.js +35 -0
- package/api/secrets.d.ts +8 -0
- package/api/secrets.js +40 -0
- package/api/validateHubl.d.ts +2 -0
- package/api/validateHubl.js +18 -0
- package/config/CLIConfiguration.d.ts +22 -16
- package/config/CLIConfiguration.js +39 -9
- package/config/configFile.d.ts +4 -4
- package/config/configFile.js +2 -2
- package/config/configUtils.d.ts +8 -8
- package/config/config_DEPRECATED.d.ts +78 -0
- package/config/config_DEPRECATED.js +636 -0
- package/config/environment.d.ts +2 -3
- package/config/environment.js +11 -17
- package/config/index.d.ts +38 -0
- package/config/index.js +232 -0
- package/constants/api.d.ts +17 -0
- package/constants/api.js +20 -0
- package/constants/auth.d.ts +13 -0
- package/constants/auth.js +8 -1
- package/constants/config.d.ts +0 -4
- package/constants/config.js +1 -5
- package/constants/environments.d.ts +1 -0
- package/constants/environments.js +1 -0
- package/constants/extensions.d.ts +2 -0
- package/constants/extensions.js +4 -1
- package/constants/files.d.ts +16 -0
- package/constants/files.js +17 -1
- package/enums/build.d.ts +36 -0
- package/enums/build.js +39 -0
- package/enums/deploy.d.ts +11 -0
- package/enums/deploy.js +14 -0
- package/enums/project.d.ts +6 -0
- package/enums/project.js +9 -0
- package/errors/HubSpotAuthError.d.ts +8 -2
- package/errors/HubSpotAuthError.js +14 -0
- package/errors/apiErrors.d.ts +9 -0
- package/errors/apiErrors.js +182 -0
- package/errors/errors_DEPRECATED.d.ts +7 -0
- package/errors/errors_DEPRECATED.js +73 -0
- package/errors/fileSystemErrors.d.ts +1 -7
- package/errors/standardErrors.d.ts +7 -1
- package/errors/standardErrors.js +20 -23
- package/http/getAxiosConfig.d.ts +6 -0
- package/http/getAxiosConfig.js +22 -0
- package/http/index.d.ts +18 -0
- package/http/index.js +175 -0
- package/lang/en.lyaml +247 -0
- package/lib/cms/functions.d.ts +13 -0
- package/lib/cms/functions.js +181 -0
- package/lib/cms/handleFieldsJS.d.ts +2 -1
- package/lib/cms/handleFieldsJS.js +4 -3
- package/lib/cms/modules.js +3 -3
- package/lib/cms/processFieldsJs.d.ts +1 -0
- package/lib/cms/processFieldsJs.js +122 -0
- package/lib/cms/templates.d.ts +25 -0
- package/lib/cms/templates.js +62 -0
- package/lib/cms/themes.js +2 -2
- package/lib/cms/uploadFolder.d.ts +18 -0
- package/lib/cms/uploadFolder.js +182 -0
- package/lib/cms/watch.d.ts +20 -0
- package/lib/cms/watch.js +194 -0
- package/lib/customObjects.d.ts +5 -0
- package/lib/customObjects.js +36 -0
- package/lib/environment.d.ts +2 -1
- package/lib/fileMapper.d.ts +13 -0
- package/lib/fileMapper.js +322 -0
- package/lib/github.d.ts +6 -3
- package/lib/github.js +36 -27
- package/lib/gitignore.js +1 -46
- package/lib/hubdb.d.ts +16 -0
- package/lib/hubdb.js +130 -0
- package/lib/ignoreRules.d.ts +3 -0
- package/lib/ignoreRules.js +69 -0
- package/lib/logging/git.d.ts +2 -0
- package/lib/logging/git.js +54 -0
- package/lib/logging/logger.d.ts +44 -0
- package/lib/logging/logger.js +146 -0
- package/lib/logging/logs.d.ts +22 -0
- package/lib/logging/logs.js +82 -0
- package/lib/logging/table.d.ts +3 -0
- package/lib/logging/table.js +47 -0
- package/lib/oauth.d.ts +7 -0
- package/lib/oauth.js +44 -0
- package/lib/path.d.ts +2 -1
- package/lib/path.js +8 -3
- package/lib/personalAccessKey.d.ts +13 -0
- package/lib/personalAccessKey.js +135 -0
- package/lib/sandboxes.d.ts +14 -0
- package/lib/sandboxes.js +71 -0
- package/lib/trackUsage.d.ts +1 -0
- package/lib/trackUsage.js +53 -0
- package/lib/validate.d.ts +2 -0
- package/lib/validate.js +40 -0
- package/models/OAuth2Manager.d.ts +34 -0
- package/models/OAuth2Manager.js +126 -0
- package/package.json +25 -13
- package/types/Accounts.d.ts +66 -21
- package/types/Activity.d.ts +20 -0
- package/types/Activity.js +2 -0
- package/types/Api.d.ts +2 -0
- package/types/Api.js +2 -0
- package/types/Build.d.ts +41 -0
- package/types/Build.js +2 -0
- package/types/CLIOptions.d.ts +5 -0
- package/types/ComponentStructure.d.ts +20 -0
- package/types/ComponentStructure.js +2 -0
- package/types/Config.d.ts +17 -4
- package/types/Deploy.d.ts +42 -0
- package/types/Deploy.js +2 -0
- package/types/Error.d.ts +32 -7
- package/types/FileManager.d.ts +66 -0
- package/types/FileManager.js +2 -0
- package/types/Files.d.ts +33 -1
- package/types/Functions.d.ts +40 -0
- package/types/Functions.js +2 -0
- package/types/Github.d.ts +6 -0
- package/types/Http.d.ts +33 -0
- package/types/Http.js +2 -0
- package/types/Hubdb.d.ts +90 -0
- package/types/Hubdb.js +2 -0
- package/types/HublValidation.d.ts +59 -0
- package/types/HublValidation.js +2 -0
- package/types/Lighthouse.d.ts +25 -0
- package/types/Lighthouse.js +2 -0
- package/types/MarketplaceValidation.d.ts +28 -0
- package/types/MarketplaceValidation.js +2 -0
- package/types/Project.d.ts +38 -0
- package/types/Project.js +2 -0
- package/types/Sandbox.d.ts +165 -0
- package/types/Sandbox.js +2 -0
- package/types/Schemas.d.ts +42 -0
- package/types/Schemas.js +2 -0
- package/utils/{modules.d.ts → cms/modules.d.ts} +1 -1
- package/utils/{modules.js → cms/modules.js} +3 -3
- package/utils/getAccountIdentifier.d.ts +10 -0
- package/utils/getAccountIdentifier.js +40 -0
- package/utils/git.d.ts +7 -2
- package/utils/git.js +54 -7
- package/utils/lang.d.ts +4 -0
- package/utils/lang.js +9 -2
- package/utils/notify.d.ts +1 -0
- package/utils/notify.js +42 -0
- package/utils/objectUtils.d.ts +8 -0
- package/utils/objectUtils.js +33 -0
- package/constants/index.d.ts +0 -16
- package/constants/index.js +0 -12
- package/http/requestOptions.d.ts +0 -20
- package/http/requestOptions.js +0 -27
- package/lib/cms/index.d.ts +0 -10
- package/lib/cms/index.js +0 -13
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -14
- /package/utils/{fieldsJS.d.ts → cms/fieldsJS.d.ts} +0 -0
- /package/utils/{fieldsJS.js → cms/fieldsJS.js} +0 -0
package/lang/en.lyaml
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
en:
|
|
2
|
+
debug:
|
|
3
|
+
archive:
|
|
4
|
+
extractZip:
|
|
5
|
+
init: "Extracting project source..."
|
|
6
|
+
success: "Completed project source extraction."
|
|
7
|
+
copySourceToDest:
|
|
8
|
+
init: "Copying project source..."
|
|
9
|
+
sourceEmpty: "Project source is empty"
|
|
10
|
+
success: "Completed copying project source."
|
|
11
|
+
error: "An error occured copying project source to {{ dest }}."
|
|
12
|
+
cleanupTempDir:
|
|
13
|
+
error: "Failed to clean up temp dir: {{ tmpDir }}"
|
|
14
|
+
github:
|
|
15
|
+
fetchJsonFromRepository: "Fetching {{ url }}..."
|
|
16
|
+
downloadGithubRepoZip:
|
|
17
|
+
fetching: "Fetching {{ releaseType }} with name {{ repoName }}..."
|
|
18
|
+
fetchingName: "Fetching {{ name }}..."
|
|
19
|
+
completed: "Completed project fetch."
|
|
20
|
+
cloneGithubRepo:
|
|
21
|
+
success: "Your new {{ type }} has been created in {{ dest }}"
|
|
22
|
+
downloadGithubRepoContents:
|
|
23
|
+
downloading: "Downloading content piece: {{ contentPiecePath }} from {{ downloadUrl }} to {{ downloadPath }}"
|
|
24
|
+
git:
|
|
25
|
+
securityIssue: "Security Issue Detected"
|
|
26
|
+
configFileTracked: "The HubSpot config file can be tracked by git."
|
|
27
|
+
fileName: 'File: "{{ configPath }}"'
|
|
28
|
+
remediate: "To remediate:"
|
|
29
|
+
moveConfig: "- Move the config file to your home directory: '{{ homeDir }}'"
|
|
30
|
+
addGitignore: "- Add gitignore pattern '{{ configPath }}' to a .gitignore file in root of your repository."
|
|
31
|
+
noRemote: "- Ensure that the config file has not already been pushed to a remote repository."
|
|
32
|
+
checkFailed: "Unable to determine if config file is properly ignored by git."
|
|
33
|
+
modules:
|
|
34
|
+
createModule:
|
|
35
|
+
creatingModule: "Creating module at {{ path }}"
|
|
36
|
+
creatingPath: "Creating {{ path }}"
|
|
37
|
+
oauth:
|
|
38
|
+
writeTokenInfo: "Updating Oauth2 token info for portalId: {{ portalId }}"
|
|
39
|
+
addOauthToAccountConfig:
|
|
40
|
+
init: "Updating configuration"
|
|
41
|
+
success: "Configuration updated"
|
|
42
|
+
filemapper:
|
|
43
|
+
skippedExisting: "Skipped existing {{ filepath }}"
|
|
44
|
+
wroteFolder: "Wrote folder {{ filepath }}"
|
|
45
|
+
completedFetch: 'Completed fetch of file "{{ src }}"{{ version }} to "{{ dest }}" from the Design Manager'
|
|
46
|
+
folderFetch: 'Fetched "{{ src }}" from account {{ accountId }} from the Design Manager successfully'
|
|
47
|
+
completedFolderFetch: 'Completed fetch of folder "{{ src }}"{{ version }} to "{{ dest }}" from the Design Manager'
|
|
48
|
+
watch:
|
|
49
|
+
notifyOfThemePreview: "To preview this theme, visit: {{ previewUrl }}"
|
|
50
|
+
skipUnsupportedExtension: "Skipping {{ file }} due to unsupported extension"
|
|
51
|
+
skipIgnoreRule: "Skipping {{ file }} due to an ignore rule"
|
|
52
|
+
uploadAttempt: 'Attempting to upload file "{{ file }}" to "{{ dest }}"'
|
|
53
|
+
uploadSuccess: "Uploaded file {{ file }} to {{ dest }}"
|
|
54
|
+
uploadFailed: "Uploading file {{ file }} to {{ dest }} failed"
|
|
55
|
+
uploadRetry: 'Retrying to upload file "{{ file }}" to "{{ dest }}"'
|
|
56
|
+
deleteAttempt: "Attempting to delete file {{ remoteFilePath }}"
|
|
57
|
+
deleteAttemptWithType: "Attempting to delete {{ type }} {{ remoteFilePath }}"
|
|
58
|
+
deleteSuccess: "Deleted file {{ remoteFilePath }}"
|
|
59
|
+
deleteSuccessWithType: "Deleted {{ type }} {{ remoteFilePath }}"
|
|
60
|
+
deleteFailed: "Deleting file {{ remoteFilePath }} failed"
|
|
61
|
+
folderUploadSuccess: "Completed uploading files in {{ src }} to {{ dest }} in {{ accountId }}"
|
|
62
|
+
ready: "Watcher is ready and watching {{ src }}. Any changes detected will be automatically uploaded and overwrite the current version in the developer file system."
|
|
63
|
+
config:
|
|
64
|
+
cliConfiguration:
|
|
65
|
+
load:
|
|
66
|
+
configFromEnv: "Loaded config from environment variables for {{ accountId }}"
|
|
67
|
+
configFromFile: "Loaded config from configuration file."
|
|
68
|
+
empty: "The config file was empty. Initializing an empty config."
|
|
69
|
+
validate:
|
|
70
|
+
noConfig: "Valiation failed: No config was found."
|
|
71
|
+
noConfigAccounts: "Valiation failed: config.accounts[] is not defined."
|
|
72
|
+
emptyAccountConfig: "Valiation failed: config.accounts[] has an empty entry."
|
|
73
|
+
noAccountId: "Valiation failed: config.accounts[] has an entry missing accountId."
|
|
74
|
+
duplicateAccountIds: "Valiation failed: config.accounts[] has multiple entries with {{ accountId }}."
|
|
75
|
+
duplicateAccountNames: "Valiation failed: config.accounts[] has multiple entries with {{ accountName }}."
|
|
76
|
+
nameContainsSpaces: "Valiation failed: config.name {{ accountName }} cannot contain spaces."
|
|
77
|
+
updateAccount:
|
|
78
|
+
noConfigToUpdate: "No config to update."
|
|
79
|
+
updating: "Updating account config for {{ accountId }}"
|
|
80
|
+
addingConfigEntry: "Adding account config entry for {{ accountId }}"
|
|
81
|
+
removeAccountFromConfig: "Deleting config for {{ accountId }}"
|
|
82
|
+
configFile:
|
|
83
|
+
errorReading: "Config file could not be read: {{ configPath }}"
|
|
84
|
+
writeSuccess: "Successfully wrote updated config data to {{ configPath }}"
|
|
85
|
+
errorLoading: "A configuration file could not be found at {{ configPath }}."
|
|
86
|
+
configUtils:
|
|
87
|
+
unknownType: "Unknown auth type {{ type }}"
|
|
88
|
+
environment:
|
|
89
|
+
loadConfig:
|
|
90
|
+
missingAccountId: "Unable to load config from environment variables: Missing accountId"
|
|
91
|
+
missingEnv: "Unable to load config from environment variables: Missing env"
|
|
92
|
+
unknownAuthType: "Unable to load config from environment variables: Unknown auth type"
|
|
93
|
+
cms:
|
|
94
|
+
functions:
|
|
95
|
+
updateExistingConfig:
|
|
96
|
+
unableToReadFile: "The file {{ configFilePath }} could not be read"
|
|
97
|
+
invalidJSON: "The file {{ configFilePath }} is not valid JSON"
|
|
98
|
+
couldNotUpdateFile: "The file {{ configFilePath }} could not be updated"
|
|
99
|
+
createFunction:
|
|
100
|
+
destPathAlreadyExists: "The {{ path }} path already exists"
|
|
101
|
+
createdDest: "Created {{ path }}"
|
|
102
|
+
failedToCreateFile: "The file {{ configFilePath }} could not be created"
|
|
103
|
+
createdFunctionFile: "Created {{ path }}"
|
|
104
|
+
createdConfigFile: "Created {{ path }}"
|
|
105
|
+
success: "A function for the endpoint '/_hcms/api/{{ endpointPath }}' has been created. Upload {{ folderName }} to try it out"
|
|
106
|
+
handleFieldsJs:
|
|
107
|
+
convertFieldsJs:
|
|
108
|
+
creating: "Creating child process with pid {{ pid }}"
|
|
109
|
+
terminating: "Child process with pid {{ pid }} has been terminated"
|
|
110
|
+
uploadFolder:
|
|
111
|
+
attempt: 'Attempting to upload file "{{ file }}" to "{{ destPath }}"'
|
|
112
|
+
success: 'Uploaded file "{{ file}}" to "{{ destPath }}"'
|
|
113
|
+
failed: 'Uploading file "{{ file }}" to "{{ destPath }}" failed so scheduled retry'
|
|
114
|
+
retry: 'Retrying to upload file "{{ file }}" to "{{ destPath }}"'
|
|
115
|
+
retryFailed: 'Uploading file "{{ file }}" to "{{ destPath }}" failed'
|
|
116
|
+
models:
|
|
117
|
+
OAuth2Manager:
|
|
118
|
+
fetchingAccessToken: "Fetching access token for accountId {{ accountId }} for clientId {{ clientId }}"
|
|
119
|
+
updatingTokenInfo: "Persisting updated tokenInfo for accountId {{ accountId }} for clientId {{ clientId }}"
|
|
120
|
+
refreshingAccessToken: "Waiting for access token for accountId {{ accountId }} for clientId {{ clientId }} to be fetched"
|
|
121
|
+
http:
|
|
122
|
+
index:
|
|
123
|
+
createGetRequestStream:
|
|
124
|
+
onWrite: "Wrote file {{ filepath }}"
|
|
125
|
+
api:
|
|
126
|
+
filemapper:
|
|
127
|
+
trackUsage:
|
|
128
|
+
invalidEvent: "Usage tracking event {{ eventName }} is not a valid event type."
|
|
129
|
+
sendingEventAuthenticated: "Sending usage event to authenticated endpoint"
|
|
130
|
+
sendingEventUnauthenticated: "Sending usage event to unauthenticated endpoint"
|
|
131
|
+
templates:
|
|
132
|
+
debug:
|
|
133
|
+
creatingPath: "Making {{ path }} if needed"
|
|
134
|
+
logging:
|
|
135
|
+
creatingFile: "Creating file at {{ path }}"
|
|
136
|
+
processFieldsJs:
|
|
137
|
+
converting: "Converting \"{{ src }}\" to \"{{ dest }}\"."
|
|
138
|
+
converted: "Finished converting \"{{ src }}\" to \"{{ dest }}\"."
|
|
139
|
+
errors:
|
|
140
|
+
hubdb:
|
|
141
|
+
invalidJsonPath: "The HubDB table file must be a '.json' file"
|
|
142
|
+
invalidJsonFile: "The '{{{ src }}' path is not a path to a file"
|
|
143
|
+
archive:
|
|
144
|
+
extractZip:
|
|
145
|
+
write: "An error occured writing temp project source."
|
|
146
|
+
extract: "An error occured extracting project source."
|
|
147
|
+
errorTypes:
|
|
148
|
+
fileSystem:
|
|
149
|
+
readAction: "reading from"
|
|
150
|
+
writeAction: "writing to"
|
|
151
|
+
otherAction: "accessing"
|
|
152
|
+
unknownFilepath: "a file or folder"
|
|
153
|
+
baseMessage: "An error occurred while {{ fileAction }} {{ filepath }}."
|
|
154
|
+
systemErrorMessage: "This is the result of a system error: {{ errorMessage }}"
|
|
155
|
+
api:
|
|
156
|
+
messageDetail: "{{ request }} in account {{ accountId }}"
|
|
157
|
+
unableToUpload: 'Unable to upload "{{ payload }}.'
|
|
158
|
+
codes:
|
|
159
|
+
400: "The {{ messageDetail }} was bad."
|
|
160
|
+
401: "The {{ messageDetail }} was unauthorized."
|
|
161
|
+
403MissingScope: "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key."
|
|
162
|
+
403Gating: "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216."
|
|
163
|
+
403: "The {{ messageDetail }} was forbidden."
|
|
164
|
+
404Request: 'The {{ action }} failed because "{{ request }}" was not found in account {{ accountId }}.'
|
|
165
|
+
404: "The {{ messageDetail }} was not found."
|
|
166
|
+
429: "The {{ messageDetail }} surpassed the rate limit. Retry in one minute."
|
|
167
|
+
503: "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
168
|
+
500generic: "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
169
|
+
400generic: "The {{ messageDetail }} failed due to a client error."
|
|
170
|
+
generic: "The {{ messageDetail }} failed."
|
|
171
|
+
cmsFields:
|
|
172
|
+
syntax: 'There was an error converting JS file "{{ path }}"'
|
|
173
|
+
notFunction: 'There was an error loading JS file "{{ path }}". Expected type "Function" but received type "{{ returned }}". Make sure that your default export is a function.'
|
|
174
|
+
notReturnArray: 'There was an error loading JS file "{{ path }}". Expected type "Array" but received type "{{ returned }}" . Make sure that your function returns an array'
|
|
175
|
+
invalidPath: 'The path "{{ path }}" is not a path to a file or folder'
|
|
176
|
+
generic: "A {{ name }} has occurred"
|
|
177
|
+
filemapper:
|
|
178
|
+
invalidNode: "Invalid FileMapperNode: {{ json }}"
|
|
179
|
+
invalidFileType: "Invalid file type requested: {{ srcPath }}"
|
|
180
|
+
assetTimeout: "HubSpot assets are unavailable at the moment. Please wait a few minutes and try again."
|
|
181
|
+
failedToFetchFile: 'Failed fetch of file "{{ src }}" to "{{ dest }}" from the Design Manager'
|
|
182
|
+
failedToFetchFolder: 'Failed fetch of folder "{{ src }}" to "{{ dest }}" from the Design Manager'
|
|
183
|
+
invalidFetchFolderRequest: 'Invalid request for folder: "{{ src }}"'
|
|
184
|
+
incompleteFetch: 'Not all files in folder "{{ src }}" were successfully fetched. Re-run the last command to try again'
|
|
185
|
+
github:
|
|
186
|
+
downloadGithubRepoContents: "Failed to fetch contents: {{ errorMessage }}"
|
|
187
|
+
fetchJsonFromRepository: "An error occured fetching JSON file."
|
|
188
|
+
fetchReleaseData: "Failed fetching release data for {{ tag }} project."
|
|
189
|
+
downloadGithubRepoZip: "An error occurred fetching the project source."
|
|
190
|
+
modules:
|
|
191
|
+
throwInvalidPathInput: "Expected Path Input"
|
|
192
|
+
writeModuleMeta: "The {{ path }} path already exists"
|
|
193
|
+
personalAccessKey:
|
|
194
|
+
accountNotFound: "Account with id {{ accountId }} does not exist."
|
|
195
|
+
invalidPersonalAccessKey: "Error while retrieving new access token: {{ errorMessage }}"
|
|
196
|
+
templates:
|
|
197
|
+
fileAnnotations: "Error reading file annotations {{ file }}"
|
|
198
|
+
pathExists: "The {{ path }} path already exists"
|
|
199
|
+
utils:
|
|
200
|
+
git:
|
|
201
|
+
configIgnore: "Unable to determine if config file is properly ignored by git."
|
|
202
|
+
notify:
|
|
203
|
+
filePath: "Unable to notify file '{{ filePath }}'"
|
|
204
|
+
config:
|
|
205
|
+
cliConfiguration:
|
|
206
|
+
noConfigLoaded: "No config loaded."
|
|
207
|
+
updateAccount: "An accountId is required to update the config"
|
|
208
|
+
updateDefaultAccount: "A 'defaultAccount' with value of number or string is required to update the config."
|
|
209
|
+
renameAccount: "Cannot find account with identifier {{ currentName }}"
|
|
210
|
+
removeAccountFromConfig: "Unable to find account for {{ nameOrId }}."
|
|
211
|
+
updateDefaultMode: "The mode {{ defaultMode }} is invalid. Valid values are {{ validModes }}."
|
|
212
|
+
updateHttpTimeout: "The value {{ timeout }} is invalid. The value must be a number greater than {{ minTimeout }}."
|
|
213
|
+
updateAllowUsageTracking: "Unable to update allowUsageTracking. The value {{ isEnabled }} is invalid. The value must be a boolean."
|
|
214
|
+
configFile:
|
|
215
|
+
parsing: "Config file could not be parsed"
|
|
216
|
+
models:
|
|
217
|
+
OAuth2Manager:
|
|
218
|
+
missingRefreshToken: "The account {{ accountId }} has not been authenticated with Oauth2"
|
|
219
|
+
auth: "Error while retrieving new token: {{ token }}"
|
|
220
|
+
http:
|
|
221
|
+
index:
|
|
222
|
+
withOauth: "Oauth manager for account {{ accountId }} not found."
|
|
223
|
+
withAuth: "Account with id {{ accountId }} not found."
|
|
224
|
+
cms:
|
|
225
|
+
handleFieldsJs:
|
|
226
|
+
convertFieldsJs: "There was an error converting '{{ filePath }}'"
|
|
227
|
+
saveOutput: "There was an error saving the json output of {{ path }}"
|
|
228
|
+
createTmpDirSync: "An error occured writing temporary project source."
|
|
229
|
+
cleanupTmpDirSync: "There was an error deleting the temporary project source"
|
|
230
|
+
functions:
|
|
231
|
+
updateExistingConfig:
|
|
232
|
+
configIsNotObjectError: "The existing {{ configFilePath }} is not an object"
|
|
233
|
+
endpointAreadyExistsError: "The endpoint {{ endpointPath }} already exists in {{ configFilePath }}"
|
|
234
|
+
createFunction:
|
|
235
|
+
nestedConfigError: "Cannot create a functions directory inside '{{ ancestorConfigPath }}'"
|
|
236
|
+
jsFileConflictError: "The JavaScript file at '{{ functionFilePath }}'' already exists"
|
|
237
|
+
sandboxes:
|
|
238
|
+
createSandbox: "There was an error creating your sandbox."
|
|
239
|
+
deleteSandbox: "There was an error deleting your sandbox."
|
|
240
|
+
getSandboxUsageLimits: "There was an error fetching sandbox usage limits."
|
|
241
|
+
initiateSync: "There was an error initiating the sandbox sync."
|
|
242
|
+
fetchTaskStatus: "There was an error fetching the task status while syncing sandboxes."
|
|
243
|
+
fetchTypes: "There was an error fetching sandbox types."
|
|
244
|
+
processFieldsJs:
|
|
245
|
+
fieldsJsNotReturnArray: "There was an error loading JS file \"{{ path }}\". Expected type \"Array\". Make sure that your function returns an array"
|
|
246
|
+
fieldsJsNotFunction: "There was an error loading JS file \"{{ path }}\". Expected type \"Function\". Make sure that your default export is a function."
|
|
247
|
+
invalidMjsFile: ".mjs files are only supported when using Node 13.2.0+"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LogCallbacksArg } from '../../types/LogCallbacks';
|
|
2
|
+
type FunctionInfo = {
|
|
3
|
+
functionsFolder: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
endpointPath: string;
|
|
6
|
+
endpointMethod: string;
|
|
7
|
+
};
|
|
8
|
+
type FunctionOptions = {
|
|
9
|
+
allowExistingFile?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const createFunctionCallbackKeys: string[];
|
|
12
|
+
export declare function createFunction(functionInfo: FunctionInfo, dest: string, options: FunctionOptions, logCallbacks?: LogCallbacksArg<typeof createFunctionCallbackKeys>): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
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.createFunction = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
10
|
+
const path_2 = require("../path");
|
|
11
|
+
const github_1 = require("../github");
|
|
12
|
+
const logger_1 = require("../../utils/logger");
|
|
13
|
+
const objectUtils_1 = require("../../utils/objectUtils");
|
|
14
|
+
const standardErrors_1 = require("../../errors/standardErrors");
|
|
15
|
+
const fileSystemErrors_1 = require("../../errors/fileSystemErrors");
|
|
16
|
+
const i18nKey = 'cms.functions';
|
|
17
|
+
function createEndpoint(endpointMethod, filename) {
|
|
18
|
+
return {
|
|
19
|
+
method: endpointMethod || 'GET',
|
|
20
|
+
file: filename,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createConfig({ endpointPath, endpointMethod, functionFile, }) {
|
|
24
|
+
return {
|
|
25
|
+
runtime: 'nodejs18.x',
|
|
26
|
+
version: '1.0',
|
|
27
|
+
environment: {},
|
|
28
|
+
secrets: [],
|
|
29
|
+
endpoints: {
|
|
30
|
+
[endpointPath]: createEndpoint(endpointMethod, functionFile),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function writeConfig(configFilePath, config) {
|
|
35
|
+
const configJson = JSON.stringify(config, null, ' ');
|
|
36
|
+
fs_extra_1.default.writeFileSync(configFilePath, configJson);
|
|
37
|
+
}
|
|
38
|
+
function updateExistingConfig(configFilePath, { endpointPath, endpointMethod, functionFile }) {
|
|
39
|
+
let configString;
|
|
40
|
+
try {
|
|
41
|
+
configString = fs_extra_1.default.readFileSync(configFilePath).toString();
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
(0, logger_1.debug)(`${i18nKey}.updateExistingConfig.unableToReadFile`, {
|
|
45
|
+
configFilePath,
|
|
46
|
+
});
|
|
47
|
+
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
|
48
|
+
filepath: configFilePath,
|
|
49
|
+
read: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
let config;
|
|
53
|
+
try {
|
|
54
|
+
config = JSON.parse(configString);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
(0, logger_1.debug)(`${i18nKey}.updateExistingConfig.invalidJSON`, {
|
|
58
|
+
configFilePath,
|
|
59
|
+
});
|
|
60
|
+
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
|
61
|
+
filepath: configFilePath,
|
|
62
|
+
read: true,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (!(0, objectUtils_1.isObject)(config)) {
|
|
66
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateExistingConfig.configIsNotObjectError`, { configFilePath });
|
|
67
|
+
}
|
|
68
|
+
if (config.endpoints) {
|
|
69
|
+
if (config.endpoints[endpointPath]) {
|
|
70
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateExistingConfig.endpointAreadyExistsError`, {
|
|
71
|
+
configFilePath,
|
|
72
|
+
endpointPath,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
config.endpoints[endpointPath] = createEndpoint(endpointMethod, functionFile);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
config.endpoints = {
|
|
81
|
+
[endpointPath]: createEndpoint(endpointMethod, functionFile),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
writeConfig(configFilePath, config);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
(0, logger_1.debug)(`${i18nKey}.updateExistingConfig.couldNotUpdateFile`, {
|
|
89
|
+
configFilePath,
|
|
90
|
+
});
|
|
91
|
+
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
|
92
|
+
filepath: configFilePath,
|
|
93
|
+
write: true,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const createFunctionCallbackKeys = [
|
|
98
|
+
'destPathAlreadyExists',
|
|
99
|
+
'createdDest',
|
|
100
|
+
'createdFunctionFile',
|
|
101
|
+
'createdConfigFile',
|
|
102
|
+
'success',
|
|
103
|
+
];
|
|
104
|
+
async function createFunction(functionInfo, dest, options, logCallbacks) {
|
|
105
|
+
const logger = (0, logger_1.makeTypedLogger)(logCallbacks, `${i18nKey}.createFunction`);
|
|
106
|
+
const { functionsFolder, filename, endpointPath, endpointMethod } = functionInfo;
|
|
107
|
+
const allowExistingFile = options.allowExistingFile || false;
|
|
108
|
+
const ancestorFunctionsConfig = (0, findup_sync_1.default)('serverless.json', {
|
|
109
|
+
cwd: (0, path_2.getCwd)(),
|
|
110
|
+
nocase: true,
|
|
111
|
+
});
|
|
112
|
+
if (ancestorFunctionsConfig) {
|
|
113
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.createFunction.nestedConfigError`, {
|
|
114
|
+
ancestorConfigPath: path_1.default.dirname(ancestorFunctionsConfig),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const folderName = functionsFolder.endsWith('.functions')
|
|
118
|
+
? functionsFolder
|
|
119
|
+
: `${functionsFolder}.functions`;
|
|
120
|
+
const functionFile = filename.endsWith('.js') ? filename : `${filename}.js`;
|
|
121
|
+
const destPath = path_1.default.join(dest, folderName);
|
|
122
|
+
if (fs_extra_1.default.existsSync(destPath)) {
|
|
123
|
+
logger('destPathAlreadyExists', {
|
|
124
|
+
path: destPath,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
fs_extra_1.default.mkdirp(destPath);
|
|
129
|
+
logger('createdDest', {
|
|
130
|
+
path: destPath,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const functionFilePath = path_1.default.join(destPath, functionFile);
|
|
134
|
+
const configFilePath = path_1.default.join(destPath, 'serverless.json');
|
|
135
|
+
if (!allowExistingFile && fs_extra_1.default.existsSync(functionFilePath)) {
|
|
136
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.createFunction.jsFileConflictError`, {
|
|
137
|
+
functionFilePath,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
await (0, github_1.downloadGithubRepoContents)('HubSpot/cms-sample-assets', 'functions/sample-function.js', functionFilePath);
|
|
141
|
+
logger('createdFunctionFile', {
|
|
142
|
+
path: functionFilePath,
|
|
143
|
+
});
|
|
144
|
+
if (fs_extra_1.default.existsSync(configFilePath)) {
|
|
145
|
+
updateExistingConfig(configFilePath, {
|
|
146
|
+
endpointPath,
|
|
147
|
+
endpointMethod,
|
|
148
|
+
functionFile,
|
|
149
|
+
});
|
|
150
|
+
logger('createdFunctionFile', {
|
|
151
|
+
path: functionFilePath,
|
|
152
|
+
});
|
|
153
|
+
logger('success', {
|
|
154
|
+
endpointPath: endpointPath,
|
|
155
|
+
folderName,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const config = createConfig({ endpointPath, endpointMethod, functionFile });
|
|
160
|
+
try {
|
|
161
|
+
writeConfig(configFilePath, config);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
(0, logger_1.debug)(`${i18nKey}.createFunction.failedToCreateFile`, {
|
|
165
|
+
configFilePath,
|
|
166
|
+
});
|
|
167
|
+
(0, fileSystemErrors_1.throwFileSystemError)(err, {
|
|
168
|
+
filepath: configFilePath,
|
|
169
|
+
write: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
logger('createdConfigFile', {
|
|
173
|
+
path: configFilePath,
|
|
174
|
+
});
|
|
175
|
+
logger('success', {
|
|
176
|
+
endpointPath: endpointPath,
|
|
177
|
+
folderName,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.createFunction = createFunction;
|
|
@@ -5,7 +5,8 @@ export declare class FieldsJs {
|
|
|
5
5
|
rejected: boolean;
|
|
6
6
|
fieldOptions: string;
|
|
7
7
|
outputPath?: string;
|
|
8
|
-
|
|
8
|
+
toJSON?: () => JSON;
|
|
9
|
+
constructor(projectDir: string, filePath: string, rootWriteDir?: string | null, fieldOptions?: string);
|
|
9
10
|
init(): Promise<this>;
|
|
10
11
|
convertFieldsJs(writeDir: string): Promise<string | void>;
|
|
11
12
|
/**
|
|
@@ -9,10 +9,10 @@ const os_1 = __importDefault(require("os"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const escapeRegExp_1 = require("../../utils/escapeRegExp");
|
|
12
|
-
const modules_1 = require("../../utils/modules");
|
|
12
|
+
const modules_1 = require("../../utils/cms/modules");
|
|
13
13
|
const logger_1 = require("../../utils/logger");
|
|
14
14
|
const standardErrors_1 = require("../../errors/standardErrors");
|
|
15
|
-
const i18nKey = '
|
|
15
|
+
const i18nKey = 'cms.handleFieldsJs';
|
|
16
16
|
class FieldsJs {
|
|
17
17
|
projectDir;
|
|
18
18
|
filePath;
|
|
@@ -20,6 +20,7 @@ class FieldsJs {
|
|
|
20
20
|
rejected;
|
|
21
21
|
fieldOptions;
|
|
22
22
|
outputPath;
|
|
23
|
+
toJSON;
|
|
23
24
|
constructor(projectDir, filePath, rootWriteDir, fieldOptions = '') {
|
|
24
25
|
this.projectDir = projectDir;
|
|
25
26
|
this.filePath = filePath;
|
|
@@ -27,7 +28,7 @@ class FieldsJs {
|
|
|
27
28
|
this.rejected = false;
|
|
28
29
|
// Create tmpDir if no writeDir is given.
|
|
29
30
|
this.rootWriteDir =
|
|
30
|
-
rootWriteDir === undefined
|
|
31
|
+
rootWriteDir === undefined || rootWriteDir === null
|
|
31
32
|
? createTmpDirSync('hubspot-temp-fieldsjs-output-')
|
|
32
33
|
: rootWriteDir;
|
|
33
34
|
}
|
package/lib/cms/modules.js
CHANGED
|
@@ -11,7 +11,7 @@ const fs_1 = require("../fs");
|
|
|
11
11
|
const github_1 = require("../github");
|
|
12
12
|
const standardErrors_1 = require("../../errors/standardErrors");
|
|
13
13
|
const logger_1 = require("../../utils/logger");
|
|
14
|
-
const modules_1 = require("../../utils/modules");
|
|
14
|
+
const modules_1 = require("../../utils/cms/modules");
|
|
15
15
|
// Ids for testing
|
|
16
16
|
exports.ValidationIds = {
|
|
17
17
|
SRC_REQUIRED: 'SRC_REQUIRED',
|
|
@@ -106,7 +106,7 @@ async function createModule(moduleDefinition, name, dest, options = {
|
|
|
106
106
|
const folderName = !name || name.endsWith('.module') ? name : `${name}.module`;
|
|
107
107
|
const destPath = path_1.default.join(dest, folderName);
|
|
108
108
|
if (!options.allowExistingDir && fs_extra_1.default.existsSync(destPath)) {
|
|
109
|
-
(0, standardErrors_1.throwErrorWithMessage)('modules.
|
|
109
|
+
(0, standardErrors_1.throwErrorWithMessage)('modules.writeModuleMeta', {
|
|
110
110
|
path: destPath,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -119,6 +119,6 @@ async function createModule(moduleDefinition, name, dest, options = {
|
|
|
119
119
|
logger('creatingModule', {
|
|
120
120
|
path: destPath,
|
|
121
121
|
});
|
|
122
|
-
await (0, github_1.downloadGithubRepoContents)('cms-sample-assets', 'modules/Sample.module', destPath, moduleFileFilter);
|
|
122
|
+
await (0, github_1.downloadGithubRepoContents)('HubSpot/cms-sample-assets', 'modules/Sample.module', destPath, '', moduleFileFilter);
|
|
123
123
|
}
|
|
124
124
|
exports.createModule = createModule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const fs_1 = __importDefault(require("fs"));
|
|
32
|
+
const semver_1 = __importDefault(require("semver"));
|
|
33
|
+
const url_1 = require("url");
|
|
34
|
+
const path_2 = require("../path");
|
|
35
|
+
const standardErrors_1 = require("../../errors/standardErrors");
|
|
36
|
+
const lang_1 = require("../../utils/lang");
|
|
37
|
+
const i18nKey = 'processFieldsJs';
|
|
38
|
+
const { dirName, fieldOptions, filePath, writeDir } = process.env;
|
|
39
|
+
const baseName = path_1.default.basename(filePath);
|
|
40
|
+
const FieldErrors = {
|
|
41
|
+
IsNotFunction: 'IsNotFunction',
|
|
42
|
+
DoesNotReturnArray: 'DoesNotReturnArray',
|
|
43
|
+
};
|
|
44
|
+
//TODO - Figure out agnostic logging
|
|
45
|
+
console.info((0, lang_1.i18n)(`${i18nKey}.converting`, {
|
|
46
|
+
src: dirName + `/${baseName}`,
|
|
47
|
+
dest: dirName + '/fields.json',
|
|
48
|
+
}));
|
|
49
|
+
/*
|
|
50
|
+
* How this works: dynamicImport() will always return either a Promise or undefined.
|
|
51
|
+
* In the case when it's a Promise, its expected that it will resolve to a function.
|
|
52
|
+
* This function has optional return type of Promise<Array> | Array. In order to have uniform handling,
|
|
53
|
+
* we wrap the return value of the function in a Promise.resolve(), and then process.
|
|
54
|
+
*/
|
|
55
|
+
const fieldsPromise = dynamicImport(filePath).catch(e => (0, standardErrors_1.throwError)(e));
|
|
56
|
+
fieldsPromise.then(fieldsFunc => {
|
|
57
|
+
const fieldsFuncType = typeof fieldsFunc;
|
|
58
|
+
if (fieldsFuncType !== 'function') {
|
|
59
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.${FieldErrors.IsNotFunction}`, {
|
|
60
|
+
path: filePath,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return Promise.resolve(fieldsFunc(fieldOptions)).then(fields => {
|
|
64
|
+
if (!Array.isArray(fields)) {
|
|
65
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.${FieldErrors.DoesNotReturnArray}`, {
|
|
66
|
+
path: filePath,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const finalPath = path_1.default.join(writeDir, '/fields.json');
|
|
70
|
+
return fieldsArrayToJson(fields).then(json => {
|
|
71
|
+
if (!fs_1.default.existsSync(writeDir)) {
|
|
72
|
+
fs_1.default.mkdirSync(writeDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
fs_1.default.writeFileSync(finalPath, json);
|
|
75
|
+
//TODO - Figure out agnostic logging
|
|
76
|
+
console.log((0, lang_1.i18n)(`${i18nKey}.converted`, {
|
|
77
|
+
src: dirName + `/${baseName}`,
|
|
78
|
+
dest: dirName + '/fields.json',
|
|
79
|
+
}));
|
|
80
|
+
if (process) {
|
|
81
|
+
process.send({
|
|
82
|
+
action: 'COMPLETE',
|
|
83
|
+
finalPath,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
/*
|
|
90
|
+
* Polyfill for `Array.flat(Infinity)` since the `flat` is only available for Node v11+
|
|
91
|
+
* https://stackoverflow.com/a/15030117
|
|
92
|
+
*/
|
|
93
|
+
function flattenArray(arr) {
|
|
94
|
+
return arr.reduce((flat, toFlatten) => {
|
|
95
|
+
return flat.concat(Array.isArray(toFlatten) ? flattenArray(toFlatten) : toFlatten);
|
|
96
|
+
}, []);
|
|
97
|
+
}
|
|
98
|
+
async function fieldsArrayToJson(fields) {
|
|
99
|
+
const allFields = await Promise.all(flattenArray(fields));
|
|
100
|
+
const jsonFields = allFields.map(field => {
|
|
101
|
+
return typeof field['toJSON'] === 'function' ? field.toJSON() : field;
|
|
102
|
+
});
|
|
103
|
+
return JSON.stringify(jsonFields, null, 2);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Takes in a path to a javascript file and either dynamically imports it or requires it, and returns, depending on node version.
|
|
107
|
+
* @param {string} filePath - Path to javascript file
|
|
108
|
+
* @returns {Promise | undefined} - Returns _default_ exported content if ESM, or exported module content if CJS, or undefined if node version < 13.2 and file is .mjs.
|
|
109
|
+
*/
|
|
110
|
+
async function dynamicImport(filePath) {
|
|
111
|
+
var _a;
|
|
112
|
+
if (semver_1.default.gte(process.version, '13.2.0')) {
|
|
113
|
+
const exported = await (_a = (0, url_1.pathToFileURL)(filePath).toString(), Promise.resolve().then(() => __importStar(require(_a)))).then(content => content.default);
|
|
114
|
+
return exported;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if ((0, path_2.getExt)(filePath) == 'mjs') {
|
|
118
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.invalidMjsFile`);
|
|
119
|
+
}
|
|
120
|
+
return require(filePath);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LogCallbacksArg } from '../../types/LogCallbacks';
|
|
2
|
+
export declare const ANNOTATION_KEYS: {
|
|
3
|
+
isAvailableForNewContent: string;
|
|
4
|
+
templateType: string;
|
|
5
|
+
label: string;
|
|
6
|
+
screenshotPath: string;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getAnnotationValue(annotations: string, key: string): string | null;
|
|
10
|
+
export declare function isCodedFile(filePath: string): boolean;
|
|
11
|
+
declare const ASSET_PATHS: {
|
|
12
|
+
readonly 'page-template': "templates/page-template.html";
|
|
13
|
+
readonly partial: "templates/partial.html";
|
|
14
|
+
readonly 'global-partial': "templates/global-partial.html";
|
|
15
|
+
readonly 'email-template': "templates/email-template.html";
|
|
16
|
+
readonly 'blog-listing-template': "templates/blog-listing-template.html";
|
|
17
|
+
readonly 'blog-post-template': "templates/blog-post-template.html";
|
|
18
|
+
readonly 'search-template': "templates/search-template.html";
|
|
19
|
+
readonly section: "templates/section.html";
|
|
20
|
+
};
|
|
21
|
+
declare const templatesCallbackKeys: string[];
|
|
22
|
+
export declare function createTemplate(name: string, dest: string, type?: keyof typeof ASSET_PATHS, options?: {
|
|
23
|
+
allowExisting: boolean;
|
|
24
|
+
}, logCallbacks?: LogCallbacksArg<typeof templatesCallbackKeys>): Promise<void>;
|
|
25
|
+
export {};
|