contensis-cli 1.3.1-beta.0 → 1.3.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/copy.js.map +1 -1
- package/dist/commands/create.js +1 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/globalOptions.js +3 -0
- package/dist/commands/globalOptions.js.map +1 -1
- package/dist/commands/index.js +0 -2
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.js +1 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/push.js +13 -10
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/remove.js +2 -4
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/set.js +2 -4
- package/dist/commands/set.js.map +1 -1
- package/dist/factories/RequestHandlerFactory.js +12 -5
- package/dist/factories/RequestHandlerFactory.js.map +2 -2
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/localisation/en-GB.js +8 -1
- package/dist/localisation/en-GB.js.map +1 -1
- package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +1 -1
- package/dist/mappers/DevInit-to-CIWorkflow.js +11 -6
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +1 -1
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +4 -2
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +1 -1
- package/dist/providers/CredentialProvider.js +11 -4
- package/dist/providers/CredentialProvider.js.map +1 -1
- package/dist/providers/GitHubCliModuleProvider.js +8 -10
- package/dist/providers/GitHubCliModuleProvider.js.map +1 -1
- package/dist/providers/HttpProvider.js +5 -4
- package/dist/providers/HttpProvider.js.map +1 -1
- package/dist/providers/ManifestProvider.js +1 -4
- package/dist/providers/ManifestProvider.js.map +1 -1
- package/dist/providers/SessionCacheProvider.js +8 -8
- package/dist/providers/SessionCacheProvider.js.map +1 -1
- package/dist/providers/file-provider.js +13 -11
- package/dist/providers/file-provider.js.map +1 -1
- package/dist/services/ContensisAuthService.js +1 -2
- package/dist/services/ContensisAuthService.js.map +1 -1
- package/dist/services/ContensisCliService.js +83 -106
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/services/ContensisDevService.js +15 -18
- package/dist/services/ContensisDevService.js.map +2 -2
- package/dist/services/ContensisRoleService.js +8 -10
- package/dist/services/ContensisRoleService.js.map +1 -1
- package/dist/shell.js +10 -6
- package/dist/shell.js.map +1 -1
- package/dist/util/api-ids.js.map +1 -1
- package/dist/util/console.printer.js +12 -16
- package/dist/util/console.printer.js.map +1 -1
- package/dist/util/csv.formatter.js +8 -15
- package/dist/util/csv.formatter.js.map +2 -2
- package/dist/util/diff.js +6 -4
- package/dist/util/diff.js.map +1 -1
- package/dist/util/dotenv.js +1 -2
- package/dist/util/dotenv.js.map +1 -1
- package/dist/util/error.js.map +1 -1
- package/dist/util/fetch.js +4 -0
- package/dist/util/fetch.js.map +1 -1
- package/dist/util/git.js +8 -8
- package/dist/util/git.js.map +1 -1
- package/dist/util/gitignore.js +4 -0
- package/dist/util/gitignore.js.map +1 -1
- package/dist/util/index.js +5 -1
- package/dist/util/index.js.map +2 -2
- package/dist/util/json.formatter.js +6 -4
- package/dist/util/json.formatter.js.map +1 -1
- package/dist/util/logger.js +45 -50
- package/dist/util/logger.js.map +2 -2
- package/dist/util/os.js +4 -0
- package/dist/util/os.js.map +1 -1
- package/dist/util/xml.formatter.js +4 -0
- package/dist/util/xml.formatter.js.map +1 -1
- package/dist/util/yaml.js +1 -2
- package/dist/util/yaml.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/esbuild.config.js +10 -14
- package/package.json +5 -5
- package/src/factories/RequestHandlerFactory.ts +1 -1
- package/src/services/ContensisCliService.ts +38 -28
- package/src/services/ContensisDevService.ts +2 -2
- package/src/util/csv.formatter.ts +1 -1
- package/src/util/index.ts +1 -1
- package/src/util/logger.ts +15 -14
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/providers/SessionCacheProvider.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport clone from 'lodash/cloneDeep';\nimport mergeWith from 'lodash/mergeWith';\nimport unionBy from 'lodash/unionBy';\nimport { appRootDir } from './file-provider';\nimport { isJson, tryParse } from '~/util';\nimport { Logger } from '~/util/logger';\n\nclass SessionCacheProvider {\n private localFilePath: string;\n private cache = {} as SessionCache;\n\n constructor() {\n this.localFilePath = path.join(appRootDir, 'environments.json');\n this.cache = {\n currentTimestamp: new Date().toISOString(),\n environments: {},\n history: [],\n };\n this.ReadCacheFromDisk();\n }\n\n private ReadCacheFromDisk = () => {\n try {\n if (fs.existsSync(this.localFilePath)) {\n const raw = fs.readFileSync(this.localFilePath, 'utf-8');\n if (isJson(raw)) this.cache = tryParse(raw);\n } else {\n this.WriteCacheToDisk();\n }\n } catch (ex) {\n // Problem reading or parsing cache file\n }\n };\n\n private WriteCacheToDisk = () => {\n try {\n fs.writeFileSync(this.localFilePath, JSON.stringify(this.cache, null, 2));\n } catch (ex) {\n // Problem writing session cache to file\n }\n };\n\n Get = () => clone(this.cache);\n\n Update = (updateContent: Partial<SessionCache>) => {\n try {\n this.cache = mergeWith(this.cache, updateContent, (val, src, key) => {\n if (\n key === 'history' &&\n ((src?.[0] &&\n typeof src[0] === 'object' &&\n 'createdDate' in src[0]) ||\n (val?.[0] && typeof val[0] === 'object' && 'createdDate' in val[0]))\n ) {\n return unionBy(val, src, 'createdDate');\n }\n if (key === 'projects')\n return Array.isArray(val) ? [...new Set([...val, ...src])] : src;\n\n if (Array.isArray(val)) return val.concat(src);\n });\n this.cache.currentTimestamp = new Date().toISOString();\n this.WriteCacheToDisk();\n } catch (ex: any) {\n // Problem merging cache data for update\n Logger.error(`Problem updating environments.json`);\n Logger.error(ex);\n }\n return this.Get();\n };\n\n UpdateEnv = (\n updateContent: Partial<EnvironmentCache>,\n env = this.cache.currentEnvironment,\n setCurrentEnv = true\n ) => {\n try {\n const environment = this.cache.environments[env || ''];\n\n this.cache.environments[env || ''] = {\n ...environment,\n ...updateContent,\n };\n this.Update({\n currentEnvironment: setCurrentEnv ? env : this.cache.currentEnvironment,\n environments: this.cache.environments,\n });\n } catch (ex: any) {\n // Problem merging cache data for update\n Logger.error(\n `Problem updating environment \"${env}\" in environments.json`\n );\n Logger.error(ex);\n }\n return this.Get();\n };\n}\n\nexport default SessionCacheProvider;\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,uBAAkB;AAClB,uBAAsB;AACtB,qBAAoB;AACpB,2BAA2B;AAC3B,kBAAiC;AACjC,oBAAuB;AAEvB,MAAM,qBAAqB;AAAA,EACjB;AAAA,EACA,QAAQ,CAAC;AAAA,EAEjB,cAAc;AACZ,SAAK,gBAAgB,YAAAA,QAAK,KAAK,iCAAY,mBAAmB;AAC9D,SAAK,QAAQ;AAAA,MACX,mBAAkB,oBAAI,KAAK,GAAE,YAAY;AAAA,MACzC,cAAc,CAAC;AAAA,MACf,SAAS,CAAC;AAAA,IACZ;AACA,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAEQ,oBAAoB,MAAM;AAChC,QAAI;AACF,UAAI,UAAAC,QAAG,WAAW,KAAK,aAAa,GAAG;AACrC,cAAM,MAAM,UAAAA,QAAG,aAAa,KAAK,eAAe,OAAO;AACvD,gBAAI,oBAAO,GAAG,EAAG,MAAK,YAAQ,sBAAS,GAAG;AAAA,MAC5C,OAAO;AACL,aAAK,iBAAiB;AAAA,MACxB;AAAA,IACF,SAAS,IAAI;AAAA,IAEb;AAAA,EACF;AAAA,EAEQ,mBAAmB,MAAM;AAC/B,QAAI;AACF,gBAAAA,QAAG,cAAc,KAAK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S,IAAS;AAEhB,2BAAO;AAAA,QACL,iCAAiC,GAAG;AAAA,MACtC;AACA,2BAAO,MAAM,EAAE;AAAA,IACjB;AACA,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;AAEA,IAAO,+BAAQ;",
|
|
6
6
|
"names": ["path", "fs", "clone", "mergeWith", "unionBy"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -114,28 +118,26 @@ const checkDir = (filePath) => {
|
|
|
114
118
|
const appPath = (filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(appRootDir, filePath);
|
|
115
119
|
const cwdPath = (filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(process.cwd(), filePath);
|
|
116
120
|
const joinPath = import_path.default.join;
|
|
117
|
-
const addExecutePermission = (filePath) =>
|
|
121
|
+
const addExecutePermission = (filePath) => (
|
|
122
|
+
// Fails in windows with `TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be of type number. Received undefined`
|
|
123
|
+
import_fs.default.chmodSync(filePath, import_fs.default.constants.S_IRWXU)
|
|
124
|
+
);
|
|
118
125
|
const detectFileType = (fromFile) => {
|
|
119
126
|
const fileData = readFile(fromFile);
|
|
120
|
-
if (!fileData)
|
|
121
|
-
throw new Error(`Unable to read file at ${fromFile}`);
|
|
127
|
+
if (!fileData) throw new Error(`Unable to read file at ${fromFile}`);
|
|
122
128
|
try {
|
|
123
|
-
if (fileData.startsWith("<"))
|
|
124
|
-
return { contents: fileData, type: "xml" };
|
|
129
|
+
if (fileData.startsWith("<")) return { contents: fileData, type: "xml" };
|
|
125
130
|
const jsonData = (0, import_util.tryParse)(fileData);
|
|
126
|
-
if (jsonData)
|
|
127
|
-
return { contents: jsonData, type: "json" };
|
|
131
|
+
if (jsonData) return { contents: jsonData, type: "json" };
|
|
128
132
|
const csv = (0, import_csv.detectCsv)(fileData);
|
|
129
|
-
if (csv)
|
|
130
|
-
return { contents: fileData, type: "csv" };
|
|
133
|
+
if (csv) return { contents: fileData, type: "csv" };
|
|
131
134
|
} catch (ex) {
|
|
132
135
|
import_logger.Logger.error(`Problem detecting file type ${fromFile}`, ex);
|
|
133
136
|
}
|
|
134
137
|
};
|
|
135
138
|
const readFileAsJSON = async (fromFile) => {
|
|
136
139
|
const detectedFile = detectFileType(cwdPath(fromFile));
|
|
137
|
-
if (!detectedFile)
|
|
138
|
-
return void 0;
|
|
140
|
+
if (!detectedFile) return void 0;
|
|
139
141
|
try {
|
|
140
142
|
switch (detectedFile.type) {
|
|
141
143
|
case "csv": {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/providers/file-provider.ts"],
|
|
4
4
|
"sourcesContent": ["import fs from 'fs';\nimport { homedir } from 'os';\nimport path from 'path';\nimport { tryParse } from '~/util';\nimport { csvToJson, detectCsv } from '~/util/csv.formatter';\nimport { unflattenObject } from '~/util/json.formatter';\nimport { Logger } from '~/util/logger';\nimport { xmlToJson } from '~/util/xml.formatter';\n\nconst userHomeDir = homedir();\n\nexport const appRootDir =\n process.env.CONTAINER_CONTEXT === 'true'\n ? process.cwd()\n : path.join(userHomeDir, '.contensis/');\n\nexport const readFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n const file = fs.readFileSync(directoryPath, 'utf8');\n return file;\n } else {\n return undefined;\n }\n};\n\nexport const readFiles = (directory: string, createDirectory = true) => {\n const directoryPath = appPath(directory);\n if (fs.existsSync(directoryPath)) {\n const files = fs.readdirSync(directoryPath);\n return files;\n } else if (createDirectory) {\n fs.mkdirSync(directoryPath, { recursive: true });\n return [];\n } else {\n throw new Error(`ENOENT: Directory does not exist ${directoryPath}`);\n // return undefined;\n }\n};\n\nexport const writeFile = (filePath: string, content: string) => {\n const directoryPath = appPath(filePath);\n fs.writeFileSync(directoryPath, content, { encoding: 'utf-8' });\n};\n\nexport const removeFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath);\n }\n};\n\nexport const removeDirectory = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath, { force: true, recursive: true });\n }\n};\n\nexport const moveFile = (file: string, fromPath: string, toPath: string) => {\n const from = path.join(appRootDir, `${fromPath}${file}`);\n const to = path.join(appRootDir, `${toPath}${file}`);\n if (fs.existsSync(from)) {\n checkDir(toPath);\n // if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });\n\n fs.rename(from, to, err => {\n if (err)\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}`,\n err\n );\n console.info(`Renamed file \"${file}\" from: ${fromPath} to: ${toPath}`);\n });\n } else {\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}\\nFile does not exist!`\n );\n }\n};\n\nexport const checkDir = (filePath: string) => {\n const directoryPath = path.dirname(appPath(filePath));\n if (!fs.existsSync(directoryPath))\n fs.mkdirSync(directoryPath, { recursive: true });\n};\n\nexport const appPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(appRootDir, filePath);\n\nexport const cwdPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);\n\nexport const joinPath = path.join;\n\nexport const addExecutePermission = (filePath: string) =>\n // Fails in windows with `TypeError [ERR_INVALID_ARG_TYPE]: The \"mode\" argument must be of type number. Received undefined`\n fs.chmodSync(filePath, fs.constants.S_IRWXU);\n\ntype DetectedFileType =\n | { type: 'json'; contents: any }\n | { type: 'xml' | 'csv'; contents: string };\n\nconst detectFileType = (fromFile: string): DetectedFileType | undefined => {\n const fileData = readFile(fromFile);\n if (!fileData) throw new Error(`Unable to read file at ${fromFile}`);\n try {\n // if XML\n if (fileData.startsWith('<')) return { contents: fileData, type: 'xml' };\n\n // if JSON\n const jsonData = tryParse(fileData);\n if (jsonData) return { contents: jsonData, type: 'json' };\n\n // if CSV\n const csv = detectCsv(fileData);\n if (csv) return { contents: fileData, type: 'csv' };\n } catch (ex) {\n Logger.error(`Problem detecting file type ${fromFile}`, ex);\n }\n};\n\nexport const readFileAsJSON = async <T = any>(\n fromFile: string\n): Promise<T | undefined> => {\n const detectedFile = detectFileType(cwdPath(fromFile));\n if (!detectedFile) return undefined;\n try {\n switch (detectedFile.type) {\n case 'csv': {\n const flatJson = await csvToJson(detectedFile.contents);\n const unflattenedJson = flatJson.map(record => unflattenObject(record));\n return unflattenedJson as T;\n }\n case 'xml':\n return (await xmlToJson(detectedFile.contents)) as T;\n\n case 'json':\n default:\n return detectedFile.contents;\n }\n } catch (ex) {\n Logger.error(`Problem converting file from ${detectedFile.type}`, ex);\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,gBAAwB;AACxB,kBAAiB;AACjB,kBAAyB;AACzB,iBAAqC;AACrC,kBAAgC;AAChC,oBAAuB;AACvB,iBAA0B;AAE1B,MAAM,kBAAc,mBAAQ;AAErB,MAAM,aACX,QAAQ,IAAI,sBAAsB,SAC9B,QAAQ,IAAI,IACZ,Y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AM;AAGvE,UAAM,eAAW,sBAAS,QAAQ;AAClC,QAAI,SAAU,QAAO,EAAE,UAAU,UAAU,MAAM,OAAO;AAGxD,UAAM,UAAM,sBAAU,QAAQ;AAC9B,QAAI,IAAK,QAAO,EAAE,UAAU,UAAU,MAAM,MAAM;AAAA,EACpD,SAAS,IAAI;AACX,yBAAO,MAAM,+BAA+B,QAAQ,IAAI,EAAE;AAAA,EAC5D;AACF;AAEO,MAAM,iBAAiB,OAC5B,aAC2B;AAC3B,QAAM,eAAe,eAAe,QAAQ,QAAQ,CAAC;AACrD,MAAI,CAAC,aAAc,QAAO;AAC1B,MAAI;AACF,YAAQ,aAAa,MAAM;AAAA,MACzB,KAAK,OAAO;AACV,cAAM,WAAW,UAAM,sBAAU,aAAa,QAAQ;AACtD,cAAM,kBAAkB,SAAS,IAAI,gBAAU,6BAAgB,MAAM,CAAC;AACtE,eAAO;AAAA,MACT;AAAA,MACA,KAAK;AACH,eAAQ,UAAM,sBAAU,aAAa,QAAQ;AAAA,MAE/C,KAAK;AAAA,MACL;AACE,eAAO,aAAa;AAAA,IACxB;AAAA,EACF,SAAS,IAAI;AACX,yBAAO,MAAM,gCAAgC,aAAa,IAAI,IAAI,EAAE;AAAA,EACtE;AACF;",
|
|
6
6
|
"names": ["path", "fs"]
|
|
7
7
|
}
|
|
@@ -80,10 +80,9 @@ class ContensisAuthService {
|
|
|
80
80
|
};
|
|
81
81
|
BearerToken = async () => this.client.bearerToken || await this.client.ensureBearerToken();
|
|
82
82
|
RefreshToken = async () => !this.client.isRefreshTokenExpired() ? this.client.refreshToken : null;
|
|
83
|
+
/* PROJECTS */
|
|
83
84
|
ProjectId = () => this.client.clientConfig.projectId;
|
|
84
85
|
RootUrl = () => this.client.clientConfig.rootUrl;
|
|
85
86
|
}
|
|
86
87
|
var ContensisAuthService_default = ContensisAuthService;
|
|
87
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
-
0 && (module.exports = {});
|
|
89
88
|
//# sourceMappingURL=ContensisAuthService.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/ContensisAuthService.ts"],
|
|
4
4
|
"sourcesContent": ["import { NodejsClient } from 'contensis-management-api/lib/client';\nimport { ClientGrants, ClientGrantType } from 'contensis-core-api';\n\nclass ContensisAuthService {\n private client: NodejsClient;\n private credentials: {\n clientType: ClientGrantType;\n clientDetails: ClientGrants;\n };\n\n get clientType() {\n return this.credentials.clientType;\n }\n get clientDetails() {\n return this.credentials.clientDetails;\n }\n\n constructor({\n clientId = '',\n clientSecret = '',\n username,\n password,\n refreshToken,\n projectId,\n rootUrl,\n }: {\n clientId?: string;\n clientSecret?: string;\n username?: string;\n password?: string;\n refreshToken?: string;\n projectId: string;\n rootUrl: string;\n }) {\n if (clientId && clientSecret)\n this.credentials = {\n clientType: 'client_credentials',\n clientDetails: {\n clientId,\n clientSecret,\n },\n };\n else if (username && password)\n this.credentials = {\n clientType: 'contensis_classic',\n clientDetails: {\n username,\n password,\n },\n };\n else if (refreshToken)\n this.credentials = {\n clientType: 'contensis_classic_refresh_token',\n clientDetails: {\n refreshToken,\n },\n };\n else\n this.credentials = {\n clientType: 'none',\n clientDetails: { refreshToken: '' },\n };\n\n this.client = NodejsClient.create({\n ...this.credentials,\n projectId,\n rootUrl,\n });\n }\n\n ClassicToken = async (): Promise<string | null | undefined> => {\n // make sure our token isn't expried.\n await this.client.ensureBearerToken();\n return (this.client as any).contensisClassicToken;\n };\n BearerToken = async () =>\n this.client.bearerToken || (await this.client.ensureBearerToken());\n RefreshToken = async () =>\n !this.client.isRefreshTokenExpired() ? this.client.refreshToken : null;\n\n /* PROJECTS */\n ProjectId = () => this.client.clientConfig.projectId;\n RootUrl = () => this.client.clientConfig.rootUrl;\n}\n\nexport default ContensisAuthService;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAG7B,MAA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@ var __copyProps = (to2, from, except, desc) => {
|
|
|
18
18
|
return to2;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -88,9 +92,8 @@ class ContensisCli {
|
|
|
88
92
|
get env() {
|
|
89
93
|
const currentEnvironment = this.currentEnv;
|
|
90
94
|
const environments = this.cache.environments || {};
|
|
91
|
-
if (!currentEnvironment)
|
|
92
|
-
|
|
93
|
-
else if (!!environments[currentEnvironment])
|
|
95
|
+
if (!currentEnvironment) return {};
|
|
96
|
+
else if (environments[currentEnvironment])
|
|
94
97
|
return environments[currentEnvironment];
|
|
95
98
|
else {
|
|
96
99
|
return {
|
|
@@ -121,21 +124,16 @@ class ContensisCli {
|
|
|
121
124
|
const environments = this.cache.environments || {};
|
|
122
125
|
this.currentEnv = currentEnvironment;
|
|
123
126
|
const env = this.env;
|
|
124
|
-
if (outputOpts == null ? void 0 : outputOpts.projectId)
|
|
125
|
-
|
|
126
|
-
if (outputOpts == null ? void 0 : outputOpts.
|
|
127
|
-
|
|
128
|
-
if (outputOpts == null ? void 0 : outputOpts.password)
|
|
129
|
-
env.passwordFallback = outputOpts.password;
|
|
130
|
-
if (outputOpts == null ? void 0 : outputOpts.clientId)
|
|
131
|
-
env.lastUserId = outputOpts.clientId;
|
|
127
|
+
if (outputOpts == null ? void 0 : outputOpts.projectId) env.currentProject = outputOpts.projectId;
|
|
128
|
+
if (outputOpts == null ? void 0 : outputOpts.user) env.lastUserId = outputOpts.user;
|
|
129
|
+
if (outputOpts == null ? void 0 : outputOpts.password) env.passwordFallback = outputOpts.password;
|
|
130
|
+
if (outputOpts == null ? void 0 : outputOpts.clientId) env.lastUserId = outputOpts.clientId;
|
|
132
131
|
if (outputOpts == null ? void 0 : outputOpts.sharedSecret)
|
|
133
132
|
if (outputOpts.sharedSecret.startsWith("-"))
|
|
134
133
|
throw new Error(
|
|
135
134
|
`Shared secret option provided a value of ${outputOpts.sharedSecret}`
|
|
136
135
|
);
|
|
137
|
-
else
|
|
138
|
-
env.passwordFallback = outputOpts.sharedSecret;
|
|
136
|
+
else env.passwordFallback = outputOpts.sharedSecret;
|
|
139
137
|
this.currentProject = (env == null ? void 0 : env.currentProject) || "null";
|
|
140
138
|
this.sourceAlias = (outputOpts == null ? void 0 : outputOpts.sourceAlias) || currentEnvironment;
|
|
141
139
|
if (currentEnvironment) {
|
|
@@ -144,7 +142,7 @@ class ContensisCli {
|
|
|
144
142
|
this.command = {
|
|
145
143
|
commandText,
|
|
146
144
|
options: outputOpts,
|
|
147
|
-
createdDate: new Date().toISOString(),
|
|
145
|
+
createdDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
148
146
|
invokedBy: env == null ? void 0 : env.lastUserId
|
|
149
147
|
};
|
|
150
148
|
if (currentEnvironment) {
|
|
@@ -230,10 +228,8 @@ class ContensisCli {
|
|
|
230
228
|
);
|
|
231
229
|
}
|
|
232
230
|
} else {
|
|
233
|
-
if (!currentEnv)
|
|
234
|
-
|
|
235
|
-
if (!userId)
|
|
236
|
-
log.help(messages.connect.tip());
|
|
231
|
+
if (!currentEnv) log.help(messages.connect.help());
|
|
232
|
+
if (!userId) log.help(messages.connect.tip());
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
235
|
return this.contensis;
|
|
@@ -322,10 +318,8 @@ class ContensisCli {
|
|
|
322
318
|
}
|
|
323
319
|
}
|
|
324
320
|
} else {
|
|
325
|
-
if (!currentEnv)
|
|
326
|
-
|
|
327
|
-
if (!targetUserId)
|
|
328
|
-
log.help(messages.connect.tip());
|
|
321
|
+
if (!currentEnv) log.help(messages.connect.help());
|
|
322
|
+
if (!targetUserId) log.help(messages.connect.tip());
|
|
329
323
|
}
|
|
330
324
|
return this.contensis;
|
|
331
325
|
};
|
|
@@ -367,7 +361,7 @@ class ContensisCli {
|
|
|
367
361
|
let inputPassword = password || sharedSecret;
|
|
368
362
|
if (!inputPassword)
|
|
369
363
|
inputPassword = (0, import_util.isSharedSecret)(this.env.passwordFallback) || (0, import_util.isPassword)(this.env.passwordFallback) || "";
|
|
370
|
-
const {
|
|
364
|
+
const { messages } = this;
|
|
371
365
|
if (userId) {
|
|
372
366
|
const { currentEnv, env } = this;
|
|
373
367
|
if (currentEnv) {
|
|
@@ -401,10 +395,8 @@ class ContensisCli {
|
|
|
401
395
|
env.lastUserId = userId;
|
|
402
396
|
env.passwordFallback = credentials.remarks.secure !== true ? (_d = credentials.current) == null ? void 0 : _d.password : void 0;
|
|
403
397
|
this.session.UpdateEnv(env);
|
|
404
|
-
if (inputPassword)
|
|
405
|
-
|
|
406
|
-
if (sharedSecret)
|
|
407
|
-
await credentials.Save(sharedSecret);
|
|
398
|
+
if (inputPassword) await credentials.Save(inputPassword);
|
|
399
|
+
if (sharedSecret) await credentials.Save(sharedSecret);
|
|
408
400
|
if (!silent) {
|
|
409
401
|
import_logger.Logger.success(messages.login.success(currentEnv, userId));
|
|
410
402
|
await this.PrintProjects();
|
|
@@ -497,6 +489,7 @@ class ContensisCli {
|
|
|
497
489
|
try {
|
|
498
490
|
color = import_chalk.default.keyword(project.color);
|
|
499
491
|
} catch (ex) {
|
|
492
|
+
import_logger.Logger.debug(`${ex}`);
|
|
500
493
|
color = import_chalk.default.white;
|
|
501
494
|
}
|
|
502
495
|
console.log(
|
|
@@ -518,7 +511,7 @@ class ContensisCli {
|
|
|
518
511
|
}
|
|
519
512
|
};
|
|
520
513
|
PrintProject = async (projectId = this.currentProject) => {
|
|
521
|
-
const { log, messages
|
|
514
|
+
const { log, messages } = this;
|
|
522
515
|
const contensis = await this.ConnectContensis();
|
|
523
516
|
if (contensis) {
|
|
524
517
|
const [projectsErr, projects] = await (0, import_await_to_js.default)(
|
|
@@ -636,7 +629,7 @@ class ContensisCli {
|
|
|
636
629
|
const { currentEnv, log, messages } = this;
|
|
637
630
|
const contensis = await this.ConnectContensis({ commit: true });
|
|
638
631
|
if (contensis) {
|
|
639
|
-
const [err
|
|
632
|
+
const [err] = await contensis.apiKeys.RemoveKey(id);
|
|
640
633
|
if (!err) {
|
|
641
634
|
log.success(messages.keys.removed(currentEnv, id));
|
|
642
635
|
console.log("");
|
|
@@ -652,8 +645,7 @@ class ContensisCli {
|
|
|
652
645
|
const [rolesErr, roles] = await (0, import_await_to_js.default)(contensis.roles.GetRoles());
|
|
653
646
|
if (Array.isArray(roles)) {
|
|
654
647
|
log.success(messages.roles.list(currentEnv));
|
|
655
|
-
if (!roles.length)
|
|
656
|
-
log.help(messages.roles.noneExist());
|
|
648
|
+
if (!roles.length) log.help(messages.roles.noneExist());
|
|
657
649
|
await this.HandleFormattingAndOutput(roles, () => {
|
|
658
650
|
var _a, _b, _c, _d, _e;
|
|
659
651
|
for (const {
|
|
@@ -666,8 +658,7 @@ class ContensisCli {
|
|
|
666
658
|
} of roles) {
|
|
667
659
|
const color = enabled ? (s) => s : log.infoText;
|
|
668
660
|
console.log(color(` - ${import_chalk.default.bold(name)} ${log.infoText(id)}`));
|
|
669
|
-
if (description)
|
|
670
|
-
console.log(log.infoText(` ${description}`));
|
|
661
|
+
if (description) console.log(log.infoText(` ${description}`));
|
|
671
662
|
if (enabled === false)
|
|
672
663
|
console.log(` ${import_chalk.default.bold.grey("enabled")}: false`);
|
|
673
664
|
if ((_a = assignments.groups) == null ? void 0 : _a.length)
|
|
@@ -722,10 +713,8 @@ class ContensisCli {
|
|
|
722
713
|
if (Array.isArray(roles)) {
|
|
723
714
|
log.success(messages.roles.list(currentEnv));
|
|
724
715
|
const role = (0, import_find.findByIdOrName)(roles, roleNameOrId);
|
|
725
|
-
if (role)
|
|
726
|
-
|
|
727
|
-
else
|
|
728
|
-
log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
|
|
716
|
+
if (role) await this.HandleFormattingAndOutput(role, log.object);
|
|
717
|
+
else log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
|
|
729
718
|
}
|
|
730
719
|
if (rolesErr) {
|
|
731
720
|
log.error(messages.roles.noList(currentEnv));
|
|
@@ -798,8 +787,7 @@ class ContensisCli {
|
|
|
798
787
|
const [deleteErr] = await contensis.roles.RemoveRole(existingRole.id);
|
|
799
788
|
if (deleteErr)
|
|
800
789
|
log.error(messages.roles.failedRemove(currentEnv, roleNameOrId));
|
|
801
|
-
else
|
|
802
|
-
log.success(messages.roles.removed(currentEnv, roleNameOrId));
|
|
790
|
+
else log.success(messages.roles.removed(currentEnv, roleNameOrId));
|
|
803
791
|
} else {
|
|
804
792
|
log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
|
|
805
793
|
}
|
|
@@ -817,8 +805,7 @@ class ContensisCli {
|
|
|
817
805
|
const [workflowsErr, workflows] = await contensis.content.sourceRepo.workflows.GetWorkflows();
|
|
818
806
|
if (Array.isArray(workflows)) {
|
|
819
807
|
log.success(messages.workflows.list(currentEnv));
|
|
820
|
-
if (!workflows.length)
|
|
821
|
-
log.help(messages.workflows.noneExist());
|
|
808
|
+
if (!workflows.length) log.help(messages.workflows.noneExist());
|
|
822
809
|
const stringFromLanguageObject = (o) => {
|
|
823
810
|
var _a;
|
|
824
811
|
return (_a = Object.values(o || {})) == null ? void 0 : _a[0];
|
|
@@ -1031,25 +1018,20 @@ class ContensisCli {
|
|
|
1031
1018
|
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
1032
1019
|
}
|
|
1033
1020
|
const [migrateErr, result] = await contensis.MigrateContentModels();
|
|
1034
|
-
if (migrateErr)
|
|
1035
|
-
(0, import_logger.logError)(migrateErr);
|
|
1021
|
+
if (migrateErr) (0, import_logger.logError)(migrateErr);
|
|
1036
1022
|
else
|
|
1037
1023
|
await this.HandleFormattingAndOutput(result, () => {
|
|
1038
1024
|
if (!result.committed) {
|
|
1039
1025
|
log.raw(log.boldText(`
|
|
1040
1026
|
Content types:`));
|
|
1041
|
-
if (!result.contentTypes)
|
|
1042
|
-
log.info(`- None returned
|
|
1027
|
+
if (!result.contentTypes) log.info(`- None returned
|
|
1043
1028
|
`);
|
|
1044
|
-
else
|
|
1045
|
-
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
1029
|
+
else (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
1046
1030
|
log.raw(log.boldText(`
|
|
1047
1031
|
Components:`));
|
|
1048
|
-
if (!result.components)
|
|
1049
|
-
log.info(`- None returned
|
|
1032
|
+
if (!result.components) log.info(`- None returned
|
|
1050
1033
|
`);
|
|
1051
|
-
else
|
|
1052
|
-
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1034
|
+
else (0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1053
1035
|
if (result.defaults && Object.keys(result.defaults).length) {
|
|
1054
1036
|
log.raw(log.boldText(`
|
|
1055
1037
|
Defaults:`));
|
|
@@ -1156,6 +1138,7 @@ Nodes:`));
|
|
|
1156
1138
|
const contensis = await this.ConnectContensisImport({
|
|
1157
1139
|
commit,
|
|
1158
1140
|
importDataType: "user-input"
|
|
1141
|
+
// 'user-input' import type does not require a source cms
|
|
1159
1142
|
});
|
|
1160
1143
|
if (contensis) {
|
|
1161
1144
|
const [err, result] = await contensis.DeleteContentTypes(contentTypeIds);
|
|
@@ -1187,8 +1170,7 @@ Nodes:`));
|
|
|
1187
1170
|
let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
|
|
1188
1171
|
if (typeof fileData === "string")
|
|
1189
1172
|
throw new Error(`Import file format must be of type JSON`);
|
|
1190
|
-
if (!Array.isArray(fileData))
|
|
1191
|
-
fileData = [fileData];
|
|
1173
|
+
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
1192
1174
|
const contensis = await this.ConnectContensisImport({
|
|
1193
1175
|
commit,
|
|
1194
1176
|
importDataType: fromFile ? "user-input" : void 0
|
|
@@ -1198,9 +1180,8 @@ Nodes:`));
|
|
|
1198
1180
|
for (const contentType of fileData) {
|
|
1199
1181
|
contentType.projectId = currentProject;
|
|
1200
1182
|
delete contentType.uuid;
|
|
1201
|
-
const [err,
|
|
1202
|
-
if (err)
|
|
1203
|
-
log.error(err.message, err);
|
|
1183
|
+
const [err, , createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertContentType(false, contentType);
|
|
1184
|
+
if (err) log.error(err.message, err);
|
|
1204
1185
|
if (createStatus) {
|
|
1205
1186
|
log.success(
|
|
1206
1187
|
messages.contenttypes.created(
|
|
@@ -1229,8 +1210,7 @@ Nodes:`));
|
|
|
1229
1210
|
let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
|
|
1230
1211
|
if (typeof fileData === "string")
|
|
1231
1212
|
throw new Error(`Import file format must be of type JSON`);
|
|
1232
|
-
if (!Array.isArray(fileData))
|
|
1233
|
-
fileData = [fileData];
|
|
1213
|
+
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
1234
1214
|
const contensis = await this.ConnectContensisImport({
|
|
1235
1215
|
fromFile,
|
|
1236
1216
|
importDataType: "models"
|
|
@@ -1239,8 +1219,7 @@ Nodes:`));
|
|
|
1239
1219
|
const [err, result] = await (0, import_await_to_js.default)(
|
|
1240
1220
|
contensis.models.Diff(fileData.length ? fileData : modelIds)
|
|
1241
1221
|
);
|
|
1242
|
-
if (err)
|
|
1243
|
-
log.error(err.message, err);
|
|
1222
|
+
if (err) log.error(err.message, err);
|
|
1244
1223
|
if (result)
|
|
1245
1224
|
await this.HandleFormattingAndOutput(result, () => {
|
|
1246
1225
|
var _a;
|
|
@@ -1252,18 +1231,14 @@ Nodes:`));
|
|
|
1252
1231
|
);
|
|
1253
1232
|
if (result.committed === false) {
|
|
1254
1233
|
log.raw(log.boldText(`Content types:`));
|
|
1255
|
-
if (!result.contentTypes)
|
|
1256
|
-
log.info(`- None returned
|
|
1234
|
+
if (!result.contentTypes) log.info(`- None returned
|
|
1257
1235
|
`);
|
|
1258
|
-
else
|
|
1259
|
-
(0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
1236
|
+
else (0, import_console.printModelMigrationAnalysis)(this, result.contentTypes);
|
|
1260
1237
|
log.raw(log.boldText(`
|
|
1261
1238
|
Components:`));
|
|
1262
|
-
if (!result.components)
|
|
1263
|
-
log.info(`- None returned
|
|
1239
|
+
if (!result.components) log.info(`- None returned
|
|
1264
1240
|
`);
|
|
1265
|
-
else
|
|
1266
|
-
(0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1241
|
+
else (0, import_console.printModelMigrationAnalysis)(this, result.components);
|
|
1267
1242
|
}
|
|
1268
1243
|
});
|
|
1269
1244
|
}
|
|
@@ -1310,6 +1285,7 @@ Components:`));
|
|
|
1310
1285
|
const contensis = await this.ConnectContensisImport({
|
|
1311
1286
|
commit,
|
|
1312
1287
|
importDataType: "user-input"
|
|
1288
|
+
// 'user-input' import type does not require a source cms
|
|
1313
1289
|
});
|
|
1314
1290
|
if (contensis) {
|
|
1315
1291
|
const [err, result] = await contensis.DeleteContentTypes(
|
|
@@ -1344,8 +1320,7 @@ Components:`));
|
|
|
1344
1320
|
let fileData = fromFile ? await (0, import_file_provider.readFileAsJSON)(fromFile) || [] : [];
|
|
1345
1321
|
if (typeof fileData === "string")
|
|
1346
1322
|
throw new Error(`Import file format must be of type JSON`);
|
|
1347
|
-
if (!Array.isArray(fileData))
|
|
1348
|
-
fileData = [fileData];
|
|
1323
|
+
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
1349
1324
|
const contensis = await this.ConnectContensisImport({
|
|
1350
1325
|
commit,
|
|
1351
1326
|
importDataType: fromFile ? "user-input" : void 0
|
|
@@ -1355,9 +1330,8 @@ Components:`));
|
|
|
1355
1330
|
for (const component of fileData) {
|
|
1356
1331
|
component.projectId = currentProject;
|
|
1357
1332
|
delete component.uuid;
|
|
1358
|
-
const [err,
|
|
1359
|
-
if (err)
|
|
1360
|
-
log.error(err.message, err);
|
|
1333
|
+
const [err, , createStatus] = await contensis.models.targetRepos[currentProject].repo.UpsertComponent(false, component);
|
|
1334
|
+
if (err) log.error(err.message, err);
|
|
1361
1335
|
if (createStatus) {
|
|
1362
1336
|
log.success(
|
|
1363
1337
|
messages.components.created(
|
|
@@ -1385,6 +1359,7 @@ Components:`));
|
|
|
1385
1359
|
const contensis = await this.ConnectContensisImport({
|
|
1386
1360
|
commit,
|
|
1387
1361
|
importDataType: "user-input"
|
|
1362
|
+
// 'user-input' import type does not require a source cms
|
|
1388
1363
|
});
|
|
1389
1364
|
if (contensis) {
|
|
1390
1365
|
if (contensis.isPreview) {
|
|
@@ -1421,17 +1396,22 @@ Components:`));
|
|
|
1421
1396
|
if (contensis) {
|
|
1422
1397
|
log.line();
|
|
1423
1398
|
const entries = await contensis.GetEntries({ withDependents });
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1399
|
+
const nodes = contensis.content.source.nodes.raw;
|
|
1400
|
+
const combinedOutput = [...entries, ...nodes];
|
|
1401
|
+
await this.HandleFormattingAndOutput(combinedOutput, () => {
|
|
1402
|
+
var _a, _b;
|
|
1403
|
+
(0, import_migratortron.logEntitiesTable)({
|
|
1404
|
+
entries,
|
|
1405
|
+
projectId: currentProject,
|
|
1406
|
+
fields: (_a = contensis.payload.query) == null ? void 0 : _a.fields
|
|
1407
|
+
});
|
|
1408
|
+
if (nodes.length)
|
|
1409
|
+
(0, import_migratortron.logEntitiesTable)({
|
|
1410
|
+
nodes,
|
|
1430
1411
|
projectId: currentProject,
|
|
1431
|
-
fields: (
|
|
1412
|
+
fields: (_b = contensis.payload.query) == null ? void 0 : _b.fields
|
|
1432
1413
|
});
|
|
1433
|
-
|
|
1434
|
-
);
|
|
1414
|
+
});
|
|
1435
1415
|
} else {
|
|
1436
1416
|
log.warning(messages.models.noList(currentProject));
|
|
1437
1417
|
log.help(messages.connect.tip());
|
|
@@ -1458,11 +1438,16 @@ Components:`));
|
|
|
1458
1438
|
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
1459
1439
|
}
|
|
1460
1440
|
const [err, result] = await contensis.MigrateEntries();
|
|
1461
|
-
if (err)
|
|
1462
|
-
(0, import_logger.logError)(err);
|
|
1441
|
+
if (err) (0, import_logger.logError)(err);
|
|
1463
1442
|
else {
|
|
1464
1443
|
const { entries, nodes } = contensis.content.targets[currentProject];
|
|
1465
|
-
const output = saveEntries ? (
|
|
1444
|
+
const output = saveEntries ? (
|
|
1445
|
+
// include entries and dependent nodes when saving entries
|
|
1446
|
+
[
|
|
1447
|
+
((_a = entries.migrate) == null ? void 0 : _a.map((me) => me.toJSON())) || [],
|
|
1448
|
+
nodes.migrateNodes.map((mn) => mn.node)
|
|
1449
|
+
].flat()
|
|
1450
|
+
) : result;
|
|
1466
1451
|
await this.HandleFormattingAndOutput(output, () => {
|
|
1467
1452
|
(0, import_console.printEntriesMigrateResult)(this, result, {
|
|
1468
1453
|
showAll: logOutput === "all",
|
|
@@ -1527,8 +1512,7 @@ Components:`));
|
|
|
1527
1512
|
const [err, result] = await (0, import_await_to_js.default)(
|
|
1528
1513
|
contensis.content.copy.MigrateFieldContent()
|
|
1529
1514
|
);
|
|
1530
|
-
if (err)
|
|
1531
|
-
(0, import_logger.logError)(err);
|
|
1515
|
+
if (err) (0, import_logger.logError)(err);
|
|
1532
1516
|
if (result) {
|
|
1533
1517
|
const output = saveEntries ? (_a = contensis.content.copy.targets[currentProject].entries.migrate) == null ? void 0 : _a.map(
|
|
1534
1518
|
(me) => me.toJSON()
|
|
@@ -1605,8 +1589,7 @@ Components:`));
|
|
|
1605
1589
|
console.log(log.warningText(` *** COMMITTING IMPORT *** `));
|
|
1606
1590
|
}
|
|
1607
1591
|
const [err, result] = await contensis.MigrateNodes();
|
|
1608
|
-
if (err)
|
|
1609
|
-
log.raw(``);
|
|
1592
|
+
if (err) log.raw(``);
|
|
1610
1593
|
else
|
|
1611
1594
|
await this.HandleFormattingAndOutput(result, () => {
|
|
1612
1595
|
const migrateTree = contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView;
|
|
@@ -1624,8 +1607,8 @@ Components:`));
|
|
|
1624
1607
|
if (!err && (!((_f = result.errors) == null ? void 0 : _f.length) || this.contensisOpts.ignoreErrors) && (!commit && nodesMigrateCount || commit && (nodesCreated || nodesUpdated || ((_g = result.errors) == null ? void 0 : _g.length)))) {
|
|
1625
1608
|
let totalCount;
|
|
1626
1609
|
if (commit) {
|
|
1627
|
-
|
|
1628
|
-
|
|
1610
|
+
const created = typeof nodesCreated === "number" ? nodesCreated : 0;
|
|
1611
|
+
const updated = typeof nodesUpdated === "number" ? nodesUpdated : 0;
|
|
1629
1612
|
totalCount = created + updated;
|
|
1630
1613
|
} else {
|
|
1631
1614
|
totalCount = typeof nodesMigrateCount === "number" ? nodesMigrateCount : 0;
|
|
@@ -1640,8 +1623,7 @@ Components:`));
|
|
|
1640
1623
|
log.help(messages.nodes.noChange(currentEnv));
|
|
1641
1624
|
} else {
|
|
1642
1625
|
log.error(messages.nodes.failedImport(currentEnv), err);
|
|
1643
|
-
if (!nodesMigrateCount)
|
|
1644
|
-
log.help(messages.nodes.notFound(currentEnv));
|
|
1626
|
+
if (!nodesMigrateCount) log.help(messages.nodes.notFound(currentEnv));
|
|
1645
1627
|
}
|
|
1646
1628
|
}
|
|
1647
1629
|
} else {
|
|
@@ -1655,6 +1637,7 @@ Components:`));
|
|
|
1655
1637
|
const contensis = await this.ConnectContensisImport({
|
|
1656
1638
|
commit,
|
|
1657
1639
|
importDataType: "user-input"
|
|
1640
|
+
// 'user-input' import type does not require a source cms
|
|
1658
1641
|
});
|
|
1659
1642
|
if (contensis) {
|
|
1660
1643
|
if (contensis.isPreview) {
|
|
@@ -1703,8 +1686,7 @@ Components:`));
|
|
|
1703
1686
|
) : webhooks;
|
|
1704
1687
|
if (Array.isArray(filteredResults)) {
|
|
1705
1688
|
log.success(messages.webhooks.list(currentEnv));
|
|
1706
|
-
if (!(webhooks == null ? void 0 : webhooks.length))
|
|
1707
|
-
log.warning(messages.webhooks.noneExist());
|
|
1689
|
+
if (!(webhooks == null ? void 0 : webhooks.length)) log.warning(messages.webhooks.noneExist());
|
|
1708
1690
|
else {
|
|
1709
1691
|
await this.HandleFormattingAndOutput(filteredResults, () => {
|
|
1710
1692
|
for (const {
|
|
@@ -1724,8 +1706,7 @@ Components:`));
|
|
|
1724
1706
|
` ${import_chalk.default.bold.white`- ${name}`} ${id} [${(version.modified || version.created).toString().substring(0, 10)} ${version.modifiedBy || version.createdBy}]`
|
|
1725
1707
|
)
|
|
1726
1708
|
);
|
|
1727
|
-
if (description)
|
|
1728
|
-
console.log(log.infoText` ${description}`);
|
|
1709
|
+
if (description) console.log(log.infoText` ${description}`);
|
|
1729
1710
|
console.log(` ${log.infoText`[${method}]`} ${url2}`);
|
|
1730
1711
|
if (headers && Object.keys(headers).length) {
|
|
1731
1712
|
console.log(` ${log.infoText`headers`}:`);
|
|
@@ -1853,9 +1834,7 @@ Components:`));
|
|
|
1853
1834
|
console.log((0, import_json.jsonFormatter)(block));
|
|
1854
1835
|
const contensis = await this.ConnectContensis();
|
|
1855
1836
|
if (contensis) {
|
|
1856
|
-
const [err, blockVersion] = await contensis.blocks.PushBlockVersion(
|
|
1857
|
-
block
|
|
1858
|
-
);
|
|
1837
|
+
const [err, blockVersion] = await contensis.blocks.PushBlockVersion(block);
|
|
1859
1838
|
if (!err) {
|
|
1860
1839
|
log.success(
|
|
1861
1840
|
messages.blocks.pushed(
|
|
@@ -1893,8 +1872,7 @@ Components:`));
|
|
|
1893
1872
|
blockVersionNo = `${(_a = blockVersions == null ? void 0 : blockVersions[0]) == null ? void 0 : _a.version.versionNo}`;
|
|
1894
1873
|
if (!Number.isNaN(blockVersionNo) && Number(blockVersionNo) > 0)
|
|
1895
1874
|
return [null, blockVersionNo];
|
|
1896
|
-
else
|
|
1897
|
-
throw new Error(`'${blockVersionNo}' is not a valid version number`);
|
|
1875
|
+
else throw new Error(`'${blockVersionNo}' is not a valid version number`);
|
|
1898
1876
|
} catch (parseVersionEx) {
|
|
1899
1877
|
log.info(
|
|
1900
1878
|
`Request for blockId: ${blockId}, branch: ${branch}, version: latest`
|
|
@@ -1912,9 +1890,7 @@ Components:`));
|
|
|
1912
1890
|
if (contensis) {
|
|
1913
1891
|
let actionOnBlockVersion = version;
|
|
1914
1892
|
if (action === "release" && version === "latest") {
|
|
1915
|
-
const [getErr, blockVersion2] = await this.GetLatestBlockVersion(
|
|
1916
|
-
blockId
|
|
1917
|
-
);
|
|
1893
|
+
const [getErr, blockVersion2] = await this.GetLatestBlockVersion(blockId);
|
|
1918
1894
|
if (getErr) {
|
|
1919
1895
|
throw new Error(
|
|
1920
1896
|
`${messages.blocks.noList(
|
|
@@ -1997,7 +1973,7 @@ Components:`));
|
|
|
1997
1973
|
);
|
|
1998
1974
|
stopFollowing();
|
|
1999
1975
|
});
|
|
2000
|
-
|
|
1976
|
+
const delay = (0, import_timers.promiseDelay)(5 * 1e3, null);
|
|
2001
1977
|
const stopFollowing = () => {
|
|
2002
1978
|
following = false;
|
|
2003
1979
|
delay.cancel();
|
|
@@ -2078,6 +2054,7 @@ Components:`));
|
|
|
2078
2054
|
}
|
|
2079
2055
|
}
|
|
2080
2056
|
};
|
|
2057
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2081
2058
|
PrintRenderers = async (rendererId) => {
|
|
2082
2059
|
const { currentEnv, env, log, messages } = this;
|
|
2083
2060
|
const contensis = await this.ConnectContensis();
|