@dittowords/cli 5.0.0 → 5.1.0
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/README.md +5 -6
- package/bin/ditto.js +63 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,14 +40,13 @@ The first time you run the CLI, a `ditto/` folder will be created if it doesn't
|
|
|
40
40
|
The default file looks like this:
|
|
41
41
|
|
|
42
42
|
```yml
|
|
43
|
-
projects: []
|
|
44
|
-
|
|
43
|
+
projects: []
|
|
44
|
+
variants: []
|
|
45
|
+
components:
|
|
45
46
|
folders: []
|
|
46
|
-
},
|
|
47
|
-
variants: [],
|
|
48
47
|
outputs:
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
- format: json
|
|
49
|
+
framework: i18next
|
|
51
50
|
```
|
|
52
51
|
|
|
53
52
|
For more information on configuring the CLI, see [this documentation section](https://developer.dittowords.com/cli-reference/configuration).
|
package/bin/ditto.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
4
|
-
var
|
|
5
|
-
`),"nl"),p={errorText:
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3333db72-d8d9-546d-a336-10eba2a87fc0")}catch(e){}}();
|
|
4
|
+
var Lr=Object.create;var ne=Object.defineProperty;var Jr=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames;var Yr=Object.getPrototypeOf,Br=Object.prototype.hasOwnProperty;var ze=t=>{throw TypeError(t)};var n=(t,e)=>ne(t,"name",{value:e,configurable:!0});var qr=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vr(e))!Br.call(t,s)&&s!==o&&ne(t,s,{get:()=>e[s],enumerable:!(r=Jr(e,s))||r.enumerable});return t};var m=(t,e,o)=>(o=t!=null?Lr(Yr(t)):{},qr(e||!t||!t.__esModule?ne(o,"default",{value:t,enumerable:!0}):o,t));var We=(t,e,o)=>e.has(t)||ze("Cannot "+o);var D=(t,e,o)=>(We(t,e,"read from private field"),o?o.call(t):e.get(t)),V=(t,e,o)=>e.has(t)?ze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,o),A=(t,e,o,r)=>(We(t,e,"write to private field"),r?r.call(t,o):e.set(t,o),o);var br=m(require("@sentry/node"));var ct="5.1.0";var U=require("commander");var fo=m(require("boxen")),Ut=m(require("chalk"));var lo=m(require("ora"));var ro=m(require("axios"));var Y=m(require("fs")),Qe=m(require("path")),Ke=m(require("url")),mt=m(require("js-yaml")),to=m(require("@sentry/node"));var Ze=require("os"),pt=m(require("path")),u=new class{get API_HOST(){return process.env.DITTO_API_HOST||"https://api.dittowords.com"}get CONFIG_FILE(){return process.env.DITTO_CONFIG_FILE||pt.default.join((0,Ze.homedir)(),".config","ditto")}get PROJECT_CONFIG_FILE(){return pt.default.normalize(pt.default.join("ditto","config.yml"))}get TEXT_DIR(){return process.env.DITTO_TEXT_DIR||"ditto"}get TEXT_FILE(){return pt.default.normalize(pt.default.join(this.TEXT_DIR,"text.json"))}};function He(t){if(typeof t!="object")return{};let e={};for(let o in t){let r=o,s=t[r];e[r]=typeof s=="object"||Array.isArray(s)?JSON.stringify(s):s}return e}n(He,"createSentryContext");var Ur={sources:{components:!0},variants:!0,format:"flat"},eo=mt.default.dump(Ur);function jt(t,e){let o=Qe.default.dirname(t);Y.default.existsSync(o)||Y.default.mkdirSync(o),Y.default.existsSync(t)||Y.default.writeFileSync(t,e||"","utf-8")}n(jt,"createFileIfMissing");function zr(t){return typeof t=="object"}n(zr,"jsonIsConfigYAML");function Wr(t){return!!t&&typeof t=="object"&&Object.values(t).every(e=>e.every&&e.every(o=>typeof o=="object"&&Object.keys(o).includes("token")))}n(Wr,"jsonIsGlobalYAML");function se(t=u.PROJECT_CONFIG_FILE,e={}){jt(t,eo);let o=Y.default.readFileSync(t,"utf8"),r=mt.default.load(o);return zr(r)?r:e}n(se,"readProjectConfigData");function Ft(t=u.CONFIG_FILE,e={}){jt(t);let o=Y.default.readFileSync(t,"utf8"),r=mt.default.load(o);return Wr(r)?r:e}n(Ft,"readGlobalConfigData");function Zr(t,e){jt(t,eo);let o=se(t),r={...o,...e,sources:{...o.sources,...e.sources}},s=mt.default.dump(r);Y.default.writeFileSync(t,s,"utf8")}n(Zr,"writeProjectConfigData");function ie(t,e){jt(t);let o=Ft(t),r=mt.default.dump({...o,...e});Y.default.writeFileSync(t,r,"utf8")}n(ie,"writeGlobalConfigData");function Bt(t){return t.includes("://")?Ke.default.parse(t).hostname||"":t}n(Bt,"justTheHost");function Hr(t,e){let o=Ft(t),r=Bt(e);o[r]=[],o[r][0]={token:""},ie(t,o)}n(Hr,"deleteToken");function Xr(t,e,o){let r=Ft(t),s=Bt(e);r[s]=[],r[s][0]={token:o},ie(t,r)}n(Xr,"saveToken");function oo(){return process.env.DITTO_API_KEY}n(oo,"getTokenFromEnv");function Qr(t,e){let o=oo();if(o)return o;let s=Ft(t)[Bt(e)];if(!s)return;let{length:i}=s;return s[i-1].token}n(Qr,"getToken");var Xe=/-(\d+$)/;function Kr(t,e){let o=e;if(t.has(o))for(;t.has(o);){let[r,s]=o.match(Xe)||[];s&&!isNaN(parseInt(s))?o=`${o.replace(Xe,"")}-${parseInt(s)+1}`:o=`${o}-1`}return o}n(Kr,"dedupeProjectName");function tn(t){let{sources:e,variants:o,format:r,status:s,richText:i,iosLocales:a,projects:c,components:l,disableJsDriver:g}=se(t),f=e?.projects||[],d=new Set,C=[],x=!1;(f||[]).forEach(k=>{if(k.id&&k.name){if(k.id==="ditto_component_library"){x=!0;return}k.fileName=Kr(d,k.name),d.add(k.fileName),C.push(k)}});let v=!!e?.components,R=typeof e?.components=="object"?e.components.root:void 0,P=typeof e?.components=="object"?e.components.folders:void 0,I={hasSourceData:!!C.length||v,validProjects:C,shouldFetchComponentLibrary:v,variants:o||!1,format:r,status:s,richText:i,hasTopLevelProjectsField:!!c,hasTopLevelComponentsField:!!l,hasComponentLibraryInProjects:x,componentRoot:R,componentFolders:P,localeByVariantApiId:a?a.reduce((k,it)=>({...k,...it}),{}):void 0,disableJsDriver:g};return to.setContext("config",He(I)),I}n(tn,"parseSourceInformation");var S={createFileIfMissing:jt,readProjectConfigData:se,readGlobalConfigData:Ft,writeGlobalConfigData:ie,writeProjectConfigData:Zr,justTheHost:Bt,saveToken:Xr,deleteToken:Hr,getToken:Qr,getTokenFromEnv:oo,parseSourceInformation:tn};function j(t){return ro.default.create({baseURL:u.API_HOST,headers:{Authorization:`token ${t||S.getToken(u.CONFIG_FILE,u.API_HOST)}`,"x-ditto-cli":!0}})}n(j,"createApiClient");var q=m(require("chalk"));var en=n(t=>q.default.magenta(t),"errorText"),on=n(t=>q.default.yellow(t),"warnText"),rn=n(t=>q.default.blueBright(t),"info"),nn=n(t=>q.default.green(t),"success"),sn=n(t=>q.default.blueBright.underline(t),"url"),an=n(t=>q.default.grey(t),"subtle"),cn=n(t=>q.default.white(t),"write"),pn=n(()=>console.log(`
|
|
5
|
+
`),"nl"),p={errorText:en,warnText:on,info:rn,success:nn,url:sn,subtle:an,write:cn,nl:pn};var so=m(require("fs")),io=m(require("@sentry/node")),ao=m(require("chalk")),co=require("enquirer");var no=m(require("@sentry/node"));async function F(t,e=2){t&&console.log(`
|
|
6
6
|
${t}
|
|
7
|
-
`),await
|
|
8
|
-
`)}
|
|
9
|
-
`),
|
|
10
|
-
|
|
11
|
-
Error ID: ${p.info(o)}`;return await
|
|
12
|
-
- `+p.info(o)+" "+p.subtle(
|
|
13
|
-
`,"projectsToText"),bt=
|
|
14
|
-
`);let
|
|
7
|
+
`),await no.flush(),process.exit(e)}n(F,"quit");var po=require("axios");var ae=n((t,e=u.API_HOST)=>{if(S.getTokenFromEnv())return!1;let o=t||u.CONFIG_FILE;if(!so.default.existsSync(o))return!0;let r=S.readGlobalConfigData(o);return!r[S.justTheHost(e)]||r[S.justTheHost(e)][0].token===""},"needsToken");async function mn(t){let e=j(t),o="/token-check",r;try{r=await e.get(o)}catch(s){if(!(s instanceof po.AxiosError))return{success:!1,output:[p.warnText("Sorry! We're having trouble reaching the Ditto API.")]};if(s.code==="ENOTFOUND")return{success:!1,output:[p.errorText(`Can't connect to API: ${p.url(u.API_HOST)}`)]};if(s.response?.status===401||s.response?.status===404)return{success:!1,output:[p.errorText("This API key isn't valid. Please try another.")]}}return typeof r=="string"?{success:!1,output:[r]}:r?.status===200?{success:!0}:{success:!1,output:[p.errorText("This API key isn't valid. Please try another.")]}}n(mn,"verifyTokenUsingTokenCheck");async function ln(t){let e=await mn(t);return e.success?!0:e.output.join(`
|
|
8
|
+
`)}n(ln,"checkToken");async function un(t){let e=p.info,o=p.url("https://app.dittowords.com/account/devtools"),r=`${ao.default.bold(e("API Keys"))}`,s=t||`To get started, you'll need your Ditto API key. You can find this at: ${o} under "${r}".`;return console.log(s),(await(0,co.prompt)({type:"input",name:"token",message:"What is your API key?",validate:n(a=>ln(a),"validate")})).token}n(un,"collectToken");var lt=n(async(t=null)=>{try{let e=await un(t);return console.log(`Thanks for authenticating. We'll save the key to: ${p.info(u.CONFIG_FILE)}
|
|
9
|
+
`),S.saveToken(u.CONFIG_FILE,u.API_HOST,e),e}catch(e){if(e===""){await F("",0);return}let o=io.captureException(e),r=`
|
|
10
|
+
|
|
11
|
+
Error ID: ${p.info(o)}`;return await F(p.errorText("Something went wrong. Please contact support or try again later.")+r)}},"collectAndSaveToken");var mo=m(require("js-yaml"));var Q=n((t=u.PROJECT_CONFIG_FILE)=>S.parseSourceInformation(t).validProjects,"getSelectedProjects"),ut=n((t=u.PROJECT_CONFIG_FILE)=>S.parseSourceInformation(t).shouldFetchComponentLibrary,"getIsUsingComponents");var ce=n(t=>{let e="https://app.dittowords.com";return t==="ditto_component_library"?`${e}/components`:`${e}/doc/${t}`},"getSourceUrl"),fn=n(t=>(t||[]).reduce((e,{name:o,id:r})=>e+(`
|
|
12
|
+
- `+p.info(o)+" "+p.subtle(ce(r))),"")+`
|
|
13
|
+
`,"projectsToText"),bt=fn;var{AutoComplete:dn}=require("enquirer");function gn(t){return t.name+" "+p.subtle(t.url||ce(t.id))}n(gn,"formatProjectChoice");function hn(t){if(!t)return null;let[,e,o]=t.split(/^(.*)\s.*http.*\/(\w+).*$/);return o==="all"?{name:e,id:"ditto_component_library"}:{name:e,id:o}}n(hn,"parseResponse");var yn=n(async({message:t,projects:e,limit:o=10})=>{p.write(`
|
|
14
|
+
`);let r=e.map(gn),s=new dn({name:"project",message:t,limit:o,choices:r}),i;try{i=await s.run()}catch{i=null}return hn(i)},"promptForProject"),qt=yn;function xn(t,e,o){if(o==="components"){S.writeProjectConfigData(t,{sources:{components:!0}});return}let r=[...Q(t),{name:e,id:o}];S.writeProjectConfigData(t,{sources:{projects:r}})}n(xn,"saveProject");var uo=n(()=>!S.parseSourceInformation().hasSourceData,"needsSource");async function Tn(){S.deleteToken(u.CONFIG_FILE,u.API_HOST),await lt("Looks like the API key you have saved no longer works. Please enter another one.")}n(Tn,"askForAnotherToken");async function Cn(t,e){let o=j(),r=(0,lo.default)("Fetching sources in your workspace...");r.start();let s;try{s=await o.get("/v1/projects")}catch(c){throw r.stop(),c}let i=e.reduce((c,l)=>c.add(l.id.toString()),new Set),a=s.data.filter(({id:c})=>c!=="ditto_component_library"&&!i.has(c.toString()));return r.stop(),a}n(Cn,"listProjects");async function Sn(t,e){let o=Q(),r=ut(),s=await Cn(t,o);return e&&!r&&(s=[{id:"ditto_component_library",name:"Ditto Component Library"},...s]),s?.length?qt({projects:s,message:"Choose the source you'd like to sync text from"}):(console.log("You're currently syncing all projects in your workspace."),console.log(p.warnText("Not seeing a project that you were expecting? Verify that developer mode is enabled on that project. More info: https://www.dittowords.com/docs/ditto-developer-mode")),null)}n(Sn,"collectSource");var Ot=n(async({components:t=!1}={components:!1})=>{try{let e=S.getToken(u.CONFIG_FILE,u.API_HOST),o=await Sn(e,t);if(!o){await F(null,0);return}console.log(`
|
|
15
15
|
Thanks for adding ${p.info(o.name)} to your selected sources.
|
|
16
16
|
We saved your updated configuration to: ${p.info(u.PROJECT_CONFIG_FILE)}
|
|
17
|
-
`),
|
|
18
|
-
`),o},"sourcesToText"),Gt=
|
|
17
|
+
`),xn(u.PROJECT_CONFIG_FILE,o.name,o.id)}catch(e){console.log(e),e.response&&e.response.status===404?(await Tn(),await Ot({components:t})):await F(null,2)}},"collectAndSaveSource");var In=n((t,e)=>{let o="";return e&&(o+=`the ${p.info("Ditto Component Library")}`,(t||[]).length?o+=" and ":o+=".."),(t||[]).length&&(o+=`the following projects: ${bt(t)}
|
|
18
|
+
`),o},"sourcesToText"),Gt=In;var go=n(()=>ae()||uo(),"needsTokenOrSource");function vn(){let t=Ut.default.white(`${Ut.default.bold("Welcome to the",Ut.default.magentaBright("Ditto CLI"))}.
|
|
19
19
|
|
|
20
|
-
We're glad to have you here.`);console.log((0,
|
|
21
|
-
See ${p.url("https://github.com/dittowords/cli")} for more information.`);if(
|
|
22
|
-
See ${p.url("https://github.com/dittowords/cli")} for more information.`);if(!t){console.log(`Looks like there are no Ditto sources selected for your current directory: ${p.info(process.cwd())}.`),await
|
|
20
|
+
We're glad to have you here.`);console.log((0,fo.default)(t,{padding:1}))}n(vn,"welcome");var ho=n(async()=>{vn(),ae()&&await lt();let{hasSourceData:t,validProjects:e,shouldFetchComponentLibrary:o,hasTopLevelComponentsField:r,hasTopLevelProjectsField:s}=S.parseSourceInformation();if(s)return await F(`${p.errorText(`Support for ${p.warnText("projects")} as a top-level field has been removed; please configure ${p.warnText("sources.projects")} instead.`)}
|
|
21
|
+
See ${p.url("https://github.com/dittowords/cli")} for more information.`);if(r)return await F(`${p.errorText("Support for `components` as a top-level field has been removed; please configure `sources.components` instead.")}
|
|
22
|
+
See ${p.url("https://github.com/dittowords/cli")} for more information.`);if(!t){console.log(`Looks like there are no Ditto sources selected for your current directory: ${p.info(process.cwd())}.`),await Ot({initialize:!0,components:!0});return}let i="You're currently set up to sync text from "+Gt(e,o);console.log(i)},"init");var K=m(require("fs")),ft=m(require("path")),bo=m(require("ora")),Oo=m(require("@sentry/node"));var pe=m(require("fs")),me=m(require("path"));function G(t){let e=t.split(/\s{1,}/g);return e=e.map(o=>o.replace(/[^a-zA-Z0-9-_.]/g,"").toLowerCase()),e=e.filter(o=>o!==""),e.join("-")}n(G,"cleanFileName");var zt=m(require("fs")),Wt=m(require("path"));function yo(t=process.cwd()){let e=wn(t);return jn(e)}n(yo,"determineModuleType");function wn(t){if(process.env.DITTO_MODULE_TYPE)return process.env.DITTO_MODULE_TYPE;for(;t;){let e=Wt.join(t,"package.json");if(zt.existsSync(e)){let o=zt.readFileSync(e,"utf8");try{let r=JSON.parse(o);if(r?.type)return r.type}catch{}return null}if(t==="/")break;t=Wt.dirname(t)}return null}n(wn,"getRawTypeFromPackageJson");function jn(t){let e=t?.toLowerCase()||"";return e==="commonjs"||e==="module"?e:"commonjs"}n(jn,"getTypeOrDefault");var xo=m(require("fs")),To=m(require("path"));function Fn(t){switch(t){case"flat":return"IJSONFlat";case"nested":return"IJSONNested";case"structured":return"IJSONStructured";case"icu":return"IJSONICU";default:return"_JSON"}}n(Fn,"getFormatString");function bn(t,e){return e==="commonjs"?`export = ${t};`:`export default ${t};`}n(bn,"getExportString");function On(t){return`
|
|
23
23
|
interface IJSONFlat {
|
|
24
24
|
[key: string]: string;
|
|
25
25
|
}
|
|
@@ -47,81 +47,81 @@ interface IDriverFile {
|
|
|
47
47
|
|
|
48
48
|
declare const driver: IDriverFile;
|
|
49
49
|
|
|
50
|
-
${
|
|
51
|
-
`.trim()}
|
|
52
|
-
`,"utf8")}
|
|
50
|
+
${bn("driver",t.moduleType)}
|
|
51
|
+
`.trim()}n(On,"getTypesString");function Co(t){let e=On(t);xo.default.writeFileSync(To.default.resolve(u.TEXT_DIR,"index.d.ts"),e+`
|
|
52
|
+
`,"utf8")}n(Co,"generateJsDriverTypeFile");var Pn=n(t=>t==="ditto_component_library"?t:`project_${t}`,"stringifySourceId");function So(t,e){let o=yo(),r=En(t),s=kn(),i=[],a={},c={};r.forEach(f=>{var C;let d;if(f.type==="components")d=s.generate(f.fileName.split(".")[0]);else{let x=f.fileName.split(".")[0];d=s.generate(x.split("__")[0])}if(i.push(An(f.fileName,d,o)),f.type==="project"){let{variantApiId:x}=f,v=Pn(f.projectId);a[v]??(a[v]={}),a[v][x]=`{...${d}}`}else c[C=f.variantApiId]??(c[C]=[]),c[f.variantApiId].push(`...${d}`)}),Object.keys(c).forEach(f=>{a.ditto_component_library??(a.ditto_component_library={});let d="{";c[f].forEach((C,x)=>{d+=C,x<c[f].length-1&&(d+=", ")}),d+="}",a.ditto_component_library[f]=d});let l="";l+=i.join(`
|
|
53
53
|
`)+`
|
|
54
54
|
|
|
55
|
-
`,
|
|
55
|
+
`,l+=`${Dn(o)}`,l+=`${JSON.stringify(a,null,2)}`.replace(/"\{/g,"{").replace(/\}"/g,"}");let g=me.default.resolve(u.TEXT_DIR,"index.js");return pe.default.writeFileSync(g,l,{encoding:"utf8"}),Co({format:e,moduleType:o}),`Generated .js SDK driver at ${p.info(g)}`}n(So,"generateJsDriver");function En(t){let e=new Map;return t.forEach(r=>{!r.fileName||r.type==="components"||e.set(G(r.fileName),r.id)}),pe.default.readdirSync(u.TEXT_DIR).filter(r=>me.default.extname(r)===".json").map(r=>{let s=r.split("__");if(s.length===3){let[,i,a]=s,[c]=a.split(".");return{type:"components",variantApiId:c,folderApiId:i,fileName:r}}if(s.length===2){let[i,a]=s,[c]=a.split("."),l=G(r.split("__")[0]);return{type:"project",projectId:e.get(l)||"",projectName:i,variantApiId:c,fileName:r}}throw new Error("Invalid JSON file generated: "+r)})}n(En,"getFullyQualifiedJSONSources");function kn(){let t=new Set;return{generate:n(e=>{let o=e.replace(/(\W|-)/g,"_"),r=o,s=1;for(;t.has(r);)r=`${o}${s}`,s++;return t.add(r),r},"generate")}}n(kn,"createVariableNameGenerator");function Dn(t){if(t==="commonjs")return"module.exports = ";if(t==="module")return"export default ";throw new Error("Unknown module type: "+t)}n(Dn,"getExportPrefix");function An(t,e,o){if(o==="commonjs")return`const ${e} = require('./${t}');`;if(o==="module")return`import ${e} from './${t}';`;throw new Error("Unknown module type: "+o)}n(An,"getImportStatement");async function Io(t,e={}){let o=j();if(!t.variants)return null;let{shouldFetchComponentLibrary:r,validProjects:s}=t,i={params:{...e?.meta,showSampleData:e.includeSampleData}};s.length&&!r&&(i.params.projectIds=s.map(({id:c})=>c));let{data:a}=await o.get("/v1/variants",i);return a}n(Io,"fetchVariants");var Po=require("axios");async function Zt(t={}){let e=j(),o="/v1/component-folders";t.showSampleData===!0&&(o+="?showSampleData=true");let{data:r}=await e.get(o,{});return r}n(Zt,"fetchComponentFolders");var vo=m(require("path"));async function wo(t){let e=j(),o={variants:t.variants,localeByVariantId:t.localeByVariantApiId};t.componentFolders||t.componentRoot?(o.components={},t.componentFolders&&(o.components.folders=t.componentFolders),t.componentRoot&&(o.components.root=t.componentRoot)):t.shouldFetchComponentLibrary&&(o.components=!0),t.validProjects&&(o.projects=t.validProjects);let{data:r}=await e.post("/v1/ios/swift-driver",o),s=vo.default.join(u.TEXT_DIR,"Ditto.swift");return await Pt(s,r),`Successfully saved Swift driver to ${p.info("Ditto.swift")}`}n(wo,"generateSwiftDriver");var Ht=m(require("path")),E=m(require("fs"));var Nn=/\.(strings|stringsdict)$/;async function jo(t){let e=E.default.readdirSync(u.TEXT_DIR),o={};for(let r of e){if(!Nn.test(r))continue;let[s,i]=r.split(".");if(!s.length)continue;let a=s.split("__"),c=a[0],l=a[a.length-1];if(!(c&&l))continue;let g=t&&t[l]?t[l]:l,f=`${g}.lproj`,d=Ht.default.join(u.TEXT_DIR,f);E.default.existsSync(d)||E.default.mkdirSync(d);let C=Ht.default.join(u.TEXT_DIR,r),x=Ht.default.join(d,`${c}.${i}`);Mn(c,i,C,x),o[f]={mappedVariant:l===g?void 0:l}}return Object.keys(o).map(r=>{let s=`Successfully generated iOS bundle ${p.info(r)}`,i=o[r].mappedVariant;return i&&(s+=` ${p.subtle(`(mapped to variant '${i}')`)}`),s}).join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}
|
|
58
|
-
`+o;E.default.writeFileSync(e,s),E.default.unlinkSync(t)}
|
|
57
|
+
`}n(jo,"generateIOSBundles");function Mn(t,e,o,r){if(!E.default.existsSync(r))return E.default.renameSync(o,r);if(t!=="components")throw new Error("Bundle path for "+t+" already exists");if(e==="strings")return Rn(o,r);if(e==="stringsdict")return _n(o,r);throw new Error("Unsupported extension "+e)}n(Mn,"handleBundleGeneration");function Rn(t,e){let o=E.default.readFileSync(t,"utf-8"),s=E.default.readFileSync(e,"utf-8")+`
|
|
58
|
+
`+o;E.default.writeFileSync(e,s),E.default.unlinkSync(t)}n(Rn,"appendStringsFile");function _n(t,e){let r=E.default.readFileSync(t,"utf-8").split(`
|
|
59
59
|
`).slice(3,-4),a=`<?xml version="1.0" encoding="utf-8"?>
|
|
60
60
|
<plist version="1.0">
|
|
61
61
|
<dict>
|
|
62
62
|
${[E.default.readFileSync(e,"utf-8").split(`
|
|
63
|
-
`).slice(3,-4),
|
|
63
|
+
`).slice(3,-4),r].join(`
|
|
64
64
|
`)}
|
|
65
65
|
</dict>
|
|
66
66
|
</plist>
|
|
67
|
-
`;E.default.writeFileSync(e,a),E.default.unlinkSync(t)}
|
|
68
|
-
`),"ensureEndsWithNewLine"),
|
|
69
|
-
`}
|
|
70
|
-
`}
|
|
67
|
+
`;E.default.writeFileSync(e,a),E.default.unlinkSync(t)}n(_n,"appendStringsDictFile");var $n=n(t=>t+(/[\r\n]$/.test(t)?"":`
|
|
68
|
+
`),"ensureEndsWithNewLine"),Pt=n((t,e)=>new Promise(o=>K.default.writeFile(t,$n(e),o)),"writeFile"),Ln=["flat","nested","structured","android","ios-strings","ios-stringsdict","icu"],Jn=["ios-strings","ios-stringsdict"],Eo=["flat","nested","structured","icu"],Vn=n(t=>{let e=t.filter(o=>Eo.includes(o));return e[e.length-1]||"flat"},"getJsonFormat"),Yn={flat:".json",nested:".json",structured:".json",android:".xml","ios-strings":".strings","ios-stringsdict":".stringsdict",icu:".json"},Xt=n(t=>{try{return Object.keys(JSON.parse(t)).some(e=>!e.startsWith("__variant"))}catch{return!1}},"getJsonFormatIsValid"),le={flat:Xt,nested:Xt,structured:Xt,icu:Xt,android:n(t=>t.includes("<string"),"android"),"ios-strings":n(t=>t.includes('" = "'),"ios-strings"),"ios-stringsdict":n(t=>t.includes("<key>"),"ios-stringsdict")},Bn=n(t=>{let e=(Array.isArray(t)?t:[t]).filter(o=>Ln.includes(o));return e.length?e:["flat"]},"getFormat"),ue=n(t=>Yn[t],"getFormatExtension"),qn=["projects","exported_at"],Gn=n(t=>{let e=Object.keys(t).filter(r=>!qn.includes(r)).length>0,o=t.projects&&Object.keys(t.projects).length>0;return e||o},"hasVariantData");async function Un(){S.deleteToken(u.CONFIG_FILE,u.API_HOST),await lt("Looks like the API key you have saved no longer works. Please enter another one.")}n(Un,"askForAnotherToken");async function Fo(t,e){let{projects:o,format:r,status:s,richText:i,token:a}=e,c=j(),l={variant:t};return r&&(l.format=r),i&&(l.includeRichText=i.toString()),s&&(l.status=s),(await Promise.all(o.map(async f=>{let d={...l};f.status&&(d.status=f.status),f.exclude_components&&(d.exclude_components=String(f.exclude_components));let{data:C}=await c.get(`/v1/projects/${f.id}`,{params:d,headers:{Authorization:`token ${a}`}});if(!Gn(C))return"";let x=ue(r),v=G(f.fileName+("__"+(t||"base"))+x),R=ft.default.join(u.TEXT_DIR,v),P=C;x===".json"&&(P=JSON.stringify(C,null,2));let _=le[r];return _(P)?(await Pt(R,P),fe(v)):""}))).join("")}n(Fo,"downloadAndSaveVariant");async function zn(t){return(await Promise.all([Fo(null,t),...t.variants.map(({apiID:o})=>Fo(o,t))])).join("")}n(zn,"downloadAndSaveVariants");async function Wn(t){let{projects:e,format:o,status:r,richText:s,token:i,options:a}=t,c=j(),l={...a?.meta};return o&&(l.format=o),s&&(l.includeRichText=s.toString()),r&&(l.status=r),(await Promise.all(e.map(async f=>{let d={...l};f.status&&(d.status=f.status),f.exclude_components&&(d.exclude_components=String(f.exclude_components));let{data:C}=await c.get(`/v1/projects/${f.id}`,{params:d,headers:{Authorization:`token ${i}`}}),x=ue(o),v=G(`${f.fileName}__base${x}`),R=ft.default.join(u.TEXT_DIR,v),P=C;x===".json"&&(P=JSON.stringify(C,null,2));let _=le[o];return _(P)?(await Pt(R,P),fe(v)):""}))).join("")}n(Wn,"downloadAndSaveBase");function fe(t){return`Successfully saved to ${p.info(t)}
|
|
69
|
+
`}n(fe,"getSavedMessage");function Zn(){return K.default.existsSync(u.TEXT_DIR)||K.default.mkdirSync(u.TEXT_DIR),K.default.readdirSync(u.TEXT_DIR,{withFileTypes:!0}).forEach(e=>{if(e.isDirectory()&&/\.lproj$/.test(e.name))return K.default.rmSync(ft.default.resolve(u.TEXT_DIR,e.name),{recursive:!0,force:!0});if(e.isFile()&&/\.js(on)?|\.ts|\.xml|\.strings(dict)?$|\.swift$/.test(e.name))return K.default.unlinkSync(ft.default.resolve(u.TEXT_DIR,e.name))}),`Cleaning old output files..
|
|
70
|
+
`}n(Zn,"cleanOutputFiles");async function Hn(t,e,o){let r=j(),{validProjects:s,format:i,shouldFetchComponentLibrary:a,status:c,richText:l,componentFolders:g,componentRoot:f,localeByVariantApiId:d,disableJsDriver:C}=t,x=Bn(i),v=x.some(w=>Eo.includes(w)),P=x.some(w=>Jn.includes(w))&&d,_=!P,I="",k=(0,bo.default)(I);k.start();let[it,Or]=await Promise.all([Io(t,o),Zt({})]),Ye=Object.entries(Or).reduce((w,[M,L])=>w.concat([{id:M,name:L}]),[]);try{I+=Zn(),I+=`
|
|
71
71
|
Fetching the latest text from ${Gt(s,a)}
|
|
72
|
-
`;let
|
|
72
|
+
`;let w=o?o.meta:{},M={id:"__root__",name:"Root",status:typeof t.componentRoot=="object"?t.componentRoot.status:void 0},L=[];if(g)switch(f){case void 0:case!1:L.push(...g);break;default:L.push(...g),L.push(M);break}else switch(f){case void 0:L.push(...Ye),L.push(M);break;case!1:L.push(...Ye);break;default:L.push(M);break}let Be=[];async function Pr($){let vt=[{apiID:void 0},...it||[]],wt=new URLSearchParams;o?.meta&&Object.entries(o.meta).forEach(([at,X])=>wt.append(at,X)),$&&wt.append("format",$),l&&wt.append("includeRichText",l.toString()),c&&wt.append("status",c);let qe=[];vt.forEach(({apiID:at})=>{qe.push(...L.map(async X=>{let ee=new URLSearchParams(wt);at&&ee.append("variant",at),X.status&&ee.append("status",X.status);let Ar=X.id==="__root__"?"/v1/components?root_only=true":`/v1/component-folders/${X.id}/components`,{data:Ge}=await r.get(Ar,{params:ee}),Ue=ue($),Nr="components",Mr=`__${G(X.name)}`,Rr=`__${at||"base"}`,oe=G(`${Nr}${Mr}${Rr}${Ue}`),_r=ft.default.join(u.TEXT_DIR,oe),re=Ge;Ue===".json"&&(re=JSON.stringify(Ge,null,2));let $r=le[$];return $r(re)?(await Pt(_r,re),Be.push({type:"components",id:"ditto_component_library",name:"ditto_component_library",fileName:oe,variant:at||"base"}),fe(oe)):""}))});let Dr=await Promise.all(qe);_&&(I+=Dr.join(""))}if(n(Pr,"fetchComponentLibrary"),a)for(let $ of x)await Pr($);async function Er($){let vt="";it?vt=await zn({variants:it,projects:s,format:$,status:c,richText:l,token:e}):vt=await Wn({projects:s,format:$,status:c,richText:l,token:e,options:{meta:w}}),_&&(I+=vt)}if(n(Er,"fetchProjects"),s.length)for(let $ of x)await Er($);let kr=[...s,...Be];return v&&!C&&(I+=So(kr,Vn(x))),P&&(I+=`iOS locale information detected, generating bundles..
|
|
73
73
|
|
|
74
|
-
`,I+=await
|
|
74
|
+
`,I+=await jo(d),I+=await wo(t)),I+=`
|
|
75
75
|
|
|
76
|
-
${p.success("Done")}!`,k.stop(),console.log(I)}catch(
|
|
77
|
-
Choose others using the ${p.info("project")} command, or update your API key.`,console.log(I)):
|
|
78
|
-
Please choose different projects using the ${p.info("project")} command, or turn on Developer Mode for all selected projects. Learn more here: ${p.subtle("https://www.dittowords.com/docs/ditto-developer-mode")}.`,console.log(I)):(
|
|
79
|
-
Choose others using the ${p.info("project")} command.`,console.log(I))}}
|
|
76
|
+
${p.success("Done")}!`,k.stop(),console.log(I)}catch(w){console.error(w),k.stop();let M=w.message;if(w.response&&w.response.status===404){await Un(),de();return}return w.response&&w.response.status===401?(M="You don't have access to the selected projects",I=`${p.errorText(M)}.
|
|
77
|
+
Choose others using the ${p.info("project")} command, or update your API key.`,console.log(I)):w.response&&w.response.status===403?(M="One or more of the requested projects don't have Developer Mode enabled",I=`${p.errorText(M)}.
|
|
78
|
+
Please choose different projects using the ${p.info("project")} command, or turn on Developer Mode for all selected projects. Learn more here: ${p.subtle("https://www.dittowords.com/docs/ditto-developer-mode")}.`,console.log(I)):(w.response&&w.response.status===400&&(M="projects not found"),I=`We hit an error fetching text from the projects: ${p.errorText(M)}.
|
|
79
|
+
Choose others using the ${p.info("project")} command.`,console.log(I))}}n(Hn,"downloadAndSave");var de=n(async t=>{let e=t?t.meta:{},o=t?.includeSampleData||!1,r=S.getToken(u.CONFIG_FILE,u.API_HOST),s=S.parseSourceInformation();try{return await Hn(s,r,{meta:e,includeSampleData:o})}catch(i){let a=Oo.captureException(i),c=`
|
|
80
80
|
|
|
81
|
-
Error ID: ${p.info(a)}`;return i instanceof
|
|
81
|
+
Error ID: ${p.info(a)}`;return i instanceof Po.AxiosError?await F(p.errorText("Something went wrong connecting to Ditto servers. Please contact support or try again later.")+c):await F(p.errorText("Something went wrong. Please contact support or try again later.")+c)}},"pull");var Xn=n(async()=>{let t=Q(),e=ut();try{e?t.length?console.log(`
|
|
82
82
|
You're currently syncing text from the ${p.info("Component Library")} and from the following projects: ${bt(t)}`):console.log(`
|
|
83
83
|
You're currently only syncing text from the ${p.info("Component Library")}`):t.length&&console.log(`
|
|
84
|
-
You're currently set up to sync text from the following projects: ${bt(t)}`),await
|
|
85
|
-
Sorry, there was an error adding a project to your workspace: `,o),await
|
|
84
|
+
You're currently set up to sync text from the following projects: ${bt(t)}`),await Ot({components:!1})}catch(o){console.log(`
|
|
85
|
+
Sorry, there was an error adding a project to your workspace: `,o),await F("Project selection was not updated.")}},"addProject"),ko=Xn;async function Qn(){let t=Q(),e=ut();if(!t.length&&!e){console.log(`
|
|
86
86
|
No projects found in your current configuration.
|
|
87
87
|
Try adding one with: ${p.info("ditto-cli project add")}
|
|
88
|
-
`);return}let o=await qt({projects:t,message:"Select a project to remove"});o&&(
|
|
88
|
+
`);return}let o=await qt({projects:t,message:"Select a project to remove"});o&&(S.writeProjectConfigData(u.PROJECT_CONFIG_FILE,{components:e&&o.id!=="components",projects:t.filter(({id:r})=>r!==o.id)}),console.log(`
|
|
89
89
|
${p.info(o.name)} has been removed from your selected projects.
|
|
90
90
|
We saved your updated configuration to: ${p.info(u.PROJECT_CONFIG_FILE)}
|
|
91
|
-
`))}
|
|
92
|
-
`);if(!
|
|
93
|
-
`)[
|
|
94
|
-
`),"ensureEndsWithNewLine");var
|
|
91
|
+
`))}n(Qn,"removeProject");var Do=Qn;var Et=m(require("fs")),Ao=require("@babel/parser"),No=m(require("@babel/traverse")),N=m(require("@babel/types")),Mo=require("@babel/core");async function Kn(t,e,o){let r=await new Promise((a,c)=>Et.default.readFile(t,"utf-8",(l,g)=>{l?c(l):a(g)})),s=(0,Ao.parse)(r,{sourceType:"module",plugins:["jsx","typescript"]});(0,No.default)(s,{JSXText(a){let{searchString:c,replaceWith:l}=e,g=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(g,"gi").test(a.node.value)){if(o.lineNumbers&&a.node.loc&&!o.lineNumbers.includes(a.node.loc.start.line))return;let d=ts(a.node.value,g),C=[];d.forEach(x=>{if(x.toLowerCase()===c.toLowerCase()){let v=N.jsxIdentifier("DittoComponent"),R=N.jsxAttribute(N.jsxIdentifier("componentId"),N.stringLiteral(l)),P=N.jsxOpeningElement(v,[R],!0),_=N.jsxElement(P,void 0,[],!0);C.push(_)}else C.push(N.jsxText(x))}),a.replaceWithMultiple(C)}}});let{code:i}=(0,Mo.transformFromAst)(s,r,{configFile:!1});await new Promise((a,c)=>Et.default.writeFile(t,i,l=>{l?c(l):a(null)}))}n(Kn,"replaceJSXTextInFile");function ts(t,e){return t.split(new RegExp(`(${e})`,"gi")).filter(o=>o!=="")}n(ts,"splitByCaseInsensitive");function Ro(t,e){let o,r,s;try{let i=es(t);o=i.filePath,r=i.searchString,s=i.replaceWith}catch(i){console.error(i),console.error("Usage for replace: ditto-cli replace <file path> <search string> <replace with>");return}Kn(o,{searchString:r,replaceWith:s},e)}n(Ro,"replace");function es(t){if(t.length!==3)throw new Error("The options array must contain <file path> <search string> <replace with>.");let e=t[0];if(!(Et.default.existsSync(e)&&Et.default.lstatSync(e).isFile()))throw new Error(`${e} is not a valid file path.`);return{filePath:e,searchString:t[1],replaceWith:t[2]}}n(es,"parseOptions");var $o=m(require("fs")),Lo=m(require("glob")),Jo=require("@babel/parser"),Vo=m(require("@babel/traverse"));async function _o(t={}){let e=j();if(t.componentFolder)try{let{data:o}=await e.get(`/v1/component-folders/${t.componentFolder}/components`,{});return o}catch{return console.log(`Failed to get components for ${t.componentFolder}. Please verify the folder's API ID.`),{}}else{let{data:o}=await e.get("/v1/components?format=structured",{});return o}}n(_o,"fetchComponents");async function Yo(t){let e=await _o({...t.componentFolder?{componentFolder:t.componentFolder}:{}}),o=t.directory||".",r=await os({directory:o,files:t.files,components:e});console.log(JSON.stringify(r,null,2))}n(Yo,"generateSuggestions");async function os(t){let e={},o=t.files||Lo.default.sync(`${t.directory}/**/*.+(jsx|tsx)`,{ignore:"**/node_modules/**"}),r=[];async function s(i){let a=await new Promise((l,g)=>$o.default.readFile(i,"utf-8",(f,d)=>{f?g(f):l(d)})),c=(0,Jo.parse)(a,{sourceType:"module",plugins:["jsx","typescript"]});(0,Vo.default)(c,{JSXText(l){for(let[g,f]of Object.entries(t.components)){if(e[g]||(e[g]={apiId:g,...f,occurrences:{}}),!/^\s*$/.test(l.node.value)&&!/^\s*$/.test(f.text)&&l.node.value.includes(f.text)){let d=f.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C=new RegExp(d,"g"),x;for(;(x=C.exec(l.node.value))!==null;){let v=l.node.value.slice(0,x.index).split(`
|
|
92
|
+
`);if(!l.node.loc)continue;let R=l.node.loc.start.line+v.length-1,_=a.split(`
|
|
93
|
+
`)[R-1],I=rs(_,x.index,f.text,`${f.text}`);e[g].occurrences[i]||(e[g].occurrences[i]=[]),e[g].occurrences[i].push({lineNumber:R,preview:I})}}Object.keys(e[g].occurrences).length===0&&delete e[g]}}})}n(s,"handleFile");for(let i of o)r.push(s(i));return await Promise.all(r),e}n(os,"findComponentsInJSXFiles");function rs(t,e,o,r){return t.substring(0,e)+t.substring(e,t.length).replace(o,r)}n(rs,"replaceAt");var ns=n(t=>{let e={};return Array.isArray(t)&&t.forEach(o=>{let[r,s]=o.split(":");e[r]=s}),e},"processMetaOption"),Bo=ns;var qo=m(require("form-data")),ge=m(require("fs"));async function Go(t,e){let o=j();if(!ge.default.existsSync(t))return console.error("Failed to import file: couldn't find file at path "+t),{componentsInserted:0,firstImportedId:"null"};let r=new qo.default;r.append("import",ge.default.createReadStream(t));let s={method:"POST",url:"/v1/components/file",params:{...e.csvColumnMapping?.name?{name:`[${e.csvColumnMapping.name}]`}:{},...e.csvColumnMapping?.text?{text:e.csvColumnMapping.text}:{},...e.csvColumnMapping?.notes?{notes:e.csvColumnMapping.notes}:{},...e.csvColumnMapping?.status?{status:e.csvColumnMapping.status}:{},...e.csvColumnMapping?.tags?{tags:e.csvColumnMapping.tags}:{},...e.csvColumnMapping?.componentId?{componentId:e.csvColumnMapping.componentId}:{}},headers:{"content-type":"multipart/form-data"},data:r};try{let{data:i}=await o(s);return i}catch(i){return console.error("Failed to import file."),console.error(i.response?.data?.message||i.message),{componentsInserted:0,firstImportedId:"null"}}}n(Go,"importComponents");async function Uo(t,e){if(t.endsWith(".csv")&&(!e.csvColumnMapping?.name||!e.csvColumnMapping?.text))throw new Error(".csv files require the --component-name and --text flags.");let o=await Go(t,e);console.log(JSON.stringify(o))}n(Uo,"importComponents");async function zo(t){let e=await Zt(t);console.log(JSON.stringify(e))}n(zo,"showComponentFolders");var ss=["pull","none","project","project add","project remove"],is=[{name:"pull",description:"Sync copy from Ditto into the current working directory",flags:{"--sample-data":{description:"Include sample data. Currently only supports variants."}}},{name:"project",description:"Add a Ditto project to sync copy from",commands:[{name:"add",description:"Add a Ditto project to sync copy from"},{name:"remove",description:"Stop syncing copy from a Ditto project"}]},{name:"component-folders",description:"List component folders in your workspace. More information about component folders can be found here: https://www.dittowords.com/docs/component-folders.",flags:{"-s, --sample-data":{description:"Includes the sample components folder in the output"}}},{name:"generate-suggestions",description:"Find text that can be potentially replaced with Ditto text",flags:{"-d, --directory [value]":{description:"Directory to search for text"},"-f, --files [value]":{description:"Files to search for text (will override -d)",processor:n(t=>t.split(","),"processor")},"-cf, --component-folder [value]":{description:"Component folder to search for matches"}}},{name:"replace",description:"Find and replace Ditto text with code",flags:{"-ln, --line-numbers [value]":{description:"Only replace text on a specific line number",processor:n(t=>t.split(",").map(Number),"processor")}}},{name:"import-components",description:"Import components via a file. For more information please see: https://www.dittowords.com/docs/importing-string-files.",flags:{"-t, --text [value]":{description:"Text column index (.csv format only)"},"-n, --component-name [value]":{description:"Name column indexes (comma separated) (.csv format only)"},"-no, --notes [value]":{description:"Notes column index (.csv format only)"},"-t, --tags [value]":{description:"Tags column index (.csv format only)"},"-s, --status [value]":{description:"Status column index (.csv format only)"},"-c, --component-id [value]":{description:"Component ID column index (.csv format only)"}}}],as=n(()=>{U.program.name("ditto-cli"),is.forEach(t=>{let e=U.program.command(t.name).description(t.description).action(o=>he(t.name,o));t.flags&&Object.entries(t.flags).forEach(([o,{description:r,processor:s}])=>{s?e.option(o,r,s):e.option(o,r)}),"commands"in t&&t.commands&&t.commands.forEach(o=>{e.command(o.name).description(o.description).action((r,s)=>{if(t.name==="project"){let i=`${t.name} ${o.name}`;return he(i,s)}})})})},"setupCommands"),cs=n(()=>{U.program.option("-l, --legacy","Run in legacy mode"),U.program.option("-m, --meta <data...>","Include arbitrary data in requests to the Ditto API. Ex: -m githubActionRequest:true trigger:manual"),U.program.version(ct,"-v, --version","Output the current version")},"setupOptions"),he=n(async(t,e)=>{let o=ss.includes(t)&&go();if(o)try{await ho()}catch{await F("Exiting Ditto CLI...");return}let{meta:r}=U.program.opts();switch(t){case"none":case"pull":return de({meta:Bo(r),includeSampleData:e.sampleData||!1});case"project":case"project add":return o?void 0:ko();case"project remove":return Do();case"component-folders":return zo({showSampleData:e.sampleData});case"generate-suggestions":return Yo({directory:e.directory,files:e.files,componentFolder:e.componentFolder});case"replace":return Ro(e.args,{...e?.lineNumbers?{lineNumbers:e.lineNumbers}:{}});case"import-components":{if(e.args.length===0){console.info("Please provide a file path.");return}return Uo(e.args[0],{csvColumnMapping:{name:e.componentName,text:e.text,notes:e.notes,tags:e.tags,status:e.status,componentId:e.componentId}})}default:{await F("Exiting Ditto CLI...");return}}},"executeCommand"),ps=n(async()=>{if(as(),cs(),process.argv.length<=2&&process.argv[1].includes("ditto-cli")){await he("none",[]);return}U.program.parse(process.argv)},"legacyAppEntry"),Wo=ps;var jr=m(require("@sentry/node")),H=require("commander");var nr=require("os"),gt=m(require("path")),sr=m(require("crypto"));var er=require("zod"),or=m(require("fs"));var dt=m(require("path")),z=m(require("fs")),ye=m(require("fs/promises"));function kt(t,e=""){let o=dt.default.dirname(t);return z.default.existsSync(o)||z.default.mkdirSync(o),z.default.existsSync(t)?!1:(ms(t,e),!0)}n(kt,"createFileIfMissingSync");function ms(t,e){z.default.existsSync(dt.default.dirname(t))||z.default.mkdirSync(dt.default.dirname(t),{recursive:!0}),z.default.writeFileSync(t,e,"utf-8")}n(ms,"writeFileSync");async function Zo(t,e){z.default.existsSync(dt.default.dirname(t))||await ye.default.mkdir(dt.default.dirname(t),{recursive:!0}),await ye.default.writeFile(t,e,"utf-8")}n(Zo,"writeFile");var Ho=n(t=>t+(/[\r\n]$/.test(t)?"":`
|
|
94
|
+
`),"ensureEndsWithNewLine");var Se=m(require("js-yaml"));var b=require("zod"),Qt=b.z.object({projects:b.z.array(b.z.object({id:b.z.string()})).optional(),components:b.z.object({folders:b.z.array(b.z.object({id:b.z.string(),excludeNestedFolders:b.z.boolean().optional()})).optional()}).optional(),variants:b.z.array(b.z.object({id:b.z.string()})).optional(),outDir:b.z.string().optional(),richText:b.z.union([b.z.literal("html"),b.z.literal(!1)]).optional()});var Qo=require("zod");var J=require("zod");var xe=Qt.extend({format:J.z.literal("json"),framework:J.z.undefined()}).strict(),ls=xe.extend({framework:J.z.literal("i18next"),type:J.z.literal("module").or(J.z.literal("commonjs")).optional()}).strict(),us=xe.extend({framework:J.z.literal("vue-i18n"),type:J.z.literal("module").or(J.z.literal("commonjs")).optional()}).strict(),Xo=J.z.discriminatedUnion("framework",[xe,ls,us]);var Ko=Qo.z.union([...Xo.options]);var Ce=class Ce extends Error{constructor({type:e,message:o,exitCode:r,data:s}){let i=o||"Something went wrong. Please contact support or try again later.";super(i),this.exitCode=r,this.type=e,this.data=s}};n(Ce,"DittoError");var tt=Ce;function tr(t){return t instanceof tt}n(tr,"isDittoError");function Te(t,e){return t.type===e}n(Te,"isDittoErrorType");var ds=Qt.extend({outputs:er.z.array(Ko)}).strict(),Ie={projects:[],variants:[],components:{folders:[]},outputs:[{format:"json",framework:"i18next"}]};async function rr(t){let e=gs(t.config);y.setProjectConfig(e)}n(rr,"initProjectConfig");function gs(t=y.projectConfigFile,e=Ie){let o=e;try{kt(t,Se.default.dump(e));let s=or.default.readFileSync(t,"utf8");o=Se.default.load(s)}catch(s){throw new tt({type:"ConfigYamlLoadError",data:{rawErrorMessage:s.message},message:"Could not load the project config file. Please check the file path and that it is a valid YAML file."})}let r=ds.safeParse(o);if(!r.success)throw new tt({type:"ConfigParseError",data:{formattedError:JSON.stringify(r.error.flatten(),null,2),messagePrefix:"There is an error in your project config file."}});return r.data}n(gs,"readProjectConfigData");var ht,W,Dt,At,yt,xt,et,Nt,we=class we{constructor(){V(this,ht);V(this,W);V(this,Dt);V(this,At);V(this,yt);V(this,xt);V(this,et);V(this,Nt);A(this,ht,process.env.DITTO_API_HOST||"https://api.dittowords.com"),A(this,W,process.env.DITTO_TOKEN),A(this,Dt,process.env.DITTO_CONFIG_FILE||gt.default.join((0,nr.homedir)(),".config","ditto")),A(this,yt,process.env.DITTO_PROJECT_CONFIG_FILE||gt.default.normalize(gt.default.join("ditto","config.yml"))),A(this,At,gt.default.normalize(gt.default.dirname(D(this,yt)))),A(this,xt,sr.default.randomUUID()),A(this,et,Ie),A(this,Nt,process.env.DITTO_OUT_DIR||this.projectConfigDir)}get apiHost(){return D(this,ht)}set apiHost(e){A(this,ht,e)}get apiToken(){return D(this,W)}get apiTokenOrThrow(){if(!D(this,W))throw new Error("No API Token found.");return D(this,W)}get configFile(){return D(this,Dt)}get projectConfigFile(){return D(this,yt)}get clientId(){return D(this,xt)}setClientId(e){A(this,xt,e)}setApiToken(e){A(this,W,e)}get projectConfig(){return D(this,et)}setProjectConfig(e){A(this,et,e)}get selectedProjectConfigOutputs(){return D(this,et).outputs}get projectConfigDir(){return D(this,At)}get outDir(){return this.projectConfig.outDir||D(this,Nt)}};ht=new WeakMap,W=new WeakMap,Dt=new WeakMap,At=new WeakMap,yt=new WeakMap,xt=new WeakMap,et=new WeakMap,Nt=new WeakMap,n(we,"AppContext");var ve=we,hs=new ve,y=hs;var lr=require("axios");var O=require("zod");var ir=O.z.object({id:O.z.string(),text:O.z.string(),richText:O.z.string().optional(),status:O.z.string(),notes:O.z.string(),tags:O.z.array(O.z.string()),variableIds:O.z.array(O.z.string()),variantId:O.z.string().nullable()}),ys=ir.extend({projectId:O.z.string()});function ar(t){return"projectId"in t}n(ar,"isTextItem");var cr=O.z.array(ys),xs=ir.extend({folderId:O.z.string().nullable()}),pr=O.z.array(xs);var mr=m(require("axios"));function Ts({token:t,meta:e}={}){return function(o){return o.baseURL=y.apiHost,o.headers["x-ditto-client-id"]=y.clientId,o.headers["x-ditto-app"]=e?.githubActionRequest==="true"?"github_action":"cli",o.headers.Authorization=t||y.apiToken,o}}n(Ts,"defaultInterceptor");var Cs=n(t=>{let e=mr.default.create({});return e.interceptors.request.use(Ts(t)),e},"getHttpClient"),Z=Cs;async function je(t,e){try{let r=await Z({meta:e}).get("/v2/textItems",{params:t});return cr.parse(r.data)}catch(o){if(!(o instanceof lr.AxiosError))throw new Error("Sorry! We're having trouble reaching the Ditto API. Please try again later.");if(o.response?.status===400){let r="Invalid project filters";throw o.response?.data?.message&&(r=o.response.data.message),new Error(`${r}. Please check your project filters and try again.`,{cause:o.response?.data})}throw o}}n(je,"fetchText");var ur=require("axios");async function Fe(t,e){try{let r=await Z({meta:e}).get("/v2/components",{params:t});return pr.parse(r.data)}catch(o){if(!(o instanceof ur.AxiosError))throw new Error("Sorry! We're having trouble reaching the Ditto API. Please try again later.");if(o.response?.status===400){let r="Invalid component filters";throw o.response?.data?.message&&(r=o.response.data.message),new Error(`${r}. Please check your component filters and try again.`,{cause:o.response?.data})}throw o}}n(Fe,"fetchComponents");var fr=require("axios"),h=require("zod");var Mt=h.z.object({id:h.z.string(),name:h.z.string()}),Ss=Mt.merge(h.z.object({type:h.z.literal("number"),data:h.z.object({example:h.z.union([h.z.number(),h.z.string()]),fallback:h.z.union([h.z.number(),h.z.string()]).optional()})})),Is=Mt.merge(h.z.object({type:h.z.literal("string"),data:h.z.object({example:h.z.string(),fallback:h.z.string().optional()})})),vs=Mt.merge(h.z.object({type:h.z.literal("hyperlink"),data:h.z.object({text:h.z.string(),url:h.z.string()})})),ws=Mt.merge(h.z.object({type:h.z.literal("list"),data:h.z.array(h.z.string())})),js=Mt.merge(h.z.object({type:h.z.literal("map"),data:h.z.record(h.z.string())})),Fs=h.z.discriminatedUnion("type",[Is,Ss,vs,ws,js]),bs=h.z.array(Fs);async function be(t){try{let o=await Z({meta:t}).get("/v2/variables");return bs.parse(o.data)}catch(e){throw e instanceof fr.AxiosError?e:new Error("Sorry! We're having trouble reaching the Ditto API. Please try again later.")}}n(be,"fetchVariables");var B=m(require("chalk"));var Os=n(t=>B.default.magenta(t),"errorText"),Ps=n(t=>B.default.yellow(t),"warnText"),Es=n(t=>B.default.blueBright(t),"info"),ks=n(t=>B.default.green(t),"success"),Ds=n(t=>B.default.blueBright.underline(t),"url"),As=n(t=>B.default.grey(t),"subtle"),Ns=n(t=>B.default.white(t),"write"),Ms=n(t=>B.default.bold(t),"bold"),Rs=n(t=>console.log(t),"writeLine"),T={errorText:Os,warnText:Ps,info:Es,success:ks,url:Ds,subtle:As,write:Ns,writeLine:Rs,bold:Ms};var Oe=class Oe{constructor(e){this.filename=e.filename,this.path=e.path,this.extension=e.extension,this.content=e.content,this.metadata=e.metadata??{}}get fullPath(){return`${this.path}/${this.filename}.${this.extension}`}get filenameWithExtension(){return`${this.filename}.${this.extension}`}get formattedContent(){throw new Error("Not implemented")}};n(Oe,"OutputFile");var ot=Oe;var Pe=class Pe extends ot{constructor(e){super({filename:e.filename,path:e.path,extension:"json",content:e.content??{},metadata:e.metadata??{}})}get formattedContent(){return JSON.stringify(this.content,null,2)}};n(Pe,"JSONOutputFile");var rt=Pe;var Ee=class Ee{constructor(e,o,r){this.output=e,this.projectConfig=o,this.outDir=e.outDir??y.outDir,this.outputJsonFiles={},this.variablesOutputFile=new rt({filename:"variables",path:this.outDir}),this.meta=r}async fetchAPIData(){return{}}async transformAPIData(e){return[]}async format(){let e=await this.fetchAPIData(),o=await this.transformAPIData(e);await this.writeFiles(o)}async writeFiles(e){await Promise.all(e.map(o=>Zo(o.fullPath,o.formattedContent).then(()=>{T.writeLine(`Successfully saved to ${T.info(o.fullPath)}`)})))}};n(Ee,"BaseFormatter");var Rt=Ee;function Tt(t,...e){if(e.length>5)throw new Error("Maximum of 5 mixins supported");return e.reduce((o,r)=>r(o),t)}n(Tt,"applyMixins");var ke=class ke extends ot{constructor(o){super({filename:o.filename,path:o.path,extension:"js",content:o.content??"",metadata:o.metadata??{}});this.indentSpaces=2}get formattedContent(){return Ho(this.content??"")}};n(ke,"JavascriptOutputFile");var nt=ke;function _t(t){var e;return e=class extends t{constructor(){super(...arguments);this.indentSpaces=2}sanitizeStringForJSVariableName(s){return s.replace(/[^a-zA-Z0-9]/g,"_")}formatNamedModules(s){return s.map(i=>i.alias?`${i.name} as ${i.alias}`:i.name).sort().join(", ")}codegenNamedImport(s,i){return`import { ${this.formatNamedModules(s)} } from "${i}";
|
|
95
95
|
`}codegenNamedRequire(s,i){return`const { ${this.formatNamedModules(s)} } = require("${i}");
|
|
96
96
|
`}codegenDefaultImport(s,i){return`import ${s} from "${i}";
|
|
97
97
|
`}codegenDefaultRequire(s,i){return`const ${s} = require("${i}");
|
|
98
|
-
`}codegenDefaultExport(s){return`export default ${s};`}codegenCommonJSModuleExports(s){return`module.exports = ${s};`}codegenPad(s){return" ".repeat(s*this.indentSpaces)}},
|
|
99
|
-
`,
|
|
100
|
-
`,
|
|
101
|
-
`;for(let s=0;s<o.length;s++){let i=o[s],a=e[i];
|
|
102
|
-
`;for(let c of a)
|
|
103
|
-
`;
|
|
98
|
+
`}codegenDefaultExport(s){return`export default ${s};`}codegenCommonJSModuleExports(s){return`module.exports = ${s};`}codegenPad(s){return" ".repeat(s*this.indentSpaces)}},n(e,"JavascriptCodegenHelpers"),e}n(_t,"javascriptCodegenMixin");var De=class De{constructor(e){this.output=e,this.outDir=e.outDir??y.outDir}get framework(){return this.output.framework}process(...e){throw new Error("Not implemented")}};n(De,"BaseFramework");var st=De;var Ae=class Ae extends Tt(st,_t){process(e){let o="commonjs";"type"in this.output&&this.output.type&&(o=this.output.type);let r=new nt({filename:"index",path:this.outDir}),s=Object.values(e).reduce((i,a)=>{let c=a.metadata.variantId;return i[c]??(i[c]=[]),i[c].push(a),i},{});return o==="module"?(r.content+=this.generateImportStatements(e),r.content+=`
|
|
99
|
+
`,r.content+=this.codegenDefaultExport(this.generateExportedObjectString(s))):(r.content+=this.generateRequireStatements(e),r.content+=`
|
|
100
|
+
`,r.content+=this.codegenCommonJSModuleExports(this.generateExportedObjectString(s))),[r]}generateImportStatements(e){let o="";for(let r of Object.values(e))o+=this.codegenDefaultImport(this.sanitizeStringForJSVariableName(r.filename),`./${r.filenameWithExtension}`);return o}generateRequireStatements(e){let o="";for(let r of Object.values(e))o+=this.codegenDefaultRequire(this.sanitizeStringForJSVariableName(r.filename),`./${r.filenameWithExtension}`);return o}generateExportedObjectString(e){let o=Object.keys(e),r=`{
|
|
101
|
+
`;for(let s=0;s<o.length;s++){let i=o[s],a=e[i];r+=`${this.codegenPad(1)}"${i}": {
|
|
102
|
+
`;for(let c of a)r+=`${this.codegenPad(2)}...${this.sanitizeStringForJSVariableName(c.filename)},
|
|
103
|
+
`;r+=`${this.codegenPad(1)}}${s<o.length-1?`,
|
|
104
104
|
`:`
|
|
105
|
-
`}`}return
|
|
106
|
-
`,
|
|
107
|
-
`,
|
|
108
|
-
`;for(let s=0;s<o.length;s++){let i=o[s],a=e[i];
|
|
109
|
-
`;for(let c of a)
|
|
110
|
-
`;
|
|
105
|
+
`}`}return r+="}",r}};n(Ae,"I18NextFramework");var $t=Ae;var Ne=class Ne extends Tt(st,_t){process(e){for(let i of Object.values(e))for(let a in i.content){let c=i.content[a];typeof c=="string"&&(i.content[a]=c.replaceAll(/{{/g,"{").replaceAll(/}}/g,"}"))}let o="commonjs";"type"in this.output&&this.output.type&&(o=this.output.type);let r=new nt({filename:"index",path:this.outDir}),s=Object.values(e).reduce((i,a)=>{let c=a.metadata.variantId;return i[c]??(i[c]=[]),i[c].push(a),i},{});return o==="module"?(r.content+=this.generateImportStatements(e),r.content+=`
|
|
106
|
+
`,r.content+=this.codegenDefaultExport(this.generateExportedObjectString(s))):(r.content+=this.generateRequireStatements(e),r.content+=`
|
|
107
|
+
`,r.content+=this.codegenCommonJSModuleExports(this.generateExportedObjectString(s))),[r]}generateImportStatements(e){let o="";for(let r of Object.values(e))o+=this.codegenDefaultImport(this.sanitizeStringForJSVariableName(r.filename),`./${r.filenameWithExtension}`);return o}generateRequireStatements(e){let o="";for(let r of Object.values(e))o+=this.codegenDefaultRequire(this.sanitizeStringForJSVariableName(r.filename),`./${r.filenameWithExtension}`);return o}generateExportedObjectString(e){let o=Object.keys(e),r=`{
|
|
108
|
+
`;for(let s=0;s<o.length;s++){let i=o[s],a=e[i];r+=`${this.codegenPad(1)}"${i}": {
|
|
109
|
+
`;for(let c of a)r+=`${this.codegenPad(2)}...${this.sanitizeStringForJSVariableName(c.filename)},
|
|
110
|
+
`;r+=`${this.codegenPad(1)}}${s<o.length-1?`,
|
|
111
111
|
`:`
|
|
112
|
-
`}`}return
|
|
112
|
+
`}`}return r+="}",r}};n(Ne,"VueI18nFramework");var Lt=Ne;function dr(t){if(!t.framework)throw new Error("Only call this function with a framework output");let e=t.framework;switch(e){case"i18next":return new $t(t);case"vue-i18n":return new Lt(t);default:throw new Error(`Unsupported JSON framework: ${e}`)}}n(dr,"getFrameworkProcessor");var Me=class Me extends Tt(Rt){async fetchAPIData(){let e=await this.fetchTextItems(),o=await this.fetchComponents(),s=(await this.fetchVariables()).reduce((i,a)=>(i[a.id]=a,i),{});return{textItems:e,variablesById:s,components:o}}async transformAPIData(e){for(let r=0;r<e.textItems.length;r++){let s=e.textItems[r];this.transformAPITextEntity(s,e.variablesById)}for(let r=0;r<e.components.length;r++){let s=e.components[r];this.transformAPITextEntity(s,e.variablesById)}let o=[...Object.values(this.outputJsonFiles),this.variablesOutputFile];return this.output.framework&&o.push(...dr(this.output).process(this.outputJsonFiles)),o}transformAPITextEntity(e,o){var l;let r=ar(e)?`${e.projectId}___${e.variantId||"base"}`:`components___${e.variantId||"base"}`;(l=this.outputJsonFiles)[r]??(l[r]=new rt({filename:r,path:this.outDir,metadata:{variantId:e.variantId||"base"}}));let s=this.output.richText==="html",i=this.projectConfig.richText==="html"&&this.output.richText!==!1,c=(s||i)&&e.richText?e.richText:e.text;this.outputJsonFiles[r].content[e.id]=c;for(let g of e.variableIds){let f=o[g];this.variablesOutputFile.content[g]=f.data}}generateTextItemPullFilter(){let e={projects:this.projectConfig.projects,variants:this.projectConfig.variants};return this.output.projects&&(e.projects=this.output.projects),this.output.variants&&(e.variants=this.output.variants),e}generateComponentPullFilter(){let e={...this.projectConfig.components?.folders&&{folders:this.projectConfig.components.folders},variants:this.projectConfig.variants};return this.output.components&&(e.folders=this.output.components?.folders),this.output.variants&&(e.variants=this.output.variants),e}generateQueryParams(e){let o=e==="textItem"?this.generateTextItemPullFilter():this.generateComponentPullFilter(),r={filter:JSON.stringify(o)};return this.projectConfig.richText&&(r.richText=this.projectConfig.richText),this.output.richText&&(r.richText=this.output.richText),r}async fetchTextItems(){return!this.projectConfig.projects&&!this.output.projects?[]:await je(this.generateQueryParams("textItem"),this.meta)}async fetchComponents(){return!this.projectConfig.components&&!this.output.components?[]:await Fe(this.generateQueryParams("component"),this.meta)}async fetchVariables(){return await be(this.meta)}};n(Me,"JSONFormatter");var Jt=Me;function Re(t,e,o){switch(t.format){case"json":return new Jt(t,e,o).format();default:throw new Error(`Unsupported output format: ${t}`)}}n(Re,"formatOutput");var gr=n(async t=>{for(let e of y.selectedProjectConfigOutputs)await Re(e,y.projectConfig,t)},"pull");var hr=m(require("@sentry/node"));async function Ct(t,e=2){t&&T.writeLine(`
|
|
113
113
|
${t}
|
|
114
|
-
`),await
|
|
115
|
-
`)||"Invalid API key"},"validate");async function
|
|
116
|
-
`);let o=Yt(t);return
|
|
114
|
+
`),await hr.flush(),process.exit(e)}n(Ct,"quit");var vr=m(require("fs"));var _e=m(require("fs")),$e=m(require("js-yaml")),St=require("zod");var _s=St.z.record(St.z.string(),St.z.array(St.z.object({token:St.z.string()})));function Kt(t=y.configFile){kt(t);let e=_e.default.readFileSync(t,"utf8"),o=$e.default.load(e),r=_s.safeParse(o);return r.success?r.data:{}}n(Kt,"readGlobalConfigData");function $s(t,e){kt(t);let o=Kt(t),r=$e.default.dump({...o,...e});_e.default.writeFileSync(t,r,"utf8")}n($s,"writeGlobalConfigData");function yr(t,e,o){let r=Kt(t);r[e]=[{token:o}],$s(t,r)}n(yr,"saveToken");var Ir=m(require("@sentry/node"));var Tr=require("axios");async function Vt(t){try{return(await Z({token:t}).get("/token-check")).status===200?{success:!0}:{success:!1,output:[T.errorText("This API key isn't valid. Please try another.")]}}catch(e){return e instanceof Tr.AxiosError?e.code==="ENOTFOUND"?{success:!1,output:[T.errorText(`Can't connect to API: ${T.url(y.apiHost)}`)]}:e.response?.status===401||e.response?.status===404?{success:!1,output:[T.errorText("This API key isn't valid. Please try another.")]}:{success:!1,output:[T.errorText("Sorry! We're having trouble reaching the Ditto API. Please try again later.")]}:{success:!1,output:[T.warnText("Sorry! We're having trouble reaching the Ditto API. Please try again later.")]}}}n(Vt,"checkToken");var Cr=require("enquirer");var Ls=n(async t=>{let e=await Vt(t);return e.success?!0:e.output?.join(`
|
|
115
|
+
`)||"Invalid API key"},"validate");async function Le(){return await(0,Cr.prompt)({type:"input",name:"token",message:"What is your API key?",validate:Ls})}n(Le,"promptForApiToken");async function Je(){let e=`To get started, you'll need your Ditto API key. You can find this at: ${T.url("https://app.dittowords.com/developers/api-keys")}.`;return T.writeLine(e),(await Le()).token}n(Je,"collectToken");var Sr=m(require("url"));function Yt(t){return t.includes("://")?Sr.default.parse(t).hostname||"":t}n(Yt,"getURLHostname");async function It(t=y.apiHost){try{let e=await Je();T.writeLine(`Thanks for authenticating. We'll save the key to: ${T.info(y.configFile)}
|
|
116
|
+
`);let o=Yt(t);return yr(y.configFile,o,e),y.setApiToken(e),e}catch(e){if(e==="")return await Ct("",0),"";let o=Ir.captureException(e),r=`
|
|
117
117
|
|
|
118
|
-
Error ID: ${T.info(o)}`;return await
|
|
119
|
-
`),o);let
|
|
118
|
+
Error ID: ${T.info(o)}`;return await Ct(T.errorText("Something went wrong. Please contact support or try again later.")+r),""}}n(It,"collectAndSaveToken");async function te(t){return(await Vt(t)).success?t:await It()}n(te,"validateToken");async function Ve(){if(y.apiToken)return await te(y.apiToken);if(!vr.default.existsSync(y.configFile))return await It();let t=Kt(y.configFile),e=Yt(y.apiHost);return!t[e]||!t[e][0]||t[e][0].token===""?await It(e):await te(t[e][0].token)}n(Ve,"initAPIToken");var Js=n(t=>{let e={};return Array.isArray(t)&&t.forEach(o=>{let r=o.split(":");if(r.length>2)return;let[s,i]=r;e[s]=i}),e},"processCommandMetaFlag"),wr=Js;var Vs=[{name:"pull",description:"Sync copy from Ditto",flags:{"-c, --config [value]":{description:"Relative path to the project config file. Defaults to `./ditto/config.yml`. Alternatively, you can set the DITTO_PROJECT_CONFIG_FILE environment variable."}}}],Ys=n(()=>{H.program.name("ditto-cli"),Vs.forEach(t=>{let e=H.program.command(t.name).description(t.description).action(o=>qs(t.name,o));t.flags&&Object.entries(t.flags).forEach(([o,{description:r,processor:s}])=>{s?e.option(o,r,s):e.option(o,r)})})},"setupCommands"),Bs=n(()=>{H.program.option("--legacy","Run in legacy mode"),H.program.option("-m, --meta <data...>","Include arbitrary data in requests to the Ditto API. Ex: -m githubActionRequest:true trigger:manual"),H.program.version(ct,"-v, --version","Output the current version")},"setupOptions"),qs=n(async(t,e)=>{try{let o=e.opts(),r=await Ve();y.setApiToken(r),await rr(o);let{meta:s}=H.program.opts();switch(t){case"none":case"pull":return await gr(wr(s));default:{await Ct(`Invalid command: ${t}. Exiting Ditto CLI...`);return}}}catch(o){process.env.DEBUG==="true"&&console.error(T.info(`Development stack trace:
|
|
119
|
+
`),o);let r,s,i="Something went wrong. Please contact support or try again later.";tr(o)&&(s=o.exitCode,Te(o,"ConfigYamlLoadError")?i=o.message:Te(o,"ConfigParseError")&&(i=`${o.data.messagePrefix}
|
|
120
120
|
|
|
121
|
-
${o.data.formattedError}`),
|
|
121
|
+
${o.data.formattedError}`),r={extra:{message:i,...o.data||{}}});let a=jr.captureException(o,r),c=`
|
|
122
122
|
|
|
123
|
-
Error ID: ${T.info(a)}`;return await
|
|
123
|
+
Error ID: ${T.info(a)}`;return await Ct(T.errorText(i)+c,s)}},"executeCommand"),Gs=n(async()=>{Ys(),Bs(),H.program.parse(process.argv)},"appEntry"),Fr=Gs;var Us="production";br.init({dsn:"https://9c1d99fa4267f54c6b914f720b4ed3a2@o979374.ingest.sentry.io/4505705213919232",environment:Us,release:ct});var zs=n(async()=>{process.argv.includes("--legacy")?(console.log(T.warnText(`
|
|
124
124
|
Ditto CLI is running in legacy mode. This mode is deprecated and will be removed in a future release.
|
|
125
|
-
`)),
|
|
125
|
+
`)),Wo()):Fr()},"main");zs();
|
|
126
126
|
|
|
127
|
-
//# debugId=
|
|
127
|
+
//# debugId=3333db72-d8d9-546d-a336-10eba2a87fc0
|