@instawp/cli 0.0.1-beta.1 → 0.0.1-beta.11
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/CHANGELOG.md +138 -0
- package/README.md +58 -10
- package/dist/commands/db.d.ts +2 -0
- package/dist/commands/db.js +331 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/exec.js +62 -3
- package/dist/commands/exec.js.map +1 -1
- package/dist/commands/local.d.ts +2 -0
- package/dist/commands/local.js +750 -0
- package/dist/commands/local.js.map +1 -0
- package/dist/commands/login.js +23 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.d.ts +2 -0
- package/dist/commands/logs.js +239 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/open.d.ts +2 -0
- package/dist/commands/open.js +114 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/sites.js +266 -10
- package/dist/commands/sites.js.map +1 -1
- package/dist/commands/sync.js +6 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/teams.js +52 -3
- package/dist/commands/teams.js.map +1 -1
- package/dist/index.js +54 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/api.js +6 -1
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/config.d.ts +10 -1
- package/dist/lib/config.js +47 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/local-env.d.ts +35 -0
- package/dist/lib/local-env.js +299 -0
- package/dist/lib/local-env.js.map +1 -0
- package/dist/lib/output.js +14 -1
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/paths.d.ts +22 -0
- package/dist/lib/paths.js +41 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/sftp-sync.d.ts +29 -0
- package/dist/lib/sftp-sync.js +266 -0
- package/dist/lib/sftp-sync.js.map +1 -0
- package/dist/lib/site-resolver.js +32 -11
- package/dist/lib/site-resolver.js.map +1 -1
- package/dist/lib/ssh-connection.d.ts +17 -0
- package/dist/lib/ssh-connection.js +103 -5
- package/dist/lib/ssh-connection.js.map +1 -1
- package/dist/lib/ssh-keys.js +12 -5
- package/dist/lib/ssh-keys.js.map +1 -1
- package/dist/lib/windows-binaries.d.ts +10 -0
- package/dist/lib/windows-binaries.js +34 -0
- package/dist/lib/windows-binaries.js.map +1 -0
- package/dist/types.d.ts +8 -0
- package/package.json +11 -3
- package/scripts/mysql2sqlite +289 -0
- package/vendor/win32/NOTICE.md +31 -0
- package/vendor/win32/busybox.exe +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a local filesystem path to a form rsync understands.
|
|
3
|
+
*
|
|
4
|
+
* rsync uses `host:path` syntax to mean "remote path", so a Windows path like
|
|
5
|
+
* `C:\Users\vikas\file` is interpreted as host `C` + path `\Users\vikas\file`,
|
|
6
|
+
* which fails. The fix is msys-style: `/c/Users/vikas/file`. This matches what
|
|
7
|
+
* rsync from Git for Windows expects and is accepted by cwRsync as well.
|
|
8
|
+
*
|
|
9
|
+
* Non-Windows: pass-through.
|
|
10
|
+
* Remote paths (containing `user@host:`): pass-through.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toRsyncPath(p: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a path inside the CLI's installed directory (e.g. bundled scripts).
|
|
15
|
+
*
|
|
16
|
+
* `new URL(import.meta.url).pathname` returns `/C:/...` on Windows which is
|
|
17
|
+
* invalid. `fileURLToPath` returns a real OS path.
|
|
18
|
+
*
|
|
19
|
+
* @param importMetaUrl - pass `import.meta.url` from the calling module
|
|
20
|
+
* @param relative - segments relative to the calling module's directory
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveFromModule(importMetaUrl: string, ...relative: string[]): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a local filesystem path to a form rsync understands.
|
|
5
|
+
*
|
|
6
|
+
* rsync uses `host:path` syntax to mean "remote path", so a Windows path like
|
|
7
|
+
* `C:\Users\vikas\file` is interpreted as host `C` + path `\Users\vikas\file`,
|
|
8
|
+
* which fails. The fix is msys-style: `/c/Users/vikas/file`. This matches what
|
|
9
|
+
* rsync from Git for Windows expects and is accepted by cwRsync as well.
|
|
10
|
+
*
|
|
11
|
+
* Non-Windows: pass-through.
|
|
12
|
+
* Remote paths (containing `user@host:`): pass-through.
|
|
13
|
+
*/
|
|
14
|
+
export function toRsyncPath(p) {
|
|
15
|
+
if (process.platform !== 'win32')
|
|
16
|
+
return p;
|
|
17
|
+
// Already a remote spec like user@host:path
|
|
18
|
+
if (/^[^/\\:]+@[^:]+:/.test(p))
|
|
19
|
+
return p;
|
|
20
|
+
// Drive letter form: C:\foo\bar or C:/foo/bar → /c/foo/bar
|
|
21
|
+
const m = p.match(/^([A-Za-z]):[\\/](.*)$/);
|
|
22
|
+
if (m) {
|
|
23
|
+
return `/${m[1].toLowerCase()}/${m[2].replace(/\\/g, '/')}`;
|
|
24
|
+
}
|
|
25
|
+
// UNC or other — just normalize separators
|
|
26
|
+
return p.replace(/\\/g, '/');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a path inside the CLI's installed directory (e.g. bundled scripts).
|
|
30
|
+
*
|
|
31
|
+
* `new URL(import.meta.url).pathname` returns `/C:/...` on Windows which is
|
|
32
|
+
* invalid. `fileURLToPath` returns a real OS path.
|
|
33
|
+
*
|
|
34
|
+
* @param importMetaUrl - pass `import.meta.url` from the calling module
|
|
35
|
+
* @param relative - segments relative to the calling module's directory
|
|
36
|
+
*/
|
|
37
|
+
export function resolveFromModule(importMetaUrl, ...relative) {
|
|
38
|
+
const here = dirname(fileURLToPath(importMetaUrl));
|
|
39
|
+
return resolve(here, ...relative);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,CAAC,CAAC;IAC3C,4CAA4C;IAC5C,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACzC,6DAA6D;IAC7D,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,CAAC;QACN,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IAC9D,CAAC;IACD,2CAA2C;IAC3C,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB,EAAE,GAAG,QAAkB;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IACnD,OAAO,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SshConnection } from '../types.js';
|
|
2
|
+
export interface SftpSyncOptions {
|
|
3
|
+
direction: 'push' | 'pull';
|
|
4
|
+
/** Local directory (contents are synced; trailing slash optional). */
|
|
5
|
+
localPath: string;
|
|
6
|
+
/** Remote directory (POSIX path). */
|
|
7
|
+
remotePath: string;
|
|
8
|
+
/** Names/globs to skip (rsync --exclude equivalents). */
|
|
9
|
+
excludes: string[];
|
|
10
|
+
/** Names/globs that override excludes (rsync --include equivalents). */
|
|
11
|
+
includes?: string[];
|
|
12
|
+
dryRun: boolean;
|
|
13
|
+
/** Called per transferred file/dir for itemized output. */
|
|
14
|
+
onItem?: (action: string, relPath: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function makeMatcher(patterns: string[]): (name: string, relPath: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Recursively transfer a directory tree over SFTP. This is the Windows
|
|
19
|
+
* replacement for rsync-over-ssh: bundled msys rsync can't talk to native
|
|
20
|
+
* Windows OpenSSH (incompatible pipe/signal semantics), so on Windows we use
|
|
21
|
+
* a pure-JS SSH client instead. No delta algorithm — full-file copy — but
|
|
22
|
+
* reliable and dependency-free of native binaries.
|
|
23
|
+
*
|
|
24
|
+
* Strategy: one "control" connection walks the tree (cheap listing) and
|
|
25
|
+
* pre-creates directories, building a flat list of file tasks. Files are then
|
|
26
|
+
* transferred across a pool of N parallel connections (INSTAWP_SFTP_CONCURRENCY,
|
|
27
|
+
* default 4) to hide per-file SSH round-trip latency.
|
|
28
|
+
*/
|
|
29
|
+
export declare function syncViaSftp(conn: SshConnection, opts: SftpSyncOptions): Promise<number>;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import SftpClient from 'ssh2-sftp-client';
|
|
2
|
+
// ssh2 is CommonJS — a named ESM import fails at runtime. Use default import.
|
|
3
|
+
import ssh2 from 'ssh2';
|
|
4
|
+
const ssh2Utils = ssh2.utils;
|
|
5
|
+
import { readFileSync, mkdirSync, readdirSync, existsSync } from 'node:fs';
|
|
6
|
+
import { join, posix } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Build the SSH auth for ssh2. Unencrypted keys (the CLI's own generated
|
|
9
|
+
* cli_key) are passed directly. If the key is encrypted, we don't pass it
|
|
10
|
+
* (ssh2 throws at parse time) — instead we fall back to ssh-agent, which is
|
|
11
|
+
* how rsync/ssh transparently handle encrypted keys. Set INSTAWP_SSH_PASSPHRASE
|
|
12
|
+
* to use an encrypted key without an agent.
|
|
13
|
+
*/
|
|
14
|
+
function buildAuth(conn) {
|
|
15
|
+
const auth = {};
|
|
16
|
+
const passphrase = process.env.INSTAWP_SSH_PASSPHRASE || undefined;
|
|
17
|
+
try {
|
|
18
|
+
const keyContent = readFileSync(conn.privateKeyPath);
|
|
19
|
+
const parsed = ssh2Utils.parseKey(keyContent, passphrase);
|
|
20
|
+
if (!(parsed instanceof Error)) {
|
|
21
|
+
auth.privateKey = keyContent;
|
|
22
|
+
if (passphrase)
|
|
23
|
+
auth.passphrase = passphrase;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// key file unreadable — rely on agent below
|
|
28
|
+
}
|
|
29
|
+
// ssh-agent fallback (also covers encrypted keys already loaded in the agent)
|
|
30
|
+
const agentSock = process.platform === 'win32'
|
|
31
|
+
? '\\\\.\\pipe\\openssh-ssh-agent'
|
|
32
|
+
: process.env.SSH_AUTH_SOCK;
|
|
33
|
+
if (agentSock)
|
|
34
|
+
auth.agent = agentSock;
|
|
35
|
+
return auth;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a simple rsync-style pattern to a RegExp.
|
|
39
|
+
* Supports `*` (any chars except /) and `**` (any chars). Trailing `/` and
|
|
40
|
+
* leading `/` are stripped. Patterns without `/` match a path segment anywhere.
|
|
41
|
+
*/
|
|
42
|
+
function patternToRegExp(pattern) {
|
|
43
|
+
let p = pattern.replace(/\/+$/, '').replace(/^\/+/, '');
|
|
44
|
+
const anchored = pattern.includes('/');
|
|
45
|
+
// Escape regex specials except * and ?
|
|
46
|
+
let re = '';
|
|
47
|
+
for (let i = 0; i < p.length; i++) {
|
|
48
|
+
const c = p[i];
|
|
49
|
+
if (c === '*') {
|
|
50
|
+
if (p[i + 1] === '*') {
|
|
51
|
+
re += '.*';
|
|
52
|
+
i++;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
re += '[^/]*';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (c === '?') {
|
|
59
|
+
re += '[^/]';
|
|
60
|
+
}
|
|
61
|
+
else if ('.+^${}()|[]\\'.includes(c)) {
|
|
62
|
+
re += '\\' + c;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
re += c;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { re: new RegExp('^' + re + '$'), anchored };
|
|
69
|
+
}
|
|
70
|
+
export function makeMatcher(patterns) {
|
|
71
|
+
const compiled = patterns.map(patternToRegExp);
|
|
72
|
+
return (name, relPath) => {
|
|
73
|
+
for (const { re, anchored } of compiled) {
|
|
74
|
+
if (anchored) {
|
|
75
|
+
if (re.test(relPath))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
else if (re.test(name)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const DEFAULT_CONCURRENCY = 4;
|
|
86
|
+
const MAX_CONCURRENCY = 8;
|
|
87
|
+
function resolveConcurrency() {
|
|
88
|
+
const raw = parseInt(process.env.INSTAWP_SFTP_CONCURRENCY || '', 10);
|
|
89
|
+
if (!Number.isFinite(raw) || raw < 1)
|
|
90
|
+
return DEFAULT_CONCURRENCY;
|
|
91
|
+
return Math.min(raw, MAX_CONCURRENCY);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Recursively transfer a directory tree over SFTP. This is the Windows
|
|
95
|
+
* replacement for rsync-over-ssh: bundled msys rsync can't talk to native
|
|
96
|
+
* Windows OpenSSH (incompatible pipe/signal semantics), so on Windows we use
|
|
97
|
+
* a pure-JS SSH client instead. No delta algorithm — full-file copy — but
|
|
98
|
+
* reliable and dependency-free of native binaries.
|
|
99
|
+
*
|
|
100
|
+
* Strategy: one "control" connection walks the tree (cheap listing) and
|
|
101
|
+
* pre-creates directories, building a flat list of file tasks. Files are then
|
|
102
|
+
* transferred across a pool of N parallel connections (INSTAWP_SFTP_CONCURRENCY,
|
|
103
|
+
* default 4) to hide per-file SSH round-trip latency.
|
|
104
|
+
*/
|
|
105
|
+
export async function syncViaSftp(conn, opts) {
|
|
106
|
+
const isExcluded = makeMatcher(opts.excludes);
|
|
107
|
+
const isIncluded = makeMatcher(opts.includes ?? []);
|
|
108
|
+
const skip = (name, relPath) => {
|
|
109
|
+
if (isIncluded(name, relPath))
|
|
110
|
+
return false;
|
|
111
|
+
return isExcluded(name, relPath);
|
|
112
|
+
};
|
|
113
|
+
const auth = buildAuth(conn);
|
|
114
|
+
if (!auth.privateKey && !auth.agent) {
|
|
115
|
+
opts.onItem?.('error', 'SSH key appears encrypted and no ssh-agent is available. ' +
|
|
116
|
+
'Load the key into ssh-agent, or set INSTAWP_SSH_PASSPHRASE.');
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
const connectCfg = {
|
|
120
|
+
host: conn.host,
|
|
121
|
+
port: conn.port,
|
|
122
|
+
username: conn.username,
|
|
123
|
+
...auth,
|
|
124
|
+
readyTimeout: 30000,
|
|
125
|
+
};
|
|
126
|
+
const remoteRoot = opts.remotePath.replace(/\/+$/, '');
|
|
127
|
+
const localRoot = opts.localPath.replace(/[\\/]+$/, '');
|
|
128
|
+
const tasks = [];
|
|
129
|
+
// --- Phase 1: walk the tree on a single control connection, build the task
|
|
130
|
+
// list, and pre-create destination directories. ---
|
|
131
|
+
const control = new SftpClient();
|
|
132
|
+
try {
|
|
133
|
+
await control.connect(connectCfg);
|
|
134
|
+
if (opts.direction === 'pull') {
|
|
135
|
+
const walkPull = async (remoteDir, localDir) => {
|
|
136
|
+
let entries;
|
|
137
|
+
try {
|
|
138
|
+
entries = await control.list(remoteDir);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return; // remote dir missing — nothing to pull
|
|
142
|
+
}
|
|
143
|
+
if (!opts.dryRun)
|
|
144
|
+
mkdirSync(localDir, { recursive: true });
|
|
145
|
+
for (const e of entries) {
|
|
146
|
+
const rel = posix.relative(remoteRoot, posix.join(remoteDir, e.name));
|
|
147
|
+
if (skip(e.name, rel))
|
|
148
|
+
continue;
|
|
149
|
+
const remoteChild = posix.join(remoteDir, e.name);
|
|
150
|
+
const localChild = join(localDir, e.name);
|
|
151
|
+
if (e.type === 'd') {
|
|
152
|
+
await walkPull(remoteChild, localChild);
|
|
153
|
+
}
|
|
154
|
+
else if (e.type === '-') {
|
|
155
|
+
tasks.push({ remote: remoteChild, local: localChild, rel });
|
|
156
|
+
}
|
|
157
|
+
// symlinks (type 'l') are skipped — rare in wp-content
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
await walkPull(remoteRoot, localRoot);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// Push: walk the local tree (fs, no round-trips) and collect remote dirs.
|
|
164
|
+
const remoteDirs = new Set();
|
|
165
|
+
const walkPush = (localDir, remoteDir) => {
|
|
166
|
+
if (!existsSync(localDir))
|
|
167
|
+
return;
|
|
168
|
+
remoteDirs.add(remoteDir);
|
|
169
|
+
for (const entry of readdirSync(localDir, { withFileTypes: true })) {
|
|
170
|
+
const localChild = join(localDir, entry.name);
|
|
171
|
+
const remoteChild = posix.join(remoteDir, entry.name);
|
|
172
|
+
const rel = posix.relative(remoteRoot, remoteChild);
|
|
173
|
+
if (skip(entry.name, rel))
|
|
174
|
+
continue;
|
|
175
|
+
if (entry.isDirectory()) {
|
|
176
|
+
walkPush(localChild, remoteChild);
|
|
177
|
+
}
|
|
178
|
+
else if (entry.isFile()) {
|
|
179
|
+
tasks.push({ remote: remoteChild, local: localChild, rel });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
walkPush(localRoot, remoteRoot);
|
|
184
|
+
// Pre-create remote dirs shallow-first so parallel uploads have targets.
|
|
185
|
+
if (!opts.dryRun) {
|
|
186
|
+
for (const dir of [...remoteDirs].sort((a, b) => a.length - b.length)) {
|
|
187
|
+
try {
|
|
188
|
+
if (!(await control.exists(dir)))
|
|
189
|
+
await control.mkdir(dir, true);
|
|
190
|
+
}
|
|
191
|
+
catch { /* mkdir races / already exists — ignore */ }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
opts.onItem?.('error', err?.message || String(err));
|
|
198
|
+
try {
|
|
199
|
+
await control.end();
|
|
200
|
+
}
|
|
201
|
+
catch { /* ignore */ }
|
|
202
|
+
return 1;
|
|
203
|
+
}
|
|
204
|
+
const total = tasks.length;
|
|
205
|
+
if (opts.dryRun) {
|
|
206
|
+
for (const t of tasks)
|
|
207
|
+
opts.onItem?.(opts.direction === 'pull' ? 'recv' : 'sent', t.rel);
|
|
208
|
+
try {
|
|
209
|
+
await control.end();
|
|
210
|
+
}
|
|
211
|
+
catch { /* ignore */ }
|
|
212
|
+
return 0;
|
|
213
|
+
}
|
|
214
|
+
if (total === 0) {
|
|
215
|
+
try {
|
|
216
|
+
await control.end();
|
|
217
|
+
}
|
|
218
|
+
catch { /* ignore */ }
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
// --- Phase 2: transfer files across a pool of N connections. ---
|
|
222
|
+
const concurrency = Math.min(resolveConcurrency(), total);
|
|
223
|
+
const verb = opts.direction === 'pull' ? 'recv' : 'sent';
|
|
224
|
+
const transfer = (c, t) => opts.direction === 'pull' ? c.fastGet(t.remote, t.local) : c.fastPut(t.local, t.remote);
|
|
225
|
+
// Reuse the control connection as the first worker; open the rest.
|
|
226
|
+
const workers = [control];
|
|
227
|
+
try {
|
|
228
|
+
for (let i = 1; i < concurrency; i++) {
|
|
229
|
+
const w = new SftpClient();
|
|
230
|
+
await w.connect(connectCfg);
|
|
231
|
+
workers.push(w);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
// If extra workers fail to connect, proceed with whatever connected.
|
|
236
|
+
opts.onItem?.('error', `only ${workers.length}/${concurrency} connections opened: ${err?.message || err}`);
|
|
237
|
+
}
|
|
238
|
+
let next = 0;
|
|
239
|
+
let done = 0;
|
|
240
|
+
let errors = 0;
|
|
241
|
+
const runWorker = async (c) => {
|
|
242
|
+
while (true) {
|
|
243
|
+
const i = next++; // synchronous claim — safe in single-threaded JS
|
|
244
|
+
if (i >= total)
|
|
245
|
+
break;
|
|
246
|
+
const t = tasks[i];
|
|
247
|
+
try {
|
|
248
|
+
await transfer(c, t);
|
|
249
|
+
done++;
|
|
250
|
+
opts.onItem?.(verb, `[${done}/${total}] ${t.rel}`);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
errors++;
|
|
254
|
+
opts.onItem?.('error', `${t.rel}: ${e?.message || e}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
await Promise.all(workers.map(runWorker));
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
await Promise.all(workers.map(w => w.end().catch(() => { })));
|
|
263
|
+
}
|
|
264
|
+
return errors === 0 ? 0 : 1;
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=sftp-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sftp-sync.js","sourceRoot":"","sources":["../../src/lib/sftp-sync.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,8EAA8E;AAC9E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AASxC;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,IAAmB;IACpC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC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C,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { getClient } from './api.js';
|
|
2
|
+
import { getSiteCache, setSiteCache } from './config.js';
|
|
2
3
|
import { error, info } from './output.js';
|
|
4
|
+
async function fetchSiteById(client, id) {
|
|
5
|
+
const res = await client.get(`/sites/${id}/details`);
|
|
6
|
+
const data = res.data?.data;
|
|
7
|
+
const site = data?.site || data;
|
|
8
|
+
return normalizeSite(site, data);
|
|
9
|
+
}
|
|
3
10
|
export async function resolveSite(identifier) {
|
|
4
11
|
const client = getClient();
|
|
5
12
|
// If purely numeric, fetch directly by ID
|
|
6
13
|
if (/^\d+$/.test(identifier)) {
|
|
7
14
|
try {
|
|
8
|
-
|
|
9
|
-
const data = res.data?.data;
|
|
10
|
-
const site = data?.site || data;
|
|
11
|
-
return normalizeSite(site, data);
|
|
15
|
+
return await fetchSiteById(client, identifier);
|
|
12
16
|
}
|
|
13
17
|
catch (err) {
|
|
14
18
|
if (err.response?.status === 404) {
|
|
@@ -20,7 +24,19 @@ export async function resolveSite(identifier) {
|
|
|
20
24
|
process.exit(1);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
|
-
//
|
|
27
|
+
// Check cache for name/domain → ID mapping
|
|
28
|
+
const cachedId = getSiteCache(identifier);
|
|
29
|
+
if (cachedId) {
|
|
30
|
+
try {
|
|
31
|
+
return await fetchSiteById(client, cachedId);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
// Cache stale (site deleted?), fall through to fresh lookup
|
|
35
|
+
if (err.response?.status !== 404)
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Search by name/domain
|
|
24
40
|
try {
|
|
25
41
|
const res = await client.get('/sites', { params: { per_page: 100 } });
|
|
26
42
|
const sites = res.data?.data || [];
|
|
@@ -43,16 +59,21 @@ export async function resolveSite(identifier) {
|
|
|
43
59
|
info('Use the site ID to be specific.');
|
|
44
60
|
process.exit(1);
|
|
45
61
|
}
|
|
46
|
-
// Single match — fetch full details
|
|
62
|
+
// Single match — cache the mapping and fetch full details
|
|
47
63
|
const match = matches[0];
|
|
64
|
+
setSiteCache(identifier, match.id);
|
|
48
65
|
try {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
66
|
+
const details = await fetchSiteById(client, match.id);
|
|
67
|
+
// Also cache by name and domain for future lookups
|
|
68
|
+
if (match.name)
|
|
69
|
+
setSiteCache(match.name, match.id);
|
|
70
|
+
if (match.sub_domain)
|
|
71
|
+
setSiteCache(match.sub_domain, match.id);
|
|
72
|
+
if (match.domain?.name)
|
|
73
|
+
setSiteCache(match.domain.name, match.id);
|
|
74
|
+
return details;
|
|
53
75
|
}
|
|
54
76
|
catch {
|
|
55
|
-
// Fall back to list data if details endpoint fails
|
|
56
77
|
return normalizeSite(match, match);
|
|
57
78
|
}
|
|
58
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-resolver.js","sourceRoot":"","sources":["../../src/lib/site-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"site-resolver.js","sourceRoot":"","sources":["../../src/lib/site-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAG1C,KAAK,UAAU,aAAa,CAAC,MAAW,EAAE,EAAmB;IAC3D,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;IAC5B,MAAM,IAAI,GA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CAAC,MAAM,IAAI,CAAC;QACxB,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;QACnC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,MAAM;QAClC,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,GAAG,EAAE,eAAe,IAAI,EAAE;QACnE,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,GAAG,EAAE,WAAW,IAAI,EAAE;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -5,4 +5,21 @@ export declare function execViaSsh(conn: SshConnection, command: string): {
|
|
|
5
5
|
stderr: string;
|
|
6
6
|
exitCode: number;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Execute a command via SSH and stream stdout directly to a file.
|
|
10
|
+
* Useful for large outputs like database dumps.
|
|
11
|
+
*/
|
|
12
|
+
export declare function execViaSshToFile(conn: SshConnection, command: string, outputPath: string): {
|
|
13
|
+
exitCode: number;
|
|
14
|
+
stderr: string;
|
|
15
|
+
};
|
|
8
16
|
export declare function rsyncViaSsh(conn: SshConnection, source: string, dest: string, extraArgs: string[], dryRun: boolean, stream: boolean): number;
|
|
17
|
+
/**
|
|
18
|
+
* Transfer files between local and remote. On macOS/Linux this shells out to
|
|
19
|
+
* rsync (delta sync). On Windows it uses a pure-JS SFTP client instead —
|
|
20
|
+
* the bundled msys rsync.exe cannot drive native Windows OpenSSH (incompatible
|
|
21
|
+
* pipe/signal semantics → "connection unexpectedly closed"), so rsync-over-ssh
|
|
22
|
+
* is unusable there. Same call shape as rsyncViaSsh; one of source/dest is a
|
|
23
|
+
* `user@host:path` spec.
|
|
24
|
+
*/
|
|
25
|
+
export declare function syncFiles(conn: SshConnection, source: string, dest: string, extraArgs: string[], dryRun: boolean, stream: boolean): Promise<number>;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { existsSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { existsSync, mkdirSync, openSync, closeSync } from 'node:fs';
|
|
5
|
+
import { toRsyncPath } from './paths.js';
|
|
6
|
+
import { syncViaSftp } from './sftp-sync.js';
|
|
5
7
|
const KNOWN_HOSTS = path.join(homedir(), '.instawp', 'known_hosts');
|
|
8
|
+
// Paths embedded into the rsync `-e ssh ...` command are parsed by rsync's
|
|
9
|
+
// internal shell (msys/cygwin sh on Windows), where backslashes are escapes.
|
|
10
|
+
// Use forward slashes throughout. The actual ssh.exe on Windows accepts both.
|
|
11
|
+
function toSshPath(p) {
|
|
12
|
+
return p.replace(/\\/g, '/');
|
|
13
|
+
}
|
|
6
14
|
function ensureKnownHosts() {
|
|
7
15
|
const dir = path.dirname(KNOWN_HOSTS);
|
|
8
16
|
if (!existsSync(dir)) {
|
|
@@ -41,20 +49,47 @@ export function execViaSsh(conn, command) {
|
|
|
41
49
|
exitCode: result.status ?? 1,
|
|
42
50
|
};
|
|
43
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Execute a command via SSH and stream stdout directly to a file.
|
|
54
|
+
* Useful for large outputs like database dumps.
|
|
55
|
+
*/
|
|
56
|
+
export function execViaSshToFile(conn, command, outputPath) {
|
|
57
|
+
ensureKnownHosts();
|
|
58
|
+
const fd = openSync(outputPath, 'w');
|
|
59
|
+
try {
|
|
60
|
+
const result = spawnSync('ssh', ['-T', ...sshArgs(conn), sshTarget(conn)], {
|
|
61
|
+
input: command + '\n',
|
|
62
|
+
stdio: ['pipe', fd, 'pipe'],
|
|
63
|
+
encoding: 'utf-8',
|
|
64
|
+
maxBuffer: 500 * 1024 * 1024, // 500MB
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
exitCode: result.status ?? 1,
|
|
68
|
+
stderr: result.stderr || '',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
closeSync(fd);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
44
75
|
export function rsyncViaSsh(conn, source, dest, extraArgs, dryRun, stream) {
|
|
45
76
|
ensureKnownHosts();
|
|
46
|
-
const
|
|
77
|
+
const keyPath = toSshPath(conn.privateKeyPath);
|
|
78
|
+
const knownHosts = toSshPath(KNOWN_HOSTS);
|
|
79
|
+
const sshCmd = `ssh -i "${keyPath}" -p ${conn.port} -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="${knownHosts}"`;
|
|
47
80
|
const args = [
|
|
48
|
-
'-
|
|
81
|
+
'-arz',
|
|
82
|
+
'--itemize-changes',
|
|
49
83
|
'--exclude=.git',
|
|
50
84
|
'--exclude=node_modules',
|
|
51
85
|
'--exclude=.DS_Store',
|
|
52
86
|
...(dryRun ? ['--dry-run'] : []),
|
|
53
87
|
...extraArgs,
|
|
54
88
|
'-e', sshCmd,
|
|
55
|
-
source,
|
|
56
|
-
dest,
|
|
89
|
+
toRsyncPath(source),
|
|
90
|
+
toRsyncPath(dest),
|
|
57
91
|
];
|
|
92
|
+
// rsyncViaSsh only runs on macOS/Linux now (Windows uses syncViaSftp).
|
|
58
93
|
const result = spawnSync('rsync', args, {
|
|
59
94
|
stdio: stream ? 'inherit' : ['pipe', 'pipe', 'pipe'],
|
|
60
95
|
encoding: stream ? undefined : 'utf-8',
|
|
@@ -67,4 +102,67 @@ export function rsyncViaSsh(conn, source, dest, extraArgs, dryRun, stream) {
|
|
|
67
102
|
}
|
|
68
103
|
return result.status ?? 1;
|
|
69
104
|
}
|
|
105
|
+
/** Strip a `user@host:` prefix, returning the remote path (or null if not remote). */
|
|
106
|
+
function parseRemoteSpec(spec, conn) {
|
|
107
|
+
const prefix = `${conn.username}@${conn.host}:`;
|
|
108
|
+
if (spec.startsWith(prefix))
|
|
109
|
+
return spec.slice(prefix.length);
|
|
110
|
+
const m = spec.match(/^[^@/\\]+@[^:]+:(.*)$/);
|
|
111
|
+
return m ? m[1] : null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Transfer files between local and remote. On macOS/Linux this shells out to
|
|
115
|
+
* rsync (delta sync). On Windows it uses a pure-JS SFTP client instead —
|
|
116
|
+
* the bundled msys rsync.exe cannot drive native Windows OpenSSH (incompatible
|
|
117
|
+
* pipe/signal semantics → "connection unexpectedly closed"), so rsync-over-ssh
|
|
118
|
+
* is unusable there. Same call shape as rsyncViaSsh; one of source/dest is a
|
|
119
|
+
* `user@host:path` spec.
|
|
120
|
+
*/
|
|
121
|
+
export async function syncFiles(conn, source, dest, extraArgs, dryRun, stream) {
|
|
122
|
+
if (process.platform !== 'win32') {
|
|
123
|
+
return rsyncViaSsh(conn, source, dest, extraArgs, dryRun, stream);
|
|
124
|
+
}
|
|
125
|
+
const destRemote = parseRemoteSpec(dest, conn);
|
|
126
|
+
const sourceRemote = parseRemoteSpec(source, conn);
|
|
127
|
+
let direction;
|
|
128
|
+
let localPath;
|
|
129
|
+
let remotePath;
|
|
130
|
+
if (destRemote !== null) {
|
|
131
|
+
direction = 'push';
|
|
132
|
+
localPath = source;
|
|
133
|
+
remotePath = destRemote;
|
|
134
|
+
}
|
|
135
|
+
else if (sourceRemote !== null) {
|
|
136
|
+
direction = 'pull';
|
|
137
|
+
localPath = dest;
|
|
138
|
+
remotePath = sourceRemote;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.error('syncFiles: could not determine remote endpoint from source/dest');
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
// rsyncViaSsh hardcodes these defaults; mirror them for SFTP.
|
|
145
|
+
const excludes = ['.git', 'node_modules', '.DS_Store'];
|
|
146
|
+
const includes = [];
|
|
147
|
+
for (const a of extraArgs) {
|
|
148
|
+
if (a.startsWith('--exclude='))
|
|
149
|
+
excludes.push(a.slice('--exclude='.length));
|
|
150
|
+
else if (a.startsWith('--include='))
|
|
151
|
+
includes.push(a.slice('--include='.length));
|
|
152
|
+
}
|
|
153
|
+
return syncViaSftp(conn, {
|
|
154
|
+
direction,
|
|
155
|
+
localPath,
|
|
156
|
+
remotePath,
|
|
157
|
+
excludes,
|
|
158
|
+
includes,
|
|
159
|
+
dryRun,
|
|
160
|
+
onItem: (action, rel) => {
|
|
161
|
+
if (action === 'error')
|
|
162
|
+
console.error(rel);
|
|
163
|
+
else if (rel)
|
|
164
|
+
console.log(` ${action === 'sent' ? '↑' : '↓'} ${rel}`);
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
70
168
|
//# sourceMappingURL=ssh-connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-connection.js","sourceRoot":"","sources":["../../src/lib/ssh-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ssh-connection.js","sourceRoot":"","sources":["../../src/lib/ssh-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpE,2EAA2E;AAC3E,6EAA6E;AAC7E,8EAA8E;AAC9E,SAAS,SAAS,CAAC,CAAS;IAC1B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