@syncify/cli 0.2.4-beta → 0.3.0-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.
package/types/api.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PartialDeep } from 'type-fest';
2
2
  import { Config } from './config';
3
- import { Asset } from './internal/requests';
4
- import { File } from './internal/file';
3
+ import { Asset } from './bundle/requests';
4
+ import { File } from './bundle/file';
5
5
 
6
6
  type Download = (
7
7
  this: {
@@ -0,0 +1,101 @@
1
+ import { Requests, Resource } from './requests';
2
+
3
+ export interface Cache {
4
+ /**
5
+ * The Syncify version - cache will be purged and reset when changed
6
+ */
7
+ version?: string;
8
+ /**
9
+ * The last time cache was updated at (timestamp)
10
+ */
11
+ updated?: number;
12
+ /**
13
+ * The last time a build was executed
14
+ */
15
+ lastBuild?: number;
16
+ /**
17
+ * The last time a build was executed
18
+ */
19
+ lastResource?: Resource;
20
+ /**
21
+ * Cache Build File
22
+ *
23
+ * @default 'node_modules/.syncify/build.map'
24
+ */
25
+ uri?: string;
26
+ /**
27
+ * Sourcemap directories for transforms
28
+ */
29
+ sourcemaps?: {
30
+ /**
31
+ * JavaScript sourcemaps
32
+ *
33
+ * @default 'node_modules/.syncify/sourcemaps/script/'
34
+ */
35
+ script: string;
36
+ /**
37
+ * Stylesheet sourcemaps
38
+ *
39
+ * @default 'node_modules/.syncify/sourcemaps/script/'
40
+ */
41
+ style: string;
42
+ }
43
+ /**
44
+ * Output > Input Source Path Mapping
45
+ *
46
+ * Holds reverse references between input and output
47
+ * directories. Used when executing `upload` mode.
48
+ *
49
+ * > **NOTE**
50
+ * >
51
+ * > This cache reference will update each time build mode runs.
52
+ */
53
+ maps?: {
54
+ /**
55
+ * The output path pointing to input path
56
+ *
57
+ * `key`
58
+ * - _The output path_
59
+ *
60
+ * `value`
61
+ * - _The input path_
62
+ */
63
+ [outputFileURI: string]: string;
64
+ },
65
+ /**
66
+ * Page related cache records, this reference typically
67
+ * holds `path > id` object references. Page ids are
68
+ * cached for lookup when changes occur.
69
+ */
70
+ pages?: {
71
+ /**
72
+ * The store domain name containing the pages, eg: `syncify` would
73
+ * equate to `syncify.myshopify.com`.
74
+ */
75
+ [myshopifyDomain: string]: {
76
+ /**
77
+ * The page id, as property and the page payload reference as value.
78
+ */
79
+ [pageId: number]: Requests.Page
80
+ }
81
+ },
82
+ /**
83
+ * Metafields related cache records. Metafield source maps
84
+ * are `path > id` object references. Metafield ids are
85
+ * cached for lookup when changes occur. The `map` object
86
+ * holds the references and applied to model on initialization.
87
+ */
88
+ metafields?: {
89
+ /**
90
+ * The store domain name containing the pages, eg: `syncify` would
91
+ * equate to `syncify.myshopify.com`.
92
+ */
93
+ [myshopifyDomain: string]: {
94
+ /**
95
+ * Metafield pathname > id cache references..
96
+ */
97
+ [inputFileUri: string]: Requests.Page
98
+ }
99
+ }
100
+
101
+ }
@@ -114,6 +114,29 @@ export interface HOTBundle {
114
114
  * @default 'hot'
115
115
  */
116
116
  method?: 'hot' | 'refresh';
117
+ /**
118
+ * The HOT strategy to use. Syncify supports 2 different
119
+ * replacement strategies and you will need choose which one
120
+ * to use depending on your project type.
121
+ *
122
+ *
123
+ * **hydrate**
124
+ *
125
+ * _The hydrate strategy will execute morph replacements. This is what Syncify
126
+ * will default to, however it is not always perfect and in cases where you leverage
127
+ * frameworks that use DOM Mutation observers, it probably better to use `replace`_
128
+ *
129
+ * **replace**
130
+ *
131
+ * _The replace strategy will execute fragment swaps use `replaceWith` instead of morphs
132
+ * when executing HOT reloads. It works almost identical to `hydrate` but respects DOM
133
+ * mutations. If you are leveraging a framework like Stimulus or Alpine, then choose this
134
+ * strategy._
135
+ *
136
+ *
137
+ * @default 'hydrate'
138
+ */
139
+ strategy?: 'hydrate' | 'replace';
117
140
  /**
118
141
  * Scroll position between reloads
119
142
  *
@@ -131,7 +154,7 @@ export interface HOTBundle {
131
154
  * The hot reload inline snippet script URI location
132
155
  *
133
156
  * @default
134
- * 'node_modules/@syncify/syncify/hot.js.liquid'
157
+ * 'node_modules/@syncify/cli/hot.js.liquid'
135
158
  */
136
159
  snippet?: string;
137
160
  /**
@@ -155,6 +178,7 @@ export type HOTConfig = Pick<HOTBundle,
155
178
  | 'label'
156
179
  | 'layouts'
157
180
  | 'method'
181
+ | 'strategy'
158
182
  | 'server'
159
183
  | 'socket'
160
184
  | 'scroll'
@@ -3,10 +3,9 @@
3
3
  import type { Tester } from 'anymatch';
4
4
  import type { Config as TailwindProcessor } from 'tailwindcss';
5
5
  import type { Merge } from 'type-fest';
6
- import type { Markdown } from './markdown';
7
6
  import type { AxiosRequestConfig } from 'axios';
8
- import type { ESBuildProcesser, ScriptBundle } from '../transforms/script';
9
- import type { SASSProcesser, PostCSSProcesser, StyleBundle } from '../transforms/style';
7
+ import type { ESBuildProcesser } from '../transforms/script';
8
+ import type { SASSProcesser, PostCSSProcesser } from '../transforms/style';
10
9
  import type { SVGOProcesser, SVGSpriteProcesser } from '../transforms/svg';
11
10
  import type { JSONBundle } from '../transforms/json';
12
11
  import type { FSWatcher } from 'chokidar';
@@ -394,6 +393,12 @@ export interface ConfigFile {
394
393
  export type SectionBundle = Merge<Config.Views['sections'], {
395
394
  global: RegExp;
396
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>;
397
402
  }>
398
403
 
399
404
  /* -------------------------------------------- */
@@ -408,6 +413,12 @@ export type SectionBundle = Merge<Config.Views['sections'], {
408
413
  export type SnippetBundle = Merge<Config.Views['snippets'], {
409
414
  global: RegExp;
410
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>;
411
422
  }>
412
423
 
413
424
  /* -------------------------------------------- */
@@ -423,19 +434,97 @@ export type PathsBundle = Merge<Config.Paths<Tester>, {
423
434
  transforms?: Map<string, 7 | 8 | 9>
424
435
  }>;
425
436
 
426
- /* -------------------------------------------- */
427
- /* PAGES */
428
- /* -------------------------------------------- */
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
+ };
429
447
 
430
- /**
431
- * **INTERNAL USE**
432
- *
433
- * Page configuration
434
- */
435
- export type PagesBundle = Merge<Config.Views['pages'], {
436
- import: Markdown.Import;
437
- export: Markdown.Export
438
- }>
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
+ }
439
528
 
440
529
  /* -------------------------------------------- */
441
530
  /* WATCH */
@@ -465,6 +554,7 @@ export type WatchBundle = Merge<FSWatcher, {
465
554
  * Returns all watched paths
466
555
  */
467
556
  get paths (): string[]
557
+
468
558
  }>;
469
559
 
470
560
  /* -------------------------------------------- */
@@ -481,33 +571,33 @@ export interface ProcessorsBundle {
481
571
  /**
482
572
  * JSON processing
483
573
  */
484
- json: JSONBundle;
574
+ json?: JSONBundle;
485
575
  /**
486
576
  * [PostCSS](https://postcss.org/) Pre-Processor
487
577
  */
488
- postcss: PostCSSProcesser;
578
+ postcss?: PostCSSProcesser;
489
579
  /**
490
580
  * [SASS Dart](https://sass-lang.com/documentation/js-api/) Pre-Processor
491
581
  */
492
- sass: SASSProcesser;
582
+ sass?: SASSProcesser;
493
583
  /**
494
584
  * [TailwindCSS](https://tailwindcss.com/) Pre-Processor
495
585
  */
496
- tailwind: TailwindProcessor;
586
+ tailwind?: TailwindProcessor;
497
587
  /**
498
588
  * [Sharp](https://sharp.pixelplumbing.com) Pre-Processor
499
589
  */
500
- sharp: any;
590
+ sharp?: any;
501
591
  /**
502
592
  * [SVG Sprite](https://github.com/svg-sprite) Pre-Processor
503
593
  */
504
- sprite: SVGSpriteProcesser;
594
+ sprite?: SVGSpriteProcesser;
505
595
  /**
506
596
  * [SVGO](https://github.com/svg/svgo) Pre-Processor
507
597
  */
508
- svgo: SVGOProcesser
598
+ svgo?: SVGOProcesser
509
599
  /**
510
600
  * [ESBuild](https://esbuild.github.io/) Pre-Processor
511
601
  */
512
- esbuild: ESBuildProcesser
602
+ esbuild?: ESBuildProcesser
513
603
  }
@@ -1,5 +1,28 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { File, FileKeys } from './file';
3
+ import { LiteralUnion } from 'type-fest';
4
+
5
+ /**
6
+ * Metafield Types
7
+ */
8
+ export type MetafieldTypes = LiteralUnion<(
9
+ | 'boolean'
10
+ | 'color'
11
+ | 'date'
12
+ | 'date_time'
13
+ | 'dimension'
14
+ | 'json'
15
+ | 'money'
16
+ | 'multi_line_text_field'
17
+ | 'number_decimal'
18
+ | 'number_integer'
19
+ | 'rating'
20
+ | 'rich_text_field'
21
+ | 'single_line_text_field'
22
+ | 'url'
23
+ | 'volume'
24
+ | 'weight'
25
+ ), string>
3
26
 
4
27
  /**
5
28
  * Axios Request Methods
@@ -33,6 +56,7 @@ export type ChokidorEvents = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir
33
56
  export type GetAsset = (
34
57
  `templates/${string}${'.liquid' | '.json'}` |
35
58
  `templates/customer/${string}${'.liquid' | '.json'}` |
59
+ `templates/metaobject/${string}${'.liquid' | '.json'}` |
36
60
  `assets/${string}` |
37
61
  `sections/${string}${'-group.json' | '.liquid'}` |
38
62
  `snippets/${string}${'.liquid'}` |
@@ -137,6 +161,30 @@ export interface Asset {
137
161
  theme_id?: number;
138
162
  }
139
163
 
164
+ export interface PageMetafield {
165
+ /**
166
+ * An identifier for the metafield. (maximum: 30 characters)
167
+ */
168
+ key: string;
169
+ /**
170
+ * The information to be stored as metadata.
171
+ */
172
+ type: MetafieldTypes;
173
+ /**
174
+ * The information to be stored as metadata.
175
+ */
176
+ value: string;
177
+ /**
178
+ * A container for a set of metadata. Namespaces help distinguish
179
+ * between metadata created by different apps. (maximum: 20 characters)
180
+ */
181
+ namespace:string;
182
+ /**
183
+ * Additional information about the metafield.
184
+ */
185
+ description?: string;
186
+ }
187
+
140
188
  export namespace Requests {
141
189
 
142
190
  /**
@@ -168,23 +216,61 @@ export namespace Requests {
168
216
  /* -------------------------------------------- */
169
217
 
170
218
  export interface Page {
219
+ /**
220
+ * The name of the person who created the page.
221
+ */
171
222
  author?: string;
223
+ /**
224
+ * The text content of the page, complete with HTML markup.
225
+ */
172
226
  body_html?: string;
173
- created_at?: string;
227
+ /**
228
+ * The date and time (ISO 8601 format) when the page was created.
229
+ */
230
+ readonly created_at?: string;
231
+ /**
232
+ * A unique, human-friendly string for the page,
233
+ * generated automatically from its title. In themes, the Liquid templating language refers to a page by its handle.
234
+ */
174
235
  handle?: string;
236
+ /**
237
+ * The unique numeric identifier for the page.
238
+ */
175
239
  id?: number;
176
- metafield?: {
177
- key: string;
178
- type: string;
179
- value: string;
180
- namespace:string;
181
- },
240
+ /**
241
+ * Additional information attached to the Page object.
242
+ */
243
+ metafields?: PageMetafield | PageMetafield[];
244
+ /**
245
+ * The date and time (ISO 8601 format) when the page was published.
246
+ * Returns null when the page is hidden.
247
+ */
182
248
  published_at?:string;
249
+ /**
250
+ * Published boolean
251
+ */
252
+ published?: boolean;
253
+ /**
254
+ * The ID of the shop to which the page belongs.
255
+ */
183
256
  shop_id?: number
257
+ /**
258
+ * The suffix of the template that is used to render the page.
259
+ * If the value is an empty string or null, then the default page template is used.
260
+ */
184
261
  template_suffix?: string;
262
+ /**
263
+ * The title of the page.
264
+ */
185
265
  title?: string;
266
+ /**
267
+ * The date and time (ISO 8601 format) when the page was last updated.
268
+ */
186
269
  updated_at?: string;
187
-
270
+ /**
271
+ * The GraphQL GID of the page.
272
+ */
273
+ readonly admin_graphql_api_id?: string
188
274
  }
189
275
  /* -------------------------------------------- */
190
276
  /* METAFIELDS */
@@ -213,7 +299,7 @@ export namespace Requests {
213
299
  /**
214
300
  * Type is JSON
215
301
  */
216
- type?: 'json';
302
+ type?: MetafieldTypes;
217
303
  /**
218
304
  * Value Type (this is legacy but we assert it anyway)
219
305
  */
@@ -96,7 +96,7 @@ export namespace ENV {
96
96
  export type RCSecrets = RCSecret[]
97
97
 
98
98
  /**
99
- * Auth using `token` in `.syncifyrc` file
99
+ * Auth using `token` in `.env.syncify.json` file
100
100
  *
101
101
  * > _Single store_
102
102
  */
package/types/cli.d.ts CHANGED
@@ -190,6 +190,12 @@ export interface Commands {
190
190
  * ```
191
191
  */
192
192
  export?: boolean;
193
+ /**
194
+ * Triggers a resource mode
195
+ *
196
+ * @default ''
197
+ */
198
+ resource?: string;
193
199
  /**
194
200
  * Download a theme from a store. Will be place in `import` driectory. Requires a store
195
201
  * target and theme target to be passed.
@@ -1,11 +1,12 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
 
3
- import type { Pages, Sections, Snippets } from './views';
4
- import type { HOTConfig } from '../internal/hot';
5
- import type { ScriptTerse, JSONTerse, ViewTerse } from './terser';
6
- import type { PluginHooks } from '../internal/plugin';
3
+ import type { Sections, Snippets } from './views';
4
+ import type { HOTConfig } from '../bundle/hot';
5
+ import type { ScriptTerse, JSONTerse, MarkupTerse, LiquidTerse } from './terser';
6
+ import type { PluginHooks } from '../bundle/plugin';
7
7
  import type { JSONConfig } from '../transforms/json';
8
8
  import type { SharpConfig } from '../transforms/image';
9
+ import type { PagesConfig } from '../transforms/pages';
9
10
  import type { ScriptTransformer, ESBuildConfig } from '../transforms/script';
10
11
  import type { StyleTransformer, SASSConfig, PostCSSConfig } from '../transforms/style';
11
12
  import type { SVGTransformer, SVGOConfig, SVGSpriteConfig } from '../transforms/svg';
@@ -69,7 +70,7 @@ export interface Views {
69
70
  /**
70
71
  * Static page handling
71
72
  */
72
- pages?: Pages;
73
+ pages?: PagesConfig;
73
74
  /**
74
75
  * Snippet file handling (ie: sub-directory grouping)
75
76
  */
@@ -245,7 +246,17 @@ export interface Terser {
245
246
  * of options are exposed in order to prevent invalid or broken
246
247
  * output from being generated.
247
248
  */
248
- views?: boolean | ViewTerse;
249
+ liquid?: boolean | LiquidTerse;
250
+ /**
251
+ * View minification options. You can disable all views from
252
+ * being minified by passing a boolean `false`.
253
+ *
254
+ * Syncify uses HTML Minifier Terser under the hood, it has been
255
+ * configured to work with Liquid files so only a limited number
256
+ * of options are exposed in order to prevent invalid or broken
257
+ * output from being generated.
258
+ */
259
+ markup?: boolean | MarkupTerse;
249
260
  /**
250
261
  * JavaScript minification options. Script minification is only
251
262
  * available for projects with `esbuild` installed and configured
@@ -301,7 +312,7 @@ export interface Stores {
301
312
  * structure. The `key` values represent target names that
302
313
  * will be used in the CLI.
303
314
  */
304
- themes: { [target: string]: number; }
315
+ themes: { [target: string]: number }
305
316
  }
306
317
 
307
318
  /* -------------------------------------------- */
@@ -340,19 +351,11 @@ export interface Directories {
340
351
  */
341
352
  config?: string;
342
353
  /**
343
- * The resolved `pages` directory path, if multiple paths
344
- * are defined the value will be an array list.
354
+ * The resolved `cache` directory path for build tool files
345
355
  *
346
- * @default '/source/pages/'
356
+ * @default 'node_modules/.syncify/'
347
357
  */
348
- pages?: string;
349
- /**
350
- * The resolved `metafields` directory path, if multiple paths
351
- * are defined the value will be an array list.
352
- *
353
- * @default '/source/metafields/'
354
- */
355
- metafields?: string | string[]
358
+ cache?: string;
356
359
  }
357
360
 
358
361
  /* -------------------------------------------- */
@@ -390,6 +393,12 @@ export interface Paths<T = string | string[]> {
390
393
  * @default 'source/templates'
391
394
  */
392
395
  templates?: T
396
+ /**
397
+ * An array list of files to be uploaded as metaobject templates
398
+ *
399
+ * @default 'source/templates/metaobject'
400
+ */
401
+ metaobject?: T
393
402
  /**
394
403
  * An array list of files to be uploaded as template/customers
395
404
  *
@@ -409,6 +418,12 @@ export interface Paths<T = string | string[]> {
409
418
  */
410
419
  locales?: T
411
420
  /**
421
+ * **NOT YET AVAILABLE**
422
+ *
423
+ * > **This option will be available in later versions**
424
+ *
425
+ * ---
426
+ *
412
427
  * The resolved `metafields` directory path
413
428
  *
414
429
  * @default 'source/metafields'
@@ -421,7 +436,11 @@ export interface Paths<T = string | string[]> {
421
436
  */
422
437
  pages?: T
423
438
  /**
424
- * The resolved `redirects` yaml file
439
+ * **NOT YET AVAILABLE**
440
+ *
441
+ * > **This option will be available in later versions**
442
+ *
443
+ * ---
425
444
  *
426
445
  * @default 'redirects.yaml'
427
446
  */
@@ -435,11 +454,11 @@ export interface Paths<T = string | string[]> {
435
454
  /**
436
455
  * The Configuration model
437
456
  */
438
- export interface Config extends Directories {
457
+ export interface Config<T = Stores> extends Directories {
439
458
  /**
440
459
  * Define your Shopify store/s and thier theme/s
441
460
  */
442
- stores: Stores | Stores[];
461
+ stores: T | Stores | Stores[];
443
462
  /**
444
463
  * Define customize input structures - Paths resolve to `input`
445
464
  */
@@ -524,7 +543,8 @@ export interface Config extends Directories {
524
543
  terser?: boolean | Terser;
525
544
  /**
526
545
  * @deprecated
527
- * Use `terser` option instead
546
+ *
547
+ * Use `terser` option instead
528
548
  */
529
549
  minify?: undefined;
530
550
  }