@lightward/mechanic-cli 0.1.10 → 0.1.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.
- package/package.json +3 -2
- package/dist/commands/globals/delete.d.ts +0 -13
- package/dist/commands/globals/delete.d.ts.map +0 -1
- package/dist/commands/globals/delete.js +0 -28
- package/dist/commands/globals/list.d.ts +0 -10
- package/dist/commands/globals/list.d.ts.map +0 -1
- package/dist/commands/globals/list.js +0 -39
- package/dist/commands/globals/pull.d.ts +0 -11
- package/dist/commands/globals/pull.d.ts.map +0 -1
- package/dist/commands/globals/pull.js +0 -42
- package/dist/commands/globals/push.d.ts +0 -11
- package/dist/commands/globals/push.d.ts.map +0 -1
- package/dist/commands/globals/push.js +0 -57
- package/dist/commands/globals/set.d.ts +0 -13
- package/dist/commands/globals/set.d.ts.map +0 -1
- package/dist/commands/globals/set.js +0 -26
- package/dist/commands/secrets/delete.d.ts +0 -13
- package/dist/commands/secrets/delete.d.ts.map +0 -1
- package/dist/commands/secrets/delete.js +0 -28
- package/dist/commands/secrets/list.d.ts +0 -10
- package/dist/commands/secrets/list.d.ts.map +0 -1
- package/dist/commands/secrets/list.js +0 -37
- package/dist/commands/secrets/set.d.ts +0 -25
- package/dist/commands/secrets/set.d.ts.map +0 -1
- package/dist/commands/secrets/set.js +0 -91
- package/dist/config-keys.d.ts +0 -2
- package/dist/config-keys.d.ts.map +0 -1
- package/dist/config-keys.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightward/mechanic-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Develop, preview, diff, and publish Mechanic Shopify automation tasks from local files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -64,7 +64,8 @@
|
|
|
64
64
|
"README.md"
|
|
65
65
|
],
|
|
66
66
|
"scripts": {
|
|
67
|
-
"
|
|
67
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
68
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
68
69
|
"test": "npm run build && node --import ./test/v1/no-color.mjs --test test/v1/*.test.mjs",
|
|
69
70
|
"prepack": "npm run build",
|
|
70
71
|
"prepare": "npm run build"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class GlobalsDelete extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static args: {
|
|
6
|
-
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
-
};
|
|
8
|
-
static flags: {
|
|
9
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/globals/delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,OAAgB,OAAO,SAA6B;IACpD,OAAgB,WAAW,SAA2C;IAEtE,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;MAKnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAc3B"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import { validateConfigKey } from "../../config-keys.js";
|
|
4
|
-
import { CliError } from "../../errors.js";
|
|
5
|
-
export default class GlobalsDelete extends BaseCommand {
|
|
6
|
-
static summary = "Delete one shop global.";
|
|
7
|
-
static description = "Delete one visible shop-level global.";
|
|
8
|
-
static args = {
|
|
9
|
-
key: Args.string({ required: true, description: "Global key, using lower snake-case." }),
|
|
10
|
-
};
|
|
11
|
-
static flags = {
|
|
12
|
-
force: Flags.boolean({
|
|
13
|
-
char: "f",
|
|
14
|
-
description: "Delete without an interactive confirmation.",
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
async run() {
|
|
18
|
-
const { args, flags } = await this.parse(GlobalsDelete);
|
|
19
|
-
const key = validateConfigKey(args.key);
|
|
20
|
-
if (!flags.force) {
|
|
21
|
-
throw new CliError(`Deleting global ${key} cannot be undone. Re-run with --force to confirm.`, 2);
|
|
22
|
-
}
|
|
23
|
-
const project = await this.loadProject();
|
|
24
|
-
const client = await this.verifiedClientForProject(project);
|
|
25
|
-
await client.deleteGlobal(key);
|
|
26
|
-
this.log(`${this.success("Deleted")} global ${this.taskName(key)}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class GlobalsList extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
};
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/globals/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAUpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAAwB;IAC/C,OAAgB,WAAW,SAAqE;IAEhG,OAAgB,KAAK;;MAInB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwB3B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
function formatValue(value) {
|
|
4
|
-
if (value === undefined) {
|
|
5
|
-
return "";
|
|
6
|
-
}
|
|
7
|
-
return JSON.stringify(value);
|
|
8
|
-
}
|
|
9
|
-
export default class GlobalsList extends BaseCommand {
|
|
10
|
-
static summary = "List shop globals.";
|
|
11
|
-
static description = "List visible shop-level JSON globals for this Mechanic project.";
|
|
12
|
-
static flags = {
|
|
13
|
-
json: Flags.boolean({
|
|
14
|
-
description: "Print globals as JSON for agents, scripts, or editor integrations.",
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
async run() {
|
|
18
|
-
const { flags } = await this.parse(GlobalsList);
|
|
19
|
-
const project = await this.loadProject();
|
|
20
|
-
const client = await this.verifiedClientForProject(project);
|
|
21
|
-
const response = await client.listGlobals();
|
|
22
|
-
const globals = response.globals || [];
|
|
23
|
-
if (flags.json) {
|
|
24
|
-
this.outputJson({
|
|
25
|
-
shop_domain: project.shopDomain,
|
|
26
|
-
globals,
|
|
27
|
-
});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.table([
|
|
31
|
-
["Key", "Value", "Updated"],
|
|
32
|
-
...globals.map((global) => [
|
|
33
|
-
this.taskName(global.key),
|
|
34
|
-
formatValue(global.value),
|
|
35
|
-
this.muted(global.updated_at || ""),
|
|
36
|
-
]),
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class GlobalsPull extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
out: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/commands/globals/pull.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAAmD;IAC1E,OAAgB,WAAW,SAAiE;IAE5F,OAAgB,KAAK;;;MAQnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0B3B"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { BaseCommand } from "../../base-command.js";
|
|
4
|
-
import { CliError } from "../../errors.js";
|
|
5
|
-
import { pathExists, readText, writeText } from "../../fs.js";
|
|
6
|
-
import { stableStringify } from "../../json.js";
|
|
7
|
-
const DEFAULT_GLOBALS_FILE = "mechanic.globals.json";
|
|
8
|
-
export default class GlobalsPull extends BaseCommand {
|
|
9
|
-
static summary = "Pull shop globals into mechanic.globals.json.";
|
|
10
|
-
static description = "Pull visible shop-level globals into a repo-safe JSON file.";
|
|
11
|
-
static flags = {
|
|
12
|
-
out: Flags.string({
|
|
13
|
-
description: "File path to write.",
|
|
14
|
-
default: DEFAULT_GLOBALS_FILE,
|
|
15
|
-
}),
|
|
16
|
-
force: Flags.boolean({
|
|
17
|
-
description: "Overwrite an existing globals file when its contents differ.",
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
async run() {
|
|
21
|
-
const { flags } = await this.parse(GlobalsPull);
|
|
22
|
-
const project = await this.loadProject();
|
|
23
|
-
const client = await this.verifiedClientForProject(project);
|
|
24
|
-
const response = await client.listGlobals();
|
|
25
|
-
const globals = Object.fromEntries((response.globals || []).map((global) => [global.key, global.value]));
|
|
26
|
-
const file = path.resolve(project.cwd, flags.out);
|
|
27
|
-
const relativeFile = path.relative(project.cwd, file) || file;
|
|
28
|
-
const contents = `${stableStringify(globals)}\n`;
|
|
29
|
-
if (await pathExists(file)) {
|
|
30
|
-
const existingContents = await readText(file);
|
|
31
|
-
if (existingContents === contents) {
|
|
32
|
-
this.log(`${this.success("Unchanged")} ${this.taskName(relativeFile)}`);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (!flags.force) {
|
|
36
|
-
throw new CliError(`${relativeFile} already exists and differs. Re-run with --force to overwrite.`, 2);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
await writeText(file, contents);
|
|
40
|
-
this.log(`${this.success("Wrote")} ${this.taskName(relativeFile)}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class GlobalsPush extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
"dry-run": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=push.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/commands/globals/push.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAgBpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAA8C;IACrE,OAAgB,WAAW,SAAmI;IAE9J,OAAgB,KAAK;;;MAQnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAuC3B"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { BaseCommand } from "../../base-command.js";
|
|
4
|
-
import { validateConfigKey } from "../../config-keys.js";
|
|
5
|
-
import { CliError } from "../../errors.js";
|
|
6
|
-
import { readJson } from "../../fs.js";
|
|
7
|
-
import { stableStringify } from "../../json.js";
|
|
8
|
-
const DEFAULT_GLOBALS_FILE = "mechanic.globals.json";
|
|
9
|
-
function ensurePlainObject(value, source) {
|
|
10
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype) {
|
|
11
|
-
throw new CliError(`${source} must contain a JSON object mapping global keys to values.`, 2);
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
export default class GlobalsPush extends BaseCommand {
|
|
16
|
-
static summary = "Push mechanic.globals.json to this shop.";
|
|
17
|
-
static description = "Push visible shop-level globals from a repo-safe JSON file. This updates listed keys and does not delete missing remote keys.";
|
|
18
|
-
static flags = {
|
|
19
|
-
file: Flags.string({
|
|
20
|
-
description: "Globals JSON file to read.",
|
|
21
|
-
default: DEFAULT_GLOBALS_FILE,
|
|
22
|
-
}),
|
|
23
|
-
"dry-run": Flags.boolean({
|
|
24
|
-
description: "Show what would be pushed without writing to Mechanic.",
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
async run() {
|
|
28
|
-
const { flags } = await this.parse(GlobalsPush);
|
|
29
|
-
const project = await this.loadProject();
|
|
30
|
-
const client = await this.verifiedClientForProject(project);
|
|
31
|
-
const file = path.resolve(project.cwd, flags.file);
|
|
32
|
-
const entries = Object.entries(ensurePlainObject(await readJson(file), path.relative(project.cwd, file) || file));
|
|
33
|
-
const rows = [["Key", "Action"]];
|
|
34
|
-
for (const [key] of entries) {
|
|
35
|
-
validateConfigKey(key);
|
|
36
|
-
}
|
|
37
|
-
if (flags["dry-run"]) {
|
|
38
|
-
const remoteGlobals = Object.fromEntries((await client.listGlobals()).globals?.map((global) => [global.key, global.value]) || []);
|
|
39
|
-
for (const [key, value] of entries) {
|
|
40
|
-
const remoteValue = remoteGlobals[key];
|
|
41
|
-
const action = remoteValue === undefined
|
|
42
|
-
? "would create"
|
|
43
|
-
: stableStringify(remoteValue) === stableStringify(value)
|
|
44
|
-
? "unchanged"
|
|
45
|
-
: "would update";
|
|
46
|
-
rows.push([this.taskName(key), this.actionLabel(action)]);
|
|
47
|
-
}
|
|
48
|
-
this.table(rows);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
for (const [key, value] of entries) {
|
|
52
|
-
await client.setGlobal(key, value);
|
|
53
|
-
rows.push([this.taskName(key), this.actionLabel("updated")]);
|
|
54
|
-
}
|
|
55
|
-
this.table(rows);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class GlobalsSet extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static args: {
|
|
6
|
-
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
-
};
|
|
8
|
-
static flags: {
|
|
9
|
-
json: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=set.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/commands/globals/set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,OAAO,SAA0B;IACjD,OAAgB,WAAW,SAA6C;IAExE,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;MAKnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAU3B"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import { validateConfigKey } from "../../config-keys.js";
|
|
4
|
-
import { parseJson } from "../../json.js";
|
|
5
|
-
export default class GlobalsSet extends BaseCommand {
|
|
6
|
-
static summary = "Set one shop global.";
|
|
7
|
-
static description = "Set one visible shop-level JSON global.";
|
|
8
|
-
static args = {
|
|
9
|
-
key: Args.string({ required: true, description: "Global key, using lower snake-case." }),
|
|
10
|
-
};
|
|
11
|
-
static flags = {
|
|
12
|
-
json: Flags.string({
|
|
13
|
-
required: true,
|
|
14
|
-
description: "JSON value to store.",
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
async run() {
|
|
18
|
-
const { args, flags } = await this.parse(GlobalsSet);
|
|
19
|
-
const key = validateConfigKey(args.key);
|
|
20
|
-
const value = parseJson(flags.json, "--json");
|
|
21
|
-
const project = await this.loadProject();
|
|
22
|
-
const client = await this.verifiedClientForProject(project);
|
|
23
|
-
await client.setGlobal(key, value);
|
|
24
|
-
this.log(`${this.success("Set")} global ${this.taskName(key)}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class SecretsDelete extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static args: {
|
|
6
|
-
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
-
};
|
|
8
|
-
static flags: {
|
|
9
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
};
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets/delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,OAAgB,OAAO,SAA6B;IACpD,OAAgB,WAAW,SAAqF;IAEhH,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;MAKnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAc3B"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
import { validateConfigKey } from "../../config-keys.js";
|
|
4
|
-
import { CliError } from "../../errors.js";
|
|
5
|
-
export default class SecretsDelete extends BaseCommand {
|
|
6
|
-
static summary = "Delete one shop secret.";
|
|
7
|
-
static description = "Delete one write-only shop-level secret. Affected tasks may fail until updated.";
|
|
8
|
-
static args = {
|
|
9
|
-
key: Args.string({ required: true, description: "Secret key, using lower snake-case." }),
|
|
10
|
-
};
|
|
11
|
-
static flags = {
|
|
12
|
-
force: Flags.boolean({
|
|
13
|
-
char: "f",
|
|
14
|
-
description: "Delete without an interactive confirmation.",
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
async run() {
|
|
18
|
-
const { args, flags } = await this.parse(SecretsDelete);
|
|
19
|
-
const key = validateConfigKey(args.key);
|
|
20
|
-
if (!flags.force) {
|
|
21
|
-
throw new CliError(`Deleting secret ${key} can break tasks until updated. Re-run with --force to confirm.`, 2);
|
|
22
|
-
}
|
|
23
|
-
const project = await this.loadProject();
|
|
24
|
-
const client = await this.verifiedClientForProject(project);
|
|
25
|
-
await client.deleteSecret(key);
|
|
26
|
-
this.log(`${this.success("Deleted")} secret ${this.taskName(key)}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../base-command.js";
|
|
2
|
-
export default class SecretsList extends BaseCommand {
|
|
3
|
-
static summary: string;
|
|
4
|
-
static description: string;
|
|
5
|
-
static flags: {
|
|
6
|
-
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
};
|
|
8
|
-
run(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,OAAO,SAAwB;IAC/C,OAAgB,WAAW,SAAmF;IAE9G,OAAgB,KAAK;;MAInB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyB3B"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
function formatCount(value) {
|
|
4
|
-
return typeof value === "number" ? value.toLocaleString() : "0";
|
|
5
|
-
}
|
|
6
|
-
export default class SecretsList extends BaseCommand {
|
|
7
|
-
static summary = "List shop secrets.";
|
|
8
|
-
static description = "List write-only shop-level secret metadata. Secret values are never returned.";
|
|
9
|
-
static flags = {
|
|
10
|
-
json: Flags.boolean({
|
|
11
|
-
description: "Print secret metadata as JSON for agents, scripts, or editor integrations.",
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
async run() {
|
|
15
|
-
const { flags } = await this.parse(SecretsList);
|
|
16
|
-
const project = await this.loadProject();
|
|
17
|
-
const client = await this.verifiedClientForProject(project);
|
|
18
|
-
const response = await client.listSecrets();
|
|
19
|
-
const secrets = response.secrets || [];
|
|
20
|
-
if (flags.json) {
|
|
21
|
-
this.outputJson({
|
|
22
|
-
shop_domain: project.shopDomain,
|
|
23
|
-
secrets,
|
|
24
|
-
});
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.table([
|
|
28
|
-
["Key", "Value", "Task refs", "Updated"],
|
|
29
|
-
...secrets.map((secret) => [
|
|
30
|
-
this.taskName(secret.key),
|
|
31
|
-
secret.value_present ? this.success("set") : this.muted("missing"),
|
|
32
|
-
formatCount(secret.task_reference_count),
|
|
33
|
-
this.muted(secret.updated_at || ""),
|
|
34
|
-
]),
|
|
35
|
-
]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { stdin } from "node:process";
|
|
2
|
-
import { BaseCommand } from "../../base-command.js";
|
|
3
|
-
type SecretStdin = typeof stdin;
|
|
4
|
-
export declare function readStdin(input?: SecretStdin): Promise<string>;
|
|
5
|
-
export declare function readSecretValueFromStdin(input?: SecretStdin): Promise<string>;
|
|
6
|
-
export declare function readSecretValueFromEnv(envName: string, env?: NodeJS.ProcessEnv): string;
|
|
7
|
-
export default class SecretsSet extends BaseCommand {
|
|
8
|
-
static summary: string;
|
|
9
|
-
static description: string;
|
|
10
|
-
static args: {
|
|
11
|
-
key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
-
};
|
|
13
|
-
static flags: {
|
|
14
|
-
"from-stdin": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
-
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
-
"value-env": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
};
|
|
18
|
-
run(): Promise<void>;
|
|
19
|
-
secretValue(flags: {
|
|
20
|
-
"from-stdin"?: boolean;
|
|
21
|
-
"value-env"?: string;
|
|
22
|
-
}): Promise<string>;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=set.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets/set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,KAAK,WAAW,GAAG,OAAO,KAAK,CAAC;AAEhC,wBAAgB,SAAS,CAAC,KAAK,GAAE,WAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBrE;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,GAAE,WAAmB,GACzB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAYR;AAED,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAgB,OAAO,SAA0B;IACjD,OAAgB,WAAW,SAAwE;IAEnG,OAAgB,IAAI;;MAElB;IAEF,OAAgB,KAAK;;;;MAanB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBpB,WAAW,CAAC,KAAK,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAsB5F"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { stdin } from "node:process";
|
|
3
|
-
import { promptForHiddenValue } from "../../auth.js";
|
|
4
|
-
import { BaseCommand } from "../../base-command.js";
|
|
5
|
-
import { validateConfigKey } from "../../config-keys.js";
|
|
6
|
-
import { CliError } from "../../errors.js";
|
|
7
|
-
export function readStdin(input = stdin) {
|
|
8
|
-
if (input.isTTY) {
|
|
9
|
-
throw new CliError("Cannot read secret value from stdin while stdin is a TTY. Pipe a value or use --value-env.", 2);
|
|
10
|
-
}
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
let value = "";
|
|
13
|
-
input.setEncoding("utf8");
|
|
14
|
-
input.on("data", (chunk) => {
|
|
15
|
-
value += chunk;
|
|
16
|
-
});
|
|
17
|
-
input.on("end", () => {
|
|
18
|
-
resolve(value);
|
|
19
|
-
});
|
|
20
|
-
input.on("error", reject);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export async function readSecretValueFromStdin(input = stdin) {
|
|
24
|
-
const value = await readStdin(input);
|
|
25
|
-
if (value.length === 0) {
|
|
26
|
-
throw new CliError("Secret value cannot be blank.", 2);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
export function readSecretValueFromEnv(envName, env = process.env) {
|
|
31
|
-
const value = env[envName];
|
|
32
|
-
if (value === undefined) {
|
|
33
|
-
throw new CliError(`Environment variable ${envName} is not set.`, 2);
|
|
34
|
-
}
|
|
35
|
-
if (value.length === 0) {
|
|
36
|
-
throw new CliError(`Environment variable ${envName} is empty.`, 2);
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
export default class SecretsSet extends BaseCommand {
|
|
41
|
-
static summary = "Set one shop secret.";
|
|
42
|
-
static description = "Set one write-only shop secret. The secret value is never printed.";
|
|
43
|
-
static args = {
|
|
44
|
-
key: Args.string({ required: true, description: "Secret key, using lower snake-case." }),
|
|
45
|
-
};
|
|
46
|
-
static flags = {
|
|
47
|
-
"from-stdin": Flags.boolean({
|
|
48
|
-
description: "Read the secret value from stdin.",
|
|
49
|
-
exclusive: ["value-env"],
|
|
50
|
-
}),
|
|
51
|
-
force: Flags.boolean({
|
|
52
|
-
char: "f",
|
|
53
|
-
description: "Replace the value when this secret key already exists.",
|
|
54
|
-
}),
|
|
55
|
-
"value-env": Flags.string({
|
|
56
|
-
description: "Read the secret value from the named environment variable.",
|
|
57
|
-
exclusive: ["from-stdin"],
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
async run() {
|
|
61
|
-
const { args, flags } = await this.parse(SecretsSet);
|
|
62
|
-
const key = validateConfigKey(args.key);
|
|
63
|
-
const project = await this.loadProject();
|
|
64
|
-
const client = await this.verifiedClientForProject(project);
|
|
65
|
-
const existing = (await client.listSecrets()).secrets?.some((secret) => secret.key === key);
|
|
66
|
-
if (existing && !flags.force) {
|
|
67
|
-
throw new CliError(`Secret ${key} already exists. Re-run with --force to replace its value.`, 2);
|
|
68
|
-
}
|
|
69
|
-
const value = await this.secretValue(flags);
|
|
70
|
-
await client.setSecret(key, value);
|
|
71
|
-
this.log(`${this.success(existing ? "Replaced" : "Set")} secret ${this.taskName(key)}`);
|
|
72
|
-
}
|
|
73
|
-
async secretValue(flags) {
|
|
74
|
-
if (flags["from-stdin"]) {
|
|
75
|
-
return readSecretValueFromStdin();
|
|
76
|
-
}
|
|
77
|
-
if (flags["value-env"]) {
|
|
78
|
-
return readSecretValueFromEnv(flags["value-env"]);
|
|
79
|
-
}
|
|
80
|
-
const value = await promptForHiddenValue({
|
|
81
|
-
blankMessage: "Secret value cannot be blank.",
|
|
82
|
-
missingInputMessage: "Provide a secret value with --from-stdin or --value-env.",
|
|
83
|
-
prompt: "Secret value: ",
|
|
84
|
-
trim: false,
|
|
85
|
-
});
|
|
86
|
-
if (value === null) {
|
|
87
|
-
throw new CliError("Secret value cannot be blank.", 2);
|
|
88
|
-
}
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
}
|
package/dist/config-keys.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-keys.d.ts","sourceRoot":"","sources":["../src/config-keys.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
package/dist/config-keys.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CliError } from "./errors.js";
|
|
2
|
-
const CONFIG_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
3
|
-
export function validateConfigKey(key) {
|
|
4
|
-
if (!CONFIG_KEY_PATTERN.test(key)) {
|
|
5
|
-
throw new CliError("Keys must use lower snake-case and match /^[a-z][a-z0-9_]*$/.", 2);
|
|
6
|
-
}
|
|
7
|
-
return key;
|
|
8
|
-
}
|