@syncify/cli 0.1.3-beta → 0.2.1-beta

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.
@@ -0,0 +1,509 @@
1
+ /* eslint-disable no-unused-vars */
2
+
3
+ import type { Tester } from 'anymatch';
4
+ import type { Config as TailwindProcessor } from 'tailwindcss';
5
+ import type { Merge } from 'type-fest';
6
+ import type { Markdown } from './markdown';
7
+ import type { AxiosRequestConfig } from 'axios';
8
+ import type { ESBuildProcesser, ScriptBundle } from '../transforms/script';
9
+ import type { SASSProcesser, PostCSSProcesser, StyleBundle } from '../transforms/style';
10
+ import type { SVGOProcesser, SVGSpriteProcesser } from '../transforms/svg';
11
+ import type { JSONBundle } from '../transforms/json';
12
+ import type { FSWatcher } from 'chokidar';
13
+ import type { ChildProcessWithoutNullStreams } from 'child_process';
14
+ import type * as Config from '../config/index';
15
+
16
+ /* -------------------------------------------- */
17
+ /* PROCESSORS */
18
+ /* -------------------------------------------- */
19
+
20
+ export interface SpawnCommand {
21
+ /**
22
+ * The base command, For example `esbuild` would be the
23
+ * _base_ command in `esbuild src/file.js --watch`. If an
24
+ * array command was provided in config then this value would
25
+ * represent the first item in that array.
26
+ */
27
+ cmd: string;
28
+ /**
29
+ * The command arguments. For example, all commands following
30
+ * the base command. The value here will be passed to spawn.
31
+ */
32
+ args: string[];
33
+ /**
34
+ * The process id (pid) assigned to the spawn. This is dynamically
35
+ * assigned and will be `NaN` until spawn has been invoked.
36
+ */
37
+ pid: number;
38
+ }
39
+
40
+ /* -------------------------------------------- */
41
+ /* ENVIRONMENT REFERENCES */
42
+ /* -------------------------------------------- */
43
+
44
+ /**
45
+ * **INTERNAL USE**
46
+ *
47
+ * Execution options which describe the invocation and operation
48
+ * instructions which Syncify was initialised.
49
+ */
50
+ export interface Env {
51
+ /**
52
+ * Building for development (default)
53
+ *
54
+ * @default true
55
+ */
56
+ dev: boolean;
57
+ /**
58
+ * Building for production (default)
59
+ *
60
+ * @default false
61
+ */
62
+ prod: boolean;
63
+ /**
64
+ * Signals sync execution, values represent the following:
65
+ *
66
+ * `0` - _No sync operation inferred_
67
+ *
68
+ * `1` - _Sync to 1 store and 1 theme_
69
+ *
70
+ * `2` - _Syncing to more than 1 store or theme._
71
+ *
72
+ * @default 0
73
+ */
74
+ sync: 0 | 1 | 2;
75
+ /**
76
+ * Whether or not syncify was CLI Initialized. When `false` syncify
77
+ * was called from JavaScript API, whereas `true` means it was invoked via API.
78
+ *
79
+ * @default false
80
+ */
81
+ cli: boolean;
82
+ }
83
+
84
+ /* -------------------------------------------- */
85
+ /* SPAWN CONFIGURATION */
86
+ /* -------------------------------------------- */
87
+
88
+ /**
89
+ * **INTERNAL USE**
90
+ *
91
+ * Spawn configuration state.
92
+ */
93
+ export interface Spawn {
94
+ /**
95
+ * Dynamically populated `Set` of file paths
96
+ * that were generated from a spawned process.
97
+ * Each item in the set will be matched against
98
+ * in modes like `watch` from the chokidar instance.
99
+ */
100
+ paths: Set<string>;
101
+ /**
102
+ * Whether or not a spawn process ran. This is used
103
+ * to determine what action took place in the build
104
+ * cycles. When this value is `true` it infers a spawn
105
+ * process was fired, when `false` it infers the opposite.
106
+ *
107
+ * > _Spawned invocation uses the `stdio` stream to determine
108
+ * whether or not a change was fired by a child running process_
109
+ */
110
+ invoked: boolean;
111
+ /**
112
+ * Child Processes
113
+ *
114
+ * Collection of spawned child proccesses. We need to hold reference of these
115
+ * so as they can be killed when ending the session.
116
+ */
117
+ streams: Map<string, ChildProcessWithoutNullStreams>
118
+ /**
119
+ * Commands that were spawned.
120
+ */
121
+ commands: {
122
+ /**
123
+ * The name of the process that will run, eg: `esbuild`
124
+ */
125
+ [name: string]: SpawnCommand
126
+ }
127
+ }
128
+
129
+ /* -------------------------------------------- */
130
+ /* STORE CONFIGURATION */
131
+ /* -------------------------------------------- */
132
+
133
+ /**
134
+ * **INTERNAL USE**
135
+ *
136
+ * Store authorisation client
137
+ */
138
+ export interface Store {
139
+ /**
140
+ * The store domain name in Upcase (without `myshopify.com`)
141
+ */
142
+ store: string;
143
+ /**
144
+ * The store myshopify domain, eg: `store.myshopify.com`
145
+ */
146
+ domain: string;
147
+ /**
148
+ * Client instances
149
+ */
150
+ client: AxiosRequestConfig
151
+ /**
152
+ * Queue
153
+ */
154
+ queue: boolean;
155
+ }
156
+
157
+ /* -------------------------------------------- */
158
+ /* THEME CONFIGURATION */
159
+ /* -------------------------------------------- */
160
+
161
+ /**
162
+ * **INTERNAL USE**
163
+ *
164
+ * Theme related model
165
+ */
166
+ export interface Theme {
167
+ /**
168
+ * The store index reference
169
+ */
170
+ sidx: number;
171
+ /**
172
+ * The theme id.
173
+ */
174
+ id: number;
175
+ /**
176
+ * The store domain name
177
+ */
178
+ store: string;
179
+ /**
180
+ * The theme target name
181
+ */
182
+ target: string;
183
+ /**
184
+ * The authorized assets URL endpoint
185
+ */
186
+ url: string;
187
+ }
188
+
189
+ /* -------------------------------------------- */
190
+ /* SYNC CONFIGURATION */
191
+ /* -------------------------------------------- */
192
+
193
+ /**
194
+ * **INTERNAL USE**
195
+ *
196
+ * Sync clients
197
+ */
198
+ export interface Sync {
199
+ /**
200
+ * Theme synchronization options
201
+ */
202
+ themes: Array<Theme>;
203
+ /**
204
+ * Store synchronization options
205
+ */
206
+ stores: Array<Store>;
207
+ }
208
+
209
+ /* -------------------------------------------- */
210
+ /* TERSER CONFIGURATION */
211
+ /* -------------------------------------------- */
212
+
213
+ /* -------------------------------------------- */
214
+ /* MODE CONFIGURATION */
215
+ /* -------------------------------------------- */
216
+
217
+ /**
218
+ * **INTERNAL USE**
219
+ *
220
+ * Execution modes
221
+ */
222
+ export interface Modes {
223
+ /**
224
+ * Run the command prompt
225
+ */
226
+ interactive: boolean;
227
+ /**
228
+ * Execute a build, alias: `-b`
229
+ */
230
+ build: boolean;
231
+ /**
232
+ * Execute watch, alias: `-w`
233
+ */
234
+ watch: boolean;
235
+ /**
236
+ * Execute Upload, alias: `-u`
237
+ */
238
+ upload: boolean;
239
+ /**
240
+ * Execute Download, alias: `-d`
241
+ */
242
+ download: boolean;
243
+ /**
244
+ * Execute Clean, alias: `-c`
245
+ */
246
+ clean: boolean;
247
+ /**
248
+ * Generates VSC Schema spec file
249
+ */
250
+ vsc: boolean;
251
+ /**
252
+ * Execute metafields action, `--metafields`
253
+ */
254
+ metafields: boolean
255
+ /**
256
+ * Execute redirects resource, `--redirects`
257
+ */
258
+ redirects: boolean;
259
+ /**
260
+ * Execute page action, `--pages`
261
+ */
262
+ pages: boolean
263
+ /**
264
+ * Pull data from remote store, `--pull`
265
+ */
266
+ pull: boolean;
267
+ /**
268
+ * Force upload and overwrite, `--force`
269
+ */
270
+ force: boolean;
271
+ /**
272
+ * Invoke HOT reloads, `--hot`
273
+ */
274
+ hot: boolean;
275
+ /**
276
+ * Run the style transform, `--style`
277
+ */
278
+ style: boolean;
279
+ /**
280
+ * Run the script transform, `--script`
281
+ */
282
+ script: boolean;
283
+ /**
284
+ * Run the svg transform, `--svg`
285
+ */
286
+ svg: boolean;
287
+ /**
288
+ * Run the image transform, `--image`
289
+ */
290
+ image: boolean;
291
+ /**
292
+ * Run minification, either `--prod`, `--terse`
293
+ */
294
+ terse: boolean;
295
+ /**
296
+ * Trigger export, alias: `-e`
297
+ */
298
+ export: boolean;
299
+ }
300
+
301
+ /* -------------------------------------------- */
302
+ /* CMD CONFIGURATION */
303
+ /* -------------------------------------------- */
304
+
305
+ /**
306
+ * **INTERNAL USE**
307
+ *
308
+ * Passed command overwrites
309
+ */
310
+ export interface CommandBundle {
311
+ /**
312
+ * An input overwrite path was passed
313
+ *
314
+ * @default null
315
+ */
316
+ input: string;
317
+ /**
318
+ * An output overwrite path was passed
319
+ *
320
+ * @default null
321
+ */
322
+ output: string;
323
+ /**
324
+ * A config overwrite path was passed
325
+ *
326
+ * @default null
327
+ */
328
+ config: string;
329
+ /**
330
+ * Filters were passed in the command
331
+ *
332
+ * @default null
333
+ */
334
+ filter: string;
335
+ /**
336
+ * Deletions were passed in the command
337
+ *
338
+ * @default null
339
+ */
340
+ delete: string;
341
+ }
342
+
343
+ /* -------------------------------------------- */
344
+ /* CONFIG FILE RESOLUTION */
345
+ /* -------------------------------------------- */
346
+
347
+ /**
348
+ * **INTERNAL USE**
349
+ *
350
+ * Configuration File
351
+ */
352
+ export interface ConfigFile {
353
+ /**
354
+ * The full resolved path to the syncify configuration file
355
+ *
356
+ * @example
357
+ *
358
+ * 'Users/Sissel/Sites/Folder/views/dir/syncify.config.ts'
359
+ */
360
+ path: string;
361
+ /**
362
+ * The config file name including file extension.
363
+ *
364
+ * @example
365
+ *
366
+ * 'syncify.config.ts'
367
+ */
368
+ base: string;
369
+ /**
370
+ * The config file relative path location from current _root_ working directory.
371
+ * This is typically going to match the `base` value as most config files work
372
+ * from workspace root directory unless inferred otherwise.
373
+ *
374
+ * @example
375
+ *
376
+ * 'dir/syncify.config.ts'
377
+ */
378
+ relative: string;
379
+ }
380
+
381
+ /* -------------------------------------------- */
382
+ /* SECTIONS */
383
+ /* -------------------------------------------- */
384
+
385
+ /**
386
+ * **INTERNAL USE**
387
+ *
388
+ * Sections sub-directory configuration
389
+ */
390
+ export type SectionBundle = Merge<Config.Views['sections'], {
391
+ global: RegExp;
392
+ paths?: Tester;
393
+ }>
394
+
395
+ /* -------------------------------------------- */
396
+ /* SNIPPETS */
397
+ /* -------------------------------------------- */
398
+
399
+ /**
400
+ * **INTERNAL USE**
401
+ *
402
+ * Snippets sub-directory configuration
403
+ */
404
+ export type SnippetBundle = Merge<Config.Views['snippets'], {
405
+ global: RegExp;
406
+ paths?: Tester;
407
+ }>
408
+
409
+ /* -------------------------------------------- */
410
+ /* PATHS */
411
+ /* -------------------------------------------- */
412
+
413
+ /**
414
+ * **INTERNAL USE**
415
+ *
416
+ * Anymatched paths
417
+ */
418
+ export type PathsBundle = Merge<Config.Paths<Tester>, {
419
+ transforms?: Map<string, 7 | 8 | 9>
420
+ }>;
421
+
422
+ /* -------------------------------------------- */
423
+ /* PAGES */
424
+ /* -------------------------------------------- */
425
+
426
+ /**
427
+ * **INTERNAL USE**
428
+ *
429
+ * Page configuration
430
+ */
431
+ export type PagesBundle = Merge<Config.Views['pages'], {
432
+ import: Markdown.Import;
433
+ export: Markdown.Export
434
+ }>
435
+
436
+ /* -------------------------------------------- */
437
+ /* WATCH */
438
+ /* -------------------------------------------- */
439
+
440
+ /**
441
+ * **INTERNAL USE**
442
+ *
443
+ * Chokidar watch instance
444
+ */
445
+ export type WatchBundle = Merge<FSWatcher, {
446
+ /**
447
+ * Private method of chokidar
448
+ */
449
+ _watched: Map<string, { items: Set<string> }>;
450
+ /**
451
+ * The chokidar instance will be a `Set` when running in
452
+ * non-watch modes. This value is used in the `paths` getter
453
+ * to convert entries to an array.
454
+ */
455
+ values (): IterableIterator<string>;
456
+ /**
457
+ * Check whether or not a path is being watched
458
+ */
459
+ has (path: string, dir?: string): boolean;
460
+ /**
461
+ * Returns all watched paths
462
+ */
463
+ get paths (): string[]
464
+ }>;
465
+
466
+ /* -------------------------------------------- */
467
+ /* PROCESSORS */
468
+ /* -------------------------------------------- */
469
+
470
+ /**
471
+ * **INTERNAL USE**
472
+ *
473
+ * Processor configuration state. This model infers which
474
+ * pre-processors are being used and/or available.
475
+ */
476
+ export interface ProcessorsBundle {
477
+ /**
478
+ * JSON processing
479
+ */
480
+ json: JSONBundle;
481
+ /**
482
+ * [PostCSS](https://postcss.org/) Pre-Processor
483
+ */
484
+ postcss: PostCSSProcesser;
485
+ /**
486
+ * [SASS Dart](https://sass-lang.com/documentation/js-api/) Pre-Processor
487
+ */
488
+ sass: SASSProcesser;
489
+ /**
490
+ * [TailwindCSS](https://tailwindcss.com/) Pre-Processor
491
+ */
492
+ tailwind: TailwindProcessor;
493
+ /**
494
+ * [Sharp](https://sharp.pixelplumbing.com) Pre-Processor
495
+ */
496
+ sharp: any;
497
+ /**
498
+ * [SVG Sprite](https://github.com/svg-sprite) Pre-Processor
499
+ */
500
+ sprite: SVGSpriteProcesser;
501
+ /**
502
+ * [SVGO](https://github.com/svg/svgo) Pre-Processor
503
+ */
504
+ svgo: SVGOProcesser
505
+ /**
506
+ * [ESBuild](https://esbuild.github.io/) Pre-Processor
507
+ */
508
+ esbuild: ESBuildProcesser
509
+ }
@@ -1,20 +1,18 @@
1
- import { Bundle } from '.';
2
1
  import { File } from './file';
3
- import { Config, Transforms } from '../config';
2
+ import { Transforms, Config } from '../config';
4
3
  import { WebSocketServer } from 'ws';
5
- import { Merge } from 'type-fest';
6
4
 
7
5
  /* -------------------------------------------- */
8
6
  /* PLUGIN SCOPE */
9
7
  /* -------------------------------------------- */
10
8
 
11
- export type PluginScope = Merge<Bundle, {
9
+ export type PluginScope = {
12
10
  log: {
13
11
  info: (...message: string[]) => void;
14
12
  warn: (...message: string[]) => void;
15
13
  error: (...message: string[]) => void;
16
14
  }
17
- }>
15
+ }
18
16
 
19
17
  /* -------------------------------------------- */
20
18
  /* PLUGIN HOOKS */
@@ -25,6 +23,10 @@ export interface PluginHooks {
25
23
  * The plugin name
26
24
  */
27
25
  name: Lowercase<string>;
26
+ /**
27
+ * A list of file extension the plugin handles
28
+ */
29
+ extensions?: string[];
28
30
  /**
29
31
  * Optionally infer the required transformer
30
32
  */
@@ -0,0 +1,54 @@
1
+ import type { JSONConfig } from '../transforms/json';
2
+ import type { SharpConfig } from '../transforms/image';
3
+ import type { BuildOptions } from 'esbuild';
4
+ import type { SASSConfig, PostCSSConfig } from '../transforms/style';
5
+ import type { SVGOConfig, SVGSpriteConfig } from '../transforms/svg';
6
+
7
+ /**
8
+ * **Internal Use**
9
+ *
10
+ * Processor Default Configurations
11
+ *
12
+ * Holds reference to default config options for
13
+ * each supported processor.
14
+ */
15
+ export interface ProcessorsBundle {
16
+ /**
17
+ * JSON File processing - Options defined here are used when
18
+ * writing to the file system. Typically in operations like
19
+ * `--merge`, `--pull` and `--download`.
20
+ *
21
+ * > The options will also be used in **development** (`dev`)
22
+ * mode when uploading `.json` files to stores/themes.
23
+ */
24
+ json?: JSONConfig;
25
+ /**
26
+ * [ESBuild](https://esbuild.github.io/) Config
27
+ *
28
+ * Syncify uses ESBuild under the hood for JS/TS transpilation.
29
+ * Some native ESBuild options are omitted from processing and
30
+ * handled internally by Syncify.
31
+ */
32
+ esbuild?: BuildOptions;
33
+ /**
34
+ * [PostCSS](https://postcss.org/) Plugins
35
+ */
36
+ postcss?: PostCSSConfig[]
37
+ /**
38
+ * [SASS Dart](https://sass-lang.com/documentation/js-api/) Config
39
+ */
40
+ sass?: SASSConfig
41
+ /**
42
+ * [Sharp](https://sharp.pixelplumbing.com) Config
43
+ */
44
+ sharp?: SharpConfig;
45
+ /**
46
+ * [SVGO](https://github.com/svg/svgo) Config
47
+ *
48
+ */
49
+ svgo?: SVGOConfig;
50
+ /**
51
+ * [SVG Sprite](https://github.com/svg-sprite) Config
52
+ */
53
+ sprite?: SVGSpriteConfig
54
+ }
@@ -1,6 +1,6 @@
1
- import { File } from 'types/bundle';
1
+ import { File } from './file';
2
2
 
3
- export interface BuildModeReport {
3
+ export interface UploadModeReport {
4
4
  /**
5
5
  * The file name that was build (including extension)
6
6
  *
@@ -9,24 +9,75 @@ export interface BuildModeReport {
9
9
  */
10
10
  name: string;
11
11
  /**
12
- * The processing time it took to build
12
+ * The upload time for this specific file
13
13
  *
14
14
  * @example
15
15
  * '1ms'
16
16
  */
17
17
  time: string;
18
18
  /**
19
- * The output directory the file written.
19
+ * The upload error (if occurred)
20
+ *
21
+ * @default
22
+ * null
23
+ */
24
+ error: any;
25
+ }
26
+
27
+ export interface UploadReport {
28
+ /**
29
+ * List of files in the upload group
30
+ */
31
+ files: File[];
32
+ /**
33
+ * The amount of time the group took to upload
34
+ */
35
+ time: string;
36
+ /**
37
+ * The upload report for each file handled
38
+ */
39
+ report: UploadModeReport[]
40
+ }
41
+
42
+ /* -------------------------------------------- */
43
+ /* BUILD MODE REPORTING */
44
+ /* -------------------------------------------- */
45
+
46
+ export interface BuildModeReport {
47
+ /**
48
+ * The file name that was build (including extension)
49
+ *
50
+ * @example
51
+ * 'index.liquid'
52
+ */
53
+ name: string;
54
+ /**
55
+ * The relative input path of the file
20
56
  *
21
57
  * @example
22
- * 'templates' // if file is something like index.json
58
+ * 'src/template/index.liquid'
23
59
  */
24
- output: string;
60
+ input: string;
61
+ /**
62
+ * The relative output directory path of the file
63
+ *
64
+ * @example
65
+ * 'templates/index.liquid'
66
+ */
67
+ output: string;
68
+ /**
69
+ * The processing time it took to build
70
+ *
71
+ * @example
72
+ * '1ms'
73
+ */
74
+ time: string;
25
75
  /**
26
76
  * A readable error string inferring any issues which may have occured.
27
77
  *
28
78
  * @example
29
79
  * 'skipped file'
80
+ *
30
81
  * @default
31
82
  * null
32
83
  */
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { File, FileKeys } from '../bundle/file';
2
+ import { File, FileKeys } from './file';
3
3
 
4
4
  /**
5
5
  * Axios Request Methods
@@ -14,7 +14,7 @@ export type Client = (method: Methods, file: File, content?: string) => Promise<
14
14
  /**
15
15
  * Client Request as parameter
16
16
  */
17
- export type ClientParam<T> = (method: Methods, file: File<T>, content?: string) => Promise<void>
17
+ export type ClientParam<T = any> = (method: Methods, file: File<T>, content?: string) => Promise<void>
18
18
 
19
19
  /**
20
20
  * Resources
@@ -34,7 +34,7 @@ export type GetAsset = (
34
34
  `templates/${string}${'.liquid' | '.json'}` |
35
35
  `templates/customer/${string}${'.liquid' | '.json'}` |
36
36
  `assets/${string}` |
37
- `sections/${string}${'.liquid'}` |
37
+ `sections/${string}${'-group.json' | '.liquid'}` |
38
38
  `snippets/${string}${'.liquid'}` |
39
39
  `layout/${string}${'.liquid'}` |
40
40
  `locales/${string}${'.json'}` |
@@ -158,7 +158,8 @@ export namespace Requests {
158
158
  */
159
159
  asset: {
160
160
  key: FileKeys,
161
- value: string
161
+ value: string,
162
+ attachment?: string;
162
163
  }
163
164
  }
164
165