@trayai/tray-sync-cli 0.0.10 → 0.0.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.
@@ -9,7 +9,7 @@ import { Scopes } from "../config/types.js";
9
9
  import { resolveToken } from "../lib/tokenResolution.js";
10
10
  import { isUuid } from "../lib/uuid.js";
11
11
  import { OutputFormats, parseFormat } from "../lib/outputFormat.js";
12
- import { printAddedProject, printAlreadyTracked, printLastPulled, printNoProjectsTracked, printNotPulledLocally, printNotTracked, printRemovedProject, printTrayYamlNotFound, printValidationSkippedOrFailed, printValidationSucceeded, printWorkspaceScopeDenied, } from "../views/project/project.js";
12
+ import { printAddedProject, printAlreadyTracked, printNoProjectsTracked, printNotTracked, printProjectListTable, printRemovedProject, printTrayYamlNotFound, printValidationSkippedOrFailed, printValidationSucceeded, printWorkspaceScopeDenied, } from "../views/project/project.v2.js";
13
13
  import { printProjectListJson } from "../views/project/shared.js";
14
14
  function findProjectDir(existingDirs, projectId) {
15
15
  return existingDirs.find((name) => name.split("--")[0] === projectId);
@@ -114,16 +114,17 @@ export async function runProjectList(deps, options) {
114
114
  printNoProjectsTracked(stdout);
115
115
  return 0;
116
116
  }
117
+ const rows = [];
117
118
  for (const projectId of trayYaml.projects) {
118
119
  const dirName = findProjectDir(existingDirs, projectId);
119
120
  if (!dirName) {
120
- printNotPulledLocally(stdout, projectId);
121
+ rows.push({ projectId });
121
122
  continue;
122
123
  }
123
124
  const state = await readProjectState(path.join(projectsRoot, dirName));
124
- const lastSync = state?.last_sync ?? "never";
125
- printLastPulled(stdout, dirName, lastSync);
125
+ rows.push({ projectId, dirName, lastSync: state?.last_sync ?? "never" });
126
126
  }
127
+ printProjectListTable(stdout, rows);
127
128
  return 0;
128
129
  }
129
130
  function parseUuid(value, flagName) {
@@ -0,0 +1,84 @@
1
+ import ansis from "ansis";
2
+ import Table from "cli-table3";
3
+ import { FAILURE_ICON, INFO_ICON, WARNING_ICON } from "../icons.js";
4
+ export function printTrayYamlNotFound(stderr) {
5
+ stderr(`${FAILURE_ICON} tray.yaml not found. Run \`${ansis.bold("tray init")}\` first.`);
6
+ }
7
+ export function printWorkspaceScopeDenied(stderr) {
8
+ stderr(`${INFO_ICON} Operation denied. Project add/removal is not allowed in workspace scope.`);
9
+ stderr(` Create your project with ${ansis.bold("--scope project")} (or omit --scope) in a new directory to use \`${ansis.bold("tray project add/remove")}\` commands.`);
10
+ }
11
+ export function printAlreadyTracked(stdout, projectId) {
12
+ stdout(`${ansis.bold(projectId)} is already tracked.`);
13
+ }
14
+ export function printValidationSucceeded(stdout, projectId) {
15
+ stdout(`Validation: ✓ (${ansis.bold(projectId)} found in Tray)`);
16
+ }
17
+ export function printValidationSkippedOrFailed(stdout, message) {
18
+ stdout(`Validation: skipped or failed (${message})`);
19
+ }
20
+ export function printAddedProject(stdout, projectId) {
21
+ stdout(`${ansis.bold("Added")} ${ansis.bold(projectId)} to tray.yaml.projects.`);
22
+ }
23
+ export function printNotTracked(stdout, projectId) {
24
+ stdout(`${ansis.bold(projectId)} is not tracked.`);
25
+ }
26
+ export function printRemovedProject(stdout, projectId, deletedLocalDir) {
27
+ stdout(`${ansis.bold("Removed")} ${ansis.bold(projectId)} from tray.yaml.projects${deletedLocalDir ? " and deleted its local directory" : ""}.`);
28
+ }
29
+ export function printNoProjectsTracked(stdout) {
30
+ stdout(`${INFO_ICON} No projects tracked.`);
31
+ }
32
+ export const ProjectListStatusLabels = {
33
+ PULLED: "PULLED",
34
+ NEVER_PULLED: "NEVER PULLED",
35
+ NOT_PULLED_LOCALLY: "NOT PULLED LOCALLY",
36
+ };
37
+ function projectName(dirName, projectId) {
38
+ return dirName.slice(projectId.length + 2);
39
+ }
40
+ function formatLastSync(lastSync) {
41
+ return lastSync.replace("T", " ").slice(0, 16);
42
+ }
43
+ export function printProjectListTable(stdout, rows) {
44
+ const table = new Table({
45
+ head: ["ID", "Name", "Status", "Last Pulled"].map((h) => ansis.bold(h)),
46
+ style: { head: [] },
47
+ });
48
+ const detailBlocks = [];
49
+ for (const { projectId, dirName, lastSync } of rows) {
50
+ if (!dirName) {
51
+ table.push([ansis.bold(projectId), "", `${INFO_ICON} ${ProjectListStatusLabels.NOT_PULLED_LOCALLY}`, ""]);
52
+ detailBlocks.push({
53
+ label: projectId,
54
+ lines: [`not pulled locally — run \`${ansis.bold("tray pull")}\` to fetch it`],
55
+ });
56
+ continue;
57
+ }
58
+ if (!lastSync || lastSync === "never") {
59
+ table.push([
60
+ ansis.bold(projectId),
61
+ projectName(dirName, projectId),
62
+ `${WARNING_ICON} ${ProjectListStatusLabels.NEVER_PULLED}`,
63
+ "",
64
+ ]);
65
+ detailBlocks.push({ label: projectName(dirName, projectId), lines: ["no state.json"] });
66
+ continue;
67
+ }
68
+ table.push([
69
+ ansis.bold(projectId),
70
+ projectName(dirName, projectId),
71
+ ProjectListStatusLabels.PULLED,
72
+ formatLastSync(lastSync),
73
+ ]);
74
+ }
75
+ stdout(table.toString());
76
+ for (const block of detailBlocks) {
77
+ stdout("");
78
+ stdout(`${ansis.bold(block.label)}:`);
79
+ for (const line of block.lines) {
80
+ stdout(` ${line}`);
81
+ }
82
+ }
83
+ }
84
+ //# sourceMappingURL=project.v2.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayai/tray-sync-cli",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
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"
@@ -27,7 +27,8 @@
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
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
- "gallery:pull": "tsc -p tsconfig.test.json && node dist-test/test/manual/pullOutputGallery.js"
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
32
  },
32
33
  "license": "Apache-2.0",
33
34
  "dependencies": {