sst 2.0.0-rc.23 → 2.0.0-rc.25

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.
@@ -0,0 +1,11 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const diff: (program: Program) => import("yargs").Argv<{
4
+ stage: string | undefined;
5
+ } & {
6
+ profile: string | undefined;
7
+ } & {
8
+ region: string | undefined;
9
+ } & {
10
+ mode: string;
11
+ }>;
@@ -0,0 +1,27 @@
1
+ import { useProject } from "../../project.js";
2
+ import { Stacks } from "../../stacks/index.js";
3
+ import { printStackDiff } from "aws-cdk/lib/diff.js";
4
+ import { useAWSClient } from "../../credentials.js";
5
+ import { CloudFormationClient, GetTemplateCommand, } from "@aws-sdk/client-cloudformation";
6
+ import { createSpinner } from "../spinner.js";
7
+ export const diff = (program) => program.command("diff", "", (yargs) => yargs.option("mode", {
8
+ type: "string",
9
+ describe: "deploy or dev",
10
+ default: "deploy",
11
+ }), async (args) => {
12
+ const spinner = createSpinner("Building stacks");
13
+ const project = useProject();
14
+ const assembly = await Stacks.synth({
15
+ fn: project.stacks,
16
+ mode: args.mode,
17
+ });
18
+ spinner.succeed();
19
+ const cfn = useAWSClient(CloudFormationClient);
20
+ for (const stack of assembly.stacks) {
21
+ const response = await cfn.send(new GetTemplateCommand({
22
+ StackName: stack.stackName,
23
+ }));
24
+ printStackDiff(JSON.parse(response.TemplateBody), stack, true, 3);
25
+ }
26
+ process.exit(0);
27
+ });
package/cli/sst.js CHANGED
@@ -14,6 +14,7 @@ import dotenv from "dotenv";
14
14
  import { env } from "./commands/env.js";
15
15
  import { Logger } from "../logger.js";
16
16
  import { consoleCommand } from "./commands/console.js";
17
+ import { diff } from "./commands/diff.js";
17
18
  dotenv.config();
18
19
  secrets(program);
19
20
  update(program);
@@ -24,6 +25,7 @@ deploy(program);
24
25
  remove(program);
25
26
  env(program);
26
27
  consoleCommand(program);
28
+ diff(program);
27
29
  process.removeAllListeners("uncaughtException");
28
30
  process.on("uncaughtException", (err) => {
29
31
  Logger.debug(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.23",
3
+ "version": "2.0.0-rc.25",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/site-env.js CHANGED
@@ -37,7 +37,7 @@ export async function writeValues(input) {
37
37
  await fs.promises.writeFile(file, JSON.stringify(input));
38
38
  }
39
39
  export function append(input) {
40
- input.path = path.join(useProject().paths.root, input.path);
40
+ input.path = path.resolve(useProject().paths.root, input.path);
41
41
  fs.appendFileSync(keysFile(), JSON.stringify(input) + "\n");
42
42
  }
43
43
  export function reset() {
package/sst.mjs CHANGED
@@ -129,11 +129,11 @@ var init_logger = __esm({
129
129
  Logger = {
130
130
  debug(...parts) {
131
131
  const now = new Date();
132
- const diff = now.getTime() - previous.getTime();
132
+ const diff2 = now.getTime() - previous.getTime();
133
133
  previous = now;
134
134
  const line = [
135
135
  new Date().toISOString(),
136
- `+${diff}ms`.padStart(8),
136
+ `+${diff2}ms`.padStart(8),
137
137
  "[debug]",
138
138
  ...parts.map((x) => {
139
139
  if (typeof x === "string")
@@ -5212,7 +5212,7 @@ async function writeValues(input) {
5212
5212
  await fs13.promises.writeFile(file, JSON.stringify(input));
5213
5213
  }
5214
5214
  function append(input) {
5215
- input.path = path14.join(useProject().paths.root, input.path);
5215
+ input.path = path14.resolve(useProject().paths.root, input.path);
5216
5216
  fs13.appendFileSync(keysFile(), JSON.stringify(input) + "\n");
5217
5217
  }
5218
5218
  function reset2() {
@@ -6013,6 +6013,50 @@ var consoleCommand = async (program2) => program2.command(
6013
6013
  }
6014
6014
  );
6015
6015
 
6016
+ // src/cli/commands/diff.ts
6017
+ init_project();
6018
+ init_stacks();
6019
+ init_credentials();
6020
+ init_spinner();
6021
+ import { printStackDiff } from "aws-cdk/lib/diff.js";
6022
+ import {
6023
+ CloudFormationClient as CloudFormationClient3,
6024
+ GetTemplateCommand
6025
+ } from "@aws-sdk/client-cloudformation";
6026
+ var diff = (program2) => program2.command(
6027
+ "diff",
6028
+ "",
6029
+ (yargs2) => yargs2.option("mode", {
6030
+ type: "string",
6031
+ describe: "deploy or dev",
6032
+ default: "deploy"
6033
+ }),
6034
+ async (args) => {
6035
+ const spinner = createSpinner("Building stacks");
6036
+ const project = useProject();
6037
+ const assembly = await stacks_exports.synth({
6038
+ fn: project.stacks,
6039
+ mode: args.mode
6040
+ });
6041
+ spinner.succeed();
6042
+ const cfn = useAWSClient(CloudFormationClient3);
6043
+ for (const stack of assembly.stacks) {
6044
+ const response = await cfn.send(
6045
+ new GetTemplateCommand({
6046
+ StackName: stack.stackName
6047
+ })
6048
+ );
6049
+ printStackDiff(
6050
+ JSON.parse(response.TemplateBody),
6051
+ stack,
6052
+ true,
6053
+ 3
6054
+ );
6055
+ }
6056
+ process.exit(0);
6057
+ }
6058
+ );
6059
+
6016
6060
  // src/cli/sst.ts
6017
6061
  dotenv2.config();
6018
6062
  secrets(program);
@@ -6024,6 +6068,7 @@ deploy2(program);
6024
6068
  remove3(program);
6025
6069
  env(program);
6026
6070
  consoleCommand(program);
6071
+ diff(program);
6027
6072
  process.removeAllListeners("uncaughtException");
6028
6073
  process.on("uncaughtException", (err) => {
6029
6074
  Logger.debug(err);