@junobuild/config 0.0.1-next-2024-02-17
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/LICENSE +21 -0
- package/README.md +222 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/index.js +1 -0
- package/dist/node/index.mjs +4 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/types/encoding.d.ts +1 -0
- package/dist/types/types/juno.config.d.ts +11 -0
- package/dist/types/types/juno.env.d.ts +4 -0
- package/dist/types/types/satellite.config.d.ts +72 -0
- package/dist/types/types/storage.config.d.ts +76 -0
- package/dist/types/types/utility.d.ts +6 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 David Dal Busco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
[![npm][npm-badge]][npm-badge-url]
|
|
2
|
+
[![license][npm-license]][npm-license-url]
|
|
3
|
+
|
|
4
|
+
[npm-badge]: https://img.shields.io/npm/v/@junobuild/config
|
|
5
|
+
[npm-badge-url]: https://www.npmjs.com/package/@junobuild/config
|
|
6
|
+
[npm-license]: https://img.shields.io/npm/l/@junobuild/config
|
|
7
|
+
[npm-license-url]: https://github.com/junobuild/juno-js/blob/main/LICENSE
|
|
8
|
+
|
|
9
|
+
# Juno Config
|
|
10
|
+
|
|
11
|
+
Configuration options for [Juno] CLI.
|
|
12
|
+
|
|
13
|
+
<!-- TSDOC_START -->
|
|
14
|
+
|
|
15
|
+
### :tropical_drink: Interfaces
|
|
16
|
+
|
|
17
|
+
- [JunoConfigEnv](#gear-junoconfigenv)
|
|
18
|
+
- [StorageConfigHeader](#gear-storageconfigheader)
|
|
19
|
+
- [StorageConfigRewrite](#gear-storageconfigrewrite)
|
|
20
|
+
- [StorageConfigRedirect](#gear-storageconfigredirect)
|
|
21
|
+
- [StorageConfig](#gear-storageconfig)
|
|
22
|
+
- [SatelliteAssertions](#gear-satelliteassertions)
|
|
23
|
+
- [SatelliteId](#gear-satelliteid)
|
|
24
|
+
- [SatelliteIds](#gear-satelliteids)
|
|
25
|
+
- [OrbiterConfig](#gear-orbiterconfig)
|
|
26
|
+
- [JunoConfig](#gear-junoconfig)
|
|
27
|
+
|
|
28
|
+
#### :gear: JunoConfigEnv
|
|
29
|
+
|
|
30
|
+
| Property | Type | Description |
|
|
31
|
+
| -------- | -------- | ----------- |
|
|
32
|
+
| `mode` | `string` | |
|
|
33
|
+
|
|
34
|
+
#### :gear: StorageConfigHeader
|
|
35
|
+
|
|
36
|
+
Headers allow the client and the satellite to pass additional information along with a request or a response. Some sets of headers can affect how the browser handles the page and its content.
|
|
37
|
+
|
|
38
|
+
| Property | Type | Description |
|
|
39
|
+
| --------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| `source` | `string` | The glob pattern used to match files within the storage that these headers will apply to. |
|
|
41
|
+
| `headers` | `[string, string][]` | An array of key-value pairs representing the headers to apply. Each pair includes the header name and its value.Example: `[["Cache-Control", "max-age=3600"], ["X-Custom-Header", "value"]]` |
|
|
42
|
+
|
|
43
|
+
#### :gear: StorageConfigRewrite
|
|
44
|
+
|
|
45
|
+
You can utilize optional rewrites to display the same content for multiple URLs. Rewrites are especially useful when combined with pattern matching, allowing acceptance of any URL that matches the pattern.
|
|
46
|
+
|
|
47
|
+
| Property | Type | Description |
|
|
48
|
+
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| `source` | `string` | The glob pattern or specific path to match for incoming requests. Matches are rewritten to the specified destination. |
|
|
50
|
+
| `destination` | `string` | The destination path or file to which matching requests should be rewritten. |
|
|
51
|
+
|
|
52
|
+
#### :gear: StorageConfigRedirect
|
|
53
|
+
|
|
54
|
+
Use a URL redirect to prevent broken links if you've moved a page or to shorten URLs.
|
|
55
|
+
|
|
56
|
+
| Property | Type | Description |
|
|
57
|
+
| ---------- | ------------ | ------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `source` | `string` | The glob pattern or specific path to match for incoming requests that should be redirected. |
|
|
59
|
+
| `location` | `string` | The URL or path to which the request should be redirected. |
|
|
60
|
+
| `code` | `301 or 302` | The HTTP status code to use for the redirect, typically 301 (permanent redirect) or 302 (temporary redirect). |
|
|
61
|
+
|
|
62
|
+
#### :gear: StorageConfig
|
|
63
|
+
|
|
64
|
+
Configures the Hosting behavior of the Storage.
|
|
65
|
+
|
|
66
|
+
| Property | Type | Description |
|
|
67
|
+
| ----------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `headers` | `StorageConfigHeader[]` | Optional array of `StorageConfigHeader` objects to define custom HTTP headers for specific files or patterns. |
|
|
69
|
+
| `rewrites` | `StorageConfigRewrite[]` | Optional array of `StorageConfigRewrite` objects to define rewrite rules. |
|
|
70
|
+
| `redirects` | `StorageConfigRedirect[]` | Optional array of `StorageConfigRedirect` objects to define HTTP redirects. |
|
|
71
|
+
| `iframe` | `"deny" or "same-origin" or "allow-any"` | For security reasons and to prevent click-jacking attacks, dapps deployed with Juno are, by default, set to deny embedding in other sites.Options are:- `deny`: Prevents any content from being displayed in an iframe.- `same-origin`: Allows iframe content from the same origin as the page.- `allow-any`: Allows iframe content from any origin.If not specified, then `deny` is used as default value. |
|
|
72
|
+
|
|
73
|
+
#### :gear: SatelliteAssertions
|
|
74
|
+
|
|
75
|
+
| Property | Type | Description |
|
|
76
|
+
| ------------ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `heapMemory` | `number or boolean` | Configuration for the heap memory size check, which can be:- `true` to enable the check with a default threshold of 900MB,- `false` to disable the heap memory size check,- A `number` to specify a custom threshold in MB (megabytes) for the heap memory size check.If not specified, then `true` is used as default value. |
|
|
78
|
+
|
|
79
|
+
#### :gear: SatelliteId
|
|
80
|
+
|
|
81
|
+
| Property | Type | Description |
|
|
82
|
+
| ------------- | -------- | ----------------------------------------------------------------- |
|
|
83
|
+
| `satelliteId` | `string` | The unique identifier (ID) of the satellite for this application. |
|
|
84
|
+
|
|
85
|
+
#### :gear: SatelliteIds
|
|
86
|
+
|
|
87
|
+
| Property | Type | Description |
|
|
88
|
+
| --------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| `satellitesIds` | `Record<string, string>` | A mapping of satellite identifiers (IDs) to different configurations based on the mode of the application.This allows the application to use different satellite IDs, such as production, staging, etc.Example:{ "production": "xo2hm-lqaaa-aaaal-ab3oa-cai", "staging": "gl6nx-5maaa-aaaaa-qaaqq-cai"} |
|
|
90
|
+
|
|
91
|
+
#### :gear: OrbiterConfig
|
|
92
|
+
|
|
93
|
+
| Property | Type | Description |
|
|
94
|
+
| ----------- | -------- | ----------------------------------------------- |
|
|
95
|
+
| `orbiterId` | `string` | The identifier of the orbiter used in the dApp. |
|
|
96
|
+
|
|
97
|
+
#### :gear: JunoConfig
|
|
98
|
+
|
|
99
|
+
| Property | Type | Description |
|
|
100
|
+
| ----------- | ----------------- | ----------- |
|
|
101
|
+
| `satellite` | `SatelliteConfig` | |
|
|
102
|
+
| `orbiter` | `OrbiterConfig` | |
|
|
103
|
+
|
|
104
|
+
### :cocktail: Types
|
|
105
|
+
|
|
106
|
+
- [ENCODING_TYPE](#gear-encoding_type)
|
|
107
|
+
- [JunoConfigMode](#gear-junoconfigmode)
|
|
108
|
+
- [StorageConfigSourceGlob](#gear-storageconfigsourceglob)
|
|
109
|
+
- [Only](#gear-only)
|
|
110
|
+
- [Either](#gear-either)
|
|
111
|
+
- [SatelliteConfig](#gear-satelliteconfig)
|
|
112
|
+
|
|
113
|
+
#### :gear: ENCODING_TYPE
|
|
114
|
+
|
|
115
|
+
| Type | Type |
|
|
116
|
+
| --------------- | --------------------------------------------------------- |
|
|
117
|
+
| `ENCODING_TYPE` | `'identity' or 'gzip' or 'compress' or 'deflate' or 'br'` |
|
|
118
|
+
|
|
119
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/encoding.ts#L1)
|
|
120
|
+
|
|
121
|
+
#### :gear: JunoConfigMode
|
|
122
|
+
|
|
123
|
+
| Type | Type |
|
|
124
|
+
| ---------------- | ----------------------------------------- |
|
|
125
|
+
| `JunoConfigMode` | `'production' or 'development' or string` |
|
|
126
|
+
|
|
127
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/juno.env.ts#L1)
|
|
128
|
+
|
|
129
|
+
#### :gear: StorageConfigSourceGlob
|
|
130
|
+
|
|
131
|
+
Represents a glob pattern for matching files in the storage configuration.
|
|
132
|
+
|
|
133
|
+
| Type | Type |
|
|
134
|
+
| ------------------------- | ---- |
|
|
135
|
+
| `StorageConfigSourceGlob` | |
|
|
136
|
+
|
|
137
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/storage.config.ts#L4)
|
|
138
|
+
|
|
139
|
+
#### :gear: Only
|
|
140
|
+
|
|
141
|
+
| Type | Type |
|
|
142
|
+
| ------ | ---- |
|
|
143
|
+
| `Only` | `{ |
|
|
144
|
+
|
|
145
|
+
[P in keyof T]: T[P];
|
|
146
|
+
} and {
|
|
147
|
+
[P in keyof U]?: never;
|
|
148
|
+
}` |
|
|
149
|
+
|
|
150
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/utility.ts#L2)
|
|
151
|
+
|
|
152
|
+
#### :gear: Either
|
|
153
|
+
|
|
154
|
+
| Type | Type |
|
|
155
|
+
| -------- | -------------------------- |
|
|
156
|
+
| `Either` | `Only<T, U> or Only<U, T>` |
|
|
157
|
+
|
|
158
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/utility.ts#L8)
|
|
159
|
+
|
|
160
|
+
#### :gear: SatelliteConfig
|
|
161
|
+
|
|
162
|
+
| Type | Type |
|
|
163
|
+
| ----------------- | ---------------------------------------- |
|
|
164
|
+
| `SatelliteConfig` | `Either<SatelliteId, SatelliteIds> and { |
|
|
165
|
+
|
|
166
|
+
/\*\*
|
|
167
|
+
|
|
168
|
+
- Specifies the directory from which to deploy to storage.
|
|
169
|
+
- For instance, if `npm run build` outputs files to a `dist` folder, use `source: 'dist'`.
|
|
170
|
+
-
|
|
171
|
+
- @default `build`
|
|
172
|
+
\*/
|
|
173
|
+
source?: string;
|
|
174
|
+
|
|
175
|
+
/\*\*
|
|
176
|
+
|
|
177
|
+
- Optional configuration parameters for the satellite, affecting the operational behavior of its Storage.
|
|
178
|
+
- Changes to these parameters must be applied manually afterwards using `juno config` commands.
|
|
179
|
+
\*/
|
|
180
|
+
storage?: StorageConfig;
|
|
181
|
+
|
|
182
|
+
/\*\*
|
|
183
|
+
|
|
184
|
+
- Specifies files or patterns to ignore during deployment, using glob patterns similar to those in .gitignore.
|
|
185
|
+
\*/
|
|
186
|
+
ignore?: string[];
|
|
187
|
+
|
|
188
|
+
/\*\*
|
|
189
|
+
|
|
190
|
+
- Controls the Gzip compression optimization for files in the source folder. By default, it targets JavaScript (js), ES Module (mjs), and CSS (css) files.
|
|
191
|
+
- You can disable this by setting it to `false` or customize it with a different file matching pattern using glob syntax.
|
|
192
|
+
\*/
|
|
193
|
+
gzip?: string or false;
|
|
194
|
+
|
|
195
|
+
/\*\*
|
|
196
|
+
|
|
197
|
+
- Customizes file encoding mapping for HTTP response headers `Content-Encoding` based on file extension:
|
|
198
|
+
- - `.Z` for compress,
|
|
199
|
+
- - `.gz` for gzip,
|
|
200
|
+
- - `.br` for brotli,
|
|
201
|
+
- - `.zlib` for deflate,
|
|
202
|
+
- - anything else defaults to `identity`.
|
|
203
|
+
- The "encoding" attribute allows overriding default mappings with an array of glob patterns and encoding types.
|
|
204
|
+
\*/
|
|
205
|
+
encoding?: Array<[string, ENCODING_TYPE]>;
|
|
206
|
+
|
|
207
|
+
/\*\*
|
|
208
|
+
|
|
209
|
+
- Optional configurations to override default assertions made by the CLI regarding satellite deployment conditions.
|
|
210
|
+
\*/
|
|
211
|
+
assertions?: SatelliteAssertions;
|
|
212
|
+
}` |
|
|
213
|
+
|
|
214
|
+
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/config/src/types/satellite.config.ts#L40)
|
|
215
|
+
|
|
216
|
+
<!-- TSDOC_END -->
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT © [David Dal Busco](mailto:david.dalbusco@outlook.com)
|
|
221
|
+
|
|
222
|
+
[juno]: https://juno.build
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export type * from './types/encoding';\nexport type * from './types/juno.config';\nexport type * from './types/juno.env';\nexport type * from './types/satellite.config';\nexport type * from './types/storage.config';\nexport type * from './types/utility';\n\n/// Export and expose functions for user configuration\n\nimport type {JunoConfig} from './types/juno.config';\nimport type {JunoConfigEnv} from './types/juno.env';\n\nexport type JunoConfigFn = (config: JunoConfigEnv) => JunoConfig;\n\nexport type JunoConfigFnOrObject = JunoConfig | JunoConfigFn;\n\nexport function defineConfig(config: JunoConfig): JunoConfig;\nexport function defineConfig(config: JunoConfigFn): JunoConfigFn;\nexport function defineConfig(config: JunoConfigFnOrObject): JunoConfigFnOrObject;\nexport function defineConfig(config: JunoConfigFnOrObject): JunoConfigFnOrObject {\n return config;\n}\n"],
|
|
5
|
+
"mappings": "AAmBO,SAASA,EAAaC,EAAoD,CAC/E,OAAOA,CACT",
|
|
6
|
+
"names": ["defineConfig", "config"]
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './browser/index.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export type * from './types/encoding';\nexport type * from './types/juno.config';\nexport type * from './types/juno.env';\nexport type * from './types/satellite.config';\nexport type * from './types/storage.config';\nexport type * from './types/utility';\n\n/// Export and expose functions for user configuration\n\nimport type {JunoConfig} from './types/juno.config';\nimport type {JunoConfigEnv} from './types/juno.env';\n\nexport type JunoConfigFn = (config: JunoConfigEnv) => JunoConfig;\n\nexport type JunoConfigFnOrObject = JunoConfig | JunoConfigFn;\n\nexport function defineConfig(config: JunoConfig): JunoConfig;\nexport function defineConfig(config: JunoConfigFn): JunoConfigFn;\nexport function defineConfig(config: JunoConfigFnOrObject): JunoConfigFnOrObject;\nexport function defineConfig(config: JunoConfigFnOrObject): JunoConfigFnOrObject {\n return config;\n}\n"],
|
|
5
|
+
"mappings": ";;AAmBO,SAASA,EAAaC,EAAoD,CAC/E,OAAOA,CACT",
|
|
6
|
+
"names": ["defineConfig", "config"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type * from './types/encoding';
|
|
2
|
+
export type * from './types/juno.config';
|
|
3
|
+
export type * from './types/juno.env';
|
|
4
|
+
export type * from './types/satellite.config';
|
|
5
|
+
export type * from './types/storage.config';
|
|
6
|
+
export type * from './types/utility';
|
|
7
|
+
import type { JunoConfig } from './types/juno.config';
|
|
8
|
+
import type { JunoConfigEnv } from './types/juno.env';
|
|
9
|
+
export type JunoConfigFn = (config: JunoConfigEnv) => JunoConfig;
|
|
10
|
+
export type JunoConfigFnOrObject = JunoConfig | JunoConfigFn;
|
|
11
|
+
export declare function defineConfig(config: JunoConfig): JunoConfig;
|
|
12
|
+
export declare function defineConfig(config: JunoConfigFn): JunoConfigFn;
|
|
13
|
+
export declare function defineConfig(config: JunoConfigFnOrObject): JunoConfigFnOrObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ENCODING_TYPE = 'identity' | 'gzip' | 'compress' | 'deflate' | 'br';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SatelliteConfig } from './satellite.config';
|
|
2
|
+
export interface OrbiterConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The identifier of the orbiter used in the dApp.
|
|
5
|
+
*/
|
|
6
|
+
orbiterId: string;
|
|
7
|
+
}
|
|
8
|
+
export interface JunoConfig {
|
|
9
|
+
satellite: SatelliteConfig;
|
|
10
|
+
orbiter?: OrbiterConfig;
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ENCODING_TYPE } from './encoding';
|
|
2
|
+
import type { JunoConfigMode } from './juno.env';
|
|
3
|
+
import type { StorageConfig } from './storage.config';
|
|
4
|
+
import type { Either } from './utility';
|
|
5
|
+
export interface SatelliteAssertions {
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the heap memory size check, which can be:
|
|
8
|
+
* - `true` to enable the check with a default threshold of 900MB,
|
|
9
|
+
* - `false` to disable the heap memory size check,
|
|
10
|
+
* - A `number` to specify a custom threshold in MB (megabytes) for the heap memory size check.
|
|
11
|
+
*
|
|
12
|
+
* If not specified, then `true` is used as default value.
|
|
13
|
+
*/
|
|
14
|
+
heapMemory?: number | boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SatelliteId {
|
|
17
|
+
/**
|
|
18
|
+
* The unique identifier (ID) of the satellite for this application.
|
|
19
|
+
*/
|
|
20
|
+
satelliteId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SatelliteIds {
|
|
23
|
+
/**
|
|
24
|
+
* A mapping of satellite identifiers (IDs) to different configurations based on the mode of the application.
|
|
25
|
+
*
|
|
26
|
+
* This allows the application to use different satellite IDs, such as production, staging, etc.
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* {
|
|
30
|
+
* "production": "xo2hm-lqaaa-aaaal-ab3oa-cai",
|
|
31
|
+
* "staging": "gl6nx-5maaa-aaaaa-qaaqq-cai"
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
satellitesIds: Record<JunoConfigMode, string>;
|
|
35
|
+
}
|
|
36
|
+
export type SatelliteConfig = Either<SatelliteId, SatelliteIds> & {
|
|
37
|
+
/**
|
|
38
|
+
* Specifies the directory from which to deploy to storage.
|
|
39
|
+
* For instance, if `npm run build` outputs files to a `dist` folder, use `source: 'dist'`.
|
|
40
|
+
*
|
|
41
|
+
* @default `build`
|
|
42
|
+
*/
|
|
43
|
+
source?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional configuration parameters for the satellite, affecting the operational behavior of its Storage.
|
|
46
|
+
* Changes to these parameters must be applied manually afterwards using `juno config` commands.
|
|
47
|
+
*/
|
|
48
|
+
storage?: StorageConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Specifies files or patterns to ignore during deployment, using glob patterns similar to those in .gitignore.
|
|
51
|
+
*/
|
|
52
|
+
ignore?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Controls the Gzip compression optimization for files in the source folder. By default, it targets JavaScript (js), ES Module (mjs), and CSS (css) files.
|
|
55
|
+
* You can disable this by setting it to `false` or customize it with a different file matching pattern using glob syntax.
|
|
56
|
+
*/
|
|
57
|
+
gzip?: string | false;
|
|
58
|
+
/**
|
|
59
|
+
* Customizes file encoding mapping for HTTP response headers `Content-Encoding` based on file extension:
|
|
60
|
+
* - `.Z` for compress,
|
|
61
|
+
* - `.gz` for gzip,
|
|
62
|
+
* - `.br` for brotli,
|
|
63
|
+
* - `.zlib` for deflate,
|
|
64
|
+
* - anything else defaults to `identity`.
|
|
65
|
+
* The "encoding" attribute allows overriding default mappings with an array of glob patterns and encoding types.
|
|
66
|
+
*/
|
|
67
|
+
encoding?: Array<[string, ENCODING_TYPE]>;
|
|
68
|
+
/**
|
|
69
|
+
* Optional configurations to override default assertions made by the CLI regarding satellite deployment conditions.
|
|
70
|
+
*/
|
|
71
|
+
assertions?: SatelliteAssertions;
|
|
72
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a glob pattern for matching files in the storage configuration.
|
|
3
|
+
*/
|
|
4
|
+
export type StorageConfigSourceGlob = string;
|
|
5
|
+
/**
|
|
6
|
+
* Headers allow the client and the satellite to pass additional information along with a request or a response. Some sets of headers can affect how the browser handles the page and its content.
|
|
7
|
+
*/
|
|
8
|
+
export interface StorageConfigHeader {
|
|
9
|
+
/**
|
|
10
|
+
* The glob pattern used to match files within the storage that these headers will apply to.
|
|
11
|
+
*/
|
|
12
|
+
source: StorageConfigSourceGlob;
|
|
13
|
+
/**
|
|
14
|
+
* An array of key-value pairs representing the headers to apply. Each pair includes the header name and its value.
|
|
15
|
+
* Example: `[["Cache-Control", "max-age=3600"], ["X-Custom-Header", "value"]]`
|
|
16
|
+
*/
|
|
17
|
+
headers: [string, string][];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* You can utilize optional rewrites to display the same content for multiple URLs. Rewrites are especially useful when combined with pattern matching, allowing acceptance of any URL that matches the pattern.
|
|
21
|
+
*/
|
|
22
|
+
export interface StorageConfigRewrite {
|
|
23
|
+
/**
|
|
24
|
+
* The glob pattern or specific path to match for incoming requests. Matches are rewritten to the specified destination.
|
|
25
|
+
*/
|
|
26
|
+
source: StorageConfigSourceGlob;
|
|
27
|
+
/**
|
|
28
|
+
* The destination path or file to which matching requests should be rewritten.
|
|
29
|
+
*/
|
|
30
|
+
destination: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Use a URL redirect to prevent broken links if you've moved a page or to shorten URLs.
|
|
34
|
+
*/
|
|
35
|
+
export interface StorageConfigRedirect {
|
|
36
|
+
/**
|
|
37
|
+
* The glob pattern or specific path to match for incoming requests that should be redirected.
|
|
38
|
+
*/
|
|
39
|
+
source: StorageConfigSourceGlob;
|
|
40
|
+
/**
|
|
41
|
+
* The URL or path to which the request should be redirected.
|
|
42
|
+
*/
|
|
43
|
+
location: string;
|
|
44
|
+
/**
|
|
45
|
+
* The HTTP status code to use for the redirect, typically 301 (permanent redirect) or 302 (temporary redirect).
|
|
46
|
+
*/
|
|
47
|
+
code: 301 | 302;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Configures the Hosting behavior of the Storage.
|
|
51
|
+
*/
|
|
52
|
+
export interface StorageConfig {
|
|
53
|
+
/**
|
|
54
|
+
* Optional array of `StorageConfigHeader` objects to define custom HTTP headers for specific files or patterns.
|
|
55
|
+
*/
|
|
56
|
+
headers?: StorageConfigHeader[];
|
|
57
|
+
/**
|
|
58
|
+
* Optional array of `StorageConfigRewrite` objects to define rewrite rules.
|
|
59
|
+
*/
|
|
60
|
+
rewrites?: StorageConfigRewrite[];
|
|
61
|
+
/**
|
|
62
|
+
* Optional array of `StorageConfigRedirect` objects to define HTTP redirects.
|
|
63
|
+
*/
|
|
64
|
+
redirects?: StorageConfigRedirect[];
|
|
65
|
+
/**
|
|
66
|
+
* For security reasons and to prevent click-jacking attacks, dapps deployed with Juno are, by default, set to deny embedding in other sites.
|
|
67
|
+
*
|
|
68
|
+
* Options are:
|
|
69
|
+
* - `deny`: Prevents any content from being displayed in an iframe.
|
|
70
|
+
* - `same-origin`: Allows iframe content from the same origin as the page.
|
|
71
|
+
* - `allow-any`: Allows iframe content from any origin.
|
|
72
|
+
*
|
|
73
|
+
* If not specified, then `deny` is used as default value.
|
|
74
|
+
*/
|
|
75
|
+
iframe?: 'deny' | 'same-origin' | 'allow-any';
|
|
76
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@junobuild/config",
|
|
3
|
+
"version": "0.0.1-next-2024-02-17",
|
|
4
|
+
"description": "Configuration options for Juno CLI",
|
|
5
|
+
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/node/index.mjs",
|
|
9
|
+
"module": "./dist/browser/index.js",
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"default": "./dist/browser/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"default": "./dist/node/index.mjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"rmdir": "node ../../scripts/rmdir.mjs",
|
|
30
|
+
"ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
31
|
+
"build": "npm run rmdir && mkdir -p dist && node esbuild.mjs && npm run ts-declaration",
|
|
32
|
+
"prepack": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/junobuild/juno-js.git",
|
|
37
|
+
"directory": "packages/config"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/junobuild/juno-js"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://juno.build"
|
|
43
|
+
}
|