@pmate/cli 0.24.13 → 0.24.14

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/index.d.ts CHANGED
@@ -902,7 +902,7 @@ type ServiceCommandArgs = {
902
902
  json: boolean;
903
903
  } | {
904
904
  type: Command.Service;
905
- action: "deploy";
905
+ action: "deploy" | "stop";
906
906
  namespace: string;
907
907
  name: string;
908
908
  baseUrl?: string;
package/dist/index.js CHANGED
@@ -18055,6 +18055,24 @@ var ServiceRuntimeRunner = class {
18055
18055
  throw new Error(`Unsupported service type for deploy: ${this.getType(service)}`);
18056
18056
  }
18057
18057
  }
18058
+ async stop(service) {
18059
+ switch (this.getType(service)) {
18060
+ case "rust":
18061
+ case "python":
18062
+ await this.stopScriptManaged(service);
18063
+ return;
18064
+ case "node":
18065
+ throw new Error("service stop is only supported for script-managed python/rust services for now");
18066
+ case "vite":
18067
+ case "static":
18068
+ case "fc":
18069
+ case "ios":
18070
+ case "android":
18071
+ throw new Error(`Service type "${this.getType(service)}" does not support stop`);
18072
+ default:
18073
+ throw new Error(`Unsupported service type for stop: ${this.getType(service)}`);
18074
+ }
18075
+ }
18058
18076
  async init(service, options = {}) {
18059
18077
  switch (this.getType(service)) {
18060
18078
  case "vite":
@@ -18490,6 +18508,32 @@ var ServiceRuntimeRunner = class {
18490
18508
  ].join(" && ");
18491
18509
  await this.runRemoteCommand(server, command);
18492
18510
  }
18511
+ async stopScriptManaged(service) {
18512
+ const network = this.getNetwork(service);
18513
+ const runner = this.getRunner(service);
18514
+ const server = network.server?.trim();
18515
+ const repository = network.repository?.trim();
18516
+ const script = runner.script?.trim();
18517
+ if (!server) {
18518
+ throw new Error(`Missing network.server for ${service.id}`);
18519
+ }
18520
+ if (!repository) {
18521
+ throw new Error(`Missing network.repository for ${service.id}`);
18522
+ }
18523
+ if (!script) {
18524
+ throw new Error(`Missing runner.script for ${service.id}`);
18525
+ }
18526
+ const repoDir = this.getRepoDirName(repository);
18527
+ const scriptPath = script.startsWith("/") || script.startsWith("./") ? script : `./${script}`;
18528
+ const command = [
18529
+ `cd "$HOME"`,
18530
+ `cd "${repoDir}"`,
18531
+ `if [ -f ~/.profile ]; then . ~/.profile; fi`,
18532
+ `if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,
18533
+ `"${scriptPath}" stop`
18534
+ ].join(" && ");
18535
+ await this.runRemoteCommand(server, command);
18536
+ }
18493
18537
  async initStaticLike(service) {
18494
18538
  const site = this.getSite(service);
18495
18539
  const bucketName = site.bucket?.trim();
@@ -19411,6 +19455,11 @@ var ServiceCommandHandler = class {
19411
19455
  await runtime.deploy(record);
19412
19456
  return;
19413
19457
  }
19458
+ case "stop": {
19459
+ const record = await registry.getService(args.namespace, args.name);
19460
+ await runtime.stop(record);
19461
+ return;
19462
+ }
19414
19463
  case "init": {
19415
19464
  const record = await registry.getService(args.namespace, args.name);
19416
19465
  await runtime.init(record, { cwd: args.cwd });
@@ -21979,7 +22028,7 @@ function parseServiceArgs(tokens) {
21979
22028
  }
21980
22029
  const action = rawAction === "view" ? "view" : rawAction;
21981
22030
  if (!action) {
21982
- throw new Error("Missing service action. Use: service list|get|view|create|update|rename|delete");
22031
+ throw new Error("Missing service action. Use: service list|get|view|create|update|rename|delete|deploy|stop|init|log");
21983
22032
  }
21984
22033
  let baseUrl;
21985
22034
  let json = false;
@@ -22036,7 +22085,7 @@ function parseServiceArgs(tokens) {
22036
22085
  json
22037
22086
  };
22038
22087
  }
22039
- if (action === "get" || action === "delete" || action === "deploy" || action === "init" || action === "log") {
22088
+ if (action === "get" || action === "delete" || action === "deploy" || action === "stop" || action === "init" || action === "log") {
22040
22089
  const ref = rest.shift();
22041
22090
  if (!ref || ref.startsWith("-")) {
22042
22091
  throw new Error(`Usage: service ${action} <ns:objectId> [--base-url <url>] [--json]`);
@@ -22084,7 +22133,7 @@ function parseServiceArgs(tokens) {
22084
22133
  if (action === "log") {
22085
22134
  return { type: "service" /* Service */, action, namespace, name, baseUrl, json, page, history, search, follow };
22086
22135
  }
22087
- if (action === "deploy") {
22136
+ if (action === "deploy" || action === "stop") {
22088
22137
  return { type: "service" /* Service */, action, namespace, name, baseUrl, json };
22089
22138
  }
22090
22139
  if (action === "init") {
@@ -23742,6 +23791,7 @@ var HELP_TEXT = [
23742
23791
  ` ${import_chalk4.default.gray(" move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]")}`,
23743
23792
  ` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
23744
23793
  ` ${import_chalk4.default.gray(" deploy <ns:objectId> [--base-url <url>]")}`,
23794
+ ` ${import_chalk4.default.gray(" stop <ns:objectId> [--base-url <url>]")}`,
23745
23795
  ` ${import_chalk4.default.gray(" init <ns:objectId> [--cwd <dir>] [--base-url <url>]")}`,
23746
23796
  ` ${import_chalk4.default.gray(" log <ns:objectId> [--page <n>] [--history] [--search <keyword>] [--follow|-f] [--base-url <url>]")}`,
23747
23797
  ` ${import_chalk4.default.gray(" default base URL: https://apps-api.pmate.chat")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.24.13",
3
+ "version": "0.24.14",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {