create-vidra-app 0.6.1 → 1.0.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
@@ -3,7 +3,7 @@
3
3
  Scaffold a [Vidra](https://vidra.build) desktop app with a web UI and a
4
4
  C#/.NET native host.
5
5
 
6
- > **Alpha:** APIs and templates may change between 0.x releases.
6
+ > **Beta:** APIs and templates may still change between releases.
7
7
 
8
8
  ## Create an app
9
9
 
@@ -42,6 +42,31 @@ npx vidra --help
42
42
  See the [getting started guide](https://vidra.build/docs/getting-started/) for
43
43
  project structure, development, and build options.
44
44
 
45
+ ## Telemetry
46
+
47
+ When it finishes or fails, `create-vidra-app` sends one anonymous event to
48
+ `https://vidra.build/api/telemetry` so we can see how many apps get created and
49
+ where setup breaks. The event contains:
50
+
51
+ - whether the app was created, and if not, which step failed
52
+ - how long scaffolding took, including `npm install` but not the .NET MAUI
53
+ workload check or install
54
+ - whether `npm install` succeeded and the .NET MAUI workload was ready
55
+ - the Vidra version, Node.js version, operating system, and CPU architecture
56
+
57
+ It never includes your project name, app ID, file paths, error messages, or any
58
+ identifier for you or your machine. Nothing else in Vidra sends telemetry.
59
+
60
+ Opt out by setting either variable before running the scaffolder:
61
+
62
+ ```bash
63
+ VIDRA_TELEMETRY=0 npm create vidra-app@latest
64
+ DO_NOT_TRACK=1 npm create vidra-app@latest
65
+ ```
66
+
67
+ Nothing is sent in CI (when `CI` is set). To see exactly what would be sent
68
+ without sending it, set `VIDRA_TELEMETRY_DEBUG=1`.
69
+
45
70
  ## License
46
71
 
47
72
  MIT
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import prompts2 from "prompts";
3
- import fs2 from "fs-extra";
4
- import path2 from "path";
3
+ import fs3 from "fs-extra";
4
+ import path3 from "path";
5
5
  import { randomUUID } from "crypto";
6
6
  import { fileURLToPath } from "url";
7
7
 
@@ -47,57 +47,14 @@ var isInteractive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
47
47
 
48
48
  // ../shared/src/exec.ts
49
49
  import { execFileSync, execSync, spawn } from "child_process";
50
-
51
- // ../shared/src/theme.ts
52
- import chalk from "chalk";
53
- var lime = chalk.hex("#c8f751");
54
- var value = chalk.hex("#e8e8ec");
55
- var dim = chalk.hex("#7a7a86");
56
- var amber = chalk.hex("#ffcf5c");
57
- var green = chalk.hex("#86d98f");
58
- var red = chalk.hex("#ff8585");
59
- var slate = chalk.hex("#a9b0bd");
60
- var uiColor = chalk.hex("#6fd3e0");
61
- var hostColor = chalk.hex("#a48ce8");
62
- var GLYPH_CHAR = {
63
- done: "\u2713",
64
- active: "\u25B8",
65
- error: "\u2717",
66
- manual: "?",
67
- plan: "\u25C6",
68
- skip: "\u2298"
69
- };
70
- var GLYPH_COLOR = {
71
- done: green,
72
- active: lime,
73
- error: red,
74
- manual: amber,
75
- plan: slate,
76
- skip: slate
77
- };
78
- var glyph = (name) => GLYPH_COLOR[name](GLYPH_CHAR[name]);
79
- var wordmark = () => lime("vidra");
80
- var kv = (label, val, width = 9) => ` ${dim(label.padEnd(width))} ${value(val)}`;
81
- var row = (opts) => {
82
- const parts = [` ${glyph(opts.glyph)}`];
83
- if (opts.label !== void 0) {
84
- const padded = opts.labelWidth ? opts.label.padEnd(opts.labelWidth) : opts.label;
85
- parts.push(value(padded));
86
- }
87
- if (opts.detail) parts.push(opts.detail);
88
- return parts.join(" ");
89
- };
90
- var footer = (content) => ` ${content}`;
91
- var fixLine = (cmd, label = "fix:") => ` ${amber(label)} ${lime(cmd)}`;
92
-
93
- // ../shared/src/exec.ts
94
50
  var toText = (value2) => {
95
51
  if (value2 == null) return "";
96
52
  return Buffer.isBuffer(value2) ? value2.toString() : value2;
97
53
  };
98
- var run = (cmd, args) => {
54
+ var run = (cmd, args, cwd) => {
99
55
  try {
100
56
  const stdout = execFileSync(cmd, args, {
57
+ cwd,
101
58
  encoding: "utf-8",
102
59
  stdio: ["ignore", "pipe", "pipe"]
103
60
  });
@@ -121,9 +78,8 @@ var exec = (cmd, cwd) => {
121
78
  try {
122
79
  execSync(cmd, { cwd, stdio: "pipe" });
123
80
  } catch (e) {
124
- console.error(row({ glyph: "error", detail: dim(`command failed: ${cmd}`) }));
125
- console.error(dim(formatProcessError(e)));
126
- process.exit(1);
81
+ throw new Error(`command failed: ${cmd}
82
+ ${formatProcessError(e)}`, { cause: e });
127
83
  }
128
84
  };
129
85
  var tryExecAsync = (cmd, cwd) => new Promise((resolve) => {
@@ -189,8 +145,54 @@ var applyReplacements = (str, replacements) => {
189
145
  };
190
146
 
191
147
  // ../shared/src/dotnet-toolchain.ts
148
+ import fs2 from "fs";
149
+ import path2 from "path";
192
150
  import { execFileSync as execFileSync2 } from "child_process";
193
151
  import prompts from "prompts";
152
+
153
+ // ../shared/src/theme.ts
154
+ import chalk from "chalk";
155
+ var lime = chalk.hex("#c8f751");
156
+ var value = chalk.hex("#e8e8ec");
157
+ var dim = chalk.hex("#7a7a86");
158
+ var amber = chalk.hex("#ffcf5c");
159
+ var green = chalk.hex("#86d98f");
160
+ var red = chalk.hex("#ff8585");
161
+ var slate = chalk.hex("#a9b0bd");
162
+ var uiColor = chalk.hex("#6fd3e0");
163
+ var hostColor = chalk.hex("#a48ce8");
164
+ var GLYPH_CHAR = {
165
+ done: "\u2713",
166
+ active: "\u25B8",
167
+ error: "\u2717",
168
+ manual: "?",
169
+ plan: "\u25C6",
170
+ skip: "\u2298"
171
+ };
172
+ var GLYPH_COLOR = {
173
+ done: green,
174
+ active: lime,
175
+ error: red,
176
+ manual: amber,
177
+ plan: slate,
178
+ skip: slate
179
+ };
180
+ var glyph = (name) => GLYPH_COLOR[name](GLYPH_CHAR[name]);
181
+ var wordmark = () => lime("vidra");
182
+ var kv = (label, val, width = 9) => ` ${dim(label.padEnd(width))} ${value(val)}`;
183
+ var row = (opts) => {
184
+ const parts = [` ${glyph(opts.glyph)}`];
185
+ if (opts.label !== void 0) {
186
+ const padded = opts.labelWidth ? opts.label.padEnd(opts.labelWidth) : opts.label;
187
+ parts.push(value(padded));
188
+ }
189
+ if (opts.detail) parts.push(opts.detail);
190
+ return parts.join(" ");
191
+ };
192
+ var footer = (content) => ` ${content}`;
193
+ var fixLine = (cmd, label = "fix:") => ` ${amber(label)} ${lime(cmd)}`;
194
+
195
+ // ../shared/src/dotnet-toolchain.ts
194
196
  var DOTNET = process.platform === "win32" ? "dotnet.exe" : "dotnet";
195
197
  var MAUI_DOCS = "https://learn.microsoft.com/dotnet/maui/get-started/installation";
196
198
  var INSTALL_NET_10_FIX = "Install the .NET 10 SDK \u2014 https://dotnet.microsoft.com/download";
@@ -201,13 +203,19 @@ var newestNet10Sdk = (listSdksOutput) => splitLines(listSdksOutput).map((line) =
201
203
  (a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
202
204
  ).pop();
203
205
  var outputMentionsMaui = (workloadListOutput) => MAUI_WORKLOAD.test(workloadListOutput);
206
+ var TARGET_WORKLOADS = {
207
+ macos: "maui-maccatalyst",
208
+ windows: "maui-windows",
209
+ android: "maui-android",
210
+ ios: "maui-ios"
211
+ };
204
212
  var outputMentionsMauiTarget = (workloadListOutput, target) => {
205
213
  if (!target) return outputMentionsMaui(workloadListOutput);
206
- const targetWorkload = target === "macos" ? "maui-maccatalyst" : target === "windows" ? "maui-windows" : "maui-android";
207
- return new RegExp(
208
- `(?:\\[(?:maui|${targetWorkload})\\]|^\\s*(?:maui|${targetWorkload})\\s)`,
209
- "m"
210
- ).test(workloadListOutput);
214
+ return listsAnyWorkload(workloadListOutput, ["maui", TARGET_WORKLOADS[target]]);
215
+ };
216
+ var listsAnyWorkload = (workloadListOutput, ids) => {
217
+ const alternatives = ids.join("|");
218
+ return new RegExp(`(?:\\[(?:${alternatives})\\]|^\\s*(?:${alternatives})\\s)`, "m").test(workloadListOutput);
211
219
  };
212
220
  var checkDotnetSdk = () => {
213
221
  const name = ".NET SDK";
@@ -234,13 +242,69 @@ var checkDotnetSdk = () => {
234
242
  fix: INSTALL_NET_10_FIX
235
243
  };
236
244
  };
237
- var isMauiWorkloadInstalled = (target) => outputMentionsMauiTarget(
238
- run(DOTNET, ["workload", "list"]).stdout,
239
- target
245
+ var TFM_PLATFORMS = {
246
+ maccatalyst: "macos",
247
+ windows: "windows",
248
+ android: "android",
249
+ ios: "ios"
250
+ };
251
+ var MSBUILD_OS = {
252
+ darwin: "osx",
253
+ win32: "windows",
254
+ linux: "linux"
255
+ };
256
+ var projectMauiTargets = (csproj, platform = process.platform) => {
257
+ const os = MSBUILD_OS[platform];
258
+ const found = /* @__PURE__ */ new Set();
259
+ for (const match of csproj.matchAll(
260
+ /<TargetFrameworks?(?:\s+Condition="([^"]*)")?\s*>([^<]*)<\/TargetFrameworks?>/g
261
+ )) {
262
+ const [, condition, frameworks] = match;
263
+ if (condition && !(os && condition.includes(`IsOSPlatform('${os}')`))) continue;
264
+ for (const framework of frameworks.split(";")) {
265
+ const target = TFM_PLATFORMS[framework.trim().match(/^net[\d.]+-([a-z]+)/)?.[1] ?? ""];
266
+ if (target) found.add(target);
267
+ }
268
+ }
269
+ return [...found];
270
+ };
271
+ var readProjectMauiTargets = (csprojPath) => {
272
+ try {
273
+ return projectMauiTargets(fs2.readFileSync(csprojPath, "utf8"));
274
+ } catch {
275
+ return [];
276
+ }
277
+ };
278
+ var PLATFORM_WORKLOADS = {
279
+ macos: "maccatalyst",
280
+ android: "android",
281
+ ios: "ios"
282
+ };
283
+ var missingWorkloadsFor = (workloadListOutput, target, projectTargets) => {
284
+ const missing = [];
285
+ if (!outputMentionsMauiTarget(workloadListOutput, target)) {
286
+ missing.push(mauiWorkloadFor(target));
287
+ }
288
+ for (const other of new Set(projectTargets)) {
289
+ const platformWorkload = PLATFORM_WORKLOADS[other];
290
+ if (other === target || !platformWorkload) continue;
291
+ if (!listsAnyWorkload(workloadListOutput, ["maui", mauiWorkloadFor(other), platformWorkload])) {
292
+ missing.push(platformWorkload);
293
+ }
294
+ }
295
+ return missing;
296
+ };
297
+ var projectDir = (csprojPath) => csprojPath ? path2.dirname(csprojPath) : void 0;
298
+ var listWorkloads = (csprojPath) => run(DOTNET, ["workload", "list"], projectDir(csprojPath)).stdout;
299
+ var missingWorkloads = (target, csprojPath) => missingWorkloadsFor(
300
+ listWorkloads(csprojPath),
301
+ target,
302
+ csprojPath ? readProjectMauiTargets(csprojPath) : []
240
303
  );
241
- var mauiWorkloadFor = (target) => target === "android" ? "maui-android" : target === "windows" ? "maui-windows" : target === "macos" ? "maui-maccatalyst" : "maui";
242
- var installWorkload = (csprojPath, target) => {
243
- const args = target ? ["workload", "install", mauiWorkloadFor(target)] : csprojPath ? ["workload", "restore", csprojPath] : ["workload", "install", "maui"];
304
+ var anyMauiWorkloadInstalled = (csprojPath) => outputMentionsMaui(listWorkloads(csprojPath));
305
+ var mauiWorkloadFor = (target) => target ? TARGET_WORKLOADS[target] : "maui";
306
+ var installWorkload = (csprojPath, workloads = []) => {
307
+ const args = workloads.length > 0 ? ["workload", "install", ...workloads] : csprojPath ? ["workload", "restore", csprojPath] : ["workload", "install", "maui"];
244
308
  console.log();
245
309
  console.log(
246
310
  row({
@@ -255,7 +319,7 @@ var installWorkload = (csprojPath, target) => {
255
319
  );
256
320
  console.log();
257
321
  try {
258
- execFileSync2(DOTNET, args, { stdio: "inherit" });
322
+ execFileSync2(DOTNET, args, { cwd: projectDir(csprojPath), stdio: "inherit" });
259
323
  return true;
260
324
  } catch {
261
325
  console.error();
@@ -268,7 +332,7 @@ var installWorkload = (csprojPath, target) => {
268
332
  )
269
333
  );
270
334
  console.error(
271
- fixLine(`sudo dotnet workload install ${mauiWorkloadFor(target)}`)
335
+ fixLine(`sudo ${DOTNET} ${args.join(" ")}`)
272
336
  );
273
337
  console.error();
274
338
  return false;
@@ -291,13 +355,17 @@ var ensureMauiWorkload = async (opts = {}) => {
291
355
  return false;
292
356
  }
293
357
  if (dotnet.status === "unknown") return true;
294
- if (isMauiWorkloadInstalled(opts.target)) return true;
358
+ const missing = opts.target ? missingWorkloads(opts.target, opts.csprojPath) : [];
359
+ const installed = () => opts.target ? missingWorkloads(opts.target, opts.csprojPath).length === 0 : anyMauiWorkloadInstalled(opts.csprojPath);
360
+ if (opts.target ? missing.length === 0 : anyMauiWorkloadInstalled(opts.csprojPath)) return true;
295
361
  console.log();
296
362
  console.log(
297
363
  row({
298
364
  glyph: "error",
299
365
  label: ".NET MAUI workload",
300
- detail: dim("required but not installed")
366
+ detail: dim(
367
+ missing.length > 0 ? `${missing.join(", ")} required but not installed` : "required but not installed"
368
+ )
301
369
  })
302
370
  );
303
371
  const interactive = opts.interactive ?? isInteractive();
@@ -315,7 +383,7 @@ var ensureMauiWorkload = async (opts = {}) => {
315
383
  install = false;
316
384
  }
317
385
  if (install) {
318
- if (installWorkload(opts.csprojPath, opts.target) && isMauiWorkloadInstalled(opts.target)) {
386
+ if (installWorkload(opts.csprojPath, missing) && installed()) {
319
387
  console.log(
320
388
  row({
321
389
  glyph: "done",
@@ -329,34 +397,80 @@ var ensureMauiWorkload = async (opts = {}) => {
329
397
  }
330
398
  }
331
399
  console.log(
332
- fixLine(`dotnet workload install ${mauiWorkloadFor(opts.target)}`, "run:")
400
+ fixLine(
401
+ `dotnet workload install ${missing.length > 0 ? missing.join(" ") : mauiWorkloadFor()}`,
402
+ "run:"
403
+ )
333
404
  );
334
405
  console.log(fixLine(MAUI_DOCS, "docs:"));
335
406
  return false;
336
407
  };
337
408
 
409
+ // ../shared/src/telemetry.ts
410
+ var TELEMETRY_ENDPOINT = "https://vidra.build/api/telemetry";
411
+ var SEND_TIMEOUT_MS = 1500;
412
+ var FALSY_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
413
+ var isFalsy = (v) => v !== void 0 && FALSY_VALUES.has(v.toLowerCase());
414
+ var isSet = (v) => v !== void 0 && v !== "" && !isFalsy(v);
415
+ var telemetryMode = (opts = {}) => {
416
+ const env = opts.env ?? process.env;
417
+ if (isSet(env.VIDRA_TELEMETRY_DEBUG)) return "debug";
418
+ if (opts.devCheckout || isSet(env.DO_NOT_TRACK) || isFalsy(env.VIDRA_TELEMETRY) || isSet(env.CI)) {
419
+ return "off";
420
+ }
421
+ return "send";
422
+ };
423
+ var telemetryPayload = (event, cliVersion) => ({
424
+ schema: 1,
425
+ ...event,
426
+ durationMs: Math.round(event.durationMs),
427
+ cliVersion,
428
+ os: process.platform,
429
+ arch: process.arch,
430
+ nodeVersion: process.versions.node
431
+ });
432
+ var sendTelemetry = async (mode, event, cliVersion) => {
433
+ if (mode === "off") return;
434
+ const body = JSON.stringify(telemetryPayload(event, cliVersion));
435
+ if (mode === "debug") {
436
+ console.error(`[telemetry] ${body}`);
437
+ return;
438
+ }
439
+ try {
440
+ await fetch(TELEMETRY_ENDPOINT, {
441
+ method: "POST",
442
+ headers: { "content-type": "application/json" },
443
+ body,
444
+ signal: AbortSignal.timeout(SEND_TIMEOUT_MS)
445
+ });
446
+ } catch {
447
+ }
448
+ };
449
+
338
450
  // src/index.ts
339
451
  var note = (label, body) => ` ${dim(label.padEnd(7))} ${body}`;
340
- var __dirname = path2.dirname(fileURLToPath(import.meta.url));
341
- var CLI_ROOT = path2.resolve(__dirname, "..");
342
- var TEMPLATES_DIR = path2.join(CLI_ROOT, "templates");
343
- var VIDRA_REPO_ROOT = path2.resolve(CLI_ROOT, "..", "..", "..");
344
- var LOCAL_FEED_DIR = path2.join(VIDRA_REPO_ROOT, "dist", "packages");
345
- var LOCAL_CLI_DIR = path2.join(VIDRA_REPO_ROOT, "src", "cli", "vidra-cli");
346
- var LOCAL_SDK_DIR = path2.join(VIDRA_REPO_ROOT, "src", "sdk", "vidra-js");
452
+ var __dirname = path3.dirname(fileURLToPath(import.meta.url));
453
+ var CLI_ROOT = path3.resolve(__dirname, "..");
454
+ var TEMPLATES_DIR = path3.join(CLI_ROOT, "templates");
455
+ var VIDRA_REPO_ROOT = path3.resolve(CLI_ROOT, "..", "..", "..");
456
+ var LOCAL_FEED_DIR = path3.join(VIDRA_REPO_ROOT, "dist", "packages");
457
+ var LOCAL_CLI_DIR = path3.join(VIDRA_REPO_ROOT, "src", "cli", "vidra-cli");
458
+ var LOCAL_SDK_DIR = path3.join(VIDRA_REPO_ROOT, "src", "sdk", "vidra-js");
347
459
  var VIDRA_VERSION = JSON.parse(
348
- fs2.readFileSync(path2.join(CLI_ROOT, "package.json"), "utf-8")
460
+ fs3.readFileSync(path3.join(CLI_ROOT, "package.json"), "utf-8")
349
461
  ).version;
350
462
  var SDK_VERSION = VIDRA_VERSION;
463
+ var isMonorepo = fs3.existsSync(path3.join(LOCAL_SDK_DIR, "package.json"));
351
464
  var main = async () => {
465
+ const telemetry = telemetryMode({ devCheckout: isMonorepo });
352
466
  console.log();
353
467
  console.log(` create-${lime("vidra")}-app`);
354
468
  console.log(footer(dim("scaffold a new vidra application")));
355
469
  console.log();
356
470
  const args = parseArgs(process.argv);
357
- let projectDir = args._[0];
471
+ let projectDir2 = args._[0];
358
472
  let appId = args["app-id"];
359
- if (!projectDir) {
473
+ if (!projectDir2) {
360
474
  const res = await prompts2(
361
475
  {
362
476
  type: "text",
@@ -367,11 +481,11 @@ var main = async () => {
367
481
  },
368
482
  { onCancel: () => process.exit(1) }
369
483
  );
370
- projectDir = res.projectDir;
484
+ projectDir2 = res.projectDir;
371
485
  }
372
- const projectName = toPascalCase(projectDir);
373
- const projectNameKebab = toKebabCase(projectDir);
374
- const appTitle = toTitleCase(projectDir);
486
+ const projectName = toPascalCase(projectDir2);
487
+ const projectNameKebab = toKebabCase(projectDir2);
488
+ const appTitle = toTitleCase(projectDir2);
375
489
  const appGuid = randomUUID().toUpperCase();
376
490
  if (!appId) {
377
491
  const res = await prompts2(
@@ -386,13 +500,13 @@ var main = async () => {
386
500
  );
387
501
  appId = res.appId;
388
502
  }
389
- const root = path2.resolve(projectDir);
390
- if (fs2.existsSync(root) && fs2.readdirSync(root).length > 0) {
503
+ const root = path3.resolve(projectDir2);
504
+ if (fs3.existsSync(root) && fs3.readdirSync(root).length > 0) {
391
505
  console.error();
392
506
  console.error(
393
507
  row({
394
508
  glyph: "error",
395
- detail: dim(`directory "${projectDir}" already exists and is not empty`)
509
+ detail: dim(`directory "${projectDir2}" already exists and is not empty`)
396
510
  })
397
511
  );
398
512
  console.error();
@@ -403,8 +517,7 @@ var main = async () => {
403
517
  console.log(kv("directory", root));
404
518
  console.log(kv("app id", appId));
405
519
  console.log();
406
- const isMonorepo = fs2.existsSync(path2.join(LOCAL_SDK_DIR, "package.json"));
407
- const localFeedExists = isMonorepo && fs2.existsSync(LOCAL_FEED_DIR);
520
+ const localFeedExists = isMonorepo && fs3.existsSync(LOCAL_FEED_DIR);
408
521
  const localFeedSource = localFeedExists ? ` <add key="vidra-local" value="${toTextPath(LOCAL_FEED_DIR)}" />` : "";
409
522
  const cliRef = isMonorepo ? `file:${toTextPath(LOCAL_CLI_DIR)}` : `^${VIDRA_VERSION}`;
410
523
  const sdkRef = isMonorepo ? `file:${toTextPath(LOCAL_SDK_DIR)}` : `^${SDK_VERSION}`;
@@ -419,22 +532,40 @@ var main = async () => {
419
532
  "{{sdkVersion}}": sdkRef,
420
533
  "{{localFeedSource}}": localFeedSource
421
534
  };
422
- const templateDir = path2.join(TEMPLATES_DIR, "react-vite");
423
- await scaffoldDir(templateDir, root, replacements);
424
- console.log(row({ glyph: "active", detail: dim("creating solution\u2026") }));
425
- exec(`dotnet new sln -n ${projectName} --force`, root);
426
- const slnFile = fs2.existsSync(path2.join(root, `${projectName}.slnx`)) ? `${projectName}.slnx` : `${projectName}.sln`;
427
- exec(
428
- `dotnet sln ${slnFile} add src/${projectName}.Host/${projectName}.Host.csproj`,
429
- root
430
- );
535
+ const startedAt = performance.now();
536
+ let stage = "templates";
537
+ try {
538
+ const templateDir = path3.join(TEMPLATES_DIR, "react-vite");
539
+ await scaffoldDir(templateDir, root, replacements);
540
+ stage = "solution";
541
+ console.log(row({ glyph: "active", detail: dim("creating solution\u2026") }));
542
+ exec(`dotnet new sln -n ${projectName} --force`, root);
543
+ const slnFile = fs3.existsSync(path3.join(root, `${projectName}.slnx`)) ? `${projectName}.slnx` : `${projectName}.sln`;
544
+ exec(
545
+ `dotnet sln ${slnFile} add src/${projectName}.Host/${projectName}.Host.csproj`,
546
+ root
547
+ );
548
+ } catch (e) {
549
+ await sendTelemetry(
550
+ telemetry,
551
+ {
552
+ event: "app_created",
553
+ outcome: "failed",
554
+ durationMs: performance.now() - startedAt,
555
+ stage
556
+ },
557
+ VIDRA_VERSION
558
+ );
559
+ throw e;
560
+ }
431
561
  console.log(row({ glyph: "active", detail: dim("installing dependencies\u2026") }));
432
- const uiDir = path2.join(root, "ui");
562
+ const uiDir = path3.join(root, "ui");
433
563
  const [rootNpmOk, uiNpmOk] = await Promise.all([
434
564
  tryExecAsync("npm install", root),
435
565
  tryExecAsync("npm install", uiDir)
436
566
  ]);
437
567
  const npmOk = rootNpmOk && uiNpmOk;
568
+ const durationMs = performance.now() - startedAt;
438
569
  console.log();
439
570
  console.log(
440
571
  row({
@@ -467,7 +598,7 @@ var main = async () => {
467
598
  );
468
599
  console.log();
469
600
  }
470
- const hostCsproj = path2.join(
601
+ const hostCsproj = path3.join(
471
602
  root,
472
603
  "src",
473
604
  `${projectName}.Host`,
@@ -475,7 +606,7 @@ var main = async () => {
475
606
  );
476
607
  const prereqsReady = await ensureMauiWorkload({ csprojPath: hostCsproj });
477
608
  console.log(footer(dim("next steps")));
478
- console.log(` ${value(`cd ${projectDir}`)}`);
609
+ console.log(` ${value(`cd ${projectDir2}`)}`);
479
610
  console.log(
480
611
  ` ${value("npm run dev")} ${dim("# starts vite + the MAUI host together")}`
481
612
  );
@@ -485,6 +616,17 @@ var main = async () => {
485
616
  );
486
617
  }
487
618
  console.log();
619
+ await sendTelemetry(
620
+ telemetry,
621
+ {
622
+ event: "app_created",
623
+ outcome: "created",
624
+ durationMs,
625
+ npmInstallOk: npmOk,
626
+ mauiWorkloadReady: prereqsReady
627
+ },
628
+ VIDRA_VERSION
629
+ );
488
630
  };
489
631
  main().catch((e) => {
490
632
  console.error(row({ glyph: "error", detail: dim(e.message) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vidra-app",
3
- "version": "0.6.1",
3
+ "version": "1.0.0",
4
4
  "description": "Scaffold a new Vidra application (React + .NET MAUI)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,7 @@
1
+ {
2
+ "sdk": {
3
+ "version": "10.0.100",
4
+ "rollForward": "latestFeature",
5
+ "allowPrerelease": false
6
+ }
7
+ }
@@ -29,13 +29,14 @@ public static class MauiProgram
29
29
  //
30
30
  // Whole app (desktop): native code included, via Velopack. Its other
31
31
  // half is the `VelopackApp` line in the desktop Program.cs files, which
32
- // has to run before the UI framework starts. Google Play owns Android
33
- // app updates; only the web-bundle tier runs there.
32
+ // has to run before the UI framework starts. Google Play and the App
33
+ // Store own app updates on Android and iOS; only the web-bundle tier
34
+ // runs there.
34
35
  builder
35
36
  .UseMauiApp<App>()
36
37
  .UseVidra()
37
38
  .UseVidraUpdates()
38
- #if !ANDROID
39
+ #if !ANDROID && !IOS
39
40
  .UseVidraNativeUpdates()
40
41
  #endif
41
42
  .ConfigureFonts(fonts =>
@@ -5,5 +5,7 @@
5
5
  <uses-permission android:name="android.permission.BATTERY_STATS" />
6
6
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7
7
  <application android:allowBackup="true"
8
+ android:icon="@mipmap/appicon"
9
+ android:roundIcon="@mipmap/appicon_round"
8
10
  android:supportsRtl="true" />
9
11
  </manifest>
@@ -2,6 +2,8 @@
2
2
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
3
  <plist version="1.0">
4
4
  <dict>
5
+ <key>XSAppIconAssets</key>
6
+ <string>Assets.xcassets/appicon.appiconset</string>
5
7
  <key>NSAppTransportSecurity</key>
6
8
  <dict>
7
9
  <key>NSAllowsLocalNetworking</key>
@@ -0,0 +1,9 @@
1
+ using Foundation;
2
+
3
+ namespace {{projectName}};
4
+
5
+ [Register("AppDelegate")]
6
+ public class AppDelegate : MauiUIApplicationDelegate
7
+ {
8
+ protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9
+ }
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSAppTransportSecurity</key>
6
+ <dict>
7
+ <key>NSAllowsLocalNetworking</key>
8
+ <true/>
9
+ </dict>
10
+ <key>NSLocalNetworkUsageDescription</key>
11
+ <string>Connects to the development server running on your computer.</string>
12
+ </dict>
13
+ </plist>
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>LSRequiresIPhoneOS</key>
6
+ <true/>
7
+ <key>UIDeviceFamily</key>
8
+ <array>
9
+ <integer>1</integer>
10
+ <integer>2</integer>
11
+ </array>
12
+ <key>UIRequiredDeviceCapabilities</key>
13
+ <array>
14
+ <string>arm64</string>
15
+ </array>
16
+ <key>UISupportedInterfaceOrientations</key>
17
+ <array>
18
+ <string>UIInterfaceOrientationPortrait</string>
19
+ <string>UIInterfaceOrientationLandscapeLeft</string>
20
+ <string>UIInterfaceOrientationLandscapeRight</string>
21
+ </array>
22
+ <key>UISupportedInterfaceOrientations~ipad</key>
23
+ <array>
24
+ <string>UIInterfaceOrientationPortrait</string>
25
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
26
+ <string>UIInterfaceOrientationLandscapeLeft</string>
27
+ <string>UIInterfaceOrientationLandscapeRight</string>
28
+ </array>
29
+ <key>UILaunchScreen</key>
30
+ <dict/>
31
+ <key>XSAppIconAssets</key>
32
+ <string>Assets.xcassets/appicon.appiconset</string>
33
+ </dict>
34
+ </plist>
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyTracking</key>
6
+ <false/>
7
+ <key>NSPrivacyTrackingDomains</key>
8
+ <array/>
9
+ <key>NSPrivacyCollectedDataTypes</key>
10
+ <array/>
11
+ <key>NSPrivacyAccessedAPITypes</key>
12
+ <array>
13
+ <dict>
14
+ <key>NSPrivacyAccessedAPIType</key>
15
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
16
+ <key>NSPrivacyAccessedAPITypeReasons</key>
17
+ <array>
18
+ <string>C617.1</string>
19
+ </array>
20
+ </dict>
21
+ <dict>
22
+ <key>NSPrivacyAccessedAPIType</key>
23
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
24
+ <key>NSPrivacyAccessedAPITypeReasons</key>
25
+ <array>
26
+ <string>35F9.1</string>
27
+ </array>
28
+ </dict>
29
+ <dict>
30
+ <key>NSPrivacyAccessedAPIType</key>
31
+ <string>NSPrivacyAccessedAPICategoryDiskSpace</string>
32
+ <key>NSPrivacyAccessedAPITypeReasons</key>
33
+ <array>
34
+ <string>E174.1</string>
35
+ </array>
36
+ </dict>
37
+ <dict>
38
+ <key>NSPrivacyAccessedAPIType</key>
39
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
40
+ <key>NSPrivacyAccessedAPITypeReasons</key>
41
+ <array>
42
+ <string>CA92.1</string>
43
+ </array>
44
+ </dict>
45
+ </array>
46
+ </dict>
47
+ </plist>
@@ -0,0 +1,15 @@
1
+ // The app's entry point on iOS. Unlike the desktop entry points it has no
2
+ // VelopackApp line: the App Store owns app updates here, and only the web-bundle
3
+ // tier runs.
4
+
5
+ using UIKit;
6
+
7
+ namespace {{projectName}};
8
+
9
+ public static class Program
10
+ {
11
+ static void Main(string[] args)
12
+ {
13
+ UIApplication.Main(args, null, typeof(AppDelegate));
14
+ }
15
+ }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <rect x="0" y="0" width="456" height="456" fill="#16161A" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M 152 156 L 228 304 L 304 156" fill="none" stroke="#C8F751" stroke-width="44" stroke-linecap="round" stroke-linejoin="round" />
4
+ </svg>
@@ -8,13 +8,14 @@
8
8
  restore can read an assets file with no x64 target and fail with
9
9
  NETSDK1047. Naming the set here makes every restore write both. -->
10
10
  <RuntimeIdentifiers Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
11
- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">net10.0-maccatalyst;net10.0-android</TargetFrameworks>
11
+ <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">net10.0-maccatalyst;net10.0-ios;net10.0-android</TargetFrameworks>
12
12
  <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net10.0-windows10.0.19041.0;net10.0-android</TargetFrameworks>
13
13
  <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('linux'))">net10.0-android</TargetFrameworks>
14
14
  <ValidateXcodeVersion>false</ValidateXcodeVersion>
15
15
  <OutputType>Exe</OutputType>
16
16
  <RootNamespace>{{projectName}}</RootNamespace>
17
17
  <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
18
+ <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">17.0</SupportedOSPlatformVersion>
18
19
  <DefineConstants Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' And '$(VidraAndroidTestRuntime)' == 'true'">$(DefineConstants);VIDRA_ANDROID_TEST_RUNTIME</DefineConstants>
19
20
  <UseMaui>true</UseMaui>
20
21
  <!--
@@ -57,6 +58,13 @@
57
58
  sandbox
58
59
  -->
59
60
  <CodesignEntitlements Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">Entitlements.plist</CodesignEntitlements>
61
+ <!--
62
+ The iOS SDK signs with a root Entitlements.plist on its own whenever
63
+ CodesignEntitlements is empty. That file holds Mac Catalyst
64
+ hardened-runtime keys, which are meaningless on iOS and make App Store
65
+ validation reject the app, so iOS opts out and signs with none.
66
+ -->
67
+ <EnableDefaultCodesignEntitlements Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">false</EnableDefaultCodesignEntitlements>
60
68
 
61
69
  <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">17.0</SupportedOSPlatformVersion>
62
70
  <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
@@ -101,6 +109,28 @@
101
109
 
102
110
  <ItemGroup>
103
111
  <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
112
+ <!--
113
+ One icon for every platform: MAUI renders these SVGs into the iOS and Mac
114
+ Catalyst asset catalog, the Android mipmaps and the Windows .exe icon.
115
+ Color fills the background, and must stay opaque: App Store Connect
116
+ rejects an icon with transparency.
117
+ -->
118
+ <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#16161A" />
119
+ </ItemGroup>
120
+
121
+ <!--
122
+ iOS. Info.LocalNetwork.plist allows plain HTTP to the local network, which
123
+ since iOS 17 includes every IP address: it is how a device reaches the Vite
124
+ dev server. It is merged into Debug builds and into the unsigned simulator
125
+ builds `vidra build` makes (VidraAllowLocalNetworking), never into an App
126
+ Store build.
127
+ PrivacyInfo.xcprivacy declares the required-reason APIs .NET and MAUI use;
128
+ App Store Connect refuses an upload without it.
129
+ -->
130
+ <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
131
+ <PartialAppManifest Include="Platforms\iOS\Info.LocalNetwork.plist"
132
+ Condition="'$(Configuration)' == 'Debug' Or '$(VidraAllowLocalNetworking)' == 'true'" />
133
+ <BundleResource Include="Platforms\iOS\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" />
104
134
  </ItemGroup>
105
135
 
106
136
  <ItemGroup>
@@ -112,11 +142,12 @@
112
142
  inert until vidra.config.ts names a native feed: ~280 KB of managed code
113
143
  against a self-contained .NET + MAUI app, which is the price of never
114
144
  having to retrofit an entry point, a package reference and a builder call
115
- into an app that has already shipped.
145
+ into an app that has already shipped. Desktop only: the stores own app
146
+ updates on Android and iOS.
116
147
  -->
117
148
  <PackageReference Include="Vidra.Updates.Native"
118
149
  Version="{{vidraVersion}}"
119
- Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'" />
150
+ Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android' And $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios'" />
120
151
  </ItemGroup>
121
152
 
122
153
  </Project>