@drttix/drt-sdk 1.2.2 → 1.2.3
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.
|
@@ -6,6 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
|
+
// On Windows, execFileSync with shell:true joins args without quoting, so paths
|
|
10
|
+
// containing spaces are split. Use execSync with manual quoting on Windows instead.
|
|
11
|
+
function runCommand(cmd, args) {
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
const quotedArgs = args.map((a) => (a.includes(' ') ? `"${a}"` : a));
|
|
14
|
+
(0, child_process_1.execSync)([cmd, ...quotedArgs].join(' '), { stdio: 'inherit' });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
(0, child_process_1.execFileSync)(cmd, args, { stdio: 'inherit' });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
9
20
|
// Load the spec list (use staging specs when --staging flag is passed)
|
|
10
21
|
const isStaging = process.argv.includes('--staging');
|
|
11
22
|
const specsFile = isStaging
|
|
@@ -27,11 +38,8 @@ for (const spec of specs) {
|
|
|
27
38
|
const tempSpecFile = path_1.default.join(process.cwd(), `${name}-spec.json`);
|
|
28
39
|
try {
|
|
29
40
|
console.log(`📥 Downloading spec from ${url}...`);
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
shell: true,
|
|
33
|
-
});
|
|
34
|
-
(0, child_process_1.execFileSync)(NPX_CMD, [
|
|
41
|
+
runCommand(CURL_CMD, ['-s', '-o', tempSpecFile, url]);
|
|
42
|
+
runCommand(NPX_CMD, [
|
|
35
43
|
'openapi-typescript-codegen',
|
|
36
44
|
'--input',
|
|
37
45
|
tempSpecFile,
|
|
@@ -39,7 +47,7 @@ for (const spec of specs) {
|
|
|
39
47
|
outputDir,
|
|
40
48
|
'--client',
|
|
41
49
|
'fetch',
|
|
42
|
-
]
|
|
50
|
+
]);
|
|
43
51
|
// Clean up temp file
|
|
44
52
|
fs_1.default.unlinkSync(tempSpecFile);
|
|
45
53
|
}
|
|
@@ -51,10 +59,7 @@ for (const spec of specs) {
|
|
|
51
59
|
throw error;
|
|
52
60
|
}
|
|
53
61
|
console.log(`⚙️ Generating wrapper for ${name}...`);
|
|
54
|
-
(
|
|
55
|
-
stdio: 'inherit',
|
|
56
|
-
shell: true,
|
|
57
|
-
});
|
|
62
|
+
runCommand(NPX_CMD, ['tsx', 'src/scripts/generate-definition.ts', name]);
|
|
58
63
|
}
|
|
59
64
|
// After generating all clients and definitions, replace request.ts for all services
|
|
60
65
|
const customRequestPath = path_1.default.resolve('src/custom/custom-request.txt');
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { execFileSync } from 'child_process';
|
|
3
|
+
import { execSync, execFileSync } from 'child_process';
|
|
4
|
+
// On Windows, execFileSync with shell:true joins args without quoting, so paths
|
|
5
|
+
// containing spaces are split. Use execSync with manual quoting on Windows instead.
|
|
6
|
+
function runCommand(cmd, args) {
|
|
7
|
+
if (process.platform === 'win32') {
|
|
8
|
+
const quotedArgs = args.map((a) => (a.includes(' ') ? `"${a}"` : a));
|
|
9
|
+
execSync([cmd, ...quotedArgs].join(' '), { stdio: 'inherit' });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
execFileSync(cmd, args, { stdio: 'inherit' });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
4
15
|
// Load the spec list (use staging specs when --staging flag is passed)
|
|
5
16
|
const isStaging = process.argv.includes('--staging');
|
|
6
17
|
const specsFile = isStaging
|
|
@@ -22,11 +33,8 @@ for (const spec of specs) {
|
|
|
22
33
|
const tempSpecFile = path.join(process.cwd(), `${name}-spec.json`);
|
|
23
34
|
try {
|
|
24
35
|
console.log(`📥 Downloading spec from ${url}...`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
shell: true,
|
|
28
|
-
});
|
|
29
|
-
execFileSync(NPX_CMD, [
|
|
36
|
+
runCommand(CURL_CMD, ['-s', '-o', tempSpecFile, url]);
|
|
37
|
+
runCommand(NPX_CMD, [
|
|
30
38
|
'openapi-typescript-codegen',
|
|
31
39
|
'--input',
|
|
32
40
|
tempSpecFile,
|
|
@@ -34,7 +42,7 @@ for (const spec of specs) {
|
|
|
34
42
|
outputDir,
|
|
35
43
|
'--client',
|
|
36
44
|
'fetch',
|
|
37
|
-
]
|
|
45
|
+
]);
|
|
38
46
|
// Clean up temp file
|
|
39
47
|
fs.unlinkSync(tempSpecFile);
|
|
40
48
|
}
|
|
@@ -46,10 +54,7 @@ for (const spec of specs) {
|
|
|
46
54
|
throw error;
|
|
47
55
|
}
|
|
48
56
|
console.log(`⚙️ Generating wrapper for ${name}...`);
|
|
49
|
-
|
|
50
|
-
stdio: 'inherit',
|
|
51
|
-
shell: true,
|
|
52
|
-
});
|
|
57
|
+
runCommand(NPX_CMD, ['tsx', 'src/scripts/generate-definition.ts', name]);
|
|
53
58
|
}
|
|
54
59
|
// After generating all clients and definitions, replace request.ts for all services
|
|
55
60
|
const customRequestPath = path.resolve('src/custom/custom-request.txt');
|
package/package.json
CHANGED
package/src/scripts/build-all.ts
CHANGED
|
@@ -2,6 +2,17 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { execSync, execFileSync } from 'child_process';
|
|
4
4
|
|
|
5
|
+
// On Windows, execFileSync with shell:true joins args without quoting, so paths
|
|
6
|
+
// containing spaces are split. Use execSync with manual quoting on Windows instead.
|
|
7
|
+
function runCommand(cmd: string, args: string[]): void {
|
|
8
|
+
if (process.platform === 'win32') {
|
|
9
|
+
const quotedArgs = args.map((a) => (a.includes(' ') ? `"${a}"` : a));
|
|
10
|
+
execSync([cmd, ...quotedArgs].join(' '), { stdio: 'inherit' });
|
|
11
|
+
} else {
|
|
12
|
+
execFileSync(cmd, args, { stdio: 'inherit' });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
// Load the spec list (use staging specs when --staging flag is passed)
|
|
6
17
|
const isStaging = process.argv.includes('--staging');
|
|
7
18
|
const specsFile = isStaging
|
|
@@ -31,24 +42,17 @@ for (const spec of specs) {
|
|
|
31
42
|
const tempSpecFile = path.join(process.cwd(), `${name}-spec.json`);
|
|
32
43
|
try {
|
|
33
44
|
console.log(`📥 Downloading spec from ${url}...`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'--output',
|
|
46
|
-
outputDir,
|
|
47
|
-
'--client',
|
|
48
|
-
'fetch',
|
|
49
|
-
],
|
|
50
|
-
{ stdio: 'inherit', shell: true },
|
|
51
|
-
);
|
|
45
|
+
runCommand(CURL_CMD, ['-s', '-o', tempSpecFile, url]);
|
|
46
|
+
|
|
47
|
+
runCommand(NPX_CMD, [
|
|
48
|
+
'openapi-typescript-codegen',
|
|
49
|
+
'--input',
|
|
50
|
+
tempSpecFile,
|
|
51
|
+
'--output',
|
|
52
|
+
outputDir,
|
|
53
|
+
'--client',
|
|
54
|
+
'fetch',
|
|
55
|
+
]);
|
|
52
56
|
|
|
53
57
|
// Clean up temp file
|
|
54
58
|
fs.unlinkSync(tempSpecFile);
|
|
@@ -61,10 +65,7 @@ for (const spec of specs) {
|
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
console.log(`⚙️ Generating wrapper for ${name}...`);
|
|
64
|
-
|
|
65
|
-
stdio: 'inherit',
|
|
66
|
-
shell: true,
|
|
67
|
-
});
|
|
68
|
+
runCommand(NPX_CMD, ['tsx', 'src/scripts/generate-definition.ts', name]);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
// After generating all clients and definitions, replace request.ts for all services
|