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