@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,42 @@
1
+ import type { Tester } from 'anymatch';
2
+ import type { Merge } from 'type-fest';
3
+
4
+ export interface JSONConfig {
5
+ /**
6
+ * The indentation level
7
+ *
8
+ * @default 2
9
+ */
10
+ indent?: number;
11
+ /**
12
+ * Whether to use `\t` identation characters.
13
+ *
14
+ * @default false
15
+ */
16
+ useTab?: boolean;
17
+ /**
18
+ * If line termination should be Windows (CRLF) format.
19
+ * Unix (LF) format is the default.
20
+ *
21
+ * @default false
22
+ */
23
+ crlf?: boolean;
24
+ /**
25
+ * An optional string list of paths/filenames to exclude
26
+ * from processing, ie: pass through
27
+ *
28
+ * @default false
29
+ */
30
+ exclude?: string[]
31
+ }
32
+
33
+ /* -------------------------------------------- */
34
+ /* INTERAL USE */
35
+ /* -------------------------------------------- */
36
+
37
+ /**
38
+ * **INTERNAL USE**
39
+ *
40
+ * Bundling Configuration
41
+ */
42
+ export type JSONBundle = Merge<JSONConfig, { exclude: Tester }>;
@@ -0,0 +1,174 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import type { Merge } from 'type-fest';
3
+ import type { Tester } from 'anymatch';
4
+ import type { Tsconfig } from 'tsconfig-type';
5
+ import type { BuildOptions as ESBuildOptions } from 'esbuild';
6
+ import type { GetProcessorConfigs, RenamePaths } from '../misc/shared';
7
+
8
+ export type ESBuildConfig = Merge<Pick<ESBuildOptions,
9
+ | 'bundle'
10
+ | 'treeShaking'
11
+ | 'tsconfig'
12
+ | 'target'
13
+ | 'splitting'
14
+ | 'pure'
15
+ | 'define'
16
+ | 'format'
17
+ | 'banner'
18
+ | 'footer'
19
+ | 'charset'
20
+ | 'chunkNames'
21
+ | 'drop'
22
+ | 'ignoreAnnotations'
23
+ | 'jsx'
24
+ | 'jsxDev'
25
+ | 'jsxFactory'
26
+ | 'jsxFragment'
27
+ | 'jsxImportSource'
28
+ | 'mainFields'
29
+ | 'metafile'
30
+ | 'resolveExtensions'
31
+ | 'supported'
32
+ | 'plugins'
33
+ >, {
34
+ /**
35
+ * The format to be generated. Because we are targeting
36
+ * browser environments, Syncify does not allow for CJS (commonjs)
37
+ * bundles to be produced.
38
+ *
39
+ * @default 'esm'
40
+ */
41
+ format?: 'esm' | 'iife';
42
+ /**
43
+ * Whether or not sourcemaps should be generated.
44
+ * Syncify will process sourcemap generation internally,
45
+ * so this option only accepts a boolean value.
46
+ *
47
+ * @default true
48
+ */
49
+ sourcemap?: boolean;
50
+ }
51
+ >;
52
+
53
+ /* -------------------------------------------- */
54
+ /* TRANSFORM */
55
+ /* -------------------------------------------- */
56
+
57
+ export interface ScriptTransform {
58
+ /**
59
+ * JS/TS input source paths. Accepts `string` or `string[]` glob patterns.
60
+ * Resolution is relative to your defined `input` directory.
61
+ *
62
+ * @default undefined
63
+ */
64
+ input: string | string[];
65
+ /**
66
+ * The format to be generated. Because we are targeting
67
+ * browser environments, Syncify does not allow for CJS (commonjs)
68
+ * bundles to be produced.
69
+ *
70
+ * @default 'esm'
71
+ */
72
+ format?: 'esm' | 'iife';
73
+ /**
74
+ * Rename the stylesheet file/s. The same name as source file will be used
75
+ * when undefined. Accepts namespaces, `[file]`, `[dir]` and `[ext]`.
76
+ *
77
+ * ---
78
+ *
79
+ * @default undefined
80
+ */
81
+ rename?: string;
82
+ /**
83
+ * Optionally write the javascript file inline as a snippet. This will transform
84
+ * the JS and contained code will be output within `<script></script>` tags output as a
85
+ * `snippet.liquid` file.
86
+ *
87
+ * @default false
88
+ */
89
+ snippet?: boolean;
90
+ /**
91
+ * Entry points (paths/files) to watch that will trigger a rebuilds of
92
+ * the define _input_ file. By default, Syncify will watch all import entries
93
+ * imported by the _input_.
94
+ *
95
+ * @default []
96
+ */
97
+ watch?: string[];
98
+ /**
99
+ * [ESBuild](https://esbuild.github.io/) Override
100
+ *
101
+ * ESBuild file transforms will use the options provided to `processor.esbuild`
102
+ * but you can optionally override those defaults on a per-transform
103
+ * basis. Any configuration options defined here will be merged with
104
+ * the options defined in `processor.esbuild`.
105
+ *
106
+ * You can also skip pre-processing with esbuild by passing a _boolean_
107
+ * `false` which will inform Syncify to process scripts with ESBuild.
108
+ *
109
+ * @default true // if esbuild is not installed this is false
110
+ */
111
+ esbuild?: boolean | ESBuildConfig;
112
+ }
113
+
114
+ /* -------------------------------------------- */
115
+ /* TRANSFORMER */
116
+ /* -------------------------------------------- */
117
+
118
+ export type ScriptTransformer = (
119
+ | string
120
+ | string[]
121
+ | ScriptTransform
122
+ | ScriptTransform[]
123
+ | {
124
+ [K in RenamePaths]: (
125
+ | string
126
+ | string[]
127
+ | Pick<ScriptTransform,
128
+ | 'input'
129
+ | 'format'
130
+ | 'snippet'
131
+ | 'watch'
132
+ | 'esbuild'
133
+ >
134
+ )
135
+ }
136
+ )
137
+
138
+ /* -------------------------------------------- */
139
+ /* INTERAL USE */
140
+ /* -------------------------------------------- */
141
+
142
+ /**
143
+ * **INTERNAL USE**
144
+ *
145
+ * Processor Configuration
146
+ */
147
+ export type ESBuildProcesser = Merge<
148
+ GetProcessorConfigs<ESBuildOptions>,
149
+ {
150
+ get tsconfig(): Tsconfig,
151
+ }
152
+ >
153
+
154
+ /**
155
+ * **INTERNAL USE**
156
+ *
157
+ * Bundling Configuration
158
+ */
159
+ export type ScriptBundle = Merge<ScriptTransform, {
160
+ /**
161
+ * A UUID reference for this bundle.
162
+ */
163
+ uuid: string;
164
+ /**
165
+ * Resolved input path
166
+ */
167
+ input: string;
168
+ /**
169
+ * All entry points (imports) contained in the input.
170
+ * Matches applied to the anymatch pattern and applied
171
+ * at runtime.
172
+ */
173
+ watch: Tester;
174
+ }>;
@@ -0,0 +1,178 @@
1
+ /* eslint-disable no-unused-vars */
2
+
3
+ import type { Merge } from 'type-fest';
4
+ import type { Tester } from 'anymatch';
5
+ import type { Plugin as PostCSSPlugin, Transformer, TransformCallback } from 'postcss';
6
+ import type { GetProcessorConfigs, RenamePaths } from '../misc/shared';
7
+
8
+ /* -------------------------------------------- */
9
+ /* PROCESSOR CONFIGS */
10
+ /* -------------------------------------------- */
11
+
12
+ export type PostCSSConfig = (
13
+ | PostCSSPlugin
14
+ | Transformer
15
+ | TransformCallback
16
+ );
17
+
18
+ export interface SASSConfig {
19
+ /**
20
+ * Whether or not to generate sourcemaps
21
+ *
22
+ * @default true
23
+ */
24
+ sourcemap?: boolean;
25
+ /**
26
+ * The style compiled CSS should be output.
27
+ *
28
+ * @default 'compressed'
29
+ */
30
+ style?: 'expanded' | 'compressed';
31
+ /**
32
+ * Whether or not to print warnings to CLI - Warnings will require
33
+ * an `stdin` invocation to view. Setting this to `false` will hide
34
+ * warnings all together.
35
+ *
36
+ * @default true
37
+ */
38
+ warnings?: boolean;
39
+ /**
40
+ * A list of paths to include, ie: node_modules.
41
+ *
42
+ * @default ['node_modules']
43
+ */
44
+ include?: string[];
45
+ }
46
+
47
+ /* -------------------------------------------- */
48
+ /* TRANSFORM */
49
+ /* -------------------------------------------- */
50
+
51
+ export interface StyleTransform {
52
+ /**
53
+ * SVG input source paths. Accepts `string` or `string[]` glob patterns.
54
+ * Resolution is relative to your defined `input` directory.
55
+ *
56
+ * @default undefined
57
+ */
58
+ input: string | string[];
59
+ /**
60
+ * Glob stylesheet paths/files to watch. When changes
61
+ * are applied to matched files, then the defined `input`
62
+ * will be compiled.
63
+ *
64
+ * @default []
65
+ */
66
+ watch?: string[];
67
+ /**
68
+ * Rename the stylesheet file/s. The same name as source file will be used
69
+ * when undefined. Accepts namespaces, `[file]`, `[dir]` and `[ext]`.
70
+ *
71
+ * ---
72
+ *
73
+ * @default undefined
74
+ */
75
+ rename?: string;
76
+ /**
77
+ * Optionally output the CSS as a snippet. This will transform
78
+ * the stylesheet inline, wrap output within `<style></style>`
79
+ * tags and write it to `snippets`.
80
+ *
81
+ * @default false
82
+ */
83
+ snippet?: boolean;
84
+ /**
85
+ * [PostCSS](https://postcss.org/) Override
86
+ *
87
+ * CSS File transforms will use the options provided to `processor.postcss`
88
+ * but you can optionally override those defaults on a per-transform
89
+ * basis. Any configuration options defined here will be merged with
90
+ * the options defined in `processor.postcss`.
91
+ *
92
+ * You can also skip pre-processing with postcss by passing a _boolean_
93
+ * `false` which will inform Syncify to not pass output to PostCSS. By
94
+ * default, Syncify will pass all compiled SASS and files with `.css`
95
+ * extensions to PostCSS.
96
+ *
97
+ * @default true // if postcss is not installed this is false
98
+ */
99
+ postcss?: boolean | PostCSSConfig[]
100
+ /**
101
+ * [SASS Dart](https://sass-lang.com/documentation/js-api/) Override
102
+ *
103
+ * SASS File transforms will use the options provided to `processor.sass`
104
+ * but you can optionally override those defaults on a per-transform
105
+ * basis. Any configuration options defined here will be merged with
106
+ * the options defined in `processor.sass`.
107
+ *
108
+ * You can also skip pre-processing with postcss by passing a _boolean_
109
+ * `false` which will inform Syncify to not pass output to PostCSS. By
110
+ * default, Syncify will forward all input files using `.scss` or `.sass`
111
+ * or extension to SASS Dart.
112
+ *
113
+ * @default true // if sass is not installed this is false
114
+ */
115
+ sass?: boolean | SASSConfig;
116
+ }
117
+
118
+ /* -------------------------------------------- */
119
+ /* TRANSFORMER */
120
+ /* -------------------------------------------- */
121
+
122
+ export type StyleTransformer = (
123
+ | string
124
+ | string[]
125
+ | StyleTransform
126
+ | StyleTransform[]
127
+ | {
128
+ [K in RenamePaths]: (
129
+ | string
130
+ | string[]
131
+ | Pick<StyleTransform,
132
+ | 'postcss'
133
+ | 'sass'
134
+ | 'snippet'
135
+ | 'watch'
136
+ | 'input'
137
+ >
138
+ )
139
+ }
140
+ )
141
+
142
+ /* -------------------------------------------- */
143
+ /* INTERNAL USE */
144
+ /* -------------------------------------------- */
145
+
146
+ /**
147
+ * **INTERNAL USE**
148
+ *
149
+ * Processor Configuration
150
+ */
151
+ export type PostCSSProcesser = GetProcessorConfigs<PostCSSConfig[]>
152
+
153
+ /**
154
+ * **INTERNAL USE**
155
+ *
156
+ * Processor Configuration
157
+ */
158
+ export type SASSProcesser = GetProcessorConfigs<SASSConfig>
159
+
160
+ /**
161
+ * **INTERNAL USE**
162
+ *
163
+ * Bundling Configuration
164
+ */
165
+ export type StyleBundle = Merge<StyleTransform, {
166
+ /**
167
+ * A UUID reference for this bundle.
168
+ */
169
+ uuid: string;
170
+ /**
171
+ * Resolved input path
172
+ */
173
+ input: string;
174
+ /**
175
+ * Anymatch function
176
+ */
177
+ watch: Tester;
178
+ }>;
@@ -0,0 +1,189 @@
1
+ /* eslint-disable no-unused-vars */
2
+
3
+ import type { LiteralUnion, Merge } from 'type-fest';
4
+ import type { Tester } from 'anymatch';
5
+ import type { Config as SVGOConfig } from 'svgo';
6
+ import type { Config as SVGSpriteConfig } from 'svg-sprite';
7
+ import type { GetProcessorConfigs, RenamePaths } from '../misc/shared';
8
+
9
+ /* -------------------------------------------- */
10
+ /* PROCESSOR CONFIGS */
11
+ /* -------------------------------------------- */
12
+
13
+ export { SVGOConfig, SVGSpriteConfig };
14
+
15
+ /* -------------------------------------------- */
16
+ /* SHARED */
17
+ /* -------------------------------------------- */
18
+
19
+ interface SVGShared<T extends 'file' | 'sprite'> {
20
+ /**
21
+ * SVG input source paths. Accepts `string` or `string[]` glob patterns.
22
+ * Resolution is relative to your defined `input` directory.
23
+ *
24
+ * @default ''
25
+ */
26
+ input: string | string[];
27
+ /**
28
+ * Rename the svg file/s. The same name as source file will be used
29
+ * when undefined. Accepts namespaces, `[file]`, `[dir]` and `[ext]`.
30
+ * ---
31
+ *
32
+ * @default undefined
33
+ *
34
+ * @example
35
+ * 'source/svgs/arrow.svg' > 'arrow.svg' // if snippet is false
36
+ * 'source/svgs/checkmark.svg' > 'checkmark.liquid' // if snippet is true
37
+ */
38
+ rename?: string;
39
+ /**
40
+ * Whether to generate svg as snippet or asset. When `true` the
41
+ * svg source will be written as a snippet
42
+ *
43
+ * @default false
44
+ */
45
+ snippet?: boolean;
46
+ /**
47
+ * The SVG export format. Syncify can produce 2 different SVG formats:
48
+ *
49
+ * You can omit this option when you have only 1 pre-processor installed or
50
+ * if you are applying a per-transfrom configuration override as it will default
51
+ * to the format which the inferred pre-processor produces. If you are using
52
+ * both the supported processors ([SVGO](https://github.com/svg/svgo) &
53
+ * [SVG Sprite](https://github.com/svg-sprite)) then you will need
54
+ * to inform Syncify on which format it should produce.
55
+ *
56
+ * ---
57
+ *
58
+ * **File Format**
59
+ *
60
+ * _SVG transforms using a `file` format require SVGO to be installed. File
61
+ * formats will produce individual `.svg` files from that can be output as
62
+ * an`asset` or inlined into a `snippet`_
63
+ *
64
+ * ---
65
+ *
66
+ * **Sprite Format**
67
+ *
68
+ * _SVG transforms using a `sprite` format require SVG Sprite to be installed.
69
+ * Sprite formats will produce an SVG Sprite that can be output as an `asset`
70
+ * or inlined into a `snippet`_
71
+ *
72
+ * ---
73
+ *
74
+ * @default
75
+ * undefined // When no SVG pre-processor is installed
76
+ * null // When both SVGO and SVG Sprite are installed (required)
77
+ * 'file' // When SVGO is the only processor installed
78
+ * 'sprite' // When SVG Sprite is the only processor installed
79
+ */
80
+ format?: LiteralUnion<T, string>;
81
+ }
82
+
83
+ export interface SVGFile extends SVGShared<'file'> {
84
+ /**
85
+ * [SVGO](https://github.com/svg/svgo) Override
86
+ *
87
+ * SVG File transforms will use the options provided to `processor.svgo`
88
+ * but you can optionally override those defaults on a per-transform
89
+ * basis. Any configuration options defined here will be merged with
90
+ * the options defined in `processor.svgo`.
91
+ *
92
+ * @default
93
+ * processor.svgo // When processor configuration is defined
94
+ */
95
+ svgo?: SVGOConfig
96
+ }
97
+
98
+ export interface SVGSprite extends SVGShared<'sprite'> {
99
+ /**
100
+ * [SVG Sprite](https://github.com/svg-sprite) Override
101
+ *
102
+ * SVG Sprite transforms will use the options provided to `processor.sprite`
103
+ * but you can optionally override those defaults on a per-transform
104
+ * basis. Any configuration options defined here will be merged with
105
+ * the options defined in `processor.sprite`.
106
+ *
107
+ * @default
108
+ * processor.sprite // When processor configuration is defined
109
+ */
110
+ sprite?: SVGSpriteConfig
111
+ }
112
+
113
+ /* -------------------------------------------- */
114
+ /* TRANSFORM */
115
+ /* -------------------------------------------- */
116
+
117
+ /**
118
+ * SVG processing transforms
119
+ */
120
+ export type SVGTransform = (
121
+ | SVGFile
122
+ | SVGSprite
123
+ )
124
+
125
+ /* -------------------------------------------- */
126
+ /* TRANSFORMER */
127
+ /* -------------------------------------------- */
128
+
129
+ export type SVGTransformer = (
130
+ | string
131
+ | string[]
132
+ | SVGTransform
133
+ | SVGTransform[]
134
+ | {
135
+ [K in RenamePaths]: (
136
+ | string
137
+ | string[]
138
+ | Pick<SVGFile, 'format' | 'input' | 'snippet' | 'svgo'>
139
+ | Pick<SVGSprite, 'format'| 'input'| 'snippet' | 'sprite'>
140
+ )
141
+ }
142
+ )
143
+
144
+ /* -------------------------------------------- */
145
+ /* INTERAL USE */
146
+ /* -------------------------------------------- */
147
+
148
+ /**
149
+ * **INTERNAL USE**
150
+ *
151
+ * Processor Configuration
152
+ */
153
+ export type SVGOProcesser = GetProcessorConfigs<SVGOConfig>
154
+
155
+ /**
156
+ * **INTERNAL USE**
157
+ *
158
+ * Processor Configuration
159
+ */
160
+ export type SVGSpriteProcesser = GetProcessorConfigs<SVGSpriteConfig>
161
+
162
+ /**
163
+ * **INTERNAL USE**
164
+ *
165
+ * Bundling Configuration
166
+ */
167
+ export type SVGBundle = Merge<SVGTransform, {
168
+ /**
169
+ * A UUID reference for this bundle.
170
+ */
171
+ uuid: string;
172
+ /**
173
+ * Resolved input paths (paths are expanded)
174
+ */
175
+ input: Set<string>;
176
+ /**
177
+ * File matching, used to determine when new files are
178
+ * added to an `input` defined path/directory.
179
+ */
180
+ match: Tester;
181
+ /**
182
+ * SVGO Override
183
+ */
184
+ svgo?: true | SVGOConfig;
185
+ /**
186
+ * SVG Sprite Override
187
+ */
188
+ sprite?: true | SVGSpriteConfig;
189
+ }>;