@trayai/tray-sync-cli 0.0.11 → 0.0.12

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,7 @@ import { PUBLIC_REGIONS, parseRegion } from "../lib/regionParsing.js";
10
10
  import { resolveToken } from "../lib/tokenResolution.js";
11
11
  import { isUuid } from "../lib/uuid.js";
12
12
  import { runPull } from "./pull.js";
13
- import { printConnectivityCheckFailed, printConnectivityCheckSucceeded, printNoTokenSkippingConnectivityAndPull, printTokenNotSaved, printTrayYamlAlreadyExists, } from "../views/init/init.js";
13
+ import { printConnectivityCheckFailed, printConnectivityCheckSucceeded, printNoTokenSkippingConnectivityAndPull, printTokenNotSaved, printTrayYamlAlreadyExists, } from "../views/init/init.v2.js";
14
14
  const SCOPES = Object.values(Scopes);
15
15
  function parseScope(value) {
16
16
  if (!SCOPES.includes(value)) {
@@ -12,13 +12,13 @@ import { readTrayYaml } from "../config/trayYaml.js";
12
12
  import { resolveContainedSafe } from "../lib/pathContainment.js";
13
13
  import { entityDisplayName } from "../lib/exportStructure.js";
14
14
  import { importProject, previewImport } from "../lib/promoteExecute.js";
15
- import { printProjectImportImpact, toProjectImportImpact, } from "../lib/promoteReport.js";
15
+ import { toProjectImportImpact } from "../lib/promoteReport.js";
16
16
  import { isFullyResolved, resolveProjectRequirements, scaffoldUnresolvedAuthentications, } from "../lib/promoteTarget.js";
17
17
  import { resolveToken } from "../lib/tokenResolution.js";
18
18
  import { isUuid } from "../lib/uuid.js";
19
19
  import { OutputFormats, parseFormat } from "../lib/outputFormat.js";
20
20
  import { checkProjectDrift, DriftStatuses } from "./status.js";
21
- import { printError, printInvalidAuthMappings, printLocalDrift, printMutuallyExclusiveResumeAndProject, printNoTargetProjectMapped, printProjectError, printProjectNoStateFile, printProjectNotPulledLocally, printPromoted, printTargetEnvNotFound, printTrayYamlNotFound, printUnresolvedRequirements, } from "../views/promote/promote.v2.js";
21
+ import { printError, printInvalidAuthMappings, printLocalDrift, printMutuallyExclusiveResumeAndProject, printNoTargetProjectMapped, printProjectError, printProjectImportImpact, printProjectNoStateFile, printProjectNotPulledLocally, printPromoted, printTargetEnvNotFound, printTrayYamlNotFound, printUnresolvedRequirements, printWouldBePromoted, } from "../views/promote/promote.v2.js";
22
22
  import { printPromoteResultJson } from "../views/promote/shared.js";
23
23
  function findProjectDir(existingDirs, projectId) {
24
24
  return existingDirs.find((name) => name.split("--")[0] === projectId);
@@ -200,15 +200,17 @@ export async function runPromote(deps, options) {
200
200
  if (asJson) {
201
201
  promoted.push(impact);
202
202
  }
203
- else {
204
- printProjectImportImpact(stdout, impact);
205
- }
206
203
  if (options.dryRun) {
204
+ if (!asJson) {
205
+ printWouldBePromoted(stdout, projectId, sourceProjectName, options.to);
206
+ printProjectImportImpact(stdout, impact);
207
+ }
207
208
  continue;
208
209
  }
209
210
  await importProject(targetClient, targetProjectId, payload);
210
211
  if (!asJson) {
211
212
  printPromoted(stdout, projectId, sourceProjectName, options.to);
213
+ printProjectImportImpact(stdout, impact);
212
214
  }
213
215
  }
214
216
  catch (err) {
@@ -20,25 +20,4 @@ export function toProjectImportImpact(projectName, projectId, impact) {
20
20
  ],
21
21
  };
22
22
  }
23
- export function printProjectImportImpact(stdout, impact) {
24
- stdout(`${impact.projectName} (${impact.projectId})`);
25
- if (impact.workflows.length === 0) {
26
- stdout(" workflows: no changes");
27
- }
28
- else {
29
- stdout(" workflows:");
30
- for (const w of impact.workflows) {
31
- stdout(` ${w.kind}: ${w.name}${w.id ? ` (${w.id})` : ""}`);
32
- }
33
- }
34
- if (impact.config.length === 0) {
35
- stdout(" config: no changes");
36
- }
37
- else {
38
- stdout(" config:");
39
- for (const c of impact.config) {
40
- stdout(` ${c.kind}: ${c.name}`);
41
- }
42
- }
43
- }
44
23
  //# sourceMappingURL=promoteReport.js.map
@@ -0,0 +1,20 @@
1
+ import ansis from "ansis";
2
+ import { FAILURE_ICON, INFO_ICON, SUCCESS_ICON, WARNING_ICON } from "../icons.js";
3
+ export function printTrayYamlAlreadyExists(stderr) {
4
+ stderr(`${FAILURE_ICON} ${ansis.bold("tray.yaml")} already exists in this directory. Refusing to overwrite.`);
5
+ }
6
+ export function printTokenNotSaved(stderr, workspaceId, region) {
7
+ stderr(`${WARNING_ICON} ${ansis.bold("--token")} was NOT saved\n` +
8
+ ` ${ansis.bold("credentials.json")} already has a token for workspace ${ansis.bold(workspaceId)}, and the existing one was kept.\n` +
9
+ ` tray.yaml has already been written, so \`${ansis.bold("tray init")}\` can't be re-run here — use \`${ansis.bold(`tray env add <name> --region ${region} --workspace-id ${workspaceId} --token <token> --force-token`)}\` to replace it, or edit ~/.tray/credentials.json directly.`);
10
+ }
11
+ export function printNoTokenSkippingConnectivityAndPull(stdout) {
12
+ stdout(`${INFO_ICON} ${ansis.bold("No")} token provided — skipping connectivity check and pull.`);
13
+ }
14
+ export function printConnectivityCheckSucceeded(stdout) {
15
+ stdout(`${SUCCESS_ICON} Connectivity check: connected`);
16
+ }
17
+ export function printConnectivityCheckFailed(stdout, message) {
18
+ stdout(`${FAILURE_ICON} Connectivity check: ${message}`);
19
+ }
20
+ //# sourceMappingURL=init.v2.js.map
@@ -1,46 +1,70 @@
1
1
  import ansis from "ansis";
2
- import { FAILURE_ICON } from "../icons.js";
2
+ import { FAILURE_ICON, INFO_ICON, SUCCESS_ICON } from "../icons.js";
3
3
  import { printIssueBlock } from "../shared.js";
4
4
  export function printMutuallyExclusiveResumeAndProject(stderr) {
5
- stderr("--resume and --project are mutually exclusive.");
5
+ stderr(`${FAILURE_ICON} ${ansis.bold("--resume")} and ${ansis.bold("--project")} are mutually exclusive.`);
6
6
  }
7
7
  export function printTrayYamlNotFound(stderr) {
8
- stderr("tray.yaml not found. Run `tray init` first.");
8
+ stderr(`${FAILURE_ICON} tray.yaml not found. Run \`${ansis.bold("tray init")}\` first.`);
9
9
  }
10
10
  export function printTargetEnvNotFound(stderr, envName) {
11
11
  stderr(`${FAILURE_ICON} Target environment "${ansis.bold(envName)}" not found. Run \`${ansis.bold(`tray env add ${envName} ...`)}\` first.`);
12
12
  }
13
13
  export function printError(stderr, message) {
14
- stderr(message);
14
+ stderr(`${FAILURE_ICON} ${message}`);
15
15
  }
16
16
  export function printProjectNotPulledLocally(stderr, projectId) {
17
- stderr(`Project ${projectId} has not been pulled locally. Run \`tray pull\` first.`);
17
+ stderr(`${FAILURE_ICON} Project ${ansis.bold(projectId)} has not been pulled locally. Run \`${ansis.bold("tray pull")}\` first.`);
18
18
  }
19
19
  export function printProjectNoStateFile(stderr, projectId) {
20
- stderr(`Project ${projectId} has no state.json. Run \`tray pull\` first.`);
20
+ stderr(`${FAILURE_ICON} Project ${ansis.bold(projectId)} has no state.json. Run \`${ansis.bold("tray pull")}\` first.`);
21
21
  }
22
22
  export function printLocalDrift(stderr, projectId, dirName, dirty) {
23
- printIssueBlock(stderr, `Project ${projectId} (${dirName}) has local drift; refusing to promote:`, dirty.map((d) => `${d.status}\t${d.path}`), "Run `tray pull` to refresh, or resolve the drift, then retry.");
23
+ printIssueBlock(stderr, `Project ${ansis.bold(`${projectId} (${dirName})`)} has local drift; refusing to promote:`, dirty.map((d) => `${d.status}\t${d.path}`), `Run \`${ansis.bold("tray pull")}\` to refresh, or resolve the drift, then retry.`);
24
24
  }
25
25
  export function printNoTargetProjectMapped(stderr, sourceProjectName, projectId, envName, mappingsPath) {
26
- stderr(`"${sourceProjectName}" (${projectId}) has no target project mapped for "${envName}".`);
27
- stderr(`Fill in target_project_id in ${mappingsPath}, or re-run with --auto-create-projects.`);
26
+ stderr(`${FAILURE_ICON} ${ansis.bold(`"${sourceProjectName}" (${projectId})`)} has no target project mapped for "${ansis.bold(envName)}".`);
27
+ stderr(`Fill in target_project_id in ${mappingsPath}, or re-run with ${ansis.bold("--auto-create-projects")}.`);
28
28
  }
29
29
  export function printInvalidAuthMappings(stderr, projectId, sourceProjectName, invalidAuthMappings) {
30
- printIssueBlock(stderr, `Project ${projectId} (${sourceProjectName}) has unresolved authentication mappings:`, invalidAuthMappings.map((invalid) => `${invalid.authExportId}: "${invalid.value}" is not a valid target authentication id`), "Fill in a real target authentication id for each entry above, then retry.");
30
+ printIssueBlock(stderr, `Project ${ansis.bold(`${projectId} (${sourceProjectName})`)} has unresolved authentication mappings:`, invalidAuthMappings.map((invalid) => `${ansis.bold(invalid.authExportId)}: "${invalid.value}" is not a valid target authentication id`), "Fill in a real target authentication id for each entry above, then retry.");
31
31
  }
32
32
  export function printUnresolvedRequirements(stderr, projectId, sourceProjectName, envName, unresolved) {
33
33
  const bulletLines = unresolved.unresolvedAuthentications.map((auth) => `unresolved authentication: ${auth.title} (${auth.authExportId})`);
34
34
  if (unresolved.hasNewConfigKeys) {
35
35
  bulletLines.push("new config keys require mapping");
36
36
  }
37
- printIssueBlock(stderr, `Project ${projectId} (${sourceProjectName}) has unresolved import requirements:`, bulletLines, `Run \`tray env resolve ${envName}\` to resolve, then retry.`);
37
+ printIssueBlock(stderr, `Project ${ansis.bold(`${projectId} (${sourceProjectName})`)} has unresolved import requirements:`, bulletLines, `Run \`${ansis.bold(`tray env resolve ${envName}`)}\` to resolve, then retry.`);
38
38
  }
39
39
  export function printPromoted(stdout, projectId, sourceProjectName, envName) {
40
- stdout(`Promoted project ${projectId} (${sourceProjectName}) to "${envName}"`);
40
+ stdout(`${SUCCESS_ICON} ${sourceProjectName} (${projectId}) ${ansis.bold("promoted")} to "${ansis.bold(envName)}"`);
41
+ }
42
+ export function printWouldBePromoted(stdout, projectId, sourceProjectName, envName) {
43
+ stdout(`${INFO_ICON} ${sourceProjectName} (${projectId}) would be promoted to "${ansis.bold(envName)}"`);
41
44
  }
42
45
  export function printProjectError(stderr, projectId, sourceProjectName, message, targetProjectId) {
43
46
  const target = targetProjectId ? ` -> target project ${targetProjectId}` : "";
44
- stderr(`Project ${projectId} (${sourceProjectName})${target}: ${message}`);
47
+ stderr(`${FAILURE_ICON} Project ${ansis.bold(`${projectId} (${sourceProjectName})`)}${target}: ${message}`);
48
+ }
49
+ export function printProjectImportImpact(stdout, impact) {
50
+ if (impact.workflows.length === 0) {
51
+ stdout(" workflows: no changes");
52
+ }
53
+ else {
54
+ stdout(" workflows:");
55
+ for (const w of impact.workflows) {
56
+ stdout(` ${ansis.bold(w.kind)}: ${w.name}${w.id ? ` (${w.id})` : ""}`);
57
+ }
58
+ }
59
+ if (impact.config.length === 0) {
60
+ stdout(" config: no changes");
61
+ }
62
+ else {
63
+ stdout(" config:");
64
+ for (const c of impact.config) {
65
+ stdout(` ${ansis.bold(c.kind)}: ${c.name}`);
66
+ }
67
+ }
68
+ stdout("");
45
69
  }
46
70
  //# sourceMappingURL=promote.v2.js.map
@@ -1,5 +1,6 @@
1
+ import { FAILURE_ICON } from "./icons.js";
1
2
  export function printIssueBlock(stderr, header, bulletLines, fixHint) {
2
- stderr(header);
3
+ stderr(`${FAILURE_ICON} ${header}`);
3
4
  for (const line of bulletLines) {
4
5
  stderr(`\t${line}`);
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayai/tray-sync-cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "CLI tool to clone Tray projects and related assets to a local directory, and promote them between Tray environments",
5
5
  "bin": {
6
6
  "tray": "dist/cli.js"
@@ -28,7 +28,9 @@
28
28
  "gallery:env": "tsc -p tsconfig.test.json && node dist-test/test/manual/envOutputGallery.js",
29
29
  "gallery:status": "tsc -p tsconfig.test.json && node dist-test/test/manual/statusOutputGallery.js",
30
30
  "gallery:pull": "tsc -p tsconfig.test.json && node dist-test/test/manual/pullOutputGallery.js",
31
- "gallery:project": "tsc -p tsconfig.test.json && node dist-test/test/manual/projectOutputGallery.js"
31
+ "gallery:project": "tsc -p tsconfig.test.json && node dist-test/test/manual/projectOutputGallery.js",
32
+ "gallery:init": "tsc -p tsconfig.test.json && node dist-test/test/manual/initOutputGallery.js",
33
+ "gallery:promote": "tsc -p tsconfig.test.json && node dist-test/test/manual/promoteOutputGallery.js"
32
34
  },
33
35
  "license": "Apache-2.0",
34
36
  "dependencies": {