@sentio/cli 4.0.1-rc.4 → 4.1.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/dist/index.js CHANGED
@@ -51429,6 +51429,40 @@ async function printVersions() {
51429
51429
  console.log(`Using @sentio/sdk ${sdkVersion}, latest version is ${latestSdkVersion}\n`);
51430
51430
  } catch (e) {}
51431
51431
  }
51432
+ function majorVersion(version) {
51433
+ const major = Number.parseInt(version.split(".")[0], 10);
51434
+ return Number.isNaN(major) ? void 0 : major;
51435
+ }
51436
+ /**
51437
+ * Whether the installed @sentio/sdk is compatible with the given @sentio/cli.
51438
+ * @sentio/cli, @sentio/sdk and @sentio/runtime are released in lockstep, so they
51439
+ * are only compatible when their major versions match — the CLI drives the SDK's
51440
+ * build tooling (it runs the SDK's `dist/tsdown.config.js`), which changes across
51441
+ * majors. Development builds and unparseable versions are treated as compatible so
51442
+ * the local workspace and test flows are never blocked.
51443
+ */
51444
+ function isSdkVersionCompatible(cliVersion, sdkVersion) {
51445
+ if (cliVersion.endsWith("-development") || sdkVersion.endsWith("-development")) return true;
51446
+ const cliMajor = majorVersion(cliVersion);
51447
+ const sdkMajor = majorVersion(sdkVersion);
51448
+ if (cliMajor === void 0 || sdkMajor === void 0) return true;
51449
+ return sdkMajor === cliMajor;
51450
+ }
51451
+ /**
51452
+ * Fail fast with a clear message when the installed @sentio/sdk is too old for this
51453
+ * CLI, instead of letting the build crash later with a cryptic packaging error.
51454
+ */
51455
+ function checkSdkCompatibility() {
51456
+ const cliVersion = getCliVersion();
51457
+ const sdkVersion = getSdkVersion();
51458
+ if (!sdkVersion) return;
51459
+ if (!isSdkVersionCompatible(cliVersion, sdkVersion)) {
51460
+ const cliMajor = majorVersion(cliVersion);
51461
+ const sdkMajor = majorVersion(sdkVersion);
51462
+ console.error(chalk.red(`Version mismatch: @sentio/cli ${cliVersion} (v${cliMajor}) and @sentio/sdk ${sdkVersion} (v${sdkMajor}) must share the same major version.\nPlease align them, e.g. install @sentio/sdk@^${cliMajor} (or switch to @sentio/cli@^${sdkMajor} to match the installed SDK).`));
51463
+ process.exit(1);
51464
+ }
51465
+ }
51432
51466
  function getApiUrl(apiPath, host) {
51433
51467
  let apiHost = host;
51434
51468
  if (host.includes("sentio.xyz")) {
@@ -131013,7 +131047,11 @@ function createGenCommand() {
131013
131047
  });
131014
131048
  }
131015
131049
  async function buildProcessor(onlyGen, options) {
131016
- if (!options.skipDeps && !onlyGen) await installDeps();
131050
+ checkSdkCompatibility();
131051
+ if (!options.skipDeps && !onlyGen) {
131052
+ await installDeps();
131053
+ checkSdkCompatibility();
131054
+ }
131017
131055
  if (!options.skipGen) {
131018
131056
  console.log(chalk.blue("Codegen Begin (can be skipped with --skip-gen)"));
131019
131057
  await codegen(options.example || false);
@@ -131023,9 +131061,13 @@ async function buildProcessor(onlyGen, options) {
131023
131061
  if (!onlyGen) {
131024
131062
  let tsdownConfig;
131025
131063
  try {
131026
- tsdownConfig = path$1.resolve(getPackageRoot("@sentio/sdk"), "dist", "tsdown.config.ts");
131064
+ tsdownConfig = path$1.resolve(getPackageRoot("@sentio/sdk"), "dist", "tsdown.config.js");
131027
131065
  } catch (e) {
131028
- console.error(chalk.red("Wrong CLI version for sdk, can't find tsdown.config.ts"));
131066
+ console.error(chalk.red("@sentio/sdk is not installed. Run an install (or drop --skip-deps) and try again."));
131067
+ process.exit(1);
131068
+ }
131069
+ if (!import_lib$1.default.existsSync(tsdownConfig)) {
131070
+ console.error(chalk.red("Incompatible @sentio/sdk: missing dist/tsdown.config.js. Please upgrade @sentio/sdk to match this CLI's version."));
131029
131071
  process.exit(1);
131030
131072
  }
131031
131073
  await execStep([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/cli",
3
- "version": "4.0.1-rc.4",
3
+ "version": "4.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk'
2
2
  import path from 'path'
3
3
  import fs from 'fs-extra'
4
- import { getPackageRoot } from '../utils.js'
4
+ import { checkSdkCompatibility, getPackageRoot } from '../utils.js'
5
5
  import { Command } from '@commander-js/extra-typings'
6
6
  import { CHAIN_TYPES, loadProcessorConfig } from '../config.js'
7
7
  import { getABIFilePath, getABI, writeABIFile } from '../abi.js'
@@ -29,8 +29,14 @@ export function createGenCommand() {
29
29
  }
30
30
 
31
31
  export async function buildProcessor(onlyGen: boolean, options: CommandOptionsType<typeof createBuildCommand>) {
32
+ // Fail fast with a clear message if an incompatible (older-major) @sentio/sdk is
33
+ // already installed, instead of crashing later with a cryptic packaging error.
34
+ checkSdkCompatibility()
35
+
32
36
  if (!options.skipDeps && !onlyGen) {
33
37
  await installDeps()
38
+ // Re-check after install in case it resolved an older-major @sentio/sdk.
39
+ checkSdkCompatibility()
34
40
  }
35
41
 
36
42
  if (!options.skipGen) {
@@ -41,11 +47,22 @@ export async function buildProcessor(onlyGen: boolean, options: CommandOptionsTy
41
47
  }
42
48
 
43
49
  if (!onlyGen) {
50
+ // The SDK ships its tsdown config as plain JS (dist/tsdown.config.js) so Node
51
+ // can load it natively from node_modules — a .ts config fails there because
52
+ // Node refuses to strip types for files under node_modules.
44
53
  let tsdownConfig: string
45
54
  try {
46
- tsdownConfig = path.resolve(getPackageRoot('@sentio/sdk'), 'dist', 'tsdown.config.ts')
55
+ tsdownConfig = path.resolve(getPackageRoot('@sentio/sdk'), 'dist', 'tsdown.config.js')
47
56
  } catch (e) {
48
- console.error(chalk.red("Wrong CLI version for sdk, can't find tsdown.config.ts"))
57
+ console.error(chalk.red('@sentio/sdk is not installed. Run an install (or drop --skip-deps) and try again.'))
58
+ process.exit(1)
59
+ }
60
+ if (!fs.existsSync(tsdownConfig)) {
61
+ console.error(
62
+ chalk.red(
63
+ "Incompatible @sentio/sdk: missing dist/tsdown.config.js. Please upgrade @sentio/sdk to match this CLI's version."
64
+ )
65
+ )
49
66
  process.exit(1)
50
67
  }
51
68
 
@@ -11,7 +11,7 @@ import { CommonExecOptions, execFileSync } from 'child_process'
11
11
  import { getApiUrl, getSdkVersion } from '../utils.js'
12
12
  import readline from 'readline'
13
13
  import JSZip from 'jszip'
14
- import type { UserInfo } from '../../../protos/lib/service/common/protos/common_pb.js'
14
+ import type { UserInfo } from '../../../protos/dist/service/common/protos/common_pb.js'
15
15
  import { CommandOptionsType } from './types.js'
16
16
  import {
17
17
  getSentioNetworkConfig,
package/src/utils.ts CHANGED
@@ -65,6 +65,56 @@ export async function printVersions() {
65
65
  } catch (e) {}
66
66
  }
67
67
 
68
+ function majorVersion(version: string): number | undefined {
69
+ const major = Number.parseInt(version.split('.')[0], 10)
70
+ return Number.isNaN(major) ? undefined : major
71
+ }
72
+
73
+ /**
74
+ * Whether the installed @sentio/sdk is compatible with the given @sentio/cli.
75
+ * @sentio/cli, @sentio/sdk and @sentio/runtime are released in lockstep, so they
76
+ * are only compatible when their major versions match — the CLI drives the SDK's
77
+ * build tooling (it runs the SDK's `dist/tsdown.config.js`), which changes across
78
+ * majors. Development builds and unparseable versions are treated as compatible so
79
+ * the local workspace and test flows are never blocked.
80
+ */
81
+ export function isSdkVersionCompatible(cliVersion: string, sdkVersion: string): boolean {
82
+ if (cliVersion.endsWith('-development') || sdkVersion.endsWith('-development')) {
83
+ return true
84
+ }
85
+ const cliMajor = majorVersion(cliVersion)
86
+ const sdkMajor = majorVersion(sdkVersion)
87
+ if (cliMajor === undefined || sdkMajor === undefined) {
88
+ return true
89
+ }
90
+ return sdkMajor === cliMajor
91
+ }
92
+
93
+ /**
94
+ * Fail fast with a clear message when the installed @sentio/sdk is too old for this
95
+ * CLI, instead of letting the build crash later with a cryptic packaging error.
96
+ */
97
+ export function checkSdkCompatibility() {
98
+ const cliVersion = getCliVersion()
99
+ const sdkVersion = getSdkVersion()
100
+ // SDK is not installed (e.g. `sentio create` in a fresh dir): nothing to validate.
101
+ if (!sdkVersion) {
102
+ return
103
+ }
104
+ if (!isSdkVersionCompatible(cliVersion, sdkVersion)) {
105
+ const cliMajor = majorVersion(cliVersion)
106
+ const sdkMajor = majorVersion(sdkVersion)
107
+ console.error(
108
+ chalk.red(
109
+ `Version mismatch: @sentio/cli ${cliVersion} (v${cliMajor}) and @sentio/sdk ${sdkVersion} (v${sdkMajor}) ` +
110
+ `must share the same major version.\n` +
111
+ `Please align them, e.g. install @sentio/sdk@^${cliMajor} (or switch to @sentio/cli@^${sdkMajor} to match the installed SDK).`
112
+ )
113
+ )
114
+ process.exit(1)
115
+ }
116
+ }
117
+
68
118
  export function getApiUrl(apiPath: string, host: string) {
69
119
  let apiHost = host
70
120
  if (host.includes('sentio.xyz')) {