@vuepress/plugin-redirect 2.0.0-rc.69 → 2.0.0-rc.71

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/lib/cli/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import{removeEndingSlash as f,removeLeadingSlash as m}from"@vuepress/helper";import{cac as b}from"cac";import{resolveCliAppConfig as v,resolveUserConfigPath as y,resolveUserConfigConventionalPath as C,loadUserConfig as j,resolveAppConfig as w,transformUserConfigToPlugin as x}from"vuepress/cli";import{createBuildApp as $}from"vuepress/core";import{logger as n,fs as r,path as s}from"vuepress/utils";var P="@vuepress/plugin-redirect",k="2.0.0-rc.69",S="VuePress plugin - redirect",A=["vuepress-plugin","vuepress","plugin","redirect"],D="https://ecosystem.vuejs.press/plugins/tools/redirect.html",H={url:"https://github.com/vuepress/ecosystem/issues"},T={type:"git",url:"git+https://github.com/vuepress/ecosystem.git",directory:"plugins/tools/plugin-redirect"},U="MIT",E={name:"Mr.Hope",email:"mister-hope@outlook.com",url:"https://mister-hope.com"},V="module",M={".":"./lib/node/index.js","./client":"./lib/client/index.js","./package.json":"./package.json"},R="./lib/node/index.js",F="./lib/node/index.d.ts",G={"vp-redirect":"./lib/cli/index.js"},I=["lib"],L={build:"tsc -b tsconfig.build.json",bundle:"rollup -c rollup.config.ts --configPlugin esbuild",clean:"rimraf --glob ./lib ./*.tsbuildinfo",style:"sass src:lib --embed-sources --style=compressed"},N={"@vuepress/helper":"workspace:*","@vueuse/core":"^12.3.0",cac:"^6.7.14",vue:"^3.5.13"},q={vuepress:"2.0.0-rc.19"},z={access:"public"},B={name:P,version:k,description:S,keywords:A,homepage:D,bugs:H,repository:T,license:U,author:E,type:V,exports:M,main:R,types:F,bin:G,files:I,scripts:L,dependencies:N,peerDependencies:q,publishConfig:z};const O=i=>`<!doctype html>
2
+ import{removeEndingSlash as v,removeLeadingSlash as g}from"@vuepress/helper";import{createCommand as b}from"commander";import{resolveCliAppConfig as y,resolveUserConfigPath as C,resolveUserConfigConventionalPath as w,loadUserConfig as j,resolveAppConfig as x,transformUserConfigToPlugin as $}from"vuepress/cli";import{createBuildApp as P}from"vuepress/core";import{fs as o,logger as n,path as s}from"vuepress/utils";var k="@vuepress/plugin-redirect",S="2.0.0-rc.71",A="VuePress plugin - redirect",D=["vuepress-plugin","vuepress","plugin","redirect"],E="https://ecosystem.vuejs.press/plugins/tools/redirect.html",T={url:"https://github.com/vuepress/ecosystem/issues"},U={type:"git",url:"git+https://github.com/vuepress/ecosystem.git",directory:"plugins/tools/plugin-redirect"},V="MIT",H={name:"Mr.Hope",email:"mister-hope@outlook.com",url:"https://mister-hope.com"},G="module",M={".":"./lib/node/index.js","./client":"./lib/client/index.js","./package.json":"./package.json"},R="./lib/node/index.js",F="./lib/node/index.d.ts",I={"vp-redirect":"./lib/cli/index.js"},L=["lib"],N={build:"tsc -b tsconfig.build.json",bundle:"rollup -c rollup.config.ts --configPlugin esbuild",clean:"rimraf --glob ./lib ./*.tsbuildinfo",style:"sass src:lib --embed-sources --style=compressed --pkg-importer=node"},O={"@vuepress/helper":"workspace:*","@vueuse/core":"^12.4.0",commander:"^13.0.0",vue:"^3.5.13"},q={vuepress:"2.0.0-rc.19"},z={access:"public"},B={name:k,version:S,description:A,keywords:D,homepage:E,bugs:T,repository:U,license:V,author:H,type:G,exports:M,main:R,types:F,bin:I,files:L,scripts:N,dependencies:O,peerDependencies:q,publishConfig:z};const _=e=>`<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <meta name="robots" content="noindex">
7
- <meta http-equiv="refresh" content="0; url=${i}">
8
- <link rel="canonical" href="${i}">
7
+ <meta http-equiv="refresh" content="0; url=${e}">
8
+ <link rel="canonical" href="${e}">
9
9
  <title>Redirecting...</title>
10
10
  <script>
11
11
  const anchor = window.location.hash.substring(1);
12
- location.href = \`${i}\${anchor? \`#\${anchor}\`: ""}\`;
12
+ location.href = \`${e}\${anchor? \`#\${anchor}\`: ""}\`;
13
13
  <\/script>
14
14
  </head>
15
15
  <body>
16
16
  <p>Redirecting...</p>
17
17
  </body>
18
18
  </html>
19
- `,o=b("vp-redirect");o.command("generate [source-dir]","Generate redirect site using VuePress project under source folder").option("--hostname <hostname>","Hostname to redirect to (E.g.: https://new.example.com/)",{default:"/"}).option("-c, --config <config>","Set path to config file").option("-o, --output <output>","Set the output directory (default: .vuepress/redirect)").option("--cache <cache>","Set the directory of the cache files").option("-t, --temp <temp>","Set the directory of the temporary files").option("--clean-cache","Clean the cache files before generation").option("--clean-temp","Clean the temporary files before generation").action(async(i,e)=>{if(!i){o.outputHelp();return}process.env.NODE_ENV??="production";const c=v(i,{}),g=e.config?y(e.config):C(c.source),{userConfig:a}=await j(g),p=w({defaultAppConfig:{},cliAppConfig:c,userConfig:a});if(p===null)return;const t=$(p);t.use(x(a,c.source)),e.cleanTemp===!0&&(n.info("Cleaning temp..."),await r.remove(t.dir.temp())),e.cleanCache===!0&&(n.info("Cleaning cache..."),await r.remove(t.dir.cache()));const l=e.output?s.join(process.cwd(),e.output):s.join(t.dir.source(),".vuepress","redirect");await r.emptyDir(l),n.info("Initializing VuePress and preparing data..."),await t.init(),n.info("Generating redirect pages..."),await Promise.all(t.pages.map(u=>{const h=`${f(e.hostname)}${t.siteData.base}${m(u.path)}`,d=s.join(l,m(u.path.replace(/\/$/,"/index.html")));return r.ensureDir(s.dirname(d)).then(()=>r.writeFile(d,O(h)))}))}),o.command("").action(()=>{o.outputHelp()}),o.help(),o.version(B.version),o.parse();
19
+ `,t=b("vp-redirect");t.summary("Generate redirect site").description("Generate redirect site for current VuePress project").option("--hostname <hostname>","Hostname to redirect to (E.g.: https://new.example.com/)","/").option("-c, --config [config]","Set path to config file").option("--cache [cache]","Set the directory of the cache files").option("--temp [temp]","Set the directory of the temporary files").option("--clean-cache","Clean the cache files before generation").option("--clean-temp","Clean the temporary files before generation").argument("<source>","Source directory of VuePress project").argument("[output]","Output folder (default: .vuepress/redirect relative to source folder)").action(async(e,a,i)=>{process.env.NODE_ENV??="production",o.existsSync(e)||t.error(`Source directory ${e} does not exist!`);const c=y(e,{}),h=i.config?C(i.config):w(c.source),{userConfig:p}=await j(h),l=x({defaultAppConfig:{},cliAppConfig:c,userConfig:p});if(l===null)return;const r=P(l);r.use($(p,c.source)),i.cleanTemp===!0&&(n.info("Cleaning temp..."),await o.remove(r.dir.temp())),i.cleanCache===!0&&(n.info("Cleaning cache..."),await o.remove(r.dir.cache()));const u=a?s.join(process.cwd(),a):s.join(r.dir.source(),".vuepress","redirect");await o.emptyDir(u),n.info("Initializing VuePress and preparing data..."),await r.init(),n.info("Generating redirect pages..."),await Promise.all(r.pages.map(d=>{const f=`${v(i.hostname)}${r.siteData.base}${g(d.path)}`,m=s.join(u,g(d.path.replace(/\/$/,"/index.html")));return o.ensureDir(s.dirname(m)).then(()=>o.writeFile(m,_(f)))}))}),t.version(B.version),t.showHelpAfterError("add --help for additional information"),await t.parseAsync();
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../package.json","../../src/node/generate/getRedirectHTML.ts","../../src/cli/index.ts"],"sourcesContent":["{\n \"name\": \"@vuepress/plugin-redirect\",\n \"version\": \"2.0.0-rc.69\",\n \"description\": \"VuePress plugin - redirect\",\n \"keywords\": [\n \"vuepress-plugin\",\n \"vuepress\",\n \"plugin\",\n \"redirect\"\n ],\n \"homepage\": \"https://ecosystem.vuejs.press/plugins/tools/redirect.html\",\n \"bugs\": {\n \"url\": \"https://github.com/vuepress/ecosystem/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vuepress/ecosystem.git\",\n \"directory\": \"plugins/tools/plugin-redirect\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"Mr.Hope\",\n \"email\": \"mister-hope@outlook.com\",\n \"url\": \"https://mister-hope.com\"\n },\n \"type\": \"module\",\n \"exports\": {\n \".\": \"./lib/node/index.js\",\n \"./client\": \"./lib/client/index.js\",\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./lib/node/index.js\",\n \"types\": \"./lib/node/index.d.ts\",\n \"bin\": {\n \"vp-redirect\": \"./lib/cli/index.js\"\n },\n \"files\": [\n \"lib\"\n ],\n \"scripts\": {\n \"build\": \"tsc -b tsconfig.build.json\",\n \"bundle\": \"rollup -c rollup.config.ts --configPlugin esbuild\",\n \"clean\": \"rimraf --glob ./lib ./*.tsbuildinfo\",\n \"style\": \"sass src:lib --embed-sources --style=compressed\"\n },\n \"dependencies\": {\n \"@vuepress/helper\": \"workspace:*\",\n \"@vueuse/core\": \"^12.3.0\",\n \"cac\": \"^6.7.14\",\n \"vue\": \"^3.5.13\"\n },\n \"peerDependencies\": {\n \"vuepress\": \"2.0.0-rc.19\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export const getRedirectHTML = (redirectUrl: string): string => `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"robots\" content=\"noindex\">\n <meta http-equiv=\"refresh\" content=\"0; url=${redirectUrl}\">\n <link rel=\"canonical\" href=\"${redirectUrl}\">\n <title>Redirecting...</title>\n <script>\n const anchor = window.location.hash.substring(1);\n location.href = \\`${redirectUrl}\\${anchor? \\`#\\${anchor}\\`: \"\"}\\`;\n </script>\n</head>\n<body>\n <p>Redirecting...</p>\n</body>\n</html>\n`\n","#!/usr/bin/env node\nimport { removeEndingSlash, removeLeadingSlash } from '@vuepress/helper'\nimport { cac } from 'cac'\nimport {\n loadUserConfig,\n resolveAppConfig,\n resolveCliAppConfig,\n resolveUserConfigConventionalPath,\n resolveUserConfigPath,\n transformUserConfigToPlugin,\n} from 'vuepress/cli'\nimport { createBuildApp } from 'vuepress/core'\nimport { fs, logger, path } from 'vuepress/utils'\nimport pkg from '../../package.json' with { type: 'json' }\nimport { getRedirectHTML } from '../node/generate/getRedirectHTML.js'\n\ninterface RedirectCommandOptions {\n hostname: string\n output?: string\n config?: string\n cache: string\n temp?: string\n cleanCache?: boolean\n cleanTemp?: boolean\n}\n\nconst cli = cac('vp-redirect')\n\ncli\n .command(\n 'generate [source-dir]',\n 'Generate redirect site using VuePress project under source folder',\n )\n .option(\n '--hostname <hostname>',\n 'Hostname to redirect to (E.g.: https://new.example.com/)',\n { default: '/' },\n )\n .option('-c, --config <config>', 'Set path to config file')\n .option(\n '-o, --output <output>',\n 'Set the output directory (default: .vuepress/redirect)',\n )\n .option('--cache <cache>', 'Set the directory of the cache files')\n .option('-t, --temp <temp>', 'Set the directory of the temporary files')\n .option('--clean-cache', 'Clean the cache files before generation')\n .option('--clean-temp', 'Clean the temporary files before generation')\n .action(async (sourceDir: string, commandOptions: RedirectCommandOptions) => {\n if (!sourceDir) {\n cli.outputHelp()\n return\n }\n\n // ensure NODE_ENV is set\n process.env.NODE_ENV ??= 'production'\n\n // resolve app config from cli options\n const cliAppConfig = resolveCliAppConfig(sourceDir, {})\n\n // resolve user config file\n const userConfigPath = commandOptions.config\n ? resolveUserConfigPath(commandOptions.config)\n : resolveUserConfigConventionalPath(cliAppConfig.source)\n\n const { userConfig } = await loadUserConfig(userConfigPath)\n\n // resolve the final app config to use\n const appConfig = resolveAppConfig({\n defaultAppConfig: {},\n cliAppConfig,\n userConfig,\n })\n\n if (appConfig === null) return\n\n // create vuepress app\n const app = createBuildApp(appConfig)\n\n // use user-config plugin\n app.use(transformUserConfigToPlugin(userConfig, cliAppConfig.source))\n\n // clean temp and cache\n if (commandOptions.cleanTemp === true) {\n logger.info('Cleaning temp...')\n await fs.remove(app.dir.temp())\n }\n if (commandOptions.cleanCache === true) {\n logger.info('Cleaning cache...')\n await fs.remove(app.dir.cache())\n }\n\n const outputFolder = commandOptions.output\n ? path.join(process.cwd(), commandOptions.output)\n : path.join(app.dir.source(), '.vuepress', 'redirect')\n\n // empty output directory\n await fs.emptyDir(outputFolder)\n\n // initialize vuepress app to get pages\n logger.info('Initializing VuePress and preparing data...')\n\n // initialize vuepress app to get pages\n await app.init()\n\n logger.info('Generating redirect pages...')\n\n // redirect all pages\n await Promise.all(\n app.pages.map((page) => {\n const redirectUrl = `${removeEndingSlash(commandOptions.hostname)}${\n app.siteData.base\n }${removeLeadingSlash(page.path)}`\n const destLocation = path.join(\n outputFolder,\n removeLeadingSlash(page.path.replace(/\\/$/, '/index.html')),\n )\n\n return fs\n .ensureDir(path.dirname(destLocation))\n .then(() => fs.writeFile(destLocation, getRedirectHTML(redirectUrl)))\n }),\n )\n })\n\ncli.command('').action(() => {\n cli.outputHelp()\n})\n\ncli.help()\ncli.version(pkg.version)\n\ncli.parse()\n"],"names":["name","version","description","keywords","homepage","bugs","repository","license","author","type","exports","main","types","bin","files","scripts","dependencies","peerDependencies","publishConfig","package_default","getRedirectHTML","redirectUrl","cli","cac","sourceDir","commandOptions","cliAppConfig","resolveCliAppConfig","userConfigPath","resolveUserConfigPath","resolveUserConfigConventionalPath","userConfig","loadUserConfig","appConfig","resolveAppConfig","app","createBuildApp","transformUserConfigToPlugin","logger","fs","outputFolder","path","page","removeEndingSlash","removeLeadingSlash","destLocation","pkg"],"mappings":";gZACE,IAAAA,EAAQ,4BACRC,EAAW,cACXC,EAAe,6BACfC,EAAY,CACV,kBACA,WACA,SACA,UACF,EACAC,EAAY,4DACZC,EAAQ,CACN,IAAO,8CACT,EACAC,EAAc,CACZ,KAAQ,MACR,IAAO,gDACP,UAAa,+BACf,EACAC,EAAW,MACXC,EAAU,CACR,KAAQ,UACR,MAAS,0BACT,IAAO,yBACT,EACAC,EAAQ,SACRC,EAAW,CACT,IAAK,sBACL,WAAY,wBACZ,iBAAkB,gBACpB,EACAC,EAAQ,sBACRC,EAAS,wBACTC,EAAO,CACL,cAAe,oBACjB,EACAC,EAAS,CACP,KACF,EACAC,EAAW,CACT,MAAS,6BACT,OAAU,oDACV,MAAS,sCACT,MAAS,iDACX,EACAC,EAAgB,CACd,mBAAoB,cACpB,eAAgB,UAChB,IAAO,UACP,IAAO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AA4BN,EAAYL,EAAa,MAAM,CAAC,EAGhED,EAAe,YAAc,KAC/Ba,EAAO,KAAK,kBAAkB,EAC9B,MAAMC,EAAG,OAAOJ,EAAI,IAAI,MAAM,GAE5BV,EAAe,aAAe,KAChCa,EAAO,KAAK,mBAAmB,EAC/B,MAAMC,EAAG,OAAOJ,EAAI,IAAI,OAAO,GAGjC,MAAMK,EAAef,EAAe,OAChCgB,EAAK,KAAK,QAAQ,IAAI,EAAGhB,EAAe,MAAM,EAC9CgB,EAAK,KAAKN,EAAI,IAAI,OAAU,EAAA,YAAa,UAAU,EAGvD,MAAMI,EAAG,SAASC,CAAY,EAG9BF,EAAO,KAAK,6CAA6C,EAGzD,MAAMH,EAAI,KAAK,EAEfG,EAAO,KAAK,8BAA8B,EAG1C,MAAM,QAAQ,IACZH,EAAI,MAAM,IAAKO,GAAS,CACtB,MAAMrB,EAAc,GAAGsB,EAAkBlB,EAAe,QAAQ,CAAC,GAC/DU,EAAI,SAAS,IACf,GAAGS,EAAmBF,EAAK,IAAI,CAAC,GAC1BG,EAAeJ,EAAK,KACxBD,EACAI,EAAmBF,EAAK,KAAK,QAAQ,MAAO,aAAa,CAAC,CAC5D,EAEA,OAAOH,EACJ,UAAUE,EAAK,QAAQI,CAAY,CAAC,EACpC,KAAK,IAAMN,EAAG,UAAUM,EAAczB,EAAgBC,CAAW,CAAC,CAAC,CACxE,CAAC,CACH,CACF,CAAC,EAEHC,EAAI,QAAQ,EAAE,EAAE,OAAO,IAAM,CAC3BA,EAAI,WACN,CAAA,CAAC,EAEDA,EAAI,KAAK,EACTA,EAAI,QAAQwB,EAAI,OAAO,EAEvBxB,EAAI,MAAM"}
1
+ {"version":3,"file":"index.js","sources":["../../package.json","../../src/node/generate/getRedirectHTML.ts","../../src/cli/index.ts"],"sourcesContent":["{\n \"name\": \"@vuepress/plugin-redirect\",\n \"version\": \"2.0.0-rc.71\",\n \"description\": \"VuePress plugin - redirect\",\n \"keywords\": [\n \"vuepress-plugin\",\n \"vuepress\",\n \"plugin\",\n \"redirect\"\n ],\n \"homepage\": \"https://ecosystem.vuejs.press/plugins/tools/redirect.html\",\n \"bugs\": {\n \"url\": \"https://github.com/vuepress/ecosystem/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vuepress/ecosystem.git\",\n \"directory\": \"plugins/tools/plugin-redirect\"\n },\n \"license\": \"MIT\",\n \"author\": {\n \"name\": \"Mr.Hope\",\n \"email\": \"mister-hope@outlook.com\",\n \"url\": \"https://mister-hope.com\"\n },\n \"type\": \"module\",\n \"exports\": {\n \".\": \"./lib/node/index.js\",\n \"./client\": \"./lib/client/index.js\",\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./lib/node/index.js\",\n \"types\": \"./lib/node/index.d.ts\",\n \"bin\": {\n \"vp-redirect\": \"./lib/cli/index.js\"\n },\n \"files\": [\n \"lib\"\n ],\n \"scripts\": {\n \"build\": \"tsc -b tsconfig.build.json\",\n \"bundle\": \"rollup -c rollup.config.ts --configPlugin esbuild\",\n \"clean\": \"rimraf --glob ./lib ./*.tsbuildinfo\",\n \"style\": \"sass src:lib --embed-sources --style=compressed --pkg-importer=node\"\n },\n \"dependencies\": {\n \"@vuepress/helper\": \"workspace:*\",\n \"@vueuse/core\": \"^12.4.0\",\n \"commander\": \"^13.0.0\",\n \"vue\": \"^3.5.13\"\n },\n \"peerDependencies\": {\n \"vuepress\": \"2.0.0-rc.19\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export const getRedirectHTML = (redirectUrl: string): string => `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"robots\" content=\"noindex\">\n <meta http-equiv=\"refresh\" content=\"0; url=${redirectUrl}\">\n <link rel=\"canonical\" href=\"${redirectUrl}\">\n <title>Redirecting...</title>\n <script>\n const anchor = window.location.hash.substring(1);\n location.href = \\`${redirectUrl}\\${anchor? \\`#\\${anchor}\\`: \"\"}\\`;\n </script>\n</head>\n<body>\n <p>Redirecting...</p>\n</body>\n</html>\n`\n","#!/usr/bin/env node\nimport { removeEndingSlash, removeLeadingSlash } from '@vuepress/helper'\nimport { createCommand } from 'commander'\nimport {\n loadUserConfig,\n resolveAppConfig,\n resolveCliAppConfig,\n resolveUserConfigConventionalPath,\n resolveUserConfigPath,\n transformUserConfigToPlugin,\n} from 'vuepress/cli'\nimport { createBuildApp } from 'vuepress/core'\nimport { fs, logger, path } from 'vuepress/utils'\nimport pkg from '../../package.json' with { type: 'json' }\nimport { getRedirectHTML } from '../node/generate/getRedirectHTML.js'\n\ninterface RedirectCommandOptions {\n hostname: string\n config?: string\n cache?: string\n temp?: string\n cleanCache?: boolean\n cleanTemp?: boolean\n}\n\nconst program = createCommand('vp-redirect')\n\nprogram\n .summary('Generate redirect site')\n .description('Generate redirect site for current VuePress project')\n .option(\n '--hostname <hostname>',\n 'Hostname to redirect to (E.g.: https://new.example.com/)',\n '/',\n )\n .option('-c, --config [config]', 'Set path to config file')\n .option('--cache [cache]', 'Set the directory of the cache files')\n .option('--temp [temp]', 'Set the directory of the temporary files')\n .option('--clean-cache', 'Clean the cache files before generation')\n .option('--clean-temp', 'Clean the temporary files before generation')\n .argument('<source>', 'Source directory of VuePress project')\n .argument(\n '[output]',\n 'Output folder (default: .vuepress/redirect relative to source folder)',\n )\n .action(\n async (\n sourceDir: string,\n output: string | undefined,\n commandOptions: RedirectCommandOptions,\n ) => {\n // ensure NODE_ENV is set\n process.env.NODE_ENV ??= 'production'\n\n if (!fs.existsSync(sourceDir)) {\n program.error(`Source directory ${sourceDir} does not exist!`)\n }\n\n // resolve app config from cli options\n const cliAppConfig = resolveCliAppConfig(sourceDir, {})\n\n // resolve user config file\n const userConfigPath = commandOptions.config\n ? resolveUserConfigPath(commandOptions.config)\n : resolveUserConfigConventionalPath(cliAppConfig.source)\n\n const { userConfig } = await loadUserConfig(userConfigPath)\n\n // resolve the final app config to use\n const appConfig = resolveAppConfig({\n defaultAppConfig: {},\n cliAppConfig,\n userConfig,\n })\n\n if (appConfig === null) return\n\n // create vuepress app\n const app = createBuildApp(appConfig)\n\n // use user-config plugin\n app.use(transformUserConfigToPlugin(userConfig, cliAppConfig.source))\n\n // clean temp and cache\n if (commandOptions.cleanTemp === true) {\n logger.info('Cleaning temp...')\n await fs.remove(app.dir.temp())\n }\n if (commandOptions.cleanCache === true) {\n logger.info('Cleaning cache...')\n await fs.remove(app.dir.cache())\n }\n\n const outputFolder = output\n ? path.join(process.cwd(), output)\n : path.join(app.dir.source(), '.vuepress', 'redirect')\n\n // empty output directory\n await fs.emptyDir(outputFolder)\n\n // initialize vuepress app to get pages\n logger.info('Initializing VuePress and preparing data...')\n\n // initialize vuepress app to get pages\n await app.init()\n\n logger.info('Generating redirect pages...')\n\n // redirect all pages\n await Promise.all(\n app.pages.map((page) => {\n const redirectUrl = `${removeEndingSlash(commandOptions.hostname)}${\n app.siteData.base\n }${removeLeadingSlash(page.path)}`\n const destLocation = path.join(\n outputFolder,\n removeLeadingSlash(page.path.replace(/\\/$/, '/index.html')),\n )\n\n return fs\n .ensureDir(path.dirname(destLocation))\n .then(() =>\n fs.writeFile(destLocation, getRedirectHTML(redirectUrl)),\n )\n }),\n )\n },\n )\n\nprogram.version(pkg.version)\nprogram.showHelpAfterError('add --help for additional information')\n\nawait program.parseAsync()\n"],"names":["name","version","description","keywords","homepage","bugs","repository","license","author","type","exports","main","types","bin","files","scripts","dependencies","peerDependencies","publishConfig","package_default","getRedirectHTML","redirectUrl","program","createCommand","sourceDir","output","commandOptions","fs","cliAppConfig","resolveCliAppConfig","userConfigPath","resolveUserConfigPath","resolveUserConfigConventionalPath","userConfig","loadUserConfig","appConfig","resolveAppConfig","app","createBuildApp","transformUserConfigToPlugin","logger","outputFolder","path","page","removeEndingSlash","removeLeadingSlash","destLocation","pkg"],"mappings":";gaACE,IAAAA,EAAQ,4BACRC,EAAW,cACXC,EAAe,6BACfC,EAAY,CACV,kBACA,WACA,SACA,UACF,EACAC,EAAY,4DAC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QI,CAAY,CAAC,EACpC,KAAK,IACJnB,EAAG,UAAUmB,EAAc1B,EAAgBC,CAAW,CAAC,CACzD,CACJ,CAAC,CACH,CACF,CACF,EAEFC,EAAQ,QAAQyB,EAAI,OAAO,EAC3BzB,EAAQ,mBAAmB,uCAAuC,EAElE,MAAMA,EAAQ,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-redirect",
3
- "version": "2.0.0-rc.69",
3
+ "version": "2.0.0-rc.71",
4
4
  "description": "VuePress plugin - redirect",
5
5
  "keywords": [
6
6
  "vuepress-plugin",
@@ -38,9 +38,9 @@
38
38
  "lib"
39
39
  ],
40
40
  "dependencies": {
41
- "@vuepress/helper": "2.0.0-rc.69",
42
- "@vueuse/core": "^12.3.0",
43
- "cac": "^6.7.14",
41
+ "@vuepress/helper": "2.0.0-rc.71",
42
+ "@vueuse/core": "^12.4.0",
43
+ "commander": "^13.0.0",
44
44
  "vue": "^3.5.13"
45
45
  },
46
46
  "peerDependencies": {
@@ -49,5 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "ab0cb0e717d839b789be6a38721fd9a84caf9c37"
52
+ "gitHead": "564eceb25a8332d4c2090c5ca3863b8673935b7d"
53
53
  }