kirby-deploy 0.0.3 → 0.0.5

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
@@ -78,9 +78,10 @@ var loadConfig = async () => {
78
78
  ${info}`);
79
79
  return null;
80
80
  }
81
+ let folderStructure;
81
82
  config.folderStructure ??= "flat";
82
83
  if (config.folderStructure === "public") {
83
- config.folderStructure = {
84
+ folderStructure = {
84
85
  content: "content",
85
86
  media: "public/media",
86
87
  accounts: "storage/accounts",
@@ -88,17 +89,20 @@ ${info}`);
88
89
  cache: "storage/cache"
89
90
  };
90
91
  } else if (config.folderStructure === "flat") {
91
- config.folderStructure = {
92
+ folderStructure = {
92
93
  content: "content",
93
94
  media: "site/media",
94
95
  accounts: "site/accounts",
95
96
  sessions: "site/sessions",
96
97
  cache: "site/cache"
97
98
  };
99
+ } else {
100
+ folderStructure = config.folderStructure;
98
101
  }
99
- config = {
102
+ const configResolved = {
100
103
  remoteDir: "./",
101
104
  dryRun: true,
105
+ verbose: false,
102
106
  parallel: 10,
103
107
  checkComposerLock: true,
104
108
  callWebhooks: true,
@@ -107,13 +111,14 @@ ${info}`);
107
111
  include: [],
108
112
  includeGlob: [],
109
113
  ...config,
114
+ folderStructure,
110
115
  lftpSettings: {
111
116
  "ftp:ssl-force": true,
112
117
  ...config.lftpSettings
113
118
  },
114
119
  lftpFlags: ["--parallel=10", "--dereference", ...config.lftpFlags ?? []]
115
120
  };
116
- return config;
121
+ return configResolved;
117
122
  };
118
123
 
119
124
  // src/lftp/cat.ts
@@ -254,8 +259,17 @@ var callWebhook = async (url, token) => {
254
259
  var sync = async (source, mode, config) => {
255
260
  const reverse = mode === "push";
256
261
  const targetName = mode === "push" ? "remote" : "local";
257
- const webhook = `${config.url}/plugin-kirby-deploy`;
262
+ const webhookBase = `${config.url}/plugin-kirby-deploy`;
263
+ const shouldCallWebhooks = mode === "push" && config.callWebhooks;
258
264
  const destination = source === "./" ? config.remoteDir : `./${join2(config.remoteDir, source)}`;
265
+ if (shouldCallWebhooks && !config.token) {
266
+ consola5.error("token needed to call webhooks");
267
+ return false;
268
+ }
269
+ if (shouldCallWebhooks && !config.url) {
270
+ consola5.error("url needed to call webhooks");
271
+ return false;
272
+ }
259
273
  const flags = [
260
274
  "--continue",
261
275
  "--only-newer",
@@ -292,8 +306,9 @@ var sync = async (source, mode, config) => {
292
306
  consola5.log("");
293
307
  }
294
308
  consola5.log("Apply changes...\n");
295
- if (config.callWebhooks)
296
- await callWebhook(`${webhook}/start`, config.token);
309
+ if (shouldCallWebhooks) {
310
+ await callWebhook(`${webhookBase}/start`, config.token);
311
+ }
297
312
  let hasChanges, hasErrors;
298
313
  try {
299
314
  ;
@@ -307,8 +322,8 @@ var sync = async (source, mode, config) => {
307
322
  consola5.error(e);
308
323
  return false;
309
324
  } finally {
310
- if (config.callWebhooks) {
311
- await callWebhook(`${webhook}/finish`, config.token);
325
+ if (shouldCallWebhooks) {
326
+ await callWebhook(`${webhookBase}/finish`, config.token);
312
327
  }
313
328
  }
314
329
  if (!hasChanges) {
@@ -418,7 +433,7 @@ var main = defineCommand3({
418
433
  ];
419
434
  const excludeGlob = [...config.excludeGlob, ".*", ".*/"];
420
435
  const include = config.include;
421
- const includeGlob = [...config.includeGlob, ".htaccess"];
436
+ const includeGlob = [...config.includeGlob, ".htaccess", ".vite/"];
422
437
  const branch = getBranch();
423
438
  const displaySource = branch ? colors5.cyan(` ${branch} `) : " ";
424
439
  const displayDestination = colors5.magenta(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kirby-deploy",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,7 +35,7 @@ export const main = defineCommand({
35
35
  ]
36
36
  const excludeGlob = [...config.excludeGlob, '.*', '.*/']
37
37
  const include = config.include
38
- const includeGlob = [...config.includeGlob, '.htaccess']
38
+ const includeGlob = [...config.includeGlob, '.htaccess', '.vite/']
39
39
 
40
40
  const branch = getBranch()
41
41
  const displaySource = branch ? colors.cyan(` ${branch} `) : ' '
package/src/config.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { loadConfig as load } from 'c12'
2
2
  import consola from 'consola'
3
3
  import { flatten, parse } from 'valibot'
4
- import { Config, ConfigResolved, ConfigSchema } from './types'
4
+ import { Config, ConfigResolved, ConfigSchema, FolderStructure } from './types'
5
5
 
6
6
  export const loadConfig = async (): Promise<ConfigResolved | null> => {
7
7
  let { config, configFile } = await load<Config>({
@@ -27,9 +27,11 @@ export const loadConfig = async (): Promise<ConfigResolved | null> => {
27
27
  }
28
28
 
29
29
  // Resolve shorthands
30
+
31
+ let folderStructure: FolderStructure
30
32
  config.folderStructure ??= 'flat'
31
33
  if (config.folderStructure === 'public') {
32
- config.folderStructure = {
34
+ folderStructure = {
33
35
  content: 'content',
34
36
  media: 'public/media',
35
37
  accounts: 'storage/accounts',
@@ -37,18 +39,22 @@ export const loadConfig = async (): Promise<ConfigResolved | null> => {
37
39
  cache: 'storage/cache',
38
40
  }
39
41
  } else if (config.folderStructure === 'flat') {
40
- config.folderStructure = {
42
+ // 'flat' structure is the default.
43
+ folderStructure = {
41
44
  content: 'content',
42
45
  media: 'site/media',
43
46
  accounts: 'site/accounts',
44
47
  sessions: 'site/sessions',
45
48
  cache: 'site/cache',
46
49
  }
50
+ } else {
51
+ folderStructure = config.folderStructure
47
52
  }
48
53
 
49
- config = {
54
+ const configResolved = {
50
55
  remoteDir: './',
51
56
  dryRun: true,
57
+ verbose: false,
52
58
  parallel: 10,
53
59
  checkComposerLock: true,
54
60
  callWebhooks: true,
@@ -57,12 +63,13 @@ export const loadConfig = async (): Promise<ConfigResolved | null> => {
57
63
  include: [],
58
64
  includeGlob: [],
59
65
  ...config,
66
+ folderStructure,
60
67
  lftpSettings: {
61
68
  'ftp:ssl-force': true,
62
69
  ...config.lftpSettings,
63
70
  },
64
71
  lftpFlags: ['--parallel=10', '--dereference', ...(config.lftpFlags ?? [])],
65
- }
72
+ } satisfies ConfigResolved
66
73
 
67
- return config as ConfigResolved
74
+ return configResolved
68
75
  }
package/src/sync.ts CHANGED
@@ -11,10 +11,21 @@ export const sync = async (
11
11
  ): Promise<boolean> => {
12
12
  const reverse = mode === 'push'
13
13
  const targetName = mode === 'push' ? 'remote' : 'local'
14
- const webhook = `${config.url}/plugin-kirby-deploy`
14
+ const webhookBase = `${config.url}/plugin-kirby-deploy`
15
+ const shouldCallWebhooks = mode === 'push' && config.callWebhooks
15
16
  const destination =
16
17
  source === './' ? config.remoteDir : `./${join(config.remoteDir, source)}`
17
18
 
19
+ if (shouldCallWebhooks && !config.token) {
20
+ consola.error('token needed to call webhooks')
21
+ return false
22
+ }
23
+
24
+ if (shouldCallWebhooks && !config.url) {
25
+ consola.error('url needed to call webhooks')
26
+ return false
27
+ }
28
+
18
29
  const flags = [
19
30
  '--continue',
20
31
  '--only-newer',
@@ -57,8 +68,10 @@ export const sync = async (
57
68
 
58
69
  consola.log('Apply changes...\n')
59
70
 
71
+ if (shouldCallWebhooks) {
72
+ await callWebhook(`${webhookBase}/start`, config.token!)
73
+ }
60
74
  // Make sure the finish hook is called even if an unexpected error occurs.
61
- if (config.callWebhooks) await callWebhook(`${webhook}/start`, config.token)
62
75
  let hasChanges, hasErrors
63
76
  try {
64
77
  ;({ hasChanges, hasErrors } = await mirror(
@@ -71,8 +84,8 @@ export const sync = async (
71
84
  consola.error(e)
72
85
  return false
73
86
  } finally {
74
- if (config.callWebhooks) {
75
- await callWebhook(`${webhook}/finish`, config.token)
87
+ if (shouldCallWebhooks) {
88
+ await callWebhook(`${webhookBase}/finish`, config.token!)
76
89
  }
77
90
  }
78
91
 
package/src/types.ts CHANGED
@@ -47,6 +47,9 @@ export const ConfigSchema = object({
47
47
 
48
48
  export type Config = Output<typeof ConfigSchema>
49
49
 
50
- export type ConfigResolved = Required<Omit<Config, 'folderStructure'>> & {
50
+ type ConfigWithDefaults = Pick<Config, 'url' | 'token'> &
51
+ Required<Omit<Config, 'url' | 'token'>>
52
+
53
+ export type ConfigResolved = Omit<ConfigWithDefaults, 'folderStructure'> & {
51
54
  folderStructure: FolderStructure
52
55
  }