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P,eAEiB,EAG1B,qBAAqB,MAAM,IACvB,MAAO,EAAQ,GAAW,EACpB,GACS,IAAX,EACM,GAAG,iBAAiB,IAAU,eAC9B,GAAG,eAAe,IAAU,eAEtC,QAAQ,OAAO,MAAM,GAGrB,WAAW,MAAM,GACb,QAAQ,OAAO,MACX,GAAG,sCAAsC,IAAW,mBAKjD,IAAX,GACI,YAAW,KACP,MAAM,EAAgB,EAAQ,MAAM,uBAC9B,sBACA,iBAEN,KAAK,EAAc,GACpB,IAAK","file":"/npm/@squiz/dxp-plugin-template@3.1.3/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@squiz/dxp-plugin-template@3.1.3/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\nimport open from 'open';\nimport showPlugAndPlayLogo from './functions/showPnPLogo.js';\nimport getInstallPreferences from './functions/getInstallPreferences.js';\nimport installComponents from './functions/installComponents.js';\nimport isRunningInProjectHome from './constants/isRunningInProjectHome.js';\nimport {\n    consoleRed,\n    consoleGreen,\n    consoleYellow,\n    consoleReset,\n} from './constants/consoleColours.js';\nimport templateUrl from './constants/templateUrl.js';\nimport cloneRepo from './functions/cloneRepo.js';\nimport pushNewRepo from './functions/pushNewRepo.js';\nimport trackComponentUsage from './functions/trackUsage.js';\nimport runCleanupScripts from './functions/runCleanupScripts.js';\nimport {\n    collateralUrlExisting,\n    collateralUrlNew,\n} from './constants/collateralUrl.js';\nimport toKebabCase from './functions/stringToKebabCase.js';\nimport { setBranchName } from './constants/branch.js';\nimport { setShouldTrack } from './constants/shouldTrack.js';\nimport addInstallTypeToPackage from './functions/addInstallTypeToPackage.js';\nimport preflightCheck from './functions/preflightCheck.js';\nimport {\n    masterComponentRepoUrl,\n    masterComponentGlobalsRepoUrl,\n} from './constants/componentRepoUrls.js';\nimport { saveLogs } from './functions/logger.js';\nimport installGlobalDependencies from './functions/installGlobalDependencies.js';\n\n// Array of PNP repos user needs at least read permissions.\nconst REPOS = [\n    masterComponentRepoUrl,\n    masterComponentGlobalsRepoUrl,\n    templateUrl,\n];\n\nconst handleInstallation = async () => {\n    // Show our ascii logo\n    showPlugAndPlayLogo();\n\n    try {\n        await preflightCheck(REPOS);\n    } catch (e) {\n        // No access to one of the main repos or node version is wrong, stopping.\n        return [false, e.message];\n    }\n\n    process.stdout.write('\\n');\n\n    const answers = await getInstallPreferences();\n\n    process.stdout.write('\\n');\n\n    // Setup some defaults if they haven't been defined\n    // Define the default branch as master if it isn't defined\n    if (answers.branch !== undefined) {\n        setBranchName(answers.branch);\n    }\n\n    // If should track answer is defined\n    if (answers.track !== undefined) {\n        setShouldTrack(answers.track);\n    }\n\n    const componentType = answers.componentType || 'src';\n\n    if (answers.installType === 'existing project') {\n        if (!isRunningInProjectHome) {\n            return [\n                false,\n                `${consoleRed} Oops, looks like you are running this tool somewhere other than the root of your project directory. Please change directories to your project root and try again.${consoleReset}`,\n            ];\n        }\n\n        // Components being download.\n        try {\n            await installComponents(answers, componentType);\n        } catch (e) {\n            // There was something wrong let user know we are not able to continue.\n            return [false, e.message];\n        }\n\n        // set the install type in our package.json file\n        await addInstallTypeToPackage(answers);\n\n        return [\n            true,\n            'Successfully installed component(s) within existing project.',\n        ];\n    }\n\n    try {\n        // If the user has selected new repo we will clone this repo.\n        await cloneRepo(answers);\n\n        // Track the usage of the template\n        await trackComponentUsage(answers);\n\n        // Install the global dependencies as this should be different based on the branch selected for Plug & Play team members\n        await installGlobalDependencies(answers);\n\n        // Run the template cleanup scripts\n        await runCleanupScripts(answers);\n\n        // set the install type in our package.json file\n        await addInstallTypeToPackage(answers);\n    } catch (e) {\n        // We cannot clone repo lets stop the process.\n        return [false, e.message];\n    }\n\n    // Push the cloned repo to the new projects url\n    try {\n        await pushNewRepo(answers);\n    } catch (e) {\n        // Don't stop me know, I'm having such good time.\n        process.stdout.write(e.message);\n    }\n\n    const message = `Installation complete ${consoleYellow}Remember to change to your new project folder with \"cd ${toKebabCase(\n        answers.projectName\n    )}\"${consoleReset}`;\n\n    return [true, message];\n};\n\nhandleInstallation().then((response) => {\n    const [status, message] = response;\n    const finalMessage =\n        status === true\n            ? `${consoleGreen}\\n${message}${consoleReset}`\n            : `${consoleRed}\\n${message}${consoleReset}`;\n\n    process.stdout.write(finalMessage);\n\n    // Print messages and warnings for the user.\n    saveLogs().then((fileName) =>\n        process.stdout.write(\n            `${consoleYellow}\\nLogs are written in ${fileName}${consoleReset}`\n        )\n    );\n\n    // eslint-disable-next-line no-unused-expressions\n    status === true &&\n        setTimeout(() => {\n            const collateralUrl = message.match(/existing project/gim)\n                ? collateralUrlExisting\n                : collateralUrlNew;\n\n            open(collateralUrl);\n        }, 2000);\n});\n"]}