diff --git a/dist/index.js b/dist/index.js index a836f13..8c04a26 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32,7 +32,7 @@ Expecting `+v1.join(", ")+", got '"+(this.terminals_[k]||k)+"'":V="Parse error o `,e};q.prototype.Program=function(t){var e="",a=t.body,r=void 0,p=void 0;if(t.blockParams){var i="BLOCK PARAMS: [";for(r=0,p=t.blockParams.length;r "+e+" }}")};q.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+" }}")};q.prototype.ContentStatement=function(t){return this.pad("CONTENT[ '"+t.value+"' ]")};q.prototype.CommentStatement=function(t){return this.pad("{{! '"+t.value+"' }}")};q.prototype.SubExpression=function(t){for(var e=t.params,a=[],r=void 0,p=0,i=e.length;p=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}},Rr=Cr;var io=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 Rr(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 Rr(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:t.record_delimiter.length===0?2:Math.max(...t.record_delimiter.map(e=>e.length)),trimChars:[Buffer.from(" ",t.encoding)[0],Buffer.from(" ",t.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1}};var so=function(t){return t.replace(/([A-Z])/g,function(e,a){return"_"+a.toLowerCase()})};var Gr=function(t){let e={};for(let r in t)e[so(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 P("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 P("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 P("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 p=Date.parse(r);return isNaN(p)?r:new Date(p)};else throw new P("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=Ut(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new P("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 P("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 P("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 P("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 P("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 P("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 P("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 P("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 P("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 P("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 P("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,p){if(typeof r!="string"&&!Buffer.isBuffer(r))throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${p},`,`got ${JSON.stringify(r)}`],e);if(r.length===0)throw new P("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${p},`,`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 oo=function(t){return t.every(e=>e==null||e.toString&&e.toString().trim()==="")},E6=9,Bt=10,y6=12,Lr=13,T6=32,qt={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},no=function(t={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},a=Gr(t);return{info:e,original_options:t,options:a,state:io(a),__needMoreData:function(r,p,i){if(i)return!1;let{quote:s}=this.options,{quoting:o,needMoreDataSize:d,recordDelimiterMaxLength:n}=this.state,m=p-r-1,l=Math.max(d,n,o?s.length+n:0);return mD){this.state.stop=!0,s();return}this.state.quoting===!1&&k.length===0&&this.__autoDiscoverRecordDelimiter(C,b)&&(k=this.options.record_delimiter);let A=C[b];if(v===!0&&J.append(A),(A===Lr||A===Bt)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(n!==null&&this.state.quoting===!0&&this.__isEscape(C,b,A)&&b+n.length=m){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),b+=V-1;continue}if(y===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,b+=V-1;continue}this.info.bytes=this.state.bufBytesStart+b;let Et=this.__onField();if(Et!==void 0)return Et;this.info.bytes=this.state.bufBytesStart+b+V;let j1=this.__onRecord(i);if(j1!==void 0)return j1;if(E!==-1&&this.info.records>=E){this.state.stop=!0,s();return}}this.state.commenting=!1,b+=V-1;continue}if(this.state.commenting)continue;if((d===null?0:this.__compareBytes(d,C,b,A))!==0){this.state.commenting=!0;continue}let bt=this.__isDelimiter(C,b,A);if(bt!==0){this.info.bytes=this.state.bufBytesStart+b;let M1=this.__onField();if(M1!==void 0)return M1;b+=bt-1;continue}}}if(this.state.commenting===!1&&u!==0&&this.state.record_length+this.state.field.length>u){let V=this.__error(new P("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()));if(V!==void 0)return V}let De=l===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(A),v1=O===!1||this.state.wasQuoting===!1;if(De===!0&&v1===!0)this.state.field.append(A);else if(O===!0&&!this.__isCharTrimable(A)){let V=this.__error(new P("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()));if(V!==void 0)return V}}if(p===!0)if(this.state.quoting===!0){let A=this.__error(new P("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(A!==void 0)return A}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+b;let A=this.__onField();if(A!==void 0)return A;let De=this.__onRecord(i);if(De!==void 0)return De}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=b,this.state.previousBuf=C.slice(b);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(r){let{columns:p,group_columns_by_name:i,encoding:s,info:o,from:d,relax_column_count:n,relax_column_count_less:m,relax_column_count_more:l,raw:u,skip_records_with_empty_values:h}=this.options,{enabled:v,record:_}=this.state;if(v===!1)return this.__resetRecord();let O=_.length;if(p===!0){if(h===!0&&oo(_)){this.__resetRecord();return}return this.__firstLineToColumns(_)}if(p===!1&&this.info.records===0&&(this.state.expectedRecordLength=O),O!==this.state.expectedRecordLength){let y=p===!1?new P("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${O} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_}):new P("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${p.length},`,`got ${O} on line ${this.info.lines}`],this.options,this.__infoField(),{record:_});if(n===!0||m===!0&&Othis.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=y;else{let E=this.__error(y);if(E)return E}}if(h===!0&&oo(_)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,d===1||this.info.records>=d){let{objname:y}=this.options;if(p!==!1){let E={};for(let D=0,k=_.length;D=0},__compareBytes:function(r,p,i,s){if(r[0]!==s)return 0;let o=r.length;for(let d=1;dthis.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting})}}};var Mt=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let a=e&&e.objname?{}:[],r=no(e),p=d=>{r.options.objname===void 0?a.push(d):a[d[0]]=d[1]},i=()=>{},s=r.parse(t,!1,p,i);if(s!==void 0)throw s;let o=r.parse(void 0,!0,p,i);if(o!==void 0)throw o;return a};var Wt=re(require("fs")),co=re(require("os")),d1=re(require("path"));function ho(){let t=Vr();return{addHosts:Ht(S.getInput("add-hosts")),allow:Ht(S.getInput("allow")),buildArgs:S.getMultilineInput("build-args"),buildContexts:S.getMultilineInput("build-contexts"),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"),outputs:S.getMultilineInput("outputs"),platforms:Ht(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:Ht(S.getInput("tags")),target:S.getInput("target"),token:S.getInput("token")||process.env.DEPOT_TOKEN,ulimit:S.getMultilineInput("ulimit")}}var jt;function Vr(){if(jt)return jt;let t=process.env.GITHUB_SERVER_URL||"https://github.com",e=S6();return jt=`${t}/${r1.context.repo.owner}/${r1.context.repo.repo}.git#${e}`,jt}function S6(){let t=r1.context.ref;return r1.context.sha&&t&&!t.startsWith("refs/")&&(t=`refs/heads/${r1.context.ref}`),r1.context.sha&&!t.startsWith("refs/pull/")&&(t=r1.context.sha),t}var pt;function C1(){return pt||(S.getState("tempDir")?S.getState("tempDir"):(pt=Wt.mkdtempSync(d1.join(co.tmpdir(),"depot-build-push-").split(d1.sep).join(d1.posix.sep)),S.saveState("tempDir",pt),pt))}var mo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function fo(){let t=0;for(;t<20;){let e;try{e=zt.randomBytes(16)}catch{e=zt.pseudoRandomBytes(16)}let a=[];for(let p=0;p<10;p++)a.push(mo[e.readUInt8(p)%mo.length]);let r=d1.join(C1(),a.join(""));if(!Wt.existsSync(r))return r;t+=1}throw new Error("Unable to generate a temporary file")}var Ir=!!S.getState("isPost");Ir||S.saveState("isPost","true");function Jt(t,e){(0,uo.issueCommand)("set-output",{name:t},e)}function Ht(t){return t=t.trim(),t===""?[]:Mt(t,{columns:!1,relaxColumnCount:!0,relaxQuotes:!0,skipEmptyLines:!0}).flatMap(a=>a).map(a=>a.trim()).filter(a=>a)}var Ad=re(z1()),wt=re(Io());var Fe=re(require("fs")),kd=re(Dd()),Je=re(require("path"));async function Cd(){try{let{exitCode:t}=await wt.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function Rd(){await wt.exec("depot",["version"],{failOnStdErr:!1})}async function Gd(t){var p,i;let e=Vr(),a=["build",...L("--add-host",t.addHosts),...L("--allow",t.allow.join(",")),...L("--build-arg",t.buildArgs),...L("--build-context",t.buildContexts),...L("--cache-from",t.cacheFrom),...L("--cache-to",t.cacheTo),...L("--cgroup-parent",t.cgroupParent),...L("--file",t.file),...L("--iidfile",j9(t.outputs)?!1:Ld()),...L("--label",t.labels),...L("--load",t.load),...L("--metadata-file",Id()),...L("--network",t.network),...L("--no-cache",t.noCache),...L("--output",t.outputs),...L("--platform",t.platforms.join(",")),...L("--project",t.project),...L("--pull",t.pull),...L("--push",t.push),...L("--shm-size",t.shmSize),...L("--ssh",t.ssh),...L("--tag",t.tags),...L("--target",t.target),...L("--ulimit",t.ulimit),...L("--secret",t.secrets.map(s=>Gp(s)).filter(s=>Boolean(s))),...L("--secret",t.secretFiles.map(s=>Gp(s,!0)).filter(s=>Boolean(s))),...L("--secret",t.githubToken&&!H9(t.secrets)&&t.context==e?Gp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1),kd.compile(t.context)({defaultContext:e})],r=await wt.getExecOutput("depot",a,{ignoreReturnCode:!0,env:$e($e({},process.env),t.token?{DEPOT_TOKEN:t.token}:{})});if(r.stderr.length>0&&r.exitCode!=0)throw new Error(`depot failed with: ${((i=(p=r.stderr.match(/(.*)\s*$/))==null?void 0:p[0])==null?void 0:i.trim())??"unknown error"}`)}function L(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(a=>[t,a]):[t,e]:[]}function j9(t){let e=Mt(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,p]of a.map(i=>i.split("=").map(s=>s.trim())))if(r==="type"&&(p==="local"||p==="tar"))return!0}return!1}function H9(t){return t.some(e=>e.startsWith("GIT_AUTH_TOKEN="))}function Gp(t,e){try{let a=t.indexOf("="),r=t.substring(0,a),p=t.substring(a+1);if(!r||!p)throw new Error(`Invalid secret: ${t}`);if(e){if(!Fe.existsSync(p))throw new Error(`Secret file not found: ${p}`);p=Fe.readFileSync(p,"utf8")}let i=fo();return Fe.writeFileSync(i,p),`id=${r},src=${i}`}catch(a){Ad.warning(a.message)}}function Ld(){return Je.join(C1(),"iidfile").split(Je.sep).join(Je.posix.sep)}function Vd(){let t=Ld();if(!!Fe.existsSync(t))return Fe.readFileSync(t,{encoding:"utf-8"}).trim()}function Id(){return Je.join(C1(),"metadata-file").split(Je.sep).join(Je.posix.sep)}function xd(){let t=Id();if(!Fe.existsSync(t))return;let e=Fe.readFileSync(t,{encoding:"utf-8"}).trim();if(e!=="null")return e}function Fd(t){return t===void 0?void 0:JSON.parse(t)["containerimage.digest"]}async function W9(){if(!await Cd())return Z.setFailed("Depot CLI is not installed. See https://github.com/depot/setup-action to install it before this step.");await Z.group("Depot version",async()=>{await Rd()});let t=ho();await Gd(t);let e=Vd(),a=xd(),r=Fd(a);e&&await Z.group("ImageID",async()=>{Z.info(e),Jt("imageid",e)}),r&&await Z.group("Digest",async()=>{Z.info(r),Jt("digest",r)}),a&&await Z.group("Metadata",async()=>{Z.info(a),Jt("metadata",a)})}async function J9(){let t=C1();t.length!==0&&(Z.startGroup(`Removing temp folder ${t}`),Ud.rmdirSync(t,{recursive:!0}),Z.endGroup())}(Ir?J9():W9()).catch(t=>{t instanceof Error?Z.setFailed(t.message):Z.setFailed(`${t}`)}); +`),{columns:!1,relaxColumnCount:!0,trim:!0});for(let a of e){if(a.length===1&&!a[0].startsWith("type="))return!0;for(let[r,p]of a.map(i=>i.split("=").map(s=>s.trim())))if(r==="type"&&(p==="local"||p==="tar"))return!0}return!1}function H9(t){return t.some(e=>e.startsWith("GIT_AUTH_TOKEN="))}function Gp(t,e){try{let a=t.indexOf("="),r=t.substring(0,a),p=t.substring(a+1);if(!r||!p)throw new Error(`Invalid secret: ${t}`);if(e){if(!Fe.existsSync(p))throw new Error(`Secret file not found: ${p}`);p=Fe.readFileSync(p,"utf8")}let i=fo();return Fe.writeFileSync(i,p),`id=${r},src=${i}`}catch(a){Ad.warning(a.message)}}function Ld(){return Je.join(C1(),"iidfile").split(Je.sep).join(Je.posix.sep)}function Vd(){let t=Ld();if(!!Fe.existsSync(t))return Fe.readFileSync(t,{encoding:"utf-8"}).trim()}function Id(){return Je.join(C1(),"metadata-file").split(Je.sep).join(Je.posix.sep)}function xd(){let t=Id();if(!Fe.existsSync(t))return;let e=Fe.readFileSync(t,{encoding:"utf-8"}).trim();if(e!=="null")return e}function Fd(t){return t===void 0?void 0:JSON.parse(t)["containerimage.digest"]}async function W9(){if(!await Cd())return Z.setFailed("Depot CLI is not installed. See https://github.com/depot/setup-action to install it before this step.");await Z.group("Depot version",async()=>{await Rd()});let t=ho();await Gd(t);let e=Vd(),a=xd(),r=Fd(a);e&&await Z.group("ImageID",async()=>{Z.info(e),Jt("imageid",e)}),r&&await Z.group("Digest",async()=>{Z.info(r),Jt("digest",r)}),a&&await Z.group("Metadata",async()=>{Z.info(a),Jt("metadata",a)})}async function J9(){let t=C1();t.length!==0&&(Z.startGroup(`Removing temp folder ${t}`),Ud.rmSync(t,{recursive:!0}),Z.endGroup())}(Ir?J9():W9()).catch(t=>{t instanceof Error?Z.setFailed(t.message):Z.setFailed(`${t}`)}); /*! * is-plain-object * diff --git a/src/index.ts b/src/index.ts index 4ec32de..f416b47 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,7 +47,7 @@ async function cleanup() { const tempDir = context.getTempDir() if (tempDir.length === 0) return core.startGroup(`Removing temp folder ${tempDir}`) - fs.rmdirSync(tempDir, {recursive: true}) + fs.rmSync(tempDir, {recursive: true}) core.endGroup() }