@syncify/cli 0.1.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.
@@ -0,0 +1,101 @@
1
+ export type ErrorTypes = (
2
+ | 'request'
3
+ | 'syntax'
4
+ | 'transform'
5
+ | 'esbuild'
6
+ | 'sass'
7
+ | 'postcss'
8
+ | 'minify'
9
+ | 'json'
10
+ | 'liquid'
11
+ | 'shopify'
12
+ | 'sharp'
13
+ | 'svgo'
14
+ | 'sprite'
15
+ | 'resolve'
16
+ )
17
+
18
+ export interface RequestError {
19
+ /**
20
+ * An error code number - Typically used in request errors
21
+ *
22
+ * @default false
23
+ */
24
+ code?: number;
25
+ /**
26
+ * The error message to be printed
27
+ */
28
+ message: string;
29
+ /**
30
+ *
31
+ */
32
+ detail?: string;
33
+ /**
34
+ *
35
+ */
36
+ info?: string[];
37
+ /**
38
+ * The stack trace
39
+ */
40
+ stack?: string;
41
+ /**
42
+ * Additional notes or suggestions
43
+ */
44
+ notes?: string;
45
+ }
46
+
47
+ export interface Error {
48
+ /**
49
+ * The error type - This can one of many issues
50
+ */
51
+ type: ErrorTypes
52
+ /**
53
+ * An error code number - Typically used in request errors
54
+ *
55
+ * @default false
56
+ */
57
+ code?: number;
58
+ /**
59
+ * The error message to be printed
60
+ */
61
+ message: string | string[];
62
+ /**
63
+ *
64
+ */
65
+ data?: { details: string[]; line?: number }[]
66
+ /**
67
+ * Error details, typically used in request failures
68
+ */
69
+ details?: string | string[];
70
+ /**
71
+ * Whether or not to throw
72
+ *
73
+ * @default false
74
+ */
75
+ throw?: boolean;
76
+ /**
77
+ * The stack trace
78
+ */
79
+ stack?: string;
80
+ /**
81
+ * Additional notes or suggestions
82
+ */
83
+ notes?: string | string[];
84
+ /**
85
+ * The line number and column (if any)
86
+ */
87
+ location?: {
88
+ /**
89
+ * Line number
90
+ */
91
+ line: number;
92
+ /**
93
+ * Column number (ie: character)
94
+ */
95
+ column?: number;
96
+ /**
97
+ * Code sample indicating where the error occurs
98
+ */
99
+ sample?: string
100
+ }
101
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * **Markdown > HTML**
3
+ *
4
+ * Syncify uses [markdown-it](https://github.com/markdown-it/markdown-it) when
5
+ * converting markdown to HTML (export).
6
+ *
7
+ * **HTML > Markdown**
8
+ *
9
+ * Syncify uses [Turndown](https://github.com/mixmark-io/turndown) when
10
+ * converting HTML to HTML (import).
11
+ */
12
+ export namespace Markdown {
13
+ /**
14
+ * Syncify uses [markdown-it](https://github.com/markdown-it/markdown-it) under
15
+ * the hood for transforming markdown pages into HTML. The options provided here
16
+ * will be passed onto markdown-it.
17
+ */
18
+ export interface Export {
19
+ /**
20
+ * Enable HTML tags in source, defaults to `true`
21
+ */
22
+ html: boolean;
23
+ /**
24
+ * // Use `/` to close single tags (<br />), defaults to `false`.
25
+ * This is only for full CommonMark compatibility.
26
+ */
27
+ xhtmlOut: boolean;
28
+ /**
29
+ * Convert '\n' in paragraphs into `<br>`, defaults to `true`
30
+ */
31
+ breaks: boolean;
32
+ /**
33
+ * CSS language prefix for fenced blocks. Can be useful for external
34
+ * highlighters, defaults to `language-`
35
+ */
36
+ langPrefix: string;
37
+ /**
38
+ * Autoconvert URL-like text to links, defaults to `false`
39
+ */
40
+ linkify: boolean;
41
+
42
+ /**
43
+ * Enable some language-neutral replacement + quotes beautification (defaults to `false`)
44
+ * For the full list of replacements, see;
45
+ * https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js
46
+ */
47
+ typographer: boolean;
48
+ /**
49
+ * Double + single quotes replacement pairs, when typographer enabled,
50
+ * and smartquotes on. Could be either a String or an Array.
51
+ * For example, you can use '«»„“' for Russian, '„“‚‘' for German,
52
+ * and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
53
+ */
54
+ quotes: string;
55
+ }
56
+
57
+ /**
58
+ * Syncify uses [Turndown](https://github.com/mixmark-io/turndown) under
59
+ * the hood to convert pages imported from stores into Markdown. The
60
+ * `language` option **MUST** be set to `markdown`.
61
+ */
62
+ export interface Import {
63
+ /**
64
+ * Heading style for conversion. This defaults to `atx`.
65
+ */
66
+ headingStyle?: 'setext' | 'atx';
67
+ /**
68
+ * Horizontal Rules, defaults to `***`
69
+ */
70
+ hr?: '***' | '---' | '___';
71
+ /**
72
+ * Bullet list markers, defaults to `-`
73
+ */
74
+ bulletListMarker?: '-' | '+' | '*'
75
+ /**
76
+ * Code blocks, defaults to `fenced`
77
+ */
78
+ codeBlockStyle?: 'indented' | 'fenced';
79
+ /**
80
+ * EM Delimiter (ie: Italic), defaults to `_`
81
+ */
82
+ emDelimiter?: '_' | '*';
83
+ /**
84
+ * Code block fence style, defaults to ```
85
+ */
86
+ fence?: '```' | '~~~' | undefined;
87
+ /**
88
+ * Strong Delimiter (ie: bold), defaults to `**`
89
+ */
90
+ strongDelimiter?: '__' | '**' | undefined;
91
+ /**
92
+ * Link style, defaults to `inlined`
93
+ *
94
+ * _Don't fuck around with this and leave it as `inlined`_
95
+ */
96
+ linkStyle?: 'inlined' | 'referenced' | undefined;
97
+ /**
98
+ * Link style reference, defaults to `full`
99
+ *
100
+ * _Don't fuck around with this and leave it as `full`_
101
+ */
102
+ linkReferenceStyle?: 'full' | 'collapsed' | 'shortcut' | undefined;
103
+ }
104
+ }
@@ -0,0 +1,72 @@
1
+ import { File } from 'types/bundle';
2
+
3
+ export interface BuildModeReport {
4
+ /**
5
+ * The file name that was build (including extension)
6
+ *
7
+ * @example
8
+ * 'index.liquid'
9
+ */
10
+ name: string;
11
+ /**
12
+ * The processing time it took to build
13
+ *
14
+ * @example
15
+ * '1ms'
16
+ */
17
+ time: string;
18
+ /**
19
+ * The output directory the file written.
20
+ *
21
+ * @example
22
+ * 'templates' // if file is something like index.json
23
+ */
24
+ output: string;
25
+ /**
26
+ * A readable error string inferring any issues which may have occured.
27
+ *
28
+ * @example
29
+ * 'skipped file'
30
+ * @default
31
+ * null
32
+ */
33
+ error: string;
34
+ /**
35
+ * Output size stack
36
+ *
37
+ * _Undefined if `error` exists._
38
+ */
39
+ size?: {
40
+ /**
41
+ * Before transformation, returns ansi string
42
+ */
43
+ before: string;
44
+ /**
45
+ * After transformation, returns ansi string
46
+ */
47
+ after: string;
48
+ /**
49
+ * The saving amount, returns ansi string
50
+ */
51
+ saved: string;
52
+ /**
53
+ * The gzipped size, returns ansi string
54
+ */
55
+ gzip: string;
56
+ }
57
+ }
58
+
59
+ export interface BuildReport {
60
+ /**
61
+ * List of files in the transform group
62
+ */
63
+ files: File[]
64
+ /**
65
+ * The amount of time the transform group took to process.
66
+ */
67
+ time: string;
68
+ /**
69
+ * The build report of each file transform
70
+ */
71
+ report: BuildModeReport[]
72
+ }
@@ -0,0 +1,287 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { File, FileKeys } from '../bundle/file';
3
+
4
+ /**
5
+ * Axios Request Methods
6
+ */
7
+ export type Methods = 'get' | 'post' | 'put' | 'delete'
8
+
9
+ /**
10
+ * Client Request
11
+ */
12
+ export type Client = (method: Methods, file: File, content?: string) => Promise<void>
13
+
14
+ /**
15
+ * Client Request as parameter
16
+ */
17
+ export type ClientParam<T> = (method: Methods, file: File<T>, content?: string) => Promise<void>
18
+
19
+ /**
20
+ * Resources
21
+ */
22
+ export type Resource = 'build' | 'watch' | 'upload' |'download'
23
+
24
+ /**
25
+ * Chokidor Event Names
26
+ */
27
+ export type ChokidorEvents = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'
28
+
29
+ /**
30
+ * Shopify theme asset paths, we use this to when re-pathing
31
+ * custom directories.
32
+ */
33
+ export type GetAsset = (
34
+ `templates/${string}${'.liquid' | '.json'}` |
35
+ `templates/customer/${string}${'.liquid' | '.json'}` |
36
+ `assets/${string}` |
37
+ `sections/${string}${'.liquid'}` |
38
+ `snippets/${string}${'.liquid'}` |
39
+ `layout/${string}${'.liquid'}` |
40
+ `locales/${string}${'.json'}` |
41
+ `config/settings_${'data' | 'schema'}${'.json'}`
42
+ )
43
+
44
+ /* -------------------------------------------- */
45
+ /* ASSETS */
46
+ /* -------------------------------------------- */
47
+
48
+ /**
49
+ * Return response for Shopify theme assets
50
+ */
51
+ export interface AssetResource {
52
+ /**
53
+ * The asset path
54
+ */
55
+ key: string;
56
+ /**
57
+ * The public-facing URL of the asset.
58
+ */
59
+ public_url: string;
60
+ /**
61
+ * The date and time (ISO 8601 format) when the
62
+ * asset was created.
63
+ */
64
+ created_at: string;
65
+ /**
66
+ * The date and time (ISO 8601 format) when an
67
+ * asset was last updated.
68
+ */
69
+ updated_at: string;
70
+ /**
71
+ * The MIME representation of the content, consisting
72
+ * of the type and subtype of the asset.
73
+ */
74
+ content_type: string;
75
+ /**
76
+ * The asset size in bytes.
77
+ */
78
+ size: number;
79
+ /**
80
+ * The MD5 representation of the content, consisting
81
+ * of a string of 32 hexadecimal digits. May be null
82
+ * if an asset has not been updated recently.
83
+ */
84
+ checksum: string;
85
+ /**
86
+ * The ID for the theme that an asset belongs to.
87
+ */
88
+ theme_id: number;
89
+ /**
90
+ * The text content of the asset, such as the HTML
91
+ * and Liquid markup of a template file.
92
+ */
93
+ value?: string;
94
+ }
95
+
96
+ export interface Asset {
97
+ /**
98
+ * The asset path
99
+ */
100
+ key?: string;
101
+ /**
102
+ * Base64 Encoded File
103
+ */
104
+ attachment?: string;
105
+ /**
106
+ * Value file string
107
+ */
108
+ value?: string;
109
+ /**
110
+ * The date and time (ISO 8601 format) when the
111
+ * asset was created.
112
+ */
113
+ created_at?: string;
114
+ /**
115
+ * The date and time (ISO 8601 format) when an
116
+ * asset was last updated.
117
+ */
118
+ updated_at?: string;
119
+ /**
120
+ * The MIME representation of the content, consisting
121
+ * of the type and subtype of the asset.
122
+ */
123
+ content_type?: string;
124
+ /**
125
+ * The asset size in bytes.
126
+ */
127
+ size?: number;
128
+ /**
129
+ * The MD5 representation of the content, consisting of a
130
+ * string of 32 hexadecimal digits. May be null if an asset
131
+ * has not been updated recently.
132
+ */
133
+ checksum?: string;
134
+ /**
135
+ * The ID for the theme that an asset belongs to.
136
+ */
137
+ theme_id?: number;
138
+ }
139
+
140
+ export namespace Requests {
141
+
142
+ /**
143
+ * Return response for Shopify theme asset resources
144
+ */
145
+ export interface Assets {
146
+ /**
147
+ * The assets resource
148
+ */
149
+ assets: AssetResource[]
150
+ }
151
+
152
+ /**
153
+ * The request body for Shopify theme assets
154
+ */
155
+ export interface Asset {
156
+ /**
157
+ * The theme asset
158
+ */
159
+ asset: {
160
+ key: FileKeys,
161
+ value: string
162
+ }
163
+ }
164
+
165
+ /* -------------------------------------------- */
166
+ /* PAGES */
167
+ /* -------------------------------------------- */
168
+
169
+ export interface Page {
170
+ author?: string;
171
+ body_html?: string;
172
+ created_at?: string;
173
+ handle?: string;
174
+ id?: number;
175
+ metafield?: {
176
+ key: string;
177
+ type: string;
178
+ value: string;
179
+ namespace:string;
180
+ },
181
+ published_at?:string;
182
+ shop_id?: number
183
+ template_suffix?: string;
184
+ title?: string;
185
+ updated_at?: string;
186
+
187
+ }
188
+ /* -------------------------------------------- */
189
+ /* METAFIELDS */
190
+ /* -------------------------------------------- */
191
+
192
+ /**
193
+ * The request body for Shopify metafields
194
+ */
195
+ export interface Metafield {
196
+ /**
197
+ * The metafield ID
198
+ */
199
+ id?: number;
200
+ /**
201
+ * The parent directory name
202
+ */
203
+ namespace?: string;
204
+ /**
205
+ * The JSON file name with extension
206
+ */
207
+ key?: string;
208
+ /**
209
+ * The stringified JSON value
210
+ */
211
+ value?: string;
212
+ /**
213
+ * Type is JSON
214
+ */
215
+ type?: 'json';
216
+ /**
217
+ * Value Type (this is legacy but we assert it anyway)
218
+ */
219
+ value_type?: 'json_string';
220
+ /**
221
+ * Last updated date
222
+ */
223
+ updated_at?: string;
224
+ }
225
+
226
+ /* -------------------------------------------- */
227
+ /* REDIRECTS */
228
+ /* -------------------------------------------- */
229
+
230
+ export interface Redirect {
231
+ /**
232
+ * Redirect ID
233
+ */
234
+ id?: number;
235
+ /**
236
+ * The redirect from path
237
+ */
238
+ path?: string;
239
+ /**
240
+ * The redirect to path
241
+ */
242
+ target?: string;
243
+ }
244
+
245
+ export interface File {
246
+ /**
247
+ * File ID
248
+ */
249
+ id?: number;
250
+ /**
251
+ * The filename
252
+ */
253
+ filename?: string;
254
+ /**
255
+ * The mimeType of the file
256
+ */
257
+ mimeType?: string;
258
+ /**
259
+ * The file content type.
260
+ */
261
+ contentType?: string;
262
+ /**
263
+ * An external URL or a signed upload URL of the file object.
264
+ */
265
+ originalSource?: string;
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Extended request options passed to axios when
271
+ * uploading, downloading or interfacing with the Shopify
272
+ * API themes, metafields or other endpoints.
273
+ */
274
+ export interface Request extends AxiosRequestConfig {
275
+ url?: string;
276
+ method?: Methods;
277
+ responseType?: 'json',
278
+ data?: (
279
+ Requests.Asset |
280
+ { metafield?: Requests.Metafield } |
281
+ { redirect?: Requests.Redirect }
282
+ )
283
+ params?: {
284
+ 'asset[key]'?: string;
285
+ fields?: string
286
+ }
287
+ }
@@ -0,0 +1,128 @@
1
+ import { Config } from '../config';
2
+
3
+ export type Namespacing = (
4
+ | '[dir]'
5
+ | '[file]'
6
+ | '[ext]'
7
+ )
8
+
9
+ /**
10
+ * Namespaced Paths
11
+ */
12
+ export type NamespacePaths = `${'assets' | 'snippets'}/${Namespacing}${string}${Namespacing}`
13
+
14
+ /**
15
+ * Directory Paths
16
+ */
17
+ export type DirPaths = `${'assets' | 'snippets'}/${string}`
18
+
19
+ /**
20
+ * Rename Paths
21
+ */
22
+ export type RenamePaths = NamespacePaths | DirPaths
23
+
24
+ /**
25
+ * Rename input type
26
+ */
27
+ export type RenameInput = {
28
+ [filename: string]: string | string[]
29
+ }
30
+
31
+ /**
32
+ * Rename input paths type
33
+ */
34
+ export type RenameInputPaths = {
35
+ [filename: RenamePaths]: string | string[]
36
+ }
37
+
38
+ /**
39
+ * Rename config type
40
+ */
41
+ export type RenameConfig<T> = {
42
+ [filename: RenamePaths]: string | string[] | T
43
+ }
44
+
45
+ /**
46
+ * Processor Configuration
47
+ */
48
+ export type GetProcessorConfigs<T> = {
49
+ /**
50
+ * Whether or not the processor is installed
51
+ */
52
+ installed: boolean;
53
+ /**
54
+ * Whether or not the module was loaded, ie: imported.
55
+ * This will be `false` until the the import was loaded.
56
+ */
57
+ loaded: boolean;
58
+ /**
59
+ * Whether or not a config file exists for the processor,
60
+ * When one exists the URI path location to the file will
61
+ * applied as the value.
62
+ */
63
+ file: false | string;
64
+ /**
65
+ * Configuration of the processor, Initialized with defaults
66
+ */
67
+ config: T;
68
+ }
69
+
70
+ /**
71
+ * Picked `package.json` fields
72
+ */
73
+ export interface Package {
74
+ version?: string;
75
+ syncify?: Config;
76
+ dependencies?: { [module: string]: string; };
77
+ devDependencies?: { [module: string]: string };
78
+ peerDependencies?: { [module: string]: string };
79
+ optionalDependencies?: { [module: string]: string };
80
+ }
81
+
82
+ export namespace ENV {
83
+
84
+ /**
85
+ * Auth using `key` and `secret` in `.syncifyrc` file
86
+ *
87
+ * > _Single store_
88
+ */
89
+ export interface RCSecret {
90
+ domain: string,
91
+ key: string,
92
+ secret: string
93
+ }
94
+
95
+ /**
96
+ * Auth using `key` and `secret` in `.syncifyrc` File
97
+ *
98
+ * > _Array of stores_
99
+ */
100
+ export type RCSecrets = RCSecret[]
101
+
102
+ /**
103
+ * Auth using `token` in `.syncifyrc` file
104
+ *
105
+ * > _Single store_
106
+ */
107
+ export interface RCToken {
108
+ domain: string,
109
+ token: string
110
+ }
111
+
112
+ /**
113
+ * Auth using `token` in `.syncifyrc` file
114
+ *
115
+ * > _Array of stores_
116
+ */
117
+ export type RCTokens = RCToken[]
118
+
119
+ /**
120
+ * Using a `.syncifyrc` file for authorizations
121
+ */
122
+ export type RCFile =
123
+ | RCSecret
124
+ | RCSecret[]
125
+ | RCToken
126
+ | RCToken[]
127
+
128
+ }
@@ -0,0 +1,15 @@
1
+ import type { SharpOptions as SharpConfig } from 'sharp';
2
+ import type { GetProcessorConfigs } from '../misc/shared';
3
+
4
+ export type { SharpConfig };
5
+
6
+ /* -------------------------------------------- */
7
+ /* INTERNAL USE */
8
+ /* -------------------------------------------- */
9
+
10
+ /**
11
+ * **INTERNAL USE**
12
+ *
13
+ * Processor Configuration
14
+ */
15
+ export type SharpProcesser = GetProcessorConfigs<SharpConfig>