stellate 2.7.4 → 2.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +3 -3
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1094,7 +1094,7 @@ Try running "stellate pull" first if your service has been created already.`);le
|
|
|
1094
1094
|
|
|
1095
1095
|
-s, --service Name of the service
|
|
1096
1096
|
-b, --browser Automatically open the preview UI with the default browser
|
|
1097
|
-
`);var ms=_e(gn());var bv=_e(gn());var LD=class{async parse(e){return Ji(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.7.
|
|
1097
|
+
`);var ms=_e(gn());var bv=_e(gn());var LD=class{async parse(e){return Ji(e,{"--help":Boolean,"-h":"--help","--version":Boolean,"-v":"--version","--json":Boolean})["--help"]?this.help():"stellate@2.7.5"}help(e){if(e)throw new Vn(`
|
|
1098
1098
|
${bv.default.bold.red("!")} ${e}
|
|
1099
1099
|
${LD.help}`);return LD.help}},_1=LD;_1.help=Yi(`
|
|
1100
1100
|
Print current version of Stellate
|
|
@@ -1293,7 +1293,7 @@ ${AN.help}`);return AN.help}},aw=AN;aw.help=Yi(`
|
|
|
1293
1293
|
All further pulls once a ${$s.default.dim("stellate")} config file has been created
|
|
1294
1294
|
${$s.default.dim("$")} stellate pull
|
|
1295
1295
|
|
|
1296
|
-
`);var dn=_e(gn()),D9e=_e(qf()),EJ=_e(require("is-ci"));var ow=_e(gn()),TJ="stellate_cache";function C9e(t,e,r){let i=[],n=t.getDirective(TJ);if(!n)return r;if(!(n.locations.includes(ut.FIELD_DEFINITION)&&n.locations.includes(ut.OBJECT)))return console.warn(ow.default.yellowBright("The @stellate_cache defined by the schema is defined for unexpected locations, expected are 'FIELD_DEFINITION' and 'OBJECT'.")),r;if(!n.args.find(c=>c.name==="maxAge"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'maxAge: Int!' argument.")),r;if(!n.args.find(c=>c.name==="swr"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'swr: Int' argument.")),r;if(!n.args.find(c=>c.name==="scope"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'scope: String' argument.")),r;let u=Object.entries(t.getTypeMap()).map(([c,p])=>c.startsWith("__")?void 0:p).filter(Boolean);for(let c=0;c<u.length;c++){let p=u[c];if(!qe(p))continue;let d=Yx(t,p,TJ);if(d&&d.length){let[h]=d;if(h.scope&&!e.includes(h.scope))throw new Error(`Found scope "${h.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:void 0,...h})}let f=Object.values(p.getFields());for(let h=0;h<f.length;h++){let m=f[h],g=Yx(t,m,TJ);if(!g||!g.length)continue;let[b]=g;if(b.scope&&!e.includes(b.scope))throw new Error(`Found scope "${b.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:m.name,...b})}}return i.reduce((c,p)=>{let d=Efr(p,c);if(!d)c.push({types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope});else if(p.field)if(Array.isArray(d.types[p.type]))d.types[p.type].includes(p.field)||d.types[p.type].push(p.field);else if(!d.types[p.type])d.types[p.type]=[p.field];else throw new Error(`Found "${typeof d.types[p.type]}" for "${p.type}" which is unexpected, file an issue at https://github.com/StellateHQ/cli/issues`);else Array.isArray(d.types[p.type])?c.push({types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope}):d.types[p.type]=!0;return c},r)}function Efr(t,e){let r=e.filter(i=>i.maxAge===t.maxAge);if(r.length)if(t.swr){let i=r.filter(n=>n.swr===t.swr);if(t.scope){let n=i.filter(s=>s.scope===t.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}else{let n=i.filter(s=>!s.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}}else if(t.scope){let i=r.filter(n=>n.scope===t.scope&&!n.swr);return t.field?i.find(n=>Array.isArray(n.types[t.type])):i.find(n=>!n.types[t.type])}else return r.find(i=>!i.swr&&!i.scope)}var PN=class{async parse(e){let r=Ji(e,{"--service":String,"--env":String,"--org":String,"--help":Boolean,"--dry":Boolean,"-e":"--env","-o":"--org","-h":"--help","--app":"--service"},!1);if(r["--help"])return this.help();if(r["--env"]&&r["--service"])throw new Error("Please only specify --env or --service.");let i=r._[0];if(i&&i!=="schema")throw new Error("The CLI does not support `stellate push [field]` anymore.\nInstead the entire configuration is now pushed for your environment to match it exactly.\nTo migrate, pull the latest configuration, which may include new fields you have set up in your dashboard, and run `stellate push`.");let n=r._[0]==="schema",s=await Zn(),a=r["--env"],o=await no(a),l=oc(o,r["--service"]),u=r["--dry"];if(a&&!o)throw new Error(`Could not find configuration for environment "${a}".
|
|
1296
|
+
`);var dn=_e(gn()),D9e=_e(qf()),EJ=_e(require("is-ci"));var ow=_e(gn()),TJ="stellate_cache";function C9e(t,e,r){let i=[],n=t.getDirective(TJ);if(!n)return r;if(!(n.locations.includes(ut.FIELD_DEFINITION)&&n.locations.includes(ut.OBJECT)))return console.warn(ow.default.yellowBright("The @stellate_cache defined by the schema is defined for unexpected locations, expected are 'FIELD_DEFINITION' and 'OBJECT'.")),r;if(!n.args.find(c=>c.name==="maxAge"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'maxAge: Int!' argument.")),r;if(!n.args.find(c=>c.name==="swr"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'swr: Int' argument.")),r;if(!n.args.find(c=>c.name==="scope"))return console.warn(ow.default.yellowBright("The @stellate_cache directive defined by the schema is missing the 'scope: String' argument.")),r;let u=Object.entries(t.getTypeMap()).map(([c,p])=>c.startsWith("__")?void 0:p).filter(Boolean);for(let c=0;c<u.length;c++){let p=u[c];if(!qe(p))continue;let d=Yx(t,p,TJ);if(d&&d.length){let[h]=d;if(h.scope&&!e.includes(h.scope))throw new Error(`Found scope "${h.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:void 0,...h})}let f=Object.values(p.getFields());for(let h=0;h<f.length;h++){let m=f[h],g=Yx(t,m,TJ);if(!g||!g.length)continue;let[b]=g;if(b.scope&&!e.includes(b.scope))throw new Error(`Found scope "${b.scope}" in the schema but not in the stellate config.`);i.push({type:p.name,field:m.name,...b})}}return i.reduce((c,p)=>{let d=Efr(p,c);if(!d)c.push({description:"This rule was generated from schema-directives",types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope});else if(p.field)if(Array.isArray(d.types[p.type]))d.types[p.type].includes(p.field)||d.types[p.type].push(p.field);else if(!d.types[p.type])d.types[p.type]=[p.field];else throw new Error(`Found "${typeof d.types[p.type]}" for "${p.type}" which is unexpected, file an issue at https://github.com/StellateHQ/cli/issues`);else Array.isArray(d.types[p.type])?c.push({description:"This rule was generated from schema-directives",types:{[p.type]:p.field?[p.field]:!0},maxAge:p.maxAge,swr:p.swr,scope:p.scope}):d.types[p.type]=!0;return c},r)}function Efr(t,e){let r=e.filter(i=>i.maxAge===t.maxAge);if(r.length)if(t.swr){let i=r.filter(n=>n.swr===t.swr);if(t.scope){let n=i.filter(s=>s.scope===t.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}else{let n=i.filter(s=>!s.scope);return t.field?n.find(s=>Array.isArray(s.types[t.type])):n.find(s=>!s.types[t.type])}}else if(t.scope){let i=r.filter(n=>n.scope===t.scope&&!n.swr);return t.field?i.find(n=>Array.isArray(n.types[t.type])):i.find(n=>!n.types[t.type])}else return r.find(i=>!i.swr&&!i.scope)}var PN=class{async parse(e){let r=Ji(e,{"--service":String,"--env":String,"--org":String,"--help":Boolean,"--dry":Boolean,"-e":"--env","-o":"--org","-h":"--help","--app":"--service"},!1);if(r["--help"])return this.help();if(r["--env"]&&r["--service"])throw new Error("Please only specify --env or --service.");let i=r._[0];if(i&&i!=="schema")throw new Error("The CLI does not support `stellate push [field]` anymore.\nInstead the entire configuration is now pushed for your environment to match it exactly.\nTo migrate, pull the latest configuration, which may include new fields you have set up in your dashboard, and run `stellate push`.");let n=r._[0]==="schema",s=await Zn(),a=r["--env"],o=await no(a),l=oc(o,r["--service"]),u=r["--dry"];if(a&&!o)throw new Error(`Could not find configuration for environment "${a}".
|
|
1297
1297
|
Either remove the --env (-e) flag or add configuration for this environment.`);if(!o)throw new Error(`Could not find stellate configuration file.
|
|
1298
1298
|
Try running "stellate pull" first if your service has been created already.`);let c=new En(s);if(u&&n)throw new Error(`We currently don't support combining "--dry" with schema pushes.`);if(Array.isArray(o.rateLimits)){let b=o.rateLimits.map(E=>E.name),T=new Set(b.filter((E,v)=>b.indexOf(E)!==v));if(T.size>0){let E=[...T].join(", ");throw new Error(`You have configured rate limits with the same name: ${E}.
|
|
1299
1299
|
Please make sure to provide a unique name for each rate limit.`)}}let p=await BY(o.schema,o.headers),d=await _f(p,o.headers,o.schemaView);if(Bs(p)){let b=C9e(p,Object.keys(o.scopes||{}),o.rules||[]);o.rules=b}if(!n)try{await this.diffConfig(c,o,l)||process.exit(0)}catch{}if(u)return"";let f=(0,D9e.default)(`Pushing ${n?"schema":"configuration"} for ${dn.default.bold(o.name)}`).start(),{app:h}=await c.query(`
|
|
@@ -1391,7 +1391,7 @@ Try running "stellate pull" first if your service has been created already.`);le
|
|
|
1391
1391
|
value
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
`,u=await Zn();a=(await new En(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,$J.default)();o.use("/",(0,qJ.createProxyMiddleware)({target:s,changeOrigin:!0,logLevel:"silent",onProxyReq:l=>{l.path.endsWith("/")&&(l.path=l.path.slice(0,-1)),l.setHeader("stellate-cli-serve-port",r),l.setHeader("stellate-token",a)}})),o.listen(r)}setupApiProxy(e,r){let i=`https://${e}.stellate.${process.env.STELLATE_ENDPOINT==="staging"||process.env.STELLATE_ENDPOINT==="local"?"dev":"sh"}`,n=(0,$J.default)();n.use("/",(0,qJ.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){qh.default.existsSync(lc)||qh.default.mkdirSync(lc)}getCache(){try{this.ensureConfig();let e=qh.default.readFileSync(RS,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=qh.default.readFileSync(RS,"utf-8"),i=JSON.parse(r);if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return i[e]||{checksum:"",envName:""}}catch{return{checksum:"",envName:""}}}getChecksum(e){return jdr(JSON.stringify(e)+"2.7.
|
|
1394
|
+
`,u=await Zn();a=(await new En(u).query(l,{name:"serve-token-"+Date.now(),appName:e})).createAdminApiToken.value,this.writePurgeToken(e,a)}let o=(0,$J.default)();o.use("/",(0,qJ.createProxyMiddleware)({target:s,changeOrigin:!0,logLevel:"silent",onProxyReq:l=>{l.path.endsWith("/")&&(l.path=l.path.slice(0,-1)),l.setHeader("stellate-cli-serve-port",r),l.setHeader("stellate-token",a)}})),o.listen(r)}setupApiProxy(e,r){let i=`https://${e}.stellate.${process.env.STELLATE_ENDPOINT==="staging"||process.env.STELLATE_ENDPOINT==="local"?"dev":"sh"}`,n=(0,$J.default)();n.use("/",(0,qJ.createProxyMiddleware)({target:i,changeOrigin:!0,headers:{"stellate-cli-serve-port":""+r},logLevel:"silent"})),n.listen(r)}ensureConfig(){qh.default.existsSync(lc)||qh.default.mkdirSync(lc)}getCache(){try{this.ensureConfig();let e=qh.default.readFileSync(RS,"utf-8");return JSON.parse(e)}catch{return{}}}getCacheEntry(e){try{this.ensureConfig();let r=qh.default.readFileSync(RS,"utf-8"),i=JSON.parse(r);if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return i[e]||{checksum:"",envName:""}}catch{return{checksum:"",envName:""}}}getChecksum(e){return jdr(JSON.stringify(e)+"2.7.5")}writePurgeToken(e,r){let i=this.getCache();i[e]={...i[e],purgeToken:r},qh.default.writeFileSync(RS,JSON.stringify(i))}writeCache(e,r,i){let n=this.getCache();if(!e)throw new Error('You need a service-name in your "stellate" config or as the "--service" argument.');return n[e]={checksum:this.getChecksum(r),envName:i},qh.default.writeFileSync(RS,JSON.stringify(n)),n[e]}},Sw=KJ;Sw.help=Yi(`
|
|
1395
1395
|
(BETA) - Use a local backend with Stellate\u2019s GraphQL Edge Cache.
|
|
1396
1396
|
|
|
1397
1397
|
${Ov.default.bold("Usage")}
|