@putdotio/taizn 1.4.0 → 1.5.0

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 CHANGED
@@ -48,6 +48,7 @@ Project files:
48
48
  taizn check
49
49
  taizn apps
50
50
  taizn apps put
51
+ taizn launch GinifYRGmZ.putio
51
52
  taizn profile
52
53
  taizn package
53
54
  taizn install
@@ -61,7 +62,8 @@ taizn --version
61
62
 
62
63
  `check` verifies the configured Tizen CLI and `sdb`, then prints connected
63
64
  targets without requiring `taizn.json`. `apps` lists installed applications on
64
- the target, with an optional query filter. `profile` imports
65
+ the target, with an optional query filter. `launch` starts an already-installed
66
+ application by exact application ID, exact name, or a unique query. `profile` imports
65
67
  `.taizn/certificates/author.p12` and
66
68
  `.taizn/certificates/distributor.p12` into a Tizen security profile.
67
69
  `package` builds and signs a `.wgt`. `install` packages and sideloads it.
package/dist/taizn.mjs CHANGED
@@ -57,6 +57,19 @@ var CommandFailed = class extends Schema.TaggedErrorClass()("CommandFailed", {
57
57
  return `Command failed: ${this.command} ${this.args.join(" ")}`;
58
58
  }
59
59
  };
60
+ var ApplicationNotFound = class extends Schema.TaggedErrorClass()("ApplicationNotFound", { query: Schema.String }) {
61
+ get message() {
62
+ return `No installed Tizen application matched "${this.query}".`;
63
+ }
64
+ };
65
+ var MultipleApplicationsMatched = class extends Schema.TaggedErrorClass()("MultipleApplicationsMatched", {
66
+ matches: Schema.Array(Schema.String),
67
+ query: Schema.String
68
+ }) {
69
+ get message() {
70
+ return `Multiple installed Tizen applications matched "${this.query}": ${this.matches.join(", ")}. Use the application ID.`;
71
+ }
72
+ };
60
73
  var PackageNotProduced = class extends Schema.TaggedErrorClass()("PackageNotProduced", { outputDir: Schema.String }) {
61
74
  get message() {
62
75
  return `No .wgt package was produced in ${this.outputDir}`;
@@ -799,19 +812,10 @@ const runWidget = Effect.fn("runWidget")(function* ({ config, env }) {
799
812
  yield* Console.log(`Launched ${variant.applicationId}`);
800
813
  });
801
814
  const listInstalledApplications = Effect.fn("listInstalledApplications")(function* (env, query) {
802
- const sdbPath = yield* resolveSdb(env);
803
- if (env.target) yield* run$1(sdbPath, ["connect", env.target], { env: yield* baseChildEnv() });
804
- const target = yield* resolveRequiredSdbTarget(env, sdbPath);
805
- const output = yield* capture(sdbPath, [
806
- "-s",
807
- target,
808
- "shell",
809
- "0",
810
- "applist"
811
- ]);
815
+ const { applications: installedApplications, target } = yield* loadInstalledApplications(env);
812
816
  const queryLabel = query?.trim();
813
817
  const normalizedQuery = normalizeQuery(queryLabel);
814
- const applications = parseInstalledApplications(output).filter((application) => matchesApplicationQuery(application, normalizedQuery));
818
+ const applications = installedApplications.filter((application) => matchesApplicationQuery(application, normalizedQuery));
815
819
  const suffix = queryLabel ? ` matching "${queryLabel}"` : "";
816
820
  yield* Console.log(`Installed Tizen applications${suffix} on ${target}:`);
817
821
  if (applications.length === 0) {
@@ -820,6 +824,19 @@ const listInstalledApplications = Effect.fn("listInstalledApplications")(functio
820
824
  }
821
825
  for (const application of applications) yield* Console.log(`- ${application.name} (${application.applicationId})`);
822
826
  });
827
+ const launchInstalledApplication = Effect.fn("launchInstalledApplication")(function* (env, query) {
828
+ const tizenPath = yield* resolveTizenCli(env);
829
+ const { applications, target } = yield* loadInstalledApplications(env);
830
+ const application = yield* resolveInstalledApplication(query, applications);
831
+ yield* run$1(tizenPath, [
832
+ "run",
833
+ "-p",
834
+ application.applicationId,
835
+ "-s",
836
+ target
837
+ ], { env: yield* baseChildEnv() });
838
+ yield* Console.log(`Launched ${application.name} (${application.applicationId}) on ${target}`);
839
+ });
823
840
  const resolveTizenCli = Effect.fn("resolveTizenCli")(function* (env) {
824
841
  return yield* requireFile(env.tizenCli ?? (yield* defaultTizenCli()), "Tizen CLI");
825
842
  });
@@ -1011,6 +1028,21 @@ const resolveRequiredSdbTarget = Effect.fn("resolveRequiredSdbTarget")(function*
1011
1028
  if (devices.length > 1) return yield* MultipleTargetsConnected.make({ targets: devices.map((device) => device.id) });
1012
1029
  return yield* MissingTizenTarget.make({});
1013
1030
  });
1031
+ const loadInstalledApplications = Effect.fn("loadInstalledApplications")(function* (env) {
1032
+ const sdbPath = yield* resolveSdb(env);
1033
+ if (env.target) yield* run$1(sdbPath, ["connect", env.target], { env: yield* baseChildEnv() });
1034
+ const target = yield* resolveRequiredSdbTarget(env, sdbPath);
1035
+ return {
1036
+ applications: parseInstalledApplications(yield* capture(sdbPath, [
1037
+ "-s",
1038
+ target,
1039
+ "shell",
1040
+ "0",
1041
+ "applist"
1042
+ ])),
1043
+ target
1044
+ };
1045
+ });
1014
1046
  const parseInstalledApplications = (output) => output.split("\n").flatMap((line) => {
1015
1047
  const match = line.match(/^\s*'([^']*)'\s+'([^']*)'\s*$/);
1016
1048
  const name = match?.[1]?.trim();
@@ -1022,6 +1054,32 @@ const parseInstalledApplications = (output) => output.split("\n").flatMap((line)
1022
1054
  });
1023
1055
  const normalizeQuery = (query) => query?.trim().toLowerCase();
1024
1056
  const matchesApplicationQuery = (application, normalizedQuery) => !normalizedQuery || application.name.toLowerCase().includes(normalizedQuery) || application.applicationId.toLowerCase().includes(normalizedQuery);
1057
+ const resolveInstalledApplication = Effect.fn("resolveInstalledApplication")(function* (query, applications) {
1058
+ const queryLabel = query.trim();
1059
+ const normalizedQuery = normalizeQuery(queryLabel);
1060
+ if (!normalizedQuery) return yield* ApplicationNotFound.make({ query });
1061
+ const exactMatch = applications.find((application) => application.applicationId.toLowerCase() === normalizedQuery);
1062
+ if (exactMatch) return exactMatch;
1063
+ const exactNameMatches = applications.filter((application) => application.name.toLowerCase() === normalizedQuery);
1064
+ if (exactNameMatches.length === 1) {
1065
+ const [match] = exactNameMatches;
1066
+ if (match) return match;
1067
+ }
1068
+ if (exactNameMatches.length > 1) return yield* MultipleApplicationsMatched.make({
1069
+ matches: exactNameMatches.map((application) => `${application.name} (${application.applicationId})`),
1070
+ query: queryLabel
1071
+ });
1072
+ const matches = applications.filter((application) => matchesApplicationQuery(application, normalizedQuery));
1073
+ if (matches.length === 1) {
1074
+ const [match] = matches;
1075
+ if (match) return match;
1076
+ }
1077
+ if (matches.length > 1) return yield* MultipleApplicationsMatched.make({
1078
+ matches: matches.map((application) => `${application.name} (${application.applicationId})`),
1079
+ query: queryLabel
1080
+ });
1081
+ return yield* ApplicationNotFound.make({ query: queryLabel });
1082
+ });
1025
1083
  const run$1 = Effect.fn("run")(function* (command, args, options) {
1026
1084
  const paths = yield* getPaths();
1027
1085
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
@@ -1082,6 +1140,9 @@ const check = Command.make("check", {}, () => Effect.gen(function* () {
1082
1140
  const apps = Command.make("apps", { query: Argument.string("query").pipe(Argument.optional) }, ({ query }) => Effect.gen(function* () {
1083
1141
  yield* listInstalledApplications(yield* loadEnv(), Option.getOrUndefined(query));
1084
1142
  }));
1143
+ const launch = Command.make("launch", { query: Argument.string("query") }, ({ query }) => Effect.gen(function* () {
1144
+ yield* launchInstalledApplication(yield* loadEnv(), query);
1145
+ }));
1085
1146
  const profile = Command.make("profile", {}, () => withContext((context) => createProfile(context)));
1086
1147
  const pack = Command.make("package", {}, () => withContext((context) => packageWidget(context).pipe(Effect.asVoid)));
1087
1148
  const install = Command.make("install", {}, () => withContext((context) => installWidget(context)));
@@ -1106,6 +1167,7 @@ const tv = Command.make("tv", {}).pipe(Command.withSubcommands([
1106
1167
  const command = taizn.pipe(Command.withSubcommands([
1107
1168
  apps,
1108
1169
  check,
1170
+ launch,
1109
1171
  profile,
1110
1172
  pack,
1111
1173
  install,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putdotio/taizn",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A tiny CLI companion for interacting with Tizen ecosystem.",
5
5
  "keywords": [
6
6
  "cli",