@trayai/tray-sync-cli 0.0.8 → 0.0.9

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.
@@ -7,7 +7,7 @@ import { sha256 } from "../lib/checksum.js";
7
7
  import { isUuid } from "../lib/uuid.js";
8
8
  import { resolveContainedSafe } from "../lib/pathContainment.js";
9
9
  import { OutputFormats, parseFormat } from "../lib/outputFormat.js";
10
- import { printStatusReports } from "../views/status/status.js";
10
+ import { printStatusReports } from "../views/status/status.v2.js";
11
11
  import { printStatusReportsJson } from "../views/status/shared.js";
12
12
  export const DriftStatuses = {
13
13
  CLEAN: "CLEAN",
@@ -0,0 +1,58 @@
1
+ import ansis from "ansis";
2
+ import Table from "cli-table3";
3
+ import { FAILURE_ICON, INFO_ICON, SUCCESS_ICON, WARNING_ICON } from "../icons.js";
4
+ export const StatusLabels = {
5
+ CLEAN: "CLEAN",
6
+ DRIFTED: "DRIFTED",
7
+ NEVER_PULLED: "NEVER PULLED",
8
+ NOT_PULLED_LOCALLY: "NOT PULLED LOCALLY",
9
+ };
10
+ function projectName(dirName, projectId) {
11
+ return dirName.slice(projectId.length + 2);
12
+ }
13
+ export function printStatusReports(stdout, cleanStatus, sortedReports) {
14
+ const table = new Table({
15
+ head: ["ID", "Name", "Status"].map((h) => ansis.bold(h)),
16
+ style: { head: [] },
17
+ });
18
+ const detailBlocks = [];
19
+ for (const { dirName, projectId, result } of sortedReports) {
20
+ if (!dirName) {
21
+ table.push([ansis.bold(projectId), "", `${INFO_ICON} ${StatusLabels.NOT_PULLED_LOCALLY}`]);
22
+ detailBlocks.push({
23
+ label: projectId,
24
+ lines: [`not pulled locally — run \`${ansis.bold("tray pull")}\` to fetch it`],
25
+ });
26
+ continue;
27
+ }
28
+ if (result.never_pulled) {
29
+ table.push([
30
+ ansis.bold(projectId),
31
+ projectName(dirName, projectId),
32
+ `${WARNING_ICON} ${StatusLabels.NEVER_PULLED}`,
33
+ ]);
34
+ detailBlocks.push({ label: projectName(dirName, projectId), lines: ["no state.json"] });
35
+ continue;
36
+ }
37
+ if (result.drift.every((d) => d.status === cleanStatus)) {
38
+ table.push([ansis.bold(projectId), projectName(dirName, projectId), `${SUCCESS_ICON} ${StatusLabels.CLEAN}`]);
39
+ continue;
40
+ }
41
+ table.push([ansis.bold(projectId), projectName(dirName, projectId), `${FAILURE_ICON} ${StatusLabels.DRIFTED}`]);
42
+ detailBlocks.push({
43
+ label: projectName(dirName, projectId),
44
+ lines: result.drift
45
+ .filter((d) => d.status !== cleanStatus)
46
+ .map((d) => `${d.status}\t${d.path}`),
47
+ });
48
+ }
49
+ stdout(table.toString());
50
+ for (const block of detailBlocks) {
51
+ stdout("");
52
+ stdout(`${ansis.bold(block.label)}:`);
53
+ for (const line of block.lines) {
54
+ stdout(` ${line}`);
55
+ }
56
+ }
57
+ }
58
+ //# sourceMappingURL=status.v2.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayai/tray-sync-cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
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"
@@ -25,7 +25,8 @@
25
25
  "test": "node --test dist-test/test/**/*.test.js",
26
26
  "typecheck": "tsc -p tsconfig.json --noEmit",
27
27
  "build-and-reinstall": "npm uninstall -g @trayai/tray-sync-cli --silent || true; npm run build && npm pack --silent | xargs -I{} sh -c 'npm install -g ./{} && rm ./{}'",
28
- "gallery:env": "tsc -p tsconfig.test.json && node dist-test/test/manual/envOutputGallery.js"
28
+ "gallery:env": "tsc -p tsconfig.test.json && node dist-test/test/manual/envOutputGallery.js",
29
+ "gallery:status": "tsc -p tsconfig.test.json && node dist-test/test/manual/statusOutputGallery.js"
29
30
  },
30
31
  "license": "Apache-2.0",
31
32
  "dependencies": {