@squidcloud/cli 1.0.403 → 1.0.405

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.
Files changed (2) hide show
  1. package/dist/index.js +163 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1722,7 +1722,6 @@ exports.KOTLIN_CONTROLLERS = [
1722
1722
  'internal-storage',
1723
1723
  'internalCodeExecutor',
1724
1724
  'mutation',
1725
- 'named-query',
1726
1725
  'native-query',
1727
1726
  'observability',
1728
1727
  'openapi',
@@ -4500,6 +4499,39 @@ module.exports = () => input => {
4500
4499
  };
4501
4500
 
4502
4501
 
4502
+ /***/ }),
4503
+
4504
+ /***/ 1929:
4505
+ /***/ ((__unused_webpack_module, exports) => {
4506
+
4507
+ "use strict";
4508
+
4509
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4510
+ exports.MILLIS_PER_MONTH = exports.MILLIS_PER_WEEK = exports.MILLIS_PER_DAY = exports.MILLIS_PER_HOUR = exports.MILLIS_PER_MINUTE = exports.MILLIS_PER_SECOND = exports.SECONDS_PER_MONTH = exports.SECONDS_PER_WEEK = exports.SECONDS_PER_DAY = exports.SECONDS_PER_HOUR = exports.SECONDS_PER_MINUTE = void 0;
4511
+ /** @internal */
4512
+ exports.SECONDS_PER_MINUTE = 60;
4513
+ /** @internal */
4514
+ exports.SECONDS_PER_HOUR = 60 * exports.SECONDS_PER_MINUTE;
4515
+ /** @internal */
4516
+ exports.SECONDS_PER_DAY = 24 * exports.SECONDS_PER_HOUR;
4517
+ /** @internal */
4518
+ exports.SECONDS_PER_WEEK = 7 * exports.SECONDS_PER_DAY;
4519
+ /** @internal */
4520
+ exports.SECONDS_PER_MONTH = 30 * exports.SECONDS_PER_DAY;
4521
+ /** @internal */
4522
+ exports.MILLIS_PER_SECOND = 1000;
4523
+ /** @internal */
4524
+ exports.MILLIS_PER_MINUTE = exports.SECONDS_PER_MINUTE * exports.MILLIS_PER_SECOND;
4525
+ /** @internal */
4526
+ exports.MILLIS_PER_HOUR = exports.SECONDS_PER_HOUR * exports.MILLIS_PER_SECOND;
4527
+ /** @internal */
4528
+ exports.MILLIS_PER_DAY = exports.SECONDS_PER_DAY * exports.MILLIS_PER_SECOND;
4529
+ /** @internal */
4530
+ exports.MILLIS_PER_WEEK = exports.SECONDS_PER_WEEK * exports.MILLIS_PER_SECOND;
4531
+ /** @internal */
4532
+ exports.MILLIS_PER_MONTH = exports.SECONDS_PER_MONTH * exports.MILLIS_PER_SECOND;
4533
+
4534
+
4503
4535
  /***/ }),
4504
4536
 
4505
4537
  /***/ 1943:
@@ -11828,9 +11860,14 @@ function setupBuildCommand(yargs) {
11828
11860
  description: 'Builds the project in development mode',
11829
11861
  default: false,
11830
11862
  });
11863
+ yargs.option('skip-version-check', {
11864
+ type: 'boolean',
11865
+ description: 'Skip the CLI version check',
11866
+ default: false,
11867
+ });
11831
11868
  }, async (argv) => {
11832
11869
  await (0, validate_1.validateSquidProject)();
11833
- await (0, build_1.build)({ verbose: !!argv.verbose, dev: !!argv.dev });
11870
+ await (0, build_1.build)({ verbose: !!argv.verbose, dev: !!argv.dev, skipVersionCheck: !!argv['skip-version-check'] });
11834
11871
  });
11835
11872
  }
11836
11873
  run();
@@ -13878,6 +13915,96 @@ module.exports = stringWidth;
13878
13915
  module.exports["default"] = stringWidth;
13879
13916
 
13880
13917
 
13918
+ /***/ }),
13919
+
13920
+ /***/ 4827:
13921
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
13922
+
13923
+ "use strict";
13924
+
13925
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13926
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13927
+ };
13928
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
13929
+ exports.checkCliVersion = checkCliVersion;
13930
+ const assertic_1 = __webpack_require__(3205);
13931
+ const chalk_1 = __importDefault(__webpack_require__(7459));
13932
+ const time_units_1 = __webpack_require__(1929);
13933
+ /**
13934
+ * Checks if the current CLI version is outdated compared to the npm registry.
13935
+ * Returns a warning message if outdated, null otherwise.
13936
+ * Silently catches and ignores all errors.
13937
+ *
13938
+ * @param currentVersion The current version of the CLI
13939
+ * @returns Promise resolving to a warning message or undefined.
13940
+ */
13941
+ async function checkCliVersion(currentVersion) {
13942
+ try {
13943
+ // Fetch package info from the npm registry with a 10-second timeout.
13944
+ const controller = new AbortController();
13945
+ const timeoutId = setTimeout(() => controller.abort(), 10 * time_units_1.MILLIS_PER_SECOND);
13946
+ const response = await fetch('https://registry.npmjs.org/@squidcloud/cli', { signal: controller.signal });
13947
+ clearTimeout(timeoutId);
13948
+ if (!response.ok) {
13949
+ // If the check is failed for some reason - do not alert.
13950
+ return undefined;
13951
+ }
13952
+ const packageInfo = await response.json();
13953
+ const latestVersion = packageInfo['dist-tags'].latest;
13954
+ const isOutdated = isVersionOutdated(currentVersion, latestVersion, packageInfo.time);
13955
+ return isOutdated ? formatWarningMessage(currentVersion, latestVersion) : undefined;
13956
+ }
13957
+ catch (_error) {
13958
+ // Silently ignore all errors (network issues, parsing errors, etc.).
13959
+ return undefined;
13960
+ }
13961
+ }
13962
+ /**
13963
+ * Determines if the current version is outdated based on:
13964
+ * - Older than 1 month (based on the latest version publish date)
13965
+ * - OR more than 10 patch versions behind.
13966
+ */
13967
+ function isVersionOutdated(currentVersion, latestVersion, timeData) {
13968
+ // Check patch version difference.
13969
+ const patchDiff = getPatchVersionDifference(currentVersion, latestVersion);
13970
+ if (patchDiff > 10) {
13971
+ return true;
13972
+ }
13973
+ // Check if the latest version is older than 1 month.
13974
+ const latestPublishDate = timeData[latestVersion];
13975
+ (0, assertic_1.assertTruthy)(latestPublishDate, 'Failed to determine latest version publish date.');
13976
+ const publishTime = new Date(latestPublishDate).getTime();
13977
+ return Date.now() - publishTime > 30 * time_units_1.MILLIS_PER_DAY;
13978
+ }
13979
+ /**
13980
+ * Calculates the patch version difference between two semver versions.
13981
+ * Returns the absolute difference in patch numbers if major and minor are the same.
13982
+ * Returns a large number if major or minor versions differ.
13983
+ */
13984
+ function getPatchVersionDifference(currentVersion, latestVersion) {
13985
+ const current = parseVersion(currentVersion);
13986
+ const latest = parseVersion(latestVersion);
13987
+ if (current.major !== latest.major || current.minor !== latest.minor) {
13988
+ // If major or minor differs, consider it significantly outdated.
13989
+ return 999;
13990
+ }
13991
+ return Math.abs(latest.patch - current.patch);
13992
+ }
13993
+ /** Parses a semver version string into major, minor, and patch numbers. */
13994
+ function parseVersion(version) {
13995
+ const cleaned = version.replace(/^v/, '');
13996
+ const parts = cleaned.split('.').map(p => parseInt(p, 10));
13997
+ (0, assertic_1.assertTruthy)(parts.length === 3 && !parts.some(isNaN), `Invalid version format: ${version}`);
13998
+ return { major: parts[0], minor: parts[1], patch: parts[2] };
13999
+ }
14000
+ /**
14001
+ * Formats the warning message for display.
14002
+ */
14003
+ function formatWarningMessage(currentVersion, latestVersion) {
14004
+ return chalk_1.default.yellow(`⚠ Your @squidcloud/cli (${currentVersion}) is outdated. Latest: ${latestVersion}. Update: npm install -g @squidcloud/cli@latest`);
14005
+ }
14006
+
14007
+
13881
14008
  /***/ }),
13882
14009
 
13883
14010
  /***/ 4862:
@@ -22607,12 +22734,23 @@ var __importStar = (this && this.__importStar) || (function () {
22607
22734
  })();
22608
22735
  Object.defineProperty(exports, "__esModule", ({ value: true }));
22609
22736
  exports.exitWithError = exitWithError;
22737
+ exports.isEnvVarTruthy = isEnvVarTruthy;
22610
22738
  const process = __importStar(__webpack_require__(932));
22611
- /** Prints error message into console.error() and calls process.exit(1). */
22739
+ /** Prints the error message into console.error() and calls process.exit(1). */
22612
22740
  function exitWithError(...messages) {
22613
22741
  console.error(...messages);
22614
22742
  process.exit(1);
22615
22743
  }
22744
+ /**
22745
+ * Checks if an environment variable is set to a truthy value.
22746
+ * Considers 'true' and '1' as truthy values.
22747
+ * @param variableName The name of the environment variable
22748
+ * @returns true if the variable is set to 'true' or '1', false otherwise
22749
+ */
22750
+ function isEnvVarTruthy(variableName) {
22751
+ const value = process.env[variableName];
22752
+ return value === 'true' || value === '1';
22753
+ }
22616
22754
 
22617
22755
 
22618
22756
  /***/ }),
@@ -22621,7 +22759,7 @@ function exitWithError(...messages) {
22621
22759
  /***/ ((module) => {
22622
22760
 
22623
22761
  "use strict";
22624
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.403","description":"The Squid CLI","main":"dist/index.js","scripts":{"start":"node dist/index.js","start-ts":"ts-node -r tsconfig-paths/register src/index.ts","prebuild":"rimraf dist","build":"webpack --mode=production","build:dev":"webpack --mode=development","lint":"eslint","link":"npm run build && chmod 755 dist/index.js && npm link","watch":"webpack --watch","deploy":"npm run build && npm pack --silent | xargs -I {} mv {} package.tgz && npm install -g package.tgz && rm -rf package.tgz","publish:public":"npm run build && npm publish --access public"},"files":["dist/**/*"],"bin":{"squid":"dist/index.js"},"keywords":[],"author":"","license":"ISC","engines":{"node":">=18.0.0"},"dependencies":{"@squidcloud/local-backend":"^1.0.403","copy-webpack-plugin":"^12.0.2","decompress":"^4.2.1","nodemon":"^3.1.3","terser-webpack-plugin":"^5.3.10","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"^4.2.0","tsconfig-paths-webpack-plugin":"^4.1.0","webpack":"^5.101.3","zip-webpack-plugin":"^4.0.1"},"devDependencies":{"@types/decompress":"^4.2.7","@types/node":"^20.19.9","terminal-link":"^3.0.0"}}');
22762
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.405","description":"The Squid CLI","main":"dist/index.js","scripts":{"start":"node dist/index.js","start-ts":"ts-node -r tsconfig-paths/register src/index.ts","prebuild":"rimraf dist","build":"webpack --mode=production","build:dev":"webpack --mode=development","lint":"eslint","link":"npm run build && chmod 755 dist/index.js && npm link","watch":"webpack --watch","deploy":"npm run build && npm pack --silent | xargs -I {} mv {} package.tgz && npm install -g package.tgz && rm -rf package.tgz","publish:public":"npm run build && npm publish --access public"},"files":["dist/**/*"],"bin":{"squid":"dist/index.js"},"keywords":[],"author":"","license":"ISC","engines":{"node":">=18.0.0"},"dependencies":{"@squidcloud/local-backend":"^1.0.405","copy-webpack-plugin":"^12.0.2","decompress":"^4.2.1","nodemon":"^3.1.3","terser-webpack-plugin":"^5.3.10","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"^4.2.0","tsconfig-paths-webpack-plugin":"^4.1.0","webpack":"^5.101.3","zip-webpack-plugin":"^4.0.1"},"devDependencies":{"@types/decompress":"^4.2.7","@types/node":"^20.19.9","terminal-link":"^3.0.0"}}');
22625
22763
 
22626
22764
  /***/ }),
22627
22765
 
@@ -22754,15 +22892,30 @@ const logging_1 = __webpack_require__(443);
22754
22892
  const process_utils_1 = __webpack_require__(8251);
22755
22893
  const resolve_2 = __webpack_require__(3878);
22756
22894
  const validate_1 = __webpack_require__(2246);
22895
+ const version_check_1 = __webpack_require__(4827);
22757
22896
  function isEnvVarFalsy(variableName) {
22758
22897
  const value = process.env[variableName];
22759
22898
  return !value || value.toLowerCase() === 'false' || value === '0';
22760
22899
  }
22761
22900
  const useColorsInOutput = !isEnvVarFalsy('FORCE_COLOR') || isEnvVarFalsy('NO_COLOR');
22762
- async function build({ verbose, dev }) {
22901
+ async function displayVersionWarning(versionCheckPromise) {
22902
+ try {
22903
+ const versionWarning = await versionCheckPromise;
22904
+ if (versionWarning) {
22905
+ console.warn(versionWarning);
22906
+ }
22907
+ }
22908
+ catch (_ignored) { }
22909
+ }
22910
+ async function build({ verbose, dev, skipVersionCheck }) {
22763
22911
  if (verbose)
22764
22912
  console.log(`Starting Squid project build. CLI package version: ${packageJson.version}`);
22765
22913
  await (0, validate_1.validateSquidProject)();
22914
+ // Start version checks in the background if not disabled.
22915
+ const shouldSkipVersionCheck = skipVersionCheck || (0, process_utils_1.isEnvVarTruthy)('SQUID_SKIP_BUILD_TIME_VERSION_CHECK');
22916
+ // SQUID_CURRENT_CLI_VERSION_OVERRIDE is used for testing.
22917
+ const currentVersion = process.env['SQUID_CURRENT_CLI_VERSION_OVERRIDE'] || packageJson.version;
22918
+ const versionCheckPromise = shouldSkipVersionCheck ? Promise.resolve(undefined) : (0, version_check_1.checkCliVersion)(currentVersion);
22766
22919
  const distPath = path_1.default.resolve(process.cwd(), 'dist');
22767
22920
  if (fsSync.existsSync(distPath)) {
22768
22921
  if (verbose)
@@ -22770,7 +22923,7 @@ async function build({ verbose, dev }) {
22770
22923
  await fs_1.promises.rm(distPath, { recursive: true, force: true });
22771
22924
  }
22772
22925
  await fs_1.promises.mkdir(distPath);
22773
- const isSquidConnector = process.env['SQUID_CONNECTOR'] === 'true';
22926
+ const isSquidConnector = (0, process_utils_1.isEnvVarTruthy)('SQUID_CONNECTOR');
22774
22927
  const openApiSpecAndControllers = await tsoa_utils_1.TsoaUtils.generateAllSpecs(false, !isSquidConnector);
22775
22928
  await fs_1.promises.writeFile(path_1.default.join(distPath, '', 'openapi-spec-and-controllers.json'), JSON.stringify(openApiSpecAndControllers));
22776
22929
  const isUserConfigMode = fsSync.existsSync(resolve_2.USER_WEBPACK_CONFIG_PATH);
@@ -22808,8 +22961,12 @@ async function build({ verbose, dev }) {
22808
22961
  resolve();
22809
22962
  });
22810
22963
  });
22964
+ // Show version check warning after successful build.
22965
+ await displayVersionWarning(versionCheckPromise);
22811
22966
  }
22812
22967
  catch (e) {
22968
+ // Show a version check warning even if the build failed.
22969
+ await displayVersionWarning(versionCheckPromise);
22813
22970
  const errorMessage = (0, assertic_1.getMessageFromError)(e);
22814
22971
  if (verbose)
22815
22972
  console.log(`Exiting with error: ${errorMessage}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/cli",
3
- "version": "1.0.403",
3
+ "version": "1.0.405",
4
4
  "description": "The Squid CLI",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "node": ">=18.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@squidcloud/local-backend": "^1.0.403",
31
+ "@squidcloud/local-backend": "^1.0.405",
32
32
  "copy-webpack-plugin": "^12.0.2",
33
33
  "decompress": "^4.2.1",
34
34
  "nodemon": "^3.1.3",