create-cloudflare 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. package/bin.js +1 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/bin.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const r=require("mri")(process.argv.slice(2),{alias:{v:"version",h:"help"},default:{init:!0,force:!1,debug:!1}});function e(r,e=1){e?process.stderr.write(r+"\n"):process.stdout.write(r+"\n"),process.exit(e)}if(r.help){let r="";r+="\n Usage",r+="\n npm init cloudflare <directory> <source> -- [options]",r+="\n pnpm create cloudflare <directory> <source> [options]",r+="\n yarn create cloudflare <directory> <source> [options]",r+="\n",r+="\n Sources",r+="\n • Example — A name or path to an official example subdirectory.",r+="\n Visit https://github.com/cloudflare/templates for options",r+="\n • URL — Any valid git repository address.",r+="\n [user@]host.xz:path/to/repo.git[#branch]",r+="\n git://host.xz[:port]/path/to/repo.git[#branch]",r+="\n ssh://[user@]host.xz[:port]/path/to/repo.git[#branch]",r+="\n http[s]://host.xz[:port]/path/to/repo.git[#branch]",r+="\n ftp[s]://host.xz[:port]/path/to/repo.git[#branch]",r+="\n",r+="\n Options",r+="\n --force Force overwrite target directory",r+="\n --no-init Do not initialize a git repository",r+="\n --debug Print additional error details",r+="\n --version, -v Displays current version",r+="\n --help, -h Displays this message",r+="\n",r+="\n Examples",r+="\n $ npm init cloudflare my-project pages/svelte-kit -- --debug",r+="\n $ yarn create cloudflare my-project workshops/intro-workers --force",r+="\n $ pnpm create cloudflare my-project https://github.com/user/repo.git#branch",r+="\n $ npm init cloudflare my-project https://github.com/user/repo.git",r+="\n",e(r,0)}if(r.version){let r=require("./package.json");e(`${r.name}, v${r.version}`,0)}!async function(){try{let[t,o]=r._;if(!t)return e("Missing <directory> argument",1);if(!o)return e("Missing <source> argument",1);await require(".").setup(t,o,r)}catch(r){e(r instanceof Error?r.stack||r.message:r,1)}}();
2
+ const e=require("mri")(process.argv.slice(2),{alias:{v:"version",h:"help"},default:{init:!0,force:!1,debug:!1}});function r(e,r=1){r?console.error("\n"+e+"\n"):console.log("\n"+e+"\n"),process.exit(r)}if(e.help){let e="";e+="\n Usage",e+="\n npm init cloudflare <directory> <source> -- [options]",e+="\n pnpm create cloudflare <directory> <source> [options]",e+="\n yarn create cloudflare <directory> <source> [options]",e+="\n",e+="\n Sources",e+="\n • Example — A name or path to an official example subdirectory.",e+="\n Visit https://github.com/cloudflare/templates for options",e+="\n • URL — Any valid git repository address.",e+="\n [user@]host.xz:path/to/repo.git[#branch]",e+="\n git://host.xz[:port]/path/to/repo.git[#branch]",e+="\n ssh://[user@]host.xz[:port]/path/to/repo.git[#branch]",e+="\n http[s]://host.xz[:port]/path/to/repo.git[#branch]",e+="\n ftp[s]://host.xz[:port]/path/to/repo.git[#branch]",e+="\n",e+="\n Options",e+="\n --force Force overwrite target directory",e+="\n --no-init Do not initialize a git repository",e+="\n --debug Print additional error details",e+="\n --version, -v Displays current version",e+="\n --help, -h Displays this message",e+="\n",e+="\n Examples",e+="\n $ npm init cloudflare my-project pages/svelte-kit -- --debug",e+="\n $ yarn create cloudflare my-project workshops/intro-workers --force",e+="\n $ pnpm create cloudflare my-project https://github.com/user/repo.git#branch",e+="\n $ npm init cloudflare my-project https://github.com/user/repo.git",e+="\n",r(e,0)}if(e.version){let e=require("./package.json");r(`${e.name}, v${e.version}`,0)}!async function(){try{let[t,o]=e._;if(!t)return r("Missing <directory> argument",1);if(!o)return r("Missing <source> argument",1);await require(".").setup(t,o,e)}catch(e){r(e instanceof Error?e.stack||e.message:e,1)}}();
package/index.js CHANGED
@@ -1 +1 @@
1
- const t = require('fs');const { tmpdir:r } = require('os');const { promisify:i } = require('util');const { join:e, relative:s } = require('path');const { exec:o } = require('child_process');const n = require('semiver');var a=i(o),c=t.existsSync;async function f(r){c(r)&&t.promises.rm(r,{recursive:!0})}var u=(...t)=>a(`git ${t.join(" ")}`),l=()=>Math.random().toString(16).substring(2),p=t=>/^(https?|ftps?|file|git|ssh):\/\//.test(t)||t.includes(":");async function h(i,o,h){let g=process.cwd();p(i)&&([i,o]=[o,i]);let m=e(g,i);if(c(m)){if(!h.force){let t=`Refusing to overwrite existing "${s(g,m)}" directory.\n`;throw t+="Please specify a different directory or use the `--force` flag.",t}m.startsWith(g)&&await f(m)}let d="",w="";p(o)?d=o:(d="https://github.com/cloudflare/templates.git",w=o),await async function(i,s,o){let c=["clone --depth 1"],{source:p,filter:h}=i,g=s,m=!1;function d(t,r){if(o.debug&&r&&r instanceof Error){let i=r.stack||r.message;t+="\n"+(i.includes("\n")?i.replace(/(\r?\n)/g,"$1 "):i)}throw t}try{var{stdout:w}=await u("version")}catch(t){return d("Missing `git` executable",t)}let[y]=/\d+.\d+.\d+/.exec(w)||[];if(!y)throw"Unknown `git` version";h&&(m=-1!==n(y,"2.26.0"),g=e(r(),l()+"-"+l()),m&&c.push("--filter=blob:none --sparse"));let b=p.lastIndexOf("#");-1===b?c.push(p):(c.push(`-b ${p.substring(b+1)}`),c.push(p.substring(0,b)));try{c.push(g),await u(...c)}catch(t){return d(`Error cloning "${p}" repository`,t)}if(h){if(m)try{await a(`git sparse-checkout set "${h}"`,{cwd:g})}catch(t){return d(`Error with "${h}" checkout`,t)}await t.promises.rename(e(g,h),s),await f(g)}if(await f(e(s,".git")),o.init){c=["init"],b=n(y,"2.26.0"),-1!==b&&c.push("-b main");try{await u(...c,s)}catch(t){return d("Error initializing repository",t)}}}({source:d,filter:w},m,h),console.log("Done~!")}exports.setup=h;
1
+ const t = require('fs');const { tmpdir:r } = require('os');const { promisify:i } = require('util');const { join:e, relative:s } = require('path');const { exec:o } = require('child_process');const n = require('semiver');var a=i(o),c=t.existsSync;async function u(r){c(r)&&t.promises.rm(r,{recursive:!0})}var f=(...t)=>a(`git ${t.join(" ")}`),l=()=>Math.random().toString(16).substring(2),p=t=>/^(https?|ftps?|file|git|ssh):\/\//.test(t)||t.includes(":");async function h(i,o,h){let g=process.cwd();p(i)&&([i,o]=[o,i]);let m=e(g,i);if(c(m)){if(!h.force){let t=`Refusing to overwrite existing "${s(g,m)}" directory.\n`;throw t+="Please specify a different directory or use the `--force` flag.",t}m.startsWith(g)&&await u(m)}let d="",w="";p(o)?d=o:(d="https://github.com/cloudflare/templates.git",w=o),await async function(i,s,o){let c=["clone --depth 1"],{source:p,filter:h}=i,g=s,m=!1;function d(t,r){if(o.debug&&r&&r instanceof Error){let i=r.stack||r.message;t+="\n"+(i.includes("\n")?i.replace(/(\r?\n)/g,"$1 "):i)}throw t}try{var{stdout:w}=await f("version")}catch(t){return d("Missing `git` executable",t)}let[y]=/\d+.\d+.\d+/.exec(w)||[];if(!y)throw"Unknown `git` version";h&&(m=-1!==n(y,"2.26.0"),g=e(r(),l()+"-"+l()),m&&c.push("--filter=blob:none --sparse"));let b=p.lastIndexOf("#");-1===b?c.push(p):(c.push(`-b ${p.substring(b+1)}`),c.push(p.substring(0,b)));try{c.push(g),await f(...c)}catch(t){return d(`Error cloning "${p}" repository`,t)}if(h){if(m)try{await a(`git sparse-checkout set "${h}"`,{cwd:g})}catch(t){return d(`Error with "${h}" checkout`,t)}await t.promises.rename(e(g,h),s),await u(g)}if(await u(e(s,".git")),o.init){c=["init"],b=n(y,"2.26.0"),-1!==b&&c.push("-b main");try{await f(...c,s)}catch(t){return d("Error initializing repository",t)}}}({source:d,filter:w},m,h),m=s(g,m),console.log(`\n Success 🎉\n Your "${m}" directory is ready for you~!\n`)}exports.setup=h;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.4",
2
+ "version": "0.0.5",
3
3
  "name": "create-cloudflare",
4
4
  "repository": "lukeed/create-cloudflare",
5
5
  "description": "Create new Cloudflare projects with one command",