create-shuvi 1.0.62 → 2.0.0-dev.4

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 (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -316,4 +316,4 @@ var n=r(4300);var i=n.Buffer;function copyProps(e,t){for(var r in e){t[r]=e[r]}}
316
316
  *
317
317
  * Copyright (c) 2015-2017, Jon Schlinkert.
318
318
  * Released under the MIT License.
319
- */e.exports=function base(e,t){if(!isObject(e)&&typeof e!=="function"){throw new TypeError("expected an object or function")}var r=isObject(t)?t:{};var n=typeof r.prop==="string"?r.prop:"fns";if(!Array.isArray(e[n])){define(e,n,[])}define(e,"use",use);define(e,"run",(function(t){if(!isObject(t))return;if(!t.use||!t.run){define(t,n,t[n]||[]);define(t,"use",use)}if(!t[n]||t[n].indexOf(base)===-1){t.use(base)}var r=this||e;var i=r[n];var s=i.length;var o=-1;while(++o<s){t.use(i[o])}return t}));function use(t,i,s){var o=1;if(typeof t==="string"||Array.isArray(t)){i=wrap(t,i);o++}else{s=i;i=t}if(typeof i!=="function"){throw new TypeError("expected a function")}var a=this||e;var c=a[n];var u=[].slice.call(arguments,o);u.unshift(a);if(typeof r.hook==="function"){r.hook.apply(a,u)}var l=i.apply(a,u);if(typeof l==="function"&&c.indexOf(l)===-1){c.push(l)}return a}function wrap(e,t){return function plugin(){return this.type===e?t.apply(this,arguments):plugin}}return e};function isObject(e){return e&&typeof e==="object"&&!Array.isArray(e)}function define(e,t,r){Object.defineProperty(e,t,{configurable:true,writable:true,value:r})}},2338:(e,t,r)=>{"use strict";var n=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var i=r(3113);var s=["node_modules","favicon.ico"];var o=e.exports=function(e){var t=[];var r=[];if(e===null){r.push("name cannot be null");return done(t,r)}if(e===undefined){r.push("name cannot be undefined");return done(t,r)}if(typeof e!=="string"){r.push("name must be a string");return done(t,r)}if(!e.length){r.push("name length must be greater than zero")}if(e.match(/^\./)){r.push("name cannot start with a period")}if(e.match(/^_/)){r.push("name cannot start with an underscore")}if(e.trim()!==e){r.push("name cannot contain leading or trailing spaces")}s.forEach((function(t){if(e.toLowerCase()===t){r.push(t+" is a blacklisted name")}}));i.forEach((function(r){if(e.toLowerCase()===r){t.push(r+" is a core module name")}}));if(e.length>214){t.push("name can no longer contain more than 214 characters")}if(e.toLowerCase()!==e){t.push("name can no longer contain capital letters")}if(/[~'!()*]/.test(e.split("/").slice(-1)[0])){t.push('name can no longer contain special characters ("~\'!()*")')}if(encodeURIComponent(e)!==e){var o=e.match(n);if(o){var a=o[1];var c=o[2];if(encodeURIComponent(a)===a&&encodeURIComponent(c)===c){return done(t,r)}}r.push("name can only contain URL-friendly characters")}return done(t,r)};o.scopedPackagePattern=n;var done=function(e,t){var r={validForNewPackages:t.length===0&&e.length===0,validForOldPackages:t.length===0,warnings:e,errors:t};if(!r.warnings.length)delete r.warnings;if(!r.errors.length)delete r.errors;return r}},9423:(e,t,r)=>{e.exports=which;which.sync=whichSync;var n=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";var i=r(1017);var s=n?";":":";var o=r(7745);function getNotFoundError(e){var t=new Error("not found: "+e);t.code="ENOENT";return t}function getPathInfo(e,t){var r=t.colon||s;var i=t.path||process.env.PATH||"";var o=[""];i=i.split(r);var a="";if(n){i.unshift(process.cwd());a=t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM";o=a.split(r);if(e.indexOf(".")!==-1&&o[0]!=="")o.unshift("")}if(e.match(/\//)||n&&e.match(/\\/))i=[""];return{env:i,ext:o,extExe:a}}function which(e,t,r){if(typeof t==="function"){r=t;t={}}var n=getPathInfo(e,t);var s=n.env;var a=n.ext;var c=n.extExe;var u=[];(function F(n,l){if(n===l){if(t.all&&u.length)return r(null,u);else return r(getNotFoundError(e))}var h=s[n];if(h.charAt(0)==='"'&&h.slice(-1)==='"')h=h.slice(1,-1);var p=i.join(h,e);if(!h&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}(function E(e,i){if(e===i)return F(n+1,l);var s=a[e];o(p+s,{pathExt:c},(function(n,o){if(!n&&o){if(t.all)u.push(p+s);else return r(null,p+s)}return E(e+1,i)}))})(0,a.length)})(0,s.length)}function whichSync(e,t){t=t||{};var r=getPathInfo(e,t);var n=r.env;var s=r.ext;var a=r.extExe;var c=[];for(var u=0,l=n.length;u<l;u++){var h=n[u];if(h.charAt(0)==='"'&&h.slice(-1)==='"')h=h.slice(1,-1);var p=i.join(h,e);if(!h&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}for(var d=0,m=s.length;d<m;d++){var y=p+s[d];var g;try{g=o.sync(y,{pathExt:a});if(g){if(t.all)c.push(y);else return y}}catch(e){}}}if(t.all&&c.length)return c;if(t.nothrow)return null;throw getNotFoundError(e)}},3270:e=>{e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach((function(t){wrapper[t]=e[t]}));return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];if(typeof n==="function"&&n!==i){Object.keys(i).forEach((function(e){n[e]=i[e]}))}return n}}},8076:e=>{"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next){yield e.value}}}},1190:(e,t,r)=>{"use strict";e.exports=Yallist;Yallist.Node=Node;Yallist.create=Yallist;function Yallist(e){var t=this;if(!(t instanceof Yallist)){t=new Yallist}t.tail=null;t.head=null;t.length=0;if(e&&typeof e.forEach==="function"){e.forEach((function(e){t.push(e)}))}else if(arguments.length>0){for(var r=0,n=arguments.length;r<n;r++){t.push(arguments[r])}}return t}Yallist.prototype.removeNode=function(e){if(e.list!==this){throw new Error("removing node which does not belong to this list")}var t=e.next;var r=e.prev;if(t){t.prev=r}if(r){r.next=t}if(e===this.head){this.head=t}if(e===this.tail){this.tail=r}e.list.length--;e.next=null;e.prev=null;e.list=null;return t};Yallist.prototype.unshiftNode=function(e){if(e===this.head){return}if(e.list){e.list.removeNode(e)}var t=this.head;e.list=this;e.next=t;if(t){t.prev=e}this.head=e;if(!this.tail){this.tail=e}this.length++};Yallist.prototype.pushNode=function(e){if(e===this.tail){return}if(e.list){e.list.removeNode(e)}var t=this.tail;e.list=this;e.prev=t;if(t){t.next=e}this.tail=e;if(!this.head){this.head=e}this.length++};Yallist.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++){push(this,arguments[e])}return this.length};Yallist.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++){unshift(this,arguments[e])}return this.length};Yallist.prototype.pop=function(){if(!this.tail){return undefined}var e=this.tail.value;this.tail=this.tail.prev;if(this.tail){this.tail.next=null}else{this.head=null}this.length--;return e};Yallist.prototype.shift=function(){if(!this.head){return undefined}var e=this.head.value;this.head=this.head.next;if(this.head){this.head.prev=null}else{this.tail=null}this.length--;return e};Yallist.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;r!==null;n++){e.call(t,r.value,n,this);r=r.next}};Yallist.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;r!==null;n--){e.call(t,r.value,n,this);r=r.prev}};Yallist.prototype.get=function(e){for(var t=0,r=this.head;r!==null&&t<e;t++){r=r.next}if(t===e&&r!==null){return r.value}};Yallist.prototype.getReverse=function(e){for(var t=0,r=this.tail;r!==null&&t<e;t++){r=r.prev}if(t===e&&r!==null){return r.value}};Yallist.prototype.map=function(e,t){t=t||this;var r=new Yallist;for(var n=this.head;n!==null;){r.push(e.call(t,n.value,this));n=n.next}return r};Yallist.prototype.mapReverse=function(e,t){t=t||this;var r=new Yallist;for(var n=this.tail;n!==null;){r.push(e.call(t,n.value,this));n=n.prev}return r};Yallist.prototype.reduce=function(e,t){var r;var n=this.head;if(arguments.length>1){r=t}else if(this.head){n=this.head.next;r=this.head.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var i=0;n!==null;i++){r=e(r,n.value,i);n=n.next}return r};Yallist.prototype.reduceReverse=function(e,t){var r;var n=this.tail;if(arguments.length>1){r=t}else if(this.tail){n=this.tail.prev;r=this.tail.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var i=this.length-1;n!==null;i--){r=e(r,n.value,i);n=n.prev}return r};Yallist.prototype.toArray=function(){var e=new Array(this.length);for(var t=0,r=this.head;r!==null;t++){e[t]=r.value;r=r.next}return e};Yallist.prototype.toArrayReverse=function(){var e=new Array(this.length);for(var t=0,r=this.tail;r!==null;t++){e[t]=r.value;r=r.prev}return e};Yallist.prototype.slice=function(e,t){t=t||this.length;if(t<0){t+=this.length}e=e||0;if(e<0){e+=this.length}var r=new Yallist;if(t<e||t<0){return r}if(e<0){e=0}if(t>this.length){t=this.length}for(var n=0,i=this.head;i!==null&&n<e;n++){i=i.next}for(;i!==null&&n<t;n++,i=i.next){r.push(i.value)}return r};Yallist.prototype.sliceReverse=function(e,t){t=t||this.length;if(t<0){t+=this.length}e=e||0;if(e<0){e+=this.length}var r=new Yallist;if(t<e||t<0){return r}if(e<0){e=0}if(t>this.length){t=this.length}for(var n=this.length,i=this.tail;i!==null&&n>t;n--){i=i.prev}for(;i!==null&&n>e;n--,i=i.prev){r.push(i.value)}return r};Yallist.prototype.splice=function(e,t){if(e>this.length){e=this.length-1}if(e<0){e=this.length+e}for(var r=0,n=this.head;n!==null&&r<e;r++){n=n.next}var i=[];for(var r=0;n&&r<t;r++){i.push(n.value);n=this.removeNode(n)}if(n===null){n=this.tail}if(n!==this.head&&n!==this.tail){n=n.prev}for(var r=2;r<arguments.length;r++){n=insert(this,n,arguments[r])}return i};Yallist.prototype.reverse=function(){var e=this.head;var t=this.tail;for(var r=e;r!==null;r=r.prev){var n=r.prev;r.prev=r.next;r.next=n}this.head=t;this.tail=e;return this};function insert(e,t,r){var n=t===e.head?new Node(r,null,t,e):new Node(r,t,t.next,e);if(n.next===null){e.tail=n}if(n.prev===null){e.head=n}e.length++;return n}function push(e,t){e.tail=new Node(t,e.tail,null,e);if(!e.head){e.head=e.tail}e.length++}function unshift(e,t){e.head=new Node(t,null,e.head,e);if(!e.tail){e.tail=e.head}e.length++}function Node(e,t,r,n){if(!(this instanceof Node)){return new Node(e,t,r,n)}this.list=n;this.value=e;if(t){t.next=this;this.prev=t}else{this.prev=null}if(r){r.prev=this;this.next=r}else{this.next=null}}try{r(8076)(Yallist)}catch(e){}},3348:(e,t,r)=>{"use strict";r.r(t);var n=r(6148);var i=r.n(n);var s=r(4101);var o=r.n(s);var a=r(1017);var c=r.n(a);var u=r(9966);var l=r.n(u);var h=r(5656);var p=r.n(h);var d=r(3493);var m=r.n(d);var y=r(5165);var g=r.n(y);var v=r(7147);var b=r.n(v);var w=r(2037);var S=r.n(w);var x=r(9312);var _=r.n(x);var O=r(7697);var k=r(2781);var R=r(3837);const A=(0,R.promisify)(k.Stream.pipeline);async function isUrlOk(e){const t=await _().head(e).catch((e=>e));return t.statusCode===200}async function getRepoInfo(e,t){const[,r,n,i,s,...o]=e.pathname.split("/");const a=t?t.replace(/^\//,""):o.join("/");if(i===undefined||i===""&&s===undefined){const e=await _()(`https://api.github.com/repos/${r}/${n}`).catch((e=>e));if(e.statusCode!==200){return}const t=JSON.parse(e.body);return{username:r,name:n,branch:t["default_branch"],filePath:a}}const c=t?`${s}/${o.join("/")}`.replace(new RegExp(`/${a}|/$`),""):s;if(r&&n&&c&&i==="tree"){return{username:r,name:n,branch:c,filePath:a}}}function hasRepo({username:e,name:t,branch:r,filePath:n}){const i=`https://api.github.com/repos/${e}/${t}/contents`;const s=`${n?`/${n}`:""}/package.json`;return isUrlOk(i+s+`?ref=${r}`)}function existsInRepo(e){try{const t=new URL(e);return isUrlOk(t.href)}catch{return isUrlOk(`https://api.github.com/repos/shuvijs/shuvi/contents/examples/${encodeURIComponent(e)}`)}}function downloadAndExtractRepo(e,{username:t,name:r,branch:n,filePath:i}){return A(_().stream(`https://codeload.github.com/${t}/${r}/tar.gz/${n}`),O.extract({cwd:e,strip:i?i.split("/").length+1:1},[`${r}-${n.replace(/\//g,"-")}${i?`/${i}`:""}`]))}function downloadAndExtractExample(e,t){if(t==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}return A(_().stream("https://codeload.github.com/shuvijs/shuvi/tar.gz/main"),O.extract({cwd:e,strip:3},[`shuvi-main/examples/${t}`]))}function makeDir(e,t={recursive:true}){return b().promises.mkdir(e,t)}var C=r(2081);var P=r(4700);var T=r.n(P);function isInGitRepository(){try{(0,C.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(e){}return false}function isInMercurialRepository(){try{(0,C.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(e){}return false}function tryGitInit(e){let t=false;try{(0,C.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,C.execSync)("git init",{stdio:"ignore"});t=true;(0,C.execSync)("git checkout -b main",{stdio:"ignore"});(0,C.execSync)("git add -A",{stdio:"ignore"});(0,C.execSync)('git commit -m "Initial commit from Create Shuvi App"',{stdio:"ignore"});return true}catch(r){if(t){try{T().sync(c().join(e,".git"))}catch(e){}}return false}}var M=r(9321);var j=r.n(M);function install(e,t,{packageManager:r,isOnline:n,devDependencies:s}){const o=[];const a=[];return new Promise(((c,u)=>{let l;let h=r;const p=r==="yarn";if(t&&t.length){if(p){l=["add","--exact"];if(!n)l.push("--offline");l.push("--cwd",e);if(s)l.push("--dev");l.push(...t)}else{l=["install","--save-exact"];l.push(s?"--save-dev":"--save");l.push(...t)}}else{l=["install"];if(!n){console.log(i().yellow("You appear to be offline."));if(p){console.log(i().yellow("Falling back to the local Yarn cache."));console.log();l.push("--offline")}else{console.log()}}}if(p){l.push(...a)}else{l.push(...o)}const d=j()(h,l,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});d.on("close",(e=>{if(e!==0){u({command:`${h} ${l.join(" ")}`});return}c()}))}))}function isFolderEmpty(e,t){const r=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log","yarnrc.yml",".yarn"];const n=b().readdirSync(e).filter((e=>!r.includes(e))).filter((e=>!/\.iml$/.test(e)));if(n.length>0){console.log(`The directory ${i().green(t)} contains files that could conflict:`);console.log();for(const t of n){try{const r=b().lstatSync(c().join(e,t));if(r.isDirectory()){console.log(` ${i().blue(t)}/`)}else{console.log(` ${t}`)}}catch{console.log(` ${t}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}var I=r(9523);var N=r.n(I);var D=r(7310);var L=r.n(D);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const e=(0,C.execSync)("npm config get https-proxy").toString().trim();return e!=="null"?e:undefined}catch(e){return}}function getOnline(){return new Promise((e=>{N().lookup("registry.yarnpkg.com",(t=>{if(!t){return e(true)}const r=getProxy();if(!r){return e(false)}const{hostname:n}=L().parse(r);if(!n){return e(false)}N().lookup(n,(t=>{e(t==null)}))}))}))}async function isWriteable(e){try{await b().promises.access(e,(b().constants||b()).W_OK);return true}catch(e){return false}}class DownloadError extends Error{}async function createApp({appPath:e,packageManager:t,example:n,examplePath:s,typescript:o}){let a;const u=o?"typescript":"default";if(n){let e;try{e=new URL(n)}catch(e){if(e.code!=="ERR_INVALID_URL"){console.error(e);process.exit(1)}}if(e){if(e.origin!=="https://github.com"){console.error(`Invalid URL: ${i().red(`"${n}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}a=await getRepoInfo(e,s);if(!a){console.error(`Found invalid GitHub URL: ${i().red(`"${n}"`)}. Please fix the URL and try again.`);process.exit(1)}const t=await hasRepo(a);if(!t){console.error(`Could not locate the repository for ${i().red(`"${n}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(n!=="__internal-testing-retry"){const e=await existsInRepo(n);if(!e){console.error(`Could not locate an example named ${i().red(`"${n}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${i().red(`"${n}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const l=c().resolve(e);if(!await isWriteable(c().dirname(l))){console.error("The application path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const h=c().basename(l);await makeDir(l);if(!isFolderEmpty(l,h)){process.exit(1)}const p=t==="yarn";const d=!p||await getOnline();const y=process.cwd();console.log(`Creating a new Shuvi.js app in ${i().green(l)}.`);console.log();process.chdir(l);const v=c().join(l,"package.json");let w=false;if(n){try{if(a){const e=a;console.log(`Downloading files from repo ${i().cyan(n)}. This might take a moment.`);console.log();await m()((()=>downloadAndExtractRepo(l,e)),{retries:3})}else{console.log(`Downloading files for example ${i().cyan(n)}. This might take a moment.`);console.log();await m()((()=>downloadAndExtractExample(l,n)),{retries:3})}}catch(e){function isErrorLike(e){return typeof e==="object"&&e!==null&&typeof e.message==="string"}throw new DownloadError(isErrorLike(e)?e.message:e+"")}const e=c().join(l,".gitignore");if(!b().existsSync(e)){b().copyFileSync(r.ab+"templates/"+u+"/gitignore",e)}w=b().existsSync(v);if(w){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(l,null,{packageManager:t,isOnline:d});console.log()}}else{console.log(i().bold(`Using ${t}.`));const e={name:h,version:"0.1.0",private:true,scripts:{dev:"shuvi dev",build:"shuvi build",serve:"shuvi serve"}};b().writeFileSync(c().join(l,"package.json"),JSON.stringify(e,null,2)+S().EOL);const n={packageManager:t,isOnline:d};const s=["shuvi@next"];const a=[];if(o){a.push("typescript","@types/react","@types/node","@types/react-dom")}if(s.length){console.log();console.log("Installing dependencies:");for(const e of s){console.log(`- ${i().cyan(e)}`)}console.log();await install(l,s,n)}if(a.length){console.log();console.log("Installing devDependencies:");for(const e of a){console.log(`- ${i().cyan(e)}`)}console.log();const e={devDependencies:true,...n};await install(l,a,e)}console.log();await g()("**",l,{parents:true,cwd:r.ab+"templates/"+u,rename:e=>{switch(e){case"gitignore":case"eslintrc.json":{return".".concat(e)}case"README-template.md":{return"README.md"}default:{return e}}}})}if(tryGitInit(l)){console.log("Initialized a git repository.");console.log()}let x;if(c().join(y,h)===e){x=h}else{x=e}console.log(`${i().green("Success!")} Created ${h} at ${e}`);if(w){console.log("Inside that directory, you can run several commands:");console.log();console.log(i().cyan(` ${t} ${p?"":"run "}dev`));console.log(" Starts the development server.");console.log();console.log(i().cyan(` ${t} ${p?"":"run "}build`));console.log(" Builds the app for production.");console.log();console.log(i().cyan(` ${t} serve`));console.log(" Runs the built app in production mode.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(i().cyan(" cd"),x);console.log(` ${i().cyan(`${t} ${p?"":"run "}dev`)}`)}console.log()}function getPkgManager(){try{const e=process.env.npm_config_user_agent;if(e){if(e.startsWith("yarn")){return"yarn"}else if(e.startsWith("pnpm")){return"pnpm"}}try{(0,C.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,C.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var $=r(2338);var B=r.n($);function validateNpmName(e){const t=B()(e);if(t.validForNewPackages){return{valid:true}}return{valid:false,problems:[...t.errors||[],...t.warnings||[]]}}const G=JSON.parse('{"name":"create-shuvi","version":"1.0.62","keywords":["react","shuvi","shuvi.js"],"description":"Create Shuvi.js-powered React apps with one command","license":"MIT","bin":{"create-shuvi":"./dist/index.js"},"files":["dist"],"scripts":{"dev":"ncc build ./index.ts -w -o dist/","prebuild":"rimraf ./dist/","build":"ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register"},"devDependencies":{"@types/async-retry":"1.3.0","@types/cross-spawn":"6.0.0","@types/node":"^12.6.8","@types/prompts":"2.0.1","@types/rimraf":"3.0.0","@types/tar":"4.0.3","@types/validate-npm-package-name":"3.0.0","@vercel/ncc":"0.34.0","async-retry":"1.3.3","chalk":"2.4.2","commander":"2.20.0","cpy":"7.3.0","cross-spawn":"6.0.5","got":"10.7.0","prompts":"2.1.0","rimraf":"3.0.2","tar":"4.4.10","update-check":"1.5.4","validate-npm-package-name":"3.0.0"},"engines":{"node":">=12.0.0"}}');let U="";let z=undefined;const q=new(o().Command)(G.name).version(G.version).arguments("<project-directory>").usage(`${i().green("<project-directory>")} [options]`).action((e=>{U=e})).option("--ts, --typescript",`\n\n Initialize as a TypeScript project.\n`).option("--use-npm",`\n\n Explicitly tell the CLI to bootstrap the app using npm\n`).option("--use-pnpm",`\n\n Explicitly tell the CLI to bootstrap the app using pnpm\n`).option("-e, --example [name]|[github-url]",`\n\n An example to bootstrap the app with. You can use an example name\n from the official Shuvi.js repo or a GitHub URL. The URL can use\n any branch and/or subdirectory\n`).option("--example-path <path-to-example>",`\n\n In a rare case, your GitHub URL might contain a branch name with\n a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).\n In this case, you must specify the path to the example separately:\n --example-path foo/bar\n`).allowUnknownOption().parse(process.argv);async function run(){if(typeof U==="string"){U=U.trim()}if(!U){const e=await l()({type:"text",name:"path",message:"What is your project named?",initial:"my-app",validate:e=>{const t=validateNpmName(c().basename(c().resolve(e)));if(t.valid){return true}return"Invalid project name: "+t.problems[0]}});if(typeof e.path==="string"){U=e.path.trim()}}if(!U){console.log("\nPlease specify the project directory:\n"+` ${i().cyan(q.name())} ${i().green("<project-directory>")}\n`+"For example:\n"+` ${i().cyan(q.name())} ${i().green("my-shuvi-app")}\n\n`+`Run ${i().cyan(`${q.name()} --help`)} to see all options.`);process.exit(1)}z=q.typescript;if(z===undefined){const e=await l()({type:"toggle",name:"typescript",message:"Add Typescript?",initial:false,active:"Yes",inactive:"No"});z=e.typescript}const e=c().resolve(U);const t=c().basename(e);const{valid:r,problems:n}=validateNpmName(t);if(!r){console.error(`Could not create a project called ${i().red(`"${t}"`)} because of npm naming restrictions:`);n.forEach((e=>console.error(` ${i().red.bold("*")} ${e}`)));process.exit(1)}if(q.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}const s=!!q.useNpm?"npm":!!q.usePnpm?"pnpm":getPkgManager();const o=typeof q.example==="string"&&q.example.trim();try{await createApp({appPath:e,packageManager:s,example:o&&o!=="default"?o:undefined,examplePath:q.examplePath,typescript:z})}catch(t){if(!(t instanceof DownloadError)){throw t}const r=await l()({type:"confirm",name:"builtin",message:`Could not download "${o}" because of a connectivity issue between your machine and GitHub.\n`+`Do you want to use the default template instead?`,initial:true});if(!r.builtin){throw t}await createApp({appPath:e,packageManager:s,typescript:q.typescript})}}const H=p()(G).catch((()=>null));async function notifyUpdate(){try{const e=await H;if(e===null||e===void 0?void 0:e.latest){const e=getPkgManager();console.log(i().yellow.bold("A new version of `create-shuvi` is available!")+"\n"+"You can update by running: "+i().cyan(e==="yarn"?"yarn global add create-shuvi":`${e} install --global create-shuvi`)+"\n")}process.exit()}catch{}}run().then(notifyUpdate).catch((async e=>{console.log();console.log("Aborting installation.");if(e.command){console.log(` ${i().cyan(e.command)} has failed.`)}else{console.log(i().red("Unexpected error. Please report it as a bug:")+"\n",e)}console.log();await notifyUpdate();process.exit(1)}))},9491:e=>{"use strict";e.exports=require("assert")},4300:e=>{"use strict";e.exports=require("buffer")},2081:e=>{"use strict";e.exports=require("child_process")},1071:e=>{"use strict";e.exports=require("constants")},6113:e=>{"use strict";e.exports=require("crypto")},9523:e=>{"use strict";e.exports=require("dns")},2361:e=>{"use strict";e.exports=require("events")},7147:e=>{"use strict";e.exports=require("fs")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},4521:e=>{"use strict";e.exports=require("readline")},2781:e=>{"use strict";e.exports=require("stream")},1576:e=>{"use strict";e.exports=require("string_decoder")},6224:e=>{"use strict";e.exports=require("tty")},7310:e=>{"use strict";e.exports=require("url")},3837:e=>{"use strict";e.exports=require("util")},9796:e=>{"use strict";e.exports=require("zlib")},3113:e=>{"use strict";e.exports=JSON.parse('["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","process","punycode","querystring","readline","repl","stream","string_decoder","timers","tls","tty","url","util","v8","vm","zlib"]')}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={id:r,loaded:false,exports:{}};var s=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}i.loaded=true;return i.exports}(()=>{__nccwpck_require__.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;__nccwpck_require__.d(t,{a:t});return t}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();(()=>{__nccwpck_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(3348);module.exports=r})();
319
+ */e.exports=function base(e,t){if(!isObject(e)&&typeof e!=="function"){throw new TypeError("expected an object or function")}var r=isObject(t)?t:{};var n=typeof r.prop==="string"?r.prop:"fns";if(!Array.isArray(e[n])){define(e,n,[])}define(e,"use",use);define(e,"run",(function(t){if(!isObject(t))return;if(!t.use||!t.run){define(t,n,t[n]||[]);define(t,"use",use)}if(!t[n]||t[n].indexOf(base)===-1){t.use(base)}var r=this||e;var i=r[n];var s=i.length;var o=-1;while(++o<s){t.use(i[o])}return t}));function use(t,i,s){var o=1;if(typeof t==="string"||Array.isArray(t)){i=wrap(t,i);o++}else{s=i;i=t}if(typeof i!=="function"){throw new TypeError("expected a function")}var a=this||e;var c=a[n];var u=[].slice.call(arguments,o);u.unshift(a);if(typeof r.hook==="function"){r.hook.apply(a,u)}var l=i.apply(a,u);if(typeof l==="function"&&c.indexOf(l)===-1){c.push(l)}return a}function wrap(e,t){return function plugin(){return this.type===e?t.apply(this,arguments):plugin}}return e};function isObject(e){return e&&typeof e==="object"&&!Array.isArray(e)}function define(e,t,r){Object.defineProperty(e,t,{configurable:true,writable:true,value:r})}},2338:(e,t,r)=>{"use strict";var n=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var i=r(3113);var s=["node_modules","favicon.ico"];var o=e.exports=function(e){var t=[];var r=[];if(e===null){r.push("name cannot be null");return done(t,r)}if(e===undefined){r.push("name cannot be undefined");return done(t,r)}if(typeof e!=="string"){r.push("name must be a string");return done(t,r)}if(!e.length){r.push("name length must be greater than zero")}if(e.match(/^\./)){r.push("name cannot start with a period")}if(e.match(/^_/)){r.push("name cannot start with an underscore")}if(e.trim()!==e){r.push("name cannot contain leading or trailing spaces")}s.forEach((function(t){if(e.toLowerCase()===t){r.push(t+" is a blacklisted name")}}));i.forEach((function(r){if(e.toLowerCase()===r){t.push(r+" is a core module name")}}));if(e.length>214){t.push("name can no longer contain more than 214 characters")}if(e.toLowerCase()!==e){t.push("name can no longer contain capital letters")}if(/[~'!()*]/.test(e.split("/").slice(-1)[0])){t.push('name can no longer contain special characters ("~\'!()*")')}if(encodeURIComponent(e)!==e){var o=e.match(n);if(o){var a=o[1];var c=o[2];if(encodeURIComponent(a)===a&&encodeURIComponent(c)===c){return done(t,r)}}r.push("name can only contain URL-friendly characters")}return done(t,r)};o.scopedPackagePattern=n;var done=function(e,t){var r={validForNewPackages:t.length===0&&e.length===0,validForOldPackages:t.length===0,warnings:e,errors:t};if(!r.warnings.length)delete r.warnings;if(!r.errors.length)delete r.errors;return r}},9423:(e,t,r)=>{e.exports=which;which.sync=whichSync;var n=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";var i=r(1017);var s=n?";":":";var o=r(7745);function getNotFoundError(e){var t=new Error("not found: "+e);t.code="ENOENT";return t}function getPathInfo(e,t){var r=t.colon||s;var i=t.path||process.env.PATH||"";var o=[""];i=i.split(r);var a="";if(n){i.unshift(process.cwd());a=t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM";o=a.split(r);if(e.indexOf(".")!==-1&&o[0]!=="")o.unshift("")}if(e.match(/\//)||n&&e.match(/\\/))i=[""];return{env:i,ext:o,extExe:a}}function which(e,t,r){if(typeof t==="function"){r=t;t={}}var n=getPathInfo(e,t);var s=n.env;var a=n.ext;var c=n.extExe;var u=[];(function F(n,l){if(n===l){if(t.all&&u.length)return r(null,u);else return r(getNotFoundError(e))}var h=s[n];if(h.charAt(0)==='"'&&h.slice(-1)==='"')h=h.slice(1,-1);var p=i.join(h,e);if(!h&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}(function E(e,i){if(e===i)return F(n+1,l);var s=a[e];o(p+s,{pathExt:c},(function(n,o){if(!n&&o){if(t.all)u.push(p+s);else return r(null,p+s)}return E(e+1,i)}))})(0,a.length)})(0,s.length)}function whichSync(e,t){t=t||{};var r=getPathInfo(e,t);var n=r.env;var s=r.ext;var a=r.extExe;var c=[];for(var u=0,l=n.length;u<l;u++){var h=n[u];if(h.charAt(0)==='"'&&h.slice(-1)==='"')h=h.slice(1,-1);var p=i.join(h,e);if(!h&&/^\.[\\\/]/.test(e)){p=e.slice(0,2)+p}for(var d=0,m=s.length;d<m;d++){var y=p+s[d];var g;try{g=o.sync(y,{pathExt:a});if(g){if(t.all)c.push(y);else return y}}catch(e){}}}if(t.all&&c.length)return c;if(t.nothrow)return null;throw getNotFoundError(e)}},3270:e=>{e.exports=wrappy;function wrappy(e,t){if(e&&t)return wrappy(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach((function(t){wrapper[t]=e[t]}));return wrapper;function wrapper(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];if(typeof n==="function"&&n!==i){Object.keys(i).forEach((function(e){n[e]=i[e]}))}return n}}},8076:e=>{"use strict";e.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next){yield e.value}}}},1190:(e,t,r)=>{"use strict";e.exports=Yallist;Yallist.Node=Node;Yallist.create=Yallist;function Yallist(e){var t=this;if(!(t instanceof Yallist)){t=new Yallist}t.tail=null;t.head=null;t.length=0;if(e&&typeof e.forEach==="function"){e.forEach((function(e){t.push(e)}))}else if(arguments.length>0){for(var r=0,n=arguments.length;r<n;r++){t.push(arguments[r])}}return t}Yallist.prototype.removeNode=function(e){if(e.list!==this){throw new Error("removing node which does not belong to this list")}var t=e.next;var r=e.prev;if(t){t.prev=r}if(r){r.next=t}if(e===this.head){this.head=t}if(e===this.tail){this.tail=r}e.list.length--;e.next=null;e.prev=null;e.list=null;return t};Yallist.prototype.unshiftNode=function(e){if(e===this.head){return}if(e.list){e.list.removeNode(e)}var t=this.head;e.list=this;e.next=t;if(t){t.prev=e}this.head=e;if(!this.tail){this.tail=e}this.length++};Yallist.prototype.pushNode=function(e){if(e===this.tail){return}if(e.list){e.list.removeNode(e)}var t=this.tail;e.list=this;e.prev=t;if(t){t.next=e}this.tail=e;if(!this.head){this.head=e}this.length++};Yallist.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++){push(this,arguments[e])}return this.length};Yallist.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++){unshift(this,arguments[e])}return this.length};Yallist.prototype.pop=function(){if(!this.tail){return undefined}var e=this.tail.value;this.tail=this.tail.prev;if(this.tail){this.tail.next=null}else{this.head=null}this.length--;return e};Yallist.prototype.shift=function(){if(!this.head){return undefined}var e=this.head.value;this.head=this.head.next;if(this.head){this.head.prev=null}else{this.tail=null}this.length--;return e};Yallist.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;r!==null;n++){e.call(t,r.value,n,this);r=r.next}};Yallist.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;r!==null;n--){e.call(t,r.value,n,this);r=r.prev}};Yallist.prototype.get=function(e){for(var t=0,r=this.head;r!==null&&t<e;t++){r=r.next}if(t===e&&r!==null){return r.value}};Yallist.prototype.getReverse=function(e){for(var t=0,r=this.tail;r!==null&&t<e;t++){r=r.prev}if(t===e&&r!==null){return r.value}};Yallist.prototype.map=function(e,t){t=t||this;var r=new Yallist;for(var n=this.head;n!==null;){r.push(e.call(t,n.value,this));n=n.next}return r};Yallist.prototype.mapReverse=function(e,t){t=t||this;var r=new Yallist;for(var n=this.tail;n!==null;){r.push(e.call(t,n.value,this));n=n.prev}return r};Yallist.prototype.reduce=function(e,t){var r;var n=this.head;if(arguments.length>1){r=t}else if(this.head){n=this.head.next;r=this.head.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var i=0;n!==null;i++){r=e(r,n.value,i);n=n.next}return r};Yallist.prototype.reduceReverse=function(e,t){var r;var n=this.tail;if(arguments.length>1){r=t}else if(this.tail){n=this.tail.prev;r=this.tail.value}else{throw new TypeError("Reduce of empty list with no initial value")}for(var i=this.length-1;n!==null;i--){r=e(r,n.value,i);n=n.prev}return r};Yallist.prototype.toArray=function(){var e=new Array(this.length);for(var t=0,r=this.head;r!==null;t++){e[t]=r.value;r=r.next}return e};Yallist.prototype.toArrayReverse=function(){var e=new Array(this.length);for(var t=0,r=this.tail;r!==null;t++){e[t]=r.value;r=r.prev}return e};Yallist.prototype.slice=function(e,t){t=t||this.length;if(t<0){t+=this.length}e=e||0;if(e<0){e+=this.length}var r=new Yallist;if(t<e||t<0){return r}if(e<0){e=0}if(t>this.length){t=this.length}for(var n=0,i=this.head;i!==null&&n<e;n++){i=i.next}for(;i!==null&&n<t;n++,i=i.next){r.push(i.value)}return r};Yallist.prototype.sliceReverse=function(e,t){t=t||this.length;if(t<0){t+=this.length}e=e||0;if(e<0){e+=this.length}var r=new Yallist;if(t<e||t<0){return r}if(e<0){e=0}if(t>this.length){t=this.length}for(var n=this.length,i=this.tail;i!==null&&n>t;n--){i=i.prev}for(;i!==null&&n>e;n--,i=i.prev){r.push(i.value)}return r};Yallist.prototype.splice=function(e,t){if(e>this.length){e=this.length-1}if(e<0){e=this.length+e}for(var r=0,n=this.head;n!==null&&r<e;r++){n=n.next}var i=[];for(var r=0;n&&r<t;r++){i.push(n.value);n=this.removeNode(n)}if(n===null){n=this.tail}if(n!==this.head&&n!==this.tail){n=n.prev}for(var r=2;r<arguments.length;r++){n=insert(this,n,arguments[r])}return i};Yallist.prototype.reverse=function(){var e=this.head;var t=this.tail;for(var r=e;r!==null;r=r.prev){var n=r.prev;r.prev=r.next;r.next=n}this.head=t;this.tail=e;return this};function insert(e,t,r){var n=t===e.head?new Node(r,null,t,e):new Node(r,t,t.next,e);if(n.next===null){e.tail=n}if(n.prev===null){e.head=n}e.length++;return n}function push(e,t){e.tail=new Node(t,e.tail,null,e);if(!e.head){e.head=e.tail}e.length++}function unshift(e,t){e.head=new Node(t,null,e.head,e);if(!e.tail){e.tail=e.head}e.length++}function Node(e,t,r,n){if(!(this instanceof Node)){return new Node(e,t,r,n)}this.list=n;this.value=e;if(t){t.next=this;this.prev=t}else{this.prev=null}if(r){r.prev=this;this.next=r}else{this.next=null}}try{r(8076)(Yallist)}catch(e){}},3348:(e,t,r)=>{"use strict";r.r(t);var n=r(6148);var i=r.n(n);var s=r(4101);var o=r.n(s);var a=r(1017);var c=r.n(a);var u=r(9966);var l=r.n(u);var h=r(5656);var p=r.n(h);var d=r(3493);var m=r.n(d);var y=r(5165);var g=r.n(y);var v=r(7147);var b=r.n(v);var w=r(2037);var S=r.n(w);var x=r(9312);var _=r.n(x);var O=r(7697);var k=r(2781);var R=r(3837);const A=(0,R.promisify)(k.Stream.pipeline);async function isUrlOk(e){const t=await _().head(e).catch((e=>e));return t.statusCode===200}async function getRepoInfo(e,t){const[,r,n,i,s,...o]=e.pathname.split("/");const a=t?t.replace(/^\//,""):o.join("/");if(i===undefined||i===""&&s===undefined){const e=await _()(`https://api.github.com/repos/${r}/${n}`).catch((e=>e));if(e.statusCode!==200){return}const t=JSON.parse(e.body);return{username:r,name:n,branch:t["default_branch"],filePath:a}}const c=t?`${s}/${o.join("/")}`.replace(new RegExp(`/${a}|/$`),""):s;if(r&&n&&c&&i==="tree"){return{username:r,name:n,branch:c,filePath:a}}}function hasRepo({username:e,name:t,branch:r,filePath:n}){const i=`https://api.github.com/repos/${e}/${t}/contents`;const s=`${n?`/${n}`:""}/package.json`;return isUrlOk(i+s+`?ref=${r}`)}function existsInRepo(e){try{const t=new URL(e);return isUrlOk(t.href)}catch{return isUrlOk(`https://api.github.com/repos/shuvijs/shuvi/contents/examples/${encodeURIComponent(e)}`)}}function downloadAndExtractRepo(e,{username:t,name:r,branch:n,filePath:i}){return A(_().stream(`https://codeload.github.com/${t}/${r}/tar.gz/${n}`),O.extract({cwd:e,strip:i?i.split("/").length+1:1},[`${r}-${n.replace(/\//g,"-")}${i?`/${i}`:""}`]))}function downloadAndExtractExample(e,t){if(t==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}return A(_().stream("https://codeload.github.com/shuvijs/shuvi/tar.gz/main"),O.extract({cwd:e,strip:3},[`shuvi-main/examples/${t}`]))}function makeDir(e,t={recursive:true}){return b().promises.mkdir(e,t)}var C=r(2081);var P=r(4700);var T=r.n(P);function isInGitRepository(){try{(0,C.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(e){}return false}function isInMercurialRepository(){try{(0,C.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(e){}return false}function tryGitInit(e){let t=false;try{(0,C.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,C.execSync)("git init",{stdio:"ignore"});t=true;(0,C.execSync)("git checkout -b main",{stdio:"ignore"});(0,C.execSync)("git add -A",{stdio:"ignore"});(0,C.execSync)('git commit -m "Initial commit from Create Shuvi App"',{stdio:"ignore"});return true}catch(r){if(t){try{T().sync(c().join(e,".git"))}catch(e){}}return false}}var M=r(9321);var j=r.n(M);function install(e,t,{packageManager:r,isOnline:n,devDependencies:s}){const o=[];const a=[];return new Promise(((c,u)=>{let l;let h=r;const p=r==="yarn";if(t&&t.length){if(p){l=["add","--exact"];if(!n)l.push("--offline");l.push("--cwd",e);if(s)l.push("--dev");l.push(...t)}else{l=["install","--save-exact"];l.push(s?"--save-dev":"--save");l.push(...t)}}else{l=["install"];if(!n){console.log(i().yellow("You appear to be offline."));if(p){console.log(i().yellow("Falling back to the local Yarn cache."));console.log();l.push("--offline")}else{console.log()}}}if(p){l.push(...a)}else{l.push(...o)}const d=j()(h,l,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});d.on("close",(e=>{if(e!==0){u({command:`${h} ${l.join(" ")}`});return}c()}))}))}function isFolderEmpty(e,t){const r=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log","yarnrc.yml",".yarn"];const n=b().readdirSync(e).filter((e=>!r.includes(e))).filter((e=>!/\.iml$/.test(e)));if(n.length>0){console.log(`The directory ${i().green(t)} contains files that could conflict:`);console.log();for(const t of n){try{const r=b().lstatSync(c().join(e,t));if(r.isDirectory()){console.log(` ${i().blue(t)}/`)}else{console.log(` ${t}`)}}catch{console.log(` ${t}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}var I=r(9523);var N=r.n(I);var D=r(7310);var L=r.n(D);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const e=(0,C.execSync)("npm config get https-proxy").toString().trim();return e!=="null"?e:undefined}catch(e){return}}function getOnline(){return new Promise((e=>{N().lookup("registry.yarnpkg.com",(t=>{if(!t){return e(true)}const r=getProxy();if(!r){return e(false)}const{hostname:n}=L().parse(r);if(!n){return e(false)}N().lookup(n,(t=>{e(t==null)}))}))}))}async function isWriteable(e){try{await b().promises.access(e,(b().constants||b()).W_OK);return true}catch(e){return false}}class DownloadError extends Error{}async function createApp({appPath:e,packageManager:t,example:n,examplePath:s,typescript:o}){let a;const u=o?"typescript":"default";if(n){let e;try{e=new URL(n)}catch(e){if(e.code!=="ERR_INVALID_URL"){console.error(e);process.exit(1)}}if(e){if(e.origin!=="https://github.com"){console.error(`Invalid URL: ${i().red(`"${n}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}a=await getRepoInfo(e,s);if(!a){console.error(`Found invalid GitHub URL: ${i().red(`"${n}"`)}. Please fix the URL and try again.`);process.exit(1)}const t=await hasRepo(a);if(!t){console.error(`Could not locate the repository for ${i().red(`"${n}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(n!=="__internal-testing-retry"){const e=await existsInRepo(n);if(!e){console.error(`Could not locate an example named ${i().red(`"${n}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${i().red(`"${n}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const l=c().resolve(e);if(!await isWriteable(c().dirname(l))){console.error("The application path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const h=c().basename(l);await makeDir(l);if(!isFolderEmpty(l,h)){process.exit(1)}const p=t==="yarn";const d=!p||await getOnline();const y=process.cwd();console.log(`Creating a new Shuvi.js app in ${i().green(l)}.`);console.log();process.chdir(l);const v=c().join(l,"package.json");let w=false;if(n){try{if(a){const e=a;console.log(`Downloading files from repo ${i().cyan(n)}. This might take a moment.`);console.log();await m()((()=>downloadAndExtractRepo(l,e)),{retries:3})}else{console.log(`Downloading files for example ${i().cyan(n)}. This might take a moment.`);console.log();await m()((()=>downloadAndExtractExample(l,n)),{retries:3})}}catch(e){function isErrorLike(e){return typeof e==="object"&&e!==null&&typeof e.message==="string"}throw new DownloadError(isErrorLike(e)?e.message:e+"")}const e=c().join(l,".gitignore");if(!b().existsSync(e)){b().copyFileSync(r.ab+"templates/"+u+"/gitignore",e)}w=b().existsSync(v);if(w){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(l,null,{packageManager:t,isOnline:d});console.log()}}else{console.log(i().bold(`Using ${t}.`));const e={name:h,version:"0.1.0",private:true,scripts:{dev:"shuvi dev",build:"shuvi build",serve:"shuvi serve"}};b().writeFileSync(c().join(l,"package.json"),JSON.stringify(e,null,2)+S().EOL);const n={packageManager:t,isOnline:d};const s=["shuvi@next"];const a=[];if(o){a.push("typescript","@types/react","@types/node","@types/react-dom")}if(s.length){console.log();console.log("Installing dependencies:");for(const e of s){console.log(`- ${i().cyan(e)}`)}console.log();await install(l,s,n)}if(a.length){console.log();console.log("Installing devDependencies:");for(const e of a){console.log(`- ${i().cyan(e)}`)}console.log();const e={devDependencies:true,...n};await install(l,a,e)}console.log();await g()("**",l,{parents:true,cwd:r.ab+"templates/"+u,rename:e=>{switch(e){case"gitignore":case"eslintrc.json":{return".".concat(e)}case"README-template.md":{return"README.md"}default:{return e}}}})}if(tryGitInit(l)){console.log("Initialized a git repository.");console.log()}let x;if(c().join(y,h)===e){x=h}else{x=e}console.log(`${i().green("Success!")} Created ${h} at ${e}`);if(w){console.log("Inside that directory, you can run several commands:");console.log();console.log(i().cyan(` ${t} ${p?"":"run "}dev`));console.log(" Starts the development server.");console.log();console.log(i().cyan(` ${t} ${p?"":"run "}build`));console.log(" Builds the app for production.");console.log();console.log(i().cyan(` ${t} serve`));console.log(" Runs the built app in production mode.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(i().cyan(" cd"),x);console.log(` ${i().cyan(`${t} ${p?"":"run "}dev`)}`)}console.log()}function getPkgManager(){try{const e=process.env.npm_config_user_agent;if(e){if(e.startsWith("yarn")){return"yarn"}else if(e.startsWith("pnpm")){return"pnpm"}}try{(0,C.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,C.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var $=r(2338);var B=r.n($);function validateNpmName(e){const t=B()(e);if(t.validForNewPackages){return{valid:true}}return{valid:false,problems:[...t.errors||[],...t.warnings||[]]}}const G=JSON.parse('{"name":"create-shuvi","version":"2.0.0-dev.4","keywords":["react","shuvi","shuvi.js"],"description":"Create Shuvi.js-powered React apps with one command","license":"MIT","bin":{"create-shuvi":"./dist/index.js"},"files":["dist"],"scripts":{"dev":"ncc build ./index.ts -w -o dist/","prebuild":"rimraf ./dist/","build":"ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register"},"devDependencies":{"@types/async-retry":"1.3.0","@types/cross-spawn":"6.0.0","@types/node":"^12.6.8","@types/prompts":"2.0.1","@types/rimraf":"3.0.0","@types/tar":"4.0.3","@types/validate-npm-package-name":"3.0.0","@vercel/ncc":"0.34.0","async-retry":"1.3.3","chalk":"2.4.2","commander":"2.20.0","cpy":"7.3.0","cross-spawn":"6.0.5","got":"10.7.0","prompts":"2.1.0","rimraf":"3.0.2","tar":"4.4.10","update-check":"1.5.4","validate-npm-package-name":"3.0.0"},"engines":{"node":">=12.0.0"}}');let U="";let z=undefined;const q=new(o().Command)(G.name).version(G.version).arguments("<project-directory>").usage(`${i().green("<project-directory>")} [options]`).action((e=>{U=e})).option("--ts, --typescript",`\n\n Initialize as a TypeScript project.\n`).option("--use-npm",`\n\n Explicitly tell the CLI to bootstrap the app using npm\n`).option("--use-pnpm",`\n\n Explicitly tell the CLI to bootstrap the app using pnpm\n`).option("-e, --example [name]|[github-url]",`\n\n An example to bootstrap the app with. You can use an example name\n from the official Shuvi.js repo or a GitHub URL. The URL can use\n any branch and/or subdirectory\n`).option("--example-path <path-to-example>",`\n\n In a rare case, your GitHub URL might contain a branch name with\n a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).\n In this case, you must specify the path to the example separately:\n --example-path foo/bar\n`).allowUnknownOption().parse(process.argv);async function run(){if(typeof U==="string"){U=U.trim()}if(!U){const e=await l()({type:"text",name:"path",message:"What is your project named?",initial:"my-app",validate:e=>{const t=validateNpmName(c().basename(c().resolve(e)));if(t.valid){return true}return"Invalid project name: "+t.problems[0]}});if(typeof e.path==="string"){U=e.path.trim()}}if(!U){console.log("\nPlease specify the project directory:\n"+` ${i().cyan(q.name())} ${i().green("<project-directory>")}\n`+"For example:\n"+` ${i().cyan(q.name())} ${i().green("my-shuvi-app")}\n\n`+`Run ${i().cyan(`${q.name()} --help`)} to see all options.`);process.exit(1)}z=q.typescript;if(z===undefined){const e=await l()({type:"toggle",name:"typescript",message:"Add Typescript?",initial:false,active:"Yes",inactive:"No"});z=e.typescript}const e=c().resolve(U);const t=c().basename(e);const{valid:r,problems:n}=validateNpmName(t);if(!r){console.error(`Could not create a project called ${i().red(`"${t}"`)} because of npm naming restrictions:`);n.forEach((e=>console.error(` ${i().red.bold("*")} ${e}`)));process.exit(1)}if(q.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}const s=!!q.useNpm?"npm":!!q.usePnpm?"pnpm":getPkgManager();const o=typeof q.example==="string"&&q.example.trim();try{await createApp({appPath:e,packageManager:s,example:o&&o!=="default"?o:undefined,examplePath:q.examplePath,typescript:z})}catch(t){if(!(t instanceof DownloadError)){throw t}const r=await l()({type:"confirm",name:"builtin",message:`Could not download "${o}" because of a connectivity issue between your machine and GitHub.\n`+`Do you want to use the default template instead?`,initial:true});if(!r.builtin){throw t}await createApp({appPath:e,packageManager:s,typescript:q.typescript})}}const H=p()(G).catch((()=>null));async function notifyUpdate(){try{const e=await H;if(e===null||e===void 0?void 0:e.latest){const e=getPkgManager();console.log(i().yellow.bold("A new version of `create-shuvi` is available!")+"\n"+"You can update by running: "+i().cyan(e==="yarn"?"yarn global add create-shuvi":`${e} install --global create-shuvi`)+"\n")}process.exit()}catch{}}run().then(notifyUpdate).catch((async e=>{console.log();console.log("Aborting installation.");if(e.command){console.log(` ${i().cyan(e.command)} has failed.`)}else{console.log(i().red("Unexpected error. Please report it as a bug:")+"\n",e)}console.log();await notifyUpdate();process.exit(1)}))},9491:e=>{"use strict";e.exports=require("assert")},4300:e=>{"use strict";e.exports=require("buffer")},2081:e=>{"use strict";e.exports=require("child_process")},1071:e=>{"use strict";e.exports=require("constants")},6113:e=>{"use strict";e.exports=require("crypto")},9523:e=>{"use strict";e.exports=require("dns")},2361:e=>{"use strict";e.exports=require("events")},7147:e=>{"use strict";e.exports=require("fs")},3685:e=>{"use strict";e.exports=require("http")},5687:e=>{"use strict";e.exports=require("https")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},4521:e=>{"use strict";e.exports=require("readline")},2781:e=>{"use strict";e.exports=require("stream")},1576:e=>{"use strict";e.exports=require("string_decoder")},6224:e=>{"use strict";e.exports=require("tty")},7310:e=>{"use strict";e.exports=require("url")},3837:e=>{"use strict";e.exports=require("util")},9796:e=>{"use strict";e.exports=require("zlib")},3113:e=>{"use strict";e.exports=JSON.parse('["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","process","punycode","querystring","readline","repl","stream","string_decoder","timers","tls","tty","url","util","v8","vm","zlib"]')}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={id:r,loaded:false,exports:{}};var s=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}i.loaded=true;return i.exports}(()=>{__nccwpck_require__.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;__nccwpck_require__.d(t,{a:t});return t}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();(()=>{__nccwpck_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(3348);module.exports=r})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-shuvi",
3
- "version": "1.0.62",
3
+ "version": "2.0.0-dev.4",
4
4
  "keywords": [
5
5
  "react",
6
6
  "shuvi",