@terai/dev 0.0.1 → 0.0.2

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.
@@ -47,7 +47,7 @@ ${ua}
47
47
  Try running with %s or get access `,ce.cyan("sudo"))+`
48
48
  to the local update config store via
49
49
  `+ce.cyan(ou(" sudo chown -R $USER:$(id -gn $USER) %s ",It));Ve.on("exit",()=>{console.error(xs(r,{textAlignment:"center"}))})}}check(){!this.config||this.config.get("optOut")||this.#r||(this.update=this.config.get("update"),this.update&&(this.update.current=this.#e,this.config.delete("update")),!(Date.now()-this.config.get("lastUpdateCheck")<this.#n)&&Jb(Ve.execPath,[Wd.join(Zb,"check.js"),JSON.stringify(this.#t)],{detached:!0,stdio:"ignore"}).unref())}async fetchInfo(){let{distTag:e}=this.#t,r=await jo(this._packageName,{version:e});return{latest:r,current:this.#e,type:Ei(this.#e,r)||e,name:this._packageName}}notify(e){let r=!this._shouldNotifyInNpmScript&&$h;if(!Ve.stdout.isTTY||r||!this.update||!Vd.default.gt(this.update.latest,this.update.current))return this;e={isGlobal:Yd.default,isYarnGlobal:ed(),...e};let n;e.isYarnGlobal?n=`yarn global add ${this._packageName}`:e.isGlobal?n=`npm i -g ${this._packageName}`:Go()?n=`yarn add ${this._packageName}`:n=`npm i ${this._packageName}`;let s="Update available "+ce.dim("{currentVersion}")+ce.reset(" \u2192 ")+ce.green("{latestVersion}")+`
50
- Run `+ce.cyan("{updateCommand}")+" to update",i=e.message||s;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let o=xs(iu(i,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(o):(Ve.on("exit",()=>{console.error(o)}),Ve.on("SIGINT",()=>{console.error(""),Ve.exit()})),this}};function uu(t){let e=new nn(t);return e.check(),e}var _s={name:"@terai/dev",version:"0.0.0",description:"The user-facing package for Terai",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",private:!1,author:"Hugo Corta <corta.hugo@gmail.com>",bin:{koi:"bin.js",terai:"bin.js"},scripts:{dev:"tsup --format=esm,cjs --no-dts --watch",build:"tsup"},files:["bin.js","dist"],sideEffects:!1,publishConfig:{access:"public"},exports:{".":{types:"./dist/index.d.ts",require:"./dist/index.js",import:"./dist/index.mjs"}},dependencies:{"@inquirer/prompts":"^3","@terai/extractor":"workspace:*","@terai/runtime":"workspace:*","@terai/translator":"workspace:*","@terai/utils":"workspace:*",cac:"^6",dotenv:"^1",inquirer:"^9",kleur:"^4","perfect-debounce":"^1","preferred-pm":"^3"},devDependencies:{"@terai/generator":"workspace:*","@terai/logger":"workspace:*","@terai/types":"workspace:*","@types/update-notifier":"^6","update-notifier":"^6"}};a();import{findConfig as fx,setupConfig as Dx,setupTemplate as hx}from"@terai/runtime";import{input as Zd,select as dx}from"@inquirer/prompts";a();function ws(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]}function Xd(){return typeof WeakMap<"u"?new WeakMap:rx()}function rx(){return{add:ws,delete:ws,get:ws,set:ws,has:function(t){return!1}}}var nx=Object.prototype.hasOwnProperty,cu=function(t,e){return nx.call(t,e)};function au(t,e){for(var r in e)cu(e,r)&&(t[r]=e[r]);return t}var sx=/^[ \t]*(?:\r\n|\r|\n)/,ix=/(?:\r\n|\r|\n)[ \t]*$/,ox=/^(?:[\r\n]|$)/,ux=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,ax=/^[ \t]*[\r\n][ \t\r\n]*$/;function Jd(t,e,r){var n=0,s=t[0].match(ux);s&&(n=s[1].length);var i="(\\r\\n|\\r|\\n).{0,"+n+"}",o=new RegExp(i,"g");e&&(t=t.slice(1));var u=r.newline,c=r.trimLeadingNewline,f=r.trimTrailingNewline,l=typeof u=="string",D=t.length,d=t.map(function(h,C){return h=h.replace(o,"$1"),C===0&&c&&(h=h.replace(sx,"")),C===D-1&&f&&(h=h.replace(ix,"")),l&&(h=h.replace(/\r\n|\n|\r/g,function(y){return u})),h});return d}function cx(t,e){for(var r="",n=0,s=t.length;n<s;n++)r+=t[n],n<s-1&&(r+=e[n]);return r}function lx(t){return cu(t,"raw")&&cu(t,"length")}function Qd(t){var e=Xd(),r=Xd();function n(i){for(var o=[],u=1;u<arguments.length;u++)o[u-1]=arguments[u];if(lx(i)){var c=i,f=(o[0]===n||o[0]===Ye)&&ax.test(c[0])&&ox.test(c[1]),l=f?r:e,D=l.get(c);if(D||(D=Jd(c,f,t),l.set(c,D)),o.length===0)return D[0];var d=cx(D,f?o.slice(1):o);return d}else return Qd(au(au({},t),i||{}))}var s=au(n,{string:function(i){return Jd([i],!1,t)[0]}});return s}var Ye=Qd({trimLeadingNewline:!0,trimTrailingNewline:!0});if(typeof module<"u")try{module.exports=Ye,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.default=Ye,Ye.outdent=Ye}catch{}import px from"preferred-pm";function ep(t,e){return t.command("init","Initialize config file").option("-f, --force","Force overwrite existing config files").option("--cwd <cwd>","Current working directory",{default:e}).action(mx)}async function mx({cwd:t,force:e}){K.heading("init","Initialize config file");let r=fx({cwd:t}),s=(await px(t))?.name??"npm",i=s==="npm"?"npm run":s;if(r&&!e)return K.log(Ye`
50
+ Run `+ce.cyan("{updateCommand}")+" to update",i=e.message||s;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let o=xs(iu(i,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(o):(Ve.on("exit",()=>{console.error(o)}),Ve.on("SIGINT",()=>{console.error(""),Ve.exit()})),this}};function uu(t){let e=new nn(t);return e.check(),e}var _s={name:"@terai/dev",version:"0.0.2",description:"The user-facing package for Terai",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",private:!1,author:"Hugo Corta <corta.hugo@gmail.com>",bin:{terai:"bin.js"},scripts:{dev:"tsup --format=esm,cjs --no-dts --watch",build:"tsup"},files:["bin.js","dist"],sideEffects:!1,publishConfig:{access:"public"},exports:{".":{types:"./dist/index.d.ts",require:"./dist/index.js",import:"./dist/index.mjs"}},dependencies:{"@inquirer/prompts":"^3","@terai/extractor":"workspace:*","@terai/runtime":"workspace:*","@terai/translator":"workspace:*","@terai/utils":"workspace:*",cac:"^6",dotenv:"^1",inquirer:"^9",kleur:"^4","perfect-debounce":"^1","preferred-pm":"^3"},devDependencies:{"@terai/generator":"workspace:*","@terai/logger":"workspace:*","@terai/types":"workspace:*","@types/update-notifier":"^6","update-notifier":"^6"}};a();import{findConfig as fx,setupConfig as Dx,setupTemplate as hx}from"@terai/runtime";import{input as Zd,select as dx}from"@inquirer/prompts";a();function ws(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]}function Xd(){return typeof WeakMap<"u"?new WeakMap:rx()}function rx(){return{add:ws,delete:ws,get:ws,set:ws,has:function(t){return!1}}}var nx=Object.prototype.hasOwnProperty,cu=function(t,e){return nx.call(t,e)};function au(t,e){for(var r in e)cu(e,r)&&(t[r]=e[r]);return t}var sx=/^[ \t]*(?:\r\n|\r|\n)/,ix=/(?:\r\n|\r|\n)[ \t]*$/,ox=/^(?:[\r\n]|$)/,ux=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,ax=/^[ \t]*[\r\n][ \t\r\n]*$/;function Jd(t,e,r){var n=0,s=t[0].match(ux);s&&(n=s[1].length);var i="(\\r\\n|\\r|\\n).{0,"+n+"}",o=new RegExp(i,"g");e&&(t=t.slice(1));var u=r.newline,c=r.trimLeadingNewline,f=r.trimTrailingNewline,l=typeof u=="string",D=t.length,d=t.map(function(h,C){return h=h.replace(o,"$1"),C===0&&c&&(h=h.replace(sx,"")),C===D-1&&f&&(h=h.replace(ix,"")),l&&(h=h.replace(/\r\n|\n|\r/g,function(y){return u})),h});return d}function cx(t,e){for(var r="",n=0,s=t.length;n<s;n++)r+=t[n],n<s-1&&(r+=e[n]);return r}function lx(t){return cu(t,"raw")&&cu(t,"length")}function Qd(t){var e=Xd(),r=Xd();function n(i){for(var o=[],u=1;u<arguments.length;u++)o[u-1]=arguments[u];if(lx(i)){var c=i,f=(o[0]===n||o[0]===Ye)&&ax.test(c[0])&&ox.test(c[1]),l=f?r:e,D=l.get(c);if(D||(D=Jd(c,f,t),l.set(c,D)),o.length===0)return D[0];var d=cx(D,f?o.slice(1):o);return d}else return Qd(au(au({},t),i||{}))}var s=au(n,{string:function(i){return Jd([i],!1,t)[0]}});return s}var Ye=Qd({trimLeadingNewline:!0,trimTrailingNewline:!0});if(typeof module<"u")try{module.exports=Ye,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.default=Ye,Ye.outdent=Ye}catch{}import px from"preferred-pm";function ep(t,e){return t.command("init","Initialize config file").option("-f, --force","Force overwrite existing config files").option("--cwd <cwd>","Current working directory",{default:e}).action(mx)}async function mx({cwd:t,force:e}){K.heading("init","Initialize config file");let r=fx({cwd:t}),s=(await px(t))?.name??"npm",i=s==="npm"?"npm run":s;if(r&&!e)return K.log(Ye`
51
51
  It looks like you already have terai created.
52
52
  You can now run ${K.colors.cyan(`'${i} terai extract --watch'`)}
53
53
  `);let o=await Zd({message:"What locale do you use for development?",default:"en"}),u=await Zd({message:"Where do you want to place your generated files?",default:"./locale-system"}),c=await dx({message:"Would you like to use any of these templates? (recommended)",choices:[{name:"No",value:null},{name:"Next",value:"next"},{name:"Vite",value:"vite"}]}),f=K.time.success();await Dx({cwd:t,projectLocale:o,outDir:u}),c&&await hx({cwd:t,outDir:u,framework:c}),f("Config file created"),K.log("\u{1F680} You are set up to start using terai! Thanks for choosing it.")}a();import{debounce as Ex}from"perfect-debounce";import{extract as yx}from"@terai/extractor";a();import{runtime as lu}from"@terai/runtime";import{stringify as gx}from"@terai/utils";async function As({dictionaries:t,locale:e,cwd:r,outDir:n}){let s=lu.path.resolve(r,n,e),i=[];for(let o in t){let u=lu.path.resolve(s,o+".json"),c=t[o],f=gx(c);lu.fs.write(u,f),i.push(f)}return i}import{loadConfig as Cx,runtime as it}from"@terai/runtime";import{convertExtractedMessagesToDictionary as Fx,stringify as bx,groupDictionaryByChunks as xx}from"@terai/utils";function tp(t,e){return t.command("extract","Statically extract messages from your project").option("-w, --watch","Watch files and rebuild").option("--cwd <cwd>","Current working directory",{default:e}).action(_x)}async function _x(t){K.heading("extract","Statically extract messages from your project");let e=K.time.success(),r=await Cx(t),n=it.fs.glob({...r,cwd:t.cwd}),s=it.path.resolve(t.cwd,r.outDir),i=it.path.resolve(s,r.projectLocale),o=it.path.resolve(s,".terai","locale-manifest.json");K.info("Scan:","Processing files...");async function u(f=n){let l=await yx({...r,filesPaths:f,cwd:t.cwd}),D=Fx(l),d={messages:l},h=xx(D,d,r.projectLocale);return it.fs.remove(it.path.resolve(i)),await As({...r,dictionaries:h,locale:r.projectLocale,cwd:t.cwd}),it.fs.write(o,bx(d)),Object.keys(D).length}K.info("Extraction:","Extracting messages...");let c=await u();e(`Extracted ${c} messages`),t.watch&&(K.log(""),K.info("Watch:",`Watching files for changes...