sst 2.7.1 → 2.7.2

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/sst.mjs CHANGED
@@ -576,15 +576,33 @@ var init_project_id = __esm({
576
576
  }
577
577
  });
578
578
 
579
+ // src/cli/ci-info.ts
580
+ var ci_info_exports = {};
581
+ __export(ci_info_exports, {
582
+ getCiInfo: () => getCiInfo
583
+ });
584
+ import ciInfo from "ci-info";
585
+ function getCiInfo() {
586
+ const isSeed = !!process.env.SEED_APP_NAME;
587
+ return {
588
+ isCI: ciInfo.isCI || isSeed,
589
+ name: (isSeed ? "Seed" : ciInfo.name) || null
590
+ };
591
+ }
592
+ var init_ci_info = __esm({
593
+ "src/cli/ci-info.ts"() {
594
+ "use strict";
595
+ }
596
+ });
597
+
579
598
  // src/cli/telemetry/environment.ts
580
599
  import os2 from "os";
581
- import ciInfo from "ci-info";
582
600
  function getEnvironmentData() {
583
601
  if (data) {
584
602
  return data;
585
603
  }
586
604
  const cpus = os2.cpus() || [];
587
- const isSeed = !!process.env.SEED_APP_NAME;
605
+ const ciInfo2 = getCiInfo();
588
606
  data = {
589
607
  systemPlatform: os2.platform(),
590
608
  systemRelease: os2.release(),
@@ -593,8 +611,8 @@ function getEnvironmentData() {
593
611
  cpuModel: cpus.length ? cpus[0].model : null,
594
612
  cpuSpeed: cpus.length ? cpus[0].speed : null,
595
613
  memoryInMb: Math.trunc(os2.totalmem() / Math.pow(1024, 2)),
596
- isCI: ciInfo.isCI || isSeed,
597
- ciName: (isSeed ? "Seed" : ciInfo.name) || null,
614
+ isCI: ciInfo2.isCI,
615
+ ciName: ciInfo2.name,
598
616
  sstVersion: useProject().version
599
617
  };
600
618
  return data;
@@ -603,6 +621,7 @@ var data;
603
621
  var init_environment = __esm({
604
622
  "src/cli/telemetry/environment.ts"() {
605
623
  "use strict";
624
+ init_ci_info();
606
625
  init_project();
607
626
  }
608
627
  });
@@ -3569,6 +3588,11 @@ var init_handlers = __esm({
3569
3588
  async build(functionID, mode) {
3570
3589
  async function task() {
3571
3590
  const func = useFunctions().fromID(functionID);
3591
+ if (!func)
3592
+ return {
3593
+ type: "error",
3594
+ errors: [`Function with ID "${functionID}" not found`]
3595
+ };
3572
3596
  const handler = result.for(func.runtime);
3573
3597
  const out = path7.join(project.paths.artifacts, functionID);
3574
3598
  await fs7.rm(out, { recursive: true, force: true });
@@ -3647,6 +3671,8 @@ var init_handlers = __esm({
3647
3671
  },
3648
3672
  build: async (functionID) => {
3649
3673
  const result2 = await handlers.build(functionID, "start");
3674
+ if (!result2)
3675
+ return;
3650
3676
  if (result2.type === "error")
3651
3677
  return;
3652
3678
  artifacts.set(functionID, result2);
@@ -3896,6 +3922,8 @@ var init_workers = __esm({
3896
3922
  for (const [_, worker] of workers) {
3897
3923
  if (worker.functionID === evt.properties.functionID) {
3898
3924
  const props = useFunctions2().fromID(worker.functionID);
3925
+ if (!props)
3926
+ return;
3899
3927
  const handler = handlers.for(props.runtime);
3900
3928
  await handler?.stopWorker(worker.workerID);
3901
3929
  bus.publish("worker.stopped", worker);
@@ -3913,6 +3941,8 @@ var init_workers = __esm({
3913
3941
  if (worker)
3914
3942
  return;
3915
3943
  const props = useFunctions2().fromID(evt.properties.functionID);
3944
+ if (!props)
3945
+ return;
3916
3946
  const handler = handlers.for(props.runtime);
3917
3947
  if (!handler)
3918
3948
  return;
@@ -6841,6 +6871,7 @@ var dev = (program2) => program2.command(
6841
6871
  const { useMetadata: useMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
6842
6872
  const { useIOT: useIOT2 } = await Promise.resolve().then(() => (init_iot(), iot_exports));
6843
6873
  const { clear: clear2 } = await Promise.resolve().then(() => (init_terminal(), terminal_exports));
6874
+ const { getCiInfo: getCiInfo2 } = await Promise.resolve().then(() => (init_ci_info(), ci_info_exports));
6844
6875
  if (args._[0] === "start") {
6845
6876
  console.log(
6846
6877
  yellow(
@@ -6893,12 +6924,16 @@ var dev = (program2) => program2.command(
6893
6924
  });
6894
6925
  bus.subscribe("function.build.success", async (evt) => {
6895
6926
  const info = useFunctions3().fromID(evt.properties.functionID);
6927
+ if (!info)
6928
+ return;
6896
6929
  if (info.enableLiveDev === false)
6897
6930
  return;
6898
6931
  Colors2.line(Colors2.dim(Colors2.prefix, "Built", info.handler));
6899
6932
  });
6900
6933
  bus.subscribe("function.build.failed", async (evt) => {
6901
6934
  const info = useFunctions3().fromID(evt.properties.functionID);
6935
+ if (!info)
6936
+ return;
6902
6937
  if (info.enableLiveDev === false)
6903
6938
  return;
6904
6939
  Colors2.gap();
@@ -6938,7 +6973,6 @@ var dev = (program2) => program2.command(
6938
6973
  const useStackBuilder = Context2.memo(async () => {
6939
6974
  const watcher = useWatcher2();
6940
6975
  const project = useProject2();
6941
- const bus = useBus2();
6942
6976
  let lastDeployed;
6943
6977
  let isWorking = false;
6944
6978
  let isDirty = false;
@@ -7108,7 +7142,7 @@ Are you sure you want to run this stage in dev mode? [y/N] `,
7108
7142
  );
7109
7143
  });
7110
7144
  }
7111
- if (appMetadata && appMetadata.mode !== "dev") {
7145
+ if (!getCiInfo2().isCI && appMetadata && appMetadata.mode !== "dev") {
7112
7146
  if (!await promptChangeMode()) {
7113
7147
  process.exit(0);
7114
7148
  }
@@ -7469,6 +7503,7 @@ var deploy2 = (program2) => program2.command(
7469
7503
  const { dim: dim2, blue: blue4, bold: bold2 } = await import("colorette");
7470
7504
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
7471
7505
  const { loadAssembly: loadAssembly2, useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
7506
+ const { getCiInfo: getCiInfo2 } = await Promise.resolve().then(() => (init_ci_info(), ci_info_exports));
7472
7507
  const { render } = await import("ink");
7473
7508
  const { DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
7474
7509
  const { mapValues } = await import("remeda");
@@ -7496,7 +7531,7 @@ Are you sure you want to deploy to this stage? (y/N) `,
7496
7531
  );
7497
7532
  });
7498
7533
  }
7499
- if (appMetadata && appMetadata.mode !== "deploy") {
7534
+ if (!getCiInfo2().isCI && appMetadata && appMetadata.mode !== "deploy") {
7500
7535
  if (!await promptChangeMode()) {
7501
7536
  process.exit(0);
7502
7537
  }
@@ -8066,7 +8101,6 @@ var diff2 = (program2) => program2.command(
8066
8101
  const { useAWSClient: useAWSClient2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
8067
8102
  const { CloudFormationClient: CloudFormationClient4, GetTemplateCommand } = await import("@aws-sdk/client-cloudformation");
8068
8103
  const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
8069
- const { green } = await import("colorette");
8070
8104
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
8071
8105
  const project = useProject2();
8072
8106
  const assembly = await Stacks.synth({
@@ -8080,12 +8114,17 @@ var diff2 = (program2) => program2.command(
8080
8114
  const spinner = createSpinner2(
8081
8115
  `${stack.stackName}: Checking for changes...`
8082
8116
  );
8083
- const response = await cfn.send(
8084
- new GetTemplateCommand({
8085
- StackName: stack.stackName
8086
- })
8087
- );
8088
- const oldTemplate = JSON.parse(response.TemplateBody);
8117
+ const oldTemplate = await getTemplate(stack.stackName);
8118
+ if (!oldTemplate) {
8119
+ spinner.clear();
8120
+ Colors2.line(
8121
+ `\u279C ${Colors2.dim.bold(
8122
+ stackNameToId2(stack.stackName) + ":"
8123
+ )} New stack`
8124
+ );
8125
+ Colors2.gap();
8126
+ continue;
8127
+ }
8089
8128
  const { count, diff: diff3 } = await Stacks.diff(stack, oldTemplate);
8090
8129
  spinner.clear();
8091
8130
  if (count === 0) {
@@ -8128,6 +8167,19 @@ var diff2 = (program2) => program2.command(
8128
8167
  );
8129
8168
  }
8130
8169
  process.exit(0);
8170
+ async function getTemplate(stackName) {
8171
+ try {
8172
+ const response = await cfn.send(
8173
+ new GetTemplateCommand({ StackName: stackName })
8174
+ );
8175
+ return JSON.parse(response.TemplateBody);
8176
+ } catch (e) {
8177
+ if (e.name === "ValidationError" && e.message.includes("does not exist")) {
8178
+ return;
8179
+ }
8180
+ throw e;
8181
+ }
8182
+ }
8131
8183
  }
8132
8184
  );
8133
8185