kirby-deploy 0.4.0 → 0.4.1

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/cli.js CHANGED
@@ -8,7 +8,7 @@ import { defineCommand as defineCommand4 } from "citty";
8
8
  import { consola as consola9 } from "consola";
9
9
  import { colors as colors6 } from "consola/utils";
10
10
  import { readFileSync } from "fs";
11
- import { join as join6, relative } from "path/posix";
11
+ import { join as join7, relative } from "path/posix";
12
12
  import { cwd as cwd2 } from "process";
13
13
 
14
14
  // src/config.ts
@@ -150,15 +150,15 @@ ${info}`);
150
150
  // src/lftp/cat.ts
151
151
  import { spawnSync } from "child_process";
152
152
  import { consola as consola2 } from "consola";
153
+ import { join } from "path";
153
154
  import { platform } from "os";
154
- var cat = (file, { host, user, password, lftpSettings }) => {
155
+ var cat = (file, { host, user, password, remoteDir, lftpSettings }) => {
155
156
  const commands = [
156
157
  ...Object.entries(lftpSettings).map(
157
158
  ([key, value]) => `set ${key} ${value}`
158
159
  ),
159
- `open ${host}`,
160
- `user ${user} ${password}`,
161
- `cat ${file}`,
160
+ `open -u ${user},${password} ${host}`,
161
+ `cat ${join(remoteDir, file)}`,
162
162
  "bye"
163
163
  ];
164
164
  const isWindows = platform() === "win32";
@@ -166,7 +166,8 @@ var cat = (file, { host, user, password, lftpSettings }) => {
166
166
  encoding: "utf-8"
167
167
  }) : spawnSync("lftp", ["-c", commands.join("; ")], { encoding: "utf-8" });
168
168
  if (child.stderr) {
169
- if (child.stderr.includes("550")) return void 0;
169
+ if (child.stderr.includes("550") || child.stderr.includes("No such file"))
170
+ return void 0;
170
171
  consola2.error(child.stderr);
171
172
  return void 0;
172
173
  }
@@ -175,7 +176,7 @@ var cat = (file, { host, user, password, lftpSettings }) => {
175
176
 
176
177
  // src/sync.ts
177
178
  import { consola as consola5 } from "consola";
178
- import { join as join2 } from "path/posix";
179
+ import { join as join3 } from "path/posix";
179
180
 
180
181
  // src/lftp/mirror.ts
181
182
  import { consola as consola3 } from "consola";
@@ -187,9 +188,7 @@ var mirror = (source, destination, flags, { lftpSettings, host, user, password,
187
188
  ...Object.entries(lftpSettings).map(
188
189
  ([key, value]) => `set ${key} ${value}`
189
190
  ),
190
- `open ${host}`,
191
- `user ${user} ${password}`,
192
- // mask credentials
191
+ `open -u ${user},${password} ${host}`,
193
192
  `mirror ${flags.join(" ")} ${source} ${destination}`,
194
193
  "bye"
195
194
  ];
@@ -245,11 +244,11 @@ import { consola as consola4 } from "consola";
245
244
  import { colors as colors2 } from "consola/utils";
246
245
  import { spawnSync as spawnSync2 } from "child_process";
247
246
  import { existsSync } from "fs";
248
- import { join } from "path";
247
+ import { join as join2 } from "path";
249
248
  import { cwd, stdin as input, stdout as output } from "process";
250
249
  import * as readline from "readline";
251
250
  var upperFirst = (string2) => string2.charAt(0).toUpperCase() + string2.slice(1);
252
- var isGit = () => existsSync(join(cwd(), ".git"));
251
+ var isGit = () => existsSync(join2(cwd(), ".git"));
253
252
  var getBranch = () => {
254
253
  if (!isGit()) return;
255
254
  const { stderr, stdout } = spawnSync2("git", ["branch", "--show-current"], {
@@ -291,7 +290,7 @@ var sync = async (source, mode, config) => {
291
290
  const targetName = mode === "push" ? "remote" : "local";
292
291
  const webhookBase = `${config.url}/plugin-kirby-deploy`;
293
292
  const shouldCallWebhooks = mode === "push" && config.callWebhooks;
294
- const destination = source === "./" ? config.remoteDir : join2(config.remoteDir, source);
293
+ const destination = source === "./" ? config.remoteDir : join3(config.remoteDir, source);
295
294
  if (shouldCallWebhooks && !config.token) {
296
295
  consola5.error("token needed to call webhooks");
297
296
  return false;
@@ -370,7 +369,7 @@ var sync = async (source, mode, config) => {
370
369
  import { defineCommand } from "citty";
371
370
  import { consola as consola6 } from "consola";
372
371
  import { colors as colors3 } from "consola/utils";
373
- import { join as join3 } from "path/posix";
372
+ import { join as join4 } from "path/posix";
374
373
  var syncAccounts = async (mode, force = false) => {
375
374
  const config = await loadConfig();
376
375
  if (!config) return;
@@ -381,7 +380,7 @@ var syncAccounts = async (mode, force = false) => {
381
380
  `${source}${branch ? colors3.cyan(` (${branch})`) : ""}`
382
381
  );
383
382
  const displayDestination = colors3.magenta(
384
- join3(config.host, config.remoteDir, source)
383
+ join4(config.host, config.remoteDir, source)
385
384
  );
386
385
  const direction = mode === "pull" ? "from" : "to";
387
386
  consola6.log(
@@ -418,7 +417,7 @@ var accountsPull = defineCommand({
418
417
  import { defineCommand as defineCommand2 } from "citty";
419
418
  import { consola as consola7 } from "consola";
420
419
  import { colors as colors4 } from "consola/utils";
421
- import { join as join4 } from "path/posix";
420
+ import { join as join5 } from "path/posix";
422
421
  var syncContent = async (mode, force = false) => {
423
422
  const config = await loadConfig();
424
423
  if (!config) return;
@@ -429,7 +428,7 @@ var syncContent = async (mode, force = false) => {
429
428
  `${source}${branch ? colors4.cyan(` (${branch})`) : ""}`
430
429
  );
431
430
  const displayDestination = colors4.magenta(
432
- join4(config.host, config.remoteDir, source)
431
+ join5(config.host, config.remoteDir, source)
433
432
  );
434
433
  const direction = mode === "pull" ? "from" : "to";
435
434
  consola7.log(
@@ -465,7 +464,7 @@ var contentPull = defineCommand2({
465
464
  import { defineCommand as defineCommand3 } from "citty";
466
465
  import { consola as consola8 } from "consola";
467
466
  import { colors as colors5 } from "consola/utils";
468
- import { join as join5 } from "path/posix";
467
+ import { join as join6 } from "path/posix";
469
468
  var syncLanguages = async (mode, force = false) => {
470
469
  const config = await loadConfig();
471
470
  if (!config) return;
@@ -476,7 +475,7 @@ var syncLanguages = async (mode, force = false) => {
476
475
  `${source}${branch ? colors5.cyan(` (${branch})`) : ""}`
477
476
  );
478
477
  const displayDestination = colors5.magenta(
479
- join5(config.host, config.remoteDir, source)
478
+ join6(config.host, config.remoteDir, source)
480
479
  );
481
480
  const direction = mode === "pull" ? "from" : "to";
482
481
  consola8.log(
@@ -534,7 +533,7 @@ var main = defineCommand4({
534
533
  `^${relative(cwd2(), folderStructure.sessions)}/.`,
535
534
  `^${relative(cwd2(), folderStructure.cache)}/.`,
536
535
  `^${relative(cwd2(), folderStructure.logs)}/.`,
537
- `^${relative(cwd2(), join6(folderStructure.site, "languages"))}/.`
536
+ `^${relative(cwd2(), join7(folderStructure.site, "languages"))}/.`
538
537
  ];
539
538
  const excludeGlob = [...config.excludeGlob, ".*", ".*/"];
540
539
  const include = config.include;
@@ -542,7 +541,7 @@ var main = defineCommand4({
542
541
  const branch = getBranch();
543
542
  const displaySource = branch ? colors6.cyan(` ${branch} `) : " ";
544
543
  const displayDestination = colors6.magenta(
545
- join6(config.host, config.remoteDir)
544
+ join7(config.host, config.remoteDir)
546
545
  );
547
546
  consola9.log(`\u{1F680} Deploy${displaySource}to ${displayDestination}
548
547
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kirby-deploy",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
package/src/lftp/cat.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { spawnSync } from 'child_process'
2
2
  import { consola } from 'consola'
3
+ import { join } from 'path'
3
4
  import { platform } from 'os'
4
5
  import { ConfigResolved } from '../types'
5
6
 
6
7
  export const cat = (
7
8
  file: string,
8
- { host, user, password, lftpSettings }: ConfigResolved,
9
+ { host, user, password, remoteDir, lftpSettings }: ConfigResolved,
9
10
  ) => {
10
11
  const commands = [
11
12
  ...Object.entries(lftpSettings).map(
12
13
  ([key, value]) => `set ${key} ${value}`,
13
14
  ),
14
- `open ${host}`,
15
- `user ${user} ${password}`,
16
- `cat ${file}`,
15
+ `open -u ${user},${password} ${host}`,
16
+ `cat ${join(remoteDir, file)}`,
17
17
  'bye',
18
18
  ]
19
19
 
@@ -25,8 +25,9 @@ export const cat = (
25
25
  : spawnSync('lftp', ['-c', commands.join('; ')], { encoding: 'utf-8' })
26
26
 
27
27
  if (child.stderr) {
28
- // 550 means the file doesn't exist, silently return undefined
29
- if (child.stderr.includes('550')) return undefined
28
+ // 550 or "No such file" means the file doesn't exist, silently return undefined
29
+ if (child.stderr.includes('550') || child.stderr.includes('No such file'))
30
+ return undefined
30
31
  consola.error(child.stderr)
31
32
  return undefined
32
33
  }
@@ -19,8 +19,7 @@ export const mirror = (
19
19
  ...Object.entries(lftpSettings).map(
20
20
  ([key, value]) => `set ${key} ${value}`,
21
21
  ),
22
- `open ${host}`,
23
- `user ${user} ${password}`, // mask credentials
22
+ `open -u ${user},${password} ${host}`,
24
23
  `mirror ${flags.join(' ')} ${source} ${destination}`,
25
24
  'bye',
26
25
  ]