@swipt/cli 0.1.0-nightly.98 → 0.1.0-nightly.99
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/dist/availability.d.ts +3 -1
- package/dist/availability.js +173 -151
- package/dist/availability.js.map +1 -1
- package/dist/cli/cli.js +52 -66
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command.d.ts +9 -0
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/data/clear.js +2 -2
- package/dist/cli/commands/data/clear.js.map +1 -1
- package/dist/cli/commands/data/data.js +2 -2
- package/dist/cli/commands/data/data.js.map +1 -1
- package/dist/cli/commands/data/list.js +3 -3
- package/dist/cli/commands/data/list.js.map +1 -1
- package/dist/cli/commands/data/operand.js.map +1 -1
- package/dist/cli/commands/data/read.js +4 -7
- package/dist/cli/commands/data/read.js.map +1 -1
- package/dist/cli/commands/data/remove.js +3 -3
- package/dist/cli/commands/data/remove.js.map +1 -1
- package/dist/cli/commands/data/write.js +2 -2
- package/dist/cli/commands/data/write.js.map +1 -1
- package/dist/cli/commands/device/add.js +2 -2
- package/dist/cli/commands/device/add.js.map +1 -1
- package/dist/cli/commands/device/device.js +2 -2
- package/dist/cli/commands/device/device.js.map +1 -1
- package/dist/cli/commands/device/list.js +2 -2
- package/dist/cli/commands/device/list.js.map +1 -1
- package/dist/cli/commands/device/logs.js +44 -46
- package/dist/cli/commands/device/logs.js.map +1 -1
- package/dist/cli/commands/device/remove.js +2 -2
- package/dist/cli/commands/device/remove.js.map +1 -1
- package/dist/cli/commands/device/stop.js +3 -3
- package/dist/cli/commands/device/stop.js.map +1 -1
- package/dist/cli/commands/driver/driver.js +6 -6
- package/dist/cli/commands/driver/driver.js.map +1 -1
- package/dist/cli/commands/flags.js +9 -9
- package/dist/cli/commands/flags.js.map +1 -1
- package/dist/cli/commands/index.js +2 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/project/build.js +2 -2
- package/dist/cli/commands/project/build.js.map +1 -1
- package/dist/cli/commands/project/create.js +3 -3
- package/dist/cli/commands/project/create.js.map +1 -1
- package/dist/cli/commands/project/deploy.js +2 -2
- package/dist/cli/commands/project/deploy.js.map +1 -1
- package/dist/cli/commands/project/develop.js +19 -19
- package/dist/cli/commands/project/develop.js.map +1 -1
- package/dist/cli/commands/project/project.js +2 -2
- package/dist/cli/commands/project/project.js.map +1 -1
- package/dist/cli/commands/project/source.js +62 -37
- package/dist/cli/commands/project/source.js.map +1 -1
- package/dist/cli/commands/repl/api.js +2 -2
- package/dist/cli/commands/repl/api.js.map +1 -1
- package/dist/cli/commands/repl/repl.js +4 -4
- package/dist/cli/commands/repl/repl.js.map +1 -1
- package/dist/cli/commands/repl/reset.js +2 -2
- package/dist/cli/commands/repl/reset.js.map +1 -1
- package/dist/cli/commands/repl/run.js +5 -5
- package/dist/cli/commands/repl/run.js.map +1 -1
- package/dist/cli/commands/sideload/install.js +4 -4
- package/dist/cli/commands/sideload/install.js.map +1 -1
- package/dist/cli/commands/sideload/setup.js +3 -3
- package/dist/cli/commands/sideload/setup.js.map +1 -1
- package/dist/cli/commands/sideload/sideload.js +2 -2
- package/dist/cli/commands/sideload/sideload.js.map +1 -1
- package/dist/cli/commands/sideload/uninstall.js +2 -2
- package/dist/cli/commands/sideload/uninstall.js.map +1 -1
- package/dist/cli/commands/sideload/update.js +3 -3
- package/dist/cli/commands/sideload/update.js.map +1 -1
- package/dist/cli/commands/swiplet/call.js +6 -6
- package/dist/cli/commands/swiplet/call.js.map +1 -1
- package/dist/cli/commands/swiplet/install.js +3 -3
- package/dist/cli/commands/swiplet/install.js.map +1 -1
- package/dist/cli/commands/swiplet/list.js +8 -8
- package/dist/cli/commands/swiplet/list.js.map +1 -1
- package/dist/cli/commands/swiplet/remove.js +3 -3
- package/dist/cli/commands/swiplet/remove.js.map +1 -1
- package/dist/cli/commands/swiplet/service/disable.js +3 -3
- package/dist/cli/commands/swiplet/service/disable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/enable.js +3 -3
- package/dist/cli/commands/swiplet/service/enable.js.map +1 -1
- package/dist/cli/commands/swiplet/service/service.js +2 -2
- package/dist/cli/commands/swiplet/service/service.js.map +1 -1
- package/dist/cli/commands/swiplet/service/services.js +2 -2
- package/dist/cli/commands/swiplet/service/services.js.map +1 -1
- package/dist/cli/commands/swiplet/service/watch.js +2 -2
- package/dist/cli/commands/swiplet/service/watch.js.map +1 -1
- package/dist/cli/commands/swiplet/show.js +6 -6
- package/dist/cli/commands/swiplet/show.js.map +1 -1
- package/dist/cli/commands/swiplet/swiplet.js +4 -4
- package/dist/cli/commands/swiplet/swiplet.js.map +1 -1
- package/dist/cli/commands/version/version.js +2 -2
- package/dist/cli/commands/version/version.js.map +1 -1
- package/dist/cli/deploy.js +9 -7
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/session.js.map +1 -1
- package/dist/client.d.ts +145 -7
- package/dist/client.js +20 -22
- package/dist/client.js.map +1 -1
- package/dist/connection.d.ts +292 -25
- package/dist/connection.js +36 -35
- package/dist/connection.js.map +1 -1
- package/dist/driver.d.ts +62 -23
- package/dist/driver.js +29 -33
- package/dist/driver.js.map +1 -1
- package/dist/i18n.d.ts +2 -5
- package/dist/i18n.js +15 -13
- package/dist/i18n.js.map +1 -1
- package/dist/i18next.d.ts +7 -0
- package/dist/ignore.d.ts +14 -7
- package/dist/ignore.js +13 -14
- package/dist/ignore.js.map +1 -1
- package/dist/mdns.d.ts +2 -2
- package/dist/mdns.js +1 -1
- package/dist/mdns.js.map +1 -1
- package/dist/metro.d.ts +19 -5
- package/dist/metro.js +61 -63
- package/dist/metro.js.map +1 -1
- package/dist/output.d.ts +29 -14
- package/dist/output.js +17 -15
- package/dist/output.js.map +1 -1
- package/dist/passcode.d.ts +12 -8
- package/dist/passcode.js +18 -18
- package/dist/passcode.js.map +1 -1
- package/dist/project.d.ts +20 -10
- package/dist/project.js +72 -49
- package/dist/project.js.map +1 -1
- package/dist/proto/common_pb.d.ts +240 -0
- package/dist/proto/common_pb.js +7 -2
- package/dist/proto/common_pb.js.map +1 -1
- package/dist/proto/logs_pb.d.ts +38 -0
- package/dist/proto/repl_pb.d.ts +96 -0
- package/dist/proto/swiplets_pb.d.ts +361 -0
- package/dist/proto/swiplets_pb.js +7 -2
- package/dist/proto/swiplets_pb.js.map +1 -1
- package/dist/proto/system_pb.d.ts +33 -0
- package/dist/resources.d.ts +400 -0
- package/dist/serve.d.ts +9 -1
- package/dist/serve.js +17 -16
- package/dist/serve.js.map +1 -1
- package/dist/sideload.d.ts +27 -14
- package/dist/sideload.js +102 -89
- package/dist/sideload.js.map +1 -1
- package/dist/swipt-app.d.ts +19 -9
- package/dist/swipt-app.js +1 -1
- package/dist/swipt-app.js.map +1 -1
- package/locales/ar/translation.json +413 -0
- package/locales/bg/translation.json +397 -0
- package/locales/bn/translation.json +397 -0
- package/locales/ca/translation.json +401 -0
- package/locales/cs/translation.json +405 -0
- package/locales/da/translation.json +397 -0
- package/locales/de/translation.json +397 -0
- package/locales/el/translation.json +397 -0
- package/locales/en/translation.json +397 -0
- package/locales/es/translation.json +401 -0
- package/locales/es-419/translation.json +401 -0
- package/locales/fi/translation.json +397 -0
- package/locales/fr/translation.json +401 -0
- package/locales/fr-CA/translation.json +401 -0
- package/locales/gu/translation.json +397 -0
- package/locales/he/translation.json +401 -0
- package/locales/hi/translation.json +397 -0
- package/locales/hr/translation.json +401 -0
- package/locales/hu/translation.json +397 -0
- package/locales/id/translation.json +393 -0
- package/locales/it/translation.json +401 -0
- package/locales/ja/translation.json +393 -0
- package/locales/kk/translation.json +397 -0
- package/locales/kn/translation.json +397 -0
- package/locales/ko/translation.json +393 -0
- package/locales/lt/translation.json +405 -0
- package/locales/ml/translation.json +397 -0
- package/locales/mr/translation.json +397 -0
- package/locales/ms/translation.json +393 -0
- package/locales/nb/translation.json +397 -0
- package/locales/nl/translation.json +397 -0
- package/locales/or/translation.json +397 -0
- package/locales/pa/translation.json +397 -0
- package/locales/pl/translation.json +405 -0
- package/locales/pt-BR/translation.json +401 -0
- package/locales/pt-PT/translation.json +401 -0
- package/locales/ro/translation.json +401 -0
- package/locales/ru/translation.json +405 -0
- package/locales/sk/translation.json +405 -0
- package/locales/sl/translation.json +405 -0
- package/locales/sv/translation.json +397 -0
- package/locales/ta/translation.json +397 -0
- package/locales/te/translation.json +397 -0
- package/locales/th/translation.json +393 -0
- package/locales/tr/translation.json +397 -0
- package/locales/uk/translation.json +405 -0
- package/locales/ur/translation.json +397 -0
- package/locales/vi/translation.json +397 -0
- package/locales/zh-HK/translation.json +393 -0
- package/locales/zh-Hans/translation.json +393 -0
- package/locales/zh-Hant/translation.json +393 -0
- package/package.json +14 -9
- package/locales/ar.json +0 -311
- package/locales/bg.json +0 -295
- package/locales/bn.json +0 -295
- package/locales/ca.json +0 -299
- package/locales/cs.json +0 -303
- package/locales/da.json +0 -295
- package/locales/de.json +0 -295
- package/locales/el.json +0 -295
- package/locales/es-419.json +0 -299
- package/locales/es.json +0 -299
- package/locales/fi.json +0 -295
- package/locales/fr-CA.json +0 -299
- package/locales/fr.json +0 -299
- package/locales/gu.json +0 -295
- package/locales/he.json +0 -299
- package/locales/hi.json +0 -295
- package/locales/hr.json +0 -299
- package/locales/hu.json +0 -295
- package/locales/id.json +0 -283
- package/locales/it.json +0 -299
- package/locales/ja.json +0 -283
- package/locales/kk.json +0 -295
- package/locales/kn.json +0 -295
- package/locales/ko.json +0 -283
- package/locales/lt.json +0 -303
- package/locales/ml.json +0 -295
- package/locales/mr.json +0 -295
- package/locales/ms.json +0 -283
- package/locales/nb.json +0 -295
- package/locales/nl.json +0 -295
- package/locales/or.json +0 -295
- package/locales/pa.json +0 -295
- package/locales/pl.json +0 -303
- package/locales/pt-BR.json +0 -299
- package/locales/pt-PT.json +0 -299
- package/locales/ro.json +0 -299
- package/locales/ru.json +0 -303
- package/locales/sk.json +0 -303
- package/locales/sl.json +0 -303
- package/locales/sv.json +0 -295
- package/locales/ta.json +0 -295
- package/locales/te.json +0 -295
- package/locales/th.json +0 -283
- package/locales/tr.json +0 -295
- package/locales/uk.json +0 -303
- package/locales/ur.json +0 -295
- package/locales/vi.json +0 -295
- package/locales/zh-HK.json +0 -283
- package/locales/zh-Hans.json +0 -283
- package/locales/zh-Hant.json +0 -283
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UsageError } from "../../../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
import { session } from "../../session.js";
|
|
5
5
|
import { operandCount } from "./operand.js";
|
|
@@ -39,10 +39,7 @@ var FileSink = class {
|
|
|
39
39
|
for (const file of this.files.values()) fs.closeSync(file);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
const printSaved = (target, count) => console.error(
|
|
43
|
-
one: "saved {count} file to {path}",
|
|
44
|
-
other: "saved {count} files to {path}"
|
|
45
|
-
}, {
|
|
42
|
+
const printSaved = (target, count) => console.error(t("commands.data.read.saved", {
|
|
46
43
|
count,
|
|
47
44
|
path: target
|
|
48
45
|
}));
|
|
@@ -108,12 +105,12 @@ const read = (operand, target) => {
|
|
|
108
105
|
return defineCommand({
|
|
109
106
|
name: "read",
|
|
110
107
|
use: `read ${operand}PATH`,
|
|
111
|
-
short:
|
|
108
|
+
short: t("commands.data.read.description"),
|
|
112
109
|
args: [before + 1, before + 1],
|
|
113
110
|
options: { output: {
|
|
114
111
|
type: "string",
|
|
115
112
|
value: "PATH",
|
|
116
|
-
help:
|
|
113
|
+
help: t("commands.data.read.output")
|
|
117
114
|
} },
|
|
118
115
|
run: readFile(target)
|
|
119
116
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","names":[],"sources":["../../../../src/cli/commands/data/read.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { UsageError } from \"../../../client\";\nimport {
|
|
1
|
+
{"version":3,"file":"read.js","names":[],"sources":["../../../../src/cli/commands/data/read.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { UsageError } from \"../../../client\";\nimport { t } from \"../../../i18n\";\nimport type { FileInfo } from \"../../../proto/common_pb\";\nimport { type Context, defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\nimport { type ResolveTarget, operandCount } from \"./operand\";\n\nclass FileSink {\n declare root: string;\n files = new Map<string, number>();\n saved = 0;\n\n constructor(root: string) {\n this.root = root;\n }\n\n target(name: string) {\n const target = path.resolve(this.root, ...name.split(\"/\"));\n const relative = path.relative(path.resolve(this.root), target);\n if (\n relative === \"..\" ||\n relative.startsWith(`..${path.sep}`) ||\n path.isAbsolute(relative)\n ) {\n throw new Error(\n `the server sent the path ${name}, which leaves the output directory`,\n );\n }\n return target;\n }\n\n begin(name: string, directory: boolean) {\n const target = this.target(name);\n if (directory) {\n fs.mkdirSync(target, { recursive: true });\n return;\n }\n fs.mkdirSync(path.dirname(target), { recursive: true });\n const previous = this.files.get(name);\n if (previous !== undefined) {\n fs.closeSync(previous);\n }\n this.files.set(name, fs.openSync(target, \"w\"));\n this.saved++;\n }\n\n write(name: string, offset: bigint, data: Uint8Array) {\n const file = this.files.get(name);\n if (file === undefined) {\n throw new Error(`the server sent data for ${name} before announcing it`);\n }\n fs.writeSync(file, data, 0, data.length, Number(offset));\n }\n\n close() {\n for (const file of this.files.values()) {\n fs.closeSync(file);\n }\n }\n}\n\nconst printSaved = (target: string, count: number) =>\n console.error(t(\"commands.data.read.saved\", { count, path: target }));\n\nconst readFile =\n (target: ResolveTarget) =>\n (context: Context<{ device?: string; output?: string }>) =>\n session(context, async (client) => {\n const {\n id,\n wholeDirectory,\n subdirectory,\n args: [given],\n } = target(context.args);\n const output = context.options.output ?? \"\";\n const requested = path.posix\n .normalize(`/${given}`)\n .replace(/^\\/+|\\/+$/g, \"\");\n const printing = output === \"\" || output === \"-\";\n const directory = () =>\n new UsageError(\n requested === \"\"\n ? wholeDirectory(JSON.stringify(given))\n : subdirectory(JSON.stringify(requested)),\n );\n const relativeTo = (name: string) =>\n name.slice(requested.length).replace(/^\\//, \"\");\n let sink: FileSink | undefined;\n let single: FileInfo | undefined;\n const contents: Uint8Array[] = [];\n try {\n for await (const response of client.swiplets.readDataFile(\n { swipletId: id, path: given },\n { signal: context.signal },\n )) {\n if (response.part.case === \"file\") {\n const file = response.part.value;\n if (file.path === requested && !file.directory) {\n single = file;\n continue;\n }\n if (!sink) {\n if (printing) {\n throw directory();\n }\n sink = new FileSink(output);\n }\n sink.begin(relativeTo(file.path), file.directory);\n } else if (response.part.case === \"chunk\") {\n const chunk = response.part.value;\n if (single && chunk.path === single.path) {\n contents.push(chunk.data);\n continue;\n }\n if (!sink) {\n throw new Error(\n `the server sent data for ${chunk.path} before announcing it`,\n );\n }\n sink.write(relativeTo(chunk.path), chunk.offset, chunk.data);\n }\n }\n } finally {\n sink?.close();\n }\n if (sink) {\n printSaved(sink.root, sink.saved);\n return;\n }\n if (!single) {\n if (printing) {\n throw directory();\n }\n fs.mkdirSync(output, { recursive: true });\n printSaved(output, 0);\n return;\n }\n const data = Buffer.concat(contents);\n if (printing) {\n process.stdout.write(data);\n return;\n }\n let destination = output;\n if (\n fs.existsSync(destination) &&\n fs.statSync(destination).isDirectory()\n ) {\n destination = path.join(destination, path.posix.basename(single.path));\n }\n fs.writeFileSync(destination, data);\n printSaved(destination, 1);\n });\n\nexport const read = (operand: string, target: ResolveTarget) => {\n const before = operandCount(operand);\n return defineCommand({\n name: \"read\",\n use: `read ${operand}PATH`,\n short: t(\"commands.data.read.description\"),\n args: [before + 1, before + 1],\n options: {\n output: {\n type: \"string\",\n value: \"PATH\",\n help: t(\"commands.data.read.output\"),\n },\n },\n run: readFile(target),\n });\n};\n"],"mappings":";;;;;;;;AAUA,IAAM,WAAN,MAAe;CAEb,wBAAQ,IAAI,IAAoB;CAChC,QAAQ;CAER,YAAY,MAAc;EACxB,KAAK,OAAO;CACd;CAEA,OAAO,MAAc;EACnB,MAAM,SAAS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C;EACxC,WAAW,QAAQ,CAAC;EACpB;CACF;CACA,MAAM,OAAO,OAAO,OAAO,QAAQ;CACnC,IAAI,UAAU;EACZ,QAAQ,OAAO,MAAM,IAAI;EACzB;CACF;CACA,IAAI,cAAc;CAClB,IACE,GAAG,WAAW,WAAW,KACzB,GAAG,SAAS,WAAW,CAAC,CAAC,YAAY,GAErC,cAAc,KAAK,KAAK,aAAa,KAAK,MAAM,SAAS,OAAO,IAAI,CAAC;CAEvE,GAAG,cAAc,aAAa,IAAI;CAClC,WAAW,aAAa,CAAC;AAC3B,CAAC;AAEL,MAAa,QAAQ,SAAiB,WAA0B;CAC9D,MAAM,SAAS,aAAa,OAAO;CACnC,OAAO,cAAc;EACnB,MAAM;EACN,KAAK,QAAQ,QAAQ;EACrB,OAAO,EAAE,gCAAgC;EACzC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;EAC7B,SAAS,EACP,QAAQ;GACN,MAAM;GACN,OAAO;GACP,MAAM,EAAE,2BAA2B;EACrC,EACF;EACA,KAAK,SAAS,MAAM;CACtB,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../../i18n.js";
|
|
2
2
|
import { defineCommand } from "../../command.js";
|
|
3
3
|
import { session } from "../../session.js";
|
|
4
4
|
import { operandCount } from "./operand.js";
|
|
@@ -16,11 +16,11 @@ const remove = (operand, target) => {
|
|
|
16
16
|
return defineCommand({
|
|
17
17
|
name: "remove",
|
|
18
18
|
use: `remove ${operand}PATH`,
|
|
19
|
-
short:
|
|
19
|
+
short: t("commands.data.remove.description"),
|
|
20
20
|
args: [before + 1, before + 1],
|
|
21
21
|
options: { recursive: {
|
|
22
22
|
type: "boolean",
|
|
23
|
-
help:
|
|
23
|
+
help: t("commands.data.remove.recursive")
|
|
24
24
|
} },
|
|
25
25
|
run: removeFile(target)
|
|
26
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","names":[],"sources":["../../../../src/cli/commands/data/remove.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"remove.js","names":[],"sources":["../../../../src/cli/commands/data/remove.ts"],"sourcesContent":["import { t } from \"../../../i18n\";\nimport { type Context, defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\nimport { type ResolveTarget, operandCount } from \"./operand\";\n\nconst removeFile =\n (target: ResolveTarget) =>\n (context: Context<{ device?: string; recursive?: boolean }>) =>\n session(context, async (client) => {\n const {\n id,\n args: [name],\n } = target(context.args);\n await client.swiplets.removeDataFile(\n { swipletId: id, path: name, recursive: context.options.recursive },\n { signal: context.signal },\n );\n });\n\nexport const remove = (operand: string, target: ResolveTarget) => {\n const before = operandCount(operand);\n return defineCommand({\n name: \"remove\",\n use: `remove ${operand}PATH`,\n short: t(\"commands.data.remove.description\"),\n args: [before + 1, before + 1],\n options: {\n recursive: {\n type: \"boolean\",\n help: t(\"commands.data.remove.recursive\"),\n },\n },\n run: removeFile(target),\n });\n};\n"],"mappings":";;;;;AAKA,MAAM,cACH,YACA,YACC,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,EACJ,IACA,MAAM,CAAC,UACL,OAAO,QAAQ,IAAI;CACvB,MAAM,OAAO,SAAS,eACpB;EAAE,WAAW;EAAI,MAAM;EAAM,WAAW,QAAQ,QAAQ;CAAU,GAClE,EAAE,QAAQ,QAAQ,OAAO,CAC3B;AACF,CAAC;AAEL,MAAa,UAAU,SAAiB,WAA0B;CAChE,MAAM,SAAS,aAAa,OAAO;CACnC,OAAO,cAAc;EACnB,MAAM;EACN,KAAK,UAAU,QAAQ;EACvB,OAAO,EAAE,kCAAkC;EAC3C,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;EAC7B,SAAS,EACP,WAAW;GACT,MAAM;GACN,MAAM,EAAE,gCAAgC;EAC1C,EACF;EACA,KAAK,WAAW,MAAM;CACxB,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../../i18n.js";
|
|
2
2
|
import { defineCommand } from "../../command.js";
|
|
3
3
|
import { readStdin, uploadChunk } from "../../io.js";
|
|
4
4
|
import { session } from "../../session.js";
|
|
@@ -27,7 +27,7 @@ const write = (operand, target) => {
|
|
|
27
27
|
return defineCommand({
|
|
28
28
|
name: "write",
|
|
29
29
|
use: `write ${operand}PATH [FILE | -]`,
|
|
30
|
-
short:
|
|
30
|
+
short: t("commands.data.write.description"),
|
|
31
31
|
args: [before + 1, before + 2],
|
|
32
32
|
run: writeFile(target)
|
|
33
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","names":[],"sources":["../../../../src/cli/commands/data/write.ts"],"sourcesContent":["import fs from \"node:fs\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"write.js","names":[],"sources":["../../../../src/cli/commands/data/write.ts"],"sourcesContent":["import fs from \"node:fs\";\n\nimport { t } from \"../../../i18n\";\nimport { type Context, defineCommand } from \"../../command\";\nimport { readStdin, uploadChunk } from \"../../io\";\nimport { session } from \"../../session\";\nimport { type ResolveTarget, operandCount } from \"./operand\";\n\nconst writeFile =\n (target: ResolveTarget) => (context: Context<{ device?: string }>) =>\n session(context, async (client) => {\n const {\n id,\n args: [name, file],\n } = target(context.args);\n const data =\n file === undefined || file === \"-\"\n ? readStdin()\n : fs.readFileSync(file);\n await client.swiplets.writeDataFile(\n (async function* () {\n yield {\n part: { case: \"header\", value: { swipletId: id, path: name } },\n };\n for (let offset = 0; offset < data.length; offset += uploadChunk) {\n yield {\n part: {\n case: \"data\",\n value: data.subarray(offset, offset + uploadChunk),\n },\n };\n }\n })(),\n { signal: context.signal },\n );\n });\n\nexport const write = (operand: string, target: ResolveTarget) => {\n const before = operandCount(operand);\n return defineCommand({\n name: \"write\",\n use: `write ${operand}PATH [FILE | -]`,\n short: t(\"commands.data.write.description\"),\n args: [before + 1, before + 2],\n run: writeFile(target),\n });\n};\n"],"mappings":";;;;;;;AAQA,MAAM,aACH,YAA2B,YAC1B,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,EACJ,IACA,MAAM,CAAC,MAAM,UACX,OAAO,QAAQ,IAAI;CACvB,MAAM,OACJ,SAAS,KAAA,KAAa,SAAS,MAC3B,UAAU,IACV,GAAG,aAAa,IAAI;CAC1B,MAAM,OAAO,SAAS,eACnB,mBAAmB;EAClB,MAAM,EACJ,MAAM;GAAE,MAAM;GAAU,OAAO;IAAE,WAAW;IAAI,MAAM;GAAK;EAAE,EAC/D;EACA,KAAK,IAAI,SAAS,GAAG,SAAS,KAAK,QAAQ,UAAU,aACnD,MAAM,EACJ,MAAM;GACJ,MAAM;GACN,OAAO,KAAK,SAAS,QAAQ,SAAS,WAAW;EACnD,EACF;CAEJ,EAAA,CAAG,GACH,EAAE,QAAQ,QAAQ,OAAO,CAC3B;AACF,CAAC;AAEL,MAAa,SAAS,SAAiB,WAA0B;CAC/D,MAAM,SAAS,aAAa,OAAO;CACnC,OAAO,cAAc;EACnB,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,OAAO,EAAE,iCAAiC;EAC1C,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;EAC7B,KAAK,UAAU,MAAM;CACvB,CAAC;AACH"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { add as add$1 } from "../../../connection.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
// src/cli/commands/device/add.ts
|
|
5
5
|
const add = defineCommand({
|
|
6
6
|
name: "add",
|
|
7
7
|
use: "add URL",
|
|
8
|
-
short:
|
|
8
|
+
short: t("commands.device.add.description"),
|
|
9
9
|
args: [1, 1],
|
|
10
10
|
run: add$1
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","names":["connection.add"],"sources":["../../../../src/cli/commands/device/add.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport {
|
|
1
|
+
{"version":3,"file":"add.js","names":["connection.add"],"sources":["../../../../src/cli/commands/device/add.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport { t } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\n\nexport const add = defineCommand({\n name: \"add\",\n use: \"add URL\",\n short: t(\"commands.device.add.description\"),\n args: [1, 1],\n run: connection.add,\n});\n"],"mappings":";;;;AAIA,MAAa,MAAM,cAAc;CAC/B,MAAM;CACN,KAAK;CACL,OAAO,EAAE,iCAAiC;CAC1C,MAAM,CAAC,GAAG,CAAC;CACX,KAAKA;AACP,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../../i18n.js";
|
|
2
2
|
import { defineCommand } from "../../command.js";
|
|
3
3
|
import { add } from "./add.js";
|
|
4
4
|
import { list } from "./list.js";
|
|
@@ -8,7 +8,7 @@ import { stop } from "./stop.js";
|
|
|
8
8
|
// src/cli/commands/device/device.ts
|
|
9
9
|
const device = defineCommand({
|
|
10
10
|
name: "device",
|
|
11
|
-
short:
|
|
11
|
+
short: t("commands.device.description"),
|
|
12
12
|
commands: [
|
|
13
13
|
list,
|
|
14
14
|
add,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","names":[],"sources":["../../../../src/cli/commands/device/device.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"device.js","names":[],"sources":["../../../../src/cli/commands/device/device.ts"],"sourcesContent":["import { t } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\nimport { add } from \"./add\";\nimport { list } from \"./list\";\nimport { logs } from \"./logs\";\nimport { remove } from \"./remove\";\nimport { stop } from \"./stop\";\n\nexport const device = defineCommand({\n name: \"device\",\n short: t(\"commands.device.description\"),\n commands: [list, add, remove, stop, logs],\n});\n"],"mappings":";;;;;;;;AAQA,MAAa,SAAS,cAAc;CAClC,MAAM;CACN,OAAO,EAAE,6BAA6B;CACtC,UAAU;EAAC;EAAM;EAAK;EAAQ;EAAM;CAAI;AAC1C,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { list as list$1 } from "../../../connection.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
// src/cli/commands/device/list.ts
|
|
5
5
|
const list = defineCommand({
|
|
6
6
|
name: "list",
|
|
7
|
-
short:
|
|
7
|
+
short: t("commands.device.list.description"),
|
|
8
8
|
args: [0, 0],
|
|
9
9
|
run: list$1
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":["connection.list"],"sources":["../../../../src/cli/commands/device/list.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport {
|
|
1
|
+
{"version":3,"file":"list.js","names":["connection.list"],"sources":["../../../../src/cli/commands/device/list.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport { t } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\n\nexport const list = defineCommand({\n name: \"list\",\n short: t(\"commands.device.list.description\"),\n args: [0, 0],\n run: connection.list,\n});\n"],"mappings":";;;;AAIA,MAAa,OAAO,cAAc;CAChC,MAAM;CACN,OAAO,EAAE,kCAAkC;CAC3C,MAAM,CAAC,GAAG,CAAC;CACX,KAAKA;AACP,CAAC"}
|
|
@@ -1,102 +1,100 @@
|
|
|
1
1
|
import { UsageError } from "../../../client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { printLog } from "../../../output.js";
|
|
4
|
+
import { LogEntrySchema } from "../../../proto/common_pb.js";
|
|
4
5
|
import { defineCommand } from "../../command.js";
|
|
5
6
|
import { session } from "../../session.js";
|
|
6
7
|
import { deviceOption } from "../flags.js";
|
|
8
|
+
import { create } from "@bufbuild/protobuf";
|
|
7
9
|
import { timestampFromMs } from "@bufbuild/protobuf/wkt";
|
|
8
10
|
// src/cli/commands/device/logs.ts
|
|
9
|
-
const durationUnits =
|
|
10
|
-
ns
|
|
11
|
-
us
|
|
12
|
-
µs
|
|
13
|
-
ms
|
|
14
|
-
s
|
|
15
|
-
m
|
|
16
|
-
h
|
|
17
|
-
|
|
11
|
+
const durationUnits = /* @__PURE__ */ new Map([
|
|
12
|
+
["ns", 1e-6],
|
|
13
|
+
["us", .001],
|
|
14
|
+
["µs", .001],
|
|
15
|
+
["ms", 1],
|
|
16
|
+
["s", 1e3],
|
|
17
|
+
["m", 6e4],
|
|
18
|
+
["h", 36e5]
|
|
19
|
+
]);
|
|
20
|
+
const levels = /* @__PURE__ */ new Map([
|
|
21
|
+
["error", 1],
|
|
22
|
+
["warn", 2],
|
|
23
|
+
["info", 3],
|
|
24
|
+
["debug", 4]
|
|
25
|
+
]);
|
|
18
26
|
function parseDuration(text, option) {
|
|
19
27
|
if (text === void 0) return 0;
|
|
20
28
|
if (/^-?\d+$/.test(text) && Number(text) === 0) return 0;
|
|
21
29
|
let total = 0;
|
|
22
30
|
let rest = text;
|
|
23
31
|
while (rest !== "") {
|
|
24
|
-
const match = /^(\d+(?:\.\d*)?|\.\d+)(
|
|
25
|
-
|
|
32
|
+
const match = /^(\d+(?:\.\d*)?|\.\d+)([^\d.]+)/.exec(rest);
|
|
33
|
+
const unit = match === null ? void 0 : durationUnits.get(match[2]);
|
|
34
|
+
if (match === null || unit === void 0) throw new UsageError(t("commands.device.logs.invalidDuration", {
|
|
26
35
|
value: JSON.stringify(text),
|
|
27
36
|
option
|
|
28
37
|
}));
|
|
29
|
-
total += Number(match[1]) *
|
|
38
|
+
total += Number(match[1]) * unit;
|
|
30
39
|
rest = rest.slice(match[0].length);
|
|
31
40
|
}
|
|
32
41
|
return total;
|
|
33
42
|
}
|
|
34
43
|
function parseCount(text, option) {
|
|
35
44
|
if (text === void 0) return;
|
|
36
|
-
if (!/^\d+$/.test(text) || Number(text) > 4294967295) throw new UsageError(
|
|
45
|
+
if (!/^\d+$/.test(text) || Number(text) > 4294967295) throw new UsageError(t("commands.device.logs.invalidNumber", {
|
|
37
46
|
value: JSON.stringify(text),
|
|
38
47
|
option
|
|
39
48
|
}));
|
|
40
49
|
return Number(text);
|
|
41
50
|
}
|
|
42
|
-
|
|
51
|
+
async function readLogs(context) {
|
|
43
52
|
const { options } = context;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
request.since = timestampFromMs(Date.now() - options.since);
|
|
59
|
-
if (options.tail === void 0) request.tail = 4294967295;
|
|
60
|
-
}
|
|
61
|
-
for await (const response of client.logs.readLogs(request, { signal: context.signal })) printLog(response.entry, true);
|
|
62
|
-
});
|
|
53
|
+
const tail = parseCount(options.tail, "--tail");
|
|
54
|
+
const since = parseDuration(options.since, "--since");
|
|
55
|
+
const level = levels.get(options.level ?? "info");
|
|
56
|
+
if (level === void 0) throw new UsageError(t("commands.device.logs.invalidLevel"));
|
|
57
|
+
await session(context, async (client) => {
|
|
58
|
+
for await (const response of client.logs.readLogs({
|
|
59
|
+
follow: options.follow,
|
|
60
|
+
tail: tail ?? (since > 0 ? 4294967295 : 100),
|
|
61
|
+
swipletId: options.swiplet ?? "",
|
|
62
|
+
level,
|
|
63
|
+
since: since > 0 ? timestampFromMs(Date.now() - since) : void 0
|
|
64
|
+
}, { signal: context.signal })) printLog(response.entry ?? create(LogEntrySchema), true);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
63
67
|
const logs = defineCommand({
|
|
64
68
|
name: "logs",
|
|
65
|
-
short:
|
|
69
|
+
short: t("commands.device.logs.description"),
|
|
66
70
|
args: [0, 0],
|
|
67
71
|
options: {
|
|
68
72
|
...deviceOption,
|
|
69
73
|
follow: {
|
|
70
74
|
type: "boolean",
|
|
71
|
-
help:
|
|
75
|
+
help: t("commands.device.logs.follow")
|
|
72
76
|
},
|
|
73
77
|
tail: {
|
|
74
78
|
type: "string",
|
|
75
79
|
value: "COUNT",
|
|
76
|
-
help:
|
|
80
|
+
help: t("commands.device.logs.count")
|
|
77
81
|
},
|
|
78
82
|
since: {
|
|
79
83
|
type: "string",
|
|
80
84
|
value: "DURATION",
|
|
81
|
-
help:
|
|
85
|
+
help: t("commands.device.logs.since")
|
|
82
86
|
},
|
|
83
87
|
level: {
|
|
84
88
|
type: "string",
|
|
85
89
|
value: "LEVEL",
|
|
86
|
-
help:
|
|
90
|
+
help: t("commands.device.logs.level")
|
|
87
91
|
},
|
|
88
92
|
swiplet: {
|
|
89
93
|
type: "string",
|
|
90
94
|
value: "ID",
|
|
91
|
-
help:
|
|
95
|
+
help: t("commands.device.logs.swiplet")
|
|
92
96
|
}
|
|
93
97
|
},
|
|
94
|
-
parse: (options) => ({
|
|
95
|
-
...options,
|
|
96
|
-
tail: parseCount(options.tail, "--tail"),
|
|
97
|
-
since: parseDuration(options.since, "--since"),
|
|
98
|
-
level: options.level ?? "info"
|
|
99
|
-
}),
|
|
100
98
|
run: readLogs
|
|
101
99
|
});
|
|
102
100
|
export { logs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","names":[],"sources":["../../../../src/cli/commands/device/logs.ts"],"sourcesContent":["import { timestampFromMs } from \"@bufbuild/protobuf/wkt\";\n\nimport { UsageError } from \"../../../client\";\nimport {
|
|
1
|
+
{"version":3,"file":"logs.js","names":[],"sources":["../../../../src/cli/commands/device/logs.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport { timestampFromMs } from \"@bufbuild/protobuf/wkt\";\n\nimport { UsageError } from \"../../../client\";\nimport { t } from \"../../../i18n\";\nimport { printLog } from \"../../../output\";\nimport { LogEntrySchema, LogLevel } from \"../../../proto/common_pb\";\nimport { type Context, defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\nimport { deviceOption } from \"../flags\";\n\nconst durationUnits = new Map([\n [\"ns\", 1e-6],\n [\"us\", 1e-3],\n [\"µs\", 1e-3],\n [\"ms\", 1],\n [\"s\", 1000],\n [\"m\", 60_000],\n [\"h\", 3_600_000],\n]);\n\nconst levels = new Map([\n [\"error\", LogLevel.ERROR],\n [\"warn\", LogLevel.WARN],\n [\"info\", LogLevel.INFO],\n [\"debug\", LogLevel.DEBUG],\n]);\n\nfunction parseDuration(text: string | undefined, option: string) {\n if (text === undefined) {\n return 0;\n }\n if (/^-?\\d+$/.test(text) && Number(text) === 0) {\n return 0;\n }\n let total = 0;\n let rest = text;\n while (rest !== \"\") {\n const match = /^(\\d+(?:\\.\\d*)?|\\.\\d+)([^\\d.]+)/.exec(rest);\n const unit = match === null ? undefined : durationUnits.get(match[2]);\n if (match === null || unit === undefined) {\n throw new UsageError(\n t(\"commands.device.logs.invalidDuration\", {\n value: JSON.stringify(text),\n option,\n }),\n );\n }\n total += Number(match[1]) * unit;\n rest = rest.slice(match[0].length);\n }\n return total;\n}\n\nfunction parseCount(text: string | undefined, option: string) {\n if (text === undefined) {\n return undefined;\n }\n if (!/^\\d+$/.test(text) || Number(text) > 0xffffffff) {\n throw new UsageError(\n t(\"commands.device.logs.invalidNumber\", {\n value: JSON.stringify(text),\n option,\n }),\n );\n }\n return Number(text);\n}\n\nasync function readLogs(\n context: Context<{\n device?: string;\n follow?: boolean;\n tail?: string;\n since?: string;\n level?: string;\n swiplet?: string;\n }>,\n) {\n const { options } = context;\n const tail = parseCount(options.tail, \"--tail\");\n const since = parseDuration(options.since, \"--since\");\n const level = levels.get(options.level ?? \"info\");\n if (level === undefined) {\n throw new UsageError(t(\"commands.device.logs.invalidLevel\"));\n }\n await session(context, async (client) => {\n for await (const response of client.logs.readLogs(\n {\n follow: options.follow,\n tail: tail ?? (since > 0 ? 0xffffffff : 100),\n swipletId: options.swiplet ?? \"\",\n level,\n since: since > 0 ? timestampFromMs(Date.now() - since) : undefined,\n },\n { signal: context.signal },\n )) {\n printLog(response.entry ?? create(LogEntrySchema), true);\n }\n });\n}\n\nexport const logs = defineCommand({\n name: \"logs\",\n short: t(\"commands.device.logs.description\"),\n args: [0, 0],\n options: {\n ...deviceOption,\n follow: { type: \"boolean\", help: t(\"commands.device.logs.follow\") },\n tail: {\n type: \"string\",\n value: \"COUNT\",\n help: t(\"commands.device.logs.count\"),\n },\n since: {\n type: \"string\",\n value: \"DURATION\",\n help: t(\"commands.device.logs.since\"),\n },\n level: {\n type: \"string\",\n value: \"LEVEL\",\n help: t(\"commands.device.logs.level\"),\n },\n swiplet: {\n type: \"string\",\n value: \"ID\",\n help: t(\"commands.device.logs.swiplet\"),\n },\n },\n run: readLogs,\n});\n"],"mappings":";;;;;;;;;;AAWA,MAAM,gCAAgB,IAAI,IAAI;CAC5B,CAAC,MAAM,IAAI;CACX,CAAC,MAAM,IAAI;CACX,CAAC,MAAM,IAAI;CACX,CAAC,MAAM,CAAC;CACR,CAAC,KAAK,GAAI;CACV,CAAC,KAAK,GAAM;CACZ,CAAC,KAAK,IAAS;AACjB,CAAC;AAED,MAAM,yBAAS,IAAI,IAAI;CACrB,CAAC,SAAA,CAAuB;CACxB,CAAC,QAAA,CAAqB;CACtB,CAAC,QAAA,CAAqB;CACtB,CAAC,SAAA,CAAuB;AAC1B,CAAC;AAED,SAAS,cAAc,MAA0B,QAAgB;CAC/D,IAAI,SAAS,KAAA,GACX,OAAO;CAET,IAAI,UAAU,KAAK,IAAI,KAAK,OAAO,IAAI,MAAM,GAC3C,OAAO;CAET,IAAI,QAAQ;CACZ,IAAI,OAAO;CACX,OAAO,SAAS,IAAI;EAClB,MAAM,QAAQ,kCAAkC,KAAK,IAAI;EACzD,MAAM,OAAO,UAAU,OAAO,KAAA,IAAY,cAAc,IAAI,MAAM,EAAE;EACpE,IAAI,UAAU,QAAQ,SAAS,KAAA,GAC7B,MAAM,IAAI,WACR,EAAE,wCAAwC;GACxC,OAAO,KAAK,UAAU,IAAI;GAC1B;EACF,CAAC,CACH;EAEF,SAAS,OAAO,MAAM,EAAE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OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM,EAAE,4BAA4B;EACtC;EACA,SAAS;GACP,MAAM;GACN,OAAO;GACP,MAAM,EAAE,8BAA8B;EACxC;CACF;CACA,KAAK;AACP,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { remove as remove$1 } from "../../../connection.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
// src/cli/commands/device/remove.ts
|
|
5
5
|
const remove = defineCommand({
|
|
6
6
|
name: "remove",
|
|
7
7
|
use: "remove NAME",
|
|
8
|
-
short:
|
|
8
|
+
short: t("commands.device.remove.description"),
|
|
9
9
|
args: [1, 1],
|
|
10
10
|
run: remove$1
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.js","names":["connection.remove"],"sources":["../../../../src/cli/commands/device/remove.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport {
|
|
1
|
+
{"version":3,"file":"remove.js","names":["connection.remove"],"sources":["../../../../src/cli/commands/device/remove.ts"],"sourcesContent":["import * as connection from \"../../../connection\";\nimport { t } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\n\nexport const remove = defineCommand({\n name: \"remove\",\n use: \"remove NAME\",\n short: t(\"commands.device.remove.description\"),\n args: [1, 1],\n run: connection.remove,\n});\n"],"mappings":";;;;AAIA,MAAa,SAAS,cAAc;CAClC,MAAM;CACN,KAAK;CACL,OAAO,EAAE,oCAAoC;CAC7C,MAAM,CAAC,GAAG,CAAC;CACX,KAAKA;AACP,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../../i18n.js";
|
|
2
2
|
import { defineCommand } from "../../command.js";
|
|
3
3
|
import { session } from "../../session.js";
|
|
4
4
|
import { deviceOption } from "../flags.js";
|
|
5
5
|
// src/cli/commands/device/stop.ts
|
|
6
6
|
const stopServing = (context) => session(context, async (client) => {
|
|
7
7
|
await client.system.shutdown({}, { signal: context.signal });
|
|
8
|
-
console.log(
|
|
8
|
+
console.log(t("commands.device.stop.stopped"));
|
|
9
9
|
});
|
|
10
10
|
const stop = defineCommand({
|
|
11
11
|
name: "stop",
|
|
12
|
-
short:
|
|
12
|
+
short: t("commands.device.stop.description"),
|
|
13
13
|
args: [0, 0],
|
|
14
14
|
options: deviceOption,
|
|
15
15
|
run: stopServing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop.js","names":[],"sources":["../../../../src/cli/commands/device/stop.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"stop.js","names":[],"sources":["../../../../src/cli/commands/device/stop.ts"],"sourcesContent":["import { t } from \"../../../i18n\";\nimport { type Context, defineCommand } from \"../../command\";\nimport { session } from \"../../session\";\nimport { deviceOption } from \"../flags\";\n\nconst stopServing = (context: Context<{ device?: string }>) =>\n session(context, async (client) => {\n await client.system.shutdown({}, { signal: context.signal });\n console.log(t(\"commands.device.stop.stopped\"));\n });\n\nexport const stop = defineCommand({\n name: \"stop\",\n short: t(\"commands.device.stop.description\"),\n args: [0, 0],\n options: deviceOption,\n run: stopServing,\n});\n"],"mappings":";;;;;AAKA,MAAM,eAAe,YACnB,QAAQ,SAAS,OAAO,WAAW;CACjC,MAAM,OAAO,OAAO,SAAS,CAAC,GAAG,EAAE,QAAQ,QAAQ,OAAO,CAAC;CAC3D,QAAQ,IAAI,EAAE,8BAA8B,CAAC;AAC/C,CAAC;AAEH,MAAa,OAAO,cAAc;CAChC,MAAM;CACN,OAAO,EAAE,kCAAkC;CAC3C,MAAM,CAAC,GAAG,CAAC;CACX,SAAS;CACT,KAAK;AACP,CAAC"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { run } from "../../../serve.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t } from "../../../i18n.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
import { passcodeOptions, udidDeviceOption } from "../flags.js";
|
|
5
5
|
// src/cli/commands/driver/driver.ts
|
|
6
6
|
const driver = defineCommand({
|
|
7
7
|
name: "driver",
|
|
8
|
-
short:
|
|
9
|
-
description: [
|
|
8
|
+
short: t("commands.driver.description"),
|
|
9
|
+
description: [t("commands.driver.details")],
|
|
10
10
|
args: [0, 0],
|
|
11
11
|
options: {
|
|
12
12
|
...udidDeviceOption,
|
|
13
|
-
...passcodeOptions(
|
|
13
|
+
...passcodeOptions(t("commands.driver.passcode")),
|
|
14
14
|
token: {
|
|
15
15
|
type: "string",
|
|
16
16
|
value: "TOKEN",
|
|
17
|
-
help:
|
|
17
|
+
help: t("commands.driver.token")
|
|
18
18
|
},
|
|
19
19
|
"random-token": {
|
|
20
20
|
type: "boolean",
|
|
21
|
-
help:
|
|
21
|
+
help: t("commands.driver.randomToken")
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
run
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","names":["serving.run"],"sources":["../../../../src/cli/commands/driver/driver.ts"],"sourcesContent":["import * as serving from \"../../../serve\";\nimport {
|
|
1
|
+
{"version":3,"file":"driver.js","names":["serving.run"],"sources":["../../../../src/cli/commands/driver/driver.ts"],"sourcesContent":["import * as serving from \"../../../serve\";\nimport { t } from \"../../../i18n\";\nimport { defineCommand } from \"../../command\";\nimport { passcodeOptions, udidDeviceOption } from \"../flags\";\n\nexport const driver = defineCommand({\n name: \"driver\",\n short: t(\"commands.driver.description\"),\n description: [t(\"commands.driver.details\")],\n args: [0, 0],\n options: {\n ...udidDeviceOption,\n ...passcodeOptions(t(\"commands.driver.passcode\")),\n token: {\n type: \"string\",\n value: \"TOKEN\",\n help: t(\"commands.driver.token\"),\n },\n \"random-token\": {\n type: \"boolean\",\n help: t(\"commands.driver.randomToken\"),\n },\n },\n run: serving.run,\n});\n"],"mappings":";;;;;AAKA,MAAa,SAAS,cAAc;CAClC,MAAM;CACN,OAAO,EAAE,6BAA6B;CACtC,aAAa,CAAC,EAAE,yBAAyB,CAAC;CAC1C,MAAM,CAAC,GAAG,CAAC;CACX,SAAS;EACP,GAAG;EACH,GAAG,gBAAgB,EAAE,0BAA0B,CAAC;EAChD,OAAO;GACL,MAAM;GACN,OAAO;GACP,MAAM,EAAE,uBAAuB;EACjC;EACA,gBAAgB;GACd,MAAM;GACN,MAAM,EAAE,6BAA6B;EACvC;CACF;CACKA;AACP,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../i18n.js";
|
|
2
2
|
// src/cli/commands/flags.ts
|
|
3
3
|
const deviceOption = { device: {
|
|
4
4
|
type: "string",
|
|
5
5
|
short: "d",
|
|
6
6
|
value: "NAME|URL",
|
|
7
|
-
help:
|
|
7
|
+
help: t("flags.device")
|
|
8
8
|
} };
|
|
9
9
|
const udidDeviceOption = { device: {
|
|
10
10
|
type: "string",
|
|
11
11
|
short: "d",
|
|
12
12
|
value: "NAME|UDID",
|
|
13
|
-
help:
|
|
13
|
+
help: t("flags.device")
|
|
14
14
|
} };
|
|
15
15
|
const sideloadOptions = {
|
|
16
16
|
...udidDeviceOption,
|
|
17
17
|
team: {
|
|
18
18
|
type: "string",
|
|
19
19
|
value: "ID",
|
|
20
|
-
help:
|
|
20
|
+
help: t("flags.team")
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
const passcodeOptions = (help) => ({
|
|
@@ -29,27 +29,27 @@ const passcodeOptions = (help) => ({
|
|
|
29
29
|
"passcode-type": {
|
|
30
30
|
type: "string",
|
|
31
31
|
value: "TYPE",
|
|
32
|
-
help:
|
|
32
|
+
help: t("flags.passcodeType")
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
const nightlyOption = { nightly: {
|
|
36
36
|
type: "boolean",
|
|
37
|
-
help:
|
|
37
|
+
help: t("flags.nightly")
|
|
38
38
|
} };
|
|
39
39
|
const setupStepOptions = {
|
|
40
40
|
"no-setup-pair": {
|
|
41
41
|
type: "boolean",
|
|
42
|
-
help:
|
|
42
|
+
help: t("flags.noSetupPair")
|
|
43
43
|
},
|
|
44
44
|
"no-setup-api": {
|
|
45
45
|
type: "boolean",
|
|
46
|
-
help:
|
|
46
|
+
help: t("flags.noSetupAPI")
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const setupOptions = {
|
|
50
50
|
"no-setup": {
|
|
51
51
|
type: "boolean",
|
|
52
|
-
help:
|
|
52
|
+
help: t("flags.noSetup")
|
|
53
53
|
},
|
|
54
54
|
...setupStepOptions
|
|
55
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","names":[],"sources":["../../../src/cli/commands/flags.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"flags.js","names":[],"sources":["../../../src/cli/commands/flags.ts"],"sourcesContent":["import { t } from \"../../i18n\";\nimport type { Options } from \"../command\";\n\nexport const deviceOption: Options = {\n device: {\n type: \"string\",\n short: \"d\",\n value: \"NAME|URL\",\n help: t(\"flags.device\"),\n },\n};\n\nexport const udidDeviceOption: Options = {\n device: {\n type: \"string\",\n short: \"d\",\n value: \"NAME|UDID\",\n help: t(\"flags.device\"),\n },\n};\n\nexport const sideloadOptions: Options = {\n ...udidDeviceOption,\n team: {\n type: \"string\",\n value: \"ID\",\n help: t(\"flags.team\"),\n },\n};\n\nexport const passcodeOptions = (help: string): Options => ({\n passcode: { type: \"string\", value: \"CODE\", help },\n \"passcode-type\": {\n type: \"string\",\n value: \"TYPE\",\n help: t(\"flags.passcodeType\"),\n },\n});\n\nexport const nightlyOption: Options = {\n nightly: { type: \"boolean\", help: t(\"flags.nightly\") },\n};\n\nexport const setupStepOptions: Options = {\n \"no-setup-pair\": { type: \"boolean\", help: t(\"flags.noSetupPair\") },\n \"no-setup-api\": {\n type: \"boolean\",\n help: t(\"flags.noSetupAPI\"),\n },\n};\n\nexport const setupOptions: Options = {\n \"no-setup\": {\n type: \"boolean\",\n help: t(\"flags.noSetup\"),\n },\n ...setupStepOptions,\n};\n"],"mappings":";;AAGA,MAAa,eAAwB,EACnC,QAAQ;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM,EAAE,cAAc;AACxB,EACF;AAEA,MAAa,mBAA4B,EACvC,QAAQ;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM,EAAE,cAAc;AACxB,EACF;AAEA,MAAa,kBAA2B;CACtC,GAAG;CACH,MAAM;EACJ,MAAM;EACN,OAAO;EACP,MAAM,EAAE,YAAY;CACtB;AACF;AAEA,MAAa,mBAAmB,UAA2B;CACzD,UAAU;EAAE,MAAM;EAAU,OAAO;EAAQ;CAAK;CAChD,iBAAiB;EACf,MAAM;EACN,OAAO;EACP,MAAM,EAAE,oBAAoB;CAC9B;AACF;AAEA,MAAa,gBAAyB,EACpC,SAAS;CAAE,MAAM;CAAW,MAAM,EAAE,eAAe;AAAE,EACvD;AAEA,MAAa,mBAA4B;CACvC,iBAAiB;EAAE,MAAM;EAAW,MAAM,EAAE,mBAAmB;CAAE;CACjE,gBAAgB;EACd,MAAM;EACN,MAAM,EAAE,kBAAkB;CAC5B;AACF;AAEA,MAAa,eAAwB;CACnC,YAAY;EACV,MAAM;EACN,MAAM,EAAE,eAAe;CACzB;CACA,GAAG;AACL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../i18n.js";
|
|
2
2
|
import { defineCommand } from "../command.js";
|
|
3
3
|
import { device } from "./device/device.js";
|
|
4
4
|
import "./device/index.js";
|
|
@@ -17,7 +17,7 @@ import "./version/index.js";
|
|
|
17
17
|
// src/cli/commands/index.ts
|
|
18
18
|
const root = defineCommand({
|
|
19
19
|
name: "swipt",
|
|
20
|
-
short:
|
|
20
|
+
short: t("commands.description"),
|
|
21
21
|
commands: [
|
|
22
22
|
project,
|
|
23
23
|
device,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/commands/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/commands/index.ts"],"sourcesContent":["import { t } from \"../../i18n\";\nimport { defineCommand } from \"../command\";\nimport { device } from \"./device\";\nimport { driver } from \"./driver\";\nimport { project } from \"./project\";\nimport { repl } from \"./repl\";\nimport { sideload } from \"./sideload\";\nimport { swiplet } from \"./swiplet\";\nimport { version } from \"./version\";\n\nexport const root = defineCommand({\n name: \"swipt\",\n short: t(\"commands.description\"),\n commands: [project, device, swiplet, repl, driver, sideload, version],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAa,OAAO,cAAc;CAChC,MAAM;CACN,OAAO,EAAE,sBAAsB;CAC/B,UAAU;EAAC;EAAS;EAAQ;EAAS;EAAM;EAAQ;EAAU;CAAO;AACtE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t } from "../../../i18n.js";
|
|
2
2
|
import { buildProject } from "../../../project.js";
|
|
3
3
|
import { defineCommand } from "../../command.js";
|
|
4
4
|
import path from "node:path";
|
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
const build = defineCommand({
|
|
7
7
|
name: "build",
|
|
8
8
|
use: "build [PROJECT]",
|
|
9
|
-
short:
|
|
9
|
+
short: t("commands.project.build.description"),
|
|
10
10
|
args: [0, 1],
|
|
11
11
|
run: async ({ args }) => {
|
|
12
12
|
const { archive } = await buildProject(path.resolve(args[0] ?? "."));
|