sst 2.0.0-rc.2 → 2.0.0-rc.21

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.
Files changed (107) hide show
  1. package/bootstrap.js +3 -3
  2. package/bus.d.ts +3 -3
  3. package/cache.js +1 -1
  4. package/cdk/deploy-stack.d.ts +2 -2
  5. package/cdk/deploy-stack.js +24 -16
  6. package/cli/commands/bind.js +2 -2
  7. package/cli/commands/build.js +4 -4
  8. package/cli/commands/deploy.js +11 -6
  9. package/cli/commands/dev.js +14 -16
  10. package/cli/commands/env.js +4 -3
  11. package/cli/commands/plugins/kysely.js +2 -2
  12. package/cli/commands/remove.js +4 -5
  13. package/cli/commands/update.js +12 -6
  14. package/cli/local/router.d.ts +6 -6
  15. package/cli/local/router.js +3 -3
  16. package/cli/local/server.d.ts +1 -1
  17. package/cli/local/server.js +7 -12
  18. package/cli/program.d.ts +1 -1
  19. package/cli/program.js +1 -1
  20. package/cli/telemetry/environment.d.ts +1 -1
  21. package/cli/telemetry/environment.js +1 -1
  22. package/cli/ui/deploy.js +2 -2
  23. package/config.js +5 -5
  24. package/constructs/Api.d.ts +3 -3
  25. package/constructs/ApiGatewayV1Api.d.ts +2 -2
  26. package/constructs/App.d.ts +2 -2
  27. package/constructs/App.js +1 -1
  28. package/constructs/AppSyncApi.d.ts +1 -1
  29. package/constructs/AppSyncApi.js +1 -1
  30. package/constructs/Function.d.ts +4 -5
  31. package/constructs/Function.js +6 -14
  32. package/constructs/FunctionalStack.d.ts +2 -2
  33. package/constructs/Job.d.ts +1 -1
  34. package/constructs/Job.js +2 -2
  35. package/constructs/Metadata.d.ts +19 -19
  36. package/constructs/NextjsSite.d.ts +1 -1
  37. package/constructs/NextjsSite.js +21 -4
  38. package/constructs/RDS.d.ts +1 -1
  39. package/constructs/RDS.js +1 -1
  40. package/constructs/ReactStaticSite.d.ts +2 -2
  41. package/constructs/ReactStaticSite.js +2 -1
  42. package/constructs/Script.js +1 -1
  43. package/constructs/SsrSite.d.ts +11 -6
  44. package/constructs/SsrSite.js +56 -43
  45. package/constructs/Stack.d.ts +1 -1
  46. package/constructs/Stack.js +1 -1
  47. package/constructs/StaticSite.d.ts +3 -3
  48. package/constructs/StaticSite.js +9 -9
  49. package/constructs/Table.d.ts +1 -1
  50. package/constructs/ViteStaticSite.d.ts +1 -1
  51. package/constructs/ViteStaticSite.js +2 -1
  52. package/constructs/deferred_task.d.ts +1 -1
  53. package/constructs/deprecated/NextjsSite.js +1 -1
  54. package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
  55. package/constructs/util/duration.d.ts +1 -1
  56. package/constructs/util/permission.d.ts +3 -3
  57. package/constructs/util/size.d.ts +1 -1
  58. package/context/handler.d.ts +1 -1
  59. package/credentials.d.ts +1 -1
  60. package/credentials.js +8 -6
  61. package/index.d.ts +1 -0
  62. package/index.js +1 -0
  63. package/iot.js +2 -2
  64. package/logger.js +1 -1
  65. package/node/api/index.d.ts +2 -0
  66. package/node/api/index.js +8 -0
  67. package/node/auth/adapter/adapter.d.ts +1 -1
  68. package/node/auth/adapter/github.js +4 -4
  69. package/node/auth/adapter/google.d.ts +1 -1
  70. package/node/auth/session.d.ts +1 -1
  71. package/node/config/index.d.ts +2 -2
  72. package/node/job/index.d.ts +2 -2
  73. package/package.json +8 -13
  74. package/project.d.ts +44 -0
  75. package/{app.js → project.js} +56 -51
  76. package/runtime/handlers/dotnet.js +1 -1
  77. package/runtime/handlers/java.js +1 -1
  78. package/runtime/handlers/node.js +6 -5
  79. package/runtime/handlers.js +14 -11
  80. package/runtime/runtime.d.ts +4 -0
  81. package/runtime/workers.js +4 -0
  82. package/site-env.js +1 -1
  83. package/sst.mjs +807 -16608
  84. package/stacks/build.d.ts +1 -1
  85. package/stacks/build.js +13 -21
  86. package/stacks/metadata.js +5 -5
  87. package/stacks/monitor.d.ts +1 -1
  88. package/stacks/synth.js +4 -4
  89. package/support/base-site-archiver.mjs +79 -0
  90. package/support/bridge/bridge.mjs +83 -22
  91. package/support/custom-resources/index.mjs +22 -1
  92. package/support/edge-function/edge-lambda.mjs +2 -2
  93. package/support/nodejs-runtime/index.mjs +79 -72
  94. package/support/rds-migrator/index.mjs +27 -23
  95. package/support/script-function/index.mjs +30485 -0
  96. package/support/ssr-site-function-archiver.mjs +96 -0
  97. package/watcher.js +1 -1
  98. package/app.d.ts +0 -36
  99. package/constructs/Script/cfn-response.d.ts +0 -19
  100. package/constructs/Script/cfn-response.js +0 -77
  101. package/constructs/Script/index.d.ts +0 -1
  102. package/constructs/Script/index.js +0 -78
  103. package/constructs/Script/outbound.d.ts +0 -10
  104. package/constructs/Script/outbound.js +0 -42
  105. package/constructs/Script/util.d.ts +0 -2
  106. package/constructs/Script/util.js +0 -11
  107. package/support/base-site-archiver.cjs +0 -116
package/stacks/build.d.ts CHANGED
@@ -6,4 +6,4 @@ declare module "../bus.js" {
6
6
  };
7
7
  }
8
8
  }
9
- export declare function build(): Promise<any>;
9
+ export declare function load(input: string): Promise<readonly [esbuild.Metafile, any]>;
package/stacks/build.js CHANGED
@@ -1,18 +1,14 @@
1
1
  import esbuild from "esbuild";
2
2
  import fs from "fs/promises";
3
3
  import path from "path";
4
- import { Logger } from "../logger.js";
5
- import { useBus } from "../bus.js";
6
- import { useProject } from "../app.js";
7
4
  import { dynamicImport } from "../util/module.js";
8
- export async function build() {
9
- const project = useProject();
10
- const bus = useBus();
11
- const pkg = JSON.parse(await fs
12
- .readFile(path.join(project.paths.root, "package.json"))
13
- .then((x) => x.toString()));
14
- const outfile = path.join(project.paths.out, `stacks.${Math.random()}.mjs`);
15
- Logger.debug("Running esbuild on", project.main, "to", outfile);
5
+ import { findAbove } from "../util/fs.js";
6
+ import { VisibleError } from "../error.js";
7
+ export async function load(input) {
8
+ const parsed = path.parse(input);
9
+ const root = await findAbove(input, "package.json");
10
+ const outfile = path.join(parsed.dir, `${parsed.name}.${Date.now()}.mjs`);
11
+ const pkg = JSON.parse(await fs.readFile(path.join(root, "package.json")).then((x) => x.toString()));
16
12
  const result = await esbuild.build({
17
13
  keepNames: true,
18
14
  bundle: true,
@@ -23,14 +19,14 @@ export async function build() {
23
19
  format: "esm",
24
20
  external: [
25
21
  "aws-cdk-lib",
26
- "@serverless-stack/*",
22
+ "sst",
27
23
  ...Object.keys({
28
24
  ...pkg.devDependencies,
29
25
  ...pkg.dependencies,
30
26
  ...pkg.peerDependencies,
31
27
  }),
32
28
  ],
33
- absWorkingDir: project.paths.root,
29
+ absWorkingDir: root,
34
30
  outfile,
35
31
  banner: {
36
32
  js: [
@@ -41,20 +37,16 @@ export async function build() {
41
37
  // The entry can have any file name (ie. "stacks/anything.ts"). We want the
42
38
  // build output to be always named "lib/index.js". This allow us to always
43
39
  // import from "buildDir" without needing to pass "anything" around.
44
- entryPoints: [project.main],
40
+ entryPoints: [input],
45
41
  });
46
- Logger.debug("Finished esbuild");
47
- Logger.debug("Sourcing stacks");
48
42
  try {
49
43
  const mod = await dynamicImport(outfile);
50
- Logger.debug("Finished sourcing stacks");
51
44
  await fs.rm(outfile, {
52
45
  force: true,
53
46
  });
54
- bus.publish("stack.built", {
55
- metafile: result.metafile,
56
- });
57
- return mod.default;
47
+ if (!mod.default?.config)
48
+ throw new VisibleError(`The config file is improperly formatted.`, `Example:`, `export default {`, ` config() {`, ` return {`, ` name: "my-app",`, ` region: "us-east-1"`, ` }`, ` },`, ` stacks(app) {`, ` }`, `}`);
49
+ return [result.metafile, mod.default];
58
50
  }
59
51
  catch (e) {
60
52
  await fs.rm(outfile, {
@@ -7,7 +7,7 @@ import { Context } from "../context/context.js";
7
7
  import { useBus } from "../bus.js";
8
8
  import { Stacks } from "./index.js";
9
9
  import { Logger } from "../logger.js";
10
- import { useProject } from "../app.js";
10
+ import { useProject } from "../project.js";
11
11
  export async function metadata() {
12
12
  Logger.debug("Fetching all metadata");
13
13
  const project = useProject();
@@ -16,10 +16,10 @@ export async function metadata() {
16
16
  useBootstrap(),
17
17
  ]);
18
18
  const s3 = new S3Client({
19
- region: project.region,
19
+ region: project.config.region,
20
20
  credentials: credentials,
21
21
  });
22
- const key = `stackMetadata/app.${project.name}/stage.${project.stage}/`;
22
+ const key = `stackMetadata/app.${project.config.name}/stage.${project.config.stage}/`;
23
23
  const list = await s3.send(new ListObjectsV2Command({
24
24
  Prefix: key,
25
25
  Bucket: bootstrap.bucket,
@@ -44,10 +44,10 @@ export async function metadataForStack(stackID) {
44
44
  useBootstrap(),
45
45
  ]);
46
46
  const s3 = new S3Client({
47
- region: project.region,
47
+ region: project.config.region,
48
48
  credentials: credentials,
49
49
  });
50
- const key = `stackMetadata/app.${project.name}/stage.${project.stage}/stack.${stackID}.json`;
50
+ const key = `stackMetadata/app.${project.config.name}/stage.${project.config.stage}/stack.${stackID}.json`;
51
51
  Logger.debug("Getting metadata", key, "from", bootstrap.bucket);
52
52
  try {
53
53
  const result = await s3
@@ -24,4 +24,4 @@ export declare function monitor(stack: string): Promise<{
24
24
  outputs: Record<string, string>;
25
25
  errors: Record<string, string>;
26
26
  }>;
27
- export declare type StackDeploymentResult = Awaited<ReturnType<typeof monitor>>;
27
+ export type StackDeploymentResult = Awaited<ReturnType<typeof monitor>>;
package/stacks/synth.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Logger } from "../logger.js";
2
- import { useProject } from "../app.js";
2
+ import { useProject } from "../project.js";
3
3
  import { useAWSProvider, useSTSIdentity } from "../credentials.js";
4
4
  import { useBootstrap } from "../bootstrap.js";
5
5
  import * as contextproviders from "aws-cdk/lib/context-providers/index.js";
@@ -43,9 +43,9 @@ export async function synth(opts) {
43
43
  while (true) {
44
44
  const app = new App({
45
45
  account: identity.Account,
46
- stage: project.stage,
47
- name: project.name,
48
- region: project.region,
46
+ stage: project.config.stage,
47
+ name: project.config.name,
48
+ region: project.config.region,
49
49
  mode: opts.mode,
50
50
  skipBuild: opts.mode === "remove",
51
51
  bootstrap,
@@ -18,3 +18,82 @@ See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof be))r
18
18
  See: https://github.com/isaacs/node-glob/issues/167`);return new we(e,t).found}a(wp,"globSync");function we(e,t){if(!e)throw new Error("must provide pattern");if(typeof t=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
19
19
  See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof we))return new we(e,t);if(YE(this,e,t),this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var i=0;i<r;i++)this._process(this.minimatch.set[i],i,!1);this._finish()}a(we,"GlobSync");we.prototype._finish=function(){if(bp.ok(this instanceof we),this.realpath){var e=this;this.matches.forEach(function(t,r){var i=e.matches[r]=Object.create(null);for(var n in t)try{n=e._makeAbs(n);var s=QE.realpathSync(n,e.realpathCache);i[s]=!0}catch(o){if(o.syscall==="stat")i[e._makeAbs(n)]=!0;else throw o}})}Ht.finish(this)};we.prototype._process=function(e,t,r){bp.ok(this instanceof we);for(var i=0;typeof e[i]=="string";)i++;var n;switch(i){case e.length:this._processSimple(e.join("/"),t);return;case 0:n=null;break;default:n=e.slice(0,i).join("/");break}var s=e.slice(i),o;n===null?o=".":((Zn(n)||Zn(e.map(function(d){return typeof d=="string"?d:"[*]"}).join("/")))&&(!n||!Zn(n))&&(n="/"+n),o=n);var u=this._makeAbs(o);if(!KE(this,o)){var l=s[0]===_p.GLOBSTAR;l?this._processGlobStar(n,o,u,s,t,r):this._processReaddir(n,o,u,s,t,r)}};we.prototype._processReaddir=function(e,t,r,i,n,s){var o=this._readdir(r,s);if(o){for(var u=i[0],l=!!this.minimatch.negate,d=u._glob,p=this.dot||d.charAt(0)===".",m=[],g=0;g<o.length;g++){var y=o[g];if(y.charAt(0)!=="."||p){var b;l&&!e?b=!y.match(u):b=y.match(u),b&&m.push(y)}}var A=m.length;if(A!==0){if(i.length===1&&!this.mark&&!this.stat){this.matches[n]||(this.matches[n]=Object.create(null));for(var g=0;g<A;g++){var y=m[g];e&&(e.slice(-1)!=="/"?y=e+"/"+y:y=e+y),y.charAt(0)==="/"&&!this.nomount&&(y=Co.join(this.root,y)),this._emitMatch(n,y)}return}i.shift();for(var g=0;g<A;g++){var y=m[g],E;e?E=[e,y]:E=[y],this._process(E.concat(i),n,s)}}}};we.prototype._emitMatch=function(e,t){if(!XE(this,t)){var r=this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var i=this.cache[r];if(i==="DIR"||Array.isArray(i))return}this.matches[e][t]=!0,this.stat&&this._stat(t)}}};we.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var t,r,i;try{r=this.fs.lstatSync(e)}catch(s){if(s.code==="ENOENT")return null}var n=r&&r.isSymbolicLink();return this.symlinks[e]=n,!n&&r&&!r.isDirectory()?this.cache[e]="FILE":t=this._readdir(e,!1),t};we.prototype._readdir=function(e,t){var r;if(t&&!Po(this.symlinks,e))return this._readdirInGlobStar(e);if(Po(this.cache,e)){var i=this.cache[e];if(!i||i==="FILE")return null;if(Array.isArray(i))return i}try{return this._readdirEntries(e,this.fs.readdirSync(e))}catch(n){return this._readdirError(e,n),null}};we.prototype._readdirEntries=function(e,t){if(!this.mark&&!this.stat)for(var r=0;r<t.length;r++){var i=t[r];e==="/"?i=e+i:i=e+"/"+i,this.cache[i]=!0}return this.cache[e]=t,t};we.prototype._readdirError=function(e,t){switch(t.code){case"ENOTSUP":case"ENOTDIR":var r=this._makeAbs(e);if(this.cache[r]="FILE",r===this.cwdAbs){var i=new Error(t.code+" invalid cwd "+this.cwd);throw i.path=this.cwd,i.code=t.code,i}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:if(this.cache[this._makeAbs(e)]=!1,this.strict)throw t;this.silent||console.error("glob error",t);break}};we.prototype._processGlobStar=function(e,t,r,i,n,s){var o=this._readdir(r,s);if(o){var u=i.slice(1),l=e?[e]:[],d=l.concat(u);this._process(d,n,!1);var p=o.length,m=this.symlinks[r];if(!(m&&s))for(var g=0;g<p;g++){var y=o[g];if(!(y.charAt(0)==="."&&!this.dot)){var b=l.concat(o[g],u);this._process(b,n,!0);var A=l.concat(o[g],i);this._process(A,n,!0)}}}};we.prototype._processSimple=function(e,t){var r=this._stat(e);if(this.matches[t]||(this.matches[t]=Object.create(null)),!!r){if(e&&Zn(e)&&!this.nomount){var i=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=Co.join(this.root,e):(e=Co.resolve(this.root,e),i&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e)}};we.prototype._stat=function(e){var t=this._makeAbs(e),r=e.slice(-1)==="/";if(e.length>this.maxLength)return!1;if(!this.stat&&Po(this.cache,t)){var o=this.cache[t];if(Array.isArray(o)&&(o="DIR"),!r||o==="DIR")return o;if(r&&o==="FILE")return!1}var i,n=this.statCache[t];if(!n){var s;try{s=this.fs.lstatSync(t)}catch(u){if(u&&(u.code==="ENOENT"||u.code==="ENOTDIR"))return this.statCache[t]=!1,!1}if(s&&s.isSymbolicLink())try{n=this.fs.statSync(t)}catch{n=s}else n=s}this.statCache[t]=n;var o=!0;return n&&(o=n.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||o,r&&o==="FILE"?!1:o};we.prototype._mark=function(e){return Ht.mark(this,e)};we.prototype._makeAbs=function(e){return Ht.makeAbs(this,e)}});var No=L((jx,Tp)=>{Tp.exports=$t;var JE=Zr(),Op=Mr(),qx=Op.Minimatch,e1=Me(),t1=D("events").EventEmitter,qo=D("path"),Fo=D("assert"),pi=D("path").isAbsolute,ko=Ep(),Zt=Do(),r1=Zt.setopts,jo=Zt.ownProp,Bo=Ss(),Fx=D("util"),i1=Zt.childrenIgnored,n1=Zt.isIgnored,a1=Yr();function $t(e,t,r){if(typeof t=="function"&&(r=t,t={}),t||(t={}),t.sync){if(r)throw new TypeError("callback provided to sync glob");return ko(e,t)}return new le(e,t,r)}a($t,"glob");$t.sync=ko;var s1=$t.GlobSync=ko.GlobSync;$t.glob=$t;function o1(e,t){if(t===null||typeof t!="object")return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e}a(o1,"extend");$t.hasMagic=function(e,t){var r=o1({},t);r.noprocess=!0;var i=new le(e,r),n=i.minimatch.set;if(!e)return!1;if(n.length>1)return!0;for(var s=0;s<n[0].length;s++)if(typeof n[0][s]!="string")return!0;return!1};$t.Glob=le;e1(le,t1);function le(e,t,r){if(typeof t=="function"&&(r=t,t=null),t&&t.sync){if(r)throw new TypeError("callback provided to sync glob");return new s1(e,t)}if(!(this instanceof le))return new le(e,t,r);r1(this,e,t),this._didRealPath=!1;var i=this.minimatch.set.length;this.matches=new Array(i),typeof r=="function"&&(r=a1(r),this.on("error",r),this.on("end",function(l){r(null,l)}));var n=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(i===0)return u();for(var s=!0,o=0;o<i;o++)this._process(this.minimatch.set[o],o,!1,u);s=!1;function u(){--n._processing,n._processing<=0&&(s?process.nextTick(function(){n._finish()}):n._finish())}a(u,"done")}a(le,"Glob");le.prototype._finish=function(){if(Fo(this instanceof le),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();Zt.finish(this),this.emit("end",this.found)}};le.prototype._realpath=function(){if(this._didRealpath)return;this._didRealpath=!0;var e=this.matches.length;if(e===0)return this._finish();for(var t=this,r=0;r<this.matches.length;r++)this._realpathSet(r,i);function i(){--e===0&&t._finish()}a(i,"next")};le.prototype._realpathSet=function(e,t){var r=this.matches[e];if(!r)return t();var i=Object.keys(r),n=this,s=i.length;if(s===0)return t();var o=this.matches[e]=Object.create(null);i.forEach(function(u,l){u=n._makeAbs(u),JE.realpath(u,n.realpathCache,function(d,p){d?d.syscall==="stat"?o[u]=!0:n.emit("error",d):o[p]=!0,--s===0&&(n.matches[e]=o,t())})})};le.prototype._mark=function(e){return Zt.mark(this,e)};le.prototype._makeAbs=function(e){return Zt.makeAbs(this,e)};le.prototype.abort=function(){this.aborted=!0,this.emit("abort")};le.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))};le.prototype.resume=function(){if(this.paused){if(this.emit("resume"),this.paused=!1,this._emitQueue.length){var e=this._emitQueue.slice(0);this._emitQueue.length=0;for(var t=0;t<e.length;t++){var r=e[t];this._emitMatch(r[0],r[1])}}if(this._processQueue.length){var i=this._processQueue.slice(0);this._processQueue.length=0;for(var t=0;t<i.length;t++){var n=i[t];this._processing--,this._process(n[0],n[1],n[2],n[3])}}}};le.prototype._process=function(e,t,r,i){if(Fo(this instanceof le),Fo(typeof i=="function"),!this.aborted){if(this._processing++,this.paused){this._processQueue.push([e,t,r,i]);return}for(var n=0;typeof e[n]=="string";)n++;var s;switch(n){case e.length:this._processSimple(e.join("/"),t,i);return;case 0:s=null;break;default:s=e.slice(0,n).join("/");break}var o=e.slice(n),u;s===null?u=".":((pi(s)||pi(e.map(function(p){return typeof p=="string"?p:"[*]"}).join("/")))&&(!s||!pi(s))&&(s="/"+s),u=s);var l=this._makeAbs(u);if(i1(this,u))return i();var d=o[0]===Op.GLOBSTAR;d?this._processGlobStar(s,u,l,o,t,r,i):this._processReaddir(s,u,l,o,t,r,i)}};le.prototype._processReaddir=function(e,t,r,i,n,s,o){var u=this;this._readdir(r,s,function(l,d){return u._processReaddir2(e,t,r,i,n,s,d,o)})};le.prototype._processReaddir2=function(e,t,r,i,n,s,o,u){if(!o)return u();for(var l=i[0],d=!!this.minimatch.negate,p=l._glob,m=this.dot||p.charAt(0)===".",g=[],y=0;y<o.length;y++){var b=o[y];if(b.charAt(0)!=="."||m){var A;d&&!e?A=!b.match(l):A=b.match(l),A&&g.push(b)}}var E=g.length;if(E===0)return u();if(i.length===1&&!this.mark&&!this.stat){this.matches[n]||(this.matches[n]=Object.create(null));for(var y=0;y<E;y++){var b=g[y];e&&(e!=="/"?b=e+"/"+b:b=e+b),b.charAt(0)==="/"&&!this.nomount&&(b=qo.join(this.root,b)),this._emitMatch(n,b)}return u()}i.shift();for(var y=0;y<E;y++){var b=g[y],x;e&&(e!=="/"?b=e+"/"+b:b=e+b),this._process([b].concat(i),n,s,u)}u()};le.prototype._emitMatch=function(e,t){if(!this.aborted&&!n1(this,t)){if(this.paused){this._emitQueue.push([e,t]);return}var r=pi(t)?t:this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var i=this.cache[r];if(i==="DIR"||Array.isArray(i))return}this.matches[e][t]=!0;var n=this.statCache[r];n&&this.emit("stat",t,n),this.emit("match",t)}}};le.prototype._readdirInGlobStar=function(e,t){if(this.aborted)return;if(this.follow)return this._readdir(e,!1,t);var r="lstat\0"+e,i=this,n=Bo(r,s);n&&i.fs.lstat(e,n);function s(o,u){if(o&&o.code==="ENOENT")return t();var l=u&&u.isSymbolicLink();i.symlinks[e]=l,!l&&u&&!u.isDirectory()?(i.cache[e]="FILE",t()):i._readdir(e,!1,t)}a(s,"lstatcb_")};le.prototype._readdir=function(e,t,r){if(!this.aborted&&(r=Bo("readdir\0"+e+"\0"+t,r),!!r)){if(t&&!jo(this.symlinks,e))return this._readdirInGlobStar(e,r);if(jo(this.cache,e)){var i=this.cache[e];if(!i||i==="FILE")return r();if(Array.isArray(i))return r(null,i)}var n=this;n.fs.readdir(e,u1(this,e,r))}};function u1(e,t,r){return function(i,n){i?e._readdirError(t,i,r):e._readdirEntries(t,n,r)}}a(u1,"readdirCb");le.prototype._readdirEntries=function(e,t,r){if(!this.aborted){if(!this.mark&&!this.stat)for(var i=0;i<t.length;i++){var n=t[i];e==="/"?n=e+n:n=e+"/"+n,this.cache[n]=!0}return this.cache[e]=t,r(null,t)}};le.prototype._readdirError=function(e,t,r){if(!this.aborted){switch(t.code){case"ENOTSUP":case"ENOTDIR":var i=this._makeAbs(e);if(this.cache[i]="FILE",i===this.cwdAbs){var n=new Error(t.code+" invalid cwd "+this.cwd);n.path=this.cwd,n.code=t.code,this.emit("error",n),this.abort()}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:this.cache[this._makeAbs(e)]=!1,this.strict&&(this.emit("error",t),this.abort()),this.silent||console.error("glob error",t);break}return r()}};le.prototype._processGlobStar=function(e,t,r,i,n,s,o){var u=this;this._readdir(r,s,function(l,d){u._processGlobStar2(e,t,r,i,n,s,d,o)})};le.prototype._processGlobStar2=function(e,t,r,i,n,s,o,u){if(!o)return u();var l=i.slice(1),d=e?[e]:[],p=d.concat(l);this._process(p,n,!1,u);var m=this.symlinks[r],g=o.length;if(m&&s)return u();for(var y=0;y<g;y++){var b=o[y];if(!(b.charAt(0)==="."&&!this.dot)){var A=d.concat(o[y],l);this._process(A,n,!0,u);var E=d.concat(o[y],i);this._process(E,n,!0,u)}}u()};le.prototype._processSimple=function(e,t,r){var i=this;this._stat(e,function(n,s){i._processSimple2(e,t,n,s,r)})};le.prototype._processSimple2=function(e,t,r,i,n){if(this.matches[t]||(this.matches[t]=Object.create(null)),!i)return n();if(e&&pi(e)&&!this.nomount){var s=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=qo.join(this.root,e):(e=qo.resolve(this.root,e),s&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e),n()};le.prototype._stat=function(e,t){var r=this._makeAbs(e),i=e.slice(-1)==="/";if(e.length>this.maxLength)return t();if(!this.stat&&jo(this.cache,r)){var n=this.cache[r];if(Array.isArray(n)&&(n="DIR"),!i||n==="DIR")return t(null,n);if(i&&n==="FILE")return t()}var s,o=this.statCache[r];if(o!==void 0){if(o===!1)return t(null,o);var u=o.isDirectory()?"DIR":"FILE";return i&&u==="FILE"?t():t(null,u,o)}var l=this,d=Bo("stat\0"+r,p);d&&l.fs.lstat(r,d);function p(m,g){if(g&&g.isSymbolicLink())return l.fs.stat(r,function(y,b){y?l._stat2(e,r,null,g,t):l._stat2(e,r,y,b,t)});l._stat2(e,r,m,g,t)}a(p,"lstatcb_")};le.prototype._stat2=function(e,t,r,i,n){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return this.statCache[t]=!1,n();var s=e.slice(-1)==="/";if(this.statCache[t]=i,t.slice(-1)==="/"&&i&&!i.isDirectory())return n(null,!1,i);var o=!0;return i&&(o=i.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||o,s&&o==="FILE"?n():n(null,o,i)}});var p1=L(()=>{process.on("unhandledRejection",e=>{throw e});var Vn=D("path"),Qn=D("fs/promises"),f1=D("fs"),l1=gp(),h1=No(),Uo=process.argv.slice(2),Ip=Uo[0],xp=Uo[1],Lp=Uo[2],Rp=Lp*1024*1024,c1={dot:!0,nodir:!0,follow:!0,cwd:Ip},Ap=h1.sync("**",c1);d1().catch(()=>{process.exit(1)});function d1(){return new Promise(async(e,t)=>{let r,i,n,s=[];async function o(){let l=s.length,d=Vn.join(xp,`part${l}.zip`);await Qn.mkdir(Vn.dirname(d),{recursive:!0}),r=f1.createWriteStream(d),i=l1("zip"),n=0,s.push({output:r,archive:i,isOutputClosed:!1}),i.on("warning",t),i.on("error",t),r.once("close",()=>{s[l].isOutputClosed=!0,s.every(({isOutputClosed:p})=>p)&&e()}),i.pipe(r)}a(o,"openZip"),await o();for(let l of Ap){let d=Vn.join(Ip,l),[p,m]=await Promise.all([Qn.readFile(d),Qn.stat(d)]),g=m.size;if(g>Rp)throw new Error(`Cannot package file "${d}". The file is larger than ${Lp}MB.`);n+g>Rp&&(await i.finalize(),o()),i.append(p,{name:l,date:new Date("1980-01-01T00:00:00.000Z"),mode:m.mode}),n+=g}await i.finalize();let u=Vn.join(xp,"filenames");await Qn.writeFile(u,Ap.join(`
20
20
  `))})}a(d1,"generateZips")});export default p1();
21
+ /*! Bundled license information:
22
+
23
+ normalize-path/index.js:
24
+ (*!
25
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
26
+ *
27
+ * Copyright (c) 2014-2018, Jon Schlinkert.
28
+ * Released under the MIT License.
29
+ *)
30
+
31
+ archiver/lib/error.js:
32
+ (**
33
+ * Archiver Core
34
+ *
35
+ * @ignore
36
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
37
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
38
+ *)
39
+
40
+ safe-buffer/index.js:
41
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
42
+
43
+ archiver/lib/core.js:
44
+ (**
45
+ * Archiver Core
46
+ *
47
+ * @ignore
48
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
49
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
50
+ *)
51
+
52
+ crc-32/crc32.js:
53
+ (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
54
+
55
+ zip-stream/index.js:
56
+ (**
57
+ * ZipStream
58
+ *
59
+ * @ignore
60
+ * @license [MIT]{@link https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE}
61
+ * @copyright (c) 2014 Chris Talkington, contributors.
62
+ *)
63
+
64
+ archiver/lib/plugins/zip.js:
65
+ (**
66
+ * ZIP Format Plugin
67
+ *
68
+ * @module plugins/zip
69
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
70
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
71
+ *)
72
+
73
+ archiver/lib/plugins/tar.js:
74
+ (**
75
+ * TAR Format Plugin
76
+ *
77
+ * @module plugins/tar
78
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
79
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
80
+ *)
81
+
82
+ archiver/lib/plugins/json.js:
83
+ (**
84
+ * JSON Format Plugin
85
+ *
86
+ * @module plugins/json
87
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
88
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
89
+ *)
90
+
91
+ archiver/index.js:
92
+ (**
93
+ * Archiver Vending
94
+ *
95
+ * @ignore
96
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
97
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
98
+ *)
99
+ */