@syncify/cli 0.3.0-beta → 1.0.0-unstable.0

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.
Files changed (42) hide show
  1. package/LICENSE +10 -6
  2. package/dist/api.js +32 -12
  3. package/dist/cli.js +610 -6
  4. package/dist/index.d.ts +2264 -0
  5. package/dist/index.js +10 -10
  6. package/dist/syncify.js +24248 -0
  7. package/hot.js.liquid +13 -2
  8. package/package.json +118 -115
  9. package/readme.md +110 -2176
  10. package/scripts/postinstall.js +116 -0
  11. package/scripts/postversion.js +60 -0
  12. package/dist/cjs.js +0 -236
  13. package/pnpm-lock.yaml +0 -5662
  14. package/schema/syncify.config.json +0 -676
  15. package/schema/syncify.env.json +0 -58
  16. package/schema/syncify.package.json +0 -11
  17. package/types/api.d.ts +0 -319
  18. package/types/bundle/cache.d.ts +0 -101
  19. package/types/bundle/commands.d.ts +0 -396
  20. package/types/bundle/errors.d.ts +0 -101
  21. package/types/bundle/file.d.ts +0 -285
  22. package/types/bundle/filters.d.ts +0 -81
  23. package/types/bundle/hot.d.ts +0 -185
  24. package/types/bundle/index.d.ts +0 -603
  25. package/types/bundle/plugin.d.ts +0 -127
  26. package/types/bundle/processors.d.ts +0 -54
  27. package/types/bundle/reports.d.ts +0 -123
  28. package/types/bundle/requests.d.ts +0 -374
  29. package/types/bundle/shared.d.ts +0 -124
  30. package/types/cli.d.ts +0 -547
  31. package/types/config/index.d.ts +0 -550
  32. package/types/config/terser.d.ts +0 -319
  33. package/types/config/views.d.ts +0 -191
  34. package/types/index.d.ts +0 -55
  35. package/types/modules/html-minifier-terser.d.ts +0 -218
  36. package/types/stores.d.ts +0 -11
  37. package/types/transforms/image.d.ts +0 -15
  38. package/types/transforms/json.d.ts +0 -51
  39. package/types/transforms/pages.d.ts +0 -254
  40. package/types/transforms/script.d.ts +0 -308
  41. package/types/transforms/style.d.ts +0 -219
  42. package/types/transforms/svg.d.ts +0 -189
@@ -1,603 +0,0 @@
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 { AxiosRequestConfig } from 'axios';
7
- import type { ESBuildProcesser } from '../transforms/script';
8
- import type { SASSProcesser, PostCSSProcesser } from '../transforms/style';
9
- import type { SVGOProcesser, SVGSpriteProcesser } from '../transforms/svg';
10
- import type { JSONBundle } from '../transforms/json';
11
- import type { FSWatcher } from 'chokidar';
12
- import type { ChildProcessWithoutNullStreams } from 'child_process';
13
- import type * as Config from '../config/index';
14
-
15
- /* -------------------------------------------- */
16
- /* PROCESSORS */
17
- /* -------------------------------------------- */
18
-
19
- export interface SpawnCommand {
20
- /**
21
- * The base command, For example `esbuild` would be the
22
- * _base_ command in `esbuild src/file.js --watch`. If an
23
- * array command was provided in config then this value would
24
- * represent the first item in that array.
25
- */
26
- cmd: string;
27
- /**
28
- * The command arguments. For example, all commands following
29
- * the base command. The value here will be passed to spawn.
30
- */
31
- args: string[];
32
- /**
33
- * The process id (pid) assigned to the spawn. This is dynamically
34
- * assigned and will be `NaN` until spawn has been invoked.
35
- */
36
- pid: number;
37
- }
38
-
39
- /* -------------------------------------------- */
40
- /* ENVIRONMENT REFERENCES */
41
- /* -------------------------------------------- */
42
-
43
- /**
44
- * **INTERNAL USE**
45
- *
46
- * Execution options which describe the invocation and operation
47
- * instructions which Syncify was initialised.
48
- */
49
- export interface Env {
50
- /**
51
- * Building for development (default)
52
- *
53
- * @default true
54
- */
55
- dev: boolean;
56
- /**
57
- * Building for production (default)
58
- *
59
- * @default false
60
- */
61
- prod: boolean;
62
- /**
63
- * Signals sync execution, values represent the following:
64
- *
65
- * `0` - _No sync operation inferred_
66
- *
67
- * `1` - _Sync to 1 store and 1 theme_
68
- *
69
- * `2` - _Syncing to more than 1 store or theme._
70
- *
71
- * @default 0
72
- */
73
- sync: 0 | 1 | 2;
74
- /**
75
- * Whether or not syncify was CLI Initialized. When `false` syncify
76
- * was called from JavaScript API, whereas `true` means it was invoked via API.
77
- *
78
- * @default false
79
- */
80
- cli: boolean;
81
- }
82
-
83
- /* -------------------------------------------- */
84
- /* SPAWN CONFIGURATION */
85
- /* -------------------------------------------- */
86
-
87
- /**
88
- * **INTERNAL USE**
89
- *
90
- * Spawn configuration state.
91
- */
92
- export interface Spawn {
93
- /**
94
- * Dynamically populated `Set` of file paths
95
- * that were generated from a spawned process.
96
- * Each item in the set will be matched against
97
- * in modes like `watch` from the chokidar instance.
98
- */
99
- paths: Set<string>;
100
- /**
101
- * Whether or not a spawn process ran. This is used
102
- * to determine what action took place in the build
103
- * cycles. When this value is `true` it infers a spawn
104
- * process was fired, when `false` it infers the opposite.
105
- *
106
- * > _Spawned invocation uses the `stdio` stream to determine
107
- * whether or not a change was fired by a child running process_
108
- */
109
- invoked: boolean;
110
- /**
111
- * Child Processes
112
- *
113
- * Collection of spawned child proccesses. We need to hold reference of these
114
- * so as they can be killed when ending the session.
115
- */
116
- streams: Map<string, ChildProcessWithoutNullStreams>
117
- /**
118
- * Commands that were spawned.
119
- */
120
- commands: {
121
- /**
122
- * The name of the process that will run, eg: `esbuild`
123
- */
124
- [name: string]: SpawnCommand
125
- }
126
- }
127
-
128
- /* -------------------------------------------- */
129
- /* STORE CONFIGURATION */
130
- /* -------------------------------------------- */
131
-
132
- /**
133
- * **INTERNAL USE**
134
- *
135
- * Store authorisation client
136
- */
137
- export interface Store {
138
- /**
139
- * The store domain name in Upcase (without `myshopify.com`)
140
- */
141
- store: string;
142
- /**
143
- * The store myshopify domain, eg: `store.myshopify.com`
144
- */
145
- domain: string;
146
- /**
147
- * Client instances
148
- */
149
- client: AxiosRequestConfig
150
- /**
151
- * Queue
152
- */
153
- queue: boolean;
154
- }
155
-
156
- /* -------------------------------------------- */
157
- /* THEME CONFIGURATION */
158
- /* -------------------------------------------- */
159
-
160
- /**
161
- * **INTERNAL USE**
162
- *
163
- * Theme related model
164
- */
165
- export interface Theme {
166
- /**
167
- * The store index reference
168
- */
169
- sidx: number;
170
- /**
171
- * The theme id.
172
- */
173
- id: number;
174
- /**
175
- * The store domain name
176
- */
177
- store: string;
178
- /**
179
- * The theme target name
180
- */
181
- target: string;
182
- /**
183
- * The authorized assets URL endpoint
184
- */
185
- url: string;
186
- }
187
-
188
- /* -------------------------------------------- */
189
- /* SYNC CONFIGURATION */
190
- /* -------------------------------------------- */
191
-
192
- /**
193
- * **INTERNAL USE**
194
- *
195
- * Sync clients
196
- */
197
- export interface Sync {
198
- /**
199
- * Theme synchronization options
200
- */
201
- themes: Array<Theme>;
202
- /**
203
- * Store synchronization options
204
- */
205
- stores: Array<Store>;
206
- }
207
-
208
- /* -------------------------------------------- */
209
- /* TERSER CONFIGURATION */
210
- /* -------------------------------------------- */
211
-
212
- /* -------------------------------------------- */
213
- /* MODE CONFIGURATION */
214
- /* -------------------------------------------- */
215
-
216
- /**
217
- * **INTERNAL USE**
218
- *
219
- * Execution modes
220
- */
221
- export interface Modes {
222
- /**
223
- * Run the command prompt
224
- */
225
- interactive: boolean;
226
- /**
227
- * Execute a build, alias: `-b`
228
- */
229
- build: boolean;
230
- /**
231
- * Execute watch, alias: `-w`
232
- */
233
- watch: boolean;
234
- /**
235
- * Execute Upload, alias: `-u`
236
- */
237
- upload: boolean;
238
- /**
239
- * Execute Download, alias: `-d`
240
- */
241
- download: boolean;
242
- /**
243
- * Execute Clean, alias: `-c`
244
- */
245
- clean: boolean;
246
- /**
247
- * Generates VSC Schema spec file
248
- */
249
- vsc: boolean;
250
- /**
251
- * Execute metafields action, `--metafields`
252
- */
253
- metafields: boolean
254
- /**
255
- * Execute redirects resource, `--redirects`
256
- */
257
- redirects: boolean;
258
- /**
259
- * Execute page action, `--pages`
260
- */
261
- pages: boolean
262
- /**
263
- * Pull data from remote store, `--pull`
264
- */
265
- pull: boolean;
266
- /**
267
- * Force upload and overwrite, `--force`
268
- */
269
- force: boolean;
270
- /**
271
- * Invoke HOT reloads, `--hot`
272
- */
273
- hot: boolean;
274
- /**
275
- * Run the views transform, `--views`
276
- */
277
- views: boolean;
278
- /**
279
- * Run the style transform, `--style`
280
- */
281
- style: boolean;
282
- /**
283
- * Run the script transform, `--script`
284
- */
285
- script: boolean;
286
- /**
287
- * Run the svg transform, `--svg`
288
- */
289
- svg: boolean;
290
- /**
291
- * Run the image transform, `--image`
292
- */
293
- image: boolean;
294
- /**
295
- * Run minification, either `--prod`, `--terse`
296
- */
297
- terse: boolean;
298
- /**
299
- * Trigger export, alias: `-e`
300
- */
301
- export: boolean;
302
- }
303
-
304
- /* -------------------------------------------- */
305
- /* CMD CONFIGURATION */
306
- /* -------------------------------------------- */
307
-
308
- /**
309
- * **INTERNAL USE**
310
- *
311
- * Passed command overwrites
312
- */
313
- export interface CommandBundle {
314
- /**
315
- * An input overwrite path was passed
316
- *
317
- * @default null
318
- */
319
- input: string;
320
- /**
321
- * An output overwrite path was passed
322
- *
323
- * @default null
324
- */
325
- output: string;
326
- /**
327
- * A config overwrite path was passed
328
- *
329
- * @default null
330
- */
331
- config: string;
332
- /**
333
- * Filters were passed in the command
334
- *
335
- * @default null
336
- */
337
- filter: string;
338
- /**
339
- * Deletions were passed in the command
340
- *
341
- * @default null
342
- */
343
- delete: string;
344
- }
345
-
346
- /* -------------------------------------------- */
347
- /* CONFIG FILE RESOLUTION */
348
- /* -------------------------------------------- */
349
-
350
- /**
351
- * **INTERNAL USE**
352
- *
353
- * Configuration File
354
- */
355
- export interface ConfigFile {
356
- /**
357
- * The full resolved path to the syncify configuration file
358
- *
359
- * @example
360
- *
361
- * 'Users/Sissel/Sites/Folder/views/dir/syncify.config.ts'
362
- */
363
- path: string;
364
- /**
365
- * The config file name including file extension.
366
- *
367
- * @example
368
- *
369
- * 'syncify.config.ts'
370
- */
371
- base: string;
372
- /**
373
- * The config file relative path location from current _root_ working directory.
374
- * This is typically going to match the `base` value as most config files work
375
- * from workspace root directory unless inferred otherwise.
376
- *
377
- * @example
378
- *
379
- * 'dir/syncify.config.ts'
380
- */
381
- relative: string;
382
- }
383
-
384
- /* -------------------------------------------- */
385
- /* SECTIONS */
386
- /* -------------------------------------------- */
387
-
388
- /**
389
- * **INTERNAL USE**
390
- *
391
- * Sections sub-directory configuration
392
- */
393
- export type SectionBundle = Merge<Config.Views['sections'], {
394
- global: RegExp;
395
- paths?: Tester;
396
- /**
397
- * Base directory name used for matching on directory prefixes
398
- * The base directory name will equate to the last known directory
399
- * before a glob pattern or file reference.
400
- */
401
- baseDir: Set<string>;
402
- }>
403
-
404
- /* -------------------------------------------- */
405
- /* SNIPPETS */
406
- /* -------------------------------------------- */
407
-
408
- /**
409
- * **INTERNAL USE**
410
- *
411
- * Snippets sub-directory configuration
412
- */
413
- export type SnippetBundle = Merge<Config.Views['snippets'], {
414
- global: RegExp;
415
- paths?: Tester;
416
- /**
417
- * Base directory name used for matching on directory prefixes
418
- * The base directory name will equate to the last known directory
419
- * before a glob pattern or file reference.
420
- */
421
- baseDir: Set<string>;
422
- }>
423
-
424
- /* -------------------------------------------- */
425
- /* PATHS */
426
- /* -------------------------------------------- */
427
-
428
- /**
429
- * **INTERNAL USE**
430
- *
431
- * Anymatched paths
432
- */
433
- export type PathsBundle = Merge<Config.Paths<Tester>, {
434
- transforms?: Map<string, 7 | 8 | 9>
435
- }>;
436
-
437
- export type PathsRef = {
438
- /**
439
- * Set of all resolved paths;
440
- */
441
- input: Set<string>;
442
- /**
443
- * Anymatch tester of all resolved paths
444
- */
445
- match: Tester;
446
- };
447
-
448
- export interface PathBundle {
449
- /**
450
- * Resolved match and path references uploaded as assets
451
- *
452
- * @default 'source/assets'
453
- */
454
- assets?: PathsRef
455
- /**
456
- * Resolved match and path references uploaded as snippets
457
- *
458
- * @default 'source/snippets'
459
- */
460
- snippets?: PathsRef
461
- /**
462
- * Resolved match and path references uploaded as sections
463
- *
464
- * @default 'source/sections'
465
- */
466
- sections?: PathsRef
467
- /**
468
- * Resolved match and path references uploaded as layouts
469
- *
470
- * @default 'source/layout'
471
- */
472
- layout?: PathsRef
473
- /**
474
- * Resolved match and path references uploaded as templates
475
- *
476
- * @default 'source/templates'
477
- */
478
- templates?: PathsRef
479
- /**
480
- * Resolved match and path references uploaded as template/metaobject
481
- *
482
- * @default 'source/templates/metaobjects'
483
- */
484
- metaobject?: PathsRef
485
- /**
486
- * Resolved match and path references uploaded as template/customers
487
- *
488
- * @default 'source/templates/customers'
489
- */
490
- customers?: PathsRef
491
- /**
492
- * Resolved match and path references uploaded as configs
493
- *
494
- * @default 'source/config'
495
- */
496
- config?: PathsRef
497
- /**
498
- * Resolved match and path references uploaded as locales
499
- *
500
- * @default 'source/locales'
501
- */
502
- locales?: PathsRef
503
- /**
504
- * The resolved `metafields` directory path
505
- *
506
- * @default 'source/metafields'
507
- */
508
- metafields?: PathsRef
509
- /**
510
- * The resolved `pages` directory path
511
- *
512
- * @default 'source/pages'
513
- */
514
- pages?: PathsRef
515
- /**
516
- * The resolved `redirects` yaml file
517
- *
518
- * @default 'redirects.yaml'
519
- */
520
- redirects?: PathsRef
521
- /**
522
- * Special Transforms reference
523
- *
524
- * @default 'source/assets'
525
- */
526
- transforms?: Map<string, 7 | 8 | 9>
527
- }
528
-
529
- /* -------------------------------------------- */
530
- /* WATCH */
531
- /* -------------------------------------------- */
532
-
533
- /**
534
- * **INTERNAL USE**
535
- *
536
- * Chokidar watch instance
537
- */
538
- export type WatchBundle = Merge<FSWatcher, {
539
- /**
540
- * Private method of chokidar
541
- */
542
- _watched: Map<string, { items: Set<string> }>;
543
- /**
544
- * The chokidar instance will be a `Set` when running in
545
- * non-watch modes. This value is used in the `paths` getter
546
- * to convert entries to an array.
547
- */
548
- values (): IterableIterator<string>;
549
- /**
550
- * Check whether or not a path is being watched
551
- */
552
- has (path: string, dir?: string): boolean;
553
- /**
554
- * Returns all watched paths
555
- */
556
- get paths (): string[]
557
-
558
- }>;
559
-
560
- /* -------------------------------------------- */
561
- /* PROCESSORS */
562
- /* -------------------------------------------- */
563
-
564
- /**
565
- * **INTERNAL USE**
566
- *
567
- * Processor configuration state. This model infers which
568
- * pre-processors are being used and/or available.
569
- */
570
- export interface ProcessorsBundle {
571
- /**
572
- * JSON processing
573
- */
574
- json?: JSONBundle;
575
- /**
576
- * [PostCSS](https://postcss.org/) Pre-Processor
577
- */
578
- postcss?: PostCSSProcesser;
579
- /**
580
- * [SASS Dart](https://sass-lang.com/documentation/js-api/) Pre-Processor
581
- */
582
- sass?: SASSProcesser;
583
- /**
584
- * [TailwindCSS](https://tailwindcss.com/) Pre-Processor
585
- */
586
- tailwind?: TailwindProcessor;
587
- /**
588
- * [Sharp](https://sharp.pixelplumbing.com) Pre-Processor
589
- */
590
- sharp?: any;
591
- /**
592
- * [SVG Sprite](https://github.com/svg-sprite) Pre-Processor
593
- */
594
- sprite?: SVGSpriteProcesser;
595
- /**
596
- * [SVGO](https://github.com/svg/svgo) Pre-Processor
597
- */
598
- svgo?: SVGOProcesser
599
- /**
600
- * [ESBuild](https://esbuild.github.io/) Pre-Processor
601
- */
602
- esbuild?: ESBuildProcesser
603
- }
@@ -1,127 +0,0 @@
1
- import { File } from './file';
2
- import { Transforms, Config } from '../config';
3
- import { WebSocketServer } from 'ws';
4
-
5
- /* -------------------------------------------- */
6
- /* PLUGIN SCOPE */
7
- /* -------------------------------------------- */
8
-
9
- export type PluginScope = {
10
- log: {
11
- info: (...message: string[]) => void;
12
- warn: (...message: string[]) => void;
13
- error: (...message: string[]) => void;
14
- }
15
- }
16
-
17
- /* -------------------------------------------- */
18
- /* PLUGIN HOOKS */
19
- /* -------------------------------------------- */
20
-
21
- export interface PluginHooks {
22
- /**
23
- * The plugin name
24
- */
25
- name: Lowercase<string>;
26
- /**
27
- * A list of file extension the plugin handles
28
- */
29
- extensions?: string[];
30
- /**
31
- * Optionally infer the required transformer
32
- */
33
- transforms?: Array<keyof Transforms>
34
- /**
35
- * Executes at runtime in the final cycle
36
- * and before modes are invoked (like _watch_).
37
- */
38
- onInit?: (this: PluginScope, config: Config) => void;
39
- /**
40
- * Executes before a transform begins when running
41
- * _build_ mode. The function only fires in build mode.
42
- */
43
- onBuild?: (this: PluginScope, file: File) => void;
44
- /**
45
- * Executes before the chokidar watch process
46
- * has began. Allows you add additional files
47
- * to be watched and monitored for changes.
48
- */
49
- onWatch?:(this: PluginScope, wss: WebSocketServer) => void | string[];
50
- /**
51
- * Executes before transform begins and after file
52
- * context has been created.
53
- *
54
- * **NOTE**
55
- *
56
- * _File context might augment during transform._
57
- */
58
- onChange?: (this: PluginScope, file: File) => void;
59
- /**
60
- * Executes before hooks and after transform.
61
- * File content can be transformed and request
62
- * can be re-routed.
63
- */
64
- onTransform?:(this: PluginScope, file: File) => void | {
65
- /**
66
- * Change the Shopify output key
67
- */
68
- key?: Pick<File, 'key'>;
69
- /**
70
- * Sourcemap (optional)
71
- */
72
- map?: Buffer | object | string;
73
- /**
74
- * Return the file content.
75
- */
76
- value: Buffer;
77
- };
78
- /**
79
- * Executes on a HOT reload and before
80
- * the theme preview is updated. You can augment
81
- * the dom before reload.
82
- */
83
- onReload?: (dom: Document) => void | Document
84
-
85
- }
86
-
87
- /* -------------------------------------------- */
88
- /* BUNDLE REFERENCE */
89
- /* -------------------------------------------- */
90
-
91
- export interface Plugins {
92
- /**
93
- * Plugins executing onBuild
94
- */
95
- onBuild: [
96
- pluginName: string,
97
- pluginHook: PluginHooks['onBuild']
98
- ][]
99
- /**
100
- * Plugins executing onWatch
101
- */
102
- onWatch: [
103
- pluginName: string,
104
- pluginHook: PluginHooks['onWatch']
105
- ][]
106
- /**
107
- * Plugins executing onChange
108
- */
109
- onChange: [
110
- pluginName: string,
111
- pluginHook: PluginHooks['onChange']
112
- ][]
113
- /**
114
- * Plugins executing onTransform
115
- */
116
- onTransform: [
117
- pluginName: string,
118
- pluginHook: PluginHooks['onTransform']
119
- ][]
120
- /**
121
- * Plugins executing onReload
122
- */
123
- onReload: [
124
- pluginName: string,
125
- pluginHook: PluginHooks['onReload']
126
- ][]
127
- }