sst 2.0.0-rc.1 → 2.0.0-rc.11

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.
@@ -10,7 +10,6 @@ import { contentHash } from "aws-cdk/lib/util/content-hash.js";
10
10
  import { CfnEvaluationException } from "aws-cdk/lib/api/evaluate-cloudformation-template.js";
11
11
  import { tryHotswapDeployment } from "aws-cdk/lib/api/hotswap-deployments.js";
12
12
  import { changeSetHasNoChanges, CloudFormationStack, TemplateParameters, waitForChangeSet, waitForStackDeploy, waitForStackDelete, } from "aws-cdk/lib/api/util/cloudformation.js";
13
- import { StackActivityMonitor, } from "aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.js";
14
13
  import { blue } from "colorette";
15
14
  const LARGE_TEMPLATE_SIZE_KB = 50;
16
15
  export async function deployStack(options) {
@@ -261,14 +260,19 @@ class FullCloudFormationDeployment {
261
260
  }
262
261
  }
263
262
  async monitorDeployment(startTime, expectedChanges) {
264
- const monitor = this.options.quiet
265
- ? undefined
266
- : StackActivityMonitor.withDefaultPrinter(this.cfn, this.stackName, this.stackArtifact, {
267
- resourcesTotal: expectedChanges,
268
- progress: this.options.progress,
269
- changeSetCreationTime: startTime,
270
- ci: this.options.ci,
271
- }).start();
263
+ // const monitor = this.options.quiet
264
+ // ? undefined
265
+ // : StackActivityMonitor.withDefaultPrinter(
266
+ // this.cfn,
267
+ // this.stackName,
268
+ // this.stackArtifact,
269
+ // {
270
+ // resourcesTotal: expectedChanges,
271
+ // progress: this.options.progress,
272
+ // changeSetCreationTime: startTime,
273
+ // ci: this.options.ci,
274
+ // }
275
+ // ).start();
272
276
  let finalState = this.cloudFormationStack;
273
277
  try {
274
278
  const successStack = await waitForStackDeploy(this.cfn, this.stackName);
@@ -279,10 +283,10 @@ class FullCloudFormationDeployment {
279
283
  finalState = successStack;
280
284
  }
281
285
  catch (e) {
282
- throw new Error(suffixWithErrors(e.message, monitor?.errors));
286
+ throw new Error(suffixWithErrors(e.message /*, monitor?.errors*/));
283
287
  }
284
288
  finally {
285
- await monitor?.stop();
289
+ // await monitor?.stop();
286
290
  }
287
291
  debug("Stack %s has completed updating", this.stackName);
288
292
  return {
@@ -399,11 +403,13 @@ export async function destroyStack(options) {
399
403
  if (!currentStack.exists) {
400
404
  return;
401
405
  }
406
+ /*
402
407
  const monitor = options.quiet
403
- ? undefined
404
- : StackActivityMonitor.withDefaultPrinter(cfn, deployName, options.stack, {
405
- ci: options.ci,
408
+ ? undefined
409
+ : StackActivityMonitor.withDefaultPrinter(cfn, deployName, options.stack, {
410
+ ci: options.ci,
406
411
  }).start();
412
+ */
407
413
  try {
408
414
  await cfn
409
415
  .deleteStack({ StackName: deployName, RoleARN: options.roleArn })
@@ -415,12 +421,14 @@ export async function destroyStack(options) {
415
421
  }
416
422
  }
417
423
  catch (e) {
418
- throw new Error(suffixWithErrors(e.message, monitor?.errors));
424
+ throw new Error(suffixWithErrors(e.message /* , monitor?.errors */));
419
425
  }
420
426
  finally {
427
+ /*
421
428
  if (monitor) {
422
- await monitor.stop();
429
+ await monitor.stop();
423
430
  }
431
+ */
424
432
  }
425
433
  }
426
434
  /**
@@ -44,5 +44,7 @@ export const deploy = (program) => program.command("deploy [filter]", "Work on y
44
44
  component.unmount();
45
45
  process.stdout.write("\x1b[?1049l");
46
46
  printDeploymentResults(results);
47
+ if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
48
+ process.exit(1);
47
49
  process.exit(0);
48
50
  });
@@ -11,7 +11,7 @@ export const update = (program) => program.command("update [ver]", "Update SST a
11
11
  const { useProject } = await import("../../app.js");
12
12
  const project = useProject();
13
13
  const files = await find(project.paths.root);
14
- const metadata = await fetch(`https://registry.npmjs.org/sst/${args.ver || "rc"}`).then((resp) => resp.json());
14
+ const metadata = await fetch(`https://registry.npmjs.org/sst/${args.ver || "latest"}`).then((resp) => resp.json());
15
15
  const results = new Map();
16
16
  const tasks = files.map(async (file) => {
17
17
  const data = await fs
@@ -25,9 +25,13 @@ export const update = (program) => program.command("update [ver]", "Update SST a
25
25
  for (const [pkg, existing] of Object.entries(deps)) {
26
26
  if (!PACKAGE_MATCH.some((x) => pkg.startsWith(x)))
27
27
  continue;
28
- const desired = pkg === "sst"
29
- ? metadata.version
30
- : metadata.dependencies["aws-cdk-lib"];
28
+ const desired = (() => {
29
+ if (pkg === "sst")
30
+ return metadata.version;
31
+ if (pkg.endsWith("alpha"))
32
+ return metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
33
+ return metadata.dependencies["aws-cdk-lib"];
34
+ })();
31
35
  if (existing === desired)
32
36
  continue;
33
37
  let arr = results.get(file);
@@ -1,6 +1,7 @@
1
1
  import fs from "fs";
2
2
  import url from "url";
3
3
  import path from "path";
4
+ import spawn from "cross-spawn";
4
5
  import { buildErrorResponsesForRedirectToIndex } from "./BaseSite.js";
5
6
  import { Fn, Duration, RemovalPolicy, } from "aws-cdk-lib";
6
7
  import * as logs from "aws-cdk-lib/aws-logs";
@@ -44,7 +45,24 @@ export class NextjsSite extends SsrSite {
44
45
  handler = "server.handler";
45
46
  }
46
47
  else {
47
- bundlePath = path.join(this.props.path, path.dirname(this.buildConfig.serverBuildOutputFile));
48
+ // Note: cannot point the bundlePath to the `.open-next/server-function`
49
+ // b/c the folder contains node_modules. And pnpm node_modules
50
+ // contains symlinks. CDK cannot zip symlinks correctly.
51
+ // https://github.com/aws/aws-cdk/issues/9251
52
+ // We will zip the folder ourselves.
53
+ const zipOutDir = path.resolve(path.join(this.sstBuildDir, `Site-${this.node.id}-${this.node.addr}`));
54
+ const script = path.resolve(__dirname, "../support/ssr-site-function-archiver.cjs");
55
+ const result = spawn.sync("node", [
56
+ script,
57
+ path.join(this.props.path, ".open-next", "server-function"),
58
+ path.join(zipOutDir, "server-function.zip"),
59
+ ], {
60
+ stdio: "inherit",
61
+ });
62
+ if (result.status !== 0) {
63
+ throw new Error(`There was a problem generating the assets package.`);
64
+ }
65
+ bundlePath = path.join(zipOutDir, "server-function.zip");
48
66
  handler = "index.handler";
49
67
  }
50
68
  return new lambda.Function(this, `ServerFunction`, {
@@ -109,9 +127,8 @@ export class NextjsSite extends SsrSite {
109
127
  };
110
128
  // Create default behavior
111
129
  // default handler for requests that don't match any other path:
112
- // - try S3 first
113
- // - if 403, fall back to lambda handler (mostly for /)
114
- // - if 404, fall back to lambda handler
130
+ // - try lambda handler first first
131
+ // - if failed, fall back to S3
115
132
  const fallbackOriginGroup = new origins.OriginGroup({
116
133
  primaryOrigin: serverBehavior.origin,
117
134
  fallbackOrigin: s3Origin,
package/constructs/RDS.js CHANGED
@@ -294,7 +294,7 @@ export class RDS extends Construct {
294
294
  const app = this.node.root;
295
295
  // Create custom resource handler
296
296
  const handler = new lambda.Function(this, "MigrationHandler", {
297
- code: lambda.Code.fromAsset(path.join(__dirname, "Script")),
297
+ code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
298
298
  runtime: lambda.Runtime.NODEJS_16_X,
299
299
  handler: "index.handler",
300
300
  timeout: cdk.Duration.minutes(15),
@@ -113,7 +113,7 @@ export class Script extends Construct {
113
113
  }
114
114
  createCustomResourceFunction() {
115
115
  const handler = new lambda.Function(this, "ScriptHandler", {
116
- code: lambda.Code.fromAsset(path.join(__dirname, "Script")),
116
+ code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
117
117
  runtime: lambda.Runtime.NODEJS_16_X,
118
118
  handler: "index.handler",
119
119
  timeout: cdk.Duration.minutes(15),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.11",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -45,6 +45,7 @@
45
45
  "@babel/core": "^7.0.0-0",
46
46
  "@babel/generator": "^7.20.5",
47
47
  "@trpc/server": "9.16.0",
48
+ "archiver": "^5.3.1",
48
49
  "aws-cdk": "2.55.0",
49
50
  "aws-cdk-lib": "2.55.0",
50
51
  "aws-iot-device-sdk": "^2.2.12",
@@ -59,7 +60,7 @@
59
60
  "cross-spawn": "^7.0.3",
60
61
  "dendriform-immer-patch-optimiser": "^2.1.0",
61
62
  "dotenv": "^16.0.3",
62
- "esbuild": "0.16.9",
63
+ "esbuild": "0.16.13",
63
64
  "express": "^4.18.2",
64
65
  "fast-jwt": "^1.6.1",
65
66
  "glob": "^8.0.3",
@@ -77,8 +78,6 @@
77
78
  "remeda": "^1.3.0",
78
79
  "undici": "^5.12.0",
79
80
  "uuid": "^9.0.0",
80
- "vite": "^3.2.4",
81
- "vite-node": "^0.25.2",
82
81
  "ws": "^8.11.0",
83
82
  "yaml": "1.10.2",
84
83
  "yargs": "^17.6.2",
@@ -100,7 +99,6 @@
100
99
  "@types/uuid": "^8.3.4",
101
100
  "@types/ws": "^8.5.3",
102
101
  "@types/yargs": "^17.0.13",
103
- "archiver": "^5.3.1",
104
102
  "graphql": "^16.5.0",
105
103
  "tsx": "^3.12.1",
106
104
  "vitest": "^0.15.1"
@@ -93,9 +93,7 @@ export const useNodeHandler = Context.memo(() => {
93
93
  entryPoints: [file],
94
94
  platform: "node",
95
95
  external: [
96
- ...(nodejs.format === "esm" || input.props.runtime === "nodejs18.x"
97
- ? []
98
- : ["aws-sdk"]),
96
+ ...(isESM || input.props.runtime === "nodejs18.x" ? [] : ["aws-sdk"]),
99
97
  ...(nodejs.install || []),
100
98
  ...(external || []),
101
99
  ],
@@ -101,17 +101,20 @@ export const useFunctionBuilder = Context.memo(() => {
101
101
  };
102
102
  const watcher = useWatcher();
103
103
  watcher.subscribe("file.changed", async (evt) => {
104
- const functions = useFunctions();
105
- for (const [functionID, props] of Object.entries(functions.all)) {
106
- const handler = handlers.for(props.runtime);
107
- if (!handler?.shouldBuild({
108
- functionID,
109
- file: evt.properties.file,
110
- }))
111
- continue;
112
- await result.build(functionID);
113
- Logger.debug("Rebuilt function", functionID);
104
+ try {
105
+ const functions = useFunctions();
106
+ for (const [functionID, props] of Object.entries(functions.all)) {
107
+ const handler = handlers.for(props.runtime);
108
+ if (!handler?.shouldBuild({
109
+ functionID,
110
+ file: evt.properties.file,
111
+ }))
112
+ continue;
113
+ await result.build(functionID);
114
+ Logger.debug("Rebuilt function", functionID);
115
+ }
114
116
  }
117
+ catch { }
115
118
  });
116
119
  return result;
117
120
  });
package/sst.mjs CHANGED
@@ -1131,7 +1131,7 @@ async function build() {
1131
1131
  format: "esm",
1132
1132
  external: [
1133
1133
  "aws-cdk-lib",
1134
- "@serverless-stack/*",
1134
+ "sst",
1135
1135
  ...Object.keys({
1136
1136
  ...pkg.devDependencies,
1137
1137
  ...pkg.dependencies,
@@ -1324,9 +1324,6 @@ import {
1324
1324
  waitForStackDeploy,
1325
1325
  waitForStackDelete
1326
1326
  } from "aws-cdk/lib/api/util/cloudformation.js";
1327
- import {
1328
- StackActivityMonitor
1329
- } from "aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.js";
1330
1327
  import { blue as blue2 } from "colorette";
1331
1328
  async function deployStack(options) {
1332
1329
  const stackArtifact = options.stack;
@@ -1507,9 +1504,6 @@ async function destroyStack(options) {
1507
1504
  if (!currentStack.exists) {
1508
1505
  return;
1509
1506
  }
1510
- const monitor2 = options.quiet ? void 0 : StackActivityMonitor.withDefaultPrinter(cfn, deployName, options.stack, {
1511
- ci: options.ci
1512
- }).start();
1513
1507
  try {
1514
1508
  await cfn.deleteStack({ StackName: deployName, RoleARN: options.roleArn }).promise();
1515
1509
  const destroyedStack = await waitForStackDelete(cfn, deployName);
@@ -1519,11 +1513,8 @@ async function destroyStack(options) {
1519
1513
  );
1520
1514
  }
1521
1515
  } catch (e) {
1522
- throw new Error(suffixWithErrors(e.message, monitor2?.errors));
1516
+ throw new Error(suffixWithErrors(e.message));
1523
1517
  } finally {
1524
- if (monitor2) {
1525
- await monitor2.stop();
1526
- }
1527
1518
  }
1528
1519
  }
1529
1520
  async function canSkipDeploy(deployStackOptions, cloudFormationStack, parameterChanges) {
@@ -1780,17 +1771,6 @@ var init_deploy_stack = __esm({
1780
1771
  }
1781
1772
  }
1782
1773
  async monitorDeployment(startTime, expectedChanges) {
1783
- const monitor2 = this.options.quiet ? void 0 : StackActivityMonitor.withDefaultPrinter(
1784
- this.cfn,
1785
- this.stackName,
1786
- this.stackArtifact,
1787
- {
1788
- resourcesTotal: expectedChanges,
1789
- progress: this.options.progress,
1790
- changeSetCreationTime: startTime,
1791
- ci: this.options.ci
1792
- }
1793
- ).start();
1794
1774
  let finalState = this.cloudFormationStack;
1795
1775
  try {
1796
1776
  const successStack = await waitForStackDeploy(this.cfn, this.stackName);
@@ -1801,9 +1781,8 @@ var init_deploy_stack = __esm({
1801
1781
  }
1802
1782
  finalState = successStack;
1803
1783
  } catch (e) {
1804
- throw new Error(suffixWithErrors(e.message, monitor2?.errors));
1784
+ throw new Error(suffixWithErrors(e.message));
1805
1785
  } finally {
1806
- await monitor2?.stop();
1807
1786
  }
1808
1787
  debug("Stack %s has completed updating", this.stackName);
1809
1788
  return {
@@ -2692,16 +2671,19 @@ var init_handlers = __esm({
2692
2671
  };
2693
2672
  const watcher = useWatcher();
2694
2673
  watcher.subscribe("file.changed", async (evt) => {
2695
- const functions = useFunctions();
2696
- for (const [functionID, props] of Object.entries(functions.all)) {
2697
- const handler = handlers.for(props.runtime);
2698
- if (!handler?.shouldBuild({
2699
- functionID,
2700
- file: evt.properties.file
2701
- }))
2702
- continue;
2703
- await result.build(functionID);
2704
- Logger.debug("Rebuilt function", functionID);
2674
+ try {
2675
+ const functions = useFunctions();
2676
+ for (const [functionID, props] of Object.entries(functions.all)) {
2677
+ const handler = handlers.for(props.runtime);
2678
+ if (!handler?.shouldBuild({
2679
+ functionID,
2680
+ file: evt.properties.file
2681
+ }))
2682
+ continue;
2683
+ await result.build(functionID);
2684
+ Logger.debug("Rebuilt function", functionID);
2685
+ }
2686
+ } catch {
2705
2687
  }
2706
2688
  });
2707
2689
  return result;
@@ -3299,7 +3281,7 @@ var init_node = __esm({
3299
3281
  entryPoints: [file],
3300
3282
  platform: "node",
3301
3283
  external: [
3302
- ...nodejs.format === "esm" || input.props.runtime === "nodejs18.x" ? [] : ["aws-sdk"],
3284
+ ...isESM || input.props.runtime === "nodejs18.x" ? [] : ["aws-sdk"],
3303
3285
  ...nodejs.install || [],
3304
3286
  ...external || []
3305
3287
  ],
@@ -20903,7 +20885,7 @@ var update = (program2) => program2.command(
20903
20885
  const project = useProject2();
20904
20886
  const files = await find2(project.paths.root);
20905
20887
  const metadata2 = await fetch(
20906
- `https://registry.npmjs.org/sst/${args.ver || "rc"}`
20888
+ `https://registry.npmjs.org/sst/${args.ver || "latest"}`
20907
20889
  ).then((resp) => resp.json());
20908
20890
  const results = /* @__PURE__ */ new Map();
20909
20891
  const tasks = files.map(async (file) => {
@@ -20915,7 +20897,13 @@ var update = (program2) => program2.command(
20915
20897
  for (const [pkg, existing] of Object.entries(deps)) {
20916
20898
  if (!PACKAGE_MATCH.some((x) => pkg.startsWith(x)))
20917
20899
  continue;
20918
- const desired = pkg === "sst" ? metadata2.version : metadata2.dependencies["aws-cdk-lib"];
20900
+ const desired = (() => {
20901
+ if (pkg === "sst")
20902
+ return metadata2.version;
20903
+ if (pkg.endsWith("alpha"))
20904
+ return metadata2.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
20905
+ return metadata2.dependencies["aws-cdk-lib"];
20906
+ })();
20919
20907
  if (existing === desired)
20920
20908
  continue;
20921
20909
  let arr = results.get(file);
@@ -21680,6 +21668,8 @@ var deploy2 = (program2) => program2.command(
21680
21668
  component.unmount();
21681
21669
  process.stdout.write("\x1B[?1049l");
21682
21670
  printDeploymentResults(results);
21671
+ if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
21672
+ process.exit(1);
21683
21673
  process.exit(0);
21684
21674
  }
21685
21675
  );
package/stacks/build.js CHANGED
@@ -23,7 +23,7 @@ export async function build() {
23
23
  format: "esm",
24
24
  external: [
25
25
  "aws-cdk-lib",
26
- "@serverless-stack/*",
26
+ "sst",
27
27
  ...Object.keys({
28
28
  ...pkg.devDependencies,
29
29
  ...pkg.dependencies,
@@ -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
+ */