@rockcarver/frodo-cli 2.0.0-40 → 2.0.0-41
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/CHANGELOG.md +5 -1
- package/esm/cli/config/config-import.js +37 -4
- package/esm/cli/config/config-import.js.map +1 -1
- package/esm/cli/config/config.js +1 -2
- package/esm/cli/config/config.js.map +1 -1
- package/esm/cli/idp/idp-import.js +13 -5
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/saml/saml-import.js +13 -5
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/service/service-import.js +22 -5
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/ops/ApplicationOps.js +1 -1
- package/esm/ops/ApplicationOps.js.map +1 -1
- package/esm/ops/ConfigOps.js +35 -3
- package/esm/ops/ConfigOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +12 -17
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +41 -91
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +20 -8
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +2 -2
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +20 -8
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ServiceOps.js +30 -14
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +16 -23
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/utils/Config.js +11 -2
- package/esm/utils/Config.js.map +1 -1
- package/package.json +2 -2
package/esm/ops/Saml2Ops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","decodeBase64","saveTextToFile","getFilePath","getWorkingDirectory","utils","getTypedFilename","saveJsonToFile","getRealmString","validateImport","readSaml2ProviderStubs","readSaml2Provider","readSaml2ProviderStub","getSaml2ProviderMetadataUrl","getSaml2ProviderMetadata","exportSaml2Provider","exportSaml2Providers","importSaml2Provider","importSaml2Providers","saml2","entityProvider","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","filePath","indicatorId","metaData","brightCyan","exportSaml2ProviderToFile","includeMeta","fileData","err","exportSaml2ProvidersToFile","exportData","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","data","readFileSync","JSON","parse","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","importSaml2ProvidersFromFile","meta","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","result"],"sources":["../../src/ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { type Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/Saml2Api';\nimport { type Saml2ExportInterface } from '@rockcarver/frodo-lib/types/ops/Saml2Ops';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst { decodeBase64, saveTextToFile, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst { getTypedFilename, saveJsonToFile, getRealmString, validateImport } =\n frodo.utils;\nconst {\n readSaml2ProviderStubs,\n readSaml2Provider,\n readSaml2ProviderStub,\n getSaml2ProviderMetadataUrl,\n getSaml2ProviderMetadata,\n exportSaml2Provider,\n exportSaml2Providers,\n importSaml2Provider,\n importSaml2Providers,\n} = frodo.saml2.entityProvider;\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await readSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await readSaml2ProviderStub(entityId);\n const { location } = stub;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await readSaml2Provider(entityId);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getSaml2ProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString(), 'data');\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n if (!file) {\n file = getTypedFilename(entityId, 'metadata', 'xml');\n }\n const filePath = getFilePath(file, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting metadata for: ${entityId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const metaData = await getSaml2ProviderMetadata(entityId);\n saveTextToFile(metaData, filePath);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} metadata to ${filePath.brightCyan}.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProviderToFile(\n entityId,\n file = null,\n includeMeta = true\n) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n if (!file) {\n file = getTypedFilename(entityId, 'saml');\n }\n const filePath = getFilePath(file, true);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting provider ${entityId}`\n );\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, filePath, includeMeta);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} to ${filePath.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${filePath}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFile(\n file = null,\n includeMeta = true\n) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, getFilePath(file, true), includeMeta);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFiles(includeMeta = true) {\n const stubs = await readSaml2ProviderStubs();\n if (stubs.length > 0) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n stubs.length,\n 'Exporting providers'\n );\n for (const stub of stubs) {\n const file = getFilePath(getTypedFilename(stub.entityId, 'saml'), true);\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, file, includeMeta);\n updateProgressIndicator(\n indicatorId,\n `Exported provider ${stub.entityId}`\n );\n }\n stopProgressIndicator(indicatorId, `${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(\n `Error importing saml2 provider ${entityId}: ${error}`,\n 'error'\n );\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file: string) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = decodeBase64(entityId64);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(`Error importing first saml2 provider: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(file: string) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n } catch (error) {\n printMessage(`Error importing saml2 providers: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.saml.json'))\n .map((name) => getFilePath(name));\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of jsonFiles) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const result = await importSaml2Providers(fileData);\n total += result.length;\n updateProgressIndicator(\n indicatorId,\n `Imported ${result.length} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n } catch (error) {\n printMessage(\n `Error importing providers from ${file}: ${error.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Imported ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAG7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EAAEC,YAAY;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GACtEZ,KAAK,CAACa,KAAK;AACb,MAAM;EAAEC,gBAAgB;EAAEC,cAAc;EAAEC,cAAc;EAAEC;AAAe,CAAC,GACxEjB,KAAK,CAACa,KAAK;AACb,MAAM;EACJK,sBAAsB;EACtBC,iBAAiB;EACjBC,qBAAqB;EACrBC,2BAA2B;EAC3BC,wBAAwB;EACxBC,mBAAmB;E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oC,MAAM,CAAClE,MAAO,qBAAoB4B,IAAK,GACrD,CAAC;MACH,CAAC,MAAM;QACLnE,YAAY,CAAE,iBAAgBmE,IAAK,UAAS,EAAE,OAAO,CAAC;MACxD;IACF,CAAC,CAAC,OAAOH,KAAK,EAAE;MACdhE,YAAY,CACT,kCAAiCmE,IAAK,KAAIH,KAAK,CAACC,OAAQ,EAAC,EAC1D,OACF,CAAC;IACH;EACF;EACAhE,qBAAqB,CACnBoE,WAAW,EACV,YAAWmC,KAAM,qBAAoBL,SAAS,CAAC5D,MAAO,WACzD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"Saml2Ops.js","names":["frodo","fs","createObjectTable","createProgressIndicator","createTable","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","decodeBase64","saveTextToFile","getFilePath","getWorkingDirectory","utils","getTypedFilename","saveJsonToFile","getRealmString","validateImport","readSaml2ProviderStubs","readSaml2Provider","readSaml2ProviderStub","getSaml2ProviderMetadataUrl","getSaml2ProviderMetadata","exportSaml2Provider","exportSaml2Providers","importSaml2Provider","importSaml2Providers","saml2","entityProvider","roleMap","identityProvider","serviceProvider","attributeQueryProvider","xacmlPolicyEnforcementPoint","getOneLineDescription","saml2ProviderObj","roles","key","value","Object","entries","push","description","entityId","entityLocation","length","join","getTableHeaderMd","markdown","getTableRowMd","row","listSaml2Providers","long","providerList","sort","a","b","_id","localeCompare","provider","table","location","map","role","toString","describeSaml2Provider","stub","rawProviderData","_rev","metadataUrl","error","message","exportSaml2MetadataToFile","file","filePath","indicatorId","metaData","brightCyan","exportSaml2ProviderToFile","includeMeta","fileData","err","exportSaml2ProvidersToFile","exportData","_error$response","response","status","exportSaml2ProvidersToFiles","stubs","importSaml2ProviderFromFile","options","deps","data","readFileSync","JSON","parse","importFirstSaml2ProviderFromFile","entityId64","keys","saml","remote","hosted","importSaml2ProvidersFromFile","meta","importSaml2ProvidersFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","result"],"sources":["../../src/ops/Saml2Ops.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { type Saml2ProviderSkeleton } from '@rockcarver/frodo-lib/types/api/Saml2Api';\nimport {\n type Saml2ExportInterface,\n type Saml2ProviderImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/Saml2Ops';\nimport fs from 'fs';\n\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst { decodeBase64, saveTextToFile, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst { getTypedFilename, saveJsonToFile, getRealmString, validateImport } =\n frodo.utils;\nconst {\n readSaml2ProviderStubs,\n readSaml2Provider,\n readSaml2ProviderStub,\n getSaml2ProviderMetadataUrl,\n getSaml2ProviderMetadata,\n exportSaml2Provider,\n exportSaml2Providers,\n importSaml2Provider,\n importSaml2Providers,\n} = frodo.saml2.entityProvider;\n\nconst roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n/**\n * Get a one-line description of the saml2 provider object\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(\n saml2ProviderObj: Saml2ProviderSkeleton\n): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const description = `[${saml2ProviderObj.entityId['brightCyan']}]${\n ' (' + saml2ProviderObj.entityLocation\n }${roles.length ? ' ' + roles.join(', ') + ')' : ')'}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Entity Id | Location | Role(s) |\\n';\n markdown += '| --------- | -------- | ------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the saml2 provider in markdown\n * @param {Saml2ProviderSkeleton} saml2ProviderObj saml2 provider object to describe\n * @returns {string} a table-row of the saml2 provider in markdown\n */\nexport function getTableRowMd(saml2ProviderObj: Saml2ProviderSkeleton): string {\n const roles: string[] = [];\n for (const [key, value] of Object.entries(roleMap)) {\n if (saml2ProviderObj[key]) {\n roles.push(value);\n }\n }\n const row = `| ${saml2ProviderObj.entityId} | ${\n saml2ProviderObj.entityLocation\n } | ${roles.length ? roles.join(', ') : ''} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = await readSaml2ProviderStubs();\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const stub = await readSaml2ProviderStub(entityId);\n const { location } = stub;\n const roles = stub.roles.map((role: string) => roleMap[role]).join(', ');\n const rawProviderData = await readSaml2Provider(entityId);\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getSaml2ProviderMetadataUrl(entityId);\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString(), 'data');\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2MetadataToFile(entityId, file = null) {\n if (!file) {\n file = getTypedFilename(entityId, 'metadata', 'xml');\n }\n const filePath = getFilePath(file, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting metadata for: ${entityId}`\n );\n try {\n updateProgressIndicator(indicatorId, `Writing file ${filePath}`);\n const metaData = await getSaml2ProviderMetadata(entityId);\n saveTextToFile(metaData, filePath);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} metadata to ${filePath.brightCyan}.`\n );\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error}`);\n printMessage(error, 'error');\n }\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProviderToFile(\n entityId,\n file = null,\n includeMeta = true\n) {\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: start [entityId=${entityId}, file=${file}]`\n );\n if (!file) {\n file = getTypedFilename(entityId, 'saml');\n }\n const filePath = getFilePath(file, true);\n let indicatorId: string;\n try {\n indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting provider ${entityId}`\n );\n const fileData = await exportSaml2Provider(entityId);\n saveJsonToFile(fileData, filePath, includeMeta);\n updateProgressIndicator(indicatorId, `Exported provider ${entityId}`);\n stopProgressIndicator(\n indicatorId,\n // @ts-expect-error - brightCyan colors the string, even though it is not a property of string\n `Exported ${entityId.brightCyan} to ${filePath.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(indicatorId, `${err}`);\n printMessage(err, 'error');\n }\n debugMessage(\n `cli.Saml2Ops.exportSaml2ProviderToFile: end [entityId=${entityId}, file=${filePath}]`\n );\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFile(\n file = null,\n includeMeta = true\n) {\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: start [file=${file}]`);\n if (!file) {\n file = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const exportData = await exportSaml2Providers();\n saveJsonToFile(exportData, getFilePath(file, true), includeMeta);\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportSaml2ProvidersToFile: ${error.response?.status}`,\n 'error'\n );\n }\n debugMessage(`cli.Saml2Ops.exportSaml2ProviderToFile: end [file=${file}]`);\n}\n\n/**\n * Export all entity providers to individual files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportSaml2ProvidersToFiles(includeMeta = true) {\n const stubs = await readSaml2ProviderStubs();\n if (stubs.length > 0) {\n const indicatorId = createProgressIndicator(\n 'determinate',\n stubs.length,\n 'Exporting providers'\n );\n for (const stub of stubs) {\n const file = getFilePath(getTypedFilename(stub.entityId, 'saml'), true);\n const fileData = await exportSaml2Provider(stub.entityId);\n saveJsonToFile(fileData, file, includeMeta);\n updateProgressIndicator(\n indicatorId,\n `Exported provider ${stub.entityId}`\n );\n }\n stopProgressIndicator(indicatorId, `${stubs.length} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProviderFromFile(\n entityId: string,\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(\n `Error importing saml2 provider ${entityId}: ${error}`,\n 'error'\n );\n }\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importFirstSaml2ProviderFromFile(\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data) as Saml2ExportInterface;\n // pick the first provider and run with it\n const entityId64 =\n Object.keys(fileData.saml.remote)[0] ||\n Object.keys(fileData.saml.hosted)[0];\n const entityId = decodeBase64(entityId64);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing ${entityId}...`\n );\n try {\n await importSaml2Provider(entityId, fileData, options);\n stopProgressIndicator(indicatorId, `Imported ${entityId}.`, 'success');\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${entityId}: ${error.message}`,\n 'fail'\n );\n }\n } catch (error) {\n printMessage(`Error importing first saml2 provider: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFile(\n file: string,\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n await importSaml2Providers(fileData, options);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n } catch (error) {\n printMessage(`Error importing saml2 providers: ${error}`, 'error');\n }\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n * @param {Saml2ProviderImportOptions} options import options\n */\nexport async function importSaml2ProvidersFromFiles(\n options: Saml2ProviderImportOptions = { deps: true }\n) {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.saml.json'))\n .map((name) => getFilePath(name));\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing providers...'\n );\n let total = 0;\n for (const file of jsonFiles) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const result = await importSaml2Providers(fileData, options);\n total += result.length;\n updateProgressIndicator(\n indicatorId,\n `Imported ${result.length} provider(s) from ${file}.`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n } catch (error) {\n printMessage(\n `Error importing providers from ${file}: ${error.message}`,\n 'error'\n );\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Imported ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAM7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,uBAAuB,EACvBC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,QAClB,kBAAkB;AAEzB,MAAM;EAAEC,YAAY;EAAEC,cAAc;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GACtEZ,KAAK,CAACa,KAAK;AACb,MAAM;EAAEC,gBAAgB;EAAEC,cAAc;EAAEC,cAAc;EAAEC;AAAe,CAAC,GACxEjB,KAAK,CAACa,KAAK;AACb,MAAM;EACJK,sBAAsB;EACtBC,iBAAiB;EACjBC,qBAAqB;EACrBC,2BAA2B;EAC3BC,wBAAwB;EACxBC,mBAAmB;EACnBC,oBAAoB;EACpBC,mBAAmB;EACnBC;AACF,CAAC,GAAG1B,KAAK,CAAC2B,KAAK,CAACC,cAAc;AAE9B,MAAMC,OAAO,GAAG;EACdC,gBAAgB,EAAE,KAAK;EACvBC,eAAe,EAAE,IAAI;EACrBC,sBAAsB,EAAE,WAAW;EACnCC,2BAA2B,EAAE;AAC/B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,gBAAuC,EAC/B;EACR,MAAMC,KAAe,GAAG,EAAE;EAC1B,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACX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AAC,OAAOH,KAAK,EAAE;MACdhE,YAAY,CACT,kCAAiCmE,IAAK,KAAIH,KAAK,CAACC,OAAQ,EAAC,EAC1D,OACF,CAAC;IACH;EACF;EACAhE,qBAAqB,CACnBoE,WAAW,EACV,YAAWqC,KAAM,qBAAoBL,SAAS,CAAC9D,MAAO,WACzD,CAAC;AACH"}
|
package/esm/ops/ServiceOps.js
CHANGED
|
@@ -96,9 +96,13 @@ export async function exportServicesToFiles(globalConfig = false, includeMeta =
|
|
|
96
96
|
* Import a service from file
|
|
97
97
|
* @param {string} serviceId service id/name
|
|
98
98
|
* @param {string} file import file name
|
|
99
|
-
* @param {
|
|
99
|
+
* @param {ServiceImportOptions} options import options
|
|
100
100
|
*/
|
|
101
|
-
export async function importServiceFromFile(serviceId, file,
|
|
101
|
+
export async function importServiceFromFile(serviceId, file, options = {
|
|
102
|
+
clean: false,
|
|
103
|
+
global: false,
|
|
104
|
+
realm: false
|
|
105
|
+
}) {
|
|
102
106
|
const filePath = getFilePath(file);
|
|
103
107
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${filePath}]`);
|
|
104
108
|
const verbose = state.getVerbose();
|
|
@@ -109,7 +113,7 @@ export async function importServiceFromFile(serviceId, file, clean, globalConfig
|
|
|
109
113
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
110
114
|
try {
|
|
111
115
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
112
|
-
await importService(serviceId, importData,
|
|
116
|
+
await importService(serviceId, importData, options);
|
|
113
117
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
114
118
|
} catch (importError) {
|
|
115
119
|
var _importError$response, _importError$response2;
|
|
@@ -129,9 +133,13 @@ export async function importServiceFromFile(serviceId, file, clean, globalConfig
|
|
|
129
133
|
/**
|
|
130
134
|
* Import first service from file
|
|
131
135
|
* @param {string} file import file name
|
|
132
|
-
* @param {
|
|
136
|
+
* @param {ServiceImportOptions} options import options
|
|
133
137
|
*/
|
|
134
|
-
export async function importFirstServiceFromFile(file,
|
|
138
|
+
export async function importFirstServiceFromFile(file, options = {
|
|
139
|
+
clean: false,
|
|
140
|
+
global: false,
|
|
141
|
+
realm: false
|
|
142
|
+
}) {
|
|
135
143
|
const filePath = getFilePath(file);
|
|
136
144
|
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start [file=${filePath}]`);
|
|
137
145
|
const verbose = state.getVerbose();
|
|
@@ -143,7 +151,7 @@ export async function importFirstServiceFromFile(file, clean, globalConfig = fal
|
|
|
143
151
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
144
152
|
try {
|
|
145
153
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
146
|
-
await importService(serviceId, importData,
|
|
154
|
+
await importService(serviceId, importData, options);
|
|
147
155
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
148
156
|
} catch (importError) {
|
|
149
157
|
var _importError$response3, _importError$response4;
|
|
@@ -163,9 +171,13 @@ export async function importFirstServiceFromFile(file, clean, globalConfig = fal
|
|
|
163
171
|
/**
|
|
164
172
|
* Import services from file
|
|
165
173
|
* @param {String} file file name
|
|
166
|
-
* @param {
|
|
174
|
+
* @param {ServiceImportOptions} options import options
|
|
167
175
|
*/
|
|
168
|
-
export async function importServicesFromFile(file,
|
|
176
|
+
export async function importServicesFromFile(file, options = {
|
|
177
|
+
clean: false,
|
|
178
|
+
global: false,
|
|
179
|
+
realm: false
|
|
180
|
+
}) {
|
|
169
181
|
const filePath = getFilePath(file);
|
|
170
182
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${filePath}]`);
|
|
171
183
|
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
@@ -173,7 +185,7 @@ export async function importServicesFromFile(file, clean, globalConfig = false)
|
|
|
173
185
|
debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${filePath}`);
|
|
174
186
|
const importData = JSON.parse(data);
|
|
175
187
|
try {
|
|
176
|
-
await importServices(importData,
|
|
188
|
+
await importServices(importData, options);
|
|
177
189
|
} catch (error) {
|
|
178
190
|
printMessage(`${error.message}`, 'error');
|
|
179
191
|
printMessage(error.response.status, 'error');
|
|
@@ -184,14 +196,18 @@ export async function importServicesFromFile(file, clean, globalConfig = false)
|
|
|
184
196
|
|
|
185
197
|
/**
|
|
186
198
|
* Import all services from separate files
|
|
187
|
-
* @param {
|
|
199
|
+
* @param {ServiceImportOptions} options import options
|
|
188
200
|
*/
|
|
189
|
-
export async function importServicesFromFiles(
|
|
201
|
+
export async function importServicesFromFiles(options = {
|
|
202
|
+
clean: false,
|
|
203
|
+
global: false,
|
|
204
|
+
realm: false
|
|
205
|
+
}) {
|
|
190
206
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);
|
|
191
207
|
const names = fs.readdirSync(getWorkingDirectory());
|
|
192
|
-
const
|
|
193
|
-
for (const file of
|
|
194
|
-
await importServicesFromFile(file,
|
|
208
|
+
const serviceFiles = names.filter(name => name.toLowerCase().endsWith('.service.json'));
|
|
209
|
+
for (const file of serviceFiles) {
|
|
210
|
+
await importServicesFromFile(file, options);
|
|
195
211
|
}
|
|
196
212
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);
|
|
197
213
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOps.js","names":["frodo","state","fs","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","stack","exportServicesToFile","file","includeMeta","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","filePath","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","_importError$response","_importError$response2","message","response","detail","importFirstServiceFromFile","Object","keys","length","_importError$response3","_importError$response4","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","map","deleteService","_error$response","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([\n service._id,\n globalConfig ? service['_type'].name : service.name,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServicesToFile(\n file,\n globalConfig = false,\n includeMeta = true\n) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false,\n includeMeta = true\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n}\n\n/**\n * Export all services to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServicesToFiles(\n globalConfig = false,\n includeMeta = true\n) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const filePath = getFilePath(fileName, true);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${filePath}`\n );\n saveJsonToFile(exportData, filePath, includeMeta);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${filePath}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${filePath}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${filePath}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${filePath}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${filePath}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [file=${filePath}]`\n );\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${filePath}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean, globalConfig);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [file=${filePath}]`\n );\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names\n .filter((name) => name.toLowerCase().endsWith('.service.json'))\n .map((name) => getFilePath(name));\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean, globalConfig);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGd,KAAK,CAACe,KAAK;AACf,MAAM;EACJC,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAGxB,KAAK,CAACyB,OAAO;;AAEjB;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,IAAI,GAAG,KAAK,EAAEC,YAAY,GAAG,KAAK,EAAE;EACrE,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,CAACY,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EA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AO,IAAAoB,eAAA,GAAG9C,KAAK,CAAC2B,QAAQ,cAAAmB,eAAA,gBAAAA,eAAA,GAAdA,eAAA,CAAgB3B,IAAI,cAAA2B,eAAA,uBAApBA,eAAA,CAAsBpB,OAAO;IAC7C3D,YAAY,CAAE,mBAAkB0C,SAAU,MAAKiB,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeqB,cAAcA,CAAC1D,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;AACxC"}
|
|
1
|
+
{"version":3,"file":"ServiceOps.js","names":["frodo","state","fs","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","getRealmName","getTypedFilename","titleCase","saveJsonToFile","getFilePath","getWorkingDirectory","utils","getListOfServices","exportServices","exportService","getFullServices","createServiceExportTemplate","importService","importServices","deleteFullService","deleteFullServices","service","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","push","name","toString","error","stack","exportServicesToFile","file","includeMeta","exportData","fileName","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","filePath","importServiceFromFile","options","clean","global","realm","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","_importError$response","_importError$response2","message","response","detail","importFirstServiceFromFile","Object","keys","length","_importError$response3","_importError$response4","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","serviceFiles","filter","toLowerCase","endsWith","deleteService","_error$response","deleteServices"],"sources":["../../src/ops/ServiceOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n type ServiceExportInterface,\n type ServiceImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/ServiceOps';\nimport fs from 'fs';\n\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n} from '../utils/Console';\n\nconst {\n getRealmName,\n getTypedFilename,\n titleCase,\n saveJsonToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n getListOfServices,\n exportServices,\n exportService,\n getFullServices,\n createServiceExportTemplate,\n importService,\n importServices,\n deleteFullService,\n deleteFullServices,\n} = frodo.service;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([\n service._id,\n globalConfig ? service['_type'].name : service.name,\n ]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServicesToFile(\n file,\n globalConfig = false,\n includeMeta = true\n) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${\n globalConfig ? 'Global' : titleCase(getRealmName(state.getRealm()))\n }Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false,\n includeMeta = true\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);\n}\n\n/**\n * Export all services to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportServicesToFiles(\n globalConfig = false,\n includeMeta = true\n) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const filePath = getFilePath(fileName, true);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${filePath}`\n );\n saveJsonToFile(exportData, filePath, includeMeta);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${filePath}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, options);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${filePath}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {ServiceImportOptions} options import options\n */\nexport async function importFirstServiceFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${filePath}]`\n );\n const verbose = state.getVerbose();\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, options);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${filePath}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${filePath}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {ServiceImportOptions} options import options\n */\nexport async function importServicesFromFile(\n file: string,\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n) {\n const filePath = getFilePath(file);\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [file=${filePath}]`\n );\n fs.readFile(filePath, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${filePath}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, options);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [file=${filePath}]`\n );\n });\n}\n\n/**\n * Import all services from separate files\n * @param {ServiceImportOptions} options import options\n */\nexport async function importServicesFromFiles(\n options: ServiceImportOptions = {\n clean: false,\n global: false,\n realm: false,\n }\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const serviceFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of serviceFiles) {\n await importServicesFromFile(file, options);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAKpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,QACT,kBAAkB;AAEzB,MAAM;EACJC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACF,CAAC,GAAGd,KAAK,CAACe,KAAK;AACf,MAAM;EACJC,iBAAiB;EACjBC,cAAc;EACdC,aAAa;EACbC,eAAe;EACfC,2BAA2B;EAC3BC,aAAa;EACbC,cAAc;EACdC,iBAAiB;EACjBC;AACF,CAAC,GAAGxB,KAAK,CAACyB,OAAO;;AAEjB;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,IAAI,GAAG,KAAK,EAAEC,YAAY,GAAG,KAAK,EAAE;EACrE,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,CAACY,YAAY,CAAC;IACtDC,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIN,IAAI,EAAE;MACR,MAAMQ,KAAK,GAAGhC,WAAW,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;MACzD,KAAK,MAAMsB,OAAO,IAAII,QAAQ,EAAE;QAC9BM,KAAK,CAACC,IAAI,CAAC,CACTX,OAAO,CAACQ,GAAG,EACXL,YAAY,GAAGH,OAAO,CAAC,OAAO,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E;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeoB,cAAcA,CAAC5D,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMJ,kBAAkB,CAACI,YAAY,CAAC;AACxC"}
|
package/esm/ops/ThemeOps.js
CHANGED
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
readTheme,
|
|
18
18
|
updateThemeByName,
|
|
19
19
|
updateTheme,
|
|
20
|
-
|
|
20
|
+
importThemes,
|
|
21
21
|
exportThemes,
|
|
22
22
|
deleteTheme,
|
|
23
23
|
deleteThemeByName,
|
|
@@ -233,17 +233,9 @@ export async function importThemesFromFile(file) {
|
|
|
233
233
|
try {
|
|
234
234
|
const data = fs.readFileSync(filePath, 'utf8');
|
|
235
235
|
const themeExport = JSON.parse(data);
|
|
236
|
-
const indicatorId = createProgressIndicator('
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
const result = await updateThemes(themeExport.theme);
|
|
241
|
-
if (result == null) {
|
|
242
|
-
stopProgressIndicator(indicatorId, `Error importing ${Object.keys(themeExport.theme).length} themes!`);
|
|
243
|
-
printMessage(`Error importing ${Object.keys(themeExport.theme).length} themes from ${filePath}`, 'error');
|
|
244
|
-
} else {
|
|
245
|
-
stopProgressIndicator(indicatorId, `Successfully imported ${Object.keys(themeExport.theme).length} themes.`);
|
|
246
|
-
}
|
|
236
|
+
const indicatorId = createProgressIndicator('indeterminate', 0, `Importing themes from ${filePath}...`);
|
|
237
|
+
await importThemes(themeExport);
|
|
238
|
+
stopProgressIndicator(indicatorId, `Successfully imported ${Object.keys(themeExport.theme).length} themes.`);
|
|
247
239
|
} catch (error) {
|
|
248
240
|
printMessage(`Error importing themes: ${error}`, 'error');
|
|
249
241
|
}
|
|
@@ -261,21 +253,22 @@ export async function importThemesFromFiles() {
|
|
|
261
253
|
let total = 0;
|
|
262
254
|
let files = 0;
|
|
263
255
|
for (const file of jsonFiles) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (result == null) {
|
|
271
|
-
printMessage(`Error importing ${count} themes from ${file}`, 'error');
|
|
272
|
-
} else {
|
|
256
|
+
try {
|
|
257
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
258
|
+
fileData = JSON.parse(data);
|
|
259
|
+
if (validateImport(fileData.meta)) {
|
|
260
|
+
count = Object.keys(fileData.theme).length;
|
|
261
|
+
await importThemes(fileData);
|
|
273
262
|
files += 1;
|
|
274
263
|
total += count;
|
|
275
264
|
updateProgressIndicator(indicatorId, `Imported ${count} theme(s) from ${file}`);
|
|
265
|
+
} else {
|
|
266
|
+
printMessage(`Validation of ${file} failed!`, 'error');
|
|
276
267
|
}
|
|
277
|
-
}
|
|
278
|
-
|
|
268
|
+
} catch (error) {
|
|
269
|
+
var _error$response;
|
|
270
|
+
updateProgressIndicator(indicatorId, `Error importing theme(s) from ${file}`);
|
|
271
|
+
printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
|
|
279
272
|
}
|
|
280
273
|
}
|
|
281
274
|
stopProgressIndicator(indicatorId, `Finished importing ${total} theme(s) from ${files} file(s).`);
|
package/esm/ops/ThemeOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeOps.js","names":["frodo","fs","v4","uuidv4","createProgressIndicator","createTable","printMessage","stopProgressIndicator","updateProgressIndicator","getRealmString","validateImport","getTypedFilename","saveJsonToFile","saveToFile","getFilePath","getWorkingDirectory","utils","readThemes","readThemeByName","readTheme","updateThemeByName","updateTheme","updateThemes","exportThemes","deleteTheme","deleteThemeByName","deleteThemes","theme","getOneLineDescription","themeObj","description","_id","name","linkedTrees","join","getTableHeaderMd","markdown","getTableRowMd","row","listThemes","long","themeList","sort","a","b","localeCompare","forEach","isDefault","table","push","toString","exportThemeByName","file","includeMeta","fileName","filePath","indicatorId","themeData","error","message","exportThemeById","id","exportThemesToFile","exportData","exportThemesToFiles","themes","barId","length","fileBarId","importThemeByName","data","readFileSync","themeExport","JSON","parse","found","Object","keys","importThemeById","themeId","importThemesFromFile","result","importThemesFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","map","fileData","count","total","files","meta","importFirstThemeFromFile","then","deleteThemeCmd","undefined","deleteThemeByNameCmd","deleteAllThemes","deleteThemesCmd"],"sources":["../../src/ops/ThemeOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport {\n ThemeExportInterface,\n type ThemeSkeleton,\n} from '@rockcarver/frodo-lib/types/ops/ThemeOps';\nimport fs from 'fs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst {\n getRealmString,\n validateImport,\n getTypedFilename,\n saveJsonToFile,\n saveToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readThemes,\n readThemeByName,\n readTheme,\n updateThemeByName,\n updateTheme,\n updateThemes,\n exportThemes,\n deleteTheme,\n deleteThemeByName,\n deleteThemes,\n} = frodo.theme;\n\n/**\n * Get a one-line description of the theme\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(themeObj: ThemeSkeleton): string {\n const description = `[${themeObj._id['brightCyan']}] ${themeObj.name}${\n themeObj.linkedTrees\n ? ' (' + themeObj.linkedTrees.join(', ')['brightCyan'] + ')'\n : ''\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Linked Journey(s) | Id |\\n';\n markdown += '| ---- | ----------------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the theme in markdown\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a table-row of the theme in markdown\n */\nexport function getTableRowMd(themeObj: ThemeSkeleton): string {\n const row = `| ${themeObj.name} | ${\n themeObj.linkedTrees ? themeObj.linkedTrees.join(', ') : ''\n } | \\`${themeObj._id}\\` |`;\n return row;\n}\n\n/**\n * List all the themes\n * @param {boolean} long Long version, more fields\n */\nexport async function listThemes(long = false) {\n const themeList = await readThemes();\n themeList.sort((a, b) => a.name.localeCompare(b.name));\n if (!long) {\n themeList.forEach((theme) => {\n printMessage(\n `${theme.isDefault ? theme.name['brightCyan'] : theme.name}`,\n 'data'\n );\n });\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Id'['brightCyan'],\n 'Default'['brightCyan'],\n ]);\n themeList.forEach((theme) => {\n table.push([\n `${theme.name}`,\n `${theme._id}`,\n `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`,\n ]);\n });\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Export theme by name to file\n * @param {String} name theme name\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemeByName(name, file, includeMeta = true) {\n let fileName = getTypedFilename(name, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${name}`\n );\n try {\n const themeData = await readThemeByName(name);\n if (!themeData._id) themeData._id = uuidv4();\n updateProgressIndicator(indicatorId, `Writing file to ${filePath}`);\n saveToFile('theme', [themeData], '_id', filePath, includeMeta);\n stopProgressIndicator(indicatorId, `Successfully exported theme ${name}.`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export theme by uuid to file\n * @param {String} id theme uuid\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemeById(id, file, includeMeta = true) {\n let fileName = getTypedFilename(id, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${id}`\n );\n try {\n const themeData = await readTheme(id);\n updateProgressIndicator(indicatorId, `Writing file to ${filePath}`);\n saveToFile('theme', [themeData], '_id', filePath, includeMeta);\n stopProgressIndicator(indicatorId, `Successfully exported theme ${id}.`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export all themes to file\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemesToFile(file, includeMeta = true) {\n let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportThemes();\n saveJsonToFile(exportData, filePath, includeMeta);\n}\n\n/**\n * Export all themes to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemesToFiles(includeMeta = true) {\n const themes = await readThemes();\n const barId = createProgressIndicator(\n 'determinate',\n themes.length,\n 'Exporting themes'\n );\n for (const theme of themes) {\n if (!theme._id) theme._id = uuidv4();\n const fileBarId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting theme ${theme.name}...`\n );\n updateProgressIndicator(barId, `Exporting theme ${theme.name}`);\n const file = getFilePath(getTypedFilename(theme.name, 'theme'), true);\n saveToFile('theme', theme, '_id', file, includeMeta);\n updateProgressIndicator(fileBarId, `${theme.name} saved to ${file}`);\n stopProgressIndicator(fileBarId, `${theme.name} saved to ${file}.`);\n }\n stopProgressIndicator(barId, `${themes.length} themes exported.`);\n}\n\n/**\n * Import theme by name from file\n * @param {String} name theme name\n * @param {String} file import file name\n */\nexport async function importThemeByName(name, file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n let found = false;\n for (const id of Object.keys(themeExport.theme)) {\n if (themeExport.theme[id].name === name) {\n found = true;\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[id].name}`\n );\n try {\n await updateThemeByName(name, themeExport.theme[id]);\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${name}.`\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[id].name}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[id].name}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n if (!found) {\n stopProgressIndicator(indicatorId, `Theme ${name} not found!`);\n }\n } catch (error) {\n printMessage(`Error importing theme ${name}: ${error}`, 'error');\n }\n}\n\n/**\n * Import theme by uuid from file\n * @param {String} id theme uuid\n * @param {String} file import file name\n */\nexport async function importThemeById(id, file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n let found = false;\n for (const themeId of Object.keys(themeExport.theme)) {\n if (themeId === id) {\n found = true;\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[themeId]._id}`\n );\n try {\n await updateTheme(themeId, themeExport.theme[themeId]);\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${id}.`\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[themeId]._id}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[themeId]._id}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n if (!found) {\n stopProgressIndicator(indicatorId, `Theme ${id} not found!`);\n }\n } catch (error) {\n printMessage(`Error importing theme ${id}: ${error}`, 'error');\n }\n}\n\n/**\n * Import all themes from single file\n * @param {String} file import file name\n */\nexport async function importThemesFromFile(file) {\n const filePath = getFilePath(file);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n Object.keys(themeExport.theme).length,\n 'Importing themes...'\n );\n for (const id of Object.keys(themeExport.theme)) {\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[id].name}`\n );\n }\n const result = await updateThemes(themeExport.theme);\n if (result == null) {\n stopProgressIndicator(\n indicatorId,\n `Error importing ${Object.keys(themeExport.theme).length} themes!`\n );\n printMessage(\n `Error importing ${\n Object.keys(themeExport.theme).length\n } themes from ${filePath}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n indicatorId,\n `Successfully imported ${Object.keys(themeExport.theme).length} themes.`\n );\n }\n } catch (error) {\n printMessage(`Error importing themes: ${error}`, 'error');\n }\n}\n\n/**\n * Import themes from separate files\n */\nexport async function importThemesFromFiles() {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.theme.json'))\n .map((name) => getFilePath(name));\n\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing themes...'\n );\n let fileData = null;\n let count = 0;\n let total = 0;\n let files = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n count = Object.keys(fileData.theme).length;\n // eslint-disable-next-line no-await-in-loop\n const result = await updateThemes(fileData.theme);\n if (result == null) {\n printMessage(`Error importing ${count} themes from ${file}`, 'error');\n } else {\n files += 1;\n total += count;\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} theme(s) from ${file}`\n );\n }\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} theme(s) from ${files} file(s).`\n );\n}\n\n/**\n * Import first theme from file\n * @param {String} file import file name\n */\nexport async function importFirstThemeFromFile(file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n for (const id of Object.keys(themeExport.theme)) {\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[id].name}`\n );\n updateTheme(id, themeExport.theme[id]).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[id].name}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[id].name}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${themeExport.theme[id].name}`\n );\n }\n });\n break;\n }\n } catch (error) {\n printMessage(`Error importing themes: ${error}`, 'error');\n }\n}\n\n/**\n * Delete theme by id\n * @param {String} id theme id\n */\nexport async function deleteThemeCmd(id) {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${id}...`\n );\n try {\n await deleteTheme(id);\n stopProgressIndicator(indicatorId, `Deleted ${id}.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete theme by name\n * @param {String} name theme name\n */\nexport async function deleteThemeByNameCmd(name) {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${name}...`\n );\n try {\n await deleteThemeByName(name);\n stopProgressIndicator(indicatorId, `Deleted ${name}.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n */\nexport async function deleteAllThemes() {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting all realm themes...`\n );\n try {\n await deleteThemes();\n stopProgressIndicator(indicatorId, `Deleted all realm themes.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n * @deprecated since version 0.14.0\n */\nexport async function deleteThemesCmd() {\n return deleteAllThemes();\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAK7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SAASC,EAAE,IAAIC,MAAM,Q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ACiD,WAAW,EAAG,WAAUK,EAAG,GAAE,EAAE,SAAS,CAAC;EACjE,CAAC,CAAC,OAAOH,KAAK,EAAE;IACdnD,qBAAqB,CAACiD,WAAW,EAAG,UAASE,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAewC,oBAAoBA,CAACnE,IAAI,EAAE;EAC/C,MAAMwB,WAAW,GAAGpD,uBAAuB,CACzC,eAAe,EACf8F,SAAS,EACR,YAAWlE,IAAK,KACnB,CAAC;EACD,IAAI;IACF,MAAMP,iBAAiB,CAACO,IAAI,CAAC;IAC7BzB,qBAAqB,CAACiD,WAAW,EAAG,WAAUxB,IAAK,GAAE,EAAE,SAAS,CAAC;EACnE,CAAC,CAAC,OAAO0B,KAAK,EAAE;IACdnD,qBAAqB,CAACiD,WAAW,EAAG,UAASE,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeyC,eAAeA,CAAA,EAAG;EACtC,MAAM5C,WAAW,GAAGpD,uBAAuB,CACzC,eAAe,EACf8F,SAAS,EACR,8BACH,CAAC;EACD,IAAI;IACF,MAAMxE,YAAY,CAAC,CAAC;IACpBnB,qBAAqB,CAACiD,WAAW,EAAG,2BAA0B,EAAE,SAAS,CAAC;EAC5E,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdnD,qBAAqB,CAACiD,WAAW,EAAG,UAASE,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe0C,eAAeA,CAAA,EAAG;EACtC,OAAOD,eAAe,CAAC,CAAC;AAC1B"}
|
|
1
|
+
{"version":3,"file":"ThemeOps.js","names":["frodo","fs","v4","uuidv4","createProgressIndicator","createTable","printMessage","stopProgressIndicator","updateProgressIndicator","getRealmString","validateImport","getTypedFilename","saveJsonToFile","saveToFile","getFilePath","getWorkingDirectory","utils","readThemes","readThemeByName","readTheme","updateThemeByName","updateTheme","importThemes","exportThemes","deleteTheme","deleteThemeByName","deleteThemes","theme","getOneLineDescription","themeObj","description","_id","name","linkedTrees","join","getTableHeaderMd","markdown","getTableRowMd","row","listThemes","long","themeList","sort","a","b","localeCompare","forEach","isDefault","table","push","toString","exportThemeByName","file","includeMeta","fileName","filePath","indicatorId","themeData","error","message","exportThemeById","id","exportThemesToFile","exportData","exportThemesToFiles","themes","barId","length","fileBarId","importThemeByName","data","readFileSync","themeExport","JSON","parse","found","Object","keys","importThemeById","themeId","importThemesFromFile","importThemesFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","map","fileData","count","total","files","meta","_error$response","response","importFirstThemeFromFile","then","result","deleteThemeCmd","undefined","deleteThemeByNameCmd","deleteAllThemes","deleteThemesCmd"],"sources":["../../src/ops/ThemeOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport {\n ThemeExportInterface,\n type ThemeSkeleton,\n} from '@rockcarver/frodo-lib/types/ops/ThemeOps';\nimport fs from 'fs';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from '../utils/Console';\n\nconst {\n getRealmString,\n validateImport,\n getTypedFilename,\n saveJsonToFile,\n saveToFile,\n getFilePath,\n getWorkingDirectory,\n} = frodo.utils;\nconst {\n readThemes,\n readThemeByName,\n readTheme,\n updateThemeByName,\n updateTheme,\n importThemes,\n exportThemes,\n deleteTheme,\n deleteThemeByName,\n deleteThemes,\n} = frodo.theme;\n\n/**\n * Get a one-line description of the theme\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(themeObj: ThemeSkeleton): string {\n const description = `[${themeObj._id['brightCyan']}] ${themeObj.name}${\n themeObj.linkedTrees\n ? ' (' + themeObj.linkedTrees.join(', ')['brightCyan'] + ')'\n : ''\n }`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name | Linked Journey(s) | Id |\\n';\n markdown += '| ---- | ----------------- | ---|';\n return markdown;\n}\n\n/**\n * Get a table-row of the theme in markdown\n * @param {ThemeSkeleton} themeObj theme object to describe\n * @returns {string} a table-row of the theme in markdown\n */\nexport function getTableRowMd(themeObj: ThemeSkeleton): string {\n const row = `| ${themeObj.name} | ${\n themeObj.linkedTrees ? themeObj.linkedTrees.join(', ') : ''\n } | \\`${themeObj._id}\\` |`;\n return row;\n}\n\n/**\n * List all the themes\n * @param {boolean} long Long version, more fields\n */\nexport async function listThemes(long = false) {\n const themeList = await readThemes();\n themeList.sort((a, b) => a.name.localeCompare(b.name));\n if (!long) {\n themeList.forEach((theme) => {\n printMessage(\n `${theme.isDefault ? theme.name['brightCyan'] : theme.name}`,\n 'data'\n );\n });\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Id'['brightCyan'],\n 'Default'['brightCyan'],\n ]);\n themeList.forEach((theme) => {\n table.push([\n `${theme.name}`,\n `${theme._id}`,\n `${theme.isDefault ? 'Yes'['brightGreen'] : ''}`,\n ]);\n });\n printMessage(table.toString(), 'data');\n }\n}\n\n/**\n * Export theme by name to file\n * @param {String} name theme name\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemeByName(name, file, includeMeta = true) {\n let fileName = getTypedFilename(name, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${name}`\n );\n try {\n const themeData = await readThemeByName(name);\n if (!themeData._id) themeData._id = uuidv4();\n updateProgressIndicator(indicatorId, `Writing file to ${filePath}`);\n saveToFile('theme', [themeData], '_id', filePath, includeMeta);\n stopProgressIndicator(indicatorId, `Successfully exported theme ${name}.`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export theme by uuid to file\n * @param {String} id theme uuid\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemeById(id, file, includeMeta = true) {\n let fileName = getTypedFilename(id, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting ${id}`\n );\n try {\n const themeData = await readTheme(id);\n updateProgressIndicator(indicatorId, `Writing file to ${filePath}`);\n saveToFile('theme', [themeData], '_id', filePath, includeMeta);\n stopProgressIndicator(indicatorId, `Successfully exported theme ${id}.`);\n } catch (error) {\n stopProgressIndicator(indicatorId, `${error.message}`);\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Export all themes to file\n * @param {String} file optional export file name\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemesToFile(file, includeMeta = true) {\n let fileName = getTypedFilename(`all${getRealmString()}Themes`, 'theme');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportThemes();\n saveJsonToFile(exportData, filePath, includeMeta);\n}\n\n/**\n * Export all themes to separate files\n * @param {boolean} includeMeta true to include metadata, false otherwise. Default: true\n */\nexport async function exportThemesToFiles(includeMeta = true) {\n const themes = await readThemes();\n const barId = createProgressIndicator(\n 'determinate',\n themes.length,\n 'Exporting themes'\n );\n for (const theme of themes) {\n if (!theme._id) theme._id = uuidv4();\n const fileBarId = createProgressIndicator(\n 'determinate',\n 1,\n `Exporting theme ${theme.name}...`\n );\n updateProgressIndicator(barId, `Exporting theme ${theme.name}`);\n const file = getFilePath(getTypedFilename(theme.name, 'theme'), true);\n saveToFile('theme', theme, '_id', file, includeMeta);\n updateProgressIndicator(fileBarId, `${theme.name} saved to ${file}`);\n stopProgressIndicator(fileBarId, `${theme.name} saved to ${file}.`);\n }\n stopProgressIndicator(barId, `${themes.length} themes exported.`);\n}\n\n/**\n * Import theme by name from file\n * @param {String} name theme name\n * @param {String} file import file name\n */\nexport async function importThemeByName(name, file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n let found = false;\n for (const id of Object.keys(themeExport.theme)) {\n if (themeExport.theme[id].name === name) {\n found = true;\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[id].name}`\n );\n try {\n await updateThemeByName(name, themeExport.theme[id]);\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${name}.`\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[id].name}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[id].name}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n if (!found) {\n stopProgressIndicator(indicatorId, `Theme ${name} not found!`);\n }\n } catch (error) {\n printMessage(`Error importing theme ${name}: ${error}`, 'error');\n }\n}\n\n/**\n * Import theme by uuid from file\n * @param {String} id theme uuid\n * @param {String} file import file name\n */\nexport async function importThemeById(id, file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n let found = false;\n for (const themeId of Object.keys(themeExport.theme)) {\n if (themeId === id) {\n found = true;\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[themeId]._id}`\n );\n try {\n await updateTheme(themeId, themeExport.theme[themeId]);\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${id}.`\n );\n } catch (error) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[themeId]._id}: ${error.message}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[themeId]._id}: ${error.message}`,\n 'error'\n );\n }\n break;\n }\n }\n if (!found) {\n stopProgressIndicator(indicatorId, `Theme ${id} not found!`);\n }\n } catch (error) {\n printMessage(`Error importing theme ${id}: ${error}`, 'error');\n }\n}\n\n/**\n * Import all themes from single file\n * @param {String} file import file name\n */\nexport async function importThemesFromFile(file) {\n const filePath = getFilePath(file);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const themeExport: ThemeExportInterface = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n 0,\n `Importing themes from ${filePath}...`\n );\n await importThemes(themeExport);\n stopProgressIndicator(\n indicatorId,\n `Successfully imported ${Object.keys(themeExport.theme).length} themes.`\n );\n } catch (error) {\n printMessage(`Error importing themes: ${error}`, 'error');\n }\n}\n\n/**\n * Import themes from separate files\n */\nexport async function importThemesFromFiles() {\n const names = fs.readdirSync(getWorkingDirectory());\n const jsonFiles = names\n .filter((name) => name.toLowerCase().endsWith('.theme.json'))\n .map((name) => getFilePath(name));\n\n const indicatorId = createProgressIndicator(\n 'determinate',\n jsonFiles.length,\n 'Importing themes...'\n );\n let fileData = null;\n let count = 0;\n let total = 0;\n let files = 0;\n for (const file of jsonFiles) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n count = Object.keys(fileData.theme).length;\n await importThemes(fileData);\n files += 1;\n total += count;\n updateProgressIndicator(\n indicatorId,\n `Imported ${count} theme(s) from ${file}`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n } catch (error) {\n updateProgressIndicator(\n indicatorId,\n `Error importing theme(s) from ${file}`\n );\n printMessage(error.response?.data || error, 'error');\n }\n }\n stopProgressIndicator(\n indicatorId,\n `Finished importing ${total} theme(s) from ${files} file(s).`\n );\n}\n\n/**\n * Import first theme from file\n * @param {String} file import file name\n */\nexport async function importFirstThemeFromFile(file) {\n try {\n const data = fs.readFileSync(getFilePath(file), 'utf8');\n const themeExport = JSON.parse(data);\n const indicatorId = createProgressIndicator(\n 'determinate',\n 1,\n 'Importing theme...'\n );\n for (const id of Object.keys(themeExport.theme)) {\n updateProgressIndicator(\n indicatorId,\n `Importing ${themeExport.theme[id].name}`\n );\n updateTheme(id, themeExport.theme[id]).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n indicatorId,\n `Error importing theme ${themeExport.theme[id].name}`\n );\n printMessage(\n `Error importing theme ${themeExport.theme[id].name}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n indicatorId,\n `Successfully imported theme ${themeExport.theme[id].name}`\n );\n }\n });\n break;\n }\n } catch (error) {\n printMessage(`Error importing themes: ${error}`, 'error');\n }\n}\n\n/**\n * Delete theme by id\n * @param {String} id theme id\n */\nexport async function deleteThemeCmd(id) {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${id}...`\n );\n try {\n await deleteTheme(id);\n stopProgressIndicator(indicatorId, `Deleted ${id}.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete theme by name\n * @param {String} name theme name\n */\nexport async function deleteThemeByNameCmd(name) {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting ${name}...`\n );\n try {\n await deleteThemeByName(name);\n stopProgressIndicator(indicatorId, `Deleted ${name}.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n */\nexport async function deleteAllThemes() {\n const indicatorId = createProgressIndicator(\n 'indeterminate',\n undefined,\n `Deleting all realm themes...`\n );\n try {\n await deleteThemes();\n stopProgressIndicator(indicatorId, `Deleted all realm themes.`, 'success');\n } catch (error) {\n stopProgressIndicator(indicatorId, `Error: ${error.message}`, 'fail');\n }\n}\n\n/**\n * Delete all themes\n * @deprecated since version 0.14.0\n */\nexport async function deleteThemesCmd() {\n return deleteAllThemes();\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAK7C,OAAO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B,IAAK,GAAE,EAAE,SAAS,CAAC;EACnE,CAAC,CAAC,OAAO0B,KAAK,EAAE;IACdnD,qBAAqB,CAACiD,WAAW,EAAG,UAASE,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAe2C,eAAeA,CAAA,EAAG;EACtC,MAAM9C,WAAW,GAAGpD,uBAAuB,CACzC,eAAe,EACfgG,SAAS,EACR,8BACH,CAAC;EACD,IAAI;IACF,MAAM1E,YAAY,CAAC,CAAC;IACpBnB,qBAAqB,CAACiD,WAAW,EAAG,2BAA0B,EAAE,SAAS,CAAC;EAC5E,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdnD,qBAAqB,CAACiD,WAAW,EAAG,UAASE,KAAK,CAACC,OAAQ,EAAC,EAAE,MAAM,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe4C,eAAeA,CAAA,EAAG;EACtC,OAAOD,eAAe,CAAC,CAAC;AAC1B"}
|
package/esm/utils/Config.js
CHANGED
|
@@ -70,7 +70,16 @@ export async function getFullExportConfig(file = null) {
|
|
|
70
70
|
noDecode: false
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
// Go through files in directory and reconstruct the full export
|
|
73
|
+
// Go through files in the working directory and reconstruct the full export
|
|
74
|
+
return getFullExportConfigFromDirectory(workingDirectory);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reconstructs the full export config from files in the given directory
|
|
79
|
+
* @param directory The directory
|
|
80
|
+
* @return The full export config
|
|
81
|
+
*/
|
|
82
|
+
export async function getFullExportConfigFromDirectory(directory) {
|
|
74
83
|
const fullExportConfig = {
|
|
75
84
|
meta: {},
|
|
76
85
|
agents: {},
|
|
@@ -96,7 +105,7 @@ export async function getFullExportConfig(file = null) {
|
|
|
96
105
|
trees: {},
|
|
97
106
|
variables: {}
|
|
98
107
|
};
|
|
99
|
-
const files = await readFiles(
|
|
108
|
+
const files = await readFiles(directory);
|
|
100
109
|
const jsonFiles = files.filter(f => f.path.endsWith('.json'));
|
|
101
110
|
const idmConfigFiles = jsonFiles.filter(f => f.path.startsWith('config/'));
|
|
102
111
|
const samlFiles = jsonFiles.filter(f => f.path.startsWith('saml/') || f.path.startsWith('cot/'));
|