@lightward/mechanic-cli 0.1.4 → 0.1.6

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.
@@ -38,7 +38,7 @@ export class BaseCommand extends Command {
38
38
  async verifyClientShop(project, client) {
39
39
  const verification = await client.verifyAuth();
40
40
  const verifiedShopDomain = verification.shop?.shopify_domain;
41
- if (verifiedShopDomain !== project.shopDomain) {
41
+ if (verifiedShopDomain && verifiedShopDomain !== project.shopDomain) {
42
42
  throw new CliError("API token does not match this Mechanic CLI project. Use a token for the shop in mechanic.json, or re-run mechanic init for the intended shop.", 2);
43
43
  }
44
44
  }
package/dist/client.d.ts CHANGED
@@ -7,9 +7,9 @@ type RequestOptions = {
7
7
  retry?: boolean;
8
8
  };
9
9
  export type AuthVerification = {
10
- shop: {
11
- shopify_domain: string;
12
- };
10
+ shop?: {
11
+ shopify_domain?: string | null;
12
+ } | null;
13
13
  api_token?: {
14
14
  name?: string | null;
15
15
  created_by?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAKtH,eAAO,MAAM,UAAU,QAAkD,CAAC;AAE1E,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE;QACJ,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB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MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI1C,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IASxE,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAM3D,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ5E,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;CAM3H"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,WAAW,SAA4C;IAEvE,OAAgB,KAAK;;MAInB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BpB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CASxC"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,WAAW,SAA4C;IAEvE,OAAgB,KAAK;;MAInB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBpB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CASxC"}
@@ -21,10 +21,7 @@ export default class AuthLogin extends BaseCommand {
21
21
  });
22
22
  const verification = await client.verifyAuth();
23
23
  const verifiedDomain = verification.shop?.shopify_domain;
24
- if (!verifiedDomain) {
25
- throw new CliError("Token verification did not return a shop domain.");
26
- }
27
- if (verifiedDomain !== project.shopDomain) {
24
+ if (verifiedDomain && verifiedDomain !== project.shopDomain) {
28
25
  throw new CliError("API token does not match this Mechanic CLI project. Use a token for the shop in mechanic.json.", 2);
29
26
  }
30
27
  await saveToken(project.shopDomain, token);
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAiBjD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IAC7C,OAAgB,WAAW,SAA2E;IAEhG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAoH1B,WAAW,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;CAUpD"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAiBjD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IAC7C,OAAgB,WAAW,SAA2E;IAEhG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAsH1B,WAAW,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;CAUpD"}
@@ -53,15 +53,16 @@ export default class Doctor extends BaseCommand {
53
53
  if (token) {
54
54
  const client = new MechanicClient({
55
55
  baseUrl: project.apiBaseUrl,
56
+ expectedShopDomain: project.shopDomain,
56
57
  token,
57
58
  });
58
59
  try {
59
60
  const verification = await client.verifyAuth();
60
61
  const verifiedDomain = verification.shop?.shopify_domain;
61
- verifiedShopMatches = verifiedDomain === project.shopDomain;
62
+ verifiedShopMatches = !verifiedDomain || verifiedDomain === project.shopDomain;
62
63
  addRow("Token shop", verifiedShopMatches ? "ok" : "fail", verifiedDomain
63
64
  ? (verifiedShopMatches ? project.shopDomain : "API token does not match this project")
64
- : "API did not return a shop domain");
65
+ : `verified for ${project.shopDomain}`);
65
66
  if (verifiedShopMatches) {
66
67
  const tokenDetails = [
67
68
  verification.api_token?.name,
@@ -79,6 +80,7 @@ export default class Doctor extends BaseCommand {
79
80
  if (token && verifiedShopMatches) {
80
81
  const client = new MechanicClient({
81
82
  baseUrl: project.apiBaseUrl,
83
+ expectedShopDomain: project.shopDomain,
82
84
  token,
83
85
  });
84
86
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AASjD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,WAAW;IAC3C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,KAAK;;;;;;MAQnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoE3B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AASjD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,WAAW;IAC3C,OAAgB,WAAW,SAAkD;IAE7E,OAAgB,KAAK;;;;;;MAQnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgE3B"}
@@ -35,10 +35,7 @@ export default class Init extends BaseCommand {
35
35
  });
36
36
  const verification = await client.verifyAuth();
37
37
  const verifiedDomain = verification.shop?.shopify_domain;
38
- if (!verifiedDomain) {
39
- throw new CliError("Token verification did not return a shop domain.");
40
- }
41
- if (verifiedDomain !== flags.shop) {
38
+ if (verifiedDomain && verifiedDomain !== flags.shop) {
42
39
  throw new CliError("API token does not match the requested shop. Check --shop or use a token for that shop.", 2);
43
40
  }
44
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AASpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAA+D;IACtF,OAAgB,WAAW,SAAqG;IAChI,OAAgB,QAAQ,WAKtB;IAEF,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;MAOnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgCZ,kBAAkB;CAuEjC"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAoBpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAA+D;IACtF,OAAgB,WAAW,SAAqG;IAChI,OAAgB,QAAQ,WAKtB;IAEF,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;MAOnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgCZ,kBAAkB;CAwEjC"}
@@ -7,6 +7,14 @@ import { bundleTask, displayTaskPath, resolveTaskSelector } from "../../tasks.js
7
7
  function looksLikeTaskPath(input) {
8
8
  return input.includes("/") || input.includes("\\") || input.toLowerCase().endsWith(".json");
9
9
  }
10
+ function stripTrailingSeparators(input) {
11
+ let result = input;
12
+ const root = path.parse(path.resolve(input)).root;
13
+ while (result.length > root.length && /[\\/]$/.test(result)) {
14
+ result = result.slice(0, -1);
15
+ }
16
+ return result;
17
+ }
10
18
  export default class TasksBundle extends BaseCommand {
11
19
  static summary = "Bundle one helper task directory into one task JSON file.";
12
20
  static description = "Bundle one local task slug or editable helper task directory into one canonical task JSON file.";
@@ -55,15 +63,16 @@ export default class TasksBundle extends BaseCommand {
55
63
  this.log(`Bundled ${this.taskName(inputDisplay)} -> ${this.taskName(outputDisplay)}`);
56
64
  }
57
65
  async resolveBundlePaths(input, out) {
58
- const inputPath = path.resolve(input);
66
+ const normalizedInput = stripTrailingSeparators(input);
67
+ const inputPath = path.resolve(normalizedInput);
59
68
  if (await pathExists(path.join(inputPath, "task.json"))) {
60
69
  return {
61
70
  dirPath: inputPath,
62
- inputDisplay: input,
63
- outputDisplay: out || `${input}.json`,
71
+ inputDisplay: normalizedInput,
72
+ outputDisplay: out || `${normalizedInput}.json`,
64
73
  };
65
74
  }
66
- if (!looksLikeTaskPath(input)) {
75
+ if (!looksLikeTaskPath(normalizedInput)) {
67
76
  let project = null;
68
77
  try {
69
78
  project = await this.loadProject();
@@ -91,14 +100,14 @@ export default class TasksBundle extends BaseCommand {
91
100
  }
92
101
  }
93
102
  }
94
- if (!input.toLowerCase().endsWith(".json")) {
103
+ if (!normalizedInput.toLowerCase().endsWith(".json")) {
95
104
  return {
96
105
  dirPath: inputPath,
97
- inputDisplay: input,
98
- outputDisplay: out || `${input}.json`,
106
+ inputDisplay: normalizedInput,
107
+ outputDisplay: out || `${normalizedInput}.json`,
99
108
  };
100
109
  }
101
- const helperInput = input.slice(0, -".json".length);
110
+ const helperInput = normalizedInput.slice(0, -".json".length);
102
111
  const helperPath = path.resolve(helperInput);
103
112
  if (!(await pathExists(path.join(helperPath, "task.json")))) {
104
113
  throw new CliError([
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/diff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAYpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,OAAO,SAA2D;IAClF,OAAgB,WAAW,SAA6G;IAExI,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;;MAMnB;IAEF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA2BzB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoH3B"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/diff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAYpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,OAAO,SAA2D;IAClF,OAAgB,WAAW,SAA6G;IAExI,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;;MAMnB;IAEF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA2BzB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4H3B"}
@@ -44,11 +44,13 @@ export default class TasksDiff extends BaseCommand {
44
44
  const results = [];
45
45
  let hasFieldDifferences = false;
46
46
  let hasRemoteChanges = false;
47
+ let hasUnlinkedTasks = false;
47
48
  for (const file of files) {
48
49
  const slug = slugFromTaskFile(file);
49
50
  const link = linkForSlug(project, slug);
50
51
  const relativeFile = displayTaskPath(project, file);
51
52
  if (!link) {
53
+ hasUnlinkedTasks = true;
52
54
  results.push({
53
55
  file: relativeFile,
54
56
  slug,
@@ -116,7 +118,14 @@ export default class TasksDiff extends BaseCommand {
116
118
  return;
117
119
  }
118
120
  this.log(differences.join("\n\n"));
119
- this.log(hasFieldDifferences ? "Differences found." : "Remote changes found.");
121
+ let summary = "Differences found.";
122
+ if (!hasFieldDifferences && hasRemoteChanges) {
123
+ summary = "Remote changes found.";
124
+ }
125
+ else if (!hasFieldDifferences && hasUnlinkedTasks) {
126
+ summary = "Unlinked tasks found.";
127
+ }
128
+ this.log(summary);
120
129
  if (flags["exit-code"]) {
121
130
  process.exitCode = 1;
122
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/pull.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAoBpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,OAAO,SAAmD;IAC1E,OAAgB,WAAW,SAAmI;IAE9J,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;MAGnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsG3B"}
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/pull.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAoBpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,OAAgB,OAAO,SAAmD;IAC1E,OAAgB,WAAW,SAAmI;IAE9J,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;MAGnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuG3B"}
@@ -74,7 +74,7 @@ export default class TasksPull extends BaseCommand {
74
74
  }
75
75
  }
76
76
  await writeTaskFilePathAndRefreshHelper(filePath, envelope.task);
77
- links = updateLink({ ...project, links }, slug, envelope.id, envelope.content_hash, contentHash(taskForPush(envelope.task)));
77
+ links = updateLink({ ...project, links }, slug, envelope.id, envelope.content_hash, contentHash(taskForPush(envelope.task)), filePath);
78
78
  await saveLinks(project, links);
79
79
  rows.push([
80
80
  this.taskId(project, envelope.id),
@@ -1 +1 @@
1
- {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/push.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAmBpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb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AAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAehC"}
@@ -82,7 +82,7 @@ export default class TasksPush extends BaseCommand {
82
82
  const link = linkForSlug({ ...project, links }, slug);
83
83
  if (!link) {
84
84
  const created = await client.createTask(task, createTaskIdempotencyKey(project.shopDomain, slug));
85
- links = updateLink({ ...project, links }, slug, created.id, created.content_hash, contentHash(taskForPush(created.task)));
85
+ links = updateLink({ ...project, links }, slug, created.id, created.content_hash, contentHash(taskForPush(created.task)), file);
86
86
  await saveLinks(project, links);
87
87
  await writeTaskFilePathAndRefreshHelper(file, created.task);
88
88
  rows.push({
@@ -112,7 +112,7 @@ export default class TasksPush extends BaseCommand {
112
112
  task,
113
113
  ...(force ? { force: true } : { previous_content_hash: link.last_remote_content_hash }),
114
114
  });
115
- links = updateLink({ ...project, links }, slug, updated.id, updated.content_hash, contentHash(taskForPush(updated.task)));
115
+ links = updateLink({ ...project, links }, slug, updated.id, updated.content_hash, contentHash(taskForPush(updated.task)), file);
116
116
  await saveLinks(project, links);
117
117
  await writeTaskFilePathAndRefreshHelper(file, updated.task);
118
118
  rows.push({
package/dist/config.d.ts CHANGED
@@ -11,5 +11,5 @@ export declare function loadProject(cwd?: string): Promise<Project>;
11
11
  export declare function saveLinks(project: Project, links: LinksFile): Promise<void>;
12
12
  export declare function linkForSlug(project: Project, slug: string): LinkEntry | null;
13
13
  export declare function slugForRemoteId(project: Project, remoteId: string): string | null;
14
- export declare function updateLink(project: Project, slug: string, remoteId: string, contentHash: string, localContentHash?: string): LinksFile;
14
+ export declare function updateLink(project: Project, slug: string, remoteId: string, contentHash: string, localContentHash?: string, filePath?: string): LinksFile;
15
15
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MA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,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,SAAS,CAmBX"}
package/dist/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ import nodeFs from "node:fs";
1
2
  import path from "node:path";
2
3
  import { CliError } from "./errors.js";
3
4
  import { ensureDir, pathExists, readJson, readText, writeJson, writeText } from "./fs.js";
@@ -87,12 +88,12 @@ export function defaultConfig(shopDomain, apiBaseUrl = DEFAULT_API_BASE_URL, app
87
88
  export function emptyLinks() {
88
89
  return { tasks: {} };
89
90
  }
90
- function normalizeLinkEntry(slug, entry) {
91
+ function normalizeLinkEntry(slug, entry, tasksDirName) {
91
92
  if (!entry || typeof entry !== "object" || !entry.remote_id || !entry.last_remote_content_hash) {
92
93
  return null;
93
94
  }
94
95
  const normalized = {
95
- file: entry.file || `${DEFAULT_TASKS_DIR}/${slug}.json`,
96
+ file: entry.file || `${tasksDirName}/${slug}.json`,
96
97
  remote_id: entry.remote_id,
97
98
  last_remote_content_hash: entry.last_remote_content_hash,
98
99
  };
@@ -101,17 +102,17 @@ function normalizeLinkEntry(slug, entry) {
101
102
  }
102
103
  return [slug, normalized];
103
104
  }
104
- function normalizeLegacyLinkEntry(slug, entry) {
105
+ function normalizeLegacyLinkEntry(slug, entry, tasksDirName) {
105
106
  if (!entry || typeof entry !== "object" || !entry.task_id || !entry.last_remote_hash) {
106
107
  return null;
107
108
  }
108
109
  return [slug, {
109
- file: `${DEFAULT_TASKS_DIR}/${slug}.json`,
110
+ file: `${tasksDirName}/${slug}.json`,
110
111
  remote_id: entry.task_id,
111
112
  last_remote_content_hash: entry.last_remote_hash,
112
113
  }];
113
114
  }
114
- function normalizeLinks(value, shopDomain) {
115
+ function normalizeLinks(value, shopDomain, tasksDirName = DEFAULT_TASKS_DIR) {
115
116
  if (!value || typeof value !== "object") {
116
117
  return emptyLinks();
117
118
  }
@@ -119,7 +120,7 @@ function normalizeLinks(value, shopDomain) {
119
120
  if (links.tasks && typeof links.tasks === "object") {
120
121
  return {
121
122
  tasks: Object.fromEntries(Object.entries(links.tasks).flatMap(([slug, entry]) => {
122
- const normalized = normalizeLinkEntry(slug, entry);
123
+ const normalized = normalizeLinkEntry(slug, entry, tasksDirName);
123
124
  return normalized ? [normalized] : [];
124
125
  })),
125
126
  };
@@ -128,7 +129,7 @@ function normalizeLinks(value, shopDomain) {
128
129
  if (shopLinks && typeof shopLinks === "object") {
129
130
  return {
130
131
  tasks: Object.fromEntries(Object.entries(shopLinks).flatMap(([slug, entry]) => {
131
- const normalized = normalizeLegacyLinkEntry(slug, entry);
132
+ const normalized = normalizeLegacyLinkEntry(slug, entry, tasksDirName);
132
133
  return normalized ? [normalized] : [];
133
134
  })),
134
135
  };
@@ -147,7 +148,9 @@ export async function initProject(cwd, shopDomain, apiBaseUrl, appUrl, force = f
147
148
  }
148
149
  const existingConfig = force ? await readJson(configPath, {}) : {};
149
150
  const preserveLinks = force && existingConfig.shop_domain === shopDomain;
150
- const links = preserveLinks ? normalizeLinks(await readJson(linksPath, emptyLinks()), shopDomain) : emptyLinks();
151
+ const links = preserveLinks
152
+ ? normalizeLinks(await readJson(linksPath, emptyLinks()), shopDomain, config.tasks_dir)
153
+ : emptyLinks();
151
154
  config.api_base_url = normalizeApiBaseUrl(config.api_base_url);
152
155
  config.app_url = normalizeAppUrl(config.app_url || defaultAppUrl(config.shop_domain));
153
156
  await ensureDir(path.join(cwd, config.tasks_dir));
@@ -192,7 +195,7 @@ export async function loadProject(cwd = process.cwd()) {
192
195
  }
193
196
  const tasksDirName = config.tasks_dir || DEFAULT_TASKS_DIR;
194
197
  const linksPath = path.join(cwd, ".mechanic", "links.json");
195
- const links = normalizeLinks(await readJson(linksPath, emptyLinks()), config.shop_domain);
198
+ const links = normalizeLinks(await readJson(linksPath, emptyLinks()), config.shop_domain, tasksDirName);
196
199
  const apiBaseUrl = normalizeApiBaseUrl(process.env.MECHANIC_API_BASE_URL || config.api_base_url);
197
200
  const appUrl = normalizeAppUrl(process.env.MECHANIC_APP_URL || config.app_url || defaultAppUrl(config.shop_domain));
198
201
  return {
@@ -217,9 +220,30 @@ export function linkForSlug(project, slug) {
217
220
  export function slugForRemoteId(project, remoteId) {
218
221
  return Object.entries(project.links.tasks).find(([, link]) => link.remote_id === remoteId)?.[0] || null;
219
222
  }
220
- export function updateLink(project, slug, remoteId, contentHash, localContentHash) {
223
+ function realpathIfExists(filePath) {
224
+ try {
225
+ return nodeFs.realpathSync.native(filePath);
226
+ }
227
+ catch {
228
+ return filePath;
229
+ }
230
+ }
231
+ function relativeProjectPath(project, filePath) {
232
+ const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(project.cwd, filePath);
233
+ const relativePath = path.relative(project.cwd, absolutePath);
234
+ if (!relativePath.startsWith("..") && !path.isAbsolute(relativePath)) {
235
+ return relativePath.split(path.sep).join("/");
236
+ }
237
+ const realProjectCwd = realpathIfExists(project.cwd);
238
+ const realFilePath = realpathIfExists(absolutePath);
239
+ const realRelativePath = path.relative(realProjectCwd, realFilePath);
240
+ return realRelativePath.split(path.sep).join("/");
241
+ }
242
+ export function updateLink(project, slug, remoteId, contentHash, localContentHash, filePath) {
243
+ const existingFile = project.links.tasks[slug]?.file;
244
+ const file = filePath ? relativeProjectPath(project, filePath) : existingFile || `${project.tasksDirName}/${slug}.json`;
221
245
  const entry = {
222
- file: `${project.tasksDirName}/${slug}.json`,
246
+ file,
223
247
  remote_id: remoteId,
224
248
  last_remote_content_hash: contentHash,
225
249
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/E,MAAM,MAAM,oBAA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EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CA4D/E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEtF;AA2ID,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAyB9E"}
package/dist/tasks.js CHANGED
@@ -439,6 +439,7 @@ export function validateTask(task, source) {
439
439
  export function validateTaskForPush(task, source) {
440
440
  return validateTask(task, source);
441
441
  }
442
+ const MAX_LINE_DIFF_CELLS = 250_000;
442
443
  function comparableTaskValue(value) {
443
444
  return value === undefined ? "(missing)" : String(stableStringify(value));
444
445
  }
@@ -489,6 +490,14 @@ function lineDiff(remoteLines, localLines) {
489
490
  return operations;
490
491
  }
491
492
  function formattedLineDiff(remoteLines, localLines) {
493
+ if ((remoteLines.length + 1) * (localLines.length + 1) > MAX_LINE_DIFF_CELLS) {
494
+ return [
495
+ "@@",
496
+ `- ${remoteLines.length} current Mechanic lines`,
497
+ `+ ${localLines.length} local file lines`,
498
+ "Large value changed; detailed line diff omitted to keep the CLI responsive.",
499
+ ];
500
+ }
492
501
  const operations = lineDiff(remoteLines, localLines);
493
502
  const changeIndexes = operations.flatMap((operation, index) => (operation.kind === "context" ? [] : [index]));
494
503
  if (changeIndexes.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightward/mechanic-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Develop, preview, diff, and publish Mechanic Shopify automation tasks from local files",
5
5
  "type": "module",
6
6
  "keywords": [