@dropins/tools 0.31.0-alpha002 → 0.31.0-alpha003

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/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/tools", "version": "0.31.0-alpha002", "type": "module"}
1
+ {"name": "@dropins/tools", "version": "0.31.0-alpha003"}
@@ -1,6 +0,0 @@
1
- import p from"fs/promises";import{parseModule as w}from"esprima";import B from"escodegen";import{parse as f,print as E}from"graphql/language/index.mjs";import g from"path";function S(n){return f(n).definitions[0].name.value}function b(n,t){const e=f(n),o=new Set,s=new Set;return{operation:t.reduce((c,u)=>{var d,x;const[l]=e.definitions,[r]=f(u).definitions,i=r.name.value;return l.kind!==r.kind||l.name.value!==i||l.operation!==r.operation||((d=l.typeCondition)==null?void 0:d.name.value)!==((x=r.typeCondition)==null?void 0:x.name.value)?(s.add([i]),n):(v(l,r).forEach($=>{o.add([i,...$])}),E(e))},n),success:[...o],failure:[...s]}}function v(n,t,e=[]){const o=[];for(const s of t.selectionSet.selections){const a=n.selectionSet.selections.find(r=>{var i;return((i=r.name)==null?void 0:i.value)===s.name.value}),c=[...e,s.name.value],u=(a==null?void 0:a.arguments)??[],l=s.arguments;for(const r of l){const i=u.find(m=>m.name.value===r.name.value);i?i.value=r.value:u.push(r)}if(a!=null&&a.selectionSet&&s.selectionSet)o.push(...v(a,s,c));else{if(s.selectionSet&&c.push(s.selectionSet.selections[0].name.value),o.push(c),a)continue;n.selectionSet.selections.push(s)}}return o}async function j(n){try{await p.access(n);const t=n.replace(/\.\w+$/,".original$&");try{await p.access(t)}catch{await p.copyFile(n,t)}return{src:g.resolve(t),dist:g.resolve(n)}}catch{return null}}async function F(n){const t=g.join(process.cwd(),"node_modules",n,"fragments.js");return await j(t)}function y(n,t){return n.body.filter(e=>e.type==="ExportNamedDeclaration").flatMap(e=>e.specifiers).find(e=>e.exported.name===t)}function h(n,t){return n.body.filter(e=>e.type==="VariableDeclaration").flatMap(e=>e.declarations).find(e=>e.id.name===t)}function M(n){const t=n.init.quasis.map(o=>o.value.raw).join("").trim(),e=n.init.expressions.map(o=>`\${${o.name}}`).join(`
2
- `).trim();return[t,e]}function A(n,t){const e=w(n),o=y(e,t);if(!o)return null;const s=h(e,o.local.name),a=M(s);return{exported:o.exported.name,local:o.local.name,content:a[0],expressions:a[1]}}function D(n,t,e){const o=w(n),s=y(o,t),{local:a}=s,c=h(o,a.name);return c.init={type:"Literal",value:e,raw:`\`${e}\``},B.generate(o,{verbatim:"raw",format:{indent:{style:""},json:!0}}).replace(/\$\{\s(.*)\s\}/g,"${$1}")}async function C(n=[]){console.group("🔄 Updating GraphQl operation files...",`
3
- `);let t=new Map;for(const e of n){const{npm:o,operations:s=[]}=e;for(const a of s){const c=await F(o);if(!c){console.warn("\x1B[31m%s\x1B[0m",`⛔️ GraphQl file in "${o}" not found.`,"\x1B[0m");continue}await p.copyFile(c.src,c.dist);const u=t.get(c.dist)||await p.readFile(c.src,"utf-8"),l=S(a),r=A(u,l);if(!r){console.warn("\x1B[31m%s\x1B[0m",`⛔️ Operation "${l}" not found.`,"\x1B[0m");continue}const i=b(r.content,[a]);i.failure.forEach(d=>{console.warn("\x1B[31m%s\x1B[0m",`𐄂 ${d.join(".")}`,"\x1B[0m")}),i.success.forEach(d=>{console.log("\x1B[32m%s\x1B[0m",`✔ ${d.join(".")}`,"\x1B[0m")}),r.expressions&&(i.operation+=`
4
- `+r.expressions);const m=D(u,l,i.operation);t.set(c.dist,m)}}console.groupEnd(),console.log(`
5
- `),await Promise.all(Array.from(t.keys()).map(async e=>{const o=t.get(e);await p.writeFile(e,o),console.log(`💾 File "${e}" updated.`)})),console.log(`
6
- `)}export{C as default};
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './gql-extend/src/index'
@@ -1,2 +0,0 @@
1
- export { overrideGQLOperations as default } from './lib/override-files';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,9 +0,0 @@
1
- type GQLResult = {
2
- operation: string;
3
- success: string[][];
4
- failure: string[][];
5
- };
6
- export declare function getOperationName(operation: string): any;
7
- export declare function mergeGQLElements(operation: string, merges: string[]): GQLResult;
8
- export {};
9
- //# sourceMappingURL=extend-elements.d.ts.map
@@ -1,9 +0,0 @@
1
- export declare function getFilePath(file: string): Promise<{
2
- src: string;
3
- dist: string;
4
- } | null>;
5
- export declare function getNodeModulePath(name: string): Promise<{
6
- src: string;
7
- dist: string;
8
- } | null>;
9
- //# sourceMappingURL=get-paths.d.ts.map
@@ -1,6 +0,0 @@
1
- export type GQLOverride = {
2
- npm: string;
3
- operations: string[];
4
- };
5
- export declare function overrideGQLOperations(overrides?: GQLOverride[]): Promise<void>;
6
- //# sourceMappingURL=override-files.d.ts.map