@todesktop/cli 1.10.5 → 1.11.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
@@ -150,6 +150,7 @@ We also support:
150
150
  - `todesktop build --config=<path.to.another.todesktop.json>`. Run a build with a different configuration file.
151
151
  - `todesktop build --async`. Run a build in the background. This is handy for CI environments.
152
152
  - `todesktop build --webhook URL`. Send a POST request to the webhook URL when the build is finished. It's especially useful together with the `--async` flag.
153
+ - `todesktop build --ignore-extends-errors`. Ignore `id` and `appId` validation errors when extending another todesktop.json file.
153
154
  - `todesktop release`. Release a build. This will publish a new download and an auto-update for existing users. By default it shows a list of builds for you to choose from.
154
155
  - Use `todesktop release <id>` to release a specific build by ID.
155
156
  - `todesktop release --latest` will release the latest build.
@@ -1146,6 +1147,10 @@ Now, when we build your app on ToDesktop servers, it will also run your custom `
1146
1147
 
1147
1148
  ## Changelog
1148
1149
 
1150
+ ### v1.11.0
1151
+
1152
+ - Add additional `id` and `appId` validation when extending another `todesktop.json` file. Can be disabled with the `--ignore-extends-errors` flag.
1153
+
1149
1154
  ### v1.10.5
1150
1155
 
1151
1156
  - Add support for `snap.base` in snap configuration
package/dist/cli.js CHANGED
@@ -972,9 +972,9 @@ async function postToFirebaseFunction_default(functionName, body = {}, config2 =
972
972
  }
973
973
 
974
974
  // src/utilities/projectConfig/getProjectConfig.ts
975
- var import_path3 = require("path");
976
- var import_fs = require("fs");
977
975
  var import_find_up = __toESM(require("find-up"));
976
+ var import_fs = require("fs");
977
+ var import_path3 = require("path");
978
978
 
979
979
  // src/utilities/projectConfig/loadConfig.ts
980
980
  function loadConfig(configPath) {
@@ -1453,7 +1453,7 @@ var schema_default = {
1453
1453
  required: ["extends"]
1454
1454
  },
1455
1455
  then: {
1456
- required: []
1456
+ required: ["id"]
1457
1457
  },
1458
1458
  else: {
1459
1459
  required: ["id", "icon", "schemaVersion"]
@@ -2049,9 +2049,9 @@ ${output}`
2049
2049
  }
2050
2050
 
2051
2051
  // src/utilities/projectConfig/computeFullProjectConfig.ts
2052
- var import_path2 = require("path");
2053
2052
  var import_lodash2 = __toESM(require("lodash.merge"));
2054
- function computeFullProjectConfig(partialConfig, projectRoot) {
2053
+ var import_path2 = require("path");
2054
+ function computeFullProjectConfig(partialConfig, projectRoot, flags) {
2055
2055
  if (!partialConfig.extends) {
2056
2056
  logger_default.debug("No extends field, returning partial config");
2057
2057
  return partialConfig;
@@ -2062,8 +2062,19 @@ function computeFullProjectConfig(partialConfig, projectRoot) {
2062
2062
  parentConfig.appPath = parentConfig.appPath || ".";
2063
2063
  const parentFullConfig = computeFullProjectConfig(
2064
2064
  parentConfig,
2065
- projectRoot
2065
+ projectRoot,
2066
+ flags
2066
2067
  );
2068
+ if ((flags == null ? void 0 : flags.build) && !flags.build.ignoreExtendsErrors) {
2069
+ const hasSameId = partialConfig.id === parentFullConfig.id;
2070
+ const hasSameAppId = partialConfig.appId === parentFullConfig.appId;
2071
+ if (hasSameId || hasSameAppId) {
2072
+ throw new Error(`
2073
+ todesktop.json invalid. Cannot have the same "id" or "appId" as an extended todesktop.json file.
2074
+
2075
+ You can disable this error by running todesktop build with the --ignore-extends-errors flag.`);
2076
+ }
2077
+ }
2067
2078
  const result = (0, import_lodash2.default)({}, parentFullConfig, partialConfig);
2068
2079
  delete result.extends;
2069
2080
  return result;
@@ -2071,7 +2082,7 @@ function computeFullProjectConfig(partialConfig, projectRoot) {
2071
2082
  }
2072
2083
 
2073
2084
  // src/utilities/projectConfig/getProjectConfig.ts
2074
- function getProjectConfig(configPath) {
2085
+ function getProjectConfig(configPath, flags) {
2075
2086
  if (!configPath) {
2076
2087
  logger_default.debug("No config path provided, searching for one");
2077
2088
  configPath = import_find_up.default.sync("todesktop.json");
@@ -2089,7 +2100,7 @@ function getProjectConfig(configPath) {
2089
2100
  }
2090
2101
  const projectRoot = (0, import_path3.dirname)(configPath);
2091
2102
  const partialConfig = loadConfig(configPath);
2092
- const config2 = computeFullProjectConfig(partialConfig, projectRoot);
2103
+ const config2 = computeFullProjectConfig(partialConfig, projectRoot, flags);
2093
2104
  validateConfig({ config: config2, projectRoot });
2094
2105
  const result = resolveConfigPaths({ config: config2, projectRoot });
2095
2106
  return { config: result, unprocessedConfig: config2, projectRoot };
@@ -2607,15 +2618,15 @@ async function exists(filePath) {
2607
2618
  // src/commands/build/utilities/runBuild.ts
2608
2619
  async function runBuild({
2609
2620
  configPath,
2610
- exitAfterUploading,
2611
- shouldCodeSign = true,
2612
- onBuildFinishedWebhook,
2613
- updateState
2621
+ updateState,
2622
+ flags
2614
2623
  }) {
2615
2624
  var _a, _b, _c;
2616
2625
  logForCI_default("Getting application information...");
2617
2626
  const primaryUserId = (_a = currentUser()) == null ? void 0 : _a.uid;
2618
- const { config: config2, unprocessedConfig } = getProjectConfig(configPath);
2627
+ const { config: config2, unprocessedConfig } = getProjectConfig(configPath, {
2628
+ build: flags
2629
+ });
2619
2630
  const appId = config2.id;
2620
2631
  const appPkgJson = getPackageJson_default({ config: config2 });
2621
2632
  const buildObserver = spyBuild();
@@ -2636,9 +2647,9 @@ async function runBuild({
2636
2647
  appPkgProductName: appPkgJson.productName,
2637
2648
  appVersion: appPkgJson.version,
2638
2649
  id: config2.id,
2639
- onBuildFinishedWebhook,
2650
+ onBuildFinishedWebhook: flags.onBuildFinishedWebhook,
2640
2651
  projectConfig: unprocessedConfig,
2641
- shouldCodeSign: shouldCodeSign !== false,
2652
+ shouldCodeSign: flags.shouldCodeSign !== false,
2642
2653
  shouldRelease: false,
2643
2654
  userId: primaryUserId,
2644
2655
  versionControlInfo: await getVersionControlInfo_default(config2.appPath),
@@ -2695,7 +2706,7 @@ async function runBuild({
2695
2706
  } catch (e) {
2696
2707
  throw addErrorMessage(e, "Failed while kicking off build");
2697
2708
  }
2698
- if (exitAfterUploading) {
2709
+ if (flags.exitAfterUploading) {
2699
2710
  updateState({ state: "exit-after-uploading" });
2700
2711
  return;
2701
2712
  }
@@ -2728,21 +2739,13 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
2728
2739
  function Build({
2729
2740
  commandUsed,
2730
2741
  configPath,
2731
- exitAfterUploading,
2732
- onBuildFinishedWebhook,
2733
- shouldCodeSign
2742
+ flags
2734
2743
  }) {
2735
2744
  var _a, _b, _c, _d, _e, _f;
2736
2745
  const exit = useExit_default();
2737
2746
  const [state, setState] = (0, import_react6.useState)({ state: "initializing" });
2738
2747
  (0, import_react6.useEffect)(() => {
2739
- runBuild({
2740
- configPath,
2741
- exitAfterUploading,
2742
- onBuildFinishedWebhook,
2743
- shouldCodeSign,
2744
- updateState
2745
- }).catch((e) => {
2748
+ runBuild({ configPath, flags, updateState }).catch((e) => {
2746
2749
  const error = e.response ? e.response.data : e;
2747
2750
  logForCI_default(error);
2748
2751
  updateState({ state: "error", error });
@@ -3548,16 +3551,14 @@ var useAnalyticsCommand = (command, flags = {}, properties = {}) => {
3548
3551
  var import_jsx_runtime21 = require("react/jsx-runtime");
3549
3552
  function BuildCommand({
3550
3553
  configPath,
3551
- exitAfterUploading,
3552
- onBuildFinishedWebhook,
3553
- shouldCodeSign
3554
+ flags
3554
3555
  }) {
3555
3556
  checkIfReactIsUsable_default();
3556
3557
  useAnalyticsCommand("build", {
3557
- async: exitAfterUploading,
3558
- codeSign: shouldCodeSign,
3558
+ async: flags.exitAfterUploading,
3559
+ codeSign: flags.shouldCodeSign,
3559
3560
  config: configPath,
3560
- webhook: onBuildFinishedWebhook
3561
+ webhook: flags.onBuildFinishedWebhook
3561
3562
  });
3562
3563
  const commandUsed = "todesktop build";
3563
3564
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorBoundary_default, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(LoginHOC_default, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(OngoingBuildGuard_default, { configPath, commandUsed, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -3565,9 +3566,7 @@ function BuildCommand({
3565
3566
  {
3566
3567
  commandUsed,
3567
3568
  configPath,
3568
- exitAfterUploading,
3569
- onBuildFinishedWebhook,
3570
- shouldCodeSign
3569
+ flags
3571
3570
  }
3572
3571
  ) }) }) });
3573
3572
  }
@@ -5433,7 +5432,7 @@ var package_default = {
5433
5432
  access: "public"
5434
5433
  },
5435
5434
  name: "@todesktop/cli",
5436
- version: "1.10.4",
5435
+ version: "1.10.5",
5437
5436
  license: "MIT",
5438
5437
  author: "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
5439
5438
  homepage: "https://todesktop.com/cli",
@@ -5684,12 +5683,18 @@ import_commander.program.command("build").description(
5684
5683
  ).option(
5685
5684
  "--webhook [string]",
5686
5685
  "Send POST request to the webhook URL after building is finished"
5687
- ).addOption(configOption).action(({ async, codeSign, config: config2, webhook }) => {
5686
+ ).option(
5687
+ "--ignore-extends-errors [bool]",
5688
+ "Ignore `id` and `appId` validation errors when extending another todesktop.json file"
5689
+ ).addOption(configOption).action(({ async, codeSign, config: config2, webhook, ignoreExtendsErrors }) => {
5688
5690
  runCommand(BuildCommand, {
5689
5691
  configPath: config2,
5690
- exitAfterUploading: async === true,
5691
- onBuildFinishedWebhook: webhook,
5692
- shouldCodeSign: codeSign !== "false"
5692
+ flags: {
5693
+ exitAfterUploading: async === true,
5694
+ shouldCodeSign: codeSign !== "false",
5695
+ ignoreExtendsErrors: ignoreExtendsErrors === true,
5696
+ onBuildFinishedWebhook: webhook
5697
+ }
5693
5698
  });
5694
5699
  });
5695
5700
  import_commander.program.command("builds").description("View your builds").argument("[id]", "View a specific build by ID").option("--latest", "View the latest build").addOption(configOption).option("--count [number]", "Number of builds to show per page", parseCount).addOption(