@squidcloud/cli 1.0.340 → 1.0.342
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
@@ -981,13 +981,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
981
981
|
};
|
982
982
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
983
983
|
exports["default"] = default_1;
|
984
|
-
const shell_runner_1 = __webpack_require__(5699);
|
985
984
|
const fs = __importStar(__webpack_require__(1943));
|
986
985
|
const process_utils_1 = __webpack_require__(8251);
|
987
986
|
const resolve_1 = __webpack_require__(412);
|
988
987
|
const path_1 = __importDefault(__webpack_require__(6928));
|
989
988
|
const validate_1 = __webpack_require__(2246);
|
990
989
|
const logging_1 = __webpack_require__(443);
|
990
|
+
const shell_runner_1 = __webpack_require__(3089);
|
991
991
|
async function default_1() {
|
992
992
|
const packageJson = await (0, validate_1.validateSquidProject)();
|
993
993
|
console.log((0, logging_1.primary)('Please note:'), 'to debug your application, you need to run the "start" npm script in your IDE in debug mode');
|
@@ -2363,7 +2363,7 @@ const fs = __importStar(__webpack_require__(9896));
|
|
2363
2363
|
const fsPromises = __importStar(__webpack_require__(1943));
|
2364
2364
|
const path = __importStar(__webpack_require__(6928));
|
2365
2365
|
const resolve_1 = __webpack_require__(412);
|
2366
|
-
const shell_runner_1 = __webpack_require__(
|
2366
|
+
const shell_runner_1 = __webpack_require__(3089);
|
2367
2367
|
class TsoaUtils {
|
2368
2368
|
constructor() { }
|
2369
2369
|
static async generateAllSpecs(verbose = false, supportsDefault = true) {
|
@@ -2447,10 +2447,11 @@ class TsoaUtils {
|
|
2447
2447
|
console.log(`Running: ${routesCmd}`);
|
2448
2448
|
}
|
2449
2449
|
try {
|
2450
|
-
await Promise.all([(0, shell_runner_1.runInShell)(specCmd, process.cwd()), (0, shell_runner_1.runInShell)(routesCmd, process.cwd())]);
|
2450
|
+
await Promise.all([(0, shell_runner_1.runInShell)(specCmd, false, process.cwd()), (0, shell_runner_1.runInShell)(routesCmd, false, process.cwd())]);
|
2451
2451
|
}
|
2452
2452
|
catch (e) {
|
2453
|
-
const
|
2453
|
+
const combinedOutput = e?.combinedOutput;
|
2454
|
+
const errorMessage = combinedOutput ? JSON.stringify(combinedOutput) : e;
|
2454
2455
|
if (typeof errorMessage === 'string' && errorMessage.includes('no controllers found')) {
|
2455
2456
|
if (verbose) {
|
2456
2457
|
console.log(`No controllers found for ${file}, skipping...`);
|
@@ -2470,9 +2471,10 @@ class TsoaUtils {
|
|
2470
2471
|
const routesOutput = path.join(outputDir, 'routes.ts');
|
2471
2472
|
try {
|
2472
2473
|
const swaggerContent = await fsPromises.readFile(swaggerOutput, { encoding: 'utf8' });
|
2474
|
+
const modifiedSwaggerContent = await TsoaUtils.attachCodeSamples(swaggerContent);
|
2473
2475
|
const routesContent = await fsPromises.readFile(routesOutput, { encoding: 'utf8' });
|
2474
2476
|
specsMap[specName] = {
|
2475
|
-
openApiSpecStr:
|
2477
|
+
openApiSpecStr: modifiedSwaggerContent,
|
2476
2478
|
openApiControllersStr: routesContent,
|
2477
2479
|
};
|
2478
2480
|
}
|
@@ -2509,6 +2511,85 @@ class TsoaUtils {
|
|
2509
2511
|
return namePart || 'default';
|
2510
2512
|
}
|
2511
2513
|
}
|
2514
|
+
static async attachCodeSamples(swaggerContent) {
|
2515
|
+
const parsedSpec = JSON.parse(swaggerContent);
|
2516
|
+
const paths = parsedSpec.paths;
|
2517
|
+
for (const route in paths) {
|
2518
|
+
// renamed to avoid conflict with Node's "path" module
|
2519
|
+
const methods = paths[route];
|
2520
|
+
for (const method in methods) {
|
2521
|
+
const operation = methods[method];
|
2522
|
+
const originalDescription = operation['description'] || '';
|
2523
|
+
// Split description into individual lines
|
2524
|
+
const lines = originalDescription.split('\n');
|
2525
|
+
// Find lines that contain the directive
|
2526
|
+
const directiveLines = lines.filter(line => line.includes('--squidCodeSampleFile'));
|
2527
|
+
// Remove the directive lines from the description
|
2528
|
+
operation['description'] = lines
|
2529
|
+
.filter(line => !line.includes('--squidCodeSampleFile'))
|
2530
|
+
.join('\n')
|
2531
|
+
.trim();
|
2532
|
+
// Prepare an array to hold the code samples
|
2533
|
+
const codeSamples = [];
|
2534
|
+
for (const line of directiveLines) {
|
2535
|
+
// Find the directive in the line and extract the remainder
|
2536
|
+
const index = line.indexOf('--squidCodeSampleFile');
|
2537
|
+
const directiveContent = line.slice(index + '--squidCodeSampleFile'.length).trim();
|
2538
|
+
// Expecting format: "<file-path>,<label>"
|
2539
|
+
const parts = directiveContent.split(',').map(item => item.trim());
|
2540
|
+
if (parts.length < 2) {
|
2541
|
+
console.warn(`Directive format invalid: ${line}`);
|
2542
|
+
continue;
|
2543
|
+
}
|
2544
|
+
const [codeSampleFilePath, codeSampleLabel] = parts;
|
2545
|
+
// Determine language based on file extension
|
2546
|
+
let lang = 'Text';
|
2547
|
+
if (codeSampleFilePath.endsWith('.ts')) {
|
2548
|
+
lang = 'TypeScript';
|
2549
|
+
}
|
2550
|
+
else if (codeSampleFilePath.endsWith('.js')) {
|
2551
|
+
lang = 'JavaScript';
|
2552
|
+
}
|
2553
|
+
else if (codeSampleFilePath.endsWith('.py')) {
|
2554
|
+
lang = 'Python';
|
2555
|
+
}
|
2556
|
+
// Construct the full file path
|
2557
|
+
const fullCodeSamplePath = path.join(process.cwd(), codeSampleFilePath);
|
2558
|
+
let codeSampleContent;
|
2559
|
+
try {
|
2560
|
+
codeSampleContent = await fsPromises.readFile(fullCodeSamplePath, { encoding: 'utf8' });
|
2561
|
+
// Remove lines with '@ignore' and also remove the line immediately after each ignore line
|
2562
|
+
const codeLines = codeSampleContent.split('\n');
|
2563
|
+
const filteredLines = [];
|
2564
|
+
for (let i = 0; i < codeLines.length; i++) {
|
2565
|
+
if (codeLines[i].trim().includes('@ignore')) {
|
2566
|
+
// Skip this line and the next line
|
2567
|
+
i++;
|
2568
|
+
continue;
|
2569
|
+
}
|
2570
|
+
filteredLines.push(codeLines[i]);
|
2571
|
+
}
|
2572
|
+
codeSampleContent = filteredLines.join('\n').trim();
|
2573
|
+
}
|
2574
|
+
catch (e) {
|
2575
|
+
console.error(`Error reading code sample file ${codeSampleFilePath}:`, e);
|
2576
|
+
throw e;
|
2577
|
+
}
|
2578
|
+
// Add the code sample to the array
|
2579
|
+
codeSamples.push({
|
2580
|
+
lang,
|
2581
|
+
label: codeSampleLabel,
|
2582
|
+
source: codeSampleContent,
|
2583
|
+
});
|
2584
|
+
}
|
2585
|
+
// Attach the x-codeSamples entry if any directives were found
|
2586
|
+
if (codeSamples.length > 0) {
|
2587
|
+
operation['x-codeSamples'] = codeSamples;
|
2588
|
+
}
|
2589
|
+
}
|
2590
|
+
}
|
2591
|
+
return JSON.stringify(parsedSpec, null, 2);
|
2592
|
+
}
|
2512
2593
|
}
|
2513
2594
|
exports.TsoaUtils = TsoaUtils;
|
2514
2595
|
|
@@ -5869,7 +5950,7 @@ async function validateSquidProject() {
|
|
5869
5950
|
const packageJson = await promises_1.default.readFile('package.json', 'utf8');
|
5870
5951
|
const parsedJson = JSON.parse(packageJson);
|
5871
5952
|
const { scripts } = parsedJson;
|
5872
|
-
if (!scripts?.['start-squid'] && !scripts?.['start'].
|
5953
|
+
if (!scripts?.['start-squid'] && !scripts?.['start'].includes('squid start')) {
|
5873
5954
|
(0, process_utils_1.exitWithError)(exports.INVALID_PROJECT_ERROR);
|
5874
5955
|
}
|
5875
5956
|
return parsedJson;
|
@@ -8113,6 +8194,78 @@ async function reportLocalBackendInitialized(appId, apiKey, appRegion, verbose)
|
|
8113
8194
|
}
|
8114
8195
|
|
8115
8196
|
|
8197
|
+
/***/ }),
|
8198
|
+
|
8199
|
+
/***/ 3089:
|
8200
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
8201
|
+
|
8202
|
+
"use strict";
|
8203
|
+
|
8204
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
8205
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
8206
|
+
};
|
8207
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
8208
|
+
exports.runInShell = runInShell;
|
8209
|
+
exports.printCombinedOutput = printCombinedOutput;
|
8210
|
+
const child_process_1 = __webpack_require__(5317);
|
8211
|
+
const process_1 = __importDefault(__webpack_require__(932));
|
8212
|
+
function runInShell(command, printMessages = true, cwd = process_1.default.cwd(), envVars) {
|
8213
|
+
return new Promise((resolve, reject) => {
|
8214
|
+
const execution = (0, child_process_1.spawn)(command, {
|
8215
|
+
cwd,
|
8216
|
+
shell: true,
|
8217
|
+
stdio: 'pipe',
|
8218
|
+
env: envVars ? { ...process_1.default.env, ...envVars } : undefined,
|
8219
|
+
});
|
8220
|
+
const combinedOutput = [];
|
8221
|
+
execution.stdout.on('data', data => {
|
8222
|
+
const str = data.toString();
|
8223
|
+
combinedOutput.push({ level: 'info', message: str });
|
8224
|
+
if (printMessages)
|
8225
|
+
stdoutLog(str);
|
8226
|
+
});
|
8227
|
+
execution.stderr.on('data', data => {
|
8228
|
+
const str = data.toString();
|
8229
|
+
combinedOutput.push({ level: 'error', message: str });
|
8230
|
+
if (printMessages)
|
8231
|
+
stderrLog(str);
|
8232
|
+
});
|
8233
|
+
execution.on('error', error => {
|
8234
|
+
reject(error);
|
8235
|
+
});
|
8236
|
+
execution.on('exit', code => {
|
8237
|
+
if (code === 0) {
|
8238
|
+
resolve({ combinedOutput });
|
8239
|
+
}
|
8240
|
+
else {
|
8241
|
+
const errorMessage = `The command exited with code ${code}`;
|
8242
|
+
if (printMessages) {
|
8243
|
+
printCombinedOutput(combinedOutput);
|
8244
|
+
}
|
8245
|
+
const processError = { errorMessage, combinedOutput };
|
8246
|
+
reject(processError);
|
8247
|
+
}
|
8248
|
+
});
|
8249
|
+
});
|
8250
|
+
}
|
8251
|
+
function printCombinedOutput(combinedOutput) {
|
8252
|
+
for (const line of combinedOutput) {
|
8253
|
+
if (line.level === 'error') {
|
8254
|
+
stderrLog(line.message);
|
8255
|
+
}
|
8256
|
+
else {
|
8257
|
+
stdoutLog(line.message);
|
8258
|
+
}
|
8259
|
+
}
|
8260
|
+
}
|
8261
|
+
function stdoutLog(message) {
|
8262
|
+
process_1.default.stdout.write(message);
|
8263
|
+
}
|
8264
|
+
function stderrLog(message) {
|
8265
|
+
process_1.default.stderr.write(message);
|
8266
|
+
}
|
8267
|
+
|
8268
|
+
|
8116
8269
|
/***/ }),
|
8117
8270
|
|
8118
8271
|
/***/ 3106:
|
@@ -8366,41 +8519,6 @@ module.exports = require("string_decoder");
|
|
8366
8519
|
"use strict";
|
8367
8520
|
module.exports = require("module");
|
8368
8521
|
|
8369
|
-
/***/ }),
|
8370
|
-
|
8371
|
-
/***/ 3344:
|
8372
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
8373
|
-
|
8374
|
-
"use strict";
|
8375
|
-
|
8376
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
8377
|
-
exports.runInShell = runInShell;
|
8378
|
-
const child_process_1 = __webpack_require__(5317);
|
8379
|
-
/** @internal */
|
8380
|
-
function runInShell(command, cwd = process.cwd()) {
|
8381
|
-
return new Promise((resolve, reject) => {
|
8382
|
-
const process = (0, child_process_1.spawn)(command, { cwd, shell: true, stdio: 'pipe' });
|
8383
|
-
let stdout = '';
|
8384
|
-
let stderr = '';
|
8385
|
-
process.stdout.on('data', data => {
|
8386
|
-
stdout += data.toString();
|
8387
|
-
});
|
8388
|
-
process.stderr.on('data', data => {
|
8389
|
-
stderr += data.toString();
|
8390
|
-
});
|
8391
|
-
process.on('error', error => reject(error));
|
8392
|
-
process.on('exit', code => {
|
8393
|
-
if (code === 0) {
|
8394
|
-
resolve({ stdout, stderr });
|
8395
|
-
}
|
8396
|
-
else {
|
8397
|
-
reject({ err: new Error(`The command exited with code ${code}`), stdout, stderr });
|
8398
|
-
}
|
8399
|
-
});
|
8400
|
-
});
|
8401
|
-
}
|
8402
|
-
|
8403
|
-
|
8404
8522
|
/***/ }),
|
8405
8523
|
|
8406
8524
|
/***/ 3367:
|
@@ -11757,12 +11875,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11757
11875
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
11758
11876
|
exports["default"] = initSample;
|
11759
11877
|
const promises_1 = __importDefault(__webpack_require__(1943));
|
11760
|
-
const shell_runner_1 = __webpack_require__(5699);
|
11761
11878
|
const path_1 = __importDefault(__webpack_require__(6928));
|
11762
11879
|
const report_utils_1 = __webpack_require__(3066);
|
11763
11880
|
const process_utils_1 = __webpack_require__(8251);
|
11764
11881
|
const git_utils_1 = __webpack_require__(954);
|
11765
11882
|
const logging_1 = __webpack_require__(443);
|
11883
|
+
const shell_runner_1 = __webpack_require__(3089);
|
11766
11884
|
const ORG = 'squid-cloud-samples';
|
11767
11885
|
async function initSample(dirPath, appId, apiKey, environmentId, squidDeveloperId, region, templateName, verbose = false) {
|
11768
11886
|
try {
|
@@ -15722,69 +15840,6 @@ module.exports = () => input => {
|
|
15722
15840
|
};
|
15723
15841
|
|
15724
15842
|
|
15725
|
-
/***/ }),
|
15726
|
-
|
15727
|
-
/***/ 5699:
|
15728
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
15729
|
-
|
15730
|
-
"use strict";
|
15731
|
-
|
15732
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
15733
|
-
exports.runInShell = runInShell;
|
15734
|
-
exports.printCombinedOutput = printCombinedOutput;
|
15735
|
-
const child_process_1 = __webpack_require__(5317);
|
15736
|
-
function runInShell(command, printMessages = true, cwd = process.cwd()) {
|
15737
|
-
return new Promise((resolve, reject) => {
|
15738
|
-
const process = (0, child_process_1.spawn)(command, { cwd, shell: true, stdio: 'pipe' });
|
15739
|
-
const combinedOutput = [];
|
15740
|
-
process.stdout.on('data', data => {
|
15741
|
-
const str = data.toString();
|
15742
|
-
combinedOutput.push({ level: 'info', message: str });
|
15743
|
-
if (printMessages)
|
15744
|
-
stdoutLog(str);
|
15745
|
-
});
|
15746
|
-
process.stderr.on('data', data => {
|
15747
|
-
const str = data.toString();
|
15748
|
-
combinedOutput.push({ level: 'error', message: str });
|
15749
|
-
if (printMessages)
|
15750
|
-
stderrLog(str);
|
15751
|
-
});
|
15752
|
-
process.on('error', error => {
|
15753
|
-
reject(error);
|
15754
|
-
});
|
15755
|
-
process.on('exit', code => {
|
15756
|
-
if (code === 0) {
|
15757
|
-
resolve({ combinedOutput });
|
15758
|
-
}
|
15759
|
-
else {
|
15760
|
-
const errorMessage = `The command exited with code ${code}`;
|
15761
|
-
if (printMessages) {
|
15762
|
-
printCombinedOutput(combinedOutput);
|
15763
|
-
}
|
15764
|
-
const processError = { errorMessage, combinedOutput };
|
15765
|
-
reject(processError);
|
15766
|
-
}
|
15767
|
-
});
|
15768
|
-
});
|
15769
|
-
}
|
15770
|
-
function printCombinedOutput(combinedOutput) {
|
15771
|
-
for (const line of combinedOutput) {
|
15772
|
-
if (line.level === 'error') {
|
15773
|
-
stderrLog(line.message);
|
15774
|
-
}
|
15775
|
-
else {
|
15776
|
-
stdoutLog(line.message);
|
15777
|
-
}
|
15778
|
-
}
|
15779
|
-
}
|
15780
|
-
function stdoutLog(message) {
|
15781
|
-
process.stdout.write(message);
|
15782
|
-
}
|
15783
|
-
function stderrLog(message) {
|
15784
|
-
process.stderr.write(message);
|
15785
|
-
}
|
15786
|
-
|
15787
|
-
|
15788
15843
|
/***/ }),
|
15789
15844
|
|
15790
15845
|
/***/ 5704:
|
@@ -22712,7 +22767,7 @@ function exitWithError(...messages) {
|
|
22712
22767
|
/***/ ((module) => {
|
22713
22768
|
|
22714
22769
|
"use strict";
|
22715
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.
|
22770
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.342","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.342","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"}}');
|
22716
22771
|
|
22717
22772
|
/***/ }),
|
22718
22773
|
|
@@ -23566,12 +23621,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
23566
23621
|
exports["default"] = default_1;
|
23567
23622
|
const environment_1 = __webpack_require__(722);
|
23568
23623
|
const process_utils_1 = __webpack_require__(8251);
|
23569
|
-
const shell_runner_1 = __webpack_require__(5699);
|
23570
23624
|
const fs = __importStar(__webpack_require__(1943));
|
23571
23625
|
const http_1 = __webpack_require__(866);
|
23572
23626
|
const communication_types_1 = __webpack_require__(3443);
|
23573
23627
|
const console_app_utils_1 = __webpack_require__(7580);
|
23574
23628
|
const assertic_1 = __webpack_require__(5036);
|
23629
|
+
const shell_runner_1 = __webpack_require__(3089);
|
23575
23630
|
async function default_1(stage, appId, bundlePath, apiKey, verbose, direct, isUserSpecifiedPath, skipBuild, internalApiKey, environmentId) {
|
23576
23631
|
if (!direct && !isUserSpecifiedPath && !skipBuild) {
|
23577
23632
|
console.log('Building code bundle...');
|
@@ -6,7 +6,7 @@ export interface ProcessError {
|
|
6
6
|
errorMessage: string;
|
7
7
|
combinedOutput: Array<ErrorLine>;
|
8
8
|
}
|
9
|
-
export declare function runInShell(command: string, printMessages?: boolean, cwd?: string): Promise<{
|
9
|
+
export declare function runInShell(command: string, printMessages?: boolean, cwd?: string, envVars?: Record<string, string>): Promise<{
|
10
10
|
combinedOutput: Array<ErrorLine>;
|
11
11
|
}>;
|
12
12
|
export declare function printCombinedOutput(combinedOutput: Array<ErrorLine>): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squidcloud/cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.342",
|
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.342",
|
33
33
|
"copy-webpack-plugin": "^12.0.2",
|
34
34
|
"decompress": "^4.2.1",
|
35
35
|
"nodemon": "^3.1.3",
|