contensis-cli 1.3.1-beta.7 → 1.3.1-beta.9

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.
@@ -627,7 +627,7 @@ class ContensisCli {
627
627
  if (contensis) {
628
628
  // Retrieve token for env
629
629
  const [error, token] = await to(
630
- contensis.content.sourceRepo.repo.BearerToken()
630
+ contensis.content.source.repo.BearerToken()
631
631
  );
632
632
  if (token) {
633
633
  // Print bearer token to console
@@ -1079,7 +1079,7 @@ class ContensisCli {
1079
1079
  if (contensis) {
1080
1080
  // Retrieve workflows list for env
1081
1081
  const [workflowsErr, workflows] =
1082
- await contensis.content.sourceRepo.workflows.GetWorkflows();
1082
+ await contensis.content.source.workflows.GetWorkflows();
1083
1083
 
1084
1084
  if (Array.isArray(workflows)) {
1085
1085
  log.success(messages.workflows.list(currentEnv));
@@ -1145,7 +1145,7 @@ class ContensisCli {
1145
1145
  if (contensis) {
1146
1146
  // Retrieve workflows list for env
1147
1147
  const [workflowsErr, workflows] =
1148
- await contensis.content.sourceRepo.workflows.GetWorkflows();
1148
+ await contensis.content.source.workflows.GetWorkflows();
1149
1149
 
1150
1150
  if (Array.isArray(workflows)) {
1151
1151
  log.success(messages.workflows.list(currentEnv));
@@ -1564,7 +1564,7 @@ class ContensisCli {
1564
1564
  contentType.projectId = currentProject;
1565
1565
  delete contentType.uuid;
1566
1566
 
1567
- const [err, , createStatus] = await contensis.models.targetRepos[
1567
+ const [err, , createStatus] = await contensis.models.targets[
1568
1568
  currentProject
1569
1569
  ].repo.UpsertContentType(false, contentType);
1570
1570
 
@@ -1755,7 +1755,7 @@ class ContensisCli {
1755
1755
  component.projectId = currentProject;
1756
1756
  delete component.uuid;
1757
1757
 
1758
- const [err, , createStatus] = await contensis.models.targetRepos[
1758
+ const [err, , createStatus] = await contensis.models.targets[
1759
1759
  currentProject
1760
1760
  ].repo.UpsertComponent(false, component);
1761
1761
 
@@ -2044,6 +2044,87 @@ class ContensisCli {
2044
2044
  }
2045
2045
  };
2046
2046
 
2047
+ UpdateEntryField = async ({
2048
+ commit,
2049
+ fromFile,
2050
+ logOutput,
2051
+ saveEntries,
2052
+ }: {
2053
+ commit: boolean;
2054
+ fromFile: string;
2055
+ logOutput: string;
2056
+ saveEntries: boolean;
2057
+ }) => {
2058
+ const { currentEnv, currentProject, log, messages } = this;
2059
+
2060
+ const contensis = await this.ConnectContensisImport({
2061
+ commit,
2062
+ fromFile,
2063
+ importDataType: 'entries',
2064
+ });
2065
+
2066
+ if (contensis) {
2067
+ log.line();
2068
+ if (contensis.isPreview) {
2069
+ log.success(messages.entries.update.preview());
2070
+ } else {
2071
+ log.warning(messages.entries.update.commit());
2072
+ }
2073
+
2074
+ const [err, result] = await to(
2075
+ contensis.content.update.UpdateFieldContent()
2076
+ );
2077
+
2078
+ if (err) logError(err);
2079
+ if (result) {
2080
+ const output = saveEntries
2081
+ ? contensis.content.update.targets[
2082
+ currentProject
2083
+ ].entries.migrate?.map(me => me.toJSON())
2084
+ : result;
2085
+ await this.HandleFormattingAndOutput(output, () => {
2086
+ // print the migrateResult to console
2087
+ printEntriesMigrateResult(this, result, {
2088
+ action: 'update',
2089
+ showAll: logOutput === 'all',
2090
+ showDiff: logOutput === 'all' || logOutput === 'changes',
2091
+ showChanged: logOutput === 'changes',
2092
+ });
2093
+ });
2094
+ }
2095
+
2096
+ if (
2097
+ result &&
2098
+ !err &&
2099
+ !result.errors?.length &&
2100
+ ((!commit && result.entriesToMigrate[currentProject].totalCount) ||
2101
+ (commit &&
2102
+ (result.migrateResult?.created || result.migrateResult?.updated)))
2103
+ ) {
2104
+ log.success(
2105
+ messages.entries.update.success(
2106
+ currentEnv,
2107
+ commit,
2108
+ commit
2109
+ ? (result.migrateResult?.created || 0) +
2110
+ (result.migrateResult?.updated || 0)
2111
+ : result.entriesToMigrate[currentProject].totalCount
2112
+ )
2113
+ );
2114
+ if (!commit) {
2115
+ log.raw(``);
2116
+ log.help(messages.entries.commitTip());
2117
+ }
2118
+ } else {
2119
+ log.error(messages.entries.update.failed(currentEnv), err);
2120
+ if (!result?.entriesToMigrate?.[currentProject]?.totalCount)
2121
+ log.help(messages.entries.notFound(currentEnv));
2122
+ }
2123
+ } else {
2124
+ log.warning(messages.models.noList(currentProject));
2125
+ log.help(messages.connect.tip());
2126
+ }
2127
+ };
2047
2128
  GetNodes = async (rootPath: string, depth = 0) => {
2048
2129
  const { currentProject, log, messages } = this;
2049
2130
  const contensis = await this.ConnectContensis();
@@ -2055,7 +2136,7 @@ class ContensisCli {
2055
2136
  log.error(messages.nodes.failedGet(currentProject), err);
2056
2137
  return;
2057
2138
  }
2058
- const root = contensis.nodes.sourceRepo.nodes.tree;
2139
+ const root = contensis.nodes.source.nodes.tree;
2059
2140
 
2060
2141
  log.success(messages.nodes.get(currentProject, rootPath, depth));
2061
2142
 
@@ -2104,8 +2185,7 @@ class ContensisCli {
2104
2185
  await this.HandleFormattingAndOutput(result, () => {
2105
2186
  // print the migrateResult to console
2106
2187
  const migrateTree =
2107
- contensis.nodes.targetRepos[currentProject].nodes
2108
- .migrateNodesTreeView;
2188
+ contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView;
2109
2189
  printNodeTreeOutput(this, migrateTree, logOutput, logLimit);
2110
2190
  printNodesMigrateResult(this, result, {
2111
2191
  showAll: logOutput === 'all',
@@ -2177,8 +2257,7 @@ class ContensisCli {
2177
2257
  // print the migrateResult to console
2178
2258
  printNodeTreeOutput(
2179
2259
  this,
2180
- contensis.nodes.targetRepos[currentProject].nodes
2181
- .migrateNodesTreeView
2260
+ contensis.nodes.targets[currentProject].nodes.migrateNodesTreeView
2182
2261
  );
2183
2262
  // printNodesMigrateResult(this, result, {
2184
2263
  // action: 'delete',
package/src/shell.ts CHANGED
@@ -199,7 +199,8 @@ class ContensisShell {
199
199
  'set role description',
200
200
  'set role assignments',
201
201
  'set role enabled',
202
- 'set role permissions'
202
+ 'set role permissions',
203
+ 'update field'
203
204
  );
204
205
 
205
206
  const prompt = inquirer.createPromptModule();
@@ -125,7 +125,7 @@ export const printEntriesMigrateResult = (
125
125
  showAll = false,
126
126
  showChanged = false,
127
127
  }: {
128
- action?: 'import' | 'delete';
128
+ action?: 'import' | 'update' | 'delete';
129
129
  showDiff?: boolean;
130
130
  showAll?: boolean;
131
131
  showChanged?: boolean;
@@ -138,7 +138,7 @@ export const printEntriesMigrateResult = (
138
138
  ) as [string, any]) {
139
139
  for (const [originalId, entryStatus] of Object.entries(entryRes) as [
140
140
  string,
141
- any
141
+ any,
142
142
  ][]) {
143
143
  if (
144
144
  showAll ||
@@ -191,17 +191,21 @@ export const printEntriesMigrateResult = (
191
191
  migrateResult.entries || {}
192
192
  ) as [string, any][]) {
193
193
  log.help(
194
- `${action} from project ${
195
- action === 'delete'
196
- ? log.warningText(currentProject)
197
- : `${log.highlightText(projectId)} to ${log.boldText(
198
- log.warningText(currentProject)
199
- )}`
200
- }`
194
+ action === 'update'
195
+ ? `update entries in project ${log.boldText(
196
+ log.warningText(currentProject)
197
+ )}`
198
+ : `${action} from project ${
199
+ action === 'delete'
200
+ ? log.warningText(currentProject)
201
+ : `${log.highlightText(projectId)} to ${log.boldText(
202
+ log.warningText(currentProject)
203
+ )}`
204
+ }`
201
205
  );
202
206
  for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [
203
207
  string,
204
- number
208
+ number,
205
209
  ][]) {
206
210
  const isTotalCountRow = contentTypeId === 'totalCount';
207
211
  const migrateStatusAndCount =
@@ -227,8 +231,8 @@ export const printEntriesMigrateResult = (
227
231
  const changedColor = isTotalCountRow
228
232
  ? log.helpText
229
233
  : changedPercentage === '100'
230
- ? log.successText
231
- : log.warningText;
234
+ ? log.successText
235
+ : log.warningText;
232
236
 
233
237
  if (isTotalCountRow && 'nodes' in migrateResult) {
234
238
  printNodesMigrateResult(service, migrateResult, {
@@ -257,8 +261,8 @@ export const printEntriesMigrateResult = (
257
261
  isTotalCountRow
258
262
  ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`
259
263
  : changedPercentage === '100'
260
- ? 'up to date'
261
- : `[needs update: ${100 - Number(changedPercentage)}%]`
264
+ ? 'up to date'
265
+ : `[needs update: ${100 - Number(changedPercentage)}%]`
262
266
  }`
263
267
  )
264
268
  }`
@@ -391,7 +395,7 @@ export const printModelMigrationAnalysis = (
391
395
  ) => {
392
396
  for (const [contentTypeId, model] of Object.entries(result) as [
393
397
  string,
394
- any
398
+ any,
395
399
  ][]) {
396
400
  let mainOutput = log.standardText(
397
401
  ` - ${contentTypeId}${
@@ -415,7 +419,7 @@ export const printModelMigrationAnalysis = (
415
419
  if (key === 'projects') {
416
420
  for (const [projectId, projectDetails] of Object.entries(details) as [
417
421
  string,
418
- any
422
+ any,
419
423
  ][]) {
420
424
  mainOutput += log.infoText(
421
425
  ` [${messages.migrate.status(projectDetails.status)(
@@ -460,7 +464,7 @@ export const printModelMigrationResult = (
460
464
  ) => {
461
465
  for (const [status, ids] of Object.entries(result) as [
462
466
  MigrateResultStatus,
463
- string[]
467
+ string[],
464
468
  ][]) {
465
469
  if (ids?.length) {
466
470
  if (status === 'errors') {
@@ -555,8 +559,8 @@ export const printNodeTreeOutput = (
555
559
  fullOutput || isRoot || !node.slug ? node.path : `/${node.slug}`
556
560
  )
557
561
  : fullOutput || isRoot || !node.slug
558
- ? node.path
559
- : `/${node.slug}`
562
+ ? node.path
563
+ : `/${node.slug}`
560
564
  )}${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ''}${
561
565
  node.childCount ? ` +${node.childCount}` : ``
562
566
  } ${'displayName' in node ? log.infoText(node.displayName) : ''}${
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.3.1-beta.7";
1
+ export const LIB_VERSION = "1.3.1-beta.9";