contensis-cli 1.0.0-beta.5 → 1.0.0-beta.51
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/README.md +669 -74
- package/dist/commands/connect.js +3 -3
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/create.js +30 -10
- package/dist/commands/create.js.map +2 -2
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/get.js +61 -12
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +22 -17
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +36 -10
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/index.js +9 -1
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/list.js +19 -8
- package/dist/commands/list.js.map +2 -2
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/push.js +8 -4
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/release.js +47 -0
- package/dist/commands/release.js.map +7 -0
- package/dist/commands/remove.js +10 -8
- package/dist/commands/remove.js.map +2 -2
- package/dist/commands/set.js +53 -12
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +97 -47
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/CredentialProvider.js +36 -7
- package/dist/providers/CredentialProvider.js.map +3 -3
- package/dist/providers/SessionCacheProvider.js +21 -1
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/providers/file-provider.js +8 -4
- package/dist/providers/file-provider.js.map +3 -3
- package/dist/services/ContensisCliService.js +600 -336
- package/dist/services/ContensisCliService.js.map +3 -3
- package/dist/shell.js +27 -10
- package/dist/shell.js.map +3 -3
- package/dist/util/console.printer.js +170 -47
- package/dist/util/console.printer.js.map +2 -2
- package/dist/util/index.js +5 -2
- package/dist/util/index.js.map +3 -3
- package/dist/util/logger.js +45 -13
- package/dist/util/logger.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/connect.ts +3 -2
- package/src/commands/create.ts +37 -8
- package/src/commands/diff.ts +41 -0
- package/src/commands/get.ts +80 -5
- package/src/commands/globalOptions.ts +18 -17
- package/src/commands/import.ts +43 -4
- package/src/commands/index.ts +9 -1
- package/src/commands/list.ts +35 -9
- package/src/commands/login.ts +3 -2
- package/src/commands/push.ts +9 -2
- package/src/commands/release.ts +32 -0
- package/src/commands/remove.ts +12 -4
- package/src/commands/set.ts +65 -9
- package/src/localisation/en-GB.ts +142 -64
- package/src/providers/CredentialProvider.ts +39 -6
- package/src/providers/SessionCacheProvider.ts +29 -2
- package/src/providers/file-provider.ts +8 -4
- package/src/services/ContensisCliService.ts +742 -387
- package/src/shell.ts +31 -11
- package/src/util/console.printer.ts +234 -66
- package/src/util/index.ts +12 -6
- package/src/util/logger.ts +84 -15
- package/src/version.ts +1 -1
|
@@ -27,7 +27,7 @@ const LogMessages = {
|
|
|
27
27
|
contensis: () => "Contensis",
|
|
28
28
|
quit: () => `Goodbye \u{1F44B}
|
|
29
29
|
`,
|
|
30
|
-
startup: () =>
|
|
30
|
+
startup: (version) => `v${version} \xA9 2001-${new Date().getFullYear()} Zengenti \u{1F1EC}\u{1F1E7}.
|
|
31
31
|
- Creators of Contensis and purveyors of other fine software
|
|
32
32
|
|
|
33
33
|
\u{1F44B} Welcome to the contensis-cli
|
|
@@ -94,7 +94,7 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
94
94
|
description: () => "the shared secret to use when logging in with a client id"
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
passwordPrompt: (env, userId) => `Enter password for ${userId}@${env}
|
|
97
|
+
passwordPrompt: (env, userId) => userId ? `Enter password for ${userId}@${env}:` : `Please enter a password`,
|
|
98
98
|
failed: (env, userId) => `Unable to login to ${env} as ${userId}`,
|
|
99
99
|
success: (env, userId) => `User ${userId} connected to ${env} successfully
|
|
100
100
|
`,
|
|
@@ -105,34 +105,29 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
105
105
|
projects: {
|
|
106
106
|
list: () => `Available projects:`,
|
|
107
107
|
noList: () => `Cannot retrieve projects list`,
|
|
108
|
-
set: (projectId) => `Current project is set to
|
|
109
|
-
failedSet: (projectId) => `Project
|
|
108
|
+
set: (projectId) => `Current project is set to ${import_logger.Logger.highlightText(projectId)}`,
|
|
109
|
+
failedSet: (projectId) => `Project ${import_logger.Logger.highlightText(projectId)} not found`,
|
|
110
|
+
tip: () => `You need to set your current working project with "set project {projectId}"`,
|
|
111
|
+
created: (env, id) => `[${env}] Created project ${import_logger.Logger.highlightText(id)}`,
|
|
112
|
+
failedCreate: (env, id) => `[${env}] Unable to create project ${import_logger.Logger.highlightText(id)}`,
|
|
113
|
+
updated: (env, id) => `[${env}] Updated project ${import_logger.Logger.highlightText(id)}`,
|
|
114
|
+
failedUpdate: (env, id) => `[${env}] Unable to update project ${import_logger.Logger.highlightText(id)}`
|
|
110
115
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} component "${id}"`,
|
|
127
|
-
failedRemove: (env, id) => `[${env}] Unable to delete component "${id}"`
|
|
128
|
-
},
|
|
129
|
-
version: {
|
|
130
|
-
set: (env, versionStatus) => `[${env}] Content version status set to "${versionStatus}"`,
|
|
131
|
-
invalid: (versionStatus) => `Content version status "${versionStatus}" is not valid, allowed values are "published" or "latest".`,
|
|
132
|
-
noEnv: () => `No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`
|
|
133
|
-
},
|
|
134
|
-
entries: {
|
|
135
|
-
migrateStatus: (status) => {
|
|
116
|
+
migrate: {
|
|
117
|
+
models: {
|
|
118
|
+
result: (status) => {
|
|
119
|
+
switch (status) {
|
|
120
|
+
case "created":
|
|
121
|
+
case "updated":
|
|
122
|
+
return import_logger.Logger.successText;
|
|
123
|
+
case "errors":
|
|
124
|
+
return import_logger.Logger.errorText;
|
|
125
|
+
default:
|
|
126
|
+
return import_logger.Logger.infoText;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
status: (status) => {
|
|
136
131
|
switch (status) {
|
|
137
132
|
case "no change":
|
|
138
133
|
return import_logger.Logger.successText;
|
|
@@ -147,19 +142,48 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
147
142
|
default:
|
|
148
143
|
return import_logger.Logger.infoText;
|
|
149
144
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
models: {
|
|
148
|
+
list: (projectId) => `Content models in ${import_logger.Logger.highlightText(projectId)}:`,
|
|
149
|
+
noList: (projectId) => `[${projectId}] Cannot retrieve content models`,
|
|
150
|
+
get: (projectId, id) => `[${projectId}] Content models ${import_logger.Logger.infoText(`[ ${id} ]`)}`,
|
|
151
|
+
failedGet: (projectId, id) => `[${projectId}] Unable to get content models ${import_logger.Logger.highlightText(id)}`
|
|
152
|
+
},
|
|
153
|
+
contenttypes: {
|
|
154
|
+
list: (projectId) => `Content types in ${import_logger.Logger.highlightText(projectId)}:`,
|
|
155
|
+
get: (projectId, id) => `[${projectId}] Content type ${import_logger.Logger.highlightText(id)}`,
|
|
156
|
+
failedGet: (projectId, id) => `[${projectId}] Unable to get content type ${import_logger.Logger.highlightText(id)}`,
|
|
157
|
+
created: (projectId, id, status) => `[${projectId}] Content type ${status}d ${import_logger.Logger.highlightText(id)}`,
|
|
158
|
+
removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} content type ${import_logger.Logger.highlightText(id)}`,
|
|
159
|
+
failedRemove: (env, id) => `[${env}] Unable to delete content type ${import_logger.Logger.highlightText(id)}`
|
|
160
|
+
},
|
|
161
|
+
components: {
|
|
162
|
+
list: (projectId) => `Components in ${import_logger.Logger.highlightText(projectId)}:`,
|
|
163
|
+
get: (projectId, id) => `[${projectId}] Component ${import_logger.Logger.highlightText(id)}`,
|
|
164
|
+
failedGet: (projectId, id) => `[${projectId}] Unable to get component ${import_logger.Logger.highlightText(id)}`,
|
|
165
|
+
created: (projectId, id, status) => `[${projectId}] Component ${status}d ${import_logger.Logger.highlightText(id)}`,
|
|
166
|
+
removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} component ${import_logger.Logger.highlightText(id)}`,
|
|
167
|
+
failedRemove: (env, id) => `[${env}] Unable to delete component ${import_logger.Logger.highlightText(id)}`
|
|
168
|
+
},
|
|
169
|
+
version: {
|
|
170
|
+
set: (env, versionStatus) => `[${env}] Content version status set to "${versionStatus}"`,
|
|
171
|
+
invalid: (versionStatus) => `Content version status "${versionStatus}" is not valid, allowed values are "published" or "latest".`,
|
|
172
|
+
noEnv: () => `No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`
|
|
173
|
+
},
|
|
174
|
+
entries: {
|
|
175
|
+
removed: (env, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} entries`,
|
|
176
|
+
failedRemove: (env) => `[${env}] Unable to delete entries`,
|
|
177
|
+
notFound: (env) => `[${env}] Entries were not found`,
|
|
154
178
|
commitTip: () => ` Add --commit flag to commit the previewed changes`
|
|
155
179
|
},
|
|
156
180
|
keys: {
|
|
157
181
|
list: (env) => `[${env}] API keys:`,
|
|
158
182
|
noList: (env) => `[${env}] Cannot retrieve API`,
|
|
159
|
-
created: (env, name) => `[${env}] Created API key
|
|
160
|
-
failedCreate: (env, name) => `[${env}] Unable to create API key
|
|
161
|
-
removed: (env, id) => `[${env}] Deleted API key
|
|
162
|
-
failedRemove: (env, id) => `[${env}] Unable to delete API key
|
|
183
|
+
created: (env, name) => `[${env}] Created API key ${import_logger.Logger.highlightText(name)}`,
|
|
184
|
+
failedCreate: (env, name) => `[${env}] Unable to create API key ${import_logger.Logger.highlightText(name)}`,
|
|
185
|
+
removed: (env, id) => `[${env}] Deleted API key ${import_logger.Logger.highlightText(id)}`,
|
|
186
|
+
failedRemove: (env, id) => `[${env}] Unable to delete API key ${import_logger.Logger.highlightText(id)}`
|
|
163
187
|
},
|
|
164
188
|
blocks: {
|
|
165
189
|
runningStatus: (status) => {
|
|
@@ -178,22 +202,48 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
178
202
|
return import_logger.Logger.infoText(status);
|
|
179
203
|
}
|
|
180
204
|
},
|
|
181
|
-
get: (env) => `[${env}] Block
|
|
205
|
+
get: (id, env, projectId) => `[${env}] Block ${id} in project ${projectId}:`,
|
|
182
206
|
list: (env, projectId) => `[${env}] Blocks in project ${projectId}:`,
|
|
183
207
|
noList: (env, projectId) => `[${env}] Cannot retrieve blocks in project ${projectId}`,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
208
|
+
getLogs: (id, branch, env, projectId) => `[${env}] Requesting logs from block ${import_logger.Logger.highlightText(
|
|
209
|
+
id
|
|
210
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
211
|
+
failedGetLogs: (id, env, projectId) => `[${env}] Unable to fetch block logs for ${import_logger.Logger.highlightText(
|
|
212
|
+
id
|
|
213
|
+
)} in project ${projectId}`,
|
|
214
|
+
tryPush: (id, branch, env, projectId) => `[${env}] Request to push block ${import_logger.Logger.highlightText(
|
|
215
|
+
id
|
|
216
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
217
|
+
pushed: (id, branch, env, projectId) => `[${env}] Pushed block ${import_logger.Logger.highlightText(
|
|
218
|
+
id
|
|
219
|
+
)} in branch ${branch} in project ${projectId}`,
|
|
220
|
+
failedPush: (id, env, projectId) => `[${env}] Unable to push block ${import_logger.Logger.highlightText(
|
|
221
|
+
id
|
|
222
|
+
)} in project ${projectId}`,
|
|
223
|
+
released: (id, env, projectId) => `[${env}] Released block ${import_logger.Logger.highlightText(
|
|
224
|
+
id
|
|
225
|
+
)} in project ${projectId}`,
|
|
226
|
+
failedRelease: (id, env, projectId) => `[${env}] Unable to release block ${import_logger.Logger.highlightText(
|
|
227
|
+
id
|
|
228
|
+
)} in project ${projectId}`,
|
|
229
|
+
deleted: (id, env, projectId) => `[${env}] Deleted block ${import_logger.Logger.highlightText(
|
|
230
|
+
id
|
|
231
|
+
)} in project ${projectId}`,
|
|
232
|
+
failedDelete: (id, env, projectId) => `[${env}] Unable to delete block ${import_logger.Logger.highlightText(
|
|
233
|
+
id
|
|
234
|
+
)} in project ${projectId}`
|
|
189
235
|
},
|
|
190
236
|
webhooks: {
|
|
191
237
|
list: (env) => `[${env}] Webhook subscriptions:`,
|
|
192
238
|
noList: (env) => `[${env}] Cannot retrieve webhook subscriptions`,
|
|
193
|
-
created: (env, name) => `[${env}] Created Webhook subscription
|
|
194
|
-
failedCreate: (env, name) => `[${env}] Unable to create Webhook subscription
|
|
195
|
-
|
|
196
|
-
|
|
239
|
+
created: (env, name) => `[${env}] Created Webhook subscription ${import_logger.Logger.highlightText(name)}`,
|
|
240
|
+
failedCreate: (env, name) => `[${env}] Unable to create Webhook subscription ${import_logger.Logger.highlightText(
|
|
241
|
+
name
|
|
242
|
+
)}`,
|
|
243
|
+
deleted: (env, id) => `[${env}] Deleted Webhook subscription ${import_logger.Logger.highlightText(id)}`,
|
|
244
|
+
failedDelete: (env, id) => `[${env}] Unable to delete Webhook subscription ${import_logger.Logger.highlightText(
|
|
245
|
+
id
|
|
246
|
+
)}`
|
|
197
247
|
}
|
|
198
248
|
};
|
|
199
249
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/localisation/en-GB.ts"],
|
|
4
|
-
"sourcesContent": ["import { BlockRunningStatus, MigrateStatus } from 'migratortron';\nimport { Logger } from '~/util/logger';\n\nexport const LogMessages = {\n app: {\n contensis: () => 'Contensis',\n quit: () => `Goodbye \uD83D\uDC4B\\n`,\n startup: () =>\n `\u00A9 2001-${new Date().getFullYear()} Zengenti \uD83C\uDDEC\uD83C\uDDE7. \\n - Creators of Contensis and purveyors of other fine software\\n\\n\uD83D\uDC4B Welcome to the contensis-cli\\n`,\n help: () =>\n 'Press [CTRL]+[C] or type \"quit\" to return to your system shell\\nPress [TAB] for suggestions\\n',\n suggestions: () =>\n `\\n${Logger.errorText('>>')} Press [TAB] for suggestions\\n`,\n autocomplete: () => `\\n${Logger.errorText('>>')} Available commands:`,\n unknownError: () => `Something went wrong...`,\n fileOutput: (format = 'json', path?: string) =>\n `Output ${format} file: ${Logger.infoText(path)}\\n`,\n noFileOutput: () => `No output written\\n`,\n },\n command: {\n notKnown: (command: string) => `${command} is not known`,\n },\n envs: {\n found: (num: number) =>\n `environments store found containing ${num} environment${\n num === 1 ? '' : 's'\n }`,\n tip: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n connect: {\n command: {\n name: () => 'connect',\n example: () => `Example call:\\n > connect example-dev`,\n },\n args: {\n alias: {\n name: () => '<alias>',\n description: () => 'the Contensis Cloud alias to connect with',\n },\n },\n noEnv: () => `Cannot connect - no environment alias specified`,\n unreachable: (url: string, status: number) =>\n `Cannot reach ${url}${status ? ` - status ${status}` : ''}`,\n connected: (env: string) => `Current environment set to \"${env}\"`,\n help: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n projects: () => `Available projects:`,\n noProjects: () => `Cannot retrieve projects list`,\n tip: () =>\n `Introduce yourself with \"login {username}\" or \"login {clientId} -s {secret}\" or by passing credentials as options with your command`,\n },\n login: {\n command: {\n name: () => 'login',\n usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,\n example: () =>\n `Example call:\\n > login myuserid\\n -- or --\\n > login {clientId} -s {sharedSecret}`,\n },\n args: {\n user: {\n name: () => '<user/clientId>',\n description: () => 'the username to login with',\n },\n password: {\n name: () => '[password]',\n description: () =>\n 'the password to use to login with (optional/insecure)',\n },\n secret: {\n name: () => '-s --sharedSecret <sharedSecret>',\n description: () =>\n 'the shared secret to use when logging in with a client id',\n },\n },\n passwordPrompt: (env: string, userId: string) =>\n `Enter password for ${userId}@${env}:`,\n failed: (env: string, userId: string) =>\n `Unable to login to ${env} as ${userId}`,\n success: (env: string, userId: string) =>\n `User ${userId} connected to ${env} successfully\\n`,\n insecurePassword: () =>\n `Could not connect to local keystore - your password could be stored unencrypted!`,\n noEnv: () => `No environment set, use \"contensis connect {alias}\" first`,\n noUserId: () => `No user id specified`,\n },\n projects: {\n list: () => `Available projects:`,\n noList: () => `Cannot retrieve projects list`,\n set: (projectId: string) => `Current project is set to \"${projectId}\"`,\n failedSet: (projectId: string) => `Project \"${projectId}\" not found`,\n },\n contenttypes: {\n list: (projectId: string) => `Content types in \"${projectId}\":`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve content types list`,\n get: (projectId: string, contentTypeId: string) =>\n `[${projectId}] Content type \"${contentTypeId}\"`,\n failedGet: (projectId: string, contentTypeId: string) =>\n `[${projectId}] Unable to get content type \"${contentTypeId}\"`,\n created: (projectId: string, componentId: string, status?: string) =>\n `[${projectId}] Content type ${status}d \"${componentId}\"`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} content type \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete content type \"${id}\"`,\n },\n components: {\n list: (projectId: string) => `Components in \"${projectId}\":`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve components list`,\n get: (projectId: string, componentId: string) =>\n `[${projectId}] Component \"${componentId}\"`,\n failedGet: (projectId: string, componentId: string) =>\n `[${projectId}] Unable to get component \"${componentId}\"`,\n created: (projectId: string, componentId: string, status?: string) =>\n `[${projectId}] Component ${status}d \"${componentId}\"`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} component \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete component \"${id}\"`,\n },\n version: {\n set: (env: string, versionStatus: string) =>\n `[${env}] Content version status set to \"${versionStatus}\"`,\n invalid: (versionStatus: string) =>\n `Content version status \"${versionStatus}\" is not valid, allowed values are \"published\" or \"latest\".`,\n noEnv: () =>\n `No Contensis environment set, connect to your Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n entries: {\n migrateStatus: (status: MigrateStatus) => {\n switch (status) {\n case 'no change':\n return Logger.successText;\n case 'create':\n case 'two-pass':\n case 'update':\n case 'delete':\n return Logger.warningText;\n case 'error':\n case 'not found':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} entry \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete entry \"${id}\"`,\n notFound: (id: string) => `Entry \"${id}\" not found`,\n commitTip: () => ` Add --commit flag to commit the previewed changes`,\n },\n keys: {\n list: (env: string) => `[${env}] API keys:`,\n noList: (env: string) => `[${env}] Cannot retrieve API`,\n created: (env: string, name: string) =>\n `[${env}] Created API key \"${name}\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create API key \"${name}\"`,\n removed: (env: string, id: string) => `[${env}] Deleted API key \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete API key \"${id}\"`,\n },\n blocks: {\n runningStatus: (status: BlockRunningStatus | 'broken') => {\n switch (status) {\n case 'available':\n return Logger.successText(status);\n case 'pending':\n case 'starting':\n case 'stopped':\n return Logger.warningText(status);\n case 'degraded':\n case 'faulted':\n case 'broken':\n return Logger.errorText(status);\n default:\n return Logger.infoText(status);\n }\n },\n get: (env: string) => `[${env}] Block versions:`,\n list: (env: string, projectId?: string) =>\n `[${env}] Blocks in project ${projectId}:`,\n noList: (env: string, projectId?: string) =>\n `[${env}] Cannot retrieve blocks in project ${projectId}`,\n tryPush: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Request to push block \"${id}\" in branch ${branch} in project ${projectId}`,\n pushed: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Pushed block \"${id}\" in branch ${branch} in project ${projectId}`,\n failedPush: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to push block \"${id}\" in project ${projectId}`,\n deleted: (id: string, env: string, projectId?: string) =>\n `[${env}] Deleted block \"${id}\" in project ${projectId}`,\n failedDelete: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to delete block \"${id}\" in project ${projectId}`,\n },\n webhooks: {\n list: (env: string) => `[${env}] Webhook subscriptions:`,\n noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,\n created: (env: string, name: string) =>\n `[${env}] Created Webhook subscription \"${name}\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create Webhook subscription \"${name}\"`,\n deleted: (env: string, id: string) =>\n `[${env}] Deleted Webhook subscription \"${id}\"`,\n failedDelete: (env: string, id: string) =>\n `[${env}] Unable to delete Webhook subscription \"${id}\"`,\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import {\n BlockRunningStatus,\n MigrateModelsResult,\n MigrateStatus,\n} from 'migratortron';\nimport { Logger } from '~/util/logger';\n\nexport const LogMessages = {\n app: {\n contensis: () => 'Contensis',\n quit: () => `Goodbye \uD83D\uDC4B\\n`,\n startup: (version: string) =>\n `v${version} \u00A9 2001-${new Date().getFullYear()} Zengenti \uD83C\uDDEC\uD83C\uDDE7. \\n - Creators of Contensis and purveyors of other fine software\\n\\n\uD83D\uDC4B Welcome to the contensis-cli\\n`,\n help: () =>\n 'Press [CTRL]+[C] or type \"quit\" to return to your system shell\\nPress [TAB] for suggestions\\n',\n suggestions: () =>\n `\\n${Logger.errorText('>>')} Press [TAB] for suggestions\\n`,\n autocomplete: () => `\\n${Logger.errorText('>>')} Available commands:`,\n unknownError: () => `Something went wrong...`,\n fileOutput: (format = 'json', path?: string) =>\n `Output ${format} file: ${Logger.infoText(path)}\\n`,\n noFileOutput: () => `No output written\\n`,\n },\n command: {\n notKnown: (command: string) => `${command} is not known`,\n },\n envs: {\n found: (num: number) =>\n `environments store found containing ${num} environment${\n num === 1 ? '' : 's'\n }`,\n tip: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n connect: {\n command: {\n name: () => 'connect',\n example: () => `Example call:\\n > connect example-dev`,\n },\n args: {\n alias: {\n name: () => '<alias>',\n description: () => 'the Contensis Cloud alias to connect with',\n },\n },\n noEnv: () => `Cannot connect - no environment alias specified`,\n unreachable: (url: string, status: number) =>\n `Cannot reach ${url}${status ? ` - status ${status}` : ''}`,\n connected: (env: string) => `Current environment set to \"${env}\"`,\n help: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n projects: () => `Available projects:`,\n noProjects: () => `Cannot retrieve projects list`,\n tip: () =>\n `Introduce yourself with \"login {username}\" or \"login {clientId} -s {secret}\" or by passing credentials as options with your command`,\n },\n login: {\n command: {\n name: () => 'login',\n usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,\n example: () =>\n `Example call:\\n > login myuserid\\n -- or --\\n > login {clientId} -s {sharedSecret}`,\n },\n args: {\n user: {\n name: () => '<user/clientId>',\n description: () => 'the username to login with',\n },\n password: {\n name: () => '[password]',\n description: () =>\n 'the password to use to login with (optional/insecure)',\n },\n secret: {\n name: () => '-s --sharedSecret <sharedSecret>',\n description: () =>\n 'the shared secret to use when logging in with a client id',\n },\n },\n passwordPrompt: (env?: string, userId?: string) =>\n userId\n ? `Enter password for ${userId}@${env}:`\n : `Please enter a password`,\n failed: (env: string, userId: string) =>\n `Unable to login to ${env} as ${userId}`,\n success: (env: string, userId: string) =>\n `User ${userId} connected to ${env} successfully\\n`,\n insecurePassword: () =>\n `Could not connect to local keystore - your password could be stored unencrypted!`,\n noEnv: () => `No environment set, use \"contensis connect {alias}\" first`,\n noUserId: () => `No user id specified`,\n },\n projects: {\n list: () => `Available projects:`,\n noList: () => `Cannot retrieve projects list`,\n set: (projectId: string) =>\n `Current project is set to ${Logger.highlightText(projectId)}`,\n failedSet: (projectId: string) =>\n `Project ${Logger.highlightText(projectId)} not found`,\n tip: () =>\n `You need to set your current working project with \"set project {projectId}\"`,\n created: (env: string, id: string) =>\n `[${env}] Created project ${Logger.highlightText(id)}`,\n failedCreate: (env: string, id: string) =>\n `[${env}] Unable to create project ${Logger.highlightText(id)}`,\n updated: (env: string, id: string) =>\n `[${env}] Updated project ${Logger.highlightText(id)}`,\n failedUpdate: (env: string, id: string) =>\n `[${env}] Unable to update project ${Logger.highlightText(id)}`,\n },\n migrate: {\n models: {\n result: (\n status: keyof MigrateModelsResult['project']['contentTypes']\n ) => {\n switch (status) {\n case 'created':\n case 'updated':\n return Logger.successText;\n case 'errors':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n status: (status: MigrateStatus) => {\n switch (status) {\n case 'no change':\n return Logger.successText;\n case 'create':\n case 'two-pass':\n case 'update':\n case 'delete':\n return Logger.warningText;\n case 'error':\n case 'not found':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n models: {\n list: (projectId: string) =>\n `Content models in ${Logger.highlightText(projectId)}:`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve content models`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content models ${Logger.infoText(`[ ${id} ]`)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content models ${Logger.highlightText(id)}`,\n },\n contenttypes: {\n list: (projectId: string) =>\n `Content types in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content type ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content type ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Content type ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } content type ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete content type ${Logger.highlightText(id)}`,\n },\n components: {\n list: (projectId: string) =>\n `Components in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Component ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get component ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Component ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } component ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete component ${Logger.highlightText(id)}`,\n },\n version: {\n set: (env: string, versionStatus: string) =>\n `[${env}] Content version status set to \"${versionStatus}\"`,\n invalid: (versionStatus: string) =>\n `Content version status \"${versionStatus}\" is not valid, allowed values are \"published\" or \"latest\".`,\n noEnv: () =>\n `No Contensis environment set, connect to your Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n entries: {\n removed: (env: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} entries`,\n failedRemove: (env: string) => `[${env}] Unable to delete entries`,\n notFound: (env: string) => `[${env}] Entries were not found`,\n commitTip: () => ` Add --commit flag to commit the previewed changes`,\n },\n keys: {\n list: (env: string) => `[${env}] API keys:`,\n noList: (env: string) => `[${env}] Cannot retrieve API`,\n created: (env: string, name: string) =>\n `[${env}] Created API key ${Logger.highlightText(name)}`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create API key ${Logger.highlightText(name)}`,\n removed: (env: string, id: string) =>\n `[${env}] Deleted API key ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete API key ${Logger.highlightText(id)}`,\n },\n blocks: {\n runningStatus: (status: BlockRunningStatus | 'broken') => {\n switch (status) {\n case 'available':\n return Logger.successText(status);\n case 'pending':\n case 'starting':\n case 'stopped':\n return Logger.warningText(status);\n case 'degraded':\n case 'faulted':\n case 'broken':\n return Logger.errorText(status);\n default:\n return Logger.infoText(status);\n }\n },\n get: (id: string, env: string, projectId?: string) =>\n `[${env}] Block ${id} in project ${projectId}:`,\n list: (env: string, projectId?: string) =>\n `[${env}] Blocks in project ${projectId}:`,\n noList: (env: string, projectId?: string) =>\n `[${env}] Cannot retrieve blocks in project ${projectId}`,\n getLogs: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Requesting logs from block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedGetLogs: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to fetch block logs for ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n tryPush: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Request to push block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n pushed: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Pushed block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedPush: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to push block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n released: (id: string, env: string, projectId?: string) =>\n `[${env}] Released block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n failedRelease: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to release block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n deleted: (id: string, env: string, projectId?: string) =>\n `[${env}] Deleted block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n failedDelete: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to delete block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n },\n webhooks: {\n list: (env: string) => `[${env}] Webhook subscriptions:`,\n noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,\n created: (env: string, name: string) =>\n `[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create Webhook subscription ${Logger.highlightText(\n name\n )}`,\n deleted: (env: string, id: string) =>\n `[${env}] Deleted Webhook subscription ${Logger.highlightText(id)}`,\n failedDelete: (env: string, id: string) =>\n `[${env}] Unable to delete Webhook subscription ${Logger.highlightText(\n id\n )}`,\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAuB;AAEhB,MAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA;AAAA,IACZ,SAAS,CAAC,YACR,IAAI,qBAAkB,IAAI,KAAK,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,IAC/C,MAAM,MACJ;AAAA,IACF,aAAa,MACX;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA;AAAA,IAC5B,cAAc,MAAM;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA,IAC9C,cAAc,MAAM;AAAA,IACpB,YAAY,CAAC,SAAS,QAAQ,SAC5B,UAAU,gBAAgB,qBAAO,SAAS,IAAI;AAAA;AAAA,IAChD,cAAc,MAAM;AAAA;AAAA,EACtB;AAAA,EACA,SAAS;AAAA,IACP,UAAU,CAAC,YAAoB,GAAG;AAAA,EACpC;AAAA,EACA,MAAM;AAAA,IACJ,OAAO,CAAC,QACN,uCAAuC,kBACrC,QAAQ,IAAI,KAAK;AAAA,IAErB,KAAK,MACH;AAAA,EACJ;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,MACP,MAAM,MAAM;AAAA,MACZ,SAAS,MAAM;AAAA;AAAA,IACjB;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,QACL,MAAM,MAAM;AAAA,QAC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AAAA,MACzC;AAAA,IACF,gBAAgB;AAAA,IAClB,SAAS,CAAC,IAAY,KAAa,cACjC,IAAI,sBAAsB,qBAAO;AAAA,MAC/B;AAAA,IACF,gBAAgB;AAAA,IAClB,cAAc,CAAC,IAAY,KAAa,cACtC,IAAI,+BAA+B,qBAAO;AAAA,MACxC;AAAA,IACF,gBAAgB;AAAA,EACpB;AAAA,EACA,UAAU;AAAA,IACR,MAAM,CAAC,QAAgB,IAAI;AAAA,IAC3B,QAAQ,CAAC,QAAgB,IAAI;AAAA,IAC7B,SAAS,CAAC,KAAa,SACrB,IAAI,qCAAqC,qBAAO,cAAc,IAAI;AAAA,IACpE,cAAc,CAAC,KAAa,SAC1B,IAAI,8CAA8C,qBAAO;AAAA,MACvD;AAAA,IACF;AAAA,IACF,SAAS,CAAC,KAAa,OACrB,IAAI,qCAAqC,qBAAO,cAAc,EAAE;AAAA,IAClE,cAAc,CAAC,KAAa,OAC1B,IAAI,8CAA8C,qBAAO;AAAA,MACvD;AAAA,IACF;AAAA,EACJ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,12 +27,12 @@ __export(CredentialProvider_exports, {
|
|
|
27
27
|
default: () => CredentialProvider_default
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(CredentialProvider_exports);
|
|
30
|
-
var import_keytar = __toESM(require("keytar"));
|
|
31
30
|
var import_await_to_js = __toESM(require("await-to-js"));
|
|
32
31
|
var import_logger = require("../util/logger");
|
|
33
32
|
const SERVICE_NAME = "contensis-cli";
|
|
34
33
|
class CredentialProvider {
|
|
35
34
|
serviceId;
|
|
35
|
+
keytar;
|
|
36
36
|
userId = "";
|
|
37
37
|
passwordFallback;
|
|
38
38
|
current = null;
|
|
@@ -42,12 +42,39 @@ class CredentialProvider {
|
|
|
42
42
|
this.userId = userId;
|
|
43
43
|
this.passwordFallback = passwordFallback;
|
|
44
44
|
}
|
|
45
|
+
Import = async () => {
|
|
46
|
+
try {
|
|
47
|
+
this.keytar = (await import("keytar")).default;
|
|
48
|
+
} catch (ex) {
|
|
49
|
+
this.keytar = {
|
|
50
|
+
findCredentials: async () => {
|
|
51
|
+
throw ex;
|
|
52
|
+
},
|
|
53
|
+
getPassword: async () => {
|
|
54
|
+
throw ex;
|
|
55
|
+
},
|
|
56
|
+
findPassword: async () => {
|
|
57
|
+
throw ex;
|
|
58
|
+
},
|
|
59
|
+
setPassword: async () => {
|
|
60
|
+
throw ex;
|
|
61
|
+
},
|
|
62
|
+
deletePassword: async () => {
|
|
63
|
+
throw ex;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
45
68
|
Init = async () => {
|
|
69
|
+
await this.Import();
|
|
46
70
|
const [err, stored] = await (0, import_await_to_js.default)(
|
|
47
|
-
|
|
71
|
+
this.keytar.findCredentials(this.serviceId)
|
|
48
72
|
);
|
|
49
73
|
if (err && this.passwordFallback) {
|
|
50
|
-
this.current = {
|
|
74
|
+
this.current = {
|
|
75
|
+
account: this.userId,
|
|
76
|
+
password: this.passwordFallback
|
|
77
|
+
};
|
|
51
78
|
}
|
|
52
79
|
if (!err) {
|
|
53
80
|
this.remarks = { secure: true };
|
|
@@ -57,15 +84,17 @@ class CredentialProvider {
|
|
|
57
84
|
return ((_a = u == null ? void 0 : u.account) == null ? void 0 : _a.toLowerCase()) === this.userId.toLowerCase();
|
|
58
85
|
}
|
|
59
86
|
)) || null;
|
|
87
|
+
if (!this.current && this.passwordFallback) {
|
|
88
|
+
await this.Save(this.passwordFallback);
|
|
89
|
+
return await this.Init();
|
|
90
|
+
}
|
|
60
91
|
}
|
|
61
92
|
return [err, this];
|
|
62
93
|
};
|
|
63
94
|
Save = async (password) => {
|
|
64
95
|
const [err] = await (0, import_await_to_js.default)(
|
|
65
|
-
|
|
96
|
+
this.keytar.setPassword(this.serviceId, this.userId, password)
|
|
66
97
|
);
|
|
67
|
-
if (!err)
|
|
68
|
-
import_logger.Logger.info(`${this.serviceId} - credentials saved`);
|
|
69
98
|
return err && !this.passwordFallback ? err : true;
|
|
70
99
|
};
|
|
71
100
|
Delete = async () => {
|
|
@@ -74,7 +103,7 @@ class CredentialProvider {
|
|
|
74
103
|
return true;
|
|
75
104
|
} else {
|
|
76
105
|
const [err] = await (0, import_await_to_js.default)(
|
|
77
|
-
|
|
106
|
+
this.keytar.deletePassword(this.serviceId, this.userId)
|
|
78
107
|
);
|
|
79
108
|
import_logger.Logger.warning(`${this.serviceId} - invalid credentials removed`);
|
|
80
109
|
return err || true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/providers/CredentialProvider.ts"],
|
|
4
|
-
"sourcesContent": ["import keytar from 'keytar';\nimport to from 'await-to-js';\nimport { Logger } from '~/util/logger';\n\nconst SERVICE_NAME = 'contensis-cli';\n\ninterface Remarks {\n secure: boolean;\n}\n\nclass CredentialProvider {\n private serviceId: string;\n private userId: string = '';\n private passwordFallback?: string;\n\n current: {\n account: string;\n password: string;\n } | null = null;\n remarks: Remarks = { secure: false };\n\n constructor(\n { userId, alias }: { userId: string; alias?: string },\n passwordFallback?: string\n ) {\n this.serviceId =\n typeof alias !== 'undefined' ? `${SERVICE_NAME}_${alias}` : SERVICE_NAME;\n this.userId = userId;\n this.passwordFallback = passwordFallback;\n }\n\n Init = async (): Promise<[Error, CredentialProvider]> => {\n const [err, stored] = (await to(\n keytar.findCredentials(this.serviceId)\n )) as [\n Error,\n {\n account: string;\n password: string;\n }[]\n ];\n if (err && this.passwordFallback) {\n this.current = {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["to"
|
|
4
|
+
"sourcesContent": ["import keytar from 'keytar';\nimport to from 'await-to-js';\nimport { Logger } from '~/util/logger';\n\nconst SERVICE_NAME = 'contensis-cli';\n\ninterface Remarks {\n secure: boolean;\n}\n\nclass CredentialProvider {\n private serviceId: string;\n private keytar!: typeof keytar;\n private userId: string = '';\n private passwordFallback?: string;\n\n current: {\n account: string;\n password: string;\n } | null = null;\n remarks: Remarks = { secure: false };\n\n constructor(\n { userId, alias }: { userId: string; alias?: string },\n passwordFallback?: string\n ) {\n this.serviceId =\n typeof alias !== 'undefined' ? `${SERVICE_NAME}_${alias}` : SERVICE_NAME;\n this.userId = userId;\n this.passwordFallback = passwordFallback;\n }\n\n Import = async () => {\n try {\n this.keytar = (await import('keytar')).default;\n } catch (ex) {\n this.keytar = {\n findCredentials: async () => {\n throw ex;\n },\n getPassword: async () => {\n throw ex;\n },\n findPassword: async () => {\n throw ex;\n },\n setPassword: async () => {\n throw ex;\n },\n deletePassword: async () => {\n throw ex;\n },\n };\n }\n };\n\n Init = async (): Promise<[Error, CredentialProvider]> => {\n await this.Import();\n const [err, stored] = (await to(\n this.keytar.findCredentials(this.serviceId)\n )) as [\n Error,\n {\n account: string;\n password: string;\n }[]\n ];\n if (err && this.passwordFallback) {\n this.current = {\n account: this.userId,\n password: this.passwordFallback,\n };\n }\n if (!err) {\n this.remarks = { secure: true };\n this.current =\n stored?.find(\n u => u?.account?.toLowerCase() === this.userId.toLowerCase()\n ) || null;\n\n if (!this.current && this.passwordFallback) {\n await this.Save(this.passwordFallback);\n return await this.Init();\n }\n }\n return [err, this];\n };\n\n Save = async (password: string) => {\n const [err] = await to(\n this.keytar.setPassword(this.serviceId, this.userId, password)\n );\n\n // if (!err) Logger.info(`${this.serviceId} - credentials saved`);\n return err && !this.passwordFallback ? err : true;\n };\n\n Delete = async () => {\n if (this.passwordFallback) {\n this.passwordFallback = undefined;\n return true;\n } else {\n const [err] = await to(\n this.keytar.deletePassword(this.serviceId, this.userId)\n );\n\n Logger.warning(`${this.serviceId} - invalid credentials removed`);\n return err || true;\n }\n };\n\n // GetPassword = async () => {\n // const [err, password] = await to(\n // keytar.getPassword(this.serviceId, this.userId)\n // );\n\n // return err || password;\n // };\n}\n\nexport default CredentialProvider;\n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O,YAAY;AAAA;AAAA,YACxD;AAEP,UAAI,CAAC,KAAK,WAAW,KAAK,kBAAkB;AAC1C,cAAM,KAAK,KAAK,KAAK,gBAAgB;AACrC,eAAO,MAAM,KAAK,KAAK;AAAA,MACzB;AAAA,IACF;AACA,WAAO,CAAC,KAAK,IAAI;AAAA,EACnB;AAAA,EAEA,OAAO,OAAO,aAAqB;AACjC,UAAM,CAAC,GAAG,IAAI,UAAM,mBAAAA;AAAA,MAClB,KAAK,OAAO,YAAY,KAAK,WAAW,KAAK,QAAQ,QAAQ;AAAA,IAC/D;AAGA,WAAO,OAAO,CAAC,KAAK,mBAAmB,MAAM;AAAA,EAC/C;AAAA,EAEA,SAAS,YAAY;AACnB,QAAI,KAAK,kBAAkB;AACzB,WAAK,mBAAmB;AACxB,aAAO;AAAA,IACT,OAAO;AACL,YAAM,CAAC,GAAG,IAAI,UAAM,mBAAAA;AAAA,QAClB,KAAK,OAAO,eAAe,KAAK,WAAW,KAAK,MAAM;AAAA,MACxD;AAEA,2BAAO,QAAQ,GAAG,KAAK,yCAAyC;AAChE,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AASF;AAEA,IAAO,6BAAQ;",
|
|
6
|
+
"names": ["to"]
|
|
7
7
|
}
|
|
@@ -32,13 +32,14 @@ var import_path = __toESM(require("path"));
|
|
|
32
32
|
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
33
33
|
var import_mergeWith = __toESM(require("lodash/mergeWith"));
|
|
34
34
|
var import_unionBy = __toESM(require("lodash/unionBy"));
|
|
35
|
+
var import_file_provider = require("./file-provider");
|
|
35
36
|
var import_util = require("../util");
|
|
36
37
|
var import_logger = require("../util/logger");
|
|
37
38
|
class SessionCacheProvider {
|
|
38
39
|
localFilePath;
|
|
39
40
|
cache = {};
|
|
40
41
|
constructor() {
|
|
41
|
-
this.localFilePath = import_path.default.join(
|
|
42
|
+
this.localFilePath = import_path.default.join(import_file_provider.appRootDir, "environments.json");
|
|
42
43
|
this.cache = {
|
|
43
44
|
currentTimestamp: new Date().toISOString(),
|
|
44
45
|
environments: {},
|
|
@@ -84,6 +85,25 @@ class SessionCacheProvider {
|
|
|
84
85
|
}
|
|
85
86
|
return this.Get();
|
|
86
87
|
};
|
|
88
|
+
UpdateEnv = (updateContent, env = this.cache.currentEnvironment, setCurrentEnv = true) => {
|
|
89
|
+
try {
|
|
90
|
+
const environment = this.cache.environments[env || ""];
|
|
91
|
+
this.cache.environments[env || ""] = {
|
|
92
|
+
...environment,
|
|
93
|
+
...updateContent
|
|
94
|
+
};
|
|
95
|
+
this.Update({
|
|
96
|
+
currentEnvironment: setCurrentEnv ? env : this.cache.currentEnvironment,
|
|
97
|
+
environments: this.cache.environments
|
|
98
|
+
});
|
|
99
|
+
} catch (ex) {
|
|
100
|
+
import_logger.Logger.error(
|
|
101
|
+
`Problem updating environment "${env}" in environments.json`
|
|
102
|
+
);
|
|
103
|
+
import_logger.Logger.error(ex);
|
|
104
|
+
}
|
|
105
|
+
return this.Get();
|
|
106
|
+
};
|
|
87
107
|
}
|
|
88
108
|
var SessionCacheProvider_default = SessionCacheProvider;
|
|
89
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/providers/SessionCacheProvider.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport clone from 'lodash/cloneDeep';\nimport mergeWith from 'lodash/mergeWith';\nimport unionBy from 'lodash/unionBy';\nimport { isJson, tryParse
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,uBAAkB;AAClB,uBAAsB;AACtB,qBAAoB;AACpB,
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport clone from 'lodash/cloneDeep';\nimport mergeWith from 'lodash/mergeWith';\nimport unionBy from 'lodash/unionBy';\nimport { appRootDir } from './file-provider';\nimport { isJson, tryParse } from '~/util';\nimport { Logger } from '~/util/logger';\n\nclass SessionCacheProvider {\n private localFilePath: string;\n private cache = {} as SessionCache;\n\n constructor() {\n this.localFilePath = path.join(appRootDir, 'environments.json');\n this.cache = {\n currentTimestamp: new Date().toISOString(),\n environments: {},\n history: [],\n };\n this.ReadCacheFromDisk();\n }\n\n private ReadCacheFromDisk = () => {\n try {\n if (fs.existsSync(this.localFilePath)) {\n const raw = fs.readFileSync(this.localFilePath, 'utf-8');\n if (isJson(raw)) this.cache = tryParse(raw);\n } else {\n this.WriteCacheToDisk();\n }\n } catch (ex) {\n // Problem reading or parsing cache file\n }\n };\n\n private WriteCacheToDisk = () => {\n try {\n fs.writeFileSync(this.localFilePath, JSON.stringify(this.cache, null, 2));\n } catch (ex) {\n // Problem writing session cache to file\n }\n };\n\n Get = () => clone(this.cache);\n\n Update = (updateContent: Partial<SessionCache>) => {\n try {\n this.cache = mergeWith(this.cache, updateContent, (val, src, key) => {\n if (\n key === 'history' &&\n ((src?.[0] &&\n typeof src[0] === 'object' &&\n 'createdDate' in src[0]) ||\n (val?.[0] && typeof val[0] === 'object' && 'createdDate' in val[0]))\n ) {\n return unionBy(val, src, 'createdDate');\n }\n if (key === 'projects')\n return Array.isArray(val) ? [...new Set([...val, ...src])] : src;\n\n if (Array.isArray(val)) return val.concat(src);\n });\n this.cache.currentTimestamp = new Date().toISOString();\n this.WriteCacheToDisk();\n } catch (ex: any) {\n // Problem merging cache data for update\n Logger.error(`Problem updating environments.json`);\n Logger.error(ex);\n }\n return this.Get();\n };\n\n UpdateEnv = (\n updateContent: Partial<EnvironmentCache>,\n env = this.cache.currentEnvironment,\n setCurrentEnv = true\n ) => {\n try {\n const environment = this.cache.environments[env || ''];\n\n this.cache.environments[env || ''] = {\n ...environment,\n ...updateContent,\n };\n this.Update({\n currentEnvironment: setCurrentEnv ? env : this.cache.currentEnvironment,\n environments: this.cache.environments,\n });\n } catch (ex: any) {\n // Problem merging cache data for update\n Logger.error(\n `Problem updating environment \"${env}\" in environments.json`\n );\n Logger.error(ex);\n }\n return this.Get();\n };\n}\n\nexport default SessionCacheProvider;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,uBAAkB;AAClB,uBAAsB;AACtB,qBAAoB;AACpB,2BAA2B;AAC3B,kBAAiC;AACjC,oBAAuB;AAEvB,MAAM,qBAAqB;AAAA,EACjB;AAAA,EACA,QAAQ,CAAC;AAAA,EAEjB,cAAc;AACZ,SAAK,gBAAgB,YAAAA,QAAK,KAAK,iCAAY,mBAAmB;AAC9D,SAAK,QAAQ;AAAA,MACX,kBAAkB,IAAI,KAAK,EAAE,YAAY;AAAA,MACzC,cAAc,CAAC;AAAA,MACf,SAAS,CAAC;AAAA,IACZ;AACA,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAEQ,oBAAoB,MAAM;AAChC,QAAI;AACF,UAAI,UAAAC,QAAG,WAAW,KAAK,aAAa,GAAG;AACrC,cAAM,MAAM,UAAAA,QAAG,aAAa,KAAK,eAAe,OAAO;AACvD,gBAAI,oBAAO,GAAG;AAAG,eAAK,YAAQ,sBAAS,GAAG;AAAA,MAC5C,OAAO;AACL,aAAK,iBAAiB;AAAA,MACxB;AAAA,IACF,SAAS,IAAP;AAAA,IAEF;AAAA,EACF;AAAA,EAEQ,mBAAmB,MAAM;AAC/B,QAAI;AACF,gBAAAA,QAAG,cAAc,KAAK,eAAe,KAAK,UAAU,KAAK,OAAO,MAAM,CAAC,CAAC;AAAA,IAC1E,SAAS,IAAP;AAAA,IAEF;AAAA,EACF;AAAA,EAEA,MAAM,UAAM,iBAAAC,SAAM,KAAK,KAAK;AAAA,EAE5B,SAAS,CAAC,kBAAyC;AACjD,QAAI;AACF,WAAK,YAAQ,iBAAAC,SAAU,KAAK,OAAO,eAAe,CAAC,KAAK,KAAK,QAAQ;AACnE,YACE,QAAQ,eACN,2BAAM,OACN,OAAO,IAAI,OAAO,YAClB,iBAAiB,IAAI,OACpB,2BAAM,OAAM,OAAO,IAAI,OAAO,YAAY,iBAAiB,IAAI,KAClE;AACA,qBAAO,eAAAC,SAAQ,KAAK,KAAK,aAAa;AAAA,QACxC;AACA,YAAI,QAAQ;AACV,iBAAO,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,IAAI;AAE/D,YAAI,MAAM,QAAQ,GAAG;AAAG,iBAAO,IAAI,OAAO,GAAG;AAAA,MAC/C,CAAC;AACD,WAAK,MAAM,mBAAmB,IAAI,KAAK,EAAE,YAAY;AACrD,WAAK,iBAAiB;AAAA,IACxB,SAAS,IAAP;AAEA,2BAAO,MAAM,oCAAoC;AACjD,2BAAO,MAAM,EAAE;AAAA,IACjB;AACA,WAAO,KAAK,IAAI;AAAA,EAClB;AAAA,EAEA,YAAY,CACV,eACA,MAAM,KAAK,MAAM,oBACjB,gBAAgB,SACb;AACH,QAAI;AACF,YAAM,cAAc,KAAK,MAAM,aAAa,OAAO;AAEnD,WAAK,MAAM,aAAa,OAAO,MAAM;AAAA,QACnC,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AACA,WAAK,OAAO;AAAA,QACV,oBAAoB,gBAAgB,MAAM,KAAK,MAAM;AAAA,QACrD,cAAc,KAAK,MAAM;AAAA,MAC3B,CAAC;AAAA,IACH,SAAS,IAAP;AAEA,2BAAO;AAAA,QACL,iCAAiC;AAAA,MACnC;AACA,2BAAO,MAAM,EAAE;AAAA,IACjB;AACA,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;AAEA,IAAO,+BAAQ;",
|
|
6
6
|
"names": ["path", "fs", "clone", "mergeWith", "unionBy"]
|
|
7
7
|
}
|
|
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var file_provider_exports = {};
|
|
26
26
|
__export(file_provider_exports, {
|
|
27
|
+
appRootDir: () => appRootDir,
|
|
27
28
|
checkDir: () => checkDir,
|
|
28
29
|
localPath: () => localPath,
|
|
29
30
|
moveFile: () => moveFile,
|
|
@@ -35,9 +36,11 @@ __export(file_provider_exports, {
|
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(file_provider_exports);
|
|
37
38
|
var import_fs = __toESM(require("fs"));
|
|
39
|
+
var import_os = require("os");
|
|
38
40
|
var import_path = __toESM(require("path"));
|
|
39
|
-
var import_app_root_path = require("app-root-path");
|
|
40
41
|
var import_util = require("../util");
|
|
42
|
+
const userHomeDir = (0, import_os.homedir)();
|
|
43
|
+
const appRootDir = import_path.default.join(userHomeDir, ".contensis/");
|
|
41
44
|
const readJsonFile = (filePath) => {
|
|
42
45
|
const file = readFile(filePath);
|
|
43
46
|
if (file)
|
|
@@ -74,8 +77,8 @@ const removeFile = (filePath) => {
|
|
|
74
77
|
}
|
|
75
78
|
};
|
|
76
79
|
const moveFile = (file, fromPath, toPath) => {
|
|
77
|
-
const from = import_path.default.join(
|
|
78
|
-
const to = import_path.default.join(
|
|
80
|
+
const from = import_path.default.join(appRootDir, `${fromPath}${file}`);
|
|
81
|
+
const to = import_path.default.join(appRootDir, `${toPath}${file}`);
|
|
79
82
|
if (import_fs.default.existsSync(from)) {
|
|
80
83
|
checkDir(toPath);
|
|
81
84
|
import_fs.default.rename(from, to, (err) => {
|
|
@@ -98,9 +101,10 @@ const checkDir = (filePath) => {
|
|
|
98
101
|
if (!import_fs.default.existsSync(directoryPath))
|
|
99
102
|
import_fs.default.mkdirSync(directoryPath, { recursive: true });
|
|
100
103
|
};
|
|
101
|
-
const localPath = (filePath) => import_path.default.join(
|
|
104
|
+
const localPath = (filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(appRootDir, filePath);
|
|
102
105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
106
|
0 && (module.exports = {
|
|
107
|
+
appRootDir,
|
|
104
108
|
checkDir,
|
|
105
109
|
localPath,
|
|
106
110
|
moveFile,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/providers/file-provider.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport { homedir } from 'os';\nimport path from 'path';\nimport { tryParse } from '~/util';\n\nconst userHomeDir = homedir();\nexport const appRootDir = path.join(userHomeDir, '.contensis/');\n\nexport const readJsonFile = <T>(filePath: string) => {\n const file = readFile(filePath);\n if (file) return tryParse(file) as T | string;\n return undefined;\n};\nexport const readFile = (filePath: string) => {\n const directoryPath = localPath(filePath);\n if (fs.existsSync(directoryPath)) {\n const file = fs.readFileSync(directoryPath, 'utf8');\n return file;\n } else {\n return undefined;\n }\n};\n\nexport const readFiles = (directory: string) => {\n const directoryPath = localPath(directory);\n if (fs.existsSync(directoryPath)) {\n const files = fs.readdirSync(directoryPath);\n return files;\n } else {\n fs.mkdirSync(directoryPath, { recursive: true });\n return [];\n }\n};\n\nexport const writeFile = (filePath: string, content: string) => {\n const directoryPath = localPath(filePath);\n fs.writeFileSync(directoryPath, content, { encoding: 'utf-8' });\n};\n\nexport const removeFile = (filePath: string) => {\n const directoryPath = localPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath);\n }\n};\n\nexport const moveFile = (file: string, fromPath: string, toPath: string) => {\n const from = path.join(appRootDir, `${fromPath}${file}`);\n const to = path.join(appRootDir, `${toPath}${file}`);\n if (fs.existsSync(from)) {\n checkDir(toPath);\n // if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });\n\n fs.rename(from, to, err => {\n if (err)\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}`,\n err\n );\n console.info(`Renamed file \"${file}\" from: ${fromPath} to: ${toPath}`);\n });\n } else {\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}\\nFile does not exist!`\n );\n }\n};\n\nexport const checkDir = (filePath: string) => {\n const directoryPath = path.dirname(localPath(filePath));\n if (!fs.existsSync(directoryPath))\n fs.mkdirSync(directoryPath, { recursive: true });\n};\n\nexport const localPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(appRootDir, filePath);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,gBAAwB;AACxB,kBAAiB;AACjB,kBAAyB;AAEzB,MAAM,kBAAc,mBAAQ;AACrB,MAAM,aAAa,YAAAA,QAAK,KAAK,aAAa,aAAa;AAEvD,MAAM,eAAe,CAAI,aAAqB;AACnD,QAAM,OAAO,SAAS,QAAQ;AAC9B,MAAI;AAAM,eAAO,sBAAS,IAAI;AAC9B,SAAO;AACT;AACO,MAAM,WAAW,CAAC,aAAqB;AAC5C,QAAM,gBAAgB,UAAU,QAAQ;AACxC,MAAI,UAAAC,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,OAAO,UAAAA,QAAG,aAAa,eAAe,MAAM;AAClD,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEO,MAAM,YAAY,CAAC,cAAsB;AAC9C,QAAM,gBAAgB,UAAU,SAAS;AACzC,MAAI,UAAAA,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,QAAQ,UAAAA,QAAG,YAAY,aAAa;AA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