contensis-cli 1.0.0-beta.11 → 1.0.0-beta.12
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/dist/commands/connect.js +1 -1
- package/dist/commands/connect.js.map +2 -2
- package/dist/commands/set.js +4 -8
- package/dist/commands/set.js.map +2 -2
- package/dist/localisation/en-GB.js +2 -1
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/SessionCacheProvider.js +19 -0
- package/dist/providers/SessionCacheProvider.js.map +2 -2
- package/dist/services/ContensisCliService.js +53 -66
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/connect.ts +1 -1
- package/src/commands/set.ts +6 -10
- package/src/localisation/en-GB.ts +2 -0
- package/src/providers/SessionCacheProvider.ts +26 -1
- package/src/services/ContensisCliService.ts +62 -80
- package/src/version.ts +1 -1
package/dist/commands/connect.js
CHANGED
|
@@ -32,7 +32,7 @@ const makeConnectCommand = () => {
|
|
|
32
32
|
Example call:
|
|
33
33
|
> connect example-dev`
|
|
34
34
|
).action(async (alias, opts) => {
|
|
35
|
-
await (0, import_ContensisCliService.cliCommand)(["connect", alias], opts).Connect(alias);
|
|
35
|
+
await (0, import_ContensisCliService.cliCommand)(["connect", alias], { ...opts, alias }).Connect(alias);
|
|
36
36
|
await (0, import_shell.shell)().start();
|
|
37
37
|
});
|
|
38
38
|
return connect;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/connect.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport { shell } from '~/shell';\nimport { project } from './globalOptions';\n\nexport const makeConnectCommand = () => {\n const connect = new Command()\n .command('connect')\n .argument('<alias>', 'the Contensis Cloud alias to connect with')\n .addOption(project)\n .usage('<alias>')\n .addHelpText(\n 'after',\n `\nExample call:\n > connect example-dev`\n )\n .action(async (alias, opts) => {\n await cliCommand(['connect', alias], opts).Connect(alias);\n await shell().start();\n });\n return connect;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,iCAA2B;AAC3B,mBAAsB;AACtB,2BAAwB;AAEjB,MAAM,qBAAqB,MAAM;AACtC,QAAM,UAAU,IAAI,yBAAQ,EACzB,QAAQ,SAAS,EACjB,SAAS,WAAW,2CAA2C,EAC/D,UAAU,4BAAO,EACjB,MAAM,SAAS,EACf;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA,EAGF,EACC,OAAO,OAAO,OAAO,SAAS;AAC7B,cAAM,uCAAW,CAAC,WAAW,KAAK,GAAG,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport { shell } from '~/shell';\nimport { project } from './globalOptions';\n\nexport const makeConnectCommand = () => {\n const connect = new Command()\n .command('connect')\n .argument('<alias>', 'the Contensis Cloud alias to connect with')\n .addOption(project)\n .usage('<alias>')\n .addHelpText(\n 'after',\n `\nExample call:\n > connect example-dev`\n )\n .action(async (alias, opts) => {\n await cliCommand(['connect', alias], { ...opts, alias }).Connect(alias);\n await shell().start();\n });\n return connect;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,iCAA2B;AAC3B,mBAAsB;AACtB,2BAAwB;AAEjB,MAAM,qBAAqB,MAAM;AACtC,QAAM,UAAU,IAAI,yBAAQ,EACzB,QAAQ,SAAS,EACjB,SAAS,WAAW,2CAA2C,EAC/D,UAAU,4BAAO,EACjB,MAAM,SAAS,EACf;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA,EAGF,EACC,OAAO,OAAO,OAAO,SAAS;AAC7B,cAAM,uCAAW,CAAC,WAAW,KAAK,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,EAAE,QAAQ,KAAK;AACtE,cAAM,oBAAM,EAAE,MAAM;AAAA,EACtB,CAAC;AACH,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/commands/set.js
CHANGED
|
@@ -27,22 +27,18 @@ var import_shell = require("../shell");
|
|
|
27
27
|
const makeSetCommand = () => {
|
|
28
28
|
const set = new import_commander.Command().command("set").showHelpAfterError(true).exitOverride();
|
|
29
29
|
set.command("project").argument("<projectId>", "the project id to work with").usage("<projectId>").action(async (projectId) => {
|
|
30
|
-
const project =
|
|
31
|
-
"set",
|
|
32
|
-
"project",
|
|
30
|
+
const project = (0, import_ContensisCliService.cliCommand)(["set", "project", projectId]).SetProject(
|
|
33
31
|
projectId
|
|
34
|
-
|
|
32
|
+
);
|
|
35
33
|
if (project)
|
|
36
34
|
await (0, import_shell.shell)().start();
|
|
37
35
|
});
|
|
38
36
|
set.command("version").addArgument(
|
|
39
37
|
new import_commander.Argument("<versionStatus>", "content version status").choices(["latest", "published"]).default("latest")
|
|
40
38
|
).usage("<latest/published>").action(async (versionStatus) => {
|
|
41
|
-
const success =
|
|
42
|
-
"set",
|
|
43
|
-
"version",
|
|
39
|
+
const success = (0, import_ContensisCliService.cliCommand)(["set", "version", versionStatus]).SetVersion(
|
|
44
40
|
versionStatus
|
|
45
|
-
|
|
41
|
+
);
|
|
46
42
|
if (success)
|
|
47
43
|
await (0, import_shell.shell)().start();
|
|
48
44
|
});
|
package/dist/commands/set.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/set.ts"],
|
|
4
|
-
"sourcesContent": ["import { Argument, Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport { shell } from '~/shell';\n\nexport const makeSetCommand = () => {\n const set = new Command()\n .command('set')\n .showHelpAfterError(true)\n .exitOverride();\n set\n .command('project')\n .argument('<projectId>', 'the project id to work with')\n .usage('<projectId>')\n .action(async projectId => {\n const project =
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkC;AAClC,iCAA2B;AAC3B,mBAAsB;AAEf,MAAM,iBAAiB,MAAM;AAClC,QAAM,MAAM,IAAI,yBAAQ,EACrB,QAAQ,KAAK,EACb,mBAAmB,IAAI,EACvB,aAAa;AAChB,MACG,QAAQ,SAAS,EACjB,SAAS,eAAe,6BAA6B,EACrD,MAAM,aAAa,EACnB,OAAO,OAAM,cAAa;AACzB,UAAM,
|
|
4
|
+
"sourcesContent": ["import { Argument, Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport { shell } from '~/shell';\n\nexport const makeSetCommand = () => {\n const set = new Command()\n .command('set')\n .showHelpAfterError(true)\n .exitOverride();\n set\n .command('project')\n .argument('<projectId>', 'the project id to work with')\n .usage('<projectId>')\n .action(async projectId => {\n const project = cliCommand(['set', 'project', projectId]).SetProject(\n projectId\n );\n if (project) await shell().start();\n });\n set\n .command('version')\n .addArgument(\n new Argument('<versionStatus>', 'content version status')\n .choices(['latest', 'published'])\n .default('latest')\n )\n .usage('<latest/published>')\n .action(async versionStatus => {\n const success = cliCommand(['set', 'version', versionStatus]).SetVersion(\n versionStatus\n );\n if (success) await shell().start();\n });\n\n return set;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkC;AAClC,iCAA2B;AAC3B,mBAAsB;AAEf,MAAM,iBAAiB,MAAM;AAClC,QAAM,MAAM,IAAI,yBAAQ,EACrB,QAAQ,KAAK,EACb,mBAAmB,IAAI,EACvB,aAAa;AAChB,MACG,QAAQ,SAAS,EACjB,SAAS,eAAe,6BAA6B,EACrD,MAAM,aAAa,EACnB,OAAO,OAAM,cAAa;AACzB,UAAM,cAAU,uCAAW,CAAC,OAAO,WAAW,SAAS,CAAC,EAAE;AAAA,MACxD;AAAA,IACF;AACA,QAAI;AAAS,gBAAM,oBAAM,EAAE,MAAM;AAAA,EACnC,CAAC;AACH,MACG,QAAQ,SAAS,EACjB;AAAA,IACC,IAAI,0BAAS,mBAAmB,wBAAwB,EACrD,QAAQ,CAAC,UAAU,WAAW,CAAC,EAC/B,QAAQ,QAAQ;AAAA,EACrB,EACC,MAAM,oBAAoB,EAC1B,OAAO,OAAM,kBAAiB;AAC7B,UAAM,cAAU,uCAAW,CAAC,OAAO,WAAW,aAAa,CAAC,EAAE;AAAA,MAC5D;AAAA,IACF;AACA,QAAI;AAAS,gBAAM,oBAAM,EAAE,MAAM;AAAA,EACnC,CAAC;AAEH,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -106,7 +106,8 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
106
106
|
list: () => `Available projects:`,
|
|
107
107
|
noList: () => `Cannot retrieve projects list`,
|
|
108
108
|
set: (projectId) => `Current project is set to "${projectId}"`,
|
|
109
|
-
failedSet: (projectId) => `Project "${projectId}" not found
|
|
109
|
+
failedSet: (projectId) => `Project "${projectId}" not found`,
|
|
110
|
+
tip: () => `You need to set your current working project with "set project {projectId}"`
|
|
110
111
|
},
|
|
111
112
|
contenttypes: {
|
|
112
113
|
list: (projectId) => `Content types in "${projectId}":`,
|
|
@@ -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;AACA,oBAAuB;AAEhB,MAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA;AAAA,IACZ,SAAS,MACP,aAAU,IAAI,KAAK,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,IACnC,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;AAA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
|
|
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 tip: () =>\n `You need to set your current working project with \"set project {projectId}\"`,\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;AACA,oBAAuB;AAEhB,MAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA;AAAA,IACZ,SAAS,MACP,aAAU,IAAI,KAAK,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,IACnC,MAAM,MACJ;AAAA,IACF,aAAa,MACX;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA;AAAA,IAC5B,cAAc,MAAM;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA,IAC9C,cAAc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B,IAAI,0CAA0C;AAAA,IAChD,SAAS,CAAC,IAAY,QAAgB,KAAa,cACjD,IAAI,+BAA+B,iBAAiB,qBAAqB;AAAA,IAC3E,QAAQ,CAAC,IAAY,QAAgB,KAAa,cAChD,IAAI,sBAAsB,iBAAiB,qBAAqB;AAAA,IAClE,YAAY,CAAC,IAAY,KAAa,cACpC,IAAI,8BAA8B,kBAAkB;AAAA,IACtD,SAAS,CAAC,IAAY,KAAa,cACjC,IAAI,uBAAuB,kBAAkB;AAAA,IAC/C,cAAc,CAAC,IAAY,KAAa,cACtC,IAAI,gCAAgC,kBAAkB;AAAA,EAC1D;AAAA,EACA,UAAU;AAAA,IACR,MAAM,CAAC,QAAgB,IAAI;AAAA,IAC3B,QAAQ,CAAC,QAAgB,IAAI;AAAA,IAC7B,SAAS,CAAC,KAAa,SACrB,IAAI,sCAAsC;AAAA,IAC5C,cAAc,CAAC,KAAa,SAC1B,IAAI,+CAA+C;AAAA,IACrD,SAAS,CAAC,KAAa,OACrB,IAAI,sCAAsC;AAAA,IAC5C,cAAc,CAAC,KAAa,OAC1B,IAAI,+CAA+C;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -84,6 +84,25 @@ class SessionCacheProvider {
|
|
|
84
84
|
}
|
|
85
85
|
return this.Get();
|
|
86
86
|
};
|
|
87
|
+
UpdateEnv = (updateContent, env = this.cache.currentEnvironment) => {
|
|
88
|
+
try {
|
|
89
|
+
const environment = this.cache.environments[env || ""];
|
|
90
|
+
this.cache.environments[env || ""] = {
|
|
91
|
+
...environment,
|
|
92
|
+
...updateContent
|
|
93
|
+
};
|
|
94
|
+
this.Update({
|
|
95
|
+
currentEnvironment: env,
|
|
96
|
+
environments: this.cache.environments
|
|
97
|
+
});
|
|
98
|
+
} catch (ex) {
|
|
99
|
+
import_logger.Logger.error(
|
|
100
|
+
`Problem updating environment "${env}" in environments.json`
|
|
101
|
+
);
|
|
102
|
+
import_logger.Logger.error(ex);
|
|
103
|
+
}
|
|
104
|
+
return this.Get();
|
|
105
|
+
};
|
|
87
106
|
}
|
|
88
107
|
var SessionCacheProvider_default = SessionCacheProvider;
|
|
89
108
|
// 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 { 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(__dirname, '../../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 ) => {\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: env,\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,kBAAiC;AACjC,oBAAuB;AAEvB,MAAM,qBAAqB;AAAA,EACjB;AAAA,EACA,QAAQ,CAAC;AAAA,EAEjB,cAAc;AACZ,SAAK,gBAAgB,YAAAA,QAAK,KAAK,WAAW,yBAAyB;AACnE,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,QA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H,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;AAAA,QACpB,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
|
}
|
|
@@ -54,26 +54,48 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
54
54
|
`);
|
|
55
55
|
process.exit(exitCode);
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
command;
|
|
58
|
+
format;
|
|
59
|
+
output;
|
|
60
|
+
session;
|
|
58
61
|
contensis;
|
|
59
62
|
contensisOpts;
|
|
60
63
|
contentTypes;
|
|
61
64
|
components;
|
|
62
|
-
currentEnv;
|
|
63
65
|
currentProject;
|
|
64
|
-
env;
|
|
65
66
|
sourceEnv;
|
|
66
67
|
targetEnv;
|
|
67
68
|
urls;
|
|
68
|
-
command;
|
|
69
|
-
format;
|
|
70
|
-
output;
|
|
71
69
|
log = import_logger.Logger;
|
|
72
70
|
messages = import_en_GB.LogMessages;
|
|
73
|
-
session;
|
|
74
71
|
verb;
|
|
75
72
|
noun;
|
|
76
73
|
thirdArg;
|
|
74
|
+
get cache() {
|
|
75
|
+
return this.session.Get();
|
|
76
|
+
}
|
|
77
|
+
get currentEnv() {
|
|
78
|
+
return this.cache.currentEnvironment || "";
|
|
79
|
+
}
|
|
80
|
+
set currentEnv(currentEnvironment) {
|
|
81
|
+
this.session.Update({ currentEnvironment });
|
|
82
|
+
}
|
|
83
|
+
get env() {
|
|
84
|
+
const currentEnvironment = this.currentEnv;
|
|
85
|
+
const environments = this.cache.environments || {};
|
|
86
|
+
if (!currentEnvironment)
|
|
87
|
+
return {};
|
|
88
|
+
else if (!!environments[currentEnvironment])
|
|
89
|
+
return environments[currentEnvironment];
|
|
90
|
+
else {
|
|
91
|
+
return {
|
|
92
|
+
history: [],
|
|
93
|
+
lastUserId: "",
|
|
94
|
+
projects: [],
|
|
95
|
+
versionStatus: "latest"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
77
99
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
78
100
|
const [exe, script, verb = "", noun = "", ...restArgs] = args;
|
|
79
101
|
this.verb = verb == null ? void 0 : verb.toLowerCase();
|
|
@@ -81,24 +103,12 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
81
103
|
this.thirdArg = restArgs == null ? void 0 : restArgs[0];
|
|
82
104
|
const commandText = `${this.verb} ${this.noun} ${restArgs ? restArgs.join(" ") : ""}`.trim();
|
|
83
105
|
this.session = new import_SessionCacheProvider.default();
|
|
84
|
-
this.cache = this.session.Get();
|
|
85
106
|
this.contensisOpts = contensisOpts;
|
|
86
107
|
this.format = outputOpts == null ? void 0 : outputOpts.format;
|
|
87
108
|
this.output = (outputOpts == null ? void 0 : outputOpts.output) && import_path.default.join(process.cwd(), outputOpts.output);
|
|
88
|
-
const currentEnvironment = (outputOpts == null ? void 0 : outputOpts.alias) || this.
|
|
109
|
+
const currentEnvironment = (outputOpts == null ? void 0 : outputOpts.alias) || this.currentEnv;
|
|
89
110
|
const environments = this.cache.environments || {};
|
|
90
|
-
|
|
91
|
-
this.env = {};
|
|
92
|
-
else if (!!environments[currentEnvironment])
|
|
93
|
-
this.env = environments[currentEnvironment];
|
|
94
|
-
else {
|
|
95
|
-
this.env = {
|
|
96
|
-
history: [],
|
|
97
|
-
lastUserId: "",
|
|
98
|
-
projects: [],
|
|
99
|
-
versionStatus: "latest"
|
|
100
|
-
};
|
|
101
|
-
}
|
|
111
|
+
this.currentEnv = currentEnvironment;
|
|
102
112
|
const env = this.env;
|
|
103
113
|
if (outputOpts == null ? void 0 : outputOpts.projectId)
|
|
104
114
|
env.currentProject = outputOpts.projectId;
|
|
@@ -110,7 +120,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
110
120
|
env.lastUserId = outputOpts.clientId;
|
|
111
121
|
if (outputOpts == null ? void 0 : outputOpts.sharedSecret)
|
|
112
122
|
env.passwordFallback = outputOpts.sharedSecret;
|
|
113
|
-
this.currentEnv = currentEnvironment;
|
|
114
123
|
this.currentProject = (env == null ? void 0 : env.currentProject) || "null";
|
|
115
124
|
this.sourceEnv = (outputOpts == null ? void 0 : outputOpts.sourceEnv) || currentEnvironment;
|
|
116
125
|
if (currentEnvironment) {
|
|
@@ -124,7 +133,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
124
133
|
if (currentEnvironment) {
|
|
125
134
|
env.history = [this.command];
|
|
126
135
|
if (commandText) {
|
|
127
|
-
environments[currentEnvironment] =
|
|
136
|
+
environments[currentEnvironment] = env;
|
|
128
137
|
this.session.Update({
|
|
129
138
|
currentEnvironment,
|
|
130
139
|
environments,
|
|
@@ -149,23 +158,14 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
149
158
|
};
|
|
150
159
|
Connect = async (environment) => {
|
|
151
160
|
var _a;
|
|
152
|
-
const {
|
|
161
|
+
const { log, messages, session } = this;
|
|
153
162
|
if (environment) {
|
|
154
|
-
const envCache = cache.environments[environment];
|
|
155
|
-
if (!envCache)
|
|
156
|
-
cache.environments[environment] = {
|
|
157
|
-
versionStatus: "published",
|
|
158
|
-
history: [],
|
|
159
|
-
lastUserId: "",
|
|
160
|
-
projects: [],
|
|
161
|
-
...!this.currentEnv ? this.env : {}
|
|
162
|
-
};
|
|
163
|
-
this.env = cache.environments[environment];
|
|
164
163
|
this.currentEnv = environment;
|
|
165
164
|
this.urls = (0, import_util.url)(environment, "website");
|
|
166
165
|
const [fetchErr, response] = await (0, import_await_to_js.default)((0, import_node_fetch.default)(this.urls.cms));
|
|
167
166
|
if (response && (response == null ? void 0 : response.status) < 400) {
|
|
168
167
|
log.success(messages.connect.connected(environment));
|
|
168
|
+
session.UpdateEnv(this.env, environment);
|
|
169
169
|
if ((_a = this.env) == null ? void 0 : _a.lastUserId) {
|
|
170
170
|
await this.ConnectContensis();
|
|
171
171
|
await this.PrintProjects();
|
|
@@ -173,10 +173,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
173
173
|
log.warning(messages.projects.noList());
|
|
174
174
|
log.help(messages.connect.tip());
|
|
175
175
|
}
|
|
176
|
-
session.Update({
|
|
177
|
-
currentEnvironment: environment,
|
|
178
|
-
environments: cache.environments
|
|
179
|
-
});
|
|
180
176
|
} else {
|
|
181
177
|
log.error(
|
|
182
178
|
messages.connect.unreachable(this.urls.cms, (response == null ? void 0 : response.status) || 0)
|
|
@@ -340,7 +336,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
340
336
|
let inputPassword = password;
|
|
341
337
|
const { log, messages } = this;
|
|
342
338
|
if (userId) {
|
|
343
|
-
const {
|
|
339
|
+
const { currentEnv, env } = this;
|
|
344
340
|
if (currentEnv) {
|
|
345
341
|
const [credentialError, credentials] = await new import_CredentialProvider.default(
|
|
346
342
|
{ userId, alias: currentEnv },
|
|
@@ -350,8 +346,12 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
350
346
|
log.error(credentialError);
|
|
351
347
|
return;
|
|
352
348
|
}
|
|
353
|
-
if (credentials.remarks.secure !== true)
|
|
349
|
+
if (credentials.remarks.secure !== true) {
|
|
354
350
|
log.warning(messages.login.insecurePassword());
|
|
351
|
+
} else {
|
|
352
|
+
delete env.passwordFallback;
|
|
353
|
+
this.session.UpdateEnv(env);
|
|
354
|
+
}
|
|
355
355
|
const cachedPassword = (0, import_util.isPassword)((_a = credentials == null ? void 0 : credentials.current) == null ? void 0 : _a.password);
|
|
356
356
|
const cachedSecret = (0, import_util.isSharedSecret)((_b = credentials == null ? void 0 : credentials.current) == null ? void 0 : _b.password);
|
|
357
357
|
if (!sharedSecret && !inputPassword && !cachedPassword && !cachedSecret && promptPassword) {
|
|
@@ -379,6 +379,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
379
379
|
env.authToken = bearerToken;
|
|
380
380
|
env.lastUserId = userId;
|
|
381
381
|
env.passwordFallback = credentials.remarks.secure !== true ? (_d = credentials.current) == null ? void 0 : _d.password : void 0;
|
|
382
|
+
this.session.UpdateEnv(env);
|
|
382
383
|
if (!silent) {
|
|
383
384
|
import_logger.Logger.success(messages.login.success(currentEnv, userId));
|
|
384
385
|
await this.PrintProjects();
|
|
@@ -392,6 +393,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
392
393
|
env.authToken = "";
|
|
393
394
|
env.lastUserId = "";
|
|
394
395
|
env.passwordFallback = void 0;
|
|
396
|
+
this.session.UpdateEnv(env);
|
|
395
397
|
if ((cachedPassword || cachedSecret) && credentials.remarks.secure) {
|
|
396
398
|
await credentials.Delete();
|
|
397
399
|
return await this.Login(userId, { password, sharedSecret });
|
|
@@ -399,9 +401,6 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
399
401
|
throw new Error(messages.login.failed(currentEnv, userId));
|
|
400
402
|
}
|
|
401
403
|
}
|
|
402
|
-
this.session.Update({
|
|
403
|
-
environments: cache.environments
|
|
404
|
-
});
|
|
405
404
|
return env.authToken;
|
|
406
405
|
} else {
|
|
407
406
|
import_logger.Logger.error(messages.login.passwordPrompt(currentEnv, userId));
|
|
@@ -414,7 +413,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
414
413
|
}
|
|
415
414
|
};
|
|
416
415
|
PrintProjects = async () => {
|
|
417
|
-
const {
|
|
416
|
+
const { currentProject, log, messages, session } = this;
|
|
418
417
|
if (!this.contensis)
|
|
419
418
|
await this.ConnectContensis();
|
|
420
419
|
if (this.contensis) {
|
|
@@ -422,13 +421,11 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
422
421
|
this.contensis.projects.GetSourceProjects()
|
|
423
422
|
);
|
|
424
423
|
if (Array.isArray(projects)) {
|
|
425
|
-
const currentVals = cache.environments[currentEnv] || {};
|
|
426
424
|
const nextCurrentProject = currentProject && currentProject !== "null" ? currentProject : projects.some((p) => p.id === "website") ? "website" : void 0;
|
|
427
|
-
|
|
428
|
-
...currentVals,
|
|
425
|
+
session.UpdateEnv({
|
|
429
426
|
projects: projects.map((p) => p.id),
|
|
430
427
|
currentProject: nextCurrentProject
|
|
431
|
-
};
|
|
428
|
+
});
|
|
432
429
|
log.success(messages.projects.list());
|
|
433
430
|
this.HandleFormattingAndOutput(projects, () => {
|
|
434
431
|
for (const project of projects) {
|
|
@@ -437,13 +434,8 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
437
434
|
);
|
|
438
435
|
}
|
|
439
436
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
});
|
|
443
|
-
if (nextCurrentProject) {
|
|
444
|
-
this.env = cache.environments[currentEnv];
|
|
445
|
-
this.SetProject(nextCurrentProject);
|
|
446
|
-
}
|
|
437
|
+
if (!this.SetProject(nextCurrentProject))
|
|
438
|
+
log.warning(messages.projects.tip());
|
|
447
439
|
}
|
|
448
440
|
if (projectsErr) {
|
|
449
441
|
log.error(messages.projects.noList());
|
|
@@ -451,8 +443,8 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
451
443
|
}
|
|
452
444
|
}
|
|
453
445
|
};
|
|
454
|
-
SetProject =
|
|
455
|
-
const {
|
|
446
|
+
SetProject = (projectId = "website") => {
|
|
447
|
+
const { env, log, messages, session } = this;
|
|
456
448
|
let nextProjectId;
|
|
457
449
|
if ((env == null ? void 0 : env.projects.length) > 0 && (env == null ? void 0 : env.lastUserId)) {
|
|
458
450
|
nextProjectId = env.projects.find(
|
|
@@ -460,9 +452,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
460
452
|
);
|
|
461
453
|
if (nextProjectId) {
|
|
462
454
|
env.currentProject = nextProjectId;
|
|
463
|
-
session.
|
|
464
|
-
environments: cache.environments
|
|
465
|
-
});
|
|
455
|
+
session.UpdateEnv(env);
|
|
466
456
|
log.success(messages.projects.set(projectId));
|
|
467
457
|
} else {
|
|
468
458
|
log.error(messages.projects.failedSet(projectId));
|
|
@@ -473,8 +463,8 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
473
463
|
}
|
|
474
464
|
return nextProjectId;
|
|
475
465
|
};
|
|
476
|
-
SetVersion =
|
|
477
|
-
const {
|
|
466
|
+
SetVersion = (versionStatus) => {
|
|
467
|
+
const { env, log, messages, session } = this;
|
|
478
468
|
if (!["latest", "published"].includes(versionStatus)) {
|
|
479
469
|
log.error(messages.version.invalid(versionStatus));
|
|
480
470
|
return false;
|
|
@@ -484,10 +474,7 @@ Exiting contensis-cli with exit code: ${exitCode}
|
|
|
484
474
|
return false;
|
|
485
475
|
}
|
|
486
476
|
if ((env == null ? void 0 : env.projects.length) > 0 && (env == null ? void 0 : env.lastUserId)) {
|
|
487
|
-
|
|
488
|
-
session.Update({
|
|
489
|
-
environments: cache.environments
|
|
490
|
-
});
|
|
477
|
+
session.UpdateEnv({ versionStatus });
|
|
491
478
|
log.success(messages.version.set(this.currentEnv, versionStatus));
|
|
492
479
|
return true;
|
|
493
480
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/ContensisCliService.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport fetch from 'node-fetch';\nimport inquirer from 'inquirer';\nimport to from 'await-to-js';\nimport { Component, ContentType } from 'contensis-core-api';\nimport { isPassword, isSharedSecret, isUuid, url } from '~/util';\nimport SessionCacheProvider from '../providers/SessionCacheProvider';\nimport ContensisAuthService from './ContensisAuthService';\nimport CredentialProvider from '~/providers/CredentialProvider';\nimport { logError, Logger } from '~/util/logger';\nimport { LogMessages } from '~/localisation/en-GB';\nimport {\n ContensisMigrationService,\n MigrateRequest,\n PushBlockParams,\n SourceCms,\n logEntriesTable,\n} from 'migratortron';\nimport { Entry } from 'contensis-management-api/lib/models';\n\nimport { csvFormatter } from '~/util/csv.formatter';\nimport { xmlFormatter } from '~/util/xml.formatter';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { printBlockVersion, printMigrateResult } from '~/util/console.printer';\nimport { readJsonFile } from '~/providers/file-provider';\n\ntype OutputFormat = 'json' | 'csv' | 'xml';\n\ntype OutputOptions = {\n format?: OutputFormat;\n output?: string;\n};\n\ninterface IConnectOptions extends IAuthOptions {\n alias?: string;\n projectId?: string;\n}\n\ninterface IAuthOptions {\n user?: string;\n password?: string;\n clientId?: string;\n sharedSecret?: string;\n}\n\ninterface IImportOptions {\n sourceEnv?: string;\n sourceProjectId?: string;\n}\n\nclass ContensisCli {\n static quit = (error?: Error) => {\n process.removeAllListeners('exit');\n const exitCode = error ? 1 : 0;\n\n console.info(`\\nExiting contensis-cli with exit code: ${exitCode}\\n`);\n process.exit(exitCode);\n };\n\n cache: SessionCache;\n contensis?: ContensisMigrationService;\n contensisOpts: Partial<MigrateRequest>;\n contentTypes?: ContentType[];\n components?: Component[];\n currentEnv: string;\n currentProject: string;\n env: EnvironmentCache;\n sourceEnv?: string;\n targetEnv?: string;\n urls:\n | {\n api: string;\n cms: string;\n liveWeb: string;\n previewWeb: string;\n iisWeb: string;\n iisPreviewWeb: string;\n }\n | undefined;\n private command: CliCommand;\n private format?: OutputFormat;\n private output?: string;\n log = Logger;\n messages = LogMessages;\n private session: SessionCacheProvider;\n\n verb: string;\n noun: string;\n thirdArg: string;\n\n constructor(\n args: string[],\n outputOpts?: OutputOptions & IConnectOptions & IImportOptions,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n // console.log('args: ', JSON.stringify(args, null, 2));\n\n const [exe, script, verb = '', noun = '', ...restArgs] = args;\n this.verb = verb?.toLowerCase();\n this.noun = noun?.toLowerCase();\n this.thirdArg = restArgs?.[0];\n\n const commandText = `${this.verb} ${this.noun} ${\n restArgs ? restArgs.join(' ') : ''\n }`.trim();\n\n this.session = new SessionCacheProvider();\n this.cache = this.session.Get();\n this.contensisOpts = contensisOpts;\n this.format = outputOpts?.format;\n this.output =\n outputOpts?.output && path.join(process.cwd(), outputOpts.output);\n\n const currentEnvironment =\n outputOpts?.alias || this.cache.currentEnvironment || '';\n const environments = this.cache.environments || {};\n\n if (!currentEnvironment) this.env = {} as EnvironmentCache;\n else if (!!environments[currentEnvironment])\n this.env = environments[currentEnvironment];\n else {\n this.env = {\n history: [],\n lastUserId: '',\n projects: [],\n versionStatus: 'latest',\n };\n }\n\n const env = this.env;\n\n if (outputOpts?.projectId) env.currentProject = outputOpts.projectId;\n if (outputOpts?.user) env.lastUserId = outputOpts.user;\n if (outputOpts?.password) env.passwordFallback = outputOpts.password;\n if (outputOpts?.clientId) env.lastUserId = outputOpts.clientId;\n if (outputOpts?.sharedSecret)\n env.passwordFallback = outputOpts.sharedSecret;\n\n this.currentEnv = currentEnvironment;\n this.currentProject = env?.currentProject || 'null';\n this.sourceEnv = outputOpts?.sourceEnv || currentEnvironment;\n\n if (currentEnvironment) {\n this.urls = url(currentEnvironment, env?.currentProject || 'website');\n }\n\n this.command = {\n commandText,\n createdDate: new Date().toISOString(),\n createdUserId: env?.lastUserId,\n };\n\n if (currentEnvironment) {\n env.history = [this.command];\n if (commandText) {\n environments[currentEnvironment] = this.env;\n this.session.Update({\n currentEnvironment,\n environments,\n history: [commandText],\n });\n }\n }\n }\n\n PrintEnvironments = () => {\n const { log, messages } = this;\n const { currentEnvironment, environments = {} } = this.cache;\n const envKeys = Object.keys(environments);\n log.success(messages.envs.found(envKeys.length));\n this.HandleFormattingAndOutput(envKeys, () => {\n // print the envKeys to console\n for (const env of envKeys) {\n console.log(` - ${currentEnvironment === env ? '* ' : ''}${env}`);\n }\n });\n if (envKeys.length === 0 || !currentEnvironment) {\n log.help(messages.envs.tip());\n }\n };\n\n Connect = async (environment: string) => {\n const { cache, log, messages, session } = this;\n\n if (environment) {\n const envCache = cache.environments[environment];\n if (!envCache)\n cache.environments[environment] = {\n versionStatus: 'published',\n history: [],\n lastUserId: '',\n projects: [],\n ...(!this.currentEnv ? this.env : {}),\n };\n\n this.env = cache.environments[environment];\n this.currentEnv = environment;\n this.urls = url(environment, 'website');\n\n const [fetchErr, response] = await to(fetch(this.urls.cms));\n if (response && response?.status < 400) {\n log.success(messages.connect.connected(environment));\n\n if (this.env?.lastUserId) {\n await this.ConnectContensis();\n await this.PrintProjects();\n } else {\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n // cache.environments[environment] = {\n // versionStatus: 'published',\n // history: [],\n // lastUserId: '',\n // projects: [],\n // };\n }\n\n session.Update({\n currentEnvironment: environment,\n environments: cache.environments,\n });\n } else {\n // Cannot reach environment - status X\n log.error(\n messages.connect.unreachable(this.urls.cms, response?.status || 0)\n );\n }\n } else {\n // No environment alias specified\n log.error(messages.connect.noEnv());\n }\n };\n\n ConnectContensis = async ({ commit = false } = {}) => {\n const { contensisOpts, currentEnv, env, log, messages } = this;\n const userId = env?.lastUserId;\n const isGuidId = userId && isUuid(userId);\n\n if (currentEnv && userId) {\n const [credentialError, credentials] = await new CredentialProvider(\n {\n userId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n const cachedPassword = credentials?.current?.password;\n\n if (cachedPassword) {\n this.contensis = new ContensisMigrationService(\n {\n ...contensisOpts,\n source: {\n url: this.urls?.cms || '',\n username: !isGuidId ? userId : undefined,\n password: !isGuidId ? cachedPassword : undefined,\n clientId: isGuidId ? userId : undefined,\n sharedSecret: isGuidId ? cachedPassword : undefined,\n project: env?.currentProject || '',\n assetHostname: this.urls?.previewWeb,\n },\n concurrency:\n typeof contensisOpts.concurrency !== 'undefined'\n ? contensisOpts.concurrency\n : 3,\n outputProgress: true,\n },\n !commit\n );\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!userId) log.help(messages.connect.tip());\n }\n };\n\n ConnectContensisImport = async ({\n commit,\n source,\n fileData,\n fileDataType,\n }: {\n commit: boolean;\n source: 'contensis' | 'file' | 'input';\n fileData?: any[] | string;\n fileDataType?: 'entries' | 'contentTypes' | 'components';\n }) => {\n const { contensisOpts, currentEnv, env, log, messages, sourceEnv } = this;\n const environments = this.cache.environments || {};\n const sourceEnvironment = environments[sourceEnv || ''] || {};\n const sourceCms =\n ('source' in contensisOpts && contensisOpts.source) ||\n ({} as Partial<SourceCms>);\n const sourceUserId =\n sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;\n const sourceProjectId =\n sourceCms.project || sourceEnvironment.currentProject || 'website';\n const isSourceGuidId = sourceUserId && isUuid(sourceUserId);\n const sourceUrls = url(sourceEnv || '', sourceProjectId);\n\n const sourcePassword =\n sourceCms.sharedSecret ||\n sourceCms.password ||\n sourceEnvironment.passwordFallback;\n\n const targetUserId = env?.lastUserId;\n const isTargetGuidId = targetUserId && isUuid(targetUserId);\n\n if (sourceUserId && currentEnv && targetUserId) {\n const [sourceCredentialError, sourceCredentials] =\n await new CredentialProvider(\n {\n userId: sourceUserId,\n alias: currentEnv,\n },\n sourcePassword\n ).Init();\n\n if (sourceCredentialError && !sourceCredentials.current) {\n // Log problem with Credential Provider\n logError(sourceCredentialError);\n return;\n }\n const cachedSourcePassword = sourceCredentials?.current?.password;\n\n const [targetCredentialError, targetCredentials] =\n await new CredentialProvider(\n {\n userId: targetUserId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (targetCredentialError && !targetCredentials.current) {\n // Log problem with Credential Provider\n log.error(targetCredentialError as any);\n return;\n }\n const cachedTargetPassword = targetCredentials?.current?.password;\n\n if (cachedSourcePassword && cachedTargetPassword) {\n if (source === 'file' || source === 'input') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n ...(fileDataType ? { [fileDataType]: fileData } : {}),\n },\n !commit\n );\n }\n if (source === 'contensis') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n source: {\n url: sourceUrls.cms || '',\n username: !isSourceGuidId ? sourceUserId : undefined,\n password: !isSourceGuidId ? cachedSourcePassword : undefined,\n clientId: isSourceGuidId ? sourceUserId : undefined,\n sharedSecret: isSourceGuidId ? cachedSourcePassword : undefined,\n project: sourceProjectId,\n assetHostname: sourceUrls.previewWeb,\n },\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n },\n !commit\n );\n }\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!targetUserId) log.help(messages.connect.tip());\n }\n };\n\n Login = async (\n userId: string,\n {\n password = isPassword(this.env.passwordFallback),\n promptPassword = true,\n sharedSecret = isSharedSecret(this.env.passwordFallback),\n silent = false,\n }: {\n password?: string;\n promptPassword?: boolean;\n sharedSecret?: string;\n silent?: boolean;\n }\n ): Promise<string | undefined> => {\n let inputPassword = password;\n const { log, messages } = this;\n\n if (userId) {\n const { cache, currentEnv, env } = this;\n\n if (currentEnv) {\n const [credentialError, credentials] = await new CredentialProvider(\n { userId, alias: currentEnv },\n inputPassword || sharedSecret\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n\n if (credentials.remarks.secure !== true)\n log.warning(messages.login.insecurePassword());\n\n const cachedPassword = isPassword(credentials?.current?.password);\n const cachedSecret = isSharedSecret(credentials?.current?.password);\n\n if (\n !sharedSecret &&\n !inputPassword &&\n !cachedPassword &&\n !cachedSecret &&\n promptPassword\n ) {\n // Password prompt\n ({ inputPassword } = await inquirer.prompt([\n {\n type: 'password',\n message: messages.login.passwordPrompt(currentEnv, userId),\n name: 'inputPassword',\n mask: '*',\n prefix: undefined,\n },\n ]));\n }\n\n if (sharedSecret || cachedSecret || inputPassword || cachedPassword) {\n const authService = new ContensisAuthService({\n username: userId,\n password: inputPassword || cachedPassword,\n projectId: env?.currentProject || 'website',\n rootUrl: this.urls?.cms || '',\n clientId: userId,\n clientSecret: sharedSecret || cachedSecret,\n });\n\n const [authError, bearerToken] = await to(authService.BearerToken());\n\n // Login successful\n if (bearerToken) {\n // Set env vars\n env.authToken = bearerToken;\n env.lastUserId = userId;\n env.passwordFallback =\n credentials.remarks.secure !== true\n ? credentials.current?.password\n : undefined;\n\n if (!silent) {\n Logger.success(messages.login.success(currentEnv, userId));\n await this.PrintProjects();\n }\n if (inputPassword) await credentials.Save(inputPassword);\n if (sharedSecret) await credentials.Save(sharedSecret);\n } else if (authError) {\n Logger.error(authError.toString());\n // Clear env vars\n env.authToken = '';\n env.lastUserId = '';\n env.passwordFallback = undefined;\n\n // If the auth error was raised using a cached password\n if (\n (cachedPassword || cachedSecret) &&\n credentials.remarks.secure\n ) {\n // Remove any bad stored credential and trigger login prompt again\n await credentials.Delete();\n return await this.Login(userId, { password, sharedSecret });\n } else {\n throw new Error(messages.login.failed(currentEnv, userId));\n }\n }\n\n // Persist env\n this.session.Update({\n environments: cache.environments,\n });\n return env.authToken;\n } else {\n Logger.error(messages.login.passwordPrompt(currentEnv, userId));\n }\n } else {\n // No environment set, use `contensis connect {alias}` first\n Logger.error(messages.login.noEnv());\n }\n } else {\n // No user id specified\n Logger.error(messages.login.noUserId());\n }\n };\n\n PrintProjects = async () => {\n const { cache, currentEnv, currentProject, log, messages, session } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve projects list for env\n const [projectsErr, projects] = await to(\n this.contensis.projects.GetSourceProjects()\n );\n\n if (Array.isArray(projects)) {\n // save these projects in cache\n const currentVals = cache.environments[currentEnv] || {};\n const nextCurrentProject =\n currentProject && currentProject !== 'null'\n ? currentProject\n : projects.some(p => p.id === 'website')\n ? 'website'\n : undefined;\n\n cache.environments[currentEnv] = {\n ...currentVals,\n projects: projects.map(p => p.id),\n currentProject: nextCurrentProject,\n };\n\n log.success(messages.projects.list());\n this.HandleFormattingAndOutput(projects, () => {\n // print the projects to console\n for (const project of projects) {\n console.log(\n ` - ${nextCurrentProject === project.id ? '* ' : ''}[${\n project.primaryLanguage\n }] ${project.id}`\n );\n }\n });\n\n session.Update({\n environments: cache.environments,\n });\n\n if (nextCurrentProject) {\n this.env = cache.environments[currentEnv];\n this.SetProject(nextCurrentProject);\n }\n }\n\n if (projectsErr) {\n log.error(messages.projects.noList());\n log.error(projectsErr.message);\n }\n // } else {\n // log.warning(messages.projects.noList());\n // log.help(messages.connect.tip());\n }\n };\n\n SetProject = async (projectId = '') => {\n const { cache, env, log, messages, session } = this;\n let nextProjectId: string | undefined;\n if (env?.projects.length > 0 && env?.lastUserId) {\n nextProjectId = env.projects.find(\n p => p.toLowerCase() === projectId.toLowerCase()\n );\n if (nextProjectId) {\n env.currentProject = nextProjectId;\n session.Update({\n environments: cache.environments,\n });\n log.success(messages.projects.set(projectId));\n } else {\n log.error(messages.projects.failedSet(projectId));\n }\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n }\n return nextProjectId;\n };\n\n SetVersion = async (versionStatus: 'latest' | 'published') => {\n const { cache, env, log, messages, session } = this;\n if (!['latest', 'published'].includes(versionStatus)) {\n log.error(messages.version.invalid(versionStatus));\n return false;\n }\n if (!env) {\n log.help(messages.version.noEnv());\n return false;\n }\n if (env?.projects.length > 0 && env?.lastUserId) {\n env.versionStatus = versionStatus;\n session.Update({\n environments: cache.environments,\n });\n log.success(messages.version.set(this.currentEnv, versionStatus));\n return true;\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n return false;\n }\n };\n\n HydrateContensis = async () => {\n const { log } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve content types list for env\n const [contensisErr, models] = await to(\n this.contensis.models.HydrateContensisRepositories()\n );\n\n if (contensisErr) {\n log.error(contensisErr.message);\n return contensisErr;\n }\n }\n };\n\n PrintApiKeys = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await this.contensis.apiKeys.GetKeys();\n\n if (Array.isArray(apiKeys)) {\n log.success(messages.keys.list(currentEnv));\n this.HandleFormattingAndOutput(apiKeys, () => {\n // print the keys to console\n for (const {\n id,\n sharedSecret,\n name,\n description,\n dateModified,\n modifiedBy,\n } of apiKeys) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${dateModified.toString().substring(0, 10)} ${modifiedBy}]`\n );\n console.log(` ${id}`);\n console.log(` ${sharedSecret}`);\n }\n });\n }\n\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n }\n }\n };\n\n CreateApiKey = async (name: string, description?: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.CreateKey(\n name,\n description\n );\n\n if (key) {\n log.success(messages.keys.created(currentEnv, name));\n\n // print the key details to console\n console.log(\n ` - ${key.name}${\n key.description ? ` (${key.description})` : ''\n } [${key.dateModified.toString().substring(0, 10)} ${key.modifiedBy}]`\n );\n console.log(` - id: ${key.id}`);\n console.log(` - sharedSecret: ${key.sharedSecret}`);\n }\n console.log('');\n\n if (err) {\n log.error(messages.keys.failedCreate(currentEnv, name), err);\n }\n }\n };\n\n RemoveApiKey = async (id: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis({ commit: true });\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.RemoveKey(id);\n\n if (!err) {\n log.success(messages.keys.removed(currentEnv, id));\n console.log('');\n } else {\n log.error(messages.keys.failedRemove(currentEnv, id), err);\n }\n }\n };\n\n GetContentTypes = async () => {\n const { currentProject, log, messages } = this;\n let err;\n if (!this.contensis) err = await this.HydrateContensis();\n\n if (err) log.error(messages.contenttypes.noList(currentProject));\n if (this.contensis) {\n this.contentTypes = this.contensis.models.contentTypes();\n this.components = this.contensis.models.components();\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n }\n };\n\n PrintContentTypes = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n log.success(messages.contenttypes.list(currentProject));\n this.HandleFormattingAndOutput(contentTypes, () => {\n // print the content types to console\n for (const contentType of contentTypes) {\n const fieldsLength = contentType.fields?.length || 0;\n console.log(\n ` - ${contentType.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintContentType = async (contentTypeId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n const contentType = contentTypes.find(\n c => c.id.toLowerCase() === contentTypeId.toLowerCase()\n );\n if (contentType) {\n log.success(\n messages.contenttypes.get(currentProject, contentType.id)\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, log.object);\n } else {\n log.error(\n messages.contenttypes.failedGet(currentProject, contentTypeId)\n );\n }\n }\n }\n };\n\n RemoveContentTypes = async (contentTypeIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n contentTypeIds\n );\n\n if (err) {\n log.error(\n messages.contenttypes.failedRemove(\n currentProject,\n contentTypeIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.contenttypes.removed(\n currentProject,\n contentTypeIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.object(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportContentTypes = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n contentTypeIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<ContentType[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each content type to the target repo\n for (const contentType of fileData) {\n // Fix invalid data\n contentType.projectId = currentProject;\n delete contentType.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertContentType(false, contentType);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.contenttypes.created(\n currentProject,\n contentType.id,\n createStatus\n )\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, () => {});\n }\n }\n }\n };\n\n PrintComponents = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve components list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n log.success(messages.components.list(currentProject));\n\n this.HandleFormattingAndOutput(components, () => {\n // print the components to console\n for (const component of components) {\n const fieldsLength = component.fields?.length || 0;\n console.log(\n ` - ${component.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintComponent = async (componentId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n const component = components.find(\n c => c.id.toLowerCase() === componentId.toLowerCase()\n );\n if (component) {\n log.success(messages.components.get(currentProject, component.id));\n // print the component to console\n this.HandleFormattingAndOutput(component, log.object);\n } else {\n log.error(messages.components.failedGet(currentProject, componentId));\n }\n }\n }\n };\n\n RemoveComponents = async (componentIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n undefined,\n componentIds\n );\n\n if (err) {\n log.error(\n messages.components.failedRemove(\n currentProject,\n componentIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.components.removed(\n currentProject,\n componentIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.info(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportComponents = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n componentIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<Component[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each component to the target repo\n for (const component of fileData) {\n // Fix invalid data\n component.projectId = currentProject;\n delete component.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertComponent(false, component);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.components.created(\n currentProject,\n component.id,\n createStatus\n )\n );\n // print the component to console\n this.HandleFormattingAndOutput(component, () => {});\n }\n }\n }\n };\n\n RemoveEntry = async (id: string, commit = false) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n\n if (this.contensis) {\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING DELETE *** `));\n }\n const [err, result] = await this.contensis.DeleteEntries();\n if (result)\n this.HandleFormattingAndOutput(result, () => {\n // print the migrateResult to console\n printMigrateResult(this, result, { action: 'delete' });\n });\n if (\n !err &&\n ((!commit &&\n Object.values(result.entriesToMigrate)?.[0].totalCount > 0) ||\n (commit && result.migrateResult?.deleted))\n ) {\n log.success(messages.entries.removed(currentEnv, id, commit));\n if (!commit) log.help(messages.entries.commitTip());\n } else {\n log.error(messages.entries.failedRemove(currentEnv, id), err);\n if (!Object.values(result.entriesToMigrate)?.[0].totalCount)\n log.help(messages.entries.notFound(id));\n }\n }\n };\n\n GetEntries = async ({\n withDependents = false,\n }: {\n withDependents?: boolean;\n }) => {\n const { currentProject, log, messages } = this;\n await this.ConnectContensis();\n\n if (this.contensis) {\n log.line();\n const entries = await this.contensis.GetEntries({ withDependents });\n this.HandleFormattingAndOutput(entries, () =>\n // print the entries to console\n logEntriesTable(\n entries,\n currentProject,\n this.contensis?.payload.query?.fields\n )\n );\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n ImportEntries = async ({\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n }) => {\n const { currentProject, log, messages } = this;\n\n const fileData = fromFile ? readJsonFile<Entry[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n fileData,\n fileDataType: 'entries',\n });\n\n if (this.contensis) {\n log.line();\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- IMPORT PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING IMPORT *** `));\n }\n\n const [migrateErr, migrateResult] = await this.contensis.MigrateEntries();\n\n if (migrateErr) logError(migrateErr);\n else\n this.HandleFormattingAndOutput(migrateResult, () => {\n // print the migrateResult to console\n printMigrateResult(this, migrateResult);\n });\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n PrintWebhookSubscriptions = async (\n subscriptionIds?: string[],\n name?: string\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve webhooks list for env\n const [webhooksErr, webhooks] =\n await this.contensis.subscriptions.webhooks.GetSubscriptions();\n\n const filteredResults =\n typeof name === 'string'\n ? webhooks.filter(w =>\n w.name?.toLowerCase().includes(name.toLowerCase())\n )\n : Array.isArray(subscriptionIds)\n ? webhooks.filter(w => subscriptionIds?.some(id => id === w.id))\n : webhooks;\n\n if (Array.isArray(filteredResults)) {\n this.HandleFormattingAndOutput(filteredResults, () => {\n // print the keys to console\n log.success(messages.webhooks.list(currentEnv));\n for (const {\n id,\n description,\n method,\n name,\n version,\n url,\n } of filteredResults) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${version.modified.toString().substring(0, 10)} ${\n version.modifiedBy\n }]`\n );\n console.log(` ${id}`);\n console.log(` [${method}] ${url}`);\n }\n console.log('');\n });\n }\n\n if (webhooksErr) {\n log.error(messages.webhooks.noList(currentEnv));\n log.error(jsonFormatter(webhooksErr));\n }\n }\n };\n\n PrintBlocks = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve blocks list for env\n const [err, blocks] = await this.contensis.blocks.GetBlocks();\n\n if (Array.isArray(blocks)) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the blocks to console\n log.success(messages.blocks.list(currentEnv));\n for (const {\n id,\n description,\n branches,\n liveVersion,\n madeLive,\n versionsSinceLive,\n } of blocks) {\n console.log(\n ` - ${id}${description ? ` (${description})` : ''}${\n madeLive\n ? ` [${madeLive.toString().substring(0, 10)} v${liveVersion}]`\n : ''\n }${\n versionsSinceLive\n ? log.warningText(` +${versionsSinceLive}`)\n : ''\n }`\n );\n for (const branch of branches)\n console.log(\n log.infoText(` [${branch.id}]: ${branch.status}`)\n );\n }\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PrintBlockVersions = async (\n blockId: string,\n branch: string,\n version: string\n ) => {\n const { currentEnv, env, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block version\n const [err, blocks] = await this.contensis.blocks.GetBlockVersions(\n blockId,\n branch,\n version\n );\n\n if (blocks) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the version detail to console\n log.success(\n messages.blocks.get(`${currentEnv}:${env.currentProject}`)\n );\n for (const block of blocks)\n printBlockVersion(\n this,\n block,\n !version\n ? {\n showImage: false,\n showSource: true,\n showStaticPaths: false,\n showStatus: false,\n }\n : undefined\n );\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv, env.currentProject));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PushBlock = async (block: PushBlockParams) => {\n const { currentEnv, env, log, messages } = this;\n\n // Output request to console\n messages.blocks.tryPush(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n );\n console.log(jsonFormatter(block));\n\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Push new block version\n const [err, blockVersion] = await this.contensis.blocks.PushBlockVersion(\n block\n );\n if (!err) {\n log.success(\n messages.blocks.pushed(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n )\n );\n console.log(jsonFormatter(blockVersion));\n }\n if (blockVersion) {\n this.HandleFormattingAndOutput(blockVersion, () => {\n // print the version detail to console\n printBlockVersion(this, blockVersion);\n });\n }\n if (err)\n throw new Error(\n messages.blocks.failedPush(block.id, currentEnv, env.currentProject)\n );\n }\n };\n\n PrintBlockLogs = async (\n blockId: string,\n branch: string,\n version: string,\n dataCenter: 'hq' | 'manchester' | 'london'\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block logs\n const [err, blockLogs] = await this.contensis.blocks.GetBlockLogs({\n blockId,\n branchId: branch,\n version,\n dataCenter,\n });\n\n if (blockLogs) {\n this.HandleFormattingAndOutput(blockLogs, () => {\n // print the logs to console\n log.success(messages.blocks.list(currentEnv));\n console.log(\n ` - ${blockId} ${branch} ${\n Number(version) ? `v${version}` : version\n } [${dataCenter}]`\n );\n log.line();\n console.log(log.infoText(blockLogs));\n log.line();\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n HandleFormattingAndOutput = <T>(obj: T, logFn: (obj: T) => void) => {\n const { format, log, messages, output } = this;\n if (output) {\n let writeString = '';\n if (format === 'csv') {\n writeString = csvFormatter(obj as any);\n } else if (format === 'xml') {\n writeString = xmlFormatter(obj as any);\n } else writeString = jsonFormatter(obj);\n // write output to file\n if (writeString) {\n fs.writeFileSync(output, writeString);\n log.success(messages.app.fileOutput(format, output));\n } else {\n log.info(messages.app.noFileOutput());\n }\n } else {\n if (!format) {\n // print the object to console\n logFn(obj);\n } else if (format === 'csv') {\n log.raw('');\n log.raw(log.infoText(csvFormatter(obj)));\n } else if (format === 'xml') {\n log.raw('');\n log.raw(log.infoText(xmlFormatter(obj)));\n } else if (format === 'json') {\n log.raw('');\n log.raw(log.infoText(jsonFormatter(obj)));\n }\n log.raw('');\n }\n };\n}\n\nexport const cliCommand = (\n commandArgs: string[],\n outputOpts: OutputOptions & IConnectOptions = {},\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisCli(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\nex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AAA,EAEA,4BAA4B,CAAI,KAAQ,UAA4B;AAClE,UAAM,EAAE,QAAQ,KAAK,UAAU,OAAO,IAAI;AAC1C,QAAI,QAAQ;AACV,UAAI,cAAc;AAClB,UAAI,WAAW,OAAO;AACpB,0BAAc,yBAAa,GAAU;AAAA,MACvC,WAAW,WAAW,OAAO;AAC3B,0BAAc,yBAAa,GAAU;AAAA,MACvC;AAAO,0BAAc,2BAAc,GAAG;AAEtC,UAAI,aAAa;AACf,kBAAAC,QAAG,cAAc,QAAQ,WAAW;AACpC,YAAI,QAAQ,SAAS,IAAI,WAAW,QAAQ,MAAM,CAAC;AAAA,MACrD,OAAO;AACL,YAAI,KAAK,SAAS,IAAI,aAAa,CAAC;AAAA,MACtC;AAAA,IACF,OAAO;AACL,UAAI,CAAC,QAAQ;AAEX,cAAM,GAAG;AAAA,MACX,WAAW,WAAW,OAAO;AAC3B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,yBAAa,GAAG,CAAC,CAAC;AAAA,MACzC,WAAW,WAAW,OAAO;AAC3B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,yBAAa,GAAG,CAAC,CAAC;AAAA,MACzC,WAAW,WAAW,QAAQ;AAC5B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,2BAAc,GAAG,CAAC,CAAC;AAAA,MAC1C;AACA,UAAI,IAAI,EAAE;AAAA,IACZ;AAAA,EACF;AACF;AAEO,MAAM,aAAa,CACxB,aACA,aAA8C,CAAC,GAC/C,gBAAyC,CAAC,MACvC;AACH,SAAO,IAAI,aAAa,CAAC,IAAI,IAAI,GAAG,WAAW,GAAG,YAAY,aAAa;AAC7E;AACA,IAAO,8BAAQ;",
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport fetch from 'node-fetch';\nimport inquirer from 'inquirer';\nimport to from 'await-to-js';\nimport { Component, ContentType } from 'contensis-core-api';\nimport { isPassword, isSharedSecret, isUuid, url } from '~/util';\nimport SessionCacheProvider from '../providers/SessionCacheProvider';\nimport ContensisAuthService from './ContensisAuthService';\nimport CredentialProvider from '~/providers/CredentialProvider';\nimport { logError, Logger } from '~/util/logger';\nimport { LogMessages } from '~/localisation/en-GB';\nimport {\n ContensisMigrationService,\n MigrateRequest,\n PushBlockParams,\n SourceCms,\n logEntriesTable,\n} from 'migratortron';\nimport { Entry } from 'contensis-management-api/lib/models';\n\nimport { csvFormatter } from '~/util/csv.formatter';\nimport { xmlFormatter } from '~/util/xml.formatter';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { printBlockVersion, printMigrateResult } from '~/util/console.printer';\nimport { readJsonFile } from '~/providers/file-provider';\n\ntype OutputFormat = 'json' | 'csv' | 'xml';\n\ntype OutputOptions = {\n format?: OutputFormat;\n output?: string;\n};\n\ninterface IConnectOptions extends IAuthOptions {\n alias?: string;\n projectId?: string;\n}\n\ninterface IAuthOptions {\n user?: string;\n password?: string;\n clientId?: string;\n sharedSecret?: string;\n}\n\ninterface IImportOptions {\n sourceEnv?: string;\n sourceProjectId?: string;\n}\n\nclass ContensisCli {\n static quit = (error?: Error) => {\n process.removeAllListeners('exit');\n const exitCode = error ? 1 : 0;\n\n console.info(`\\nExiting contensis-cli with exit code: ${exitCode}\\n`);\n process.exit(exitCode);\n };\n\n private command: CliCommand;\n private format?: OutputFormat;\n private output?: string;\n private session: SessionCacheProvider;\n\n contensis?: ContensisMigrationService;\n contensisOpts: Partial<MigrateRequest>;\n contentTypes?: ContentType[];\n components?: Component[];\n currentProject: string;\n\n sourceEnv?: string;\n targetEnv?: string;\n urls:\n | {\n api: string;\n cms: string;\n liveWeb: string;\n previewWeb: string;\n iisWeb: string;\n iisPreviewWeb: string;\n }\n | undefined;\n log = Logger;\n messages = LogMessages;\n\n verb: string;\n noun: string;\n thirdArg: string;\n\n get cache() {\n return this.session.Get();\n }\n get currentEnv() {\n return this.cache.currentEnvironment || '';\n }\n\n set currentEnv(currentEnvironment: string) {\n this.session.Update({ currentEnvironment });\n }\n\n get env() {\n const currentEnvironment = this.currentEnv;\n const environments = this.cache.environments || {};\n\n if (!currentEnvironment) return {} as EnvironmentCache;\n else if (!!environments[currentEnvironment])\n return environments[currentEnvironment];\n else {\n return {\n history: [],\n lastUserId: '',\n projects: [],\n versionStatus: 'latest',\n } as EnvironmentCache;\n }\n }\n\n constructor(\n args: string[],\n outputOpts?: OutputOptions & IConnectOptions & IImportOptions,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n // console.log('args: ', JSON.stringify(args, null, 2));\n\n const [exe, script, verb = '', noun = '', ...restArgs] = args;\n this.verb = verb?.toLowerCase();\n this.noun = noun?.toLowerCase();\n this.thirdArg = restArgs?.[0];\n\n const commandText = `${this.verb} ${this.noun} ${\n restArgs ? restArgs.join(' ') : ''\n }`.trim();\n\n this.session = new SessionCacheProvider();\n\n this.contensisOpts = contensisOpts;\n this.format = outputOpts?.format;\n this.output =\n outputOpts?.output && path.join(process.cwd(), outputOpts.output);\n\n const currentEnvironment = outputOpts?.alias || this.currentEnv;\n const environments = this.cache.environments || {};\n this.currentEnv = currentEnvironment;\n\n const env = this.env;\n\n if (outputOpts?.projectId) env.currentProject = outputOpts.projectId;\n if (outputOpts?.user) env.lastUserId = outputOpts.user;\n // setting this in env means passwordFallback is written to environments.json\n if (outputOpts?.password) env.passwordFallback = outputOpts.password;\n if (outputOpts?.clientId) env.lastUserId = outputOpts.clientId;\n if (outputOpts?.sharedSecret)\n env.passwordFallback = outputOpts.sharedSecret;\n\n this.currentProject = env?.currentProject || 'null';\n this.sourceEnv = outputOpts?.sourceEnv || currentEnvironment;\n\n if (currentEnvironment) {\n this.urls = url(currentEnvironment, env?.currentProject || 'website');\n }\n\n this.command = {\n commandText,\n createdDate: new Date().toISOString(),\n createdUserId: env?.lastUserId,\n };\n\n if (currentEnvironment) {\n env.history = [this.command];\n if (commandText) {\n environments[currentEnvironment] = env;\n this.session.Update({\n currentEnvironment,\n environments,\n history: [commandText],\n });\n }\n }\n }\n\n PrintEnvironments = () => {\n const { log, messages } = this;\n const { currentEnvironment, environments = {} } = this.cache;\n const envKeys = Object.keys(environments);\n log.success(messages.envs.found(envKeys.length));\n this.HandleFormattingAndOutput(envKeys, () => {\n // print the envKeys to console\n for (const env of envKeys) {\n console.log(` - ${currentEnvironment === env ? '* ' : ''}${env}`);\n }\n });\n if (envKeys.length === 0 || !currentEnvironment) {\n log.help(messages.envs.tip());\n }\n };\n\n Connect = async (environment: string) => {\n const { log, messages, session } = this;\n\n if (environment) {\n this.currentEnv = environment;\n this.urls = url(environment, 'website');\n\n const [fetchErr, response] = await to(fetch(this.urls.cms));\n if (response && response?.status < 400) {\n log.success(messages.connect.connected(environment));\n session.UpdateEnv(this.env, environment);\n\n if (this.env?.lastUserId) {\n await this.ConnectContensis();\n await this.PrintProjects();\n } else {\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n }\n } else {\n // Cannot reach environment - status X\n log.error(\n messages.connect.unreachable(this.urls.cms, response?.status || 0)\n );\n }\n } else {\n // No environment alias specified\n log.error(messages.connect.noEnv());\n }\n };\n\n ConnectContensis = async ({ commit = false } = {}) => {\n const { contensisOpts, currentEnv, env, log, messages } = this;\n const userId = env?.lastUserId;\n const isGuidId = userId && isUuid(userId);\n\n if (currentEnv && userId) {\n const [credentialError, credentials] = await new CredentialProvider(\n {\n userId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n const cachedPassword = credentials?.current?.password;\n\n if (cachedPassword) {\n this.contensis = new ContensisMigrationService(\n {\n ...contensisOpts,\n source: {\n url: this.urls?.cms || '',\n username: !isGuidId ? userId : undefined,\n password: !isGuidId ? cachedPassword : undefined,\n clientId: isGuidId ? userId : undefined,\n sharedSecret: isGuidId ? cachedPassword : undefined,\n project: env?.currentProject || '',\n assetHostname: this.urls?.previewWeb,\n },\n concurrency:\n typeof contensisOpts.concurrency !== 'undefined'\n ? contensisOpts.concurrency\n : 3,\n outputProgress: true,\n },\n !commit\n );\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!userId) log.help(messages.connect.tip());\n }\n };\n\n ConnectContensisImport = async ({\n commit,\n source,\n fileData,\n fileDataType,\n }: {\n commit: boolean;\n source: 'contensis' | 'file' | 'input';\n fileData?: any[] | string;\n fileDataType?: 'entries' | 'contentTypes' | 'components';\n }) => {\n const { contensisOpts, currentEnv, env, log, messages, sourceEnv } = this;\n const environments = this.cache.environments || {};\n const sourceEnvironment = environments[sourceEnv || ''] || {};\n const sourceCms =\n ('source' in contensisOpts && contensisOpts.source) ||\n ({} as Partial<SourceCms>);\n const sourceUserId =\n sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;\n const sourceProjectId =\n sourceCms.project || sourceEnvironment.currentProject || 'website';\n const isSourceGuidId = sourceUserId && isUuid(sourceUserId);\n const sourceUrls = url(sourceEnv || '', sourceProjectId);\n\n const sourcePassword =\n sourceCms.sharedSecret ||\n sourceCms.password ||\n sourceEnvironment.passwordFallback;\n\n const targetUserId = env?.lastUserId;\n const isTargetGuidId = targetUserId && isUuid(targetUserId);\n\n if (sourceUserId && currentEnv && targetUserId) {\n const [sourceCredentialError, sourceCredentials] =\n await new CredentialProvider(\n {\n userId: sourceUserId,\n alias: currentEnv,\n },\n sourcePassword\n ).Init();\n\n if (sourceCredentialError && !sourceCredentials.current) {\n // Log problem with Credential Provider\n logError(sourceCredentialError);\n return;\n }\n const cachedSourcePassword = sourceCredentials?.current?.password;\n\n const [targetCredentialError, targetCredentials] =\n await new CredentialProvider(\n {\n userId: targetUserId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (targetCredentialError && !targetCredentials.current) {\n // Log problem with Credential Provider\n log.error(targetCredentialError as any);\n return;\n }\n const cachedTargetPassword = targetCredentials?.current?.password;\n\n if (cachedSourcePassword && cachedTargetPassword) {\n if (source === 'file' || source === 'input') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n ...(fileDataType ? { [fileDataType]: fileData } : {}),\n },\n !commit\n );\n }\n if (source === 'contensis') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n source: {\n url: sourceUrls.cms || '',\n username: !isSourceGuidId ? sourceUserId : undefined,\n password: !isSourceGuidId ? cachedSourcePassword : undefined,\n clientId: isSourceGuidId ? sourceUserId : undefined,\n sharedSecret: isSourceGuidId ? cachedSourcePassword : undefined,\n project: sourceProjectId,\n assetHostname: sourceUrls.previewWeb,\n },\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n },\n !commit\n );\n }\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!targetUserId) log.help(messages.connect.tip());\n }\n };\n\n Login = async (\n userId: string,\n {\n password = isPassword(this.env.passwordFallback),\n promptPassword = true,\n sharedSecret = isSharedSecret(this.env.passwordFallback),\n silent = false,\n }: {\n password?: string;\n promptPassword?: boolean;\n sharedSecret?: string;\n silent?: boolean;\n }\n ): Promise<string | undefined> => {\n let inputPassword = password;\n const { log, messages } = this;\n\n if (userId) {\n const { currentEnv, env } = this;\n\n if (currentEnv) {\n const [credentialError, credentials] = await new CredentialProvider(\n { userId, alias: currentEnv },\n inputPassword || sharedSecret\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n\n if (credentials.remarks.secure !== true) {\n log.warning(messages.login.insecurePassword());\n } else {\n delete env.passwordFallback;\n this.session.UpdateEnv(env);\n }\n\n const cachedPassword = isPassword(credentials?.current?.password);\n const cachedSecret = isSharedSecret(credentials?.current?.password);\n\n if (\n !sharedSecret &&\n !inputPassword &&\n !cachedPassword &&\n !cachedSecret &&\n promptPassword\n ) {\n // Password prompt\n ({ inputPassword } = await inquirer.prompt([\n {\n type: 'password',\n message: messages.login.passwordPrompt(currentEnv, userId),\n name: 'inputPassword',\n mask: '*',\n prefix: undefined,\n },\n ]));\n }\n\n if (sharedSecret || cachedSecret || inputPassword || cachedPassword) {\n const authService = new ContensisAuthService({\n username: userId,\n password: inputPassword || cachedPassword,\n projectId: env?.currentProject || 'website',\n rootUrl: this.urls?.cms || '',\n clientId: userId,\n clientSecret: sharedSecret || cachedSecret,\n });\n\n const [authError, bearerToken] = await to(authService.BearerToken());\n\n // Login successful\n if (bearerToken) {\n // Set env vars\n env.authToken = bearerToken;\n env.lastUserId = userId;\n env.passwordFallback =\n credentials.remarks.secure !== true\n ? credentials.current?.password\n : undefined;\n // Persist env before finding projects or doing anything else\n this.session.UpdateEnv(env);\n\n if (!silent) {\n Logger.success(messages.login.success(currentEnv, userId));\n await this.PrintProjects();\n }\n if (inputPassword) await credentials.Save(inputPassword);\n if (sharedSecret) await credentials.Save(sharedSecret);\n } else if (authError) {\n Logger.error(authError.toString());\n // Clear env vars\n env.authToken = '';\n env.lastUserId = '';\n env.passwordFallback = undefined;\n // Persist env to remove cleared values\n this.session.UpdateEnv(env);\n\n // If the auth error was raised using a cached password\n if (\n (cachedPassword || cachedSecret) &&\n credentials.remarks.secure\n ) {\n // Remove any bad stored credential and trigger login prompt again\n await credentials.Delete();\n return await this.Login(userId, { password, sharedSecret });\n } else {\n throw new Error(messages.login.failed(currentEnv, userId));\n }\n }\n\n return env.authToken;\n } else {\n Logger.error(messages.login.passwordPrompt(currentEnv, userId));\n }\n } else {\n // No environment set, use `contensis connect {alias}` first\n Logger.error(messages.login.noEnv());\n }\n } else {\n // No user id specified\n Logger.error(messages.login.noUserId());\n }\n };\n\n PrintProjects = async () => {\n const { currentProject, log, messages, session } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve projects list for env\n const [projectsErr, projects] = await to(\n this.contensis.projects.GetSourceProjects()\n );\n\n if (Array.isArray(projects)) {\n // save these projects in cache\n const nextCurrentProject =\n currentProject && currentProject !== 'null'\n ? currentProject\n : projects.some(p => p.id === 'website')\n ? 'website'\n : undefined;\n\n session.UpdateEnv({\n projects: projects.map(p => p.id),\n currentProject: nextCurrentProject,\n });\n\n log.success(messages.projects.list());\n this.HandleFormattingAndOutput(projects, () => {\n // print the projects to console\n for (const project of projects) {\n console.log(\n ` - ${nextCurrentProject === project.id ? '* ' : ''}[${\n project.primaryLanguage\n }] ${project.id}`\n );\n }\n });\n\n if (!this.SetProject(nextCurrentProject))\n log.warning(messages.projects.tip());\n }\n\n if (projectsErr) {\n log.error(messages.projects.noList());\n log.error(projectsErr.message);\n }\n }\n };\n\n SetProject = (projectId = 'website') => {\n const { env, log, messages, session } = this;\n let nextProjectId: string | undefined;\n if (env?.projects.length > 0 && env?.lastUserId) {\n nextProjectId = env.projects.find(\n p => p.toLowerCase() === projectId.toLowerCase()\n );\n if (nextProjectId) {\n env.currentProject = nextProjectId;\n session.UpdateEnv(env);\n log.success(messages.projects.set(projectId));\n } else {\n log.error(messages.projects.failedSet(projectId));\n }\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n }\n return nextProjectId;\n };\n\n SetVersion = (versionStatus: 'latest' | 'published') => {\n const { env, log, messages, session } = this;\n if (!['latest', 'published'].includes(versionStatus)) {\n log.error(messages.version.invalid(versionStatus));\n return false;\n }\n if (!env) {\n log.help(messages.version.noEnv());\n return false;\n }\n if (env?.projects.length > 0 && env?.lastUserId) {\n session.UpdateEnv({ versionStatus });\n log.success(messages.version.set(this.currentEnv, versionStatus));\n return true;\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n return false;\n }\n };\n\n HydrateContensis = async () => {\n const { log } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve content types list for env\n const [contensisErr, models] = await to(\n this.contensis.models.HydrateContensisRepositories()\n );\n\n if (contensisErr) {\n log.error(contensisErr.message);\n return contensisErr;\n }\n }\n };\n\n PrintApiKeys = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await this.contensis.apiKeys.GetKeys();\n\n if (Array.isArray(apiKeys)) {\n log.success(messages.keys.list(currentEnv));\n this.HandleFormattingAndOutput(apiKeys, () => {\n // print the keys to console\n for (const {\n id,\n sharedSecret,\n name,\n description,\n dateModified,\n modifiedBy,\n } of apiKeys) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${dateModified.toString().substring(0, 10)} ${modifiedBy}]`\n );\n console.log(` ${id}`);\n console.log(` ${sharedSecret}`);\n }\n });\n }\n\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n }\n }\n };\n\n CreateApiKey = async (name: string, description?: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.CreateKey(\n name,\n description\n );\n\n if (key) {\n log.success(messages.keys.created(currentEnv, name));\n\n // print the key details to console\n console.log(\n ` - ${key.name}${\n key.description ? ` (${key.description})` : ''\n } [${key.dateModified.toString().substring(0, 10)} ${key.modifiedBy}]`\n );\n console.log(` - id: ${key.id}`);\n console.log(` - sharedSecret: ${key.sharedSecret}`);\n }\n console.log('');\n\n if (err) {\n log.error(messages.keys.failedCreate(currentEnv, name), err);\n }\n }\n };\n\n RemoveApiKey = async (id: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis({ commit: true });\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.RemoveKey(id);\n\n if (!err) {\n log.success(messages.keys.removed(currentEnv, id));\n console.log('');\n } else {\n log.error(messages.keys.failedRemove(currentEnv, id), err);\n }\n }\n };\n\n GetContentTypes = async () => {\n const { currentProject, log, messages } = this;\n let err;\n if (!this.contensis) err = await this.HydrateContensis();\n\n if (err) log.error(messages.contenttypes.noList(currentProject));\n if (this.contensis) {\n this.contentTypes = this.contensis.models.contentTypes();\n this.components = this.contensis.models.components();\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n }\n };\n\n PrintContentTypes = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n log.success(messages.contenttypes.list(currentProject));\n this.HandleFormattingAndOutput(contentTypes, () => {\n // print the content types to console\n for (const contentType of contentTypes) {\n const fieldsLength = contentType.fields?.length || 0;\n console.log(\n ` - ${contentType.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintContentType = async (contentTypeId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n const contentType = contentTypes.find(\n c => c.id.toLowerCase() === contentTypeId.toLowerCase()\n );\n if (contentType) {\n log.success(\n messages.contenttypes.get(currentProject, contentType.id)\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, log.object);\n } else {\n log.error(\n messages.contenttypes.failedGet(currentProject, contentTypeId)\n );\n }\n }\n }\n };\n\n RemoveContentTypes = async (contentTypeIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n contentTypeIds\n );\n\n if (err) {\n log.error(\n messages.contenttypes.failedRemove(\n currentProject,\n contentTypeIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.contenttypes.removed(\n currentProject,\n contentTypeIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.object(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportContentTypes = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n contentTypeIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<ContentType[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each content type to the target repo\n for (const contentType of fileData) {\n // Fix invalid data\n contentType.projectId = currentProject;\n delete contentType.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertContentType(false, contentType);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.contenttypes.created(\n currentProject,\n contentType.id,\n createStatus\n )\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, () => {});\n }\n }\n }\n };\n\n PrintComponents = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve components list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n log.success(messages.components.list(currentProject));\n\n this.HandleFormattingAndOutput(components, () => {\n // print the components to console\n for (const component of components) {\n const fieldsLength = component.fields?.length || 0;\n console.log(\n ` - ${component.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintComponent = async (componentId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n const component = components.find(\n c => c.id.toLowerCase() === componentId.toLowerCase()\n );\n if (component) {\n log.success(messages.components.get(currentProject, component.id));\n // print the component to console\n this.HandleFormattingAndOutput(component, log.object);\n } else {\n log.error(messages.components.failedGet(currentProject, componentId));\n }\n }\n }\n };\n\n RemoveComponents = async (componentIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n undefined,\n componentIds\n );\n\n if (err) {\n log.error(\n messages.components.failedRemove(\n currentProject,\n componentIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.components.removed(\n currentProject,\n componentIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.info(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportComponents = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n componentIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<Component[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each component to the target repo\n for (const component of fileData) {\n // Fix invalid data\n component.projectId = currentProject;\n delete component.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertComponent(false, component);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.components.created(\n currentProject,\n component.id,\n createStatus\n )\n );\n // print the component to console\n this.HandleFormattingAndOutput(component, () => {});\n }\n }\n }\n };\n\n RemoveEntry = async (id: string, commit = false) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n\n if (this.contensis) {\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING DELETE *** `));\n }\n const [err, result] = await this.contensis.DeleteEntries();\n if (result)\n this.HandleFormattingAndOutput(result, () => {\n // print the migrateResult to console\n printMigrateResult(this, result, { action: 'delete' });\n });\n if (\n !err &&\n ((!commit &&\n Object.values(result.entriesToMigrate)?.[0].totalCount > 0) ||\n (commit && result.migrateResult?.deleted))\n ) {\n log.success(messages.entries.removed(currentEnv, id, commit));\n if (!commit) log.help(messages.entries.commitTip());\n } else {\n log.error(messages.entries.failedRemove(currentEnv, id), err);\n if (!Object.values(result.entriesToMigrate)?.[0].totalCount)\n log.help(messages.entries.notFound(id));\n }\n }\n };\n\n GetEntries = async ({\n withDependents = false,\n }: {\n withDependents?: boolean;\n }) => {\n const { currentProject, log, messages } = this;\n await this.ConnectContensis();\n\n if (this.contensis) {\n log.line();\n const entries = await this.contensis.GetEntries({ withDependents });\n this.HandleFormattingAndOutput(entries, () =>\n // print the entries to console\n logEntriesTable(\n entries,\n currentProject,\n this.contensis?.payload.query?.fields\n )\n );\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n ImportEntries = async ({\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n }) => {\n const { currentProject, log, messages } = this;\n\n const fileData = fromFile ? readJsonFile<Entry[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n fileData,\n fileDataType: 'entries',\n });\n\n if (this.contensis) {\n log.line();\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- IMPORT PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING IMPORT *** `));\n }\n\n const [migrateErr, migrateResult] = await this.contensis.MigrateEntries();\n\n if (migrateErr) logError(migrateErr);\n else\n this.HandleFormattingAndOutput(migrateResult, () => {\n // print the migrateResult to console\n printMigrateResult(this, migrateResult);\n });\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n PrintWebhookSubscriptions = async (\n subscriptionIds?: string[],\n name?: string\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve webhooks list for env\n const [webhooksErr, webhooks] =\n await this.contensis.subscriptions.webhooks.GetSubscriptions();\n\n const filteredResults =\n typeof name === 'string'\n ? webhooks.filter(w =>\n w.name?.toLowerCase().includes(name.toLowerCase())\n )\n : Array.isArray(subscriptionIds)\n ? webhooks.filter(w => subscriptionIds?.some(id => id === w.id))\n : webhooks;\n\n if (Array.isArray(filteredResults)) {\n this.HandleFormattingAndOutput(filteredResults, () => {\n // print the keys to console\n log.success(messages.webhooks.list(currentEnv));\n for (const {\n id,\n description,\n method,\n name,\n version,\n url,\n } of filteredResults) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${version.modified.toString().substring(0, 10)} ${\n version.modifiedBy\n }]`\n );\n console.log(` ${id}`);\n console.log(` [${method}] ${url}`);\n }\n console.log('');\n });\n }\n\n if (webhooksErr) {\n log.error(messages.webhooks.noList(currentEnv));\n log.error(jsonFormatter(webhooksErr));\n }\n }\n };\n\n PrintBlocks = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve blocks list for env\n const [err, blocks] = await this.contensis.blocks.GetBlocks();\n\n if (Array.isArray(blocks)) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the blocks to console\n log.success(messages.blocks.list(currentEnv));\n for (const {\n id,\n description,\n branches,\n liveVersion,\n madeLive,\n versionsSinceLive,\n } of blocks) {\n console.log(\n ` - ${id}${description ? ` (${description})` : ''}${\n madeLive\n ? ` [${madeLive.toString().substring(0, 10)} v${liveVersion}]`\n : ''\n }${\n versionsSinceLive\n ? log.warningText(` +${versionsSinceLive}`)\n : ''\n }`\n );\n for (const branch of branches)\n console.log(\n log.infoText(` [${branch.id}]: ${branch.status}`)\n );\n }\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PrintBlockVersions = async (\n blockId: string,\n branch: string,\n version: string\n ) => {\n const { currentEnv, env, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block version\n const [err, blocks] = await this.contensis.blocks.GetBlockVersions(\n blockId,\n branch,\n version\n );\n\n if (blocks) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the version detail to console\n log.success(\n messages.blocks.get(`${currentEnv}:${env.currentProject}`)\n );\n for (const block of blocks)\n printBlockVersion(\n this,\n block,\n !version\n ? {\n showImage: false,\n showSource: true,\n showStaticPaths: false,\n showStatus: false,\n }\n : undefined\n );\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv, env.currentProject));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PushBlock = async (block: PushBlockParams) => {\n const { currentEnv, env, log, messages } = this;\n\n // Output request to console\n messages.blocks.tryPush(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n );\n console.log(jsonFormatter(block));\n\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Push new block version\n const [err, blockVersion] = await this.contensis.blocks.PushBlockVersion(\n block\n );\n if (!err) {\n log.success(\n messages.blocks.pushed(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n )\n );\n console.log(jsonFormatter(blockVersion));\n }\n if (blockVersion) {\n this.HandleFormattingAndOutput(blockVersion, () => {\n // print the version detail to console\n printBlockVersion(this, blockVersion);\n });\n }\n if (err)\n throw new Error(\n messages.blocks.failedPush(block.id, currentEnv, env.currentProject)\n );\n }\n };\n\n PrintBlockLogs = async (\n blockId: string,\n branch: string,\n version: string,\n dataCenter: 'hq' | 'manchester' | 'london'\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block logs\n const [err, blockLogs] = await this.contensis.blocks.GetBlockLogs({\n blockId,\n branchId: branch,\n version,\n dataCenter,\n });\n\n if (blockLogs) {\n this.HandleFormattingAndOutput(blockLogs, () => {\n // print the logs to console\n log.success(messages.blocks.list(currentEnv));\n console.log(\n ` - ${blockId} ${branch} ${\n Number(version) ? `v${version}` : version\n } [${dataCenter}]`\n );\n log.line();\n console.log(log.infoText(blockLogs));\n log.line();\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n HandleFormattingAndOutput = <T>(obj: T, logFn: (obj: T) => void) => {\n const { format, log, messages, output } = this;\n if (output) {\n let writeString = '';\n if (format === 'csv') {\n writeString = csvFormatter(obj as any);\n } else if (format === 'xml') {\n writeString = xmlFormatter(obj as any);\n } else writeString = jsonFormatter(obj);\n // write output to file\n if (writeString) {\n fs.writeFileSync(output, writeString);\n log.success(messages.app.fileOutput(format, output));\n } else {\n log.info(messages.app.noFileOutput());\n }\n } else {\n if (!format) {\n // print the object to console\n logFn(obj);\n } else if (format === 'csv') {\n log.raw('');\n log.raw(log.infoText(csvFormatter(obj)));\n } else if (format === 'xml') {\n log.raw('');\n log.raw(log.infoText(xmlFormatter(obj)));\n } else if (format === 'json') {\n log.raw('');\n log.raw(log.infoText(jsonFormatter(obj)));\n }\n log.raw('');\n }\n };\n}\n\nexport const cliCommand = (\n commandArgs: string[],\n outputOpts: OutputOptions & IConnectOptions = {},\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisCli(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\nexport default ContensisCli;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;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,aAAa;AACf,kBAAAC,QAAG,cAAc,QAAQ,WAAW;AACpC,YAAI,QAAQ,SAAS,IAAI,WAAW,QAAQ,MAAM,CAAC;AAAA,MACrD,OAAO;AACL,YAAI,KAAK,SAAS,IAAI,aAAa,CAAC;AAAA,MACtC;AAAA,IACF,OAAO;AACL,UAAI,CAAC,QAAQ;AAEX,cAAM,GAAG;AAAA,MACX,WAAW,WAAW,OAAO;AAC3B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,yBAAa,GAAG,CAAC,CAAC;AAAA,MACzC,WAAW,WAAW,OAAO;AAC3B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,yBAAa,GAAG,CAAC,CAAC;AAAA,MACzC,WAAW,WAAW,QAAQ;AAC5B,YAAI,IAAI,EAAE;AACV,YAAI,IAAI,IAAI,aAAS,2BAAc,GAAG,CAAC,CAAC;AAAA,MAC1C;AACA,UAAI,IAAI,EAAE;AAAA,IACZ;AAAA,EACF;AACF;AAEO,MAAM,aAAa,CACxB,aACA,aAA8C,CAAC,GAC/C,gBAAyC,CAAC,MACvC;AACH,SAAO,IAAI,aAAa,CAAC,IAAI,IAAI,GAAG,WAAW,GAAG,YAAY,aAAa;AAC7E;AACA,IAAO,8BAAQ;",
|
|
6
6
|
"names": ["SessionCacheProvider", "path", "to", "fetch", "CredentialProvider", "inquirer", "ContensisAuthService", "name", "url", "fs"]
|
|
7
7
|
}
|
package/dist/version.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
LIB_VERSION: () => LIB_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const LIB_VERSION = "1.0.0-beta.
|
|
24
|
+
const LIB_VERSION = "1.0.0-beta.12";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.12\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.12",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": "https://github.com/contensis/node-cli",
|
|
6
6
|
"homepage": "https://github.com/contensis/node-cli/tree/main/packages/contensis-cli#readme",
|
package/src/commands/connect.ts
CHANGED
|
@@ -16,7 +16,7 @@ Example call:
|
|
|
16
16
|
> connect example-dev`
|
|
17
17
|
)
|
|
18
18
|
.action(async (alias, opts) => {
|
|
19
|
-
await cliCommand(['connect', alias], opts).Connect(alias);
|
|
19
|
+
await cliCommand(['connect', alias], { ...opts, alias }).Connect(alias);
|
|
20
20
|
await shell().start();
|
|
21
21
|
});
|
|
22
22
|
return connect;
|
package/src/commands/set.ts
CHANGED
|
@@ -12,11 +12,9 @@ export const makeSetCommand = () => {
|
|
|
12
12
|
.argument('<projectId>', 'the project id to work with')
|
|
13
13
|
.usage('<projectId>')
|
|
14
14
|
.action(async projectId => {
|
|
15
|
-
const project =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
projectId,
|
|
19
|
-
]).SetProject(projectId);
|
|
15
|
+
const project = cliCommand(['set', 'project', projectId]).SetProject(
|
|
16
|
+
projectId
|
|
17
|
+
);
|
|
20
18
|
if (project) await shell().start();
|
|
21
19
|
});
|
|
22
20
|
set
|
|
@@ -28,11 +26,9 @@ export const makeSetCommand = () => {
|
|
|
28
26
|
)
|
|
29
27
|
.usage('<latest/published>')
|
|
30
28
|
.action(async versionStatus => {
|
|
31
|
-
const success =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
versionStatus,
|
|
35
|
-
]).SetVersion(versionStatus);
|
|
29
|
+
const success = cliCommand(['set', 'version', versionStatus]).SetVersion(
|
|
30
|
+
versionStatus
|
|
31
|
+
);
|
|
36
32
|
if (success) await shell().start();
|
|
37
33
|
});
|
|
38
34
|
|
|
@@ -89,6 +89,8 @@ export const LogMessages = {
|
|
|
89
89
|
noList: () => `Cannot retrieve projects list`,
|
|
90
90
|
set: (projectId: string) => `Current project is set to "${projectId}"`,
|
|
91
91
|
failedSet: (projectId: string) => `Project "${projectId}" not found`,
|
|
92
|
+
tip: () =>
|
|
93
|
+
`You need to set your current working project with "set project {projectId}"`,
|
|
92
94
|
},
|
|
93
95
|
contenttypes: {
|
|
94
96
|
list: (projectId: string) => `Content types in "${projectId}":`,
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import clone from 'lodash/cloneDeep';
|
|
4
4
|
import mergeWith from 'lodash/mergeWith';
|
|
5
5
|
import unionBy from 'lodash/unionBy';
|
|
6
|
-
import { isJson, tryParse
|
|
6
|
+
import { isJson, tryParse } from '~/util';
|
|
7
7
|
import { Logger } from '~/util/logger';
|
|
8
8
|
|
|
9
9
|
class SessionCacheProvider {
|
|
@@ -69,6 +69,31 @@ class SessionCacheProvider {
|
|
|
69
69
|
}
|
|
70
70
|
return this.Get();
|
|
71
71
|
};
|
|
72
|
+
|
|
73
|
+
UpdateEnv = (
|
|
74
|
+
updateContent: Partial<EnvironmentCache>,
|
|
75
|
+
env = this.cache.currentEnvironment
|
|
76
|
+
) => {
|
|
77
|
+
try {
|
|
78
|
+
const environment = this.cache.environments[env || ''];
|
|
79
|
+
|
|
80
|
+
this.cache.environments[env || ''] = {
|
|
81
|
+
...environment,
|
|
82
|
+
...updateContent,
|
|
83
|
+
};
|
|
84
|
+
this.Update({
|
|
85
|
+
currentEnvironment: env,
|
|
86
|
+
environments: this.cache.environments,
|
|
87
|
+
});
|
|
88
|
+
} catch (ex: any) {
|
|
89
|
+
// Problem merging cache data for update
|
|
90
|
+
Logger.error(
|
|
91
|
+
`Problem updating environment "${env}" in environments.json`
|
|
92
|
+
);
|
|
93
|
+
Logger.error(ex);
|
|
94
|
+
}
|
|
95
|
+
return this.Get();
|
|
96
|
+
};
|
|
72
97
|
}
|
|
73
98
|
|
|
74
99
|
export default SessionCacheProvider;
|
|
@@ -58,14 +58,17 @@ class ContensisCli {
|
|
|
58
58
|
process.exit(exitCode);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
private command: CliCommand;
|
|
62
|
+
private format?: OutputFormat;
|
|
63
|
+
private output?: string;
|
|
64
|
+
private session: SessionCacheProvider;
|
|
65
|
+
|
|
62
66
|
contensis?: ContensisMigrationService;
|
|
63
67
|
contensisOpts: Partial<MigrateRequest>;
|
|
64
68
|
contentTypes?: ContentType[];
|
|
65
69
|
components?: Component[];
|
|
66
|
-
currentEnv: string;
|
|
67
70
|
currentProject: string;
|
|
68
|
-
|
|
71
|
+
|
|
69
72
|
sourceEnv?: string;
|
|
70
73
|
targetEnv?: string;
|
|
71
74
|
urls:
|
|
@@ -78,17 +81,41 @@ class ContensisCli {
|
|
|
78
81
|
iisPreviewWeb: string;
|
|
79
82
|
}
|
|
80
83
|
| undefined;
|
|
81
|
-
private command: CliCommand;
|
|
82
|
-
private format?: OutputFormat;
|
|
83
|
-
private output?: string;
|
|
84
84
|
log = Logger;
|
|
85
85
|
messages = LogMessages;
|
|
86
|
-
private session: SessionCacheProvider;
|
|
87
86
|
|
|
88
87
|
verb: string;
|
|
89
88
|
noun: string;
|
|
90
89
|
thirdArg: string;
|
|
91
90
|
|
|
91
|
+
get cache() {
|
|
92
|
+
return this.session.Get();
|
|
93
|
+
}
|
|
94
|
+
get currentEnv() {
|
|
95
|
+
return this.cache.currentEnvironment || '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set currentEnv(currentEnvironment: string) {
|
|
99
|
+
this.session.Update({ currentEnvironment });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get env() {
|
|
103
|
+
const currentEnvironment = this.currentEnv;
|
|
104
|
+
const environments = this.cache.environments || {};
|
|
105
|
+
|
|
106
|
+
if (!currentEnvironment) return {} as EnvironmentCache;
|
|
107
|
+
else if (!!environments[currentEnvironment])
|
|
108
|
+
return environments[currentEnvironment];
|
|
109
|
+
else {
|
|
110
|
+
return {
|
|
111
|
+
history: [],
|
|
112
|
+
lastUserId: '',
|
|
113
|
+
projects: [],
|
|
114
|
+
versionStatus: 'latest',
|
|
115
|
+
} as EnvironmentCache;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
92
119
|
constructor(
|
|
93
120
|
args: string[],
|
|
94
121
|
outputOpts?: OutputOptions & IConnectOptions & IImportOptions,
|
|
@@ -106,38 +133,26 @@ class ContensisCli {
|
|
|
106
133
|
}`.trim();
|
|
107
134
|
|
|
108
135
|
this.session = new SessionCacheProvider();
|
|
109
|
-
|
|
136
|
+
|
|
110
137
|
this.contensisOpts = contensisOpts;
|
|
111
138
|
this.format = outputOpts?.format;
|
|
112
139
|
this.output =
|
|
113
140
|
outputOpts?.output && path.join(process.cwd(), outputOpts.output);
|
|
114
141
|
|
|
115
|
-
const currentEnvironment =
|
|
116
|
-
outputOpts?.alias || this.cache.currentEnvironment || '';
|
|
142
|
+
const currentEnvironment = outputOpts?.alias || this.currentEnv;
|
|
117
143
|
const environments = this.cache.environments || {};
|
|
118
|
-
|
|
119
|
-
if (!currentEnvironment) this.env = {} as EnvironmentCache;
|
|
120
|
-
else if (!!environments[currentEnvironment])
|
|
121
|
-
this.env = environments[currentEnvironment];
|
|
122
|
-
else {
|
|
123
|
-
this.env = {
|
|
124
|
-
history: [],
|
|
125
|
-
lastUserId: '',
|
|
126
|
-
projects: [],
|
|
127
|
-
versionStatus: 'latest',
|
|
128
|
-
};
|
|
129
|
-
}
|
|
144
|
+
this.currentEnv = currentEnvironment;
|
|
130
145
|
|
|
131
146
|
const env = this.env;
|
|
132
147
|
|
|
133
148
|
if (outputOpts?.projectId) env.currentProject = outputOpts.projectId;
|
|
134
149
|
if (outputOpts?.user) env.lastUserId = outputOpts.user;
|
|
150
|
+
// setting this in env means passwordFallback is written to environments.json
|
|
135
151
|
if (outputOpts?.password) env.passwordFallback = outputOpts.password;
|
|
136
152
|
if (outputOpts?.clientId) env.lastUserId = outputOpts.clientId;
|
|
137
153
|
if (outputOpts?.sharedSecret)
|
|
138
154
|
env.passwordFallback = outputOpts.sharedSecret;
|
|
139
155
|
|
|
140
|
-
this.currentEnv = currentEnvironment;
|
|
141
156
|
this.currentProject = env?.currentProject || 'null';
|
|
142
157
|
this.sourceEnv = outputOpts?.sourceEnv || currentEnvironment;
|
|
143
158
|
|
|
@@ -154,7 +169,7 @@ class ContensisCli {
|
|
|
154
169
|
if (currentEnvironment) {
|
|
155
170
|
env.history = [this.command];
|
|
156
171
|
if (commandText) {
|
|
157
|
-
environments[currentEnvironment] =
|
|
172
|
+
environments[currentEnvironment] = env;
|
|
158
173
|
this.session.Update({
|
|
159
174
|
currentEnvironment,
|
|
160
175
|
environments,
|
|
@@ -181,26 +196,16 @@ class ContensisCli {
|
|
|
181
196
|
};
|
|
182
197
|
|
|
183
198
|
Connect = async (environment: string) => {
|
|
184
|
-
const {
|
|
199
|
+
const { log, messages, session } = this;
|
|
185
200
|
|
|
186
201
|
if (environment) {
|
|
187
|
-
const envCache = cache.environments[environment];
|
|
188
|
-
if (!envCache)
|
|
189
|
-
cache.environments[environment] = {
|
|
190
|
-
versionStatus: 'published',
|
|
191
|
-
history: [],
|
|
192
|
-
lastUserId: '',
|
|
193
|
-
projects: [],
|
|
194
|
-
...(!this.currentEnv ? this.env : {}),
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
this.env = cache.environments[environment];
|
|
198
202
|
this.currentEnv = environment;
|
|
199
203
|
this.urls = url(environment, 'website');
|
|
200
204
|
|
|
201
205
|
const [fetchErr, response] = await to(fetch(this.urls.cms));
|
|
202
206
|
if (response && response?.status < 400) {
|
|
203
207
|
log.success(messages.connect.connected(environment));
|
|
208
|
+
session.UpdateEnv(this.env, environment);
|
|
204
209
|
|
|
205
210
|
if (this.env?.lastUserId) {
|
|
206
211
|
await this.ConnectContensis();
|
|
@@ -208,18 +213,7 @@ class ContensisCli {
|
|
|
208
213
|
} else {
|
|
209
214
|
log.warning(messages.projects.noList());
|
|
210
215
|
log.help(messages.connect.tip());
|
|
211
|
-
// cache.environments[environment] = {
|
|
212
|
-
// versionStatus: 'published',
|
|
213
|
-
// history: [],
|
|
214
|
-
// lastUserId: '',
|
|
215
|
-
// projects: [],
|
|
216
|
-
// };
|
|
217
216
|
}
|
|
218
|
-
|
|
219
|
-
session.Update({
|
|
220
|
-
currentEnvironment: environment,
|
|
221
|
-
environments: cache.environments,
|
|
222
|
-
});
|
|
223
217
|
} else {
|
|
224
218
|
// Cannot reach environment - status X
|
|
225
219
|
log.error(
|
|
@@ -420,7 +414,7 @@ class ContensisCli {
|
|
|
420
414
|
const { log, messages } = this;
|
|
421
415
|
|
|
422
416
|
if (userId) {
|
|
423
|
-
const {
|
|
417
|
+
const { currentEnv, env } = this;
|
|
424
418
|
|
|
425
419
|
if (currentEnv) {
|
|
426
420
|
const [credentialError, credentials] = await new CredentialProvider(
|
|
@@ -434,8 +428,12 @@ class ContensisCli {
|
|
|
434
428
|
return;
|
|
435
429
|
}
|
|
436
430
|
|
|
437
|
-
if (credentials.remarks.secure !== true)
|
|
431
|
+
if (credentials.remarks.secure !== true) {
|
|
438
432
|
log.warning(messages.login.insecurePassword());
|
|
433
|
+
} else {
|
|
434
|
+
delete env.passwordFallback;
|
|
435
|
+
this.session.UpdateEnv(env);
|
|
436
|
+
}
|
|
439
437
|
|
|
440
438
|
const cachedPassword = isPassword(credentials?.current?.password);
|
|
441
439
|
const cachedSecret = isSharedSecret(credentials?.current?.password);
|
|
@@ -480,6 +478,8 @@ class ContensisCli {
|
|
|
480
478
|
credentials.remarks.secure !== true
|
|
481
479
|
? credentials.current?.password
|
|
482
480
|
: undefined;
|
|
481
|
+
// Persist env before finding projects or doing anything else
|
|
482
|
+
this.session.UpdateEnv(env);
|
|
483
483
|
|
|
484
484
|
if (!silent) {
|
|
485
485
|
Logger.success(messages.login.success(currentEnv, userId));
|
|
@@ -493,6 +493,8 @@ class ContensisCli {
|
|
|
493
493
|
env.authToken = '';
|
|
494
494
|
env.lastUserId = '';
|
|
495
495
|
env.passwordFallback = undefined;
|
|
496
|
+
// Persist env to remove cleared values
|
|
497
|
+
this.session.UpdateEnv(env);
|
|
496
498
|
|
|
497
499
|
// If the auth error was raised using a cached password
|
|
498
500
|
if (
|
|
@@ -507,10 +509,6 @@ class ContensisCli {
|
|
|
507
509
|
}
|
|
508
510
|
}
|
|
509
511
|
|
|
510
|
-
// Persist env
|
|
511
|
-
this.session.Update({
|
|
512
|
-
environments: cache.environments,
|
|
513
|
-
});
|
|
514
512
|
return env.authToken;
|
|
515
513
|
} else {
|
|
516
514
|
Logger.error(messages.login.passwordPrompt(currentEnv, userId));
|
|
@@ -526,7 +524,7 @@ class ContensisCli {
|
|
|
526
524
|
};
|
|
527
525
|
|
|
528
526
|
PrintProjects = async () => {
|
|
529
|
-
const {
|
|
527
|
+
const { currentProject, log, messages, session } = this;
|
|
530
528
|
if (!this.contensis) await this.ConnectContensis();
|
|
531
529
|
|
|
532
530
|
if (this.contensis) {
|
|
@@ -537,7 +535,6 @@ class ContensisCli {
|
|
|
537
535
|
|
|
538
536
|
if (Array.isArray(projects)) {
|
|
539
537
|
// save these projects in cache
|
|
540
|
-
const currentVals = cache.environments[currentEnv] || {};
|
|
541
538
|
const nextCurrentProject =
|
|
542
539
|
currentProject && currentProject !== 'null'
|
|
543
540
|
? currentProject
|
|
@@ -545,11 +542,10 @@ class ContensisCli {
|
|
|
545
542
|
? 'website'
|
|
546
543
|
: undefined;
|
|
547
544
|
|
|
548
|
-
|
|
549
|
-
...currentVals,
|
|
545
|
+
session.UpdateEnv({
|
|
550
546
|
projects: projects.map(p => p.id),
|
|
551
547
|
currentProject: nextCurrentProject,
|
|
552
|
-
};
|
|
548
|
+
});
|
|
553
549
|
|
|
554
550
|
log.success(messages.projects.list());
|
|
555
551
|
this.HandleFormattingAndOutput(projects, () => {
|
|
@@ -563,28 +559,19 @@ class ContensisCli {
|
|
|
563
559
|
}
|
|
564
560
|
});
|
|
565
561
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
if (nextCurrentProject) {
|
|
571
|
-
this.env = cache.environments[currentEnv];
|
|
572
|
-
this.SetProject(nextCurrentProject);
|
|
573
|
-
}
|
|
562
|
+
if (!this.SetProject(nextCurrentProject))
|
|
563
|
+
log.warning(messages.projects.tip());
|
|
574
564
|
}
|
|
575
565
|
|
|
576
566
|
if (projectsErr) {
|
|
577
567
|
log.error(messages.projects.noList());
|
|
578
568
|
log.error(projectsErr.message);
|
|
579
569
|
}
|
|
580
|
-
// } else {
|
|
581
|
-
// log.warning(messages.projects.noList());
|
|
582
|
-
// log.help(messages.connect.tip());
|
|
583
570
|
}
|
|
584
571
|
};
|
|
585
572
|
|
|
586
|
-
SetProject =
|
|
587
|
-
const {
|
|
573
|
+
SetProject = (projectId = 'website') => {
|
|
574
|
+
const { env, log, messages, session } = this;
|
|
588
575
|
let nextProjectId: string | undefined;
|
|
589
576
|
if (env?.projects.length > 0 && env?.lastUserId) {
|
|
590
577
|
nextProjectId = env.projects.find(
|
|
@@ -592,9 +579,7 @@ class ContensisCli {
|
|
|
592
579
|
);
|
|
593
580
|
if (nextProjectId) {
|
|
594
581
|
env.currentProject = nextProjectId;
|
|
595
|
-
session.
|
|
596
|
-
environments: cache.environments,
|
|
597
|
-
});
|
|
582
|
+
session.UpdateEnv(env);
|
|
598
583
|
log.success(messages.projects.set(projectId));
|
|
599
584
|
} else {
|
|
600
585
|
log.error(messages.projects.failedSet(projectId));
|
|
@@ -607,8 +592,8 @@ class ContensisCli {
|
|
|
607
592
|
return nextProjectId;
|
|
608
593
|
};
|
|
609
594
|
|
|
610
|
-
SetVersion =
|
|
611
|
-
const {
|
|
595
|
+
SetVersion = (versionStatus: 'latest' | 'published') => {
|
|
596
|
+
const { env, log, messages, session } = this;
|
|
612
597
|
if (!['latest', 'published'].includes(versionStatus)) {
|
|
613
598
|
log.error(messages.version.invalid(versionStatus));
|
|
614
599
|
return false;
|
|
@@ -618,10 +603,7 @@ class ContensisCli {
|
|
|
618
603
|
return false;
|
|
619
604
|
}
|
|
620
605
|
if (env?.projects.length > 0 && env?.lastUserId) {
|
|
621
|
-
|
|
622
|
-
session.Update({
|
|
623
|
-
environments: cache.environments,
|
|
624
|
-
});
|
|
606
|
+
session.UpdateEnv({ versionStatus });
|
|
625
607
|
log.success(messages.version.set(this.currentEnv, versionStatus));
|
|
626
608
|
return true;
|
|
627
609
|
} else {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.0.0-beta.
|
|
1
|
+
export const LIB_VERSION = "1.0.0-beta.12";
|