khoros-aurora-sdk 24.4.0 → 24.4.1
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/.github/workflows/npm-publish.yml +1 -1
- package/README.md +47 -0
- package/build-hash.txt +1 -1
- package/buildPlugin.js +5 -5
- package/package.json +1 -1
- package/pluginPreview.js +8 -8
- package/setupPlugin.js +5 -5
- package/templates/.gitignore.tmpl +4 -4
- package/templates/.npmrc.tmpl +3 -1
- package/{tsconfig.server.json → templates/tsconfig.server.tmpl.json} +4 -4
- package/types/mf/aurora.d.ts +67301 -492
- package/types/pkg/aurora.d.ts +454 -18
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Using the Aurora SDK
|
|
2
|
+
|
|
3
|
+
Start by ensure you have NodeJS installed. Node versions 16 and 17 are currently supported. Using NVM
|
|
4
|
+
(https://github.com/nvm-sh/nvm) will make it easier to use newer version of NodeJS in the future. If you have
|
|
5
|
+
NVM installed, simply run `nvm use` in the terminal to ensure you're using the correct version of NodeJS.
|
|
6
|
+
|
|
7
|
+
Once NodeJS is installed, open a terminal shell, and run `npm i` from this directory . This will ensure the
|
|
8
|
+
necessary dependencies are available, including the Aurora SDK.
|
|
9
|
+
|
|
10
|
+
## Setting up the environment
|
|
11
|
+
|
|
12
|
+
1. In a text editor, edit the `.env` file in the root your plugin's filesystem. If you don't see it, note that the file may be hidden by default by your OS (Mac: https://www.macworld.com/article/671158/how-to-show-hidden-files-on-a-mac.html, Windows: https://support.microsoft.com/en-us/windows/view-hidden-files-and-folders-in-windows-97fbc472-c603-9d90-91d0-1166d1d9f4b5). If you still don't see this file, create it.
|
|
13
|
+
2. Add an entry for `LIA_URL`. This is the base URL of your community (for example, `LIA_URL=https://community.bigco.com`)
|
|
14
|
+
3. Add an entry for `SDK_KEY` to be the value of the SDK Key found in the Dev Tools (`/admin/dev`) section of your community's admin console (for example, `SDK_KEY=abcd1234`)
|
|
15
|
+
4. Save your changes to the `.env` file.
|
|
16
|
+
5. Install all the dependencies by running `npm install` or `npm i`. Once the dependencies are installed successfully, please run `npm run init` command to set up the required files.
|
|
17
|
+
|
|
18
|
+
## Using Plugin Preview
|
|
19
|
+
|
|
20
|
+
Plugin Preview synchronizes the assets in your plugin with your community. The changes are kept in memory and are only visible
|
|
21
|
+
to admin users.
|
|
22
|
+
|
|
23
|
+
1. Open a terminal shell, and run `npm run start`. This will start the Plugin Preview process.
|
|
24
|
+
2. At this point, any changes you make to the files in your plugin repository will be synchronized with your community. Reload the page in the community where the asset is used to see the changes. To undo the changes, revert the file you changed.
|
|
25
|
+
3. On Plugin Preview startup, any currently changed files are synced into memory. All changes are cleared from memory once the Plugin Preview process is stopped. The process can be done using `Ctrl-C`.
|
|
26
|
+
|
|
27
|
+
## Developing a Custom React Component
|
|
28
|
+
|
|
29
|
+
1. Clone the git repo at https://github.com/community-khoros-internal/aurora-plugin-example
|
|
30
|
+
2. Copy over the `res/components/ReactSample` directory to your plugin's filesystem
|
|
31
|
+
3. Copy over the `src/components/ReactSample` directory to your plugin's filesystem
|
|
32
|
+
4. Commit and push these changes to a branch of your plugin of your choosing
|
|
33
|
+
5. Create a pull request to pull these changes into the main branch of your plugin (`<phase>-main`, not `main`)
|
|
34
|
+
6. Once the pull request is merged, in a browser, go into Designer in the admin console of your community
|
|
35
|
+
7. From there, go to "Page Templates" and select the page where you want to add the custom component
|
|
36
|
+
8. Click on the "+" symbol to add the component, then select "Custom" under "Other"
|
|
37
|
+
9. Select "ReactSample". This should add the sample component to your page.
|
|
38
|
+
10. Click Save and Publish
|
|
39
|
+
11. In your browser, navigate back to the page where the component was published
|
|
40
|
+
12. Now that the sample React component is on your page, start up the Plugin Preview process (see above)
|
|
41
|
+
13. In a new terminal shell, run `npm run dev`. This will start the dev server process. The process can be stopped using `Ctrl-C`.
|
|
42
|
+
14. Edit the `res/components/ReactSample/ReactSample.component.json` file (you can simply add a space to the description in the "defaults" section). This tells the community to load the plugin from your local dev server.
|
|
43
|
+
15. In your browser, reload the page where the component . The sample React component should now load from your local dev server.
|
|
44
|
+
16. Edit the `src/components/ReactSample/Component.tsx` file (you can simply change some text).
|
|
45
|
+
17. In your browser, reload the page where the component. Your changes should be reflected on the component.
|
|
46
|
+
18. To continue development on a separate branch, create a new branch of your plugin from `qa-main`.
|
|
47
|
+
19. Once this is done, you can safely remove the custom component from the page where it was added using Designer. It will still appear on the page as long as you specify your branch as the Active Branch in Dev Tools (`/admin/dev` in your community).
|
package/build-hash.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
f8fda92
|
package/buildPlugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var wn=Object.create;var Xe=Object.defineProperty;var gn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var bn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sn(t))!kn.call(e,i)&&i!==r&&Xe(e,i,{get:()=>t[i],enumerable:!(n=gn(t,i))||n.enumerable});return e};var $=(e,t,r)=>(r=e!=null?wn(vn(e)):{},bn(t||!e||!e.__esModule?Xe(r,"default",{value:e,enumerable:!0}):r,e));var et=S((Ze,ke)=>{(function(e,t){"use strict";typeof define=="function"&&define.amd?define(t):typeof ke=="object"&&ke.exports?ke.exports=t():e.log=t()})(Ze,function(){"use strict";var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function i(u,y){var m=u[y];if(typeof m.bind=="function")return m.bind(u);try{return Function.prototype.bind.call(m,u)}catch{return function(){return Function.prototype.apply.apply(m,[u,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(u){return u==="debug"&&(u="log"),typeof console===t?!1:u==="trace"&&r?o:console[u]!==void 0?i(console,u):console.log!==void 0?i(console,"log"):e}function d(u,y){for(var m=0;m<n.length;m++){var h=n[m];this[h]=m<u?e:this.methodFactory(h,u,y)}this.log=this.debug}function v(u,y,m){return function(){typeof console!==t&&(d.call(this,y,m),this[u].apply(this,arguments))}}function q(u,y,m){return s(u)||v.apply(this,arguments)}function c(u,y,m){var h=this,E;y=y??"WARN";var N="loglevel";typeof u=="string"?N+=":"+u:typeof u=="symbol"&&(N=void 0);function oe(a){var w=(n[a]||"silent").toUpperCase();if(!(typeof window===t||!N)){try{window.localStorage[N]=w;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+w+";"}catch{}}}function me(){var a;if(!(typeof window===t||!N)){try{a=window.localStorage[N]}catch{}if(typeof a===t)try{var w=window.document.cookie,g=w.indexOf(encodeURIComponent(N)+"=");g!==-1&&(a=/^([^;]+)/.exec(w.slice(g))[1])}catch{}return h.levels[a]===void 0&&(a=void 0),a}}function ve(){if(!(typeof window===t||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}h.name=u,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=m||q,h.getLevel=function(){return E},h.setLevel=function(a,w){if(typeof a=="string"&&h.levels[a.toUpperCase()]!==void 0&&(a=h.levels[a.toUpperCase()]),typeof a=="number"&&a>=0&&a<=h.levels.SILENT){if(E=a,w!==!1&&oe(a),d.call(h,a,u),typeof console===t&&a<h.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+a},h.setDefaultLevel=function(a){y=a,me()||h.setLevel(a,!1)},h.resetLevel=function(){h.setLevel(y,!1),ve()},h.enableAll=function(a){h.setLevel(h.levels.TRACE,a)},h.disableAll=function(a){h.setLevel(h.levels.SILENT,a)};var re=me();re==null&&(re=y),h.setLevel(re,!1)}var f=new c,p={};f.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var m=p[y];return m||(m=p[y]=new c(y,f.getLevel(),f.methodFactory)),m};var l=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=l),f},f.getLoggers=function(){return p},f.default=f,f})});var C=S(Ie=>{"use strict";Ie.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((r,n)=>{e.call(this,...t,(i,o)=>i!=null?n(i):r(o))})},"name",{value:e.name})};Ie.fromPromise=function(e){return Object.defineProperty(function(...t){let r=t[t.length-1];if(typeof r!="function")return e.apply(this,t);e.apply(this,t.slice(0,-1)).then(n=>r(null,n),r)},"name",{value:e.name})}});var ft=S((Mo,lt)=>{var X=require("constants"),Fn=process.cwd,be=null,Pn=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return be||(be=Fn.call(process)),be};try{process.cwd()}catch{}typeof process.chdir=="function"&&($e=process.chdir,process.chdir=function(e){be=null,$e.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,$e));var $e;lt.exports=qn;function qn(e){X.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=d(e.stat),e.fstat=d(e.fstat),e.lstat=d(e.lstat),e.statSync=v(e.statSync),e.fstatSync=v(e.fstatSync),e.lstatSync=v(e.lstatSync),e.lchmod||(e.lchmod=function(c,f,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.lchown||(e.lchown=function(c,f,p,l){l&&process.nextTick(l)},e.lchownSync=function(){}),Pn==="win32"&&(e.rename=function(c){return function(f,p,l){var u=Date.now(),y=0;c(f,p,function m(h){if(h&&(h.code==="EACCES"||h.code==="EPERM")&&Date.now()-u<6e4){setTimeout(function(){e.stat(p,function(E,N){E&&E.code==="ENOENT"?c(f,p,m):l(h)})},y),y<100&&(y+=10);return}l&&l(h)})}}(e.rename)),e.read=function(c){function f(p,l,u,y,m,h){var E;if(h&&typeof h=="function"){var N=0;E=function(oe,me,ve){if(oe&&oe.code==="EAGAIN"&&N<10)return N++,c.call(e,p,l,u,y,m,E);h.apply(this,arguments)}}return c.call(e,p,l,u,y,m,E)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,c),f}(e.read),e.readSync=function(c){return function(f,p,l,u,y){for(var m=0;;)try{return c.call(e,f,p,l,u,y)}catch(h){if(h.code==="EAGAIN"&&m<10){m++;continue}throw h}}}(e.readSync);function t(c){c.lchmod=function(f,p,l){c.open(f,X.O_WRONLY|X.O_SYMLINK,p,function(u,y){if(u){l&&l(u);return}c.fchmod(y,p,function(m){c.close(y,function(h){l&&l(m||h)})})})},c.lchmodSync=function(f,p){var l=c.openSync(f,X.O_WRONLY|X.O_SYMLINK,p),u=!0,y;try{y=c.fchmodSync(l,p),u=!1}finally{if(u)try{c.closeSync(l)}catch{}else c.closeSync(l)}return y}}function r(c){X.hasOwnProperty("O_SYMLINK")?(c.lutimes=function(f,p,l,u){c.open(f,X.O_SYMLINK,function(y,m){if(y){u&&u(y);return}c.futimes(m,p,l,function(h){c.close(m,function(E){u&&u(h||E)})})})},c.lutimesSync=function(f,p,l){var u=c.openSync(f,X.O_SYMLINK),y,m=!0;try{y=c.futimesSync(u,p,l),m=!1}finally{if(m)try{c.closeSync(u)}catch{}else c.closeSync(u)}return y}):(c.lutimes=function(f,p,l,u){u&&process.nextTick(u)},c.lutimesSync=function(){})}function n(c){return c&&function(f,p,l){return c.call(e,f,p,function(u){q(u)&&(u=null),l&&l.apply(this,arguments)})}}function i(c){return c&&function(f,p){try{return c.call(e,f,p)}catch(l){if(!q(l))throw l}}}function o(c){return c&&function(f,p,l,u){return c.call(e,f,p,l,function(y){q(y)&&(y=null),u&&u.apply(this,arguments)})}}function s(c){return c&&function(f,p,l){try{return c.call(e,f,p,l)}catch(u){if(!q(u))throw u}}}function d(c){return c&&function(f,p,l){typeof p=="function"&&(l=p,p=null);function u(y,m){m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),l&&l.apply(this,arguments)}return p?c.call(e,f,p,u):c.call(e,f,u)}}function v(c){return c&&function(f,p){var l=p?c.call(e,f,p):c.call(e,f);return l&&(l.uid<0&&(l.uid+=4294967296),l.gid<0&&(l.gid+=4294967296)),l}}function q(c){if(!c||c.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(c.code==="EINVAL"||c.code==="EPERM"))}}});var pt=S((Jo,dt)=>{var mt=require("stream").Stream;dt.exports=Cn;function Cn(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);mt.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),d=0,v=s.length;d<v;d++){var q=s[d];this[q]=i[q]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(c,f){if(c){o.emit("error",c),o.readable=!1;return}o.fd=f,o.emit("open",f),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);mt.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,d=o.length;s<d;s++){var v=o[s];this[v]=i[v]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var ht=S((Uo,yt)=>{"use strict";yt.exports=Ln;var On=Object.getPrototypeOf||function(e){return e.__proto__};function Ln(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:On(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ce=S((Go,Be)=>{var b=require("fs"),jn=ft(),Nn=pt(),Tn=ht(),Ee=require("util"),I,Fe;typeof Symbol=="function"&&typeof Symbol.for=="function"?(I=Symbol.for("graceful-fs.queue"),Fe=Symbol.for("graceful-fs.previous")):(I="___graceful-fs.queue",Fe="___graceful-fs.previous");function An(){}function St(e,t){Object.defineProperty(e,I,{get:function(){return t}})}var ne=An;Ee.debuglog?ne=Ee.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ne=function(){var e=Ee.format.apply(Ee,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
2
|
-
GFS4: `),console.error(e)});b[I]||(wt=global[I]||[],St(b,wt),b.close=function(e){function t(r,n){return e.call(b,r,function(i){i||gt(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,Fe,{value:e}),t}(b.close),b.closeSync=function(e){function t(r){e.apply(b,arguments),gt()}return Object.defineProperty(t,Fe,{value:e}),t}(b.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ne(b[I]),require("assert").equal(b[I].length,0)}));var wt;global[I]||St(global,b[I]);Be.exports=_e(Tn(b));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!b.__patched&&(Be.exports=_e(b),b.__patched=!0);function _e(e){jn(e),e.gracefulify=_e,e.createReadStream=oe,e.createWriteStream=me;var t=e.readFile;e.readFile=r;function r(a,w,g){return typeof w=="function"&&(g=w,w=null),x(a,w,g);function x(T,A,F,D){return t(T,A,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?se([x,[T,A,F],k,D||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(a,w,g,x){return typeof g=="function"&&(x=g,g=null),T(a,w,g,x);function T(A,F,D,k,U){return n(A,F,D,function(P){P&&(P.code==="EMFILE"||P.code==="ENFILE")?se([T,[A,F,D,k],P,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(a,w,g,x){return typeof g=="function"&&(x=g,g=null),T(a,w,g,x);function T(A,F,D,k,U){return o(A,F,D,function(P){P&&(P.code==="EMFILE"||P.code==="ENFILE")?se([T,[A,F,D,k],P,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var d=e.copyFile;d&&(e.copyFile=v);function v(a,w,g,x){return typeof g=="function"&&(x=g,g=0),T(a,w,g,x);function T(A,F,D,k,U){return d(A,F,D,function(P){P&&(P.code==="EMFILE"||P.code==="ENFILE")?se([T,[A,F,D,k],P,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var q=e.readdir;e.readdir=c;function c(a,w,g){return typeof w=="function"&&(g=w,w=null),x(a,w,g);function x(T,A,F,D){return q(T,A,function(k,U){k&&(k.code==="EMFILE"||k.code==="ENFILE")?se([x,[T,A,F],k,D||Date.now(),Date.now()]):(U&&U.sort&&U.sort(),typeof F=="function"&&F.call(this,k,U))})}}if(process.version.substr(0,4)==="v0.8"){var f=Nn(e);m=f.ReadStream,E=f.WriteStream}var p=e.ReadStream;p&&(m.prototype=Object.create(p.prototype),m.prototype.open=h);var l=e.WriteStream;l&&(E.prototype=Object.create(l.prototype),E.prototype.open=N),Object.defineProperty(e,"ReadStream",{get:function(){return m},set:function(a){m=a},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return E},set:function(a){E=a},enumerable:!0,configurable:!0});var u=m;Object.defineProperty(e,"FileReadStream",{get:function(){return u},set:function(a){u=a},enumerable:!0,configurable:!0});var y=E;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(a){y=a},enumerable:!0,configurable:!0});function m(a,w){return this instanceof m?(p.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}function h(){var a=this;re(a.path,a.flags,a.mode,function(w,g){w?(a.autoClose&&a.destroy(),a.emit("error",w)):(a.fd=g,a.emit("open",g),a.read())})}function E(a,w){return this instanceof E?(l.apply(this,arguments),this):E.apply(Object.create(E.prototype),arguments)}function N(){var a=this;re(a.path,a.flags,a.mode,function(w,g){w?(a.destroy(),a.emit("error",w)):(a.fd=g,a.emit("open",g))})}function oe(a,w){return new e.ReadStream(a,w)}function me(a,w){return new e.WriteStream(a,w)}var ve=e.open;e.open=re;function re(a,w,g,x){return typeof g=="function"&&(x=g,g=null),T(a,w,g,x);function T(A,F,D,k,U){return ve(A,F,D,function(P,To){P&&(P.code==="EMFILE"||P.code==="ENFILE")?se([T,[A,F,D,k],P,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}return e}function se(e){ne("ENQUEUE",e[0].name,e[1]),b[I].push(e),De()}var xe;function gt(){for(var e=Date.now(),t=0;t<b[I].length;++t)b[I][t].length>2&&(b[I][t][3]=e,b[I][t][4]=e);De()}function De(){if(clearTimeout(xe),xe=void 0,b[I].length!==0){var e=b[I].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ne("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ne("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var d=Date.now()-o,v=Math.max(o-i,1),q=Math.min(v*1.2,100);d>=q?(ne("RETRY",t.name,r),t.apply(null,r.concat([i]))):b[I].push(e)}xe===void 0&&(xe=setTimeout(De,0))}}});var R=S(Q=>{"use strict";var vt=C().fromCallback,B=ce(),In=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof B[e]=="function");Object.assign(Q,B);In.forEach(e=>{Q[e]=vt(B[e])});Q.exists=function(e,t){return typeof t=="function"?B.exists(e,t):new Promise(r=>B.exists(e,r))};Q.read=function(e,t,r,n,i,o){return typeof o=="function"?B.read(e,t,r,n,i,o):new Promise((s,d)=>{B.read(e,t,r,n,i,(v,q,c)=>{if(v)return d(v);s({bytesRead:q,buffer:c})})})};Q.write=function(e,t,...r){return typeof r[r.length-1]=="function"?B.write(e,t,...r):new Promise((n,i)=>{B.write(e,t,...r,(o,s,d)=>{if(o)return i(o);n({bytesWritten:s,buffer:d})})})};Q.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?B.readv(e,t,...r):new Promise((n,i)=>{B.readv(e,t,...r,(o,s,d)=>{if(o)return i(o);n({bytesRead:s,buffers:d})})})};Q.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?B.writev(e,t,...r):new Promise((n,i)=>{B.writev(e,t,...r,(o,s,d)=>{if(o)return i(o);n({bytesWritten:s,buffers:d})})})};typeof B.realpath.native=="function"?Q.realpath.native=vt(B.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var bt=S((Ko,kt)=>{"use strict";var $n=require("path");kt.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace($n.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var Pt=S((Vo,Re)=>{"use strict";var Et=R(),{checkPath:xt}=bt(),Ft=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};Re.exports.makeDir=async(e,t)=>(xt(e),Et.mkdir(e,{mode:Ft(t),recursive:!0}));Re.exports.makeDirSync=(e,t)=>(xt(e),Et.mkdirSync(e,{mode:Ft(t),recursive:!0}))});var G=S((Ho,qt)=>{"use strict";var _n=C().fromPromise,{makeDir:Dn,makeDirSync:We}=Pt(),Me=_n(Dn);qt.exports={mkdirs:Me,mkdirsSync:We,mkdirp:Me,mkdirpSync:We,ensureDir:Me,ensureDirSync:We}});var Z=S((Qo,Ot)=>{"use strict";var Bn=C().fromPromise,Ct=R();function Rn(e){return Ct.access(e).then(()=>!0).catch(()=>!1)}Ot.exports={pathExists:Bn(Rn),pathExistsSync:Ct.existsSync}});var Je=S((zo,Lt)=>{"use strict";var ae=R(),Wn=C().fromPromise;async function Mn(e,t,r){let n=await ae.open(e,"r+"),i=null;try{await ae.futimes(n,t,r)}finally{try{await ae.close(n)}catch(o){i=o}}if(i)throw i}function Jn(e,t,r){let n=ae.openSync(e,"r+");return ae.futimesSync(n,t,r),ae.closeSync(n)}Lt.exports={utimesMillis:Wn(Mn),utimesMillisSync:Jn}});var ie=S((Xo,At)=>{"use strict";var ue=R(),O=require("path"),jt=C().fromPromise;function Un(e,t,r){let n=r.dereference?i=>ue.stat(i,{bigint:!0}):i=>ue.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,o])=>({srcStat:i,destStat:o}))}function Gn(e,t,r){let n,i=r.dereference?s=>ue.statSync(s,{bigint:!0}):s=>ue.lstatSync(s,{bigint:!0}),o=i(e);try{n=i(t)}catch(s){if(s.code==="ENOENT")return{srcStat:o,destStat:null};throw s}return{srcStat:o,destStat:n}}async function Yn(e,t,r,n){let{srcStat:i,destStat:o}=await Un(e,t,n);if(o){if(de(i,o)){let s=O.basename(e),d=O.basename(t);if(r==="move"&&s!==d&&s.toLowerCase()===d.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&Ue(e,t))throw new Error(Pe(e,t,r));return{srcStat:i,destStat:o}}function Kn(e,t,r,n){let{srcStat:i,destStat:o}=Gn(e,t,n);if(o){if(de(i,o)){let s=O.basename(e),d=O.basename(t);if(r==="move"&&s!==d&&s.toLowerCase()===d.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&Ue(e,t))throw new Error(Pe(e,t,r));return{srcStat:i,destStat:o}}async function Nt(e,t,r,n){let i=O.resolve(O.dirname(e)),o=O.resolve(O.dirname(r));if(o===i||o===O.parse(o).root)return;let s;try{s=await ue.stat(o,{bigint:!0})}catch(d){if(d.code==="ENOENT")return;throw d}if(de(t,s))throw new Error(Pe(e,r,n));return Nt(e,t,o,n)}function Tt(e,t,r,n){let i=O.resolve(O.dirname(e)),o=O.resolve(O.dirname(r));if(o===i||o===O.parse(o).root)return;let s;try{s=ue.statSync(o,{bigint:!0})}catch(d){if(d.code==="ENOENT")return;throw d}if(de(t,s))throw new Error(Pe(e,r,n));return Tt(e,t,o,n)}function de(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ue(e,t){let r=O.resolve(e).split(O.sep).filter(i=>i),n=O.resolve(t).split(O.sep).filter(i=>i);return r.every((i,o)=>n[o]===i)}function Pe(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}At.exports={checkPaths:jt(Yn),checkPathsSync:Kn,checkParentPaths:jt(Nt),checkParentPathsSync:Tt,isSrcSubdir:Ue,areIdentical:de}});var Bt=S((Zo,Dt)=>{"use strict";var _=R(),pe=require("path"),{mkdirs:Vn}=G(),{pathExists:Hn}=Z(),{utimesMillis:Qn}=Je(),ye=ie();async function zn(e,t,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
1
|
+
"use strict";var wn=Object.create;var Xe=Object.defineProperty;var gn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var bn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sn(t))!kn.call(e,i)&&i!==r&&Xe(e,i,{get:()=>t[i],enumerable:!(n=gn(t,i))||n.enumerable});return e};var A=(e,t,r)=>(r=e!=null?wn(vn(e)):{},bn(t||!e||!e.__esModule?Xe(r,"default",{value:e,enumerable:!0}):r,e));var et=S((Ze,ke)=>{(function(e,t){"use strict";typeof define=="function"&&define.amd?define(t):typeof ke=="object"&&ke.exports?ke.exports=t():e.log=t()})(Ze,function(){"use strict";var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function i(u,y){var m=u[y];if(typeof m.bind=="function")return m.bind(u);try{return Function.prototype.bind.call(m,u)}catch{return function(){return Function.prototype.apply.apply(m,[u,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(u){return u==="debug"&&(u="log"),typeof console===t?!1:u==="trace"&&r?o:console[u]!==void 0?i(console,u):console.log!==void 0?i(console,"log"):e}function p(u,y){for(var m=0;m<n.length;m++){var h=n[m];this[h]=m<u?e:this.methodFactory(h,u,y)}this.log=this.debug}function v(u,y,m){return function(){typeof console!==t&&(p.call(this,y,m),this[u].apply(this,arguments))}}function O(u,y,m){return s(u)||v.apply(this,arguments)}function a(u,y,m){var h=this,E;y=y??"WARN";var N="loglevel";typeof u=="string"?N+=":"+u:typeof u=="symbol"&&(N=void 0);function oe(c){var w=(n[c]||"silent").toUpperCase();if(!(typeof window===t||!N)){try{window.localStorage[N]=w;return}catch{}try{window.document.cookie=encodeURIComponent(N)+"="+w+";"}catch{}}}function me(){var c;if(!(typeof window===t||!N)){try{c=window.localStorage[N]}catch{}if(typeof c===t)try{var w=window.document.cookie,g=w.indexOf(encodeURIComponent(N)+"=");g!==-1&&(c=/^([^;]+)/.exec(w.slice(g))[1])}catch{}return h.levels[c]===void 0&&(c=void 0),c}}function ve(){if(!(typeof window===t||!N)){try{window.localStorage.removeItem(N);return}catch{}try{window.document.cookie=encodeURIComponent(N)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}h.name=u,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=m||O,h.getLevel=function(){return E},h.setLevel=function(c,w){if(typeof c=="string"&&h.levels[c.toUpperCase()]!==void 0&&(c=h.levels[c.toUpperCase()]),typeof c=="number"&&c>=0&&c<=h.levels.SILENT){if(E=c,w!==!1&&oe(c),p.call(h,c,u),typeof console===t&&c<h.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+c},h.setDefaultLevel=function(c){y=c,me()||h.setLevel(c,!1)},h.resetLevel=function(){h.setLevel(y,!1),ve()},h.enableAll=function(c){h.setLevel(h.levels.TRACE,c)},h.disableAll=function(c){h.setLevel(h.levels.SILENT,c)};var re=me();re==null&&(re=y),h.setLevel(re,!1)}var f=new a,d={};f.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var m=d[y];return m||(m=d[y]=new a(y,f.getLevel(),f.methodFactory)),m};var l=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=l),f},f.getLoggers=function(){return d},f.default=f,f})});var L=S($e=>{"use strict";$e.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((r,n)=>{e.call(this,...t,(i,o)=>i!=null?n(i):r(o))})},"name",{value:e.name})};$e.fromPromise=function(e){return Object.defineProperty(function(...t){let r=t[t.length-1];if(typeof r!="function")return e.apply(this,t);e.apply(this,t.slice(0,-1)).then(n=>r(null,n),r)},"name",{value:e.name})}});var ft=S((Mo,lt)=>{var X=require("constants"),Fn=process.cwd,be=null,Pn=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return be||(be=Fn.call(process)),be};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Ae=process.chdir,process.chdir=function(e){be=null,Ae.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Ae));var Ae;lt.exports=qn;function qn(e){X.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=p(e.stat),e.fstat=p(e.fstat),e.lstat=p(e.lstat),e.statSync=v(e.statSync),e.fstatSync=v(e.fstatSync),e.lstatSync=v(e.lstatSync),e.lchmod||(e.lchmod=function(a,f,d){d&&process.nextTick(d)},e.lchmodSync=function(){}),e.lchown||(e.lchown=function(a,f,d,l){l&&process.nextTick(l)},e.lchownSync=function(){}),Pn==="win32"&&(e.rename=function(a){return function(f,d,l){var u=Date.now(),y=0;a(f,d,function m(h){if(h&&(h.code==="EACCES"||h.code==="EPERM")&&Date.now()-u<6e4){setTimeout(function(){e.stat(d,function(E,N){E&&E.code==="ENOENT"?a(f,d,m):l(h)})},y),y<100&&(y+=10);return}l&&l(h)})}}(e.rename)),e.read=function(a){function f(d,l,u,y,m,h){var E;if(h&&typeof h=="function"){var N=0;E=function(oe,me,ve){if(oe&&oe.code==="EAGAIN"&&N<10)return N++,a.call(e,d,l,u,y,m,E);h.apply(this,arguments)}}return a.call(e,d,l,u,y,m,E)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,a),f}(e.read),e.readSync=function(a){return function(f,d,l,u,y){for(var m=0;;)try{return a.call(e,f,d,l,u,y)}catch(h){if(h.code==="EAGAIN"&&m<10){m++;continue}throw h}}}(e.readSync);function t(a){a.lchmod=function(f,d,l){a.open(f,X.O_WRONLY|X.O_SYMLINK,d,function(u,y){if(u){l&&l(u);return}a.fchmod(y,d,function(m){a.close(y,function(h){l&&l(m||h)})})})},a.lchmodSync=function(f,d){var l=a.openSync(f,X.O_WRONLY|X.O_SYMLINK,d),u=!0,y;try{y=a.fchmodSync(l,d),u=!1}finally{if(u)try{a.closeSync(l)}catch{}else a.closeSync(l)}return y}}function r(a){X.hasOwnProperty("O_SYMLINK")?(a.lutimes=function(f,d,l,u){a.open(f,X.O_SYMLINK,function(y,m){if(y){u&&u(y);return}a.futimes(m,d,l,function(h){a.close(m,function(E){u&&u(h||E)})})})},a.lutimesSync=function(f,d,l){var u=a.openSync(f,X.O_SYMLINK),y,m=!0;try{y=a.futimesSync(u,d,l),m=!1}finally{if(m)try{a.closeSync(u)}catch{}else a.closeSync(u)}return y}):(a.lutimes=function(f,d,l,u){u&&process.nextTick(u)},a.lutimesSync=function(){})}function n(a){return a&&function(f,d,l){return a.call(e,f,d,function(u){O(u)&&(u=null),l&&l.apply(this,arguments)})}}function i(a){return a&&function(f,d){try{return a.call(e,f,d)}catch(l){if(!O(l))throw l}}}function o(a){return a&&function(f,d,l,u){return a.call(e,f,d,l,function(y){O(y)&&(y=null),u&&u.apply(this,arguments)})}}function s(a){return a&&function(f,d,l){try{return a.call(e,f,d,l)}catch(u){if(!O(u))throw u}}}function p(a){return a&&function(f,d,l){typeof d=="function"&&(l=d,d=null);function u(y,m){m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),l&&l.apply(this,arguments)}return d?a.call(e,f,d,u):a.call(e,f,u)}}function v(a){return a&&function(f,d){var l=d?a.call(e,f,d):a.call(e,f);return l&&(l.uid<0&&(l.uid+=4294967296),l.gid<0&&(l.gid+=4294967296)),l}}function O(a){if(!a||a.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(a.code==="EINVAL"||a.code==="EPERM"))}}});var dt=S((Jo,pt)=>{var mt=require("stream").Stream;pt.exports=Cn;function Cn(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);mt.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var s=Object.keys(i),p=0,v=s.length;p<v;p++){var O=s[p];this[O]=i[O]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(a,f){if(a){o.emit("error",a),o.readable=!1;return}o.fd=f,o.emit("open",f),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);mt.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,p=o.length;s<p;s++){var v=o[s];this[v]=i[v]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var ht=S((Uo,yt)=>{"use strict";yt.exports=Ln;var On=Object.getPrototypeOf||function(e){return e.__proto__};function Ln(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:On(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ae=S((Go,We)=>{var b=require("fs"),jn=ft(),Nn=dt(),Tn=ht(),xe=require("util"),$,Fe;typeof Symbol=="function"&&typeof Symbol.for=="function"?($=Symbol.for("graceful-fs.queue"),Fe=Symbol.for("graceful-fs.previous")):($="___graceful-fs.queue",Fe="___graceful-fs.previous");function In(){}function St(e,t){Object.defineProperty(e,$,{get:function(){return t}})}var ne=In;xe.debuglog?ne=xe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ne=function(){var e=xe.format.apply(xe,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
2
|
+
GFS4: `),console.error(e)});b[$]||(wt=global[$]||[],St(b,wt),b.close=function(e){function t(r,n){return e.call(b,r,function(i){i||gt(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,Fe,{value:e}),t}(b.close),b.closeSync=function(e){function t(r){e.apply(b,arguments),gt()}return Object.defineProperty(t,Fe,{value:e}),t}(b.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ne(b[$]),require("assert").equal(b[$].length,0)}));var wt;global[$]||St(global,b[$]);We.exports=_e(Tn(b));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!b.__patched&&(We.exports=_e(b),b.__patched=!0);function _e(e){jn(e),e.gracefulify=_e,e.createReadStream=oe,e.createWriteStream=me;var t=e.readFile;e.readFile=r;function r(c,w,g){return typeof w=="function"&&(g=w,w=null),P(c,w,g);function P(T,I,q,D){return t(T,I,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?se([P,[T,I,q],k,D||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(c,w,g,P){return typeof g=="function"&&(P=g,g=null),T(c,w,g,P);function T(I,q,D,k,U){return n(I,q,D,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?se([T,[I,q,D,k],C,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(c,w,g,P){return typeof g=="function"&&(P=g,g=null),T(c,w,g,P);function T(I,q,D,k,U){return o(I,q,D,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?se([T,[I,q,D,k],C,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var p=e.copyFile;p&&(e.copyFile=v);function v(c,w,g,P){return typeof g=="function"&&(P=g,g=0),T(c,w,g,P);function T(I,q,D,k,U){return p(I,q,D,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?se([T,[I,q,D,k],C,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var O=e.readdir;e.readdir=a;function a(c,w,g){return typeof w=="function"&&(g=w,w=null),P(c,w,g);function P(T,I,q,D){return O(T,I,function(k,U){k&&(k.code==="EMFILE"||k.code==="ENFILE")?se([P,[T,I,q],k,D||Date.now(),Date.now()]):(U&&U.sort&&U.sort(),typeof q=="function"&&q.call(this,k,U))})}}if(process.version.substr(0,4)==="v0.8"){var f=Nn(e);m=f.ReadStream,E=f.WriteStream}var d=e.ReadStream;d&&(m.prototype=Object.create(d.prototype),m.prototype.open=h);var l=e.WriteStream;l&&(E.prototype=Object.create(l.prototype),E.prototype.open=N),Object.defineProperty(e,"ReadStream",{get:function(){return m},set:function(c){m=c},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return E},set:function(c){E=c},enumerable:!0,configurable:!0});var u=m;Object.defineProperty(e,"FileReadStream",{get:function(){return u},set:function(c){u=c},enumerable:!0,configurable:!0});var y=E;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(c){y=c},enumerable:!0,configurable:!0});function m(c,w){return this instanceof m?(d.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}function h(){var c=this;re(c.path,c.flags,c.mode,function(w,g){w?(c.autoClose&&c.destroy(),c.emit("error",w)):(c.fd=g,c.emit("open",g),c.read())})}function E(c,w){return this instanceof E?(l.apply(this,arguments),this):E.apply(Object.create(E.prototype),arguments)}function N(){var c=this;re(c.path,c.flags,c.mode,function(w,g){w?(c.destroy(),c.emit("error",w)):(c.fd=g,c.emit("open",g))})}function oe(c,w){return new e.ReadStream(c,w)}function me(c,w){return new e.WriteStream(c,w)}var ve=e.open;e.open=re;function re(c,w,g,P){return typeof g=="function"&&(P=g,g=null),T(c,w,g,P);function T(I,q,D,k,U){return ve(I,q,D,function(C,To){C&&(C.code==="EMFILE"||C.code==="ENFILE")?se([T,[I,q,D,k],C,U||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}return e}function se(e){ne("ENQUEUE",e[0].name,e[1]),b[$].push(e),De()}var Ee;function gt(){for(var e=Date.now(),t=0;t<b[$].length;++t)b[$][t].length>2&&(b[$][t][3]=e,b[$][t][4]=e);De()}function De(){if(clearTimeout(Ee),Ee=void 0,b[$].length!==0){var e=b[$].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ne("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ne("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var p=Date.now()-o,v=Math.max(o-i,1),O=Math.min(v*1.2,100);p>=O?(ne("RETRY",t.name,r),t.apply(null,r.concat([i]))):b[$].push(e)}Ee===void 0&&(Ee=setTimeout(De,0))}}});var B=S(Q=>{"use strict";var vt=L().fromCallback,W=ae(),$n=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof W[e]=="function");Object.assign(Q,W);$n.forEach(e=>{Q[e]=vt(W[e])});Q.exists=function(e,t){return typeof t=="function"?W.exists(e,t):new Promise(r=>W.exists(e,r))};Q.read=function(e,t,r,n,i,o){return typeof o=="function"?W.read(e,t,r,n,i,o):new Promise((s,p)=>{W.read(e,t,r,n,i,(v,O,a)=>{if(v)return p(v);s({bytesRead:O,buffer:a})})})};Q.write=function(e,t,...r){return typeof r[r.length-1]=="function"?W.write(e,t,...r):new Promise((n,i)=>{W.write(e,t,...r,(o,s,p)=>{if(o)return i(o);n({bytesWritten:s,buffer:p})})})};Q.readv=function(e,t,...r){return typeof r[r.length-1]=="function"?W.readv(e,t,...r):new Promise((n,i)=>{W.readv(e,t,...r,(o,s,p)=>{if(o)return i(o);n({bytesRead:s,buffers:p})})})};Q.writev=function(e,t,...r){return typeof r[r.length-1]=="function"?W.writev(e,t,...r):new Promise((n,i)=>{W.writev(e,t,...r,(o,s,p)=>{if(o)return i(o);n({bytesWritten:s,buffers:p})})})};typeof W.realpath.native=="function"?Q.realpath.native=vt(W.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var bt=S((Ko,kt)=>{"use strict";var An=require("path");kt.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(An.parse(t).root,""))){let n=new Error(`Path contains invalid characters: ${t}`);throw n.code="EINVAL",n}}});var Pt=S((Vo,Be)=>{"use strict";var xt=B(),{checkPath:Et}=bt(),Ft=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};Be.exports.makeDir=async(e,t)=>(Et(e),xt.mkdir(e,{mode:Ft(t),recursive:!0}));Be.exports.makeDirSync=(e,t)=>(Et(e),xt.mkdirSync(e,{mode:Ft(t),recursive:!0}))});var G=S((Ho,qt)=>{"use strict";var _n=L().fromPromise,{makeDir:Dn,makeDirSync:Re}=Pt(),Me=_n(Dn);qt.exports={mkdirs:Me,mkdirsSync:Re,mkdirp:Me,mkdirpSync:Re,ensureDir:Me,ensureDirSync:Re}});var Z=S((Qo,Ot)=>{"use strict";var Wn=L().fromPromise,Ct=B();function Bn(e){return Ct.access(e).then(()=>!0).catch(()=>!1)}Ot.exports={pathExists:Wn(Bn),pathExistsSync:Ct.existsSync}});var Je=S((zo,Lt)=>{"use strict";var ce=B(),Rn=L().fromPromise;async function Mn(e,t,r){let n=await ce.open(e,"r+"),i=null;try{await ce.futimes(n,t,r)}finally{try{await ce.close(n)}catch(o){i=o}}if(i)throw i}function Jn(e,t,r){let n=ce.openSync(e,"r+");return ce.futimesSync(n,t,r),ce.closeSync(n)}Lt.exports={utimesMillis:Rn(Mn),utimesMillisSync:Jn}});var ie=S((Xo,It)=>{"use strict";var ue=B(),j=require("path"),jt=L().fromPromise;function Un(e,t,r){let n=r.dereference?i=>ue.stat(i,{bigint:!0}):i=>ue.lstat(i,{bigint:!0});return Promise.all([n(e),n(t).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,o])=>({srcStat:i,destStat:o}))}function Gn(e,t,r){let n,i=r.dereference?s=>ue.statSync(s,{bigint:!0}):s=>ue.lstatSync(s,{bigint:!0}),o=i(e);try{n=i(t)}catch(s){if(s.code==="ENOENT")return{srcStat:o,destStat:null};throw s}return{srcStat:o,destStat:n}}async function Yn(e,t,r,n){let{srcStat:i,destStat:o}=await Un(e,t,n);if(o){if(pe(i,o)){let s=j.basename(e),p=j.basename(t);if(r==="move"&&s!==p&&s.toLowerCase()===p.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&Ue(e,t))throw new Error(Pe(e,t,r));return{srcStat:i,destStat:o}}function Kn(e,t,r,n){let{srcStat:i,destStat:o}=Gn(e,t,n);if(o){if(pe(i,o)){let s=j.basename(e),p=j.basename(t);if(r==="move"&&s!==p&&s.toLowerCase()===p.toLowerCase())return{srcStat:i,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!i.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(i.isDirectory()&&Ue(e,t))throw new Error(Pe(e,t,r));return{srcStat:i,destStat:o}}async function Nt(e,t,r,n){let i=j.resolve(j.dirname(e)),o=j.resolve(j.dirname(r));if(o===i||o===j.parse(o).root)return;let s;try{s=await ue.stat(o,{bigint:!0})}catch(p){if(p.code==="ENOENT")return;throw p}if(pe(t,s))throw new Error(Pe(e,r,n));return Nt(e,t,o,n)}function Tt(e,t,r,n){let i=j.resolve(j.dirname(e)),o=j.resolve(j.dirname(r));if(o===i||o===j.parse(o).root)return;let s;try{s=ue.statSync(o,{bigint:!0})}catch(p){if(p.code==="ENOENT")return;throw p}if(pe(t,s))throw new Error(Pe(e,r,n));return Tt(e,t,o,n)}function pe(e,t){return t.ino&&t.dev&&t.ino===e.ino&&t.dev===e.dev}function Ue(e,t){let r=j.resolve(e).split(j.sep).filter(i=>i),n=j.resolve(t).split(j.sep).filter(i=>i);return r.every((i,o)=>n[o]===i)}function Pe(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}It.exports={checkPaths:jt(Yn),checkPathsSync:Kn,checkParentPaths:jt(Nt),checkParentPathsSync:Tt,isSrcSubdir:Ue,areIdentical:pe}});var Wt=S((Zo,Dt)=>{"use strict";var _=B(),de=require("path"),{mkdirs:Vn}=G(),{pathExists:Hn}=Z(),{utimesMillis:Qn}=Je(),ye=ie();async function zn(e,t,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
3
3
|
|
|
4
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:n,destStat:i}=await ye.checkPaths(e,t,"copy",r);if(await ye.checkParentPaths(e,n,t,"copy"),!await
|
|
4
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:n,destStat:i}=await ye.checkPaths(e,t,"copy",r);if(await ye.checkParentPaths(e,n,t,"copy"),!await At(e,t,r))return;let s=de.dirname(t);await Hn(s)||await Vn(s),await _t(i,e,t,r)}async function At(e,t,r){return r.filter?r.filter(e,t):!0}async function _t(e,t,r,n){let o=await(n.dereference?_.stat:_.lstat)(t);if(o.isDirectory())return ti(o,e,t,r,n);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return Xn(o,e,t,r,n);if(o.isSymbolicLink())return ri(e,t,r,n);throw o.isSocket()?new Error(`Cannot copy a socket file: ${t}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}async function Xn(e,t,r,n,i){if(!t)return $t(e,r,n,i);if(i.overwrite)return await _.unlink(n),$t(e,r,n,i);if(i.errorOnExist)throw new Error(`'${n}' already exists`)}async function $t(e,t,r,n){if(await _.copyFile(t,r),n.preserveTimestamps){Zn(e.mode)&&await ei(r,e.mode);let i=await _.stat(t);await Qn(r,i.atime,i.mtime)}return _.chmod(r,e.mode)}function Zn(e){return(e&128)===0}function ei(e,t){return _.chmod(e,t|128)}async function ti(e,t,r,n,i){t||await _.mkdir(n);let o=await _.readdir(r);await Promise.all(o.map(async s=>{let p=de.join(r,s),v=de.join(n,s);if(!await At(p,v,i))return;let{destStat:a}=await ye.checkPaths(p,v,"copy",i);return _t(a,p,v,i)})),t||await _.chmod(n,e.mode)}async function ri(e,t,r,n){let i=await _.readlink(t);if(n.dereference&&(i=de.resolve(process.cwd(),i)),!e)return _.symlink(i,r);let o=null;try{o=await _.readlink(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return _.symlink(i,r);throw s}if(n.dereference&&(o=de.resolve(process.cwd(),o)),ye.isSrcSubdir(i,o))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${o}'.`);if(ye.isSrcSubdir(o,i))throw new Error(`Cannot overwrite '${o}' with '${i}'.`);return await _.unlink(r),_.symlink(i,r)}Dt.exports=zn});var Ut=S((es,Jt)=>{"use strict";var R=ae(),he=require("path"),ni=G().mkdirsSync,ii=Je().utimesMillisSync,we=ie();function oi(e,t,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
5
5
|
|
|
6
|
-
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:n,destStat:i}=we.checkPathsSync(e,t,"copy",r);if(we.checkParentPathsSync(e,n,t,"copy"),r.filter&&!r.filter(e,t))return;let o=he.dirname(t);return
|
|
7
|
-
`,finalEOL:r=!0,replacer:n=null,spaces:i}={}){let o=r?t:"";return JSON.stringify(e,n,i).replace(/\n/g,t)+o}function Ki(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}Cr.exports={stringify:Yi,stripBom:Ki}});var Nr=S((fs,jr)=>{var le;try{le=ce()}catch{le=require("fs")}var Oe=C(),{stringify:Or,stripBom:Lr}=Ce();async function Vi(e,t={}){typeof t=="string"&&(t={encoding:t});let r=t.fs||le,n="throws"in t?t.throws:!0,i=await Oe.fromCallback(r.readFile)(e,t);i=Lr(i);let o;try{o=JSON.parse(i,t?t.reviver:null)}catch(s){if(n)throw s.message=`${e}: ${s.message}`,s;return null}return o}var Hi=Oe.fromPromise(Vi);function Qi(e,t={}){typeof t=="string"&&(t={encoding:t});let r=t.fs||le,n="throws"in t?t.throws:!0;try{let i=r.readFileSync(e,t);return i=Lr(i),JSON.parse(i,t.reviver)}catch(i){if(n)throw i.message=`${e}: ${i.message}`,i;return null}}async function zi(e,t,r={}){let n=r.fs||le,i=Or(t,r);await Oe.fromCallback(n.writeFile)(e,i,r)}var Xi=Oe.fromPromise(zi);function Zi(e,t,r={}){let n=r.fs||le,i=Or(t,r);return n.writeFileSync(e,i,r)}var eo={readFile:Hi,readFileSync:Qi,writeFile:Xi,writeFileSync:Zi};jr.exports=eo});var Ar=S((ms,Tr)=>{"use strict";var Le=Nr();Tr.exports={readJson:Le.readFile,readJsonSync:Le.readFileSync,writeJson:Le.writeFile,writeJsonSync:Le.writeFileSync}});var je=S((ds,_r)=>{"use strict";var to=C().fromPromise,Ye=R(),Ir=require("path"),$r=G(),ro=Z().pathExists;async function no(e,t,r="utf-8"){let n=Ir.dirname(e);return await ro(n)||await $r.mkdirs(n),Ye.writeFile(e,t,r)}function io(e,...t){let r=Ir.dirname(e);Ye.existsSync(r)||$r.mkdirsSync(r),Ye.writeFileSync(e,...t)}_r.exports={outputFile:to(no),outputFileSync:io}});var Br=S((ps,Dr)=>{"use strict";var{stringify:oo}=Ce(),{outputFile:so}=je();async function co(e,t,r={}){let n=oo(t,r);await so(e,n,r)}Dr.exports=co});var Wr=S((ys,Rr)=>{"use strict";var{stringify:ao}=Ce(),{outputFileSync:uo}=je();function lo(e,t,r){let n=ao(t,r);uo(e,n,r)}Rr.exports=lo});var Jr=S((hs,Mr)=>{"use strict";var fo=C().fromPromise,M=Ar();M.outputJson=fo(Br());M.outputJsonSync=Wr();M.outputJSON=M.outputJson;M.outputJSONSync=M.outputJsonSync;M.writeJSON=M.writeJson;M.writeJSONSync=M.writeJsonSync;M.readJSON=M.readJson;M.readJSONSync=M.readJsonSync;Mr.exports=M});var Vr=S((ws,Kr)=>{"use strict";var mo=R(),Ur=require("path"),{copy:po}=qe(),{remove:Yr}=ge(),{mkdirp:yo}=G(),{pathExists:ho}=Z(),Gr=ie();async function wo(e,t,r={}){let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:o=!1}=await Gr.checkPaths(e,t,"move",r);await Gr.checkParentPaths(e,i,t,"move");let s=Ur.dirname(t);return Ur.parse(s).root!==s&&await yo(s),go(e,t,n,o)}async function go(e,t,r,n){if(!n){if(r)await Yr(t);else if(await ho(t))throw new Error("dest already exists.")}try{await mo.rename(e,t)}catch(i){if(i.code!=="EXDEV")throw i;await So(e,t,r)}}async function So(e,t,r){return await po(e,t,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),Yr(e)}Kr.exports=wo});var Zr=S((gs,Xr)=>{"use strict";var Qr=ce(),Ve=require("path"),vo=qe().copySync,zr=ge().removeSync,ko=G().mkdirpSync,Hr=ie();function bo(e,t,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:o=!1}=Hr.checkPathsSync(e,t,"move",r);return Hr.checkParentPathsSync(e,i,t,"move"),Eo(t)||ko(Ve.dirname(t)),xo(e,t,n,o)}function Eo(e){let t=Ve.dirname(e);return Ve.parse(t).root===t}function xo(e,t,r,n){if(n)return Ke(e,t,r);if(r)return zr(t),Ke(e,t,r);if(Qr.existsSync(t))throw new Error("dest already exists.");return Ke(e,t,r)}function Ke(e,t,r){try{Qr.renameSync(e,t)}catch(n){if(n.code!=="EXDEV")throw n;return Fo(e,t,r)}}function Fo(e,t,r){return vo(e,t,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),zr(e)}Xr.exports=bo});var tn=S((Ss,en)=>{"use strict";var Po=C().fromPromise;en.exports={move:Po(Vr()),moveSync:Zr()}});var Ne=S((vs,rn)=>{"use strict";rn.exports={...R(),...qe(),...tr(),...qr(),...Jr(),...G(),...tn(),...je(),...Z(),...ge()}});var tt=$(require("yargs")),rt=require("yargs/helpers"),nt=$(require("find-config")),it=$(require("dotenv"));var Te=$(et());Te.default.setDefaultLevel(process.env.LOG_LEVEL??"info");function J(e){return Te.default.getLogger(e)}var ot=$(require("path")),Ae=J("cliBase");function En(){let e=(0,nt.default)(".env");if(!e)Ae.warn("No .env config file found.");else if(e){Ae.info("Using .env config file at path: %s",e);let{error:t}=it.default.config({path:e});t&&(Ae.error("Error reading .env config file at path: %s: %s",e,t.message),process.exit(1))}}function xn(e,t,r,n){En(),(0,tt.default)((0,rt.hideBin)(process.argv)).scriptName(e).options(n??{}).env("PLUGIN").usage("$0 [repoPath]").command("$0 [repoPath]",t,i=>i.positional("repoPath",{describe:"The full path to plugin root directory.",type:"string"}),async i=>{await r(i)}).check(({repoPath:i})=>{if(!i)throw new Error("No plugin repository path found. Please either pass it as an argument to this process or specify it in your .env file as PLUGIN_REPO_PATH. ");if(i.startsWith(ot.default.sep))return!0;throw new Error("The plugin repository path must be a full (not relative) path.")}).help().parse()}var V=xn;var ct=$(require("shelljs"));var st=J("lintPlugin");async function at(e,t){st.info("Linting plugin directory",t);let n=`eslint --ext .js --ext .jsx --ext .tsx --ext .ts --cache --config ${t}/.eslintrc.js ${e==="lint:fix"?"--fix --max-warnings=0":""} ${t}/src`;st.debug(n),ct.default.exec(n)}var ut=at;V("lint:plugin","Lints the plugin files or fixes the plugin files linting",async({repoPath:e,command:t})=>{await at(t,e)},{c:{alias:"command",choices:["lint","lint:fix"],demandOption:!1,default:"lint",type:"string"}});var L=$(Ne()),j=$(require("path"));var qo=J("setupPlugin"),Co={hooks:{"pre-commit":"npm run precommit","post-commit":"git update-index --again"}},Oo={"**/*.{js,jsx,ts,tsx,css,scss,pcss,json}":["prettier --write"],"**/*.{js,ts,tsx}":["eslint --fix --ignore-pattern '!.eslintrc.js' --ignore-pattern '!.prettierrc.js'"]};async function nn(e){qo.info("Initializing plugin directory %s",e),await L.default.ensureDir(j.default.join(e,"pages")),await L.default.ensureDir(j.default.join(e,"src")),await L.default.copy("templates/.babelrc.tmpl",j.default.join(e,".babelrc"),{overwrite:!0}),await L.default.copy("templates/.env.tmpl",j.default.join(e,".env"),{overwrite:!1}),await L.default.copy("templates/.nvmrc.tmpl",j.default.join(e,".nvmrc"),{overwrite:!0}),await L.default.copy("templates/.gitignore.tmpl",j.default.join(e,".gitignore"),{overwrite:!0}),await L.default.copy("templates/tsconfig.tmpl.json",j.default.join(e,"tsconfig.json"),{overwrite:!0}),await L.default.copy("templates/.eslintignore.tmpl",j.default.join(e,".eslintignore"),{overwrite:!0}),await L.default.copy("templates/.eslintrc.tmpl.js",j.default.join(e,".eslintrc.js"),{overwrite:!0}),await L.default.copy("templates/.prettierignore.tmpl",j.default.join(e,".prettierignore"),{overwrite:!0}),await L.default.copy("templates/.prettierrc.tmpl.js",j.default.join(e,".prettierrc.js"),{overwrite:!0});let t=L.default.readJsonSync(j.default.join(e,"package.json"),"utf8");t.scripts.precommit="lint-staged",t.husky=Co,t["lint-staged"]=Oo,await L.default.writeJson(j.default.join(e,"package.json"),t,{spaces:" "}),await L.default.copy("next.config.js",j.default.join(e,"next.config.js"),{overwrite:!0}),await L.default.copy("types/mf/aurora.d.ts",j.default.join(e,"types/mf/aurora.d.ts"),{overwrite:!0}),await L.default.copy("types/pkg/aurora.d.ts",j.default.join(e,"types/pkg/aurora.d.ts"),{overwrite:!0}),await L.default.copy("types/graphql.d.ts",j.default.join(e,"types/graphql.d.ts"),{overwrite:!0})}var on=nn;V("init:plugin","Setup static files for the plugin",async({repoPath:e})=>{await nn(e)});var cn=$(require("shelljs"));var sn=J("formatPlugin");async function an(e,t){sn.info("Formatting plugin directory",t);let n=`prettier --config ${t}/.prettierrc.js --ignore-path ${t}/.prettierignore ${e==="format:fix"?"--write":"--check"} ${t}/res ${t}/src `;sn.debug(n),cn.default.exec(n)}var un=an;V("format:plugin","Checks the plugin files for formatting or fixes the formatting in plugin files",async({command:e,repoPath:t})=>await an(e,t),{c:{alias:"command",choices:["format","format:fix"],demandOption:!1,default:"format",type:"string"}});var ln=require("glob"),He=$(require("shelljs")),Qe=$(Ne()),fe=$(require("path"));var Lo=async e=>{let t=await(0,ln.glob)(fe.default.join(e,"**/*.component.json")),n=(await Promise.all(t.map(async o=>({path:o,descriptor:await Qe.default.readJson(o)})))).filter(o=>o.descriptor.markupLanguage==="REACT"),i={};return n.forEach(o=>{let{descriptor:s,path:d}=o,{fetchedContent:v}=s.defaults.config;if(v&&v.enabled){let q=`./${v.remoteName||s.id}`,c=`./${fe.default.relative(e,fe.default.join(fe.default.dirname(d.replace("/res","/src")),`${v.componentModuleName||"Component"}.tsx`))}`;Object.assign(i,{[q]:c})}}),i};async function fn(e,t,r){let n=await Lo(t);await Qe.default.writeJSON(fe.default.join(t,"federation.config.json"),{name:"auroraComponents",exposes:n,extraOptions:{debug:!1}});let i="";e==="dev"&&(i=`-p ${r}`),He.default.env.NEXT_PRIVATE_LOCAL_WEBPACK="true",He.default.exec(`next ${e} ${i} ${t}`)}var mn=fn;V("build:plugin","Builds the plugin or runs the plugin in dev mode",async({repoPath:e,nextCliCommand:t,port:r})=>{await fn(t,e,r)},{c:{alias:"nextCliCommand",choices:["build","dev"],describe:"The NextJS CLI command to run",demandOption:!1,default:"build",type:"string"},p:{alias:"port",demandOption:!1,describe:"The port to run on in dev mode",default:3002,type:"number"}});var dn=$(require("shelljs")),pn=$(require("dotenv")),K=$(Ne()),Y=$(require("path")),yn=require("rimraf");var ze=J("buildModules");async function jo(e,t){let r=Y.default.join(e,"src/endpoints");if(await(0,K.pathExists)(r)){ze.info("Building plugin modules at %s",Y.default.resolve(__dirname,e));let n=t.startsWith("/")?t:Y.default.join(e,t);await(0,K.ensureDir)(n),await(0,yn.rimraf)(Y.default.join(n,"pkg")),ze.info(`Output directory is ${n}`),pn.default.config({path:Y.default.join(`${e}`,".env")}),dn.default.exec("tsc -p ./tsconfig.server.json"),await(0,K.copy)(r,Y.default.join(e,"dist/pkg/endpoints"),{filter:o=>!(o.endsWith(".ts")||o.includes("node_modules"))});let i=await(0,K.readJSON)(Y.default.join(e,"package.json"));i.workspaces=["endpoints/**/*"],await(0,K.writeJSON)(Y.default.join(e,"dist/pkg/package.json"),i),await(0,K.copy)(Y.default.join(e,"package-lock.json"),Y.default.join(e,"dist/pkg/package-lock.json"))}else ze.info("No plugin modules to build")}var hn=jo;var No=J("buildPlugin");V("build:modules","Build the plugin modules",async({repoPath:e,outputDirectory:t,init:r,lint:n,format:i})=>{let o=Date.now();r===!0&&await on(e),n===!0&&await ut("lint",e),i===!0&&await un("format",e),await mn("build",e,3002),await hn(e,t),No.info("Plugin build complete in "+(Date.now()-o)+"ms")},{b:{alias:"branchName",demandOption:!1,default:"main",describe:'The branch to build. If not specified, "main" is assumed. This does not control the checked out files but adds an additional branch segment to the S3 file key',type:"string"},c:{alias:"changeSet",demandOption:!1,describe:"A set of changed files. If not specified, all components and middlewares in the plugin will be built. If specified, only components and middlewares with changed files will be built.",type:"array"},o:{alias:"outputDirectory",demandOption:!1,default:"dist",describe:'The output directory. If not specified, "dist" is assumed. This is where the build artifacts will be placed.',type:"string"},i:{alias:"init",demandOption:!1,default:!1,describe:"Whether to init the plugin as part of the build process",type:"boolean"},l:{alias:"lint",demandOption:!1,default:!1,describe:"Whether to run lint as part of the build process.",type:"boolean"},f:{alias:"format",demandOption:!1,default:!1,describe:"Whether to run format as part of the build process.",type:"boolean"}});
|
|
6
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:n,destStat:i}=we.checkPathsSync(e,t,"copy",r);if(we.checkParentPathsSync(e,n,t,"copy"),r.filter&&!r.filter(e,t))return;let o=he.dirname(t);return R.existsSync(o)||ni(o),Bt(i,e,t,r)}function Bt(e,t,r,n){let o=(n.dereference?R.statSync:R.lstatSync)(t);if(o.isDirectory())return mi(o,e,t,r,n);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return si(o,e,t,r,n);if(o.isSymbolicLink())return yi(e,t,r,n);throw o.isSocket()?new Error(`Cannot copy a socket file: ${t}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}function si(e,t,r,n,i){return t?ai(e,r,n,i):Rt(e,r,n,i)}function ai(e,t,r,n){if(n.overwrite)return R.unlinkSync(r),Rt(e,t,r,n);if(n.errorOnExist)throw new Error(`'${r}' already exists`)}function Rt(e,t,r,n){return R.copyFileSync(t,r),n.preserveTimestamps&&ci(e.mode,t,r),Ge(r,e.mode)}function ci(e,t,r){return ui(e)&&li(r,e),fi(t,r)}function ui(e){return(e&128)===0}function li(e,t){return Ge(e,t|128)}function Ge(e,t){return R.chmodSync(e,t)}function fi(e,t){let r=R.statSync(e);return ii(t,r.atime,r.mtime)}function mi(e,t,r,n,i){return t?Mt(r,n,i):pi(e.mode,r,n,i)}function pi(e,t,r,n){return R.mkdirSync(r),Mt(t,r,n),Ge(r,e)}function Mt(e,t,r){R.readdirSync(e).forEach(n=>di(n,e,t,r))}function di(e,t,r,n){let i=he.join(t,e),o=he.join(r,e);if(n.filter&&!n.filter(i,o))return;let{destStat:s}=we.checkPathsSync(i,o,"copy",n);return Bt(s,i,o,n)}function yi(e,t,r,n){let i=R.readlinkSync(t);if(n.dereference&&(i=he.resolve(process.cwd(),i)),e){let o;try{o=R.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return R.symlinkSync(i,r);throw s}if(n.dereference&&(o=he.resolve(process.cwd(),o)),we.isSrcSubdir(i,o))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${o}'.`);if(we.isSrcSubdir(o,i))throw new Error(`Cannot overwrite '${o}' with '${i}'.`);return hi(i,r)}else return R.symlinkSync(i,r)}function hi(e,t){return R.unlinkSync(t),R.symlinkSync(e,t)}Jt.exports=oi});var qe=S((ts,Gt)=>{"use strict";var wi=L().fromPromise;Gt.exports={copy:wi(Wt()),copySync:Ut()}});var ge=S((rs,Kt)=>{"use strict";var Yt=ae(),gi=L().fromCallback;function Si(e,t){Yt.rm(e,{recursive:!0,force:!0},t)}function vi(e){Yt.rmSync(e,{recursive:!0,force:!0})}Kt.exports={remove:gi(Si),removeSync:vi}});var tr=S((ns,er)=>{"use strict";var ki=L().fromPromise,Qt=B(),zt=require("path"),Xt=G(),Zt=ge(),Vt=ki(async function(t){let r;try{r=await Qt.readdir(t)}catch{return Xt.mkdirs(t)}return Promise.all(r.map(n=>Zt.remove(zt.join(t,n))))});function Ht(e){let t;try{t=Qt.readdirSync(e)}catch{return Xt.mkdirsSync(e)}t.forEach(r=>{r=zt.join(e,r),Zt.removeSync(r)})}er.exports={emptyDirSync:Ht,emptydirSync:Ht,emptyDir:Vt,emptydir:Vt}});var or=S((is,ir)=>{"use strict";var bi=L().fromPromise,rr=require("path"),z=B(),nr=G();async function xi(e){let t;try{t=await z.stat(e)}catch{}if(t&&t.isFile())return;let r=rr.dirname(e),n=null;try{n=await z.stat(r)}catch(i){if(i.code==="ENOENT"){await nr.mkdirs(r),await z.writeFile(e,"");return}else throw i}n.isDirectory()?await z.writeFile(e,""):await z.readdir(r)}function Ei(e){let t;try{t=z.statSync(e)}catch{}if(t&&t.isFile())return;let r=rr.dirname(e);try{z.statSync(r).isDirectory()||z.readdirSync(r)}catch(n){if(n&&n.code==="ENOENT")nr.mkdirsSync(r);else throw n}z.writeFileSync(e,"")}ir.exports={createFile:bi(xi),createFileSync:Ei}});var lr=S((os,ur)=>{"use strict";var Fi=L().fromPromise,sr=require("path"),ee=B(),ar=G(),{pathExists:Pi}=Z(),{areIdentical:cr}=ie();async function qi(e,t){let r;try{r=await ee.lstat(t)}catch{}let n;try{n=await ee.lstat(e)}catch(s){throw s.message=s.message.replace("lstat","ensureLink"),s}if(r&&cr(n,r))return;let i=sr.dirname(t);await Pi(i)||await ar.mkdirs(i),await ee.link(e,t)}function Ci(e,t){let r;try{r=ee.lstatSync(t)}catch{}try{let o=ee.lstatSync(e);if(r&&cr(o,r))return}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}let n=sr.dirname(t);return ee.existsSync(n)||ar.mkdirsSync(n),ee.linkSync(e,t)}ur.exports={createLink:Fi(qi),createLinkSync:Ci}});var mr=S((ss,fr)=>{"use strict";var te=require("path"),Se=B(),{pathExists:Oi}=Z(),Li=L().fromPromise;async function ji(e,t){if(te.isAbsolute(e)){try{await Se.lstat(e)}catch(o){throw o.message=o.message.replace("lstat","ensureSymlink"),o}return{toCwd:e,toDst:e}}let r=te.dirname(t),n=te.join(r,e);if(await Oi(n))return{toCwd:n,toDst:e};try{await Se.lstat(e)}catch(o){throw o.message=o.message.replace("lstat","ensureSymlink"),o}return{toCwd:e,toDst:te.relative(r,e)}}function Ni(e,t){if(te.isAbsolute(e)){if(!Se.existsSync(e))throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}let r=te.dirname(t),n=te.join(r,e);if(Se.existsSync(n))return{toCwd:n,toDst:e};if(!Se.existsSync(e))throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:te.relative(r,e)}}fr.exports={symlinkPaths:Li(ji),symlinkPathsSync:Ni}});var yr=S((as,dr)=>{"use strict";var pr=B(),Ti=L().fromPromise;async function Ii(e,t){if(t)return t;let r;try{r=await pr.lstat(e)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}function $i(e,t){if(t)return t;let r;try{r=pr.lstatSync(e)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}dr.exports={symlinkType:Ti(Ii),symlinkTypeSync:$i}});var Sr=S((cs,gr)=>{"use strict";var Ai=L().fromPromise,hr=require("path"),H=B(),{mkdirs:_i,mkdirsSync:Di}=G(),{symlinkPaths:Wi,symlinkPathsSync:Bi}=mr(),{symlinkType:Ri,symlinkTypeSync:Mi}=yr(),{pathExists:Ji}=Z(),{areIdentical:wr}=ie();async function Ui(e,t,r){let n;try{n=await H.lstat(t)}catch{}if(n&&n.isSymbolicLink()){let[p,v]=await Promise.all([H.stat(e),H.stat(t)]);if(wr(p,v))return}let i=await Wi(e,t);e=i.toDst;let o=await Ri(i.toCwd,r),s=hr.dirname(t);return await Ji(s)||await _i(s),H.symlink(e,t,o)}function Gi(e,t,r){let n;try{n=H.lstatSync(t)}catch{}if(n&&n.isSymbolicLink()){let p=H.statSync(e),v=H.statSync(t);if(wr(p,v))return}let i=Bi(e,t);e=i.toDst,r=Mi(i.toCwd,r);let o=hr.dirname(t);return H.existsSync(o)||Di(o),H.symlinkSync(e,t,r)}gr.exports={createSymlink:Ai(Ui),createSymlinkSync:Gi}});var qr=S((us,Pr)=>{"use strict";var{createFile:vr,createFileSync:kr}=or(),{createLink:br,createLinkSync:xr}=lr(),{createSymlink:Er,createSymlinkSync:Fr}=Sr();Pr.exports={createFile:vr,createFileSync:kr,ensureFile:vr,ensureFileSync:kr,createLink:br,createLinkSync:xr,ensureLink:br,ensureLinkSync:xr,createSymlink:Er,createSymlinkSync:Fr,ensureSymlink:Er,ensureSymlinkSync:Fr}});var Ce=S((ls,Cr)=>{function Yi(e,{EOL:t=`
|
|
7
|
+
`,finalEOL:r=!0,replacer:n=null,spaces:i}={}){let o=r?t:"";return JSON.stringify(e,n,i).replace(/\n/g,t)+o}function Ki(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e.replace(/^\uFEFF/,"")}Cr.exports={stringify:Yi,stripBom:Ki}});var Nr=S((fs,jr)=>{var le;try{le=ae()}catch{le=require("fs")}var Oe=L(),{stringify:Or,stripBom:Lr}=Ce();async function Vi(e,t={}){typeof t=="string"&&(t={encoding:t});let r=t.fs||le,n="throws"in t?t.throws:!0,i=await Oe.fromCallback(r.readFile)(e,t);i=Lr(i);let o;try{o=JSON.parse(i,t?t.reviver:null)}catch(s){if(n)throw s.message=`${e}: ${s.message}`,s;return null}return o}var Hi=Oe.fromPromise(Vi);function Qi(e,t={}){typeof t=="string"&&(t={encoding:t});let r=t.fs||le,n="throws"in t?t.throws:!0;try{let i=r.readFileSync(e,t);return i=Lr(i),JSON.parse(i,t.reviver)}catch(i){if(n)throw i.message=`${e}: ${i.message}`,i;return null}}async function zi(e,t,r={}){let n=r.fs||le,i=Or(t,r);await Oe.fromCallback(n.writeFile)(e,i,r)}var Xi=Oe.fromPromise(zi);function Zi(e,t,r={}){let n=r.fs||le,i=Or(t,r);return n.writeFileSync(e,i,r)}var eo={readFile:Hi,readFileSync:Qi,writeFile:Xi,writeFileSync:Zi};jr.exports=eo});var Ir=S((ms,Tr)=>{"use strict";var Le=Nr();Tr.exports={readJson:Le.readFile,readJsonSync:Le.readFileSync,writeJson:Le.writeFile,writeJsonSync:Le.writeFileSync}});var je=S((ps,_r)=>{"use strict";var to=L().fromPromise,Ye=B(),$r=require("path"),Ar=G(),ro=Z().pathExists;async function no(e,t,r="utf-8"){let n=$r.dirname(e);return await ro(n)||await Ar.mkdirs(n),Ye.writeFile(e,t,r)}function io(e,...t){let r=$r.dirname(e);Ye.existsSync(r)||Ar.mkdirsSync(r),Ye.writeFileSync(e,...t)}_r.exports={outputFile:to(no),outputFileSync:io}});var Wr=S((ds,Dr)=>{"use strict";var{stringify:oo}=Ce(),{outputFile:so}=je();async function ao(e,t,r={}){let n=oo(t,r);await so(e,n,r)}Dr.exports=ao});var Rr=S((ys,Br)=>{"use strict";var{stringify:co}=Ce(),{outputFileSync:uo}=je();function lo(e,t,r){let n=co(t,r);uo(e,n,r)}Br.exports=lo});var Jr=S((hs,Mr)=>{"use strict";var fo=L().fromPromise,M=Ir();M.outputJson=fo(Wr());M.outputJsonSync=Rr();M.outputJSON=M.outputJson;M.outputJSONSync=M.outputJsonSync;M.writeJSON=M.writeJson;M.writeJSONSync=M.writeJsonSync;M.readJSON=M.readJson;M.readJSONSync=M.readJsonSync;Mr.exports=M});var Vr=S((ws,Kr)=>{"use strict";var mo=B(),Ur=require("path"),{copy:po}=qe(),{remove:Yr}=ge(),{mkdirp:yo}=G(),{pathExists:ho}=Z(),Gr=ie();async function wo(e,t,r={}){let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:o=!1}=await Gr.checkPaths(e,t,"move",r);await Gr.checkParentPaths(e,i,t,"move");let s=Ur.dirname(t);return Ur.parse(s).root!==s&&await yo(s),go(e,t,n,o)}async function go(e,t,r,n){if(!n){if(r)await Yr(t);else if(await ho(t))throw new Error("dest already exists.")}try{await mo.rename(e,t)}catch(i){if(i.code!=="EXDEV")throw i;await So(e,t,r)}}async function So(e,t,r){return await po(e,t,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),Yr(e)}Kr.exports=wo});var Zr=S((gs,Xr)=>{"use strict";var Qr=ae(),Ve=require("path"),vo=qe().copySync,zr=ge().removeSync,ko=G().mkdirpSync,Hr=ie();function bo(e,t,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:o=!1}=Hr.checkPathsSync(e,t,"move",r);return Hr.checkParentPathsSync(e,i,t,"move"),xo(t)||ko(Ve.dirname(t)),Eo(e,t,n,o)}function xo(e){let t=Ve.dirname(e);return Ve.parse(t).root===t}function Eo(e,t,r,n){if(n)return Ke(e,t,r);if(r)return zr(t),Ke(e,t,r);if(Qr.existsSync(t))throw new Error("dest already exists.");return Ke(e,t,r)}function Ke(e,t,r){try{Qr.renameSync(e,t)}catch(n){if(n.code!=="EXDEV")throw n;return Fo(e,t,r)}}function Fo(e,t,r){return vo(e,t,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),zr(e)}Xr.exports=bo});var tn=S((Ss,en)=>{"use strict";var Po=L().fromPromise;en.exports={move:Po(Vr()),moveSync:Zr()}});var Ne=S((vs,rn)=>{"use strict";rn.exports={...B(),...qe(),...tr(),...qr(),...Jr(),...G(),...tn(),...je(),...Z(),...ge()}});var tt=A(require("yargs")),rt=require("yargs/helpers"),nt=A(require("find-config")),it=A(require("dotenv"));var Te=A(et());Te.default.setDefaultLevel(process.env.LOG_LEVEL??"info");function J(e){return Te.default.getLogger(e)}var ot=A(require("path")),Ie=J("cliBase");function xn(){let e=(0,nt.default)(".env");if(!e)Ie.warn("No .env config file found.");else if(e){Ie.info("Using .env config file at path: %s",e);let{error:t}=it.default.config({path:e});t&&(Ie.error("Error reading .env config file at path: %s: %s",e,t.message),process.exit(1))}}function En(e,t,r,n){xn(),(0,tt.default)((0,rt.hideBin)(process.argv)).scriptName(e).options(n??{}).env("PLUGIN").usage("$0 [repoPath]").command("$0 [repoPath]",t,i=>i.positional("repoPath",{describe:"The full path to plugin root directory.",type:"string"}),async i=>{await r(i)}).check(({repoPath:i})=>{if(!i)throw new Error("No plugin repository path found. Please either pass it as an argument to this process or specify it in your .env file as PLUGIN_REPO_PATH. ");if(i.startsWith(ot.default.sep))return!0;throw new Error("The plugin repository path must be a full (not relative) path.")}).help().parse()}var V=En;var at=A(require("shelljs"));var st=J("lintPlugin");async function ct(e,t){st.info("Linting plugin directory",t);let n=`eslint --ext .js --ext .jsx --ext .tsx --ext .ts --cache --config ${t}/.eslintrc.js ${e==="lint:fix"?"--fix --max-warnings=0":""} ${t}/src`;st.debug(n),at.default.exec(n)}var ut=ct;V("lint:plugin","Lints the plugin files or fixes the plugin files linting",async({repoPath:e,command:t})=>{await ct(t,e)},{c:{alias:"command",choices:["lint","lint:fix"],demandOption:!1,default:"lint",type:"string"}});var x=A(Ne()),F=A(require("path"));var qo=J("setupPlugin"),Co={hooks:{"pre-commit":"npm run precommit","post-commit":"git update-index --again"}},Oo={"**/*.{js,jsx,ts,tsx,css,scss,pcss,json}":["prettier --write"],"**/*.{js,ts,tsx}":["eslint --fix --ignore-pattern '!.eslintrc.js' --ignore-pattern '!.prettierrc.js'"]};async function nn(e){qo.info("Initializing plugin directory %s",e),await x.default.ensureDir(F.default.join(e,"pages")),await x.default.ensureDir(F.default.join(e,"src")),await x.default.copy("templates/.babelrc.tmpl",F.default.join(e,".babelrc"),{overwrite:!0}),await x.default.copy("templates/.env.tmpl",F.default.join(e,".env"),{overwrite:!1}),await x.default.copy("templates/.npmrc.tmpl",F.default.join(e,".npmrc"),{overwrite:!0}),await x.default.copy("templates/.nvmrc.tmpl",F.default.join(e,".nvmrc"),{overwrite:!0}),await x.default.copy("templates/.gitignore.tmpl",F.default.join(e,".gitignore"),{overwrite:!0}),await x.default.copy("templates/tsconfig.tmpl.json",F.default.join(e,"tsconfig.json"),{overwrite:!0}),await x.default.copy("templates/tsconfig.server.tmpl.json",F.default.join(e,"tsconfig.server.json"),{overwrite:!0}),await x.default.copy("templates/.eslintignore.tmpl",F.default.join(e,".eslintignore"),{overwrite:!0}),await x.default.copy("templates/.eslintrc.tmpl.js",F.default.join(e,".eslintrc.js"),{overwrite:!0}),await x.default.copy("templates/.prettierignore.tmpl",F.default.join(e,".prettierignore"),{overwrite:!0}),await x.default.copy("templates/.prettierrc.tmpl.js",F.default.join(e,".prettierrc.js"),{overwrite:!0});let r=(await x.default.readJson("./package.json")).name,n=await x.default.readJson(F.default.join(e,"package.json"),"utf8");n.scripts.start=`npm explore ${r} -- npm run start -- $INIT_CWD`,n.scripts.dev=`npm explore ${r} -- npm run dev:plugin -- $INIT_CWD`,n.scripts.build=`npm explore ${r} -- npm run build:plugin -- $INIT_CWD`,n.scripts.lint=`npm explore ${r} -- npm run lint:plugin -- $INIT_CWD`,n.scripts["lint:fix"]=`npm explore ${r} -- npm run lint:plugin:fix -- $INIT_CWD`,n.scripts.format=`npm explore ${r} -- npm run format:plugin -- $INIT_CWD`,n.scripts["format:fix"]=`npm explore ${r} -- npm run format:plugin:fix -- $INIT_CWD`,n.scripts.init=`npm explore ${r} -- npm run init:plugin -- $INIT_CWD`,n.scripts.precommit="lint-staged",n.husky=Co,n["lint-staged"]=Oo,await x.default.writeJson(F.default.join(e,"package.json"),n,{spaces:" "}),await x.default.copy("next.config.js",F.default.join(e,"next.config.js"),{overwrite:!0}),await x.default.copy("README.md",F.default.join(e,"SDK.md"),{overwrite:!0}),await x.default.copy("types/mf/aurora.d.ts",F.default.join(e,"types/mf/aurora.d.ts"),{overwrite:!0}),await x.default.copy("types/pkg/aurora.d.ts",F.default.join(e,"types/pkg/aurora.d.ts"),{overwrite:!0}),await x.default.copy("types/graphql.d.ts",F.default.join(e,"types/graphql.d.ts"),{overwrite:!0})}var on=nn;V("init:plugin","Setup static files for the plugin",async({repoPath:e})=>{await nn(e)});var an=A(require("shelljs"));var sn=J("formatPlugin");async function cn(e,t){sn.info("Formatting plugin directory",t);let n=`prettier --config ${t}/.prettierrc.js --ignore-path ${t}/.prettierignore ${e==="format:fix"?"--write":"--check"} ${t}/res ${t}/src `;sn.debug(n),an.default.exec(n)}var un=cn;V("format:plugin","Checks the plugin files for formatting or fixes the formatting in plugin files",async({command:e,repoPath:t})=>await cn(e,t),{c:{alias:"command",choices:["format","format:fix"],demandOption:!1,default:"format",type:"string"}});var ln=require("glob"),He=A(require("shelljs")),Qe=A(Ne()),fe=A(require("path"));var Lo=async e=>{let t=await(0,ln.glob)(fe.default.join(e,"**/*.component.json")),n=(await Promise.all(t.map(async o=>({path:o,descriptor:await Qe.default.readJson(o)})))).filter(o=>o.descriptor.markupLanguage==="REACT"),i={};return n.forEach(o=>{let{descriptor:s,path:p}=o,{fetchedContent:v}=s.defaults.config;if(v&&v.enabled){let O=`./${v.remoteName||s.id}`,a=`./${fe.default.relative(e,fe.default.join(fe.default.dirname(p.replace("/res","/src")),`${v.componentModuleName||"Component"}.tsx`))}`;Object.assign(i,{[O]:a})}}),i};async function fn(e,t,r){let n=await Lo(t);await Qe.default.writeJSON(fe.default.join(t,"federation.config.json"),{name:"auroraComponents",exposes:n,extraOptions:{debug:!1}});let i="";e==="dev"&&(i=`-p ${r}`),He.default.env.NEXT_PRIVATE_LOCAL_WEBPACK="true",He.default.exec(`next ${e} ${i} ${t}`)}var mn=fn;V("build:plugin","Builds the plugin or runs the plugin in dev mode",async({repoPath:e,nextCliCommand:t,port:r})=>{await fn(t,e,r)},{c:{alias:"nextCliCommand",choices:["build","dev"],describe:"The NextJS CLI command to run",demandOption:!1,default:"build",type:"string"},p:{alias:"port",demandOption:!1,describe:"The port to run on in dev mode",default:3002,type:"number"}});var pn=A(require("shelljs")),dn=A(require("dotenv")),K=A(Ne()),Y=A(require("path")),yn=require("rimraf");var ze=J("buildModules");async function jo(e,t){let r=Y.default.join(e,"src/endpoints");if(await(0,K.pathExists)(r)){ze.info("Building plugin modules at %s",Y.default.resolve(__dirname,e));let n=t.startsWith("/")?t:Y.default.join(e,t);await(0,K.ensureDir)(n),await(0,yn.rimraf)(Y.default.join(n,"pkg")),ze.info(`Output directory is ${n}`),dn.default.config({path:Y.default.join(`${e}`,".env")}),pn.default.exec(`tsc -p ${e}/tsconfig.server.json`),await(0,K.copy)(r,Y.default.join(e,"dist/pkg/endpoints"),{filter:o=>!(o.endsWith(".ts")||o.includes("node_modules"))});let i=await(0,K.readJSON)(Y.default.join(e,"package.json"));i.workspaces=["endpoints/**/*"],await(0,K.writeJSON)(Y.default.join(e,"dist/pkg/package.json"),i),await(0,K.copy)(Y.default.join(e,"package-lock.json"),Y.default.join(e,"dist/pkg/package-lock.json"))}else ze.info("No plugin modules to build")}var hn=jo;var No=J("buildPlugin");V("build:modules","Build the plugin modules",async({repoPath:e,outputDirectory:t,init:r,lint:n,format:i})=>{let o=Date.now();r===!0&&await on(e),n===!0&&await ut("lint",e),i===!0&&await un("format",e),await mn("build",e,3002),await hn(e,t),No.info("Plugin build complete in "+(Date.now()-o)+"ms")},{b:{alias:"branchName",demandOption:!1,default:"main",describe:'The branch to build. If not specified, "main" is assumed. This does not control the checked out files but adds an additional branch segment to the S3 file key',type:"string"},c:{alias:"changeSet",demandOption:!1,describe:"A set of changed files. If not specified, all components and middlewares in the plugin will be built. If specified, only components and middlewares with changed files will be built.",type:"array"},o:{alias:"outputDirectory",demandOption:!1,default:"dist",describe:'The output directory. If not specified, "dist" is assumed. This is where the build artifacts will be placed.',type:"string"},i:{alias:"init",demandOption:!1,default:!1,describe:"Whether to init the plugin as part of the build process",type:"boolean"},l:{alias:"lint",demandOption:!1,default:!1,describe:"Whether to run lint as part of the build process.",type:"boolean"},f:{alias:"format",demandOption:!1,default:!1,describe:"Whether to run format as part of the build process.",type:"boolean"}});
|