contensis-cli 1.3.1-beta.6 → 1.3.1-beta.8

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.
@@ -54,7 +54,7 @@ Example call:
54
54
  contentTypeId,
55
55
  fieldId,
56
56
  destinationId,
57
- template: opts.template,
57
+ template,
58
58
  rootUri: opts.rootUri
59
59
  };
60
60
  return await (0, import_ContensisCliService.cliCommand)(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/copy.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport { CopyField } from 'migratortron';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {\n commit,\n concurrency,\n entryId,\n ignoreErrors,\n latest,\n mapContensisOpts,\n noCache,\n noPublish,\n outputDetail,\n saveEntries,\n versionStatus,\n zenql,\n} from './globalOptions';\n\nexport const makeCopyCommand = () => {\n const copy = new Command()\n .command('copy')\n .description('copy command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n copy\n .command('field')\n .description('copy the contents of one content type field to another')\n .argument(\n '<contentTypeId>',\n 'the api id of the content type containing the fields to copy'\n )\n .argument('<fieldId>', 'the id of the field to copy from')\n .argument('<destinationId>', 'the id of the field to copy to')\n .option(\n '-t --template <template>',\n 'apply a liquidjs template (surrounded by double quotes) to modify the copied field content'\n )\n .option(\n '--root-uri <rootUri>',\n 'prefix your public uri to relative links in canvas content'\n )\n .addOption(commit)\n .addOption(concurrency)\n .addOption(ignoreErrors)\n .addOption(outputDetail)\n .addOption(noCache)\n .addOption(noPublish)\n .option(\n '--search <phrase>',\n 'get entries with the search phrase, use quotes for multiple words'\n )\n .addOption(entryId)\n .addOption(zenql)\n .addOption(latest)\n .addOption(versionStatus)\n .addOption(saveEntries)\n .usage('<contentTypeId> <fieldId> <destinationId> (all arguments required)')\n .addHelpText(\n 'after',\n `\nExample call:\n > copy field blog authorName contributors\\n\n > copy field blog description kicker --template \"<h2>{{ source_value }}</h2>\"\\n`\n )\n .action(\n async (\n contentTypeId: string,\n fieldId: string,\n destinationId: string,\n opts: any\n ) => {\n const { template, ...restOpts } = opts;\n const copyField: CopyField = {\n contentTypeId,\n fieldId,\n destinationId,\n template: opts.template,\n rootUri: opts.rootUri,\n };\n\n return await cliCommand(\n ['copy', 'project', contentTypeId, fieldId, destinationId],\n opts,\n mapContensisOpts({ copyField, ...restOpts })\n ).CopyEntryField({\n commit: opts.commit,\n fromFile: opts.fromFile,\n logOutput: opts.outputDetail,\n saveEntries: opts.saveEntries,\n });\n }\n );\n\n return copy;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AAExB,iCAA2B;AAC3B,2BAaO;AAEA,MAAM,kBAAkB,MAAM;AACnC,QAAM,OAAO,IAAI,yBAAQ,EACtB,QAAQ,MAAM,EACd,YAAY,cAAc,EAC1B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,OACG,QAAQ,OAAO,EACf,YAAY,wDAAwD,EACpE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,SAAS,aAAa,kCAAkC,EACxD,SAAS,mBAAmB,gCAAgC,EAC5D;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,2BAAM,EAChB,UAAU,gCAAW,EACrB,UAAU,iCAAY,EACtB,UAAU,iCAAY,EACtB,UAAU,4BAAO,EACjB,UAAU,8BAAS,EACnB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,4BAAO,EACjB,UAAU,0BAAK,EACf,UAAU,2BAAM,EAChB,UAAU,kCAAa,EACvB,UAAU,gCAAW,EACrB,MAAM,oEAAoE,EAC1E;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC;AAAA,IACC,OACE,eACA,SACA,eACA,SACG;AACH,YAAM,EAAE,UAAU,GAAG,SAAS,IAAI;AAClC,YAAM,YAAuB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,KAAK;AAAA,QACf,SAAS,KAAK;AAAA,MAChB;AAEA,aAAO,UAAM;AAAA,QACX,CAAC,QAAQ,WAAW,eAAe,SAAS,aAAa;AAAA,QACzD;AAAA,YACA,uCAAiB,EAAE,WAAW,GAAG,SAAS,CAAC;AAAA,MAC7C,EAAE,eAAe;AAAA,QACf,QAAQ,KAAK;AAAA,QACb,UAAU,KAAK;AAAA,QACf,WAAW,KAAK;AAAA,QAChB,aAAa,KAAK;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEF,SAAO;AACT;",
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport { CopyField } from 'migratortron';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {\n commit,\n concurrency,\n entryId,\n ignoreErrors,\n latest,\n mapContensisOpts,\n noCache,\n noPublish,\n outputDetail,\n saveEntries,\n versionStatus,\n zenql,\n} from './globalOptions';\n\nexport const makeCopyCommand = () => {\n const copy = new Command()\n .command('copy')\n .description('copy command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n copy\n .command('field')\n .description('copy the contents of one content type field to another')\n .argument(\n '<contentTypeId>',\n 'the api id of the content type containing the fields to copy'\n )\n .argument('<fieldId>', 'the id of the field to copy from')\n .argument('<destinationId>', 'the id of the field to copy to')\n .option(\n '-t --template <template>',\n 'apply a liquidjs template (surrounded by double quotes) to modify the copied field content'\n )\n .option(\n '--root-uri <rootUri>',\n 'prefix your public uri to relative links in canvas content'\n )\n .addOption(commit)\n .addOption(concurrency)\n .addOption(ignoreErrors)\n .addOption(outputDetail)\n .addOption(noCache)\n .addOption(noPublish)\n .option(\n '--search <phrase>',\n 'get entries with the search phrase, use quotes for multiple words'\n )\n .addOption(entryId)\n .addOption(zenql)\n .addOption(latest)\n .addOption(versionStatus)\n .addOption(saveEntries)\n .usage('<contentTypeId> <fieldId> <destinationId> (all arguments required)')\n .addHelpText(\n 'after',\n `\nExample call:\n > copy field blog authorName contributors\\n\n > copy field blog description kicker --template \"<h2>{{ source_value }}</h2>\"\\n`\n )\n .action(\n async (\n contentTypeId: string,\n fieldId: string,\n destinationId: string,\n opts: any\n ) => {\n const { template, ...restOpts } = opts;\n const copyField: CopyField = {\n contentTypeId,\n fieldId,\n destinationId,\n template,\n rootUri: opts.rootUri,\n };\n\n return await cliCommand(\n ['copy', 'project', contentTypeId, fieldId, destinationId],\n opts,\n mapContensisOpts({ copyField, ...restOpts })\n ).CopyEntryField({\n commit: opts.commit,\n fromFile: opts.fromFile,\n logOutput: opts.outputDetail,\n saveEntries: opts.saveEntries,\n });\n }\n );\n\n return copy;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AAExB,iCAA2B;AAC3B,2BAaO;AAEA,MAAM,kBAAkB,MAAM;AACnC,QAAM,OAAO,IAAI,yBAAQ,EACtB,QAAQ,MAAM,EACd,YAAY,cAAc,EAC1B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,OACG,QAAQ,OAAO,EACf,YAAY,wDAAwD,EACpE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,SAAS,aAAa,kCAAkC,EACxD,SAAS,mBAAmB,gCAAgC,EAC5D;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,2BAAM,EAChB,UAAU,gCAAW,EACrB,UAAU,iCAAY,EACtB,UAAU,iCAAY,EACtB,UAAU,4BAAO,EACjB,UAAU,8BAAS,EACnB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,4BAAO,EACjB,UAAU,0BAAK,EACf,UAAU,2BAAM,EAChB,UAAU,kCAAa,EACvB,UAAU,gCAAW,EACrB,MAAM,oEAAoE,EAC1E;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC;AAAA,IACC,OACE,eACA,SACA,eACA,SACG;AACH,YAAM,EAAE,UAAU,GAAG,SAAS,IAAI;AAClC,YAAM,YAAuB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,KAAK;AAAA,MAChB;AAEA,aAAO,UAAM;AAAA,QACX,CAAC,QAAQ,WAAW,eAAe,SAAS,aAAa;AAAA,QACzD;AAAA,YACA,uCAAiB,EAAE,WAAW,GAAG,SAAS,CAAC;AAAA,MAC7C,EAAE,eAAe;AAAA,QACf,QAAQ,KAAK;AAAA,QACb,UAAU,KAAK;AAAA,QACf,WAAW,KAAK;AAAA,QAChB,aAAa,KAAK;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEF,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -55,6 +55,7 @@ const mapContensisOpts = (opts = {}) => ({
55
55
  } : void 0,
56
56
  models: opts.modelIds,
57
57
  copyField: opts.copyField,
58
+ updateField: opts.updateField,
58
59
  // convert various cli options into MigrateRequest.query format
59
60
  query: opts.id || opts.entryIds || opts.search || opts.fields || opts.orderBy || opts.paths || opts.assetType || opts.contentType || opts.dataFormat || opts.deliveryApi || opts.latest || opts.versionStatus ? {
60
61
  assetTypes: opts.assetType,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/globalOptions.ts"],
4
- "sourcesContent": ["import { Command, Option } from 'commander';\nimport { MigrateRequest } from 'migratortron';\nimport { url } from '~/util';\n\n// Map various input options into a request to be processed\n// by Migratortron / Contensis import library\nexport const mapContensisOpts = (opts: any = {}): MigrateRequest => ({\n source:\n opts.sourceAlias || opts.sourceProjectId\n ? {\n url: opts.sourceAlias\n ? url(opts.sourceAlias, 'website').cms\n : (undefined as any),\n project: opts.sourceProjectId || (undefined as any),\n }\n : undefined,\n models: opts.modelIds,\n copyField: opts.copyField,\n // convert various cli options into MigrateRequest.query format\n query:\n opts.id ||\n opts.entryIds ||\n opts.search ||\n opts.fields ||\n opts.orderBy ||\n opts.paths ||\n opts.assetType ||\n opts.contentType ||\n opts.dataFormat ||\n opts.deliveryApi ||\n opts.latest ||\n opts.versionStatus\n ? {\n assetTypes: opts.assetType,\n contentTypeIds: opts.contentType,\n dataFormats: opts.dataFormat ? [opts.dataFormat] : undefined,\n fields: opts.fields,\n includeIds: opts.id || opts.entryIds,\n includePaths: opts.paths,\n orderBy: opts.orderBy,\n searchTerm: opts.search,\n useDelivery: opts.deliveryApi,\n versionStatus: opts.latest ? 'latest' : opts.versionStatus,\n }\n : undefined,\n zenQL: opts.zenql,\n transformGuids: !opts.preserveGuids,\n ignoreErrors: opts.ignoreErrors,\n noCache: !opts.cache, // arg is inverted automatically from `--no-cache` to `cache: false`\n includeDefaults: opts.defaults, // arg is inverted automatically from `--no-defaults` to `defaults: false`\n concurrency: opts.concurrency ? Number(opts.concurrency) : undefined,\n noPublish: !opts.publish, // arg is inverted automatically from `--no-publish` to `publish: false`\n});\n\n/* Output options */\nconst output = new Option(\n '-o --output <output>',\n 'save output to a file e.g. --output ./output.txt'\n);\n\nconst format = new Option(\n '-f --format <format>',\n 'format output as csv, json, html, xml or default'\n).choices(['csv', 'json', 'html', 'xml', 'table']);\n\n/* Connect options */\nconst alias = new Option(\n '-a --alias <alias>',\n 'the cloud CMS alias to connect your request with'\n);\n\nexport const project = new Option(\n '-p --project-id <projectId>',\n 'the projectId to make your request with'\n);\n\n/* Authentication options */\nconst user = new Option(\n '-u --user <user>',\n 'the username to authenticate your request with'\n);\nconst password = new Option(\n '-pw --password <password>',\n 'the password to use to login with (optional/insecure)'\n);\nconst clientId = new Option(\n '-id --client-id <clientId>',\n 'the clientId to authenticate your request with'\n);\nconst sharedSecret = new Option(\n '-s --shared-secret <sharedSecret>',\n 'the shared secret to use when logging in with a client id'\n);\n\n/* Model get options */\nexport const requiredBy = new Option(\n '--required-by',\n 'shows the id(s) that created each dependency'\n);\nexport const exportOption = new Option(\n '--export',\n 'export the raw resources that make up the content model(s) (used with --output)'\n);\n\n/* Entry get options */\nexport const delivery = new Option(\n '-delivery --delivery-api',\n 'use delivery api to get the entries'\n);\nexport const search = new Option(\n '--search <phrase>',\n 'get entries with the search phrase, use quotes for multiple words'\n);\nexport const zenql = new Option(\n '-q --zenql <zenql>',\n 'get entries with a supplied ZenQL statement'\n);\n\nexport const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');\nexport const contentTypes = new Option(\n '-c --content-type <contentType...>',\n 'get entries of these content type(s)'\n);\nexport const assetTypes = new Option(\n '-at --asset-type <assetType...>',\n 'get assets of given content type(s) e.g. image word pdf'\n);\nexport const versionStatus = new Option(\n '-vs --version-status <versionStatus>',\n 'the entry versions to get'\n)\n .choices(['latest', 'published'])\n .default('published');\n\nexport const latest = new Option('--latest', 'get the latest entry versions');\n\n/* Import options */\nexport const fromFile = new Option(\n '-file --from-file <fromFile>',\n 'file path to import asset(s) from'\n);\n\nexport const fromCms = new Option(\n '-source --source-alias <fromCms>',\n 'the cloud CMS alias to import asset(s) from'\n);\nexport const fromProject = new Option(\n '-sp --source-project-id <fromProject>',\n 'the id of the Contensis project to import asset(s) from (Default: [last connected project])'\n);\n\nexport const commit = new Option(\n '--commit',\n 'add this flag only after you have run a preview of the import and agree with the analysis'\n).default(false);\n\nexport const ignoreErrors = new Option(\n '-ignore --ignore-errors',\n 'commit the import ignoring any reported errors'\n).default(false);\n\nexport const outputDetail = new Option(\n '-od --output-detail <outputDetail>',\n 'how much detail to output from the import'\n)\n .choices(['errors', 'changes', 'all'])\n .default('errors');\n\nexport const saveEntries = new Option(\n '-save --save-entries',\n \"save the entries we're migrating instead of the migration preview (used with --output)\"\n);\n\nexport const concurrency = new Option(\n '-conc --concurrency <concurrency>',\n 'the number of entries to load in parallel'\n).default(2);\n\nexport const noCache = new Option(\n '--no-cache',\n 'ignore internal cache and rebuild all resources from scratch'\n);\n\nexport const noPublish = new Option(\n '--no-publish',\n \"don't publish created or updated entries\"\n);\n\nexport const addConnectOptions = (program: Command) =>\n program.addOption(alias.hideHelp()).addOption(project.hideHelp());\n\nexport const addAuthenticationOptions = (program: Command) =>\n program\n .addOption(user.hideHelp())\n .addOption(password.hideHelp())\n .addOption(clientId.hideHelp())\n .addOption(sharedSecret.hideHelp());\n\nconst addOutputAndFormatOptions = (program: Command) =>\n program.addOption(output).addOption(format);\n\nexport const addImportOptions = (program: Command) => {\n for (const command of program.commands) {\n command.addOption(fromCms).addOption(fromProject).addOption(fromFile);\n }\n return program;\n};\n\nexport const addGlobalOptions = (program: Command) => {\n for (const command of program.commands) {\n addOutputAndFormatOptions(command);\n addConnectOptions(command);\n addAuthenticationOptions(command);\n }\n return program;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgC;AAEhC,kBAAoB;AAIb,MAAM,mBAAmB,CAAC,OAAY,CAAC,OAAuB;AAAA,EACnE,QACE,KAAK,eAAe,KAAK,kBACrB;AAAA,IACE,KAAK,KAAK,kBACN,iBAAI,KAAK,aAAa,SAAS,EAAE,MAChC;AAAA,IACL,SAAS,KAAK,mBAAoB;AAAA,EACpC,IACA;AAAA,EACN,QAAQ,KAAK;AAAA,EACb,WAAW,KAAK;AAAA;AAAA,EAEhB,OACE,KAAK,MACL,KAAK,YACL,KAAK,UACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,aACL,KAAK,eACL,KAAK,cACL,KAAK,eACL,KAAK,UACL,KAAK,gBACD;AAAA,IACE,YAAY,KAAK;AAAA,IACjB,gBAAgB,KAAK;AAAA,IACrB,aAAa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C,QAAQ,UAAU,MAAM,EAAE,UAAU,MAAM;AAErC,MAAM,mBAAmB,CAAC,YAAqB;AACpD,aAAW,WAAW,QAAQ,UAAU;AACtC,YAAQ,UAAU,OAAO,EAAE,UAAU,WAAW,EAAE,UAAU,QAAQ;AAAA,EACtE;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAC,YAAqB;AACpD,aAAW,WAAW,QAAQ,UAAU;AACtC,8BAA0B,OAAO;AACjC,sBAAkB,OAAO;AACzB,6BAAyB,OAAO;AAAA,EAClC;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { Command, Option } from 'commander';\nimport { MigrateRequest } from 'migratortron';\nimport { url } from '~/util';\n\n// Map various input options into a request to be processed\n// by Migratortron / Contensis import library\nexport const mapContensisOpts = (opts: any = {}): MigrateRequest => ({\n source:\n opts.sourceAlias || opts.sourceProjectId\n ? {\n url: opts.sourceAlias\n ? url(opts.sourceAlias, 'website').cms\n : (undefined as any),\n project: opts.sourceProjectId || (undefined as any),\n }\n : undefined,\n models: opts.modelIds,\n copyField: opts.copyField,\n updateField: opts.updateField,\n // convert various cli options into MigrateRequest.query format\n query:\n opts.id ||\n opts.entryIds ||\n opts.search ||\n opts.fields ||\n opts.orderBy ||\n opts.paths ||\n opts.assetType ||\n opts.contentType ||\n opts.dataFormat ||\n opts.deliveryApi ||\n opts.latest ||\n opts.versionStatus\n ? {\n assetTypes: opts.assetType,\n contentTypeIds: opts.contentType,\n dataFormats: opts.dataFormat ? [opts.dataFormat] : undefined,\n fields: opts.fields,\n includeIds: opts.id || opts.entryIds,\n includePaths: opts.paths,\n orderBy: opts.orderBy,\n searchTerm: opts.search,\n useDelivery: opts.deliveryApi,\n versionStatus: opts.latest ? 'latest' : opts.versionStatus,\n }\n : undefined,\n zenQL: opts.zenql,\n transformGuids: !opts.preserveGuids,\n ignoreErrors: opts.ignoreErrors,\n noCache: !opts.cache, // arg is inverted automatically from `--no-cache` to `cache: false`\n includeDefaults: opts.defaults, // arg is inverted automatically from `--no-defaults` to `defaults: false`\n concurrency: opts.concurrency ? Number(opts.concurrency) : undefined,\n noPublish: !opts.publish, // arg is inverted automatically from `--no-publish` to `publish: false`\n});\n\n/* Output options */\nconst output = new Option(\n '-o --output <output>',\n 'save output to a file e.g. --output ./output.txt'\n);\n\nconst format = new Option(\n '-f --format <format>',\n 'format output as csv, json, html, xml or default'\n).choices(['csv', 'json', 'html', 'xml', 'table']);\n\n/* Connect options */\nconst alias = new Option(\n '-a --alias <alias>',\n 'the cloud CMS alias to connect your request with'\n);\n\nexport const project = new Option(\n '-p --project-id <projectId>',\n 'the projectId to make your request with'\n);\n\n/* Authentication options */\nconst user = new Option(\n '-u --user <user>',\n 'the username to authenticate your request with'\n);\nconst password = new Option(\n '-pw --password <password>',\n 'the password to use to login with (optional/insecure)'\n);\nconst clientId = new Option(\n '-id --client-id <clientId>',\n 'the clientId to authenticate your request with'\n);\nconst sharedSecret = new Option(\n '-s --shared-secret <sharedSecret>',\n 'the shared secret to use when logging in with a client id'\n);\n\n/* Model get options */\nexport const requiredBy = new Option(\n '--required-by',\n 'shows the id(s) that created each dependency'\n);\nexport const exportOption = new Option(\n '--export',\n 'export the raw resources that make up the content model(s) (used with --output)'\n);\n\n/* Entry get options */\nexport const delivery = new Option(\n '-delivery --delivery-api',\n 'use delivery api to get the entries'\n);\nexport const search = new Option(\n '--search <phrase>',\n 'get entries with the search phrase, use quotes for multiple words'\n);\nexport const zenql = new Option(\n '-q --zenql <zenql>',\n 'get entries with a supplied ZenQL statement'\n);\n\nexport const entryId = new Option('-i --id <id...>', 'the entry id(s) to get');\nexport const contentTypes = new Option(\n '-c --content-type <contentType...>',\n 'get entries of these content type(s)'\n);\nexport const assetTypes = new Option(\n '-at --asset-type <assetType...>',\n 'get assets of given content type(s) e.g. image word pdf'\n);\nexport const versionStatus = new Option(\n '-vs --version-status <versionStatus>',\n 'the entry versions to get'\n)\n .choices(['latest', 'published'])\n .default('published');\n\nexport const latest = new Option('--latest', 'get the latest entry versions');\n\n/* Import options */\nexport const fromFile = new Option(\n '-file --from-file <fromFile>',\n 'file path to import asset(s) from'\n);\n\nexport const fromCms = new Option(\n '-source --source-alias <fromCms>',\n 'the cloud CMS alias to import asset(s) from'\n);\nexport const fromProject = new Option(\n '-sp --source-project-id <fromProject>',\n 'the id of the Contensis project to import asset(s) from (Default: [last connected project])'\n);\n\nexport const commit = new Option(\n '--commit',\n 'add this flag only after you have run a preview of the import and agree with the analysis'\n).default(false);\n\nexport const ignoreErrors = new Option(\n '-ignore --ignore-errors',\n 'commit the import ignoring any reported errors'\n).default(false);\n\nexport const outputDetail = new Option(\n '-od --output-detail <outputDetail>',\n 'how much detail to output from the import'\n)\n .choices(['errors', 'changes', 'all'])\n .default('errors');\n\nexport const saveEntries = new Option(\n '-save --save-entries',\n \"save the entries we're migrating instead of the migration preview (used with --output)\"\n);\n\nexport const concurrency = new Option(\n '-conc --concurrency <concurrency>',\n 'the number of entries to load in parallel'\n).default(2);\n\nexport const noCache = new Option(\n '--no-cache',\n 'ignore internal cache and rebuild all resources from scratch'\n);\n\nexport const noPublish = new Option(\n '--no-publish',\n \"don't publish created or updated entries\"\n);\n\nexport const addConnectOptions = (program: Command) =>\n program.addOption(alias.hideHelp()).addOption(project.hideHelp());\n\nexport const addAuthenticationOptions = (program: Command) =>\n program\n .addOption(user.hideHelp())\n .addOption(password.hideHelp())\n .addOption(clientId.hideHelp())\n .addOption(sharedSecret.hideHelp());\n\nconst addOutputAndFormatOptions = (program: Command) =>\n program.addOption(output).addOption(format);\n\nexport const addImportOptions = (program: Command) => {\n for (const command of program.commands) {\n command.addOption(fromCms).addOption(fromProject).addOption(fromFile);\n }\n return program;\n};\n\nexport const addGlobalOptions = (program: Command) => {\n for (const command of program.commands) {\n addOutputAndFormatOptions(command);\n addConnectOptions(command);\n addAuthenticationOptions(command);\n }\n return program;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAAA,EACA;AACF,EAAE,QAAQ,KAAK;AAER,MAAM,eAAe,IAAI;AAAA,EAC9B;AAAA,EACA;AACF,EACG,QAAQ,CAAC,UAAU,WAAW,KAAK,CAAC,EACpC,QAAQ,QAAQ;AAEZ,MAAM,cAAc,IAAI;AAAA,EAC7B;AAAA,EACA;AACF;AAEO,MAAM,cAAc,IAAI;AAAA,EAC7B;AAAA,EACA;AACF,EAAE,QAAQ,CAAC;AAEJ,MAAM,UAAU,IAAI;AAAA,EACzB;AAAA,EACA;AACF;AAEO,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,EACA;AACF;AAEO,MAAM,oBAAoB,CAAC,YAChC,QAAQ,UAAU,MAAM,SAAS,CAAC,EAAE,UAAU,QAAQ,SAAS,CAAC;AAE3D,MAAM,2BAA2B,CAAC,YACvC,QACG,UAAU,KAAK,SAAS,CAAC,EACzB,UAAU,SAAS,SAAS,CAAC,EAC7B,UAAU,SAAS,SAAS,CAAC,EAC7B,UAAU,aAAa,SAAS,CAAC;AAEtC,MAAM,4BAA4B,CAAC,YACjC,QAAQ,UAAU,MAAM,EAAE,UAAU,MAAM;AAErC,MAAM,mBAAmB,CAAC,YAAqB;AACpD,aAAW,WAAW,QAAQ,UAAU;AACtC,YAAQ,UAAU,OAAO,EAAE,UAAU,WAAW,EAAE,UAAU,QAAQ;AAAA,EACtE;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAC,YAAqB;AACpD,aAAW,WAAW,QAAQ,UAAU;AACtC,8BAA0B,OAAO;AACjC,sBAAkB,OAAO;AACzB,6BAAyB,OAAO;AAAA,EAClC;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -38,6 +38,7 @@ var import_login = require("./login");
38
38
  var import_push = require("./push");
39
39
  var import_remove = require("./remove");
40
40
  var import_set = require("./set");
41
+ var import_update = require("./update");
41
42
  const commands = () => {
42
43
  const program = new import_commander.Command().name("contensis").version(import_version.LIB_VERSION).configureOutput({
43
44
  writeErr: (str) => {
@@ -97,6 +98,9 @@ const commands = () => {
97
98
  program.addCommand(
98
99
  (0, import_globalOptions.addConnectOptions)((0, import_set.makeSetCommand)()).copyInheritedSettings(program)
99
100
  );
101
+ program.addCommand(
102
+ (0, import_globalOptions.addGlobalOptions)((0, import_update.makeUpdateCommand)()).copyInheritedSettings(program)
103
+ );
100
104
  return program;
101
105
  };
102
106
  var commands_default = commands;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/index.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport { Logger } from '~/util/logger';\nimport { LIB_VERSION } from '~/version';\nimport { makeConnectCommand } from './connect';\nimport { makeCopyCommand } from './copy';\nimport { makeCreateCommand } from './create';\nimport { makeDevCommand } from './dev';\nimport { makeDiffCommand } from './diff';\nimport { makeExecuteCommand } from './execute';\nimport { makeGetCommand } from './get';\nimport {\n addAuthenticationOptions,\n addConnectOptions,\n addGlobalOptions,\n addImportOptions,\n} from './globalOptions';\nimport { makeImportCommand } from './import';\nimport { makeListCommand } from './list';\nimport { makeLoginCommand } from './login';\nimport { makePushCommand } from './push';\nimport { makeRemoveCommand } from './remove';\nimport { makeSetCommand } from './set';\n\nconst commands = () => {\n const program = new Command()\n .name('contensis')\n .version(LIB_VERSION)\n .configureOutput({\n writeErr: str => {\n return str.toLowerCase().includes('error')\n ? Logger.error(`Command ${str}`)\n : str.trim() && Logger.help(str);\n },\n })\n .addHelpText(\n 'after',\n Logger.helpText`\n>> Each command has its own help - for example:\n > login --help\\n > get --help\n`\n )\n .exitOverride()\n .showHelpAfterError(true);\n\n program.addCommand(\n addAuthenticationOptions(makeConnectCommand()).copyInheritedSettings(\n program\n )\n );\n program.addCommand(\n addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeCopyCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(\n addAuthenticationOptions(makeDevCommand())\n ).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(addImportOptions(makeDiffCommand())).copyInheritedSettings(\n program\n )\n );\n program.addCommand(\n addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(\n addImportOptions(makeImportCommand())\n ).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeListCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(makeLoginCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makePushCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeRemoveCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(makeSetCommand()).copyInheritedSettings(program)\n );\n\n return program;\n};\n\nexport default commands;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,oBAAuB;AACvB,qBAA4B;AAC5B,qBAAmC;AACnC,kBAAgC;AAChC,oBAAkC;AAClC,iBAA+B;AAC/B,kBAAgC;AAChC,qBAAmC;AACnC,iBAA+B;AAC/B,2BAKO;AACP,oBAAkC;AAClC,kBAAgC;AAChC,mBAAiC;AACjC,kBAAgC;AAChC,oBAAkC;AAClC,iBAA+B;AAE/B,MAAM,WAAW,MAAM;AACrB,QAAM,UAAU,IAAI,yBAAQ,EACzB,KAAK,WAAW,EAChB,QAAQ,0BAAW,EACnB,gBAAgB;AAAA,IACf,UAAU,SAAO;AACf,aAAO,IAAI,YAAY,EAAE,SAAS,OAAO,IACrC,qBAAO,MAAM,WAAW,GAAG,EAAE,IAC7B,IAAI,KAAK,KAAK,qBAAO,KAAK,GAAG;AAAA,IACnC;AAAA,EACF,CAAC,EACA;AAAA,IACC;AAAA,IACA,qBAAO;AAAA;AAAA;AAAA;AAAA,EAIT,EACC,aAAa,EACb,mBAAmB,IAAI;AAE1B,UAAQ;AAAA,QACN,mDAAyB,mCAAmB,CAAC,EAAE;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACA,UAAQ;AAAA,QACN,2CAAiB,iCAAkB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN;AAAA,UACE,mDAAyB,2BAAe,CAAC;AAAA,IAC3C,EAAE,sBAAsB,OAAO;AAAA,EACjC;AACA,UAAQ;AAAA,QACN,2CAAiB,2CAAiB,6BAAgB,CAAC,CAAC,EAAE;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACA,UAAQ;AAAA,QACN,2CAAiB,mCAAmB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACtE;AACA,UAAQ;AAAA,QACN,2CAAiB,2BAAe,CAAC,EAAE,sBAAsB,OAAO;AAAA,EAClE;AACA,UAAQ;AAAA,QACN;AAAA,UACE,2CAAiB,iCAAkB,CAAC;AAAA,IACtC,EAAE,sBAAsB,OAAO;AAAA,EACjC;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN,4CAAkB,+BAAiB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN,2CAAiB,iCAAkB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,4CAAkB,2BAAe,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AAEA,SAAO;AACT;AAEA,IAAO,mBAAQ;",
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport { Logger } from '~/util/logger';\nimport { LIB_VERSION } from '~/version';\nimport { makeConnectCommand } from './connect';\nimport { makeCopyCommand } from './copy';\nimport { makeCreateCommand } from './create';\nimport { makeDevCommand } from './dev';\nimport { makeDiffCommand } from './diff';\nimport { makeExecuteCommand } from './execute';\nimport { makeGetCommand } from './get';\nimport {\n addAuthenticationOptions,\n addConnectOptions,\n addGlobalOptions,\n addImportOptions,\n} from './globalOptions';\nimport { makeImportCommand } from './import';\nimport { makeListCommand } from './list';\nimport { makeLoginCommand } from './login';\nimport { makePushCommand } from './push';\nimport { makeRemoveCommand } from './remove';\nimport { makeSetCommand } from './set';\nimport { makeUpdateCommand } from './update';\n\nconst commands = () => {\n const program = new Command()\n .name('contensis')\n .version(LIB_VERSION)\n .configureOutput({\n writeErr: str => {\n return str.toLowerCase().includes('error')\n ? Logger.error(`Command ${str}`)\n : str.trim() && Logger.help(str);\n },\n })\n .addHelpText(\n 'after',\n Logger.helpText`\n>> Each command has its own help - for example:\n > login --help\\n > get --help\n`\n )\n .exitOverride()\n .showHelpAfterError(true);\n\n program.addCommand(\n addAuthenticationOptions(makeConnectCommand()).copyInheritedSettings(\n program\n )\n );\n program.addCommand(\n addGlobalOptions(makeCreateCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeCopyCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(\n addAuthenticationOptions(makeDevCommand())\n ).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(addImportOptions(makeDiffCommand())).copyInheritedSettings(\n program\n )\n );\n program.addCommand(\n addGlobalOptions(makeExecuteCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeGetCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(\n addImportOptions(makeImportCommand())\n ).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeListCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(makeLoginCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makePushCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeRemoveCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addConnectOptions(makeSetCommand()).copyInheritedSettings(program)\n );\n program.addCommand(\n addGlobalOptions(makeUpdateCommand()).copyInheritedSettings(program)\n );\n\n return program;\n};\n\nexport default commands;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,oBAAuB;AACvB,qBAA4B;AAC5B,qBAAmC;AACnC,kBAAgC;AAChC,oBAAkC;AAClC,iBAA+B;AAC/B,kBAAgC;AAChC,qBAAmC;AACnC,iBAA+B;AAC/B,2BAKO;AACP,oBAAkC;AAClC,kBAAgC;AAChC,mBAAiC;AACjC,kBAAgC;AAChC,oBAAkC;AAClC,iBAA+B;AAC/B,oBAAkC;AAElC,MAAM,WAAW,MAAM;AACrB,QAAM,UAAU,IAAI,yBAAQ,EACzB,KAAK,WAAW,EAChB,QAAQ,0BAAW,EACnB,gBAAgB;AAAA,IACf,UAAU,SAAO;AACf,aAAO,IAAI,YAAY,EAAE,SAAS,OAAO,IACrC,qBAAO,MAAM,WAAW,GAAG,EAAE,IAC7B,IAAI,KAAK,KAAK,qBAAO,KAAK,GAAG;AAAA,IACnC;AAAA,EACF,CAAC,EACA;AAAA,IACC;AAAA,IACA,qBAAO;AAAA;AAAA;AAAA;AAAA,EAIT,EACC,aAAa,EACb,mBAAmB,IAAI;AAE1B,UAAQ;AAAA,QACN,mDAAyB,mCAAmB,CAAC,EAAE;AAAA,MAC7C;AAAA,IACF;AAAA,EACF;AACA,UAAQ;AAAA,QACN,2CAAiB,iCAAkB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN;AAAA,UACE,mDAAyB,2BAAe,CAAC;AAAA,IAC3C,EAAE,sBAAsB,OAAO;AAAA,EACjC;AACA,UAAQ;AAAA,QACN,2CAAiB,2CAAiB,6BAAgB,CAAC,CAAC,EAAE;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AACA,UAAQ;AAAA,QACN,2CAAiB,mCAAmB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACtE;AACA,UAAQ;AAAA,QACN,2CAAiB,2BAAe,CAAC,EAAE,sBAAsB,OAAO;AAAA,EAClE;AACA,UAAQ;AAAA,QACN;AAAA,UACE,2CAAiB,iCAAkB,CAAC;AAAA,IACtC,EAAE,sBAAsB,OAAO;AAAA,EACjC;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN,4CAAkB,+BAAiB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,2CAAiB,6BAAgB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN,2CAAiB,iCAAkB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AACA,UAAQ;AAAA,QACN,4CAAkB,2BAAe,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACnE;AACA,UAAQ;AAAA,QACN,2CAAiB,iCAAkB,CAAC,EAAE,sBAAsB,OAAO;AAAA,EACrE;AAEA,SAAO;AACT;AAEA,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -33,10 +33,99 @@ __export(push_exports, {
33
33
  module.exports = __toCommonJS(push_exports);
34
34
  var import_commander = require("commander");
35
35
  var import_jsonpath_mapper = __toESM(require("jsonpath-mapper"));
36
+ var import_migratortron = require("migratortron");
37
+ var import_path = __toESM(require("path"));
36
38
  var import_ContensisCliService = require("../services/ContensisCliService");
39
+ var import_globalOptions = require("./globalOptions");
40
+ var import_json = require("../util/json.formatter");
41
+ var import_file_provider = require("../providers/file-provider");
37
42
  const makePushCommand = () => {
38
43
  const push = new import_commander.Command().command("push").description("push command").addHelpText("after", `
39
44
  `).showHelpAfterError(true).exitOverride();
45
+ push.command("asset").description("push an asset").argument("<content-type-id>", "the content type id of the asset to push").argument(
46
+ "<title>",
47
+ "the title of the asset as it appears in the cms (use quotes)"
48
+ ).argument(
49
+ "[description]",
50
+ "the description or altText of the asset (use quotes)"
51
+ ).option(
52
+ "-from --from-file <fromFile>",
53
+ "the local file path of the source asset"
54
+ ).option("-url --from-url <fromUrl>", "the full url of the source asset").option(
55
+ "-to --target-file-path <targetFilePath>",
56
+ 'the file path in the cms project to push the asset to e.g. "/asset-library/"'
57
+ ).option(
58
+ "-name --target-file-name <targetFileName>",
59
+ "set the file name in the cms project"
60
+ ).option("-i --id <id>", "push the asset with a specific guid").addOption(import_globalOptions.commit).addOption(import_globalOptions.noPublish).addOption(import_globalOptions.outputDetail).addOption(import_globalOptions.saveEntries).usage("<content-type-id> <title> [description] [options]").addHelpText(
61
+ "after",
62
+ `
63
+ Example call:
64
+ > push asset pdf "Example file" "An example of a PDF asset" --from-file example.pdf --target-file-path /asset-library/pdf/
65
+ `
66
+ ).action(
67
+ async (contentTypeId, title, description, opts) => {
68
+ const cli = (0, import_ContensisCliService.cliCommand)(
69
+ ["push", "asset", contentTypeId, title, description],
70
+ opts,
71
+ (0, import_globalOptions.mapContensisOpts)({ preserveGuids: true, ...opts, id: void 0 })
72
+ );
73
+ const mapSourceVars = {
74
+ contentTypeId,
75
+ title,
76
+ description,
77
+ ...opts
78
+ };
79
+ const assetEntry = (0, import_jsonpath_mapper.default)(mapSourceVars, {
80
+ entryTitle: "title",
81
+ title: "title",
82
+ entryDescription: "description",
83
+ description: "description",
84
+ altText: ({ contentTypeId: contentTypeId2, description: description2 }) => contentTypeId2 === "image" ? description2 : void 0,
85
+ sys: {
86
+ dataFormat: () => "asset",
87
+ contentTypeId: "contentTypeId",
88
+ id: "id",
89
+ isPublished: () => true,
90
+ // can be overridden by !opts.publish
91
+ properties: {
92
+ filename: {
93
+ $path: ["targetFileName", "fromFile", "fromUrl"],
94
+ $formatting: (nameOrPath) => {
95
+ return import_path.default.basename(nameOrPath);
96
+ }
97
+ },
98
+ filePath: {
99
+ $path: "targetFilePath",
100
+ $default: (_, { fromFile, fromUrl }) => {
101
+ const toPosixPath = (windowsPath) => windowsPath.replace(/^(\w):|\\+/g, "/$1");
102
+ return import_path.default.dirname(
103
+ toPosixPath(fromFile || fromUrl.split(":/")[1])
104
+ );
105
+ }
106
+ }
107
+ },
108
+ uri: {
109
+ $path: ["fromFile", "fromUrl"],
110
+ $formatting: (from) => (from == null ? void 0 : from.startsWith("http")) ? from : (0, import_file_provider.cwdPath)(from)
111
+ }
112
+ }
113
+ });
114
+ if (!assetEntry.sys.id)
115
+ assetEntry.sys.id = (0, import_migratortron.generateGuid)(
116
+ cli.currentEnv,
117
+ cli.currentProject,
118
+ `${assetEntry.sys.contentTypeId}-${assetEntry.sys.properties.filePath.replaceAll("/", "").toLowerCase()}-${assetEntry.sys.properties.filename.toLowerCase()}`
119
+ );
120
+ console.log((0, import_json.jsonFormatter)(assetEntry));
121
+ await cli.ImportEntries({
122
+ commit: opts.commit,
123
+ logOutput: opts.outputDetail,
124
+ saveEntries: opts.saveEntries,
125
+ data: [assetEntry]
126
+ });
127
+ }
128
+ );
40
129
  push.command("block").description("push a block").argument("<block-id>", "the name of the block to push to").argument(
41
130
  "<image uri:tag>",
42
131
  "the uri and tag of the container image to push as a block (tag default: latest)"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/push.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport mapJson from 'jsonpath-mapper';\nimport { PushBlockParams } from 'migratortron';\nimport { cliCommand } from '~/services/ContensisCliService';\n\nexport const makePushCommand = () => {\n const push = new Command()\n .command('push')\n .description('push command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n push\n .command('block')\n .description('push a block')\n .argument('<block-id>', 'the name of the block to push to')\n .argument(\n '<image uri:tag>',\n 'the uri and tag of the container image to push as a block (tag default: latest)'\n )\n .argument('[branch]', 'the branch we are pushing to')\n .option(\n '-r --release',\n 'whether to release the pushed block version',\n false\n )\n .option(\n '-cid --commit-id <commitId>',\n 'the id of the source git commit for the supplied image uri'\n )\n .option(\n '-cmsg --commit-message <commitMessage>',\n 'the git commit message for the supplied commit id'\n )\n .option(\n '-cdt --commit-datetime <commitDateTime>',\n 'the timestamp of the source git commit for the supplied image uri'\n )\n .option(\n '-author --author-email <authorEmail>',\n 'the git email address of the author of the source git commit'\n )\n .option(\n '-committer --committer-email <committerEmail>',\n 'the git email address of the commiter of the source git commit'\n )\n .option(\n '-repo --repository-url <repositoryUrl>',\n 'the url of the source repository for the supplied image uri'\n )\n .option(\n '-pr --provider <sourceProvider>',\n 'the source repository provider of the supplied image uri'\n )\n .usage('<block-id> <image uri> [branch] [options]')\n .addHelpText(\n 'after',\n `\nExample call:\n > push block contensis-app ghcr.io/contensis/contensis-app/app:build-4359 master --release\\n`\n )\n .action(async (blockId: string, imageUri: string, branch: string, opts) => {\n const cli = cliCommand(['push', 'block', blockId], opts);\n const mapSourceVars = {\n blockId,\n imageUri,\n branch,\n ...opts,\n ...process.env,\n };\n\n const blockRequest = mapJson(mapSourceVars, {\n release: { $path: 'release', $default: () => false },\n id: ['blockId'],\n image: () => {\n const lastIndexOfColon = imageUri.lastIndexOf(':');\n return {\n uri: imageUri.slice(0, lastIndexOfColon),\n tag: imageUri.slice(lastIndexOfColon + 1) || 'latest',\n };\n },\n projectId: () => cli.env.currentProject || '',\n source: {\n provider: {\n $path: ['provider'],\n $return: (provider: string, { GITHUB_ACTIONS, GITLAB_CI }) => {\n if (provider) return provider;\n if (GITHUB_ACTIONS) return 'Github';\n else if (GITLAB_CI) return 'GitlabSelfHosted';\n },\n },\n repositoryUrl: {\n $path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],\n $formatting: (url: string, { GITHUB_ACTIONS }) => {\n if (GITHUB_ACTIONS) url = `https://github.com/${url}`;\n\n if (url && !url.endsWith('.git')) return `${url}.git`;\n return url;\n },\n },\n branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],\n commit: {\n id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],\n message: {\n $path: ['commitMessage', 'CI_COMMIT_MESSAGE'], // ${{ github.event.head_commit.message }}\n $formatting: (msg?: string) =>\n msg?.replace(/\\\\n/g, ' ').replace(/\\\\n/g, ' ').trim(),\n },\n dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}\n authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}\n committerEmail: [\n 'committerEmail',\n 'GITLAB_USER_EMAIL',\n 'GITHUB_TRIGGERING_ACTOR',\n ], // ${{ github.event.head_commit.committer.email }}\n },\n },\n }) as PushBlockParams;\n\n await cli.PushBlock(blockRequest);\n\n // console.log(process.env);\n });\n\n return push;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,6BAAoB;AAEpB,iCAA2B;AAEpB,MAAM,kBAAkB,MAAM;AACnC,QAAM,OAAO,IAAI,yBAAQ,EACtB,QAAQ,MAAM,EACd,YAAY,cAAc,EAC1B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,OACG,QAAQ,OAAO,EACf,YAAY,cAAc,EAC1B,SAAS,cAAc,kCAAkC,EACzD;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,SAAS,YAAY,8BAA8B,EACnD;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC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,GAAG,GAAG;AAC/C,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QACA,QAAQ,CAAC,UAAU,sBAAsB,iBAAiB;AAAA,QAC1D,QAAQ;AAAA,UACN,IAAI,CAAC,YAAY,uBAAuB,YAAY;AAAA,UACpD,SAAS;AAAA,YACP,OAAO,CAAC,iBAAiB,mBAAmB;AAAA;AAAA,YAC5C,aAAa,CAAC,QACZ,2BAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,KAAK;AAAA,UACnD;AAAA,UACA,UAAU,CAAC,kBAAkB,qBAAqB;AAAA;AAAA,UAClD,aAAa,CAAC,eAAe,qBAAqB,cAAc;AAAA;AAAA,UAChE,gBAAgB;AAAA,YACd;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,UAAM,IAAI,UAAU,YAAY;AAAA,EAGlC,CAAC;AAEH,SAAO;AACT;",
6
- "names": ["mapJson"]
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport mapJson from 'jsonpath-mapper';\nimport { generateGuid, PushBlockParams } from 'migratortron';\nimport path from 'path';\nimport { Asset } from 'contensis-delivery-api';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {\n commit,\n mapContensisOpts,\n noPublish,\n outputDetail,\n saveEntries,\n} from './globalOptions';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { cwdPath } from '~/providers/file-provider';\n\nexport const makePushCommand = () => {\n const push = new Command()\n .command('push')\n .description('push command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n push\n .command('asset')\n .description('push an asset')\n .argument('<content-type-id>', 'the content type id of the asset to push')\n .argument(\n '<title>',\n 'the title of the asset as it appears in the cms (use quotes)'\n )\n .argument(\n '[description]',\n 'the description or altText of the asset (use quotes)'\n )\n .option(\n '-from --from-file <fromFile>',\n 'the local file path of the source asset'\n )\n .option('-url --from-url <fromUrl>', 'the full url of the source asset')\n .option(\n '-to --target-file-path <targetFilePath>',\n 'the file path in the cms project to push the asset to e.g. \"/asset-library/\"'\n )\n .option(\n '-name --target-file-name <targetFileName>',\n 'set the file name in the cms project'\n )\n .option('-i --id <id>', 'push the asset with a specific guid')\n .addOption(commit)\n .addOption(noPublish)\n .addOption(outputDetail)\n .addOption(saveEntries)\n .usage('<content-type-id> <title> [description] [options]')\n .addHelpText(\n 'after',\n `\nExample call:\n > push asset pdf \"Example file\" \"An example of a PDF asset\" --from-file example.pdf --target-file-path /asset-library/pdf/\\n`\n )\n .action(\n async (\n contentTypeId: string,\n title: string,\n description: string,\n opts\n ) => {\n const cli = cliCommand(\n ['push', 'asset', contentTypeId, title, description],\n opts,\n mapContensisOpts({ preserveGuids: true, ...opts, id: undefined })\n );\n const mapSourceVars = {\n contentTypeId,\n title,\n description,\n ...opts,\n };\n\n const assetEntry: Asset = mapJson(mapSourceVars, {\n entryTitle: 'title',\n title: 'title',\n entryDescription: 'description',\n description: 'description',\n altText: ({ contentTypeId, description }) =>\n contentTypeId === 'image' ? description : undefined,\n sys: {\n dataFormat: () => 'asset',\n contentTypeId: 'contentTypeId',\n id: 'id',\n isPublished: () => true, // can be overridden by !opts.publish\n properties: {\n filename: {\n $path: ['targetFileName', 'fromFile', 'fromUrl'],\n $formatting: (nameOrPath: string) => {\n return path.basename(nameOrPath);\n },\n },\n filePath: {\n $path: 'targetFilePath',\n $default: (_, { fromFile, fromUrl }) => {\n const toPosixPath = (windowsPath: string) =>\n windowsPath.replace(/^(\\w):|\\\\+/g, '/$1');\n\n return path.dirname(\n toPosixPath(fromFile || fromUrl.split(':/')[1])\n );\n },\n },\n },\n uri: {\n $path: ['fromFile', 'fromUrl'],\n $formatting: (from: string) =>\n from?.startsWith('http') ? from : cwdPath(from),\n },\n },\n });\n\n if (!assetEntry.sys.id)\n assetEntry.sys.id = generateGuid(\n cli.currentEnv,\n cli.currentProject,\n `${assetEntry.sys.contentTypeId}-${assetEntry.sys.properties.filePath.replaceAll('/', '').toLowerCase()}-${assetEntry.sys.properties.filename.toLowerCase()}`\n );\n\n console.log(jsonFormatter(assetEntry));\n\n await cli.ImportEntries({\n commit: opts.commit,\n logOutput: opts.outputDetail,\n saveEntries: opts.saveEntries,\n data: [assetEntry],\n });\n }\n );\n\n push\n .command('block')\n .description('push a block')\n .argument('<block-id>', 'the name of the block to push to')\n .argument(\n '<image uri:tag>',\n 'the uri and tag of the container image to push as a block (tag default: latest)'\n )\n .argument('[branch]', 'the branch we are pushing to')\n .option(\n '-r --release',\n 'whether to release the pushed block version',\n false\n )\n .option(\n '-cid --commit-id <commitId>',\n 'the id of the source git commit for the supplied image uri'\n )\n .option(\n '-cmsg --commit-message <commitMessage>',\n 'the git commit message for the supplied commit id'\n )\n .option(\n '-cdt --commit-datetime <commitDateTime>',\n 'the timestamp of the source git commit for the supplied image uri'\n )\n .option(\n '-author --author-email <authorEmail>',\n 'the git email address of the author of the source git commit'\n )\n .option(\n '-committer --committer-email <committerEmail>',\n 'the git email address of the commiter of the source git commit'\n )\n .option(\n '-repo --repository-url <repositoryUrl>',\n 'the url of the source repository for the supplied image uri'\n )\n .option(\n '-pr --provider <sourceProvider>',\n 'the source repository provider of the supplied image uri'\n )\n .usage('<block-id> <image uri> [branch] [options]')\n .addHelpText(\n 'after',\n `\nExample call:\n > push block contensis-app ghcr.io/contensis/contensis-app/app:build-4359 master --release\\n`\n )\n .action(async (blockId: string, imageUri: string, branch: string, opts) => {\n const cli = cliCommand(['push', 'block', blockId], opts);\n const mapSourceVars = {\n blockId,\n imageUri,\n branch,\n ...opts,\n ...process.env,\n };\n\n const blockRequest = mapJson(mapSourceVars, {\n release: { $path: 'release', $default: () => false },\n id: ['blockId'],\n image: () => {\n const lastIndexOfColon = imageUri.lastIndexOf(':');\n return {\n uri: imageUri.slice(0, lastIndexOfColon),\n tag: imageUri.slice(lastIndexOfColon + 1) || 'latest',\n };\n },\n projectId: () => cli.env.currentProject || '',\n source: {\n provider: {\n $path: ['provider'],\n $return: (provider: string, { GITHUB_ACTIONS, GITLAB_CI }) => {\n if (provider) return provider;\n if (GITHUB_ACTIONS) return 'Github';\n else if (GITLAB_CI) return 'GitlabSelfHosted';\n },\n },\n repositoryUrl: {\n $path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],\n $formatting: (url: string, { GITHUB_ACTIONS }) => {\n if (GITHUB_ACTIONS) url = `https://github.com/${url}`;\n\n if (url && !url.endsWith('.git')) return `${url}.git`;\n return url;\n },\n },\n branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],\n commit: {\n id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],\n message: {\n $path: ['commitMessage', 'CI_COMMIT_MESSAGE'], // ${{ github.event.head_commit.message }}\n $formatting: (msg?: string) =>\n msg?.replace(/\\\\n/g, ' ').replace(/\\\\n/g, ' ').trim(),\n },\n dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}\n authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}\n committerEmail: [\n 'committerEmail',\n 'GITLAB_USER_EMAIL',\n 'GITHUB_TRIGGERING_ACTOR',\n ], // ${{ github.event.head_commit.committer.email }}\n },\n },\n }) as PushBlockParams;\n\n await cli.PushBlock(blockRequest);\n\n // console.log(process.env);\n });\n\n return push;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,6BAAoB;AACpB,0BAA8C;AAC9C,kBAAiB;AAEjB,iCAA2B;AAC3B,2BAMO;AACP,kBAA8B;AAC9B,2BAAwB;AAEjB,MAAM,kBAAkB,MAAM;AACnC,QAAM,OAAO,IAAI,yBAAQ,EACtB,QAAQ,MAAM,EACd,YAAY,cAAc,EAC1B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,a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T;AAAA,QACF;AAAA,QACA,QAAQ,CAAC,UAAU,sBAAsB,iBAAiB;AAAA,QAC1D,QAAQ;AAAA,UACN,IAAI,CAAC,YAAY,uBAAuB,YAAY;AAAA,UACpD,SAAS;AAAA,YACP,OAAO,CAAC,iBAAiB,mBAAmB;AAAA;AAAA,YAC5C,aAAa,CAAC,QACZ,2BAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,KAAK;AAAA,UACnD;AAAA,UACA,UAAU,CAAC,kBAAkB,qBAAqB;AAAA;AAAA,UAClD,aAAa,CAAC,eAAe,qBAAqB,cAAc;AAAA;AAAA,UAChE,gBAAgB;AAAA,YACd;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,UAAM,IAAI,UAAU,YAAY;AAAA,EAGlC,CAAC;AAEH,SAAO;AACT;",
6
+ "names": ["mapJson", "contentTypeId", "description", "path"]
7
7
  }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var update_exports = {};
20
+ __export(update_exports, {
21
+ makeUpdateCommand: () => makeUpdateCommand
22
+ });
23
+ module.exports = __toCommonJS(update_exports);
24
+ var import_commander = require("commander");
25
+ var import_ContensisCliService = require("../services/ContensisCliService");
26
+ var import_globalOptions = require("./globalOptions");
27
+ const makeUpdateCommand = () => {
28
+ const update = new import_commander.Command().command("update").description("update command").addHelpText("after", `
29
+ `).showHelpAfterError(true).exitOverride();
30
+ update.command("field").description("find and replace within entry fields").argument("<fieldId>", "the id of the field to update").argument(
31
+ "<find>",
32
+ "the string to find within each entry/field (surround a phrase in double quotes)"
33
+ ).argument(
34
+ "<replace>",
35
+ "the string to replace with (surround a phrase in double quotes)"
36
+ ).addOption(import_globalOptions.commit).addOption(import_globalOptions.concurrency).addOption(import_globalOptions.ignoreErrors).addOption(import_globalOptions.outputDetail.default("changes")).addOption(import_globalOptions.noCache).addOption(import_globalOptions.noPublish).option(
37
+ "--search <phrase>",
38
+ "get entries with the search phrase, use quotes for multiple words"
39
+ ).addOption(import_globalOptions.entryId).addOption(import_globalOptions.zenql).addOption(import_globalOptions.latest).addOption(import_globalOptions.versionStatus).addOption(import_globalOptions.saveEntries).usage("<fieldId> <find> <replace> (all arguments required)").addHelpText(
40
+ "after",
41
+ `
42
+ Example call:
43
+ > update field authorName "Emma Smith" "Emma Davies" --zenql "sys.contentTypeId=blog"
44
+ `
45
+ ).action(
46
+ async (fieldId, find, replace, opts) => {
47
+ const updateField = {
48
+ fieldId,
49
+ find,
50
+ replace
51
+ };
52
+ return await (0, import_ContensisCliService.cliCommand)(
53
+ ["update", "field", fieldId, find, replace],
54
+ opts,
55
+ (0, import_globalOptions.mapContensisOpts)({ updateField, ...opts })
56
+ ).UpdateEntryField({
57
+ commit: opts.commit,
58
+ fromFile: opts.fromFile,
59
+ logOutput: opts.outputDetail,
60
+ saveEntries: opts.saveEntries
61
+ });
62
+ }
63
+ );
64
+ return update;
65
+ };
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ makeUpdateCommand
69
+ });
70
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/commands/update.ts"],
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport { UpdateField } from 'migratortron';\nimport { cliCommand } from '~/services/ContensisCliService';\nimport {\n commit,\n concurrency,\n entryId,\n ignoreErrors,\n latest,\n mapContensisOpts,\n noCache,\n noPublish,\n outputDetail,\n saveEntries,\n versionStatus,\n zenql,\n} from './globalOptions';\n\nexport const makeUpdateCommand = () => {\n const update = new Command()\n .command('update')\n .description('update command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n update\n .command('field')\n .description('find and replace within entry fields')\n .argument('<fieldId>', 'the id of the field to update')\n .argument(\n '<find>',\n 'the string to find within each entry/field (surround a phrase in double quotes)'\n )\n .argument(\n '<replace>',\n 'the string to replace with (surround a phrase in double quotes)'\n )\n .addOption(commit)\n .addOption(concurrency)\n .addOption(ignoreErrors)\n .addOption(outputDetail.default('changes'))\n .addOption(noCache)\n .addOption(noPublish)\n .option(\n '--search <phrase>',\n 'get entries with the search phrase, use quotes for multiple words'\n )\n .addOption(entryId)\n .addOption(zenql)\n .addOption(latest)\n .addOption(versionStatus)\n .addOption(saveEntries)\n .usage('<fieldId> <find> <replace> (all arguments required)')\n .addHelpText(\n 'after',\n `\nExample call:\n > update field authorName \"Emma Smith\" \"Emma Davies\" --zenql \"sys.contentTypeId=blog\"\\n`\n )\n .action(\n async (fieldId: string, find: string, replace: string, opts: any) => {\n const updateField: UpdateField = {\n fieldId,\n find,\n replace,\n };\n\n return await cliCommand(\n ['update', 'field', fieldId, find, replace],\n opts,\n mapContensisOpts({ updateField, ...opts })\n ).UpdateEntryField({\n commit: opts.commit,\n fromFile: opts.fromFile,\n logOutput: opts.outputDetail,\n saveEntries: opts.saveEntries,\n });\n }\n );\n\n return update;\n};\n\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AAExB,iCAA2B;AAC3B,2BAaO;AAEA,MAAM,oBAAoB,MAAM;AACrC,QAAM,SAAS,IAAI,yBAAQ,EACxB,QAAQ,QAAQ,EAChB,YAAY,gBAAgB,EAC5B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,SACG,QAAQ,OAAO,EACf,YAAY,sCAAsC,EAClD,SAAS,aAAa,+BAA+B,EACrD;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,2BAAM,EAChB,UAAU,gCAAW,EACrB,UAAU,iCAAY,EACtB,UAAU,kCAAa,QAAQ,SAAS,CAAC,EACzC,UAAU,4BAAO,EACjB,UAAU,8BAAS,EACnB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,UAAU,4BAAO,EACjB,UAAU,0BAAK,EACf,UAAU,2BAAM,EAChB,UAAU,kCAAa,EACvB,UAAU,gCAAW,EACrB,MAAM,qDAAqD,EAC3D;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAGF,EACC;AAAA,IACC,OAAO,SAAiB,MAAc,SAAiB,SAAc;AACnE,YAAM,cAA2B;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO,UAAM;AAAA,QACX,CAAC,UAAU,SAAS,SAAS,MAAM,OAAO;AAAA,QAC1C;AAAA,YACA,uCAAiB,EAAE,aAAa,GAAG,KAAK,CAAC;AAAA,MAC3C,EAAE,iBAAiB;AAAA,QACjB,QAAQ,KAAK;AAAA,QACb,UAAU,KAAK;AAAA,QACf,WAAW,KAAK;AAAA,QAChB,aAAa,KAAK;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEF,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -262,11 +262,12 @@ class ContensisCli {
262
262
  ConnectContensisImport = async ({
263
263
  commit = false,
264
264
  fromFile,
265
- importDataType
265
+ importDataType,
266
+ importData
266
267
  }) => {
267
268
  var _a, _b, _c, _d, _e, _f;
268
- const source = fromFile ? "file" : "contensis";
269
- const fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
269
+ const source = fromFile || importData ? "file" : "contensis";
270
+ const fileData = importData || (fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : []);
270
271
  if (typeof fileData === "string")
271
272
  throw new Error(`Import file format must be of type JSON`);
272
273
  const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
@@ -1446,14 +1447,16 @@ Components:`));
1446
1447
  commit,
1447
1448
  fromFile,
1448
1449
  logOutput,
1449
- saveEntries
1450
+ saveEntries,
1451
+ data
1450
1452
  }) => {
1451
1453
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1452
1454
  const { currentEnv, currentProject, log, messages } = this;
1453
1455
  const contensis = await this.ConnectContensisImport({
1454
1456
  commit,
1455
1457
  fromFile,
1456
- importDataType: "entries"
1458
+ importDataType: "entries",
1459
+ importData: data
1457
1460
  });
1458
1461
  if (contensis) {
1459
1462
  log.line();
@@ -1479,7 +1482,7 @@ Components:`));
1479
1482
  showDiff: logOutput === "all" || logOutput === "changes",
1480
1483
  showChanged: logOutput === "changes"
1481
1484
  });
1482
- if (["all", "changes"].includes(logOutput))
1485
+ if (["all", "changes"].includes(logOutput) && nodes.migrateNodes.length)
1483
1486
  (0, import_console.printNodeTreeOutput)(
1484
1487
  this,
1485
1488
  {
@@ -1572,6 +1575,62 @@ Components:`));
1572
1575
  log.help(messages.connect.tip());
1573
1576
  }
1574
1577
  };
1578
+ UpdateEntryField = async ({
1579
+ commit,
1580
+ fromFile,
1581
+ logOutput,
1582
+ saveEntries
1583
+ }) => {
1584
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1585
+ const { currentEnv, currentProject, log, messages } = this;
1586
+ const contensis = await this.ConnectContensisImport({
1587
+ commit,
1588
+ fromFile,
1589
+ importDataType: "entries"
1590
+ });
1591
+ if (contensis) {
1592
+ log.line();
1593
+ if (contensis.isPreview) {
1594
+ log.success(messages.migrate.preview());
1595
+ } else {
1596
+ log.warning(messages.migrate.commit());
1597
+ }
1598
+ const [err, result] = await (0, import_await_to_js.default)(
1599
+ contensis.content.update.UpdateFieldContent()
1600
+ );
1601
+ if (err) (0, import_logger.logError)(err);
1602
+ if (result) {
1603
+ const output = saveEntries ? (_a = contensis.content.update.targets[currentProject].entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON()) : result;
1604
+ await this.HandleFormattingAndOutput(output, () => {
1605
+ (0, import_console.printEntriesMigrateResult)(this, result, {
1606
+ showAll: logOutput === "all",
1607
+ showDiff: logOutput === "all" || logOutput === "changes",
1608
+ showChanged: logOutput === "changes"
1609
+ });
1610
+ });
1611
+ }
1612
+ if (result && !err && !((_b = result.errors) == null ? void 0 : _b.length) && (!commit && result.entriesToMigrate[currentProject].totalCount || commit && (((_c = result.migrateResult) == null ? void 0 : _c.created) || ((_d = result.migrateResult) == null ? void 0 : _d.updated)))) {
1613
+ log.success(
1614
+ messages.entries.imported(
1615
+ currentEnv,
1616
+ commit,
1617
+ commit ? (((_e = result.migrateResult) == null ? void 0 : _e.created) || 0) + (((_f = result.migrateResult) == null ? void 0 : _f.updated) || 0) : result.entriesToMigrate[currentProject].totalCount
1618
+ )
1619
+ );
1620
+ if (!commit) {
1621
+ log.raw(``);
1622
+ log.help(messages.entries.commitTip());
1623
+ }
1624
+ } else {
1625
+ log.error(messages.entries.failedImport(currentEnv), err);
1626
+ if (!((_h = (_g = result == null ? void 0 : result.entriesToMigrate) == null ? void 0 : _g[currentProject]) == null ? void 0 : _h.totalCount))
1627
+ log.help(messages.entries.notFound(currentEnv));
1628
+ }
1629
+ } else {
1630
+ log.warning(messages.models.noList(currentProject));
1631
+ log.help(messages.connect.tip());
1632
+ }
1633
+ };
1575
1634
  GetNodes = async (rootPath, depth = 0) => {
1576
1635
  const { currentProject, log, messages } = this;
1577
1636
  const contensis = await this.ConnectContensis();