diff --git a/dist/index.js b/dist/index.js
index 45c3a98..946646f 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -32,7 +32,7 @@ Expecting `+y1.join(", ")+", got '"+(this.terminals_[C]||C)+"'":z="Parse error o
`,e};B.prototype.Program=function(t){var e="",a=t.body,r=void 0,i=void 0;if(t.blockParams){var p="BLOCK PARAMS: [";for(r=0,i=t.blockParams.length;r "+e+" }}")};B.prototype.PartialBlockStatement=function(t){var e="PARTIAL BLOCK:"+t.name.original;return t.params[0]&&(e+=" "+this.accept(t.params[0])),t.hash&&(e+=" "+this.accept(t.hash)),e+=" "+this.pad("PROGRAM:"),this.padding++,e+=this.accept(t.program),this.padding--,this.pad("{{> "+e+" }}")};B.prototype.ContentStatement=function(t){return this.pad("CONTENT[ '"+t.value+"' ]")};B.prototype.CommentStatement=function(t){return this.pad("{{! '"+t.value+"' }}")};B.prototype.SubExpression=function(t){for(var e=t.params,a=[],r=void 0,i=0,p=e.length;i
{var Ya=u2().default,f2=m2();Ya.PrintVisitor=f2.PrintVisitor;Ya.print=f2.print;h2.exports=Ya;function c2(t,e){var a=require("fs"),r=a.readFileSync(e,"utf8");t.exports=Ya.compile(r)}typeof require<"u"&&require.extensions&&(require.extensions[".handlebars"]=c2,require.extensions[".hbs"]=c2)});var M=pe(X1()),A2=pe(require("fs"));var S=pe(X1()),s1=pe(Ko()),ua=pe(require("crypto"));var O=class extends Error{constructor(e,a,r,...i){Array.isArray(a)&&(a=a.join(" ")),super(a),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,O),this.code=e;for(let p of i)for(let s in p){let o=p[s];this[s]=Buffer.isBuffer(o)?o.toString(r.encoding):o==null?o:JSON.parse(JSON.stringify(o))}}};var $o=function(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)};var sa=function(t){let e=[];for(let a=0,r=t.length;a=this.size&&(this.resize(),a>=this.size))throw Error("INVALID_BUFFER_STATE");let r=this.buf;this.buf=Buffer.allocUnsafe(this.size),e.copy(this.buf,0),r.copy(this.buf,e.length),this.length+=e.length}else{let a=this.length++;a===this.size&&this.resize();let r=this.clone();this.buf[0]=e,r.copy(this.buf,1,0,a)}}append(e){let a=this.length++;a===this.size&&this.resize(),this.buf[a]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){let e=this.length;this.size=this.size*2;let a=Buffer.allocUnsafe(this.size);this.buf.copy(a,0,0,e),this.buf=a}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},ri=ai;var _3=12,w3=13,b3=10,E3=32,y3=9,Jo=function(t){return{bomSkipped:!1,bufBytesStart:0,castField:t.cast_function,commenting:!1,error:void 0,enabled:t.from_line===1,escaping:!1,escapeIsQuote:Buffer.isBuffer(t.escape)&&Buffer.isBuffer(t.quote)&&Buffer.compare(t.escape,t.quote)===0,expectedRecordLength:Array.isArray(t.columns)?t.columns.length:void 0,field:new ri(20),firstLineToHeaders:t.cast_first_line_to_header,needMoreDataSize:Math.max(t.comment!==null?t.comment.length:0,...t.delimiter.map(e=>e.length),t.quote!==null?t.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new ri(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:t.record_delimiter.length===0?0:Math.max(...t.record_delimiter.map(e=>e.length)),trimChars:[Buffer.from(" ",t.encoding)[0],Buffer.from(" ",t.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[Buffer.from(Buffer.from([w3],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([b3],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([_3],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([E3],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([y3],"utf8").toString(),t.encoding)]}};var Qo=function(t){return t.replace(/([A-Z])/g,function(e,a){return"_"+a.toLowerCase()})};var ii=function(t){let e={};for(let r in t)e[Qo(r)]=t[r];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new O("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new O("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new O("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(r){let i=Date.parse(r);return isNaN(i)?r:new Date(i)};else if(typeof e.cast_date!="function")throw new O("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=sa(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new O("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new O("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new O("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=Buffer.from(e.comment,e.encoding)),!Buffer.isBuffer(e.comment))throw new O("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);let a=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new O("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${a}`],e);if(e.delimiter=e.delimiter.map(function(r){if(r==null||r===!1)return Buffer.from(",",e.encoding);if(typeof r=="string"&&(r=Buffer.from(r,e.encoding)),!Buffer.isBuffer(r)||r.length===0)throw new O("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${a}`],e);return r}),e.escape===void 0||e.escape===!0?e.escape=Buffer.from('"',e.encoding):typeof e.escape=="string"?e.escape=Buffer.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!Buffer.isBuffer(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(t.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(t.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(t.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new O("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new O("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(Buffer.isBuffer(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new O("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=Buffer.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=Buffer.from(e.quote,e.encoding)),!Buffer.isBuffer(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||Buffer.isBuffer(e.record_delimiter)){if(e.record_delimiter.length===0)throw new O("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new O("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(r,i){if(typeof r!="string"&&!Buffer.isBuffer(r))throw new O("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${i},`,`got ${JSON.stringify(r)}`],e);if(r.length===0)throw new O("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${i},`,`got ${JSON.stringify(r)}`],e);return typeof r=="string"&&(r=Buffer.from(r,e.encoding)),r}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&t.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&t.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(t.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(t.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(t.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(t.to_line)}`);return e};var Yo=function(t){return t.every(e=>e==null||e.toString&&e.toString().trim()==="")},T3=13,S3=10,oa={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},Zo=function(t={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},a=ii(t);return{info:e,original_options:t,options:a,state:Jo(a),__needMoreData:function(r,i,p){if(p)return!1;let{encoding:s,escape:o,quote:n}=this.options,{quoting:d,needMoreDataSize:u,recordDelimiterMaxLength:l}=this.state,m=i-r-1,f=Math.max(u,l===0?Buffer.from(`\r
`,s).length:l,d?(o===null?0:o.length)+n.length:0,d?n.length+l:0);return mD){this.state.stop=!0,s();return}this.state.quoting===!1&&C.length===0&&this.__autoDiscoverRecordDelimiter(N,E)&&(C=this.options.record_delimiter);let k=N[E];if(l===!0&&$.append(k),(k===T3||k===S3)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(b!==null&&this.state.quoting===!0&&this.__isEscape(N,E,k)&&E+b.length=n){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),E+=z-1;continue}if(g===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,E+=z-1;continue}this.info.bytes=this.state.bufBytesStart+E;let Nt=this.__onField();if(Nt!==void 0)return Nt;this.info.bytes=this.state.bufBytesStart+E+z;let Q1=this.__onRecord(p);if(Q1!==void 0)return Q1;if(_!==-1&&this.info.records>=_){this.state.stop=!0,s();return}}this.state.commenting=!1,E+=z-1;continue}if(this.state.commenting)continue;if((y===null?0:this.__compareBytes(y,N,E,k))!==0){this.state.commenting=!0;continue}let At=this.__isDelimiter(N,E,k);if(At!==0){this.info.bytes=this.state.bufBytesStart+E;let J1=this.__onField();if(J1!==void 0)return J1;E+=At-1;continue}}}if(this.state.commenting===!1&&u!==0&&this.state.record_length+this.state.field.length>u)return this.__error(new O("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${u}`,`at line ${this.info.lines}`],this.options,this.__infoField()));let Oe=d===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(N,E),y1=f===!1||this.state.wasQuoting===!1;if(Oe===!0&&y1===!0)this.state.field.append(k);else{if(f===!0&&!this.__isCharTrimable(N,E))return this.__error(new O("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));Oe===!1&&(E+=this.__isCharTrimable(N,E)-1);continue}}if(i===!0)if(this.state.quoting===!0){let k=this.__error(new O("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(k!==void 0)return k}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+E;let k=this.__onField();if(k!==void 0)return k;let Oe=this.__onRecord(p);if(Oe!==void 0)return Oe}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=E,this.state.previousBuf=N.slice(E);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(r){let{columns:i,group_columns_by_name:p,encoding:s,info:o,from:n,relax_column_count:d,relax_column_count_less:u,relax_column_count_more:l,raw:m,skip_records_with_empty_values:f}=this.options,{enabled:g,record:_}=this.state;if(g===!1)return this.__resetRecord();let D=_.length;if(i===!0){if(f===!0&&Yo(_)){this.__resetRecord();return}return this.__firstLineToColumns(_)}if(i===!1&&this.info.records===0&&(this.state.expectedRecordLength=D),D!==this.state.expectedRecordLength){let y=i===!1?new O("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${D} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_}):new O("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${i.length},`,`got ${D} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_});if(d===!0||u===!0&&Dthis.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=y;else{let b=this.__error(y);if(b)return b}}if(f===!0&&Yo(_)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,n===1||this.info.records>=n){let{objname:y}=this.options;if(i!==!1){let b={};for(let T=0,C=_.length;T{let{timchars:n}=this.state;e:for(let d=0;d=0},__compareBytes:function(r,i,p,s){if(r[0]!==s)return 0;let o=r.length;for(let n=1;nthis.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}};var na=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let a=e&&e.objname?{}:[],r=Zo(e),i=n=>{r.options.objname===void 0?a.push(n):a[n[0]]=n[1]},p=()=>{},s=r.parse(t,!1,i,p);if(s!==void 0)throw s;let o=r.parse(void 0,!0,i,p);if(o!==void 0)throw o;return a};var ma=pe(require("fs")),tn=pe(require("os")),h1=pe(require("path"));function an(){let t=pi();return{addHosts:la(S.getInput("add-hosts")),allow:la(S.getInput("allow")),buildArgs:S.getMultilineInput("build-args"),buildContexts:S.getMultilineInput("build-contexts"),buildxFallback:S.getBooleanInput("buildx-fallback"),cacheFrom:S.getMultilineInput("cache-from"),cacheTo:S.getMultilineInput("cache-to"),cgroupParent:S.getInput("cgroup-parent"),context:S.getInput("context")||t,file:S.getInput("file"),githubToken:S.getInput("github-token"),labels:S.getMultilineInput("labels"),load:S.getBooleanInput("load"),network:S.getInput("network"),noCache:S.getBooleanInput("no-cache"),noCacheFilters:S.getMultilineInput("no-cache-filters"),outputs:S.getMultilineInput("outputs"),platforms:la(S.getInput("platforms")),project:S.getInput("project"),pull:S.getBooleanInput("pull"),push:S.getBooleanInput("push"),secretFiles:S.getMultilineInput("secret-files"),secrets:S.getMultilineInput("secrets"),shmSize:S.getInput("shm-size"),ssh:S.getMultilineInput("ssh"),tags:la(S.getInput("tags")),target:S.getInput("target"),token:S.getInput("token")||process.env.DEPOT_TOKEN,ulimit:S.getMultilineInput("ulimit")}}var da;function pi(){if(da)return da;let t=process.env.GITHUB_SERVER_URL||"https://github.com",e=P3();return da=`${t}/${s1.context.repo.owner}/${s1.context.repo.repo}.git#${e}`,da}function P3(){let t=s1.context.ref;return s1.context.sha&&t&&!t.startsWith("refs/")&&(t=`refs/heads/${s1.context.ref}`),s1.context.sha&&!t.startsWith("refs/pull/")&&(t=s1.context.sha),t}var mt;function F1(){return mt||(S.getState("tempDir")?S.getState("tempDir"):(mt=ma.mkdtempSync(h1.join(tn.tmpdir(),"depot-build-push-").split(h1.sep).join(h1.posix.sep)),S.saveState("tempDir",mt),mt))}var en="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function rn(){let t=0;for(;t<20;){let e;try{e=ua.randomBytes(16)}catch{e=ua.pseudoRandomBytes(16)}let a=[];for(let i=0;i<10;i++)a.push(en[e.readUInt8(i)%en.length]);let r=h1.join(F1(),a.join(""));if(!ma.existsSync(r))return r;t+=1}throw new Error("Unable to generate a temporary file")}var si=!!S.getState("isPost");si||S.saveState("isPost","true");function la(t){return t=t.trim(),t===""?[]:na(t,{columns:!1,relaxColumnCount:!0,relaxQuotes:!0,skipEmptyLines:!0}).flatMap(a=>a).map(a=>a.trim()).filter(a=>a)}var l1=pe(X1()),Dt=pe(Pn()),_2=pe(Qt());var qe=pe(require("fs")),w2=pe(g2()),Ye=pe(require("path"));var H5=new _2.HttpClient("depot-build-push-action");async function b2(){try{let{exitCode:t}=await Dt.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function E2(){await Dt.exec("depot",["version"],{failOnStdErr:!1})}async function v2(t,e,a){var i,p;let r=await Dt.getExecOutput(t,e,a);if(r.stderr.length>0&&r.exitCode!=0)throw new Error(`failed with: ${((p=(i=r.stderr.match(/(.*)\s*$/))==null?void 0:i[0])==null?void 0:p.trim())??"unknown error"}`)}async function y2(t){let e=pi(),a=w2.compile(t.context)({defaultContext:e}),r=[...G("--add-host",t.addHosts),...G("--allow",t.allow.join(",")),...G("--build-arg",t.buildArgs),...G("--build-context",t.buildContexts),...G("--cache-from",t.cacheFrom),...G("--cache-to",t.cacheTo),...G("--cgroup-parent",t.cgroupParent),...G("--file",t.file),...G("--iidfile",z5(t.outputs)?!1:T2()),...G("--label",t.labels),...G("--load",t.load),...G("--metadata-file",P2()),...G("--network",t.network),...G("--no-cache",t.noCache),...G("--no-cache-filter",t.noCacheFilters),...G("--output",t.outputs),...G("--platform",t.platforms.join(",")),...G("--pull",t.pull),...G("--push",t.push),...G("--shm-size",t.shmSize),...G("--ssh",t.ssh),...G("--tag",t.tags),...G("--target",t.target),...G("--ulimit",t.ulimit),...G("--secret",t.secrets.map(o=>rp(o)).filter(o=>Boolean(o))),...G("--secret",t.secretFiles.map(o=>rp(o,!0)).filter(o=>Boolean(o))),...G("--secret",t.githubToken&&!W5(t.secrets)&&a.startsWith(e)?rp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1)],i=[...G("--project",t.project)],p=[...r,...i],s=t.token??process.env.DEPOT_TOKEN;if(!s)try{let o=await l1.getIDToken("https://depot.dev"),n=await H5.postJson("https://depot.dev/api/auth/oidc/github-actions",{token:o});n.result&&n.result.token&&(s=n.result.token,l1.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch(o){l1.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${o}`)}try{await v2("depot",["build",...p,a],{ignoreReturnCode:!0,env:{...process.env,...s?{DEPOT_TOKEN:s}:{}}})}catch(o){if(t.buildxFallback)l1.warning(`falling back to buildx: ${o}`),await v2("docker",["buildx","build",...r,a],{ignoreReturnCode:!0});else throw o}}function G(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(a=>[t,a]):[t,e]:[]}function z5(t){let e=na(t.join(`
+`,p),Buffer.from("\r",p)];e:for(let o=0;othis.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}};var na=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let a=e&&e.objname?{}:[],r=Zo(e),i=n=>{r.options.objname===void 0?a.push(n):a[n[0]]=n[1]},p=()=>{},s=r.parse(t,!1,i,p);if(s!==void 0)throw s;let o=r.parse(void 0,!0,i,p);if(o!==void 0)throw o;return a};var ma=pe(require("fs")),tn=pe(require("os")),h1=pe(require("path"));function an(){let t=pi();return{addHosts:la(S.getInput("add-hosts")),allow:la(S.getInput("allow")),buildArgs:S.getMultilineInput("build-args"),buildContexts:S.getMultilineInput("build-contexts"),buildxFallback:S.getBooleanInput("buildx-fallback"),cacheFrom:S.getMultilineInput("cache-from"),cacheTo:S.getMultilineInput("cache-to"),cgroupParent:S.getInput("cgroup-parent"),context:S.getInput("context")||t,file:S.getInput("file"),githubToken:S.getInput("github-token"),labels:S.getMultilineInput("labels"),load:S.getBooleanInput("load"),network:S.getInput("network"),noCache:S.getBooleanInput("no-cache"),noCacheFilters:S.getMultilineInput("no-cache-filters"),outputs:S.getMultilineInput("outputs"),platforms:la(S.getInput("platforms")),project:S.getInput("project"),pull:S.getBooleanInput("pull"),push:S.getBooleanInput("push"),secretFiles:S.getMultilineInput("secret-files"),secrets:S.getMultilineInput("secrets"),shmSize:S.getInput("shm-size"),ssh:S.getMultilineInput("ssh"),tags:la(S.getInput("tags")),target:S.getInput("target"),token:S.getInput("token")||process.env.DEPOT_TOKEN,ulimit:S.getMultilineInput("ulimit")}}var da;function pi(){if(da)return da;let t=process.env.GITHUB_SERVER_URL||"https://github.com",e=P3();return da=`${t}/${s1.context.repo.owner}/${s1.context.repo.repo}.git#${e}`,da}function P3(){let t=s1.context.ref;return s1.context.sha&&t&&!t.startsWith("refs/")&&(t=`refs/heads/${s1.context.ref}`),s1.context.sha&&!t.startsWith("refs/pull/")&&(t=s1.context.sha),t}var mt;function F1(){return mt||(S.getState("tempDir")?S.getState("tempDir"):(mt=ma.mkdtempSync(h1.join(tn.tmpdir(),"depot-build-push-").split(h1.sep).join(h1.posix.sep)),S.saveState("tempDir",mt),mt))}var en="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function rn(){let t=0;for(;t<20;){let e;try{e=ua.randomBytes(16)}catch{e=ua.pseudoRandomBytes(16)}let a=[];for(let i=0;i<10;i++)a.push(en[e.readUInt8(i)%en.length]);let r=h1.join(F1(),a.join(""));if(!ma.existsSync(r))return r;t+=1}throw new Error("Unable to generate a temporary file")}var si=!!S.getState("isPost");si||S.saveState("isPost","true");function la(t){return t=t.trim(),t===""?[]:na(t,{columns:!1,relaxColumnCount:!0,relaxQuotes:!0,skipEmptyLines:!0}).flatMap(a=>a).map(a=>a.trim()).filter(a=>a)}var l1=pe(X1()),Dt=pe(Pn()),_2=pe(Qt());var qe=pe(require("fs")),w2=pe(g2()),Ye=pe(require("path"));var H5=new _2.HttpClient("depot-build-push-action");async function b2(){try{let{exitCode:t}=await Dt.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function E2(){await Dt.exec("depot",["version"],{failOnStdErr:!1})}async function v2(t,e,a){var i,p;let r=await Dt.getExecOutput(t,e,a);if(r.stderr.length>0&&r.exitCode!=0)throw new Error(`failed with: ${((p=(i=r.stderr.match(/(.*)\s*$/))==null?void 0:i[0])==null?void 0:p.trim())??"unknown error"}`)}async function y2(t){let e=pi(),a=w2.compile(t.context)({defaultContext:e}),r=[...G("--add-host",t.addHosts),...G("--allow",t.allow.join(",")),...G("--build-arg",t.buildArgs),...G("--build-context",t.buildContexts),...G("--cache-from",t.cacheFrom),...G("--cache-to",t.cacheTo),...G("--cgroup-parent",t.cgroupParent),...G("--file",t.file),...G("--iidfile",z5(t.outputs)?!1:T2()),...G("--label",t.labels),...G("--load",t.load),...G("--metadata-file",P2()),...G("--network",t.network),...G("--no-cache",t.noCache),...G("--no-cache-filter",t.noCacheFilters),...G("--output",t.outputs),...G("--platform",t.platforms.join(",")),...G("--pull",t.pull),...G("--push",t.push),...G("--shm-size",t.shmSize),...G("--ssh",t.ssh),...G("--tag",t.tags),...G("--target",t.target),...G("--ulimit",t.ulimit),...G("--secret",t.secrets.map(o=>rp(o)).filter(o=>Boolean(o))),...G("--secret",t.secretFiles.map(o=>rp(o,!0)).filter(o=>Boolean(o))),...G("--secret",t.githubToken&&!W5(t.secrets)&&a.startsWith(e)?rp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1)],i=[...G("--project",t.project)],p=[...r,...i],s=t.token??process.env.DEPOT_TOKEN;if(!s)try{let o=await l1.getIDToken("https://depot.dev"),n=await H5.postJson("https://github.depot.dev/auth/oidc/github-actions",{token:o});n.result&&n.result.token&&(s=n.result.token,l1.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch(o){l1.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${o}`)}try{await v2("depot",["build",...p,a],{ignoreReturnCode:!0,env:{...process.env,...s?{DEPOT_TOKEN:s}:{}}})}catch(o){if(t.buildxFallback)l1.warning(`falling back to buildx: ${o}`),await v2("docker",["buildx","build",...r,a],{ignoreReturnCode:!0});else throw o}}function G(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(a=>[t,a]):[t,e]:[]}function z5(t){let e=na(t.join(`
`),{columns:!1,relaxColumnCount:!0,trim:!0});for(let a of e){if(a.length===1&&!a[0].startsWith("type="))return!0;for(let[r,i]of a.map(p=>p.split("=").map(s=>s.trim())))if(r==="type"&&(i==="local"||i==="tar"))return!0}return!1}function W5(t){return t.some(e=>e.startsWith("GIT_AUTH_TOKEN="))}function rp(t,e){try{let a=t.indexOf("="),r=t.substring(0,a),i=t.substring(a+1);if(!r||!i)throw new Error(`Invalid secret: ${t}`);if(e){if(!qe.existsSync(i))throw new Error(`Secret file not found: ${i}`);i=qe.readFileSync(i,"utf8")}let p=rn();return qe.writeFileSync(p,i),`id=${r},src=${p}`}catch(a){l1.warning(a.message)}}function T2(){return Ye.join(F1(),"iidfile").split(Ye.sep).join(Ye.posix.sep)}function S2(){let t=T2();if(!!qe.existsSync(t))return qe.readFileSync(t,{encoding:"utf-8"}).trim()}function P2(){return Ye.join(F1(),"metadata-file").split(Ye.sep).join(Ye.posix.sep)}function O2(){let t=P2();if(!qe.existsSync(t))return;let e=qe.readFileSync(t,{encoding:"utf-8"}).trim();if(e!=="null")return e}function D2(t){return t===void 0?void 0:JSON.parse(t)["containerimage.digest"]}async function $5(){if(!await b2())return M.setFailed("Depot CLI is not installed. See https://github.com/depot/setup-action to install it before this step.");await M.group("Depot version",async()=>{await E2()});let t=an();await y2(t);let e=S2(),a=O2(),r=D2(a);e&&await M.group("ImageID",async()=>{M.info(e),M.setOutput("imageid",e)}),r&&await M.group("Digest",async()=>{M.info(r),M.setOutput("digest",r)}),a&&await M.group("Metadata",async()=>{M.info(a),M.setOutput("metadata",a)})}async function J5(){let t=F1();t.length!==0&&(M.startGroup(`Removing temp folder ${t}`),A2.rmSync(t,{recursive:!0}),M.endGroup())}(si?J5():$5()).catch(t=>{t instanceof Error?M.setFailed(t.message):M.setFailed(`${t}`)});
/*!
* is-plain-object
diff --git a/src/depot.ts b/src/depot.ts
index 216f0e5..615d42e 100644
--- a/src/depot.ts
+++ b/src/depot.ts
@@ -84,7 +84,7 @@ export async function build(inputs: Inputs) {
try {
const odicToken = await core.getIDToken('https://depot.dev')
const res = await client.postJson<{ok: boolean; token: string}>(
- 'https://depot.dev/api/auth/oidc/github-actions',
+ 'https://github.depot.dev/auth/oidc/github-actions',
{token: odicToken},
)
if (res.result && res.result.token) {