contensis-cli 1.3.1-beta.5 → 1.3.1-beta.7
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/globalOptions.js +2 -2
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/push.js +89 -0
- package/dist/commands/push.js.map +3 -3
- package/dist/models/CliService.d.js.map +1 -1
- package/dist/services/ContensisCliService.js +15 -6
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/util/html.formatter.js +70 -0
- package/dist/util/html.formatter.js.map +7 -0
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/globalOptions.ts +3 -3
- package/src/commands/push.ts +125 -1
- package/src/models/CliService.d.ts +1 -1
- package/src/services/ContensisCliService.ts +21 -4
- package/src/util/html.formatter.ts +52 -0
- package/src/version.ts +1 -1
|
@@ -85,8 +85,8 @@ const output = new import_commander.Option(
|
|
|
85
85
|
);
|
|
86
86
|
const format = new import_commander.Option(
|
|
87
87
|
"-f --format <format>",
|
|
88
|
-
"format output as csv, json, xml or
|
|
89
|
-
).choices(["csv", "json", "xml", "table"]);
|
|
88
|
+
"format output as csv, json, html, xml or default"
|
|
89
|
+
).choices(["csv", "json", "html", "xml", "table"]);
|
|
90
90
|
const alias = new import_commander.Option(
|
|
91
91
|
"-a --alias <alias>",
|
|
92
92
|
"the cloud CMS alias to connect your request with"
|
|
@@ -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, xml or
|
|
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,KAAK,aAAa,CAAC,KAAK,UAAU,IAAI;AAAA,IACnD,QAAQ,KAAK;AAAA,IACb,YAAY,KAAK,MAAM,KAAK;AAAA,IAC5B,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd,YAAY,KAAK;AAAA,IACjB,aAAa,KAAK;AAAA,IAClB,eAAe,KAAK,SAAS,WAAW,KAAK;AAAA,EAC/C,IACA;AAAA,EACN,OAAO,KAAK;AAAA,EACZ,gBAAgB,CAAC,KAAK;AAAA,EACtB,cAAc,KAAK;AAAA,EACnB,SAAS,CAAC,KAAK;AAAA;AAAA,EACf,iBAAiB,KAAK;AAAA;AAAA,EACtB,aAAa,KAAK,cAAc,OAAO,KAAK,WAAW,IAAI;AAAA,EAC3D,WAAW,CAAC,KAAK;AAAA;AACnB;AAGA,MAAM,SAAS,IAAI;AAAA,EACjB;AAAA,EACA;AACF;AAEA,MAAM,SAAS,IAAI;AAAA,EACjB;AAAA,EACA;AACF,EAAE,QAAQ,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC;
|
|
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,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C7B,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
|
}
|
package/dist/commands/push.js
CHANGED
|
@@ -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;
|
|
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,aAAa;AAEhB,OACG,QAAQ,OAAO,EACf,YAAY,eAAe,EAC3B,SAAS,qBAAqB,0CAA0C,EACxE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,6BAA6B,kCAAkC,EACtE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,gBAAgB,qCAAqC,EAC5D,UAAU,2BAAM,EAChB,UAAU,8BAAS,EACnB,UAAU,iCAAY,EACtB,UAAU,gCAAW,EACrB,MAAM,mDAAmD,EACzD;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAGF,EACC;AAAA,IACC,OACE,eACA,OACA,aACA,SACG;AACH,YAAM,UAAM;AAAA,QACV,CAAC,QAAQ,SAAS,eAAe,OAAO,WAAW;AAAA,QACnD;AAAA,YACA,uCAAiB,EAAE,eAAe,MAAM,GAAG,MAAM,IAAI,OAAU,CAAC;AAAA,MAClE;AACA,YAAM,gBAAgB;AAAA,QACpB;AAAA,QACA;AAAA,QACA;A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Content": ["export type CliUrls =\n | {\n api: string;\n cms: string;\n liveWeb: string;\n previewWeb: string;\n iisWeb: string;\n iisPreviewWeb: string;\n }\n | undefined;\n\nexport type OutputFormat = 'json' | 'csv' | 'xml';\n\nexport type OutputOptions = {\n format?: OutputFormat;\n output?: string;\n};\n\nexport interface IConnectOptions extends IAuthOptions {\n alias?: string;\n projectId?: string;\n}\n\nexport interface IAuthOptions {\n user?: string;\n password?: string;\n clientId?: string;\n sharedSecret?: string;\n}\n\nexport interface IImportOptions {\n sourceAlias?: string;\n sourceProjectId?: string;\n}\n\nexport type OutputOptionsConstructorArg = OutputOptions &\n IConnectOptions &\n IImportOptions;\n\nexport interface ContensisCliConstructor {\n new (\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts?: Partial<MigrateRequest>\n ): ContensisCli;\n}\n"],
|
|
4
|
+
"sourcesContent": ["export type CliUrls =\n | {\n api: string;\n cms: string;\n liveWeb: string;\n previewWeb: string;\n iisWeb: string;\n iisPreviewWeb: string;\n }\n | undefined;\n\nexport type OutputFormat = 'json' | 'csv' | 'html' | 'xml';\n\nexport type OutputOptions = {\n format?: OutputFormat;\n output?: string;\n};\n\nexport interface IConnectOptions extends IAuthOptions {\n alias?: string;\n projectId?: string;\n}\n\nexport interface IAuthOptions {\n user?: string;\n password?: string;\n clientId?: string;\n sharedSecret?: string;\n}\n\nexport interface IImportOptions {\n sourceAlias?: string;\n sourceProjectId?: string;\n}\n\nexport type OutputOptionsConstructorArg = OutputOptions &\n IConnectOptions &\n IImportOptions;\n\nexport interface ContensisCliConstructor {\n new (\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts?: Partial<MigrateRequest>\n ): ContensisCli;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -49,6 +49,7 @@ var import_util = require("../util");
|
|
|
49
49
|
var import_api_ids = require("../util/api-ids");
|
|
50
50
|
var import_console = require("../util/console.printer");
|
|
51
51
|
var import_csv = require("../util/csv.formatter");
|
|
52
|
+
var import_html = require("../util/html.formatter");
|
|
52
53
|
var import_json = require("../util/json.formatter");
|
|
53
54
|
var import_xml = require("../util/xml.formatter");
|
|
54
55
|
var import_debug = require("../util/debug");
|
|
@@ -261,11 +262,12 @@ class ContensisCli {
|
|
|
261
262
|
ConnectContensisImport = async ({
|
|
262
263
|
commit = false,
|
|
263
264
|
fromFile,
|
|
264
|
-
importDataType
|
|
265
|
+
importDataType,
|
|
266
|
+
importData
|
|
265
267
|
}) => {
|
|
266
268
|
var _a, _b, _c, _d, _e, _f;
|
|
267
|
-
const source = fromFile ? "file" : "contensis";
|
|
268
|
-
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) || [] : []);
|
|
269
271
|
if (typeof fileData === "string")
|
|
270
272
|
throw new Error(`Import file format must be of type JSON`);
|
|
271
273
|
const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
|
|
@@ -1445,14 +1447,16 @@ Components:`));
|
|
|
1445
1447
|
commit,
|
|
1446
1448
|
fromFile,
|
|
1447
1449
|
logOutput,
|
|
1448
|
-
saveEntries
|
|
1450
|
+
saveEntries,
|
|
1451
|
+
data
|
|
1449
1452
|
}) => {
|
|
1450
1453
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1451
1454
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1452
1455
|
const contensis = await this.ConnectContensisImport({
|
|
1453
1456
|
commit,
|
|
1454
1457
|
fromFile,
|
|
1455
|
-
importDataType: "entries"
|
|
1458
|
+
importDataType: "entries",
|
|
1459
|
+
importData: data
|
|
1456
1460
|
});
|
|
1457
1461
|
if (contensis) {
|
|
1458
1462
|
log.line();
|
|
@@ -1478,7 +1482,7 @@ Components:`));
|
|
|
1478
1482
|
showDiff: logOutput === "all" || logOutput === "changes",
|
|
1479
1483
|
showChanged: logOutput === "changes"
|
|
1480
1484
|
});
|
|
1481
|
-
if (["all", "changes"].includes(logOutput))
|
|
1485
|
+
if (["all", "changes"].includes(logOutput) && nodes.migrateNodes.length)
|
|
1482
1486
|
(0, import_console.printNodeTreeOutput)(
|
|
1483
1487
|
this,
|
|
1484
1488
|
{
|
|
@@ -2127,6 +2131,9 @@ Components:`));
|
|
|
2127
2131
|
} else if (format === "csv") {
|
|
2128
2132
|
log.raw("");
|
|
2129
2133
|
log.raw(log.infoText(await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
|
|
2134
|
+
} else if (format === "html") {
|
|
2135
|
+
log.raw("");
|
|
2136
|
+
log.raw(log.infoText((0, import_html.htmlFormatter)((0, import_json.limitFields)(obj, fields))));
|
|
2130
2137
|
} else if (format === "xml") {
|
|
2131
2138
|
log.raw("");
|
|
2132
2139
|
log.raw(log.infoText((0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields))));
|
|
@@ -2140,6 +2147,8 @@ Components:`));
|
|
|
2140
2147
|
const isText = !(0, import_util.tryParse)(obj) && typeof obj === "string";
|
|
2141
2148
|
if (format === "csv") {
|
|
2142
2149
|
writeString = await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
|
|
2150
|
+
} else if (format === "html") {
|
|
2151
|
+
writeString = (0, import_html.htmlFormatter)((0, import_json.limitFields)(obj, fields));
|
|
2143
2152
|
} else if (format === "xml") {
|
|
2144
2153
|
writeString = (0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields));
|
|
2145
2154
|
} else
|