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B,GAEvB,QAAQ,IAAI,wBACd,CAEA,OAAO,OAAO,IACZ,QAAQ,MAAM,EAAE","file":"/npm/vite-add-vue-router@0.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vite-add-vue-router@0.0.2/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 prompts from 'prompts';\nimport exec from 'await-exec';\nimport { mkdir, readFile, writeFile } from 'fs/promises';\n\nfunction generateRouterConfig() {\n  return `\nimport { createRouter, createWebHistory } from 'vue-router';\nimport HomeView from '../views/HomeView.vue';\n\nconst router = createRouter({\n  history: createWebHistory(import.meta.env.BASE_URL),\n  routes: [\n    {\n      path: '/',\n      name: 'home',\n      component: HomeView,\n    },\n  ],\n});\n\nexport default router;\n`;\n}\n\nfunction generateAppVue() {\n  return `\n<template>\n    <router-view />\n</template>\n`;\n}\n\nasync function generateRouterFiles(fileEnding) {\n  await mkdir('src/router', { recursive: true });\n  await writeFile(`src/router/index.${fileEnding}`, generateRouterConfig());\n}\n\nasync function generateVueFiles() {\n  await mkdir('src/views', { recursive: true });\n\n  const oldAppVue = (await readFile('src/App.vue')).toString();\n\n  await writeFile('src/views/HomeView.vue', oldAppVue.replaceAll('./', '../'));\n  await writeFile('src/App.vue', generateAppVue());\n}\n\nasync function generateMainFile(fileEnding) {\n  const vueConfig = (await readFile(`src/main.${fileEnding}`)).toString();\n  let vueConfigLines = vueConfig.slice().split('\\n');\n  const lastImportLine = vueConfigLines\n    .map((line) => line.indexOf('import ') !== -1)\n    .lastIndexOf(true);\n\n  vueConfigLines.splice(\n    lastImportLine + 1,\n    0,\n    'import router from \"./router\";'\n  );\n\n  vueConfigLines[vueConfigLines.length - 2] = vueConfigLines[\n    vueConfigLines.length - 2\n  ].replace('.mount(', '.use(router).mount(');\n\n  await writeFile(`src/main.${fileEnding}`, vueConfigLines.join('\\n'));\n}\n\nasync function init() {\n  let result = {};\n\n  try {\n    result = await prompts(\n      [\n        {\n          name: 'usesTypeScropt',\n          type: () => 'toggle',\n          message: 'Is it a TypeScript-based project?',\n          initial: false,\n          active: 'Yes',\n          inactive: 'No',\n        },\n        {\n          name: 'npmExecutable',\n          type: () => 'text',\n          message: 'The npm executable to use',\n          initial: 'npm',\n        },\n      ],\n      {\n        onCancel: () => {\n          throw new Error(red('✖') + ' Operation cancelled');\n        },\n      }\n    );\n  } catch (cancelled) {\n    console.log(cancelled.message);\n    process.exit(1);\n  }\n\n  const {\n    usesTypeScript = result.usesTypeScropt,\n    npmExecutable = result.npmExecutable,\n  } = result;\n\n  const fileEnding = usesTypeScript ? 'ts' : 'js';\n\n  console.log('Installing vue-router...');\n  await exec(`${npmExecutable} install vue-router`);\n\n  await generateRouterFiles(fileEnding);\n  await generateVueFiles();\n  await generateMainFile(fileEnding);\n\n  console.log('Installed vue-router!');\n}\n\ninit().catch((e) => {\n  console.error(e);\n});\n"]}