@squidcloud/cli 1.0.385 → 1.0.387
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 +47 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -2319,6 +2319,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
2319
2319
|
})();
|
2320
2320
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
2321
2321
|
exports.TsoaUtils = void 0;
|
2322
|
+
exports.checkUserCodeUsesTsoa = checkUserCodeUsesTsoa;
|
2322
2323
|
const fs = __importStar(__webpack_require__(9896));
|
2323
2324
|
const fsPromises = __importStar(__webpack_require__(1943));
|
2324
2325
|
const path = __importStar(__webpack_require__(6928));
|
@@ -2334,6 +2335,7 @@ class TsoaUtils {
|
|
2334
2335
|
files = files.filter(file => /^tsoa.*\.json$/.test(file));
|
2335
2336
|
// If an exact "tsoa.json" is not present, get the fallback path.
|
2336
2337
|
if (!files.includes('tsoa.json')) {
|
2338
|
+
const hasAnyTsoaFilesProvidedByUser = files.length > 0;
|
2337
2339
|
const localBackendModule = await (0, resolve_1.findModulePath)('@squidcloud/local-backend');
|
2338
2340
|
if (localBackendModule) {
|
2339
2341
|
const fallback = path.relative(process.cwd(), path.resolve(localBackendModule, '../../tsoa.json'));
|
@@ -2341,6 +2343,20 @@ class TsoaUtils {
|
|
2341
2343
|
console.log(`"tsoa.json" not found in current directory. Using fallback: ${fallback}`);
|
2342
2344
|
}
|
2343
2345
|
files.push(fallback);
|
2346
|
+
// Optimization & the way to suppress tsoa errors in IntelliJ IDEA debug session, where IDEA listens directly
|
2347
|
+
// to the spawned process output:
|
2348
|
+
// We know that our own tsoa.json will check only files inside the 'src' directory.
|
2349
|
+
// If this directory contains no '@Route' annotations - there are no tsoa controllers and there is no need to
|
2350
|
+
// run tsoa at all.
|
2351
|
+
if (!hasAnyTsoaFilesProvidedByUser) {
|
2352
|
+
const hasTsoaAnnotationsInUserCode = await checkUserCodeUsesTsoa(path.resolve(process.cwd(), 'src'));
|
2353
|
+
if (!hasTsoaAnnotationsInUserCode) {
|
2354
|
+
if (verbose) {
|
2355
|
+
console.log('No TSOA annotations were found in the user code; skipping API generation with TSOA.');
|
2356
|
+
}
|
2357
|
+
return { openApiControllersMap: {}, openApiSpecsMap: {} };
|
2358
|
+
}
|
2359
|
+
}
|
2344
2360
|
}
|
2345
2361
|
else if (verbose) {
|
2346
2362
|
console.log(`"tsoa.json" not found and no local-backend module found.`);
|
@@ -2552,6 +2568,36 @@ class TsoaUtils {
|
|
2552
2568
|
}
|
2553
2569
|
}
|
2554
2570
|
exports.TsoaUtils = TsoaUtils;
|
2571
|
+
/** Case-sensitive regex to detect @Route() annotations. Allows any whitespace before the "(". */
|
2572
|
+
const ROUTE_ANNOTATION_REGEX = /@Route\s*\(/;
|
2573
|
+
const TSOA_FILE_EXT_CHECK_REGEX = /\.(ts|tsx|js|jsx)$/;
|
2574
|
+
/**
|
2575
|
+
* Recursively scans the given directory for TSOA controller annotations.
|
2576
|
+
* Returns true if any file contains an `@Route(` decorator.
|
2577
|
+
*/
|
2578
|
+
async function checkUserCodeUsesTsoa(srcDir) {
|
2579
|
+
try {
|
2580
|
+
const entries = await fsPromises.readdir(srcDir, { withFileTypes: true });
|
2581
|
+
for (const entry of entries) {
|
2582
|
+
const fullPath = path.join(srcDir, entry.name);
|
2583
|
+
if (entry.isDirectory()) {
|
2584
|
+
if (await checkUserCodeUsesTsoa(fullPath)) {
|
2585
|
+
return true;
|
2586
|
+
}
|
2587
|
+
}
|
2588
|
+
else if (entry.isFile() && TSOA_FILE_EXT_CHECK_REGEX.test(entry.name)) {
|
2589
|
+
const content = await fsPromises.readFile(fullPath, 'utf-8');
|
2590
|
+
if (ROUTE_ANNOTATION_REGEX.test(content)) {
|
2591
|
+
return true;
|
2592
|
+
}
|
2593
|
+
}
|
2594
|
+
}
|
2595
|
+
}
|
2596
|
+
catch {
|
2597
|
+
// If the directory doesn't exist or can't be read, assume no TSOA usage.
|
2598
|
+
}
|
2599
|
+
return false;
|
2600
|
+
}
|
2555
2601
|
|
2556
2602
|
|
2557
2603
|
/***/ }),
|
@@ -22376,7 +22422,7 @@ function exitWithError(...messages) {
|
|
22376
22422
|
/***/ ((module) => {
|
22377
22423
|
|
22378
22424
|
"use strict";
|
22379
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.
|
22425
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.387","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","build:prod":"webpack --mode=production","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.387","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.96.0","zip-webpack-plugin":"^4.0.1"},"devDependencies":{"@types/decompress":"^4.2.7","@types/node":"^20.16.10","terminal-link":"^3.0.0"}}');
|
22380
22426
|
|
22381
22427
|
/***/ }),
|
22382
22428
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squidcloud/cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.387",
|
4
4
|
"description": "The Squid CLI",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"node": ">=18.0.0"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@squidcloud/local-backend": "^1.0.
|
32
|
+
"@squidcloud/local-backend": "^1.0.387",
|
33
33
|
"copy-webpack-plugin": "^12.0.2",
|
34
34
|
"decompress": "^4.2.1",
|
35
35
|
"nodemon": "^3.1.3",
|