supatypes 1.0.0 → 1.0.2
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/lib/generate.js +11 -14
- package/lib/init.js +4 -2
- package/package.json +1 -1
package/lib/generate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -14,7 +14,7 @@ export async function generate({ configPath, outputOverride, dryRun }) {
|
|
|
14
14
|
const resolvedConfig = path.resolve(configPath);
|
|
15
15
|
if (!fs.existsSync(resolvedConfig)) {
|
|
16
16
|
console.error(`Config file not found: ${resolvedConfig}`);
|
|
17
|
-
console.error('Run "supatypes init" to create one.');
|
|
17
|
+
console.error('Run "npx supatypes init" to create one.');
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -60,7 +60,7 @@ export async function generate({ configPath, outputOverride, dryRun }) {
|
|
|
60
60
|
|
|
61
61
|
// Step 2: Upload generator script
|
|
62
62
|
process.stdout.write("Uploading generator...");
|
|
63
|
-
scp(scpBase, REMOTE_SCRIPT, `${server
|
|
63
|
+
scp(scpBase, REMOTE_SCRIPT, `${server}:${REMOTE_SCRIPT_PATH}`);
|
|
64
64
|
console.log(" done");
|
|
65
65
|
|
|
66
66
|
// Step 3: Run generator on server
|
|
@@ -86,7 +86,7 @@ export async function generate({ configPath, outputOverride, dryRun }) {
|
|
|
86
86
|
if (!fs.existsSync(outputDir)) {
|
|
87
87
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
88
88
|
}
|
|
89
|
-
scp(scpBase, `${server
|
|
89
|
+
scp(scpBase, `${server}:${REMOTE_OUTPUT_PATH}`, output);
|
|
90
90
|
console.log(" done");
|
|
91
91
|
|
|
92
92
|
// Step 5: Clean up
|
|
@@ -148,19 +148,16 @@ function buildScpBase(server, sshKey, sshPassword) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function ssh(base, command) {
|
|
151
|
-
const
|
|
152
|
-
return
|
|
151
|
+
const [bin, ...args] = base;
|
|
152
|
+
return execFileSync(bin, [...args, command], {
|
|
153
|
+
encoding: "utf8",
|
|
154
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
155
|
+
});
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
function scp(base, src, dest) {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function shellEscape(arg) {
|
|
161
|
-
// Don't escape if it looks safe
|
|
162
|
-
if (/^[a-zA-Z0-9_./:@~=-]+$/.test(arg)) return arg;
|
|
163
|
-
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
159
|
+
const [bin, ...args] = base;
|
|
160
|
+
execFileSync(bin, [...args, src, dest], { encoding: "utf8" });
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
function formatBytes(bytes) {
|
package/lib/init.js
CHANGED
|
@@ -31,7 +31,9 @@ export async function init() {
|
|
|
31
31
|
|
|
32
32
|
console.log("\nSupaTypes — Configuration\n");
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const sshUser = await ask(rl, "SSH username", "root");
|
|
35
|
+
const sshHost = await ask(rl, "SSH server host (e.g. 1.2.3.4)", "");
|
|
36
|
+
const server = `${sshUser}@${sshHost}`;
|
|
35
37
|
const authMethod = await ask(rl, "Auth method: key or password?", "key");
|
|
36
38
|
|
|
37
39
|
let sshKey = "";
|
|
@@ -56,7 +58,7 @@ export async function init() {
|
|
|
56
58
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
57
59
|
|
|
58
60
|
console.log(`\nConfig saved to ${configPath}`);
|
|
59
|
-
console.log('Run "supatypes generate" to generate types.\n');
|
|
61
|
+
console.log('Run "npx supatypes generate" to generate types.\n');
|
|
60
62
|
|
|
61
63
|
// Add to .gitignore if it exists
|
|
62
64
|
const gitignorePath = path.resolve(".gitignore");
|