@lightward/mechanic-cli 0.1.8 → 0.1.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.
- package/README.md +20 -7
- package/dist/commands/github/init.d.ts.map +1 -1
- package/dist/commands/github/init.js +2 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/tasks/diff.d.ts.map +1 -1
- package/dist/commands/tasks/diff.js +4 -3
- package/dist/commands/tasks/new.d.ts.map +1 -1
- package/dist/commands/tasks/new.js +10 -2
- package/dist/commands/tasks/push.d.ts +2 -1
- package/dist/commands/tasks/push.d.ts.map +1 -1
- package/dist/commands/tasks/push.js +43 -20
- package/dist/commands/tasks/status.d.ts +22 -4
- package/dist/commands/tasks/status.d.ts.map +1 -1
- package/dist/commands/tasks/status.js +66 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +34 -3
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -56,7 +56,17 @@ prompted:
|
|
|
56
56
|
mechanic init --shop example.myshopify.com
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Choose how to start.
|
|
60
|
+
|
|
61
|
+
To bring one existing task into local files, find its remote task ID, then pull
|
|
62
|
+
that task:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mechanic tasks list --verbose
|
|
66
|
+
mechanic tasks pull <remote-task-id>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To intentionally bootstrap a repo with every task in the shop:
|
|
60
70
|
|
|
61
71
|
```bash
|
|
62
72
|
mechanic tasks pull
|
|
@@ -70,15 +80,14 @@ initialized CLI project; it does not require a fresh repository:
|
|
|
70
80
|
mechanic tasks new order-tagger
|
|
71
81
|
```
|
|
72
82
|
|
|
73
|
-
For most Liquid or documentation edits,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
is the comfortable editing view beside it. Tasks created with `tasks new`
|
|
77
|
-
already have both files, so you can start editing the helper directory
|
|
78
|
-
immediately.
|
|
83
|
+
For most Liquid or documentation edits, use the helper directory beside the JSON
|
|
84
|
+
file. Existing pulled tasks can be unbundled first; tasks created with
|
|
85
|
+
`tasks new` already have the helper directory.
|
|
79
86
|
|
|
80
87
|
```bash
|
|
88
|
+
# for an existing pulled task only
|
|
81
89
|
mechanic tasks unbundle order-tagger
|
|
90
|
+
|
|
82
91
|
# edit tasks/order-tagger/script.liquid, docs.md, or task.json
|
|
83
92
|
mechanic tasks bundle order-tagger
|
|
84
93
|
mechanic tasks status
|
|
@@ -88,6 +97,10 @@ mechanic tasks publish order-tagger --dry-run
|
|
|
88
97
|
mechanic tasks publish order-tagger
|
|
89
98
|
```
|
|
90
99
|
|
|
100
|
+
For example, edit `tasks/order-tagger/docs.md` or
|
|
101
|
+
`tasks/order-tagger/script.liquid`, bundle it, preview it, then publish only
|
|
102
|
+
when the diff and dry-run plan look right.
|
|
103
|
+
|
|
91
104
|
For normal setup, paste the token into the masked prompt or run
|
|
92
105
|
`mechanic auth login` after `mechanic init`. In CI, store the token as
|
|
93
106
|
`MECHANIC_API_TOKEN`. The `--token` flag exists for controlled automation, but
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/github/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,OAAO,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/github/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,OAAO,SAAqF;IAC5G,OAAgB,WAAW,SAA0H;IAErJ,OAAgB,KAAK;;MAEnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2C3B"}
|
|
@@ -5,8 +5,8 @@ import { CliError } from "../../errors.js";
|
|
|
5
5
|
import { ensureDir, pathExists, writeText } from "../../fs.js";
|
|
6
6
|
import { githubWorkflowFiles } from "../../github-workflows.js";
|
|
7
7
|
export default class GithubInit extends BaseCommand {
|
|
8
|
-
static summary = "Create GitHub Actions workflows for single-shop Mechanic task updates.";
|
|
9
|
-
static description = "Create validation, manual deploy, and pull-from-app GitHub Actions workflows for this Mechanic CLI project.";
|
|
8
|
+
static summary = "Create optional GitHub Actions workflows for single-shop Mechanic task updates.";
|
|
9
|
+
static description = "Create optional validation, manual deploy, and pull-from-app GitHub Actions workflows for this Mechanic CLI project.";
|
|
10
10
|
static flags = {
|
|
11
11
|
force: Flags.boolean({ description: "Overwrite existing Mechanic GitHub workflow files." }),
|
|
12
12
|
};
|
|
@@ -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;
|
|
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;CAiE3B"}
|
package/dist/commands/init.js
CHANGED
|
@@ -59,6 +59,7 @@ export default class Init extends BaseCommand {
|
|
|
59
59
|
this.log("");
|
|
60
60
|
this.log("Next steps:");
|
|
61
61
|
if (!storedToken) {
|
|
62
|
+
this.log(" create an API token in Mechanic: Settings -> API tokens");
|
|
62
63
|
this.log(` ${this.taskName("mechanic auth login")}`);
|
|
63
64
|
}
|
|
64
65
|
this.log(` ${this.taskName("mechanic tasks pull")}`);
|
|
@@ -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;AAapD,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;
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/diff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAapD,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;CAwI3B"}
|
|
@@ -51,6 +51,7 @@ export default class TasksDiff extends BaseCommand {
|
|
|
51
51
|
const relativeFile = displayTaskPath(project, file);
|
|
52
52
|
if (!link) {
|
|
53
53
|
hasUnlinkedTasks = true;
|
|
54
|
+
const message = `No remote task is linked yet. Run "mechanic tasks publish ${slug} --dry-run" to review the disabled create plan.`;
|
|
54
55
|
results.push({
|
|
55
56
|
file: relativeFile,
|
|
56
57
|
slug,
|
|
@@ -59,9 +60,9 @@ export default class TasksDiff extends BaseCommand {
|
|
|
59
60
|
remote_changed: false,
|
|
60
61
|
field_differences: false,
|
|
61
62
|
diff: null,
|
|
62
|
-
message
|
|
63
|
+
message,
|
|
63
64
|
});
|
|
64
|
-
differences.push(`# ${relativeFile}\
|
|
65
|
+
differences.push(`# ${relativeFile}\n${message}`);
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
67
68
|
const localTask = taskForPush(await readTaskFile(file));
|
|
@@ -134,7 +135,7 @@ export default class TasksDiff extends BaseCommand {
|
|
|
134
135
|
summary = "Remote changes found.";
|
|
135
136
|
}
|
|
136
137
|
else if (!hasFieldDifferences && hasUnlinkedTasks) {
|
|
137
|
-
summary = "
|
|
138
|
+
summary = "No remote task linked yet.";
|
|
138
139
|
}
|
|
139
140
|
this.log(summary);
|
|
140
141
|
if (flags["exit-code"]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/new.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/new.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAyCpD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,WAAW;IAC/C,OAAgB,OAAO,SAAoC;IAC3D,OAAgB,WAAW,SAAiJ;IAC5K,OAAgB,QAAQ,WAGtB;IAEF,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;MAGnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA0CZ,kBAAkB;CAoCjC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { BaseCommand } from "../../base-command.js";
|
|
4
|
+
import { linkForSlug } from "../../config.js";
|
|
4
5
|
import { CliError } from "../../errors.js";
|
|
5
6
|
import { pathExists } from "../../fs.js";
|
|
6
7
|
import { displayTaskPath, taskPath, taskSlug, unbundleTask, writeTaskFilePath } from "../../tasks.js";
|
|
@@ -59,7 +60,7 @@ export default class TasksNew extends BaseCommand {
|
|
|
59
60
|
const name = taskNameFromInput(requestedName);
|
|
60
61
|
const filePath = taskPath(project, slug);
|
|
61
62
|
const helperDir = filePath.replace(/\.json$/i, "");
|
|
62
|
-
await this.checkExistingPaths(project, filePath, helperDir, Boolean(flags.force));
|
|
63
|
+
await this.checkExistingPaths(project, slug, filePath, helperDir, Boolean(flags.force));
|
|
63
64
|
await writeTaskFilePath(filePath, starterTask(name));
|
|
64
65
|
await unbundleTask(filePath, helperDir);
|
|
65
66
|
const fileDisplay = displayTaskPath(project, filePath);
|
|
@@ -83,7 +84,14 @@ export default class TasksNew extends BaseCommand {
|
|
|
83
84
|
this.log(` mechanic tasks bundle ${this.taskName(slug)}`);
|
|
84
85
|
this.log(` mechanic tasks publish ${this.taskName(slug)}`);
|
|
85
86
|
}
|
|
86
|
-
async checkExistingPaths(project, filePath, helperDir, force) {
|
|
87
|
+
async checkExistingPaths(project, slug, filePath, helperDir, force) {
|
|
88
|
+
const link = linkForSlug(project, slug);
|
|
89
|
+
if (link) {
|
|
90
|
+
throw new CliError([
|
|
91
|
+
`${slug} is already linked to a Mechanic task.`,
|
|
92
|
+
`Run "mechanic tasks pull ${link.remote_id}" to refresh it, or choose another name for a new task.`,
|
|
93
|
+
].join("\n"), 2);
|
|
94
|
+
}
|
|
87
95
|
if (force) {
|
|
88
96
|
return;
|
|
89
97
|
}
|
|
@@ -18,6 +18,7 @@ type PushRow = {
|
|
|
18
18
|
task_id: string | null;
|
|
19
19
|
content_hash: string | null;
|
|
20
20
|
details: string;
|
|
21
|
+
enabled?: boolean | null;
|
|
21
22
|
url?: string;
|
|
22
23
|
};
|
|
23
24
|
type CreateCollision = {
|
|
@@ -55,7 +56,7 @@ export default class TasksPush extends BaseCommand {
|
|
|
55
56
|
rows: PushRow[];
|
|
56
57
|
}>;
|
|
57
58
|
pushRowsToTable(project: Project, statusHeader: string, rows: PushRow[], label: (status: string) => string): string[][];
|
|
58
|
-
|
|
59
|
+
printPublishedTaskLinks(rows: PushRow[]): void;
|
|
59
60
|
planLabel(plan: string): string;
|
|
60
61
|
}
|
|
61
62
|
export {};
|
|
@@ -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;AAoBpD,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,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAA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CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;QACtF,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,OAAO,EAAE,CAAC;KACjB,CAAC;IA6EF,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,EAAE,EAAE;IAavH,uBAAuB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAe9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAehC"}
|
|
@@ -18,6 +18,25 @@ function createTaskIdempotencyKey(shopDomain, slug) {
|
|
|
18
18
|
hex.slice(20, 32),
|
|
19
19
|
].join("-");
|
|
20
20
|
}
|
|
21
|
+
function remoteTaskEnabled(envelope) {
|
|
22
|
+
if (typeof envelope.enabled === "boolean") {
|
|
23
|
+
return envelope.enabled;
|
|
24
|
+
}
|
|
25
|
+
if (typeof envelope.task.enabled === "boolean") {
|
|
26
|
+
return envelope.task.enabled;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function remoteTaskStateDetail(envelope) {
|
|
31
|
+
const enabled = remoteTaskEnabled(envelope);
|
|
32
|
+
if (enabled === true) {
|
|
33
|
+
return "currently enabled";
|
|
34
|
+
}
|
|
35
|
+
if (enabled === false) {
|
|
36
|
+
return "currently disabled";
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
21
40
|
export default class TasksPush extends BaseCommand {
|
|
22
41
|
static hidden = true;
|
|
23
42
|
static summary = "Publish one local task, or use --all to publish every local task.";
|
|
@@ -68,7 +87,7 @@ export default class TasksPush extends BaseCommand {
|
|
|
68
87
|
return;
|
|
69
88
|
}
|
|
70
89
|
this.table(this.pushRowsToTable(project, "Action", rows, (status) => this.actionLabel(status)));
|
|
71
|
-
this.
|
|
90
|
+
this.printPublishedTaskLinks(rows);
|
|
72
91
|
}
|
|
73
92
|
async publishTasks(project, preparation, force) {
|
|
74
93
|
const client = await this.verifiedClientForProject(project);
|
|
@@ -91,22 +110,25 @@ export default class TasksPush extends BaseCommand {
|
|
|
91
110
|
task_id: created.id,
|
|
92
111
|
content_hash: created.content_hash,
|
|
93
112
|
details: "created disabled; enable in Mechanic",
|
|
113
|
+
enabled: remoteTaskEnabled(created),
|
|
94
114
|
url: taskAdminUrl(project, created.id),
|
|
95
115
|
});
|
|
96
116
|
continue;
|
|
97
117
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
const remote = force
|
|
119
|
+
? await client.getTask(link.remote_id)
|
|
120
|
+
: remoteBySlug.get(slug) || await client.getTask(link.remote_id);
|
|
121
|
+
if (stableStringify(task) === stableStringify(taskForPush(remote.task))) {
|
|
122
|
+
rows.push({
|
|
123
|
+
file: relativeFile,
|
|
124
|
+
status: "skipped",
|
|
125
|
+
task_id: remote.id,
|
|
126
|
+
content_hash: remote.content_hash,
|
|
127
|
+
details: remoteTaskStateDetail(remote),
|
|
128
|
+
enabled: remoteTaskEnabled(remote),
|
|
129
|
+
url: taskAdminUrl(project, remote.id),
|
|
130
|
+
});
|
|
131
|
+
continue;
|
|
110
132
|
}
|
|
111
133
|
const updated = await client.updateTask(link.remote_id, {
|
|
112
134
|
task,
|
|
@@ -120,7 +142,8 @@ export default class TasksPush extends BaseCommand {
|
|
|
120
142
|
status: force ? "forced" : "updated",
|
|
121
143
|
task_id: updated.id,
|
|
122
144
|
content_hash: updated.content_hash,
|
|
123
|
-
details:
|
|
145
|
+
details: remoteTaskStateDetail(updated),
|
|
146
|
+
enabled: remoteTaskEnabled(updated),
|
|
124
147
|
url: taskAdminUrl(project, updated.id),
|
|
125
148
|
});
|
|
126
149
|
}
|
|
@@ -326,7 +349,7 @@ export default class TasksPush extends BaseCommand {
|
|
|
326
349
|
status: "conflict",
|
|
327
350
|
task_id: remote.id,
|
|
328
351
|
content_hash: remote.content_hash,
|
|
329
|
-
details:
|
|
352
|
+
details: remoteChangedSinceLastPullMessage(relativeFile, remote.id, localChangedSinceLastSync(link, task)),
|
|
330
353
|
});
|
|
331
354
|
continue;
|
|
332
355
|
}
|
|
@@ -356,14 +379,14 @@ export default class TasksPush extends BaseCommand {
|
|
|
356
379
|
]),
|
|
357
380
|
];
|
|
358
381
|
}
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
382
|
+
printPublishedTaskLinks(rows) {
|
|
383
|
+
const publishedRows = rows.filter((row) => ["created", "updated", "forced"].includes(row.status) && row.url);
|
|
384
|
+
if (publishedRows.length === 0) {
|
|
362
385
|
return;
|
|
363
386
|
}
|
|
364
387
|
this.log("");
|
|
365
|
-
this.log(this.accent(
|
|
366
|
-
for (const row of
|
|
388
|
+
this.log(this.accent(publishedRows.length === 1 ? "Open task:" : "Open published tasks:"));
|
|
389
|
+
for (const row of publishedRows) {
|
|
367
390
|
this.log(` ${this.taskName(row.file)} ${this.taskName(row.url || "")}`);
|
|
368
391
|
}
|
|
369
392
|
}
|
|
@@ -7,6 +7,25 @@ type HelperStatus = {
|
|
|
7
7
|
blocked: boolean;
|
|
8
8
|
details?: string;
|
|
9
9
|
};
|
|
10
|
+
type TaskStatusResult = {
|
|
11
|
+
file: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
link: {
|
|
14
|
+
linked: boolean;
|
|
15
|
+
remote_id: string | null;
|
|
16
|
+
};
|
|
17
|
+
local: HelperStatus;
|
|
18
|
+
remote: {
|
|
19
|
+
label: string;
|
|
20
|
+
details?: string;
|
|
21
|
+
task_id?: string;
|
|
22
|
+
task_name?: string;
|
|
23
|
+
updated_at?: string | null;
|
|
24
|
+
enabled?: boolean | null;
|
|
25
|
+
url?: string;
|
|
26
|
+
} | null;
|
|
27
|
+
details: string[];
|
|
28
|
+
};
|
|
10
29
|
export default class TasksStatus extends BaseCommand {
|
|
11
30
|
static summary: string;
|
|
12
31
|
static description: string;
|
|
@@ -19,12 +38,11 @@ export default class TasksStatus extends BaseCommand {
|
|
|
19
38
|
};
|
|
20
39
|
run(): Promise<void>;
|
|
21
40
|
helperStatus(project: Project, file: string, task: JsonObject): Promise<HelperStatus>;
|
|
22
|
-
remoteStatus(client: MechanicClient | null, task: JsonObject, link: ReturnType<typeof linkForSlug
|
|
23
|
-
|
|
24
|
-
details?: string;
|
|
25
|
-
}>;
|
|
41
|
+
remoteStatus(project: Project, client: MechanicClient | null, task: JsonObject, link: ReturnType<typeof linkForSlug>, relativeFile: string): Promise<TaskStatusResult["remote"]>;
|
|
42
|
+
printSingleTaskInfo(project: Project, statuses: TaskStatusResult[], checkRemote: boolean): void;
|
|
26
43
|
localLabel(label: string): string;
|
|
27
44
|
remoteLabel(label: string): string;
|
|
45
|
+
enabledLabel(enabled: boolean | null | undefined): string;
|
|
28
46
|
}
|
|
29
47
|
export {};
|
|
30
48
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/tasks/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAgB,MAAM,iBAAiB,CAAC;AAgB5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAgB,MAAM,gBAAg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,CAAC,QAAQ,CAAC,CAAC;IAiCtC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;IAwB/F,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAejC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAmBlC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;CAW1D"}
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { BaseCommand } from "../../base-command.js";
|
|
4
|
-
import { linkForSlug } from "../../config.js";
|
|
4
|
+
import { linkForSlug, taskAdminUrl } from "../../config.js";
|
|
5
5
|
import { pathExists } from "../../fs.js";
|
|
6
6
|
import { stableStringify } from "../../json.js";
|
|
7
|
-
import { displayTaskPath, helperDirForTaskFile, readRawTaskFile, remoteChangedSinceLastPull,
|
|
7
|
+
import { displayTaskPath, helperDirForTaskFile, localChangedSinceLastSync, readRawTaskFile, remoteChangedSinceLastPull, remoteChangedSinceLastPullMessage, selectedTaskFiles, slugFromTaskFile, taskForPush, unbundledHelperDirForTaskFile, validateTaskForPush, } from "../../tasks.js";
|
|
8
8
|
const IMPLICIT_REMOTE_CHECK_LIMIT = 25;
|
|
9
9
|
function errorMessage(error) {
|
|
10
10
|
return error instanceof Error ? error.message : String(error);
|
|
11
11
|
}
|
|
12
|
+
function remoteTaskEnabled(envelope) {
|
|
13
|
+
if (typeof envelope.enabled === "boolean") {
|
|
14
|
+
return envelope.enabled;
|
|
15
|
+
}
|
|
16
|
+
if (typeof envelope.task.enabled === "boolean") {
|
|
17
|
+
return envelope.task.enabled;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function remoteTaskName(envelope) {
|
|
22
|
+
return typeof envelope.task.name === "string" && envelope.task.name.trim()
|
|
23
|
+
? envelope.task.name
|
|
24
|
+
: envelope.id;
|
|
25
|
+
}
|
|
12
26
|
export default class TasksStatus extends BaseCommand {
|
|
13
27
|
static summary = "Show whether local task files are ready and in sync with Mechanic.";
|
|
14
28
|
static description = `Show whether local task files are linked, ready to publish, and in sync with their remote Mechanic tasks. Repo-wide status checks remote state for up to ${IMPLICIT_REMOTE_CHECK_LIMIT} tasks; larger projects show local status only. Use --local to skip remote checks.`;
|
|
@@ -67,13 +81,13 @@ export default class TasksStatus extends BaseCommand {
|
|
|
67
81
|
details.push(helperStatus.details);
|
|
68
82
|
}
|
|
69
83
|
const remote = checkRemote && task && !helperStatus.blocked
|
|
70
|
-
? await this.remoteStatus(link ? await getClient() : null, task, link)
|
|
84
|
+
? await this.remoteStatus(project, link ? await getClient() : null, task, link, relativeFile)
|
|
71
85
|
: checkRemote ? { label: "skipped", details: undefined } : null;
|
|
72
86
|
if (remote?.details) {
|
|
73
87
|
details.push(remote.details);
|
|
74
88
|
}
|
|
75
89
|
else if (!link && task && !helperStatus.blocked) {
|
|
76
|
-
details.push("publish
|
|
90
|
+
details.push("run publish --dry-run to check create plan");
|
|
77
91
|
}
|
|
78
92
|
statuses.push({
|
|
79
93
|
file: relativeFile,
|
|
@@ -121,6 +135,7 @@ export default class TasksStatus extends BaseCommand {
|
|
|
121
135
|
this.log("");
|
|
122
136
|
}
|
|
123
137
|
this.table(rows);
|
|
138
|
+
this.printSingleTaskInfo(project, statuses, checkRemote);
|
|
124
139
|
}
|
|
125
140
|
async helperStatus(project, file, task) {
|
|
126
141
|
const helperDir = helperDirForTaskFile(file);
|
|
@@ -146,21 +161,52 @@ export default class TasksStatus extends BaseCommand {
|
|
|
146
161
|
}
|
|
147
162
|
return { label: "ready", blocked: false };
|
|
148
163
|
}
|
|
149
|
-
async remoteStatus(client, task, link) {
|
|
164
|
+
async remoteStatus(project, client, task, link, relativeFile) {
|
|
150
165
|
if (!link) {
|
|
151
|
-
return { label: "
|
|
166
|
+
return { label: "unlinked", details: "run publish --dry-run to check create plan" };
|
|
152
167
|
}
|
|
153
168
|
if (!client) {
|
|
154
169
|
return { label: "not checked" };
|
|
155
170
|
}
|
|
156
171
|
const remote = await client.getTask(link.remote_id);
|
|
172
|
+
const taskDetails = {
|
|
173
|
+
task_id: remote.id,
|
|
174
|
+
task_name: remoteTaskName(remote),
|
|
175
|
+
updated_at: remote.updated_at || null,
|
|
176
|
+
enabled: remoteTaskEnabled(remote),
|
|
177
|
+
url: taskAdminUrl(project, remote.id),
|
|
178
|
+
};
|
|
157
179
|
if (remoteChangedSinceLastPull(link, remote)) {
|
|
158
|
-
return {
|
|
180
|
+
return {
|
|
181
|
+
label: "conflict",
|
|
182
|
+
details: remoteChangedSinceLastPullMessage(relativeFile, link.remote_id, localChangedSinceLastSync(link, task)),
|
|
183
|
+
...taskDetails,
|
|
184
|
+
};
|
|
159
185
|
}
|
|
160
186
|
if (stableStringify(taskForPush(task)) !== stableStringify(taskForPush(remote.task))) {
|
|
161
|
-
return { label: "local changes", details: "publish would update" };
|
|
187
|
+
return { label: "local changes", details: "publish would update", ...taskDetails };
|
|
188
|
+
}
|
|
189
|
+
return { label: "no change", ...taskDetails };
|
|
190
|
+
}
|
|
191
|
+
printSingleTaskInfo(project, statuses, checkRemote) {
|
|
192
|
+
if (!checkRemote || statuses.length !== 1) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const status = statuses[0];
|
|
196
|
+
const remote = status.remote;
|
|
197
|
+
if (!remote?.task_id) {
|
|
198
|
+
return;
|
|
162
199
|
}
|
|
163
|
-
|
|
200
|
+
this.log("");
|
|
201
|
+
this.log(this.accent("Task details"));
|
|
202
|
+
this.table([
|
|
203
|
+
["Field", "Value"],
|
|
204
|
+
["Name", this.taskName(remote.task_name || remote.task_id)],
|
|
205
|
+
["State", this.enabledLabel(remote.enabled)],
|
|
206
|
+
["Updated", this.muted(remote.updated_at || "--")],
|
|
207
|
+
["Task ID", this.taskId(project, remote.task_id)],
|
|
208
|
+
["URL", this.taskName(remote.url || taskAdminUrl(project, remote.task_id))],
|
|
209
|
+
]);
|
|
164
210
|
}
|
|
165
211
|
localLabel(label) {
|
|
166
212
|
switch (label) {
|
|
@@ -185,6 +231,8 @@ export default class TasksStatus extends BaseCommand {
|
|
|
185
231
|
return this.color("cyan", label);
|
|
186
232
|
case "conflict":
|
|
187
233
|
return this.color("red", label);
|
|
234
|
+
case "unlinked":
|
|
235
|
+
return this.color("yellow", label);
|
|
188
236
|
case "skipped":
|
|
189
237
|
case "not checked":
|
|
190
238
|
return this.muted(label);
|
|
@@ -192,4 +240,13 @@ export default class TasksStatus extends BaseCommand {
|
|
|
192
240
|
return label;
|
|
193
241
|
}
|
|
194
242
|
}
|
|
243
|
+
enabledLabel(enabled) {
|
|
244
|
+
if (enabled === true) {
|
|
245
|
+
return this.success("enabled");
|
|
246
|
+
}
|
|
247
|
+
if (enabled === false) {
|
|
248
|
+
return this.color("yellow", "disabled");
|
|
249
|
+
}
|
|
250
|
+
return this.muted("unknown");
|
|
251
|
+
}
|
|
195
252
|
}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,oBAAoB,QAAkE,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,oBAAoB,QAAkE,CAAC;AAwEpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBzD;AA+BD,wBAAgB,aAAa,CAAC,UAAU,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.`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
function normalizeRelativeProjectPath(value, label) {
|
|
30
|
+
const normalizedInput = value.trim().replace(/\\/g, "/");
|
|
31
|
+
if (!normalizedInput
|
|
32
|
+
|| path.posix.isAbsolute(normalizedInput)
|
|
33
|
+
|| path.win32.isAbsolute(value)) {
|
|
34
|
+
throw new CliError(`${label} must be a relative path inside this Mechanic CLI project.`);
|
|
35
|
+
}
|
|
36
|
+
const normalized = path.posix.normalize(normalizedInput).replace(/\/+$/, "");
|
|
37
|
+
if (normalized === "."
|
|
38
|
+
|| normalized === ".."
|
|
39
|
+
|| normalized.startsWith("../")
|
|
40
|
+
|| path.posix.isAbsolute(normalized)) {
|
|
41
|
+
throw new CliError(`${label} must be a relative path inside this Mechanic CLI project.`);
|
|
42
|
+
}
|
|
43
|
+
return normalized;
|
|
44
|
+
}
|
|
45
|
+
function normalizeTasksDirName(value) {
|
|
46
|
+
return normalizeRelativeProjectPath(value || DEFAULT_TASKS_DIR, "tasks_dir");
|
|
47
|
+
}
|
|
48
|
+
function normalizeLinkFile(slug, file, tasksDirName) {
|
|
49
|
+
const normalizedTasksDir = normalizeTasksDirName(tasksDirName);
|
|
50
|
+
const normalizedFile = normalizeRelativeProjectPath(file || `${normalizedTasksDir}/${slug}.json`, `.mechanic/links.json file for ${slug}`);
|
|
51
|
+
const relativeToTasksDir = path.posix.relative(normalizedTasksDir, normalizedFile);
|
|
52
|
+
if (relativeToTasksDir === ""
|
|
53
|
+
|| relativeToTasksDir === ".."
|
|
54
|
+
|| relativeToTasksDir.startsWith("../")
|
|
55
|
+
|| path.posix.isAbsolute(relativeToTasksDir)) {
|
|
56
|
+
throw new CliError(`.mechanic/links.json file for ${slug} must be inside ${normalizedTasksDir}.`);
|
|
57
|
+
}
|
|
58
|
+
return normalizedFile;
|
|
59
|
+
}
|
|
29
60
|
export function normalizeApiBaseUrl(value) {
|
|
30
61
|
const url = parseConfigUrl(value, "api_base_url");
|
|
31
62
|
const hostname = url.hostname.toLowerCase();
|
|
@@ -93,7 +124,7 @@ function normalizeLinkEntry(slug, entry, tasksDirName) {
|
|
|
93
124
|
return null;
|
|
94
125
|
}
|
|
95
126
|
const normalized = {
|
|
96
|
-
file: entry.file
|
|
127
|
+
file: normalizeLinkFile(slug, entry.file, tasksDirName),
|
|
97
128
|
remote_id: entry.remote_id,
|
|
98
129
|
last_remote_content_hash: entry.last_remote_content_hash,
|
|
99
130
|
};
|
|
@@ -107,7 +138,7 @@ function normalizeLegacyLinkEntry(slug, entry, tasksDirName) {
|
|
|
107
138
|
return null;
|
|
108
139
|
}
|
|
109
140
|
return [slug, {
|
|
110
|
-
file:
|
|
141
|
+
file: normalizeLinkFile(slug, undefined, tasksDirName),
|
|
111
142
|
remote_id: entry.task_id,
|
|
112
143
|
last_remote_content_hash: entry.last_remote_hash,
|
|
113
144
|
}];
|
|
@@ -193,7 +224,7 @@ export async function loadProject(cwd = process.cwd()) {
|
|
|
193
224
|
if (!config.api_base_url) {
|
|
194
225
|
throw new CliError("mechanic.json must include api_base_url");
|
|
195
226
|
}
|
|
196
|
-
const tasksDirName = config.tasks_dir
|
|
227
|
+
const tasksDirName = normalizeTasksDirName(config.tasks_dir);
|
|
197
228
|
const linksPath = path.join(cwd, ".mechanic", "links.json");
|
|
198
229
|
const links = normalizeLinks(await readJson(linksPath, emptyLinks()), config.shop_domain, tasksDirName);
|
|
199
230
|
const apiBaseUrl = normalizeApiBaseUrl(process.env.MECHANIC_API_BASE_URL || config.api_base_url);
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,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E,MAAM,GAAG,IAAI,CAAC;KAC9B,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightward/mechanic-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Develop, preview, diff, and publish Mechanic Shopify automation tasks from local files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,6 +18,13 @@
|
|
|
18
18
|
],
|
|
19
19
|
"author": "Lightward",
|
|
20
20
|
"homepage": "https://learn.mechanic.dev/platform/mechanic-cli",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/lightward/mechanic-cli.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/lightward/mechanic-cli/issues"
|
|
27
|
+
},
|
|
21
28
|
"bin": {
|
|
22
29
|
"mechanic": "./bin/mechanic.js"
|
|
23
30
|
},
|
|
@@ -40,7 +47,7 @@
|
|
|
40
47
|
"description": "Manage the stored API token for this project."
|
|
41
48
|
},
|
|
42
49
|
"github": {
|
|
43
|
-
"description": "Generate GitHub Actions workflows for Mechanic task updates."
|
|
50
|
+
"description": "Generate optional GitHub Actions workflows for Mechanic task updates."
|
|
44
51
|
},
|
|
45
52
|
"shop": {
|
|
46
53
|
"description": "Inspect this shop's Mechanic queue and backlog."
|