@settlemint/sdk-utils 2.3.2-pr6cb5dd2e → 2.3.2-pr74f654b5
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/README.md +51 -7
- package/dist/environment.cjs +25 -408
- package/dist/environment.d.cts +3 -176
- package/dist/environment.d.ts +3 -176
- package/dist/environment.js +4 -0
- package/dist/filesystem.cjs +39 -123
- package/dist/filesystem.d.cts +4 -59
- package/dist/filesystem.d.ts +4 -59
- package/dist/filesystem.js +5 -0
- package/dist/http.cjs +35 -147
- package/dist/http.d.cts +4 -50
- package/dist/http.d.ts +4 -50
- package/dist/http.js +5 -0
- package/dist/index.cjs +27 -184
- package/dist/index.d.cts +4 -122
- package/dist/index.d.ts +4 -122
- package/dist/index.js +7 -0
- package/dist/json.cjs +83 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.cts +56 -0
- package/dist/json.d.ts +56 -0
- package/dist/json.js +80 -0
- package/dist/json.js.map +1 -0
- package/dist/logging.cjs +34 -141
- package/dist/logging.d.cts +4 -70
- package/dist/logging.d.ts +4 -70
- package/dist/logging.js +5 -0
- package/dist/package-manager.cjs +51 -196
- package/dist/package-manager.d.cts +7 -114
- package/dist/package-manager.d.ts +7 -114
- package/dist/package-manager.js +9 -0
- package/dist/retry.cjs +69 -0
- package/dist/retry.cjs.map +1 -0
- package/dist/retry.d.cts +19 -0
- package/dist/retry.d.ts +19 -0
- package/dist/retry.js +46 -0
- package/dist/retry.js.map +1 -0
- package/dist/runtime.cjs +38 -42
- package/dist/runtime.d.cts +2 -32
- package/dist/runtime.d.ts +2 -32
- package/dist/runtime.js +3 -0
- package/dist/string.cjs +76 -0
- package/dist/string.cjs.map +1 -0
- package/dist/string.d.cts +58 -0
- package/dist/string.d.ts +58 -0
- package/dist/string.js +72 -0
- package/dist/string.js.map +1 -0
- package/dist/terminal.cjs +91 -258
- package/dist/terminal.d.cts +11 -219
- package/dist/terminal.d.ts +11 -219
- package/dist/terminal.js +12 -0
- package/dist/url.cjs +25 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +20 -0
- package/dist/url.d.ts +20 -0
- package/dist/url.js +24 -0
- package/dist/url.js.map +1 -0
- package/dist/validation.cjs +89 -183
- package/dist/validation.d.cts +7 -239
- package/dist/validation.d.ts +7 -239
- package/dist/validation.js +8 -0
- package/package.json +6 -6
- package/dist/environment.cjs.map +0 -1
- package/dist/environment.mjs +0 -383
- package/dist/environment.mjs.map +0 -1
- package/dist/filesystem.cjs.map +0 -1
- package/dist/filesystem.mjs +0 -105
- package/dist/filesystem.mjs.map +0 -1
- package/dist/http.cjs.map +0 -1
- package/dist/http.mjs +0 -129
- package/dist/http.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -156
- package/dist/index.mjs.map +0 -1
- package/dist/logging.cjs.map +0 -1
- package/dist/logging.mjs +0 -123
- package/dist/logging.mjs.map +0 -1
- package/dist/package-manager.cjs.map +0 -1
- package/dist/package-manager.mjs +0 -167
- package/dist/package-manager.mjs.map +0 -1
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.mjs +0 -23
- package/dist/runtime.mjs.map +0 -1
- package/dist/terminal.cjs.map +0 -1
- package/dist/terminal.mjs +0 -230
- package/dist/terminal.mjs.map +0 -1
- package/dist/validation.cjs.map +0 -1
- package/dist/validation.mjs +0 -159
- package/dist/validation.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
- [ensureServer()](#ensureserver)
|
|
40
40
|
- [executeCommand()](#executecommand)
|
|
41
41
|
- [exists()](#exists)
|
|
42
|
+
- [extractBaseUrlBeforeSegment()](#extractbaseurlbeforesegment)
|
|
42
43
|
- [extractJsonObject()](#extractjsonobject)
|
|
43
44
|
- [fetchWithRetry()](#fetchwithretry)
|
|
44
45
|
- [findMonoRepoPackages()](#findmonorepopackages)
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
- [PersonalAccessTokenSchema](#personalaccesstokenschema)
|
|
92
93
|
- [runsInBrowser](#runsinbrowser)
|
|
93
94
|
- [runsOnServer](#runsonserver)
|
|
95
|
+
- [STANDALONE\_INSTANCE](#standalone_instance)
|
|
94
96
|
- [UniqueNameSchema](#uniquenameschema)
|
|
95
97
|
- [UrlOrPathSchema](#urlorpathschema)
|
|
96
98
|
- [UrlPathSchema](#urlpathschema)
|
|
@@ -415,6 +417,38 @@ if (await exists('/path/to/file.txt')) {
|
|
|
415
417
|
|
|
416
418
|
***
|
|
417
419
|
|
|
420
|
+
#### extractBaseUrlBeforeSegment()
|
|
421
|
+
|
|
422
|
+
> **extractBaseUrlBeforeSegment**(`baseUrl`, `pathSegment`): `string`
|
|
423
|
+
|
|
424
|
+
Defined in: [sdk/utils/src/url.ts:15](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/url.ts#L15)
|
|
425
|
+
|
|
426
|
+
Extracts the base URL before a specific segment in a URL.
|
|
427
|
+
|
|
428
|
+
##### Parameters
|
|
429
|
+
|
|
430
|
+
| Parameter | Type | Description |
|
|
431
|
+
| ------ | ------ | ------ |
|
|
432
|
+
| `baseUrl` | `string` | The base URL to extract the path from |
|
|
433
|
+
| `pathSegment` | `string` | The path segment to start from |
|
|
434
|
+
|
|
435
|
+
##### Returns
|
|
436
|
+
|
|
437
|
+
`string`
|
|
438
|
+
|
|
439
|
+
The base URL before the specified segment
|
|
440
|
+
|
|
441
|
+
##### Example
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
import { extractBaseUrlBeforeSegment } from "@settlemint/sdk-utils/url";
|
|
445
|
+
|
|
446
|
+
const baseUrl = extractBaseUrlBeforeSegment("https://example.com/api/v1/subgraphs/name/my-subgraph", "/subgraphs");
|
|
447
|
+
// Returns: "https://example.com/api/v1"
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
***
|
|
451
|
+
|
|
418
452
|
#### extractJsonObject()
|
|
419
453
|
|
|
420
454
|
> **extractJsonObject**\<`T`\>(`value`): `null` \| `T`
|
|
@@ -1174,7 +1208,7 @@ The fetch function
|
|
|
1174
1208
|
|
|
1175
1209
|
> **retryWhenFailed**\<`T`\>(`fn`, `maxRetries`, `initialSleepTime`, `stopOnError?`): `Promise`\<`T`\>
|
|
1176
1210
|
|
|
1177
|
-
Defined in: [sdk/utils/src/retry.ts:
|
|
1211
|
+
Defined in: [sdk/utils/src/retry.ts:16](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/retry.ts#L16)
|
|
1178
1212
|
|
|
1179
1213
|
Retry a function when it fails.
|
|
1180
1214
|
|
|
@@ -1663,7 +1697,7 @@ Options for configuring the spinner behavior
|
|
|
1663
1697
|
|
|
1664
1698
|
> **DotEnv** = `z.infer`\<*typeof* [`DotEnvSchema`](#dotenvschema)\>
|
|
1665
1699
|
|
|
1666
|
-
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:
|
|
1700
|
+
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:106](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/validation/dot-env.schema.ts#L106)
|
|
1667
1701
|
|
|
1668
1702
|
Type definition for the environment variables schema.
|
|
1669
1703
|
|
|
@@ -1673,7 +1707,7 @@ Type definition for the environment variables schema.
|
|
|
1673
1707
|
|
|
1674
1708
|
> **DotEnvPartial** = `z.infer`\<*typeof* [`DotEnvSchemaPartial`](#dotenvschemapartial)\>
|
|
1675
1709
|
|
|
1676
|
-
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:
|
|
1710
|
+
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:117](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/validation/dot-env.schema.ts#L117)
|
|
1677
1711
|
|
|
1678
1712
|
Type definition for the partial environment variables schema.
|
|
1679
1713
|
|
|
@@ -1724,9 +1758,9 @@ Application access tokens start with 'sm_aat_' prefix.
|
|
|
1724
1758
|
|
|
1725
1759
|
#### DotEnvSchema
|
|
1726
1760
|
|
|
1727
|
-
> `const` **DotEnvSchema**: `ZodObject`\<\{ `SETTLEMINT_ACCESS_TOKEN`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_ACCESSIBLE_PRIVATE_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_APPLICATION`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NETWORK`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_CUSTOM_DEPLOYMENT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_ADMIN_SECRET`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_DATABASE_URL`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HD_PRIVATE_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_INSTANCE`: `ZodDefault`\<`ZodString
|
|
1761
|
+
> `const` **DotEnvSchema**: `ZodObject`\<\{ `SETTLEMINT_ACCESS_TOKEN`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_ACCESSIBLE_PRIVATE_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_APPLICATION`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NETWORK`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_CUSTOM_DEPLOYMENT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_ADMIN_SECRET`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_DATABASE_URL`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HASURA_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HD_PRIVATE_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_INSTANCE`: `ZodDefault`\<`ZodUnion`\<readonly \[`ZodString`, `ZodLiteral`\<`"standalone"`\>\]\>\>; `SETTLEMINT_IPFS`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_IPFS_API_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_IPFS_GATEWAY_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_IPFS_PINNING_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_LOG_LEVEL`: `ZodDefault`\<`ZodEnum`\<\{ `debug`: `"debug"`; `error`: `"error"`; `info`: `"info"`; `none`: `"none"`; `warn`: `"warn"`; \}\>\>; `SETTLEMINT_MINIO`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_MINIO_ACCESS_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_MINIO_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_MINIO_SECRET_KEY`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_NEW_PROJECT_NAME`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_PORTAL`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_PORTAL_REST_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_PORTAL_WS_ENDPOINT`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_THEGRAPH`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH`: `ZodOptional`\<`ZodString`\>; `SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS`: `ZodPipe`\<`ZodTransform`\<`null` \| `never`[], `unknown`\>, `ZodOptional`\<`ZodArray`\<`ZodString`\>\>\>; `SETTLEMINT_WORKSPACE`: `ZodOptional`\<`ZodString`\>; \}, `$strip`\>
|
|
1728
1762
|
|
|
1729
|
-
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:
|
|
1763
|
+
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:17](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/validation/dot-env.schema.ts#L17)
|
|
1730
1764
|
|
|
1731
1765
|
Schema for validating environment variables used by the SettleMint SDK.
|
|
1732
1766
|
Defines validation rules and types for configuration values like URLs,
|
|
@@ -1736,9 +1770,9 @@ access tokens, workspace names, and service endpoints.
|
|
|
1736
1770
|
|
|
1737
1771
|
#### DotEnvSchemaPartial
|
|
1738
1772
|
|
|
1739
|
-
> `const` **DotEnvSchemaPartial**: `ZodObject`\<\{ `SETTLEMINT_ACCESS_TOKEN`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_ACCESSIBLE_PRIVATE_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_APPLICATION`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NETWORK`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_CUSTOM_DEPLOYMENT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_ADMIN_SECRET`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_DATABASE_URL`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HD_PRIVATE_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_INSTANCE`: `ZodOptional`\<`ZodDefault`\<`ZodString
|
|
1773
|
+
> `const` **DotEnvSchemaPartial**: `ZodObject`\<\{ `SETTLEMINT_ACCESS_TOKEN`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_ACCESSIBLE_PRIVATE_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_APPLICATION`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NETWORK`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_CUSTOM_DEPLOYMENT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_ADMIN_SECRET`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_DATABASE_URL`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HASURA_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HD_PRIVATE_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_INSTANCE`: `ZodOptional`\<`ZodDefault`\<`ZodUnion`\<readonly \[`ZodString`, `ZodLiteral`\<`"standalone"`\>\]\>\>\>; `SETTLEMINT_IPFS`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_IPFS_API_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_IPFS_GATEWAY_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_IPFS_PINNING_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_LOG_LEVEL`: `ZodOptional`\<`ZodDefault`\<`ZodEnum`\<\{ `debug`: `"debug"`; `error`: `"error"`; `info`: `"info"`; `none`: `"none"`; `warn`: `"warn"`; \}\>\>\>; `SETTLEMINT_MINIO`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_MINIO_ACCESS_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_MINIO_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_MINIO_SECRET_KEY`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_NEW_PROJECT_NAME`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_PORTAL`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_PORTAL_REST_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_PORTAL_WS_ENDPOINT`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_THEGRAPH`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; `SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS`: `ZodOptional`\<`ZodPipe`\<`ZodTransform`\<`null` \| `never`[], `unknown`\>, `ZodOptional`\<`ZodArray`\<`ZodString`\>\>\>\>; `SETTLEMINT_WORKSPACE`: `ZodOptional`\<`ZodOptional`\<`ZodString`\>\>; \}, `$strip`\>
|
|
1740
1774
|
|
|
1741
|
-
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:
|
|
1775
|
+
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:112](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/validation/dot-env.schema.ts#L112)
|
|
1742
1776
|
|
|
1743
1777
|
Partial version of the environment variables schema where all fields are optional.
|
|
1744
1778
|
Useful for validating incomplete configurations during development or build time.
|
|
@@ -1800,6 +1834,16 @@ Boolean indicating if code is currently running in a server environment
|
|
|
1800
1834
|
|
|
1801
1835
|
***
|
|
1802
1836
|
|
|
1837
|
+
#### STANDALONE\_INSTANCE
|
|
1838
|
+
|
|
1839
|
+
> `const` **STANDALONE\_INSTANCE**: `"standalone"` = `"standalone"`
|
|
1840
|
+
|
|
1841
|
+
Defined in: [sdk/utils/src/validation/dot-env.schema.ts:10](https://github.com/settlemint/sdk/blob/v2.3.2/sdk/utils/src/validation/dot-env.schema.ts#L10)
|
|
1842
|
+
|
|
1843
|
+
Use this value to indicate that the resources are not part of the SettleMint platform.
|
|
1844
|
+
|
|
1845
|
+
***
|
|
1846
|
+
|
|
1803
1847
|
#### UniqueNameSchema
|
|
1804
1848
|
|
|
1805
1849
|
> `const` **UniqueNameSchema**: `ZodString`
|
package/dist/environment.cjs
CHANGED
|
@@ -1,421 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
8
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/environment.ts
|
|
31
|
-
var environment_exports = {};
|
|
32
|
-
__export(environment_exports, {
|
|
33
|
-
loadEnv: () => loadEnv,
|
|
34
|
-
writeEnv: () => writeEnv
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(environment_exports);
|
|
37
|
-
|
|
38
|
-
// src/environment/load-env.ts
|
|
39
|
-
var import_node_path = require("path");
|
|
40
|
-
|
|
41
|
-
// src/terminal/ascii.ts
|
|
42
|
-
var import_yoctocolors = require("yoctocolors");
|
|
43
|
-
|
|
44
|
-
// src/logging/mask-tokens.ts
|
|
45
|
-
var maskTokens = (output) => {
|
|
46
|
-
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/terminal/cancel.ts
|
|
50
|
-
var import_yoctocolors2 = require("yoctocolors");
|
|
51
|
-
var CancelError = class extends Error {
|
|
52
|
-
};
|
|
53
|
-
var cancel = (msg) => {
|
|
54
|
-
console.log("");
|
|
55
|
-
console.log((0, import_yoctocolors2.inverse)((0, import_yoctocolors2.redBright)(maskTokens(msg))));
|
|
56
|
-
console.log("");
|
|
57
|
-
throw new CancelError(msg);
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
58
17
|
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
59
22
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// src/terminal/intro.ts
|
|
64
|
-
var import_yoctocolors3 = require("yoctocolors");
|
|
23
|
+
//#endregion
|
|
24
|
+
const src_environment_load_env_js = __toESM(require("./environment/load-env.js"));
|
|
25
|
+
const src_environment_write_env_js = __toESM(require("./environment/write-env.js"));
|
|
65
26
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var import_yoctocolors5 = require("yoctocolors");
|
|
71
|
-
|
|
72
|
-
// src/terminal/spinner.ts
|
|
73
|
-
var import_is_in_ci = __toESM(require("is-in-ci"), 1);
|
|
74
|
-
var import_yocto_spinner = __toESM(require("yocto-spinner"), 1);
|
|
75
|
-
var import_yoctocolors6 = require("yoctocolors");
|
|
76
|
-
|
|
77
|
-
// src/terminal/table.ts
|
|
78
|
-
var import_console_table_printer = require("console-table-printer");
|
|
79
|
-
var import_yoctocolors7 = require("yoctocolors");
|
|
80
|
-
|
|
81
|
-
// src/validation/validate.ts
|
|
82
|
-
var import_v4 = require("zod/v4");
|
|
83
|
-
function validate(schema, value) {
|
|
84
|
-
try {
|
|
85
|
-
return schema.parse(value);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (error instanceof import_v4.ZodError) {
|
|
88
|
-
const formattedErrors = error.issues.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
|
|
89
|
-
throw new Error(`Validation error${error.issues.length > 1 ? "s" : ""}:
|
|
90
|
-
${formattedErrors}`);
|
|
91
|
-
}
|
|
92
|
-
throw error;
|
|
27
|
+
Object.defineProperty(exports, 'loadEnv', {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return src_environment_load_env_js.loadEnv;
|
|
93
31
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// src/validation/access-token.schema.ts
|
|
97
|
-
var import_v42 = require("zod/v4");
|
|
98
|
-
var ApplicationAccessTokenSchema = import_v42.z.string().regex(/^sm_aat_.*$/);
|
|
99
|
-
var PersonalAccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*$/);
|
|
100
|
-
var AccessTokenSchema = import_v42.z.string().regex(/^sm_pat_.*|sm_aat_.*$/);
|
|
101
|
-
|
|
102
|
-
// src/json.ts
|
|
103
|
-
function tryParseJson(value, defaultValue = null) {
|
|
104
|
-
try {
|
|
105
|
-
const parsed = JSON.parse(value);
|
|
106
|
-
if (parsed === void 0 || parsed === null) {
|
|
107
|
-
return defaultValue;
|
|
108
|
-
}
|
|
109
|
-
return parsed;
|
|
110
|
-
} catch (err) {
|
|
111
|
-
return defaultValue;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/validation/dot-env.schema.ts
|
|
116
|
-
var import_v45 = require("zod/v4");
|
|
117
|
-
|
|
118
|
-
// src/validation/unique-name.schema.ts
|
|
119
|
-
var import_v43 = require("zod/v4");
|
|
120
|
-
var UniqueNameSchema = import_v43.z.string().regex(/^[a-z0-9-]+$/);
|
|
121
|
-
|
|
122
|
-
// src/validation/url.schema.ts
|
|
123
|
-
var import_v44 = require("zod/v4");
|
|
124
|
-
var UrlSchema = import_v44.z.string().url();
|
|
125
|
-
var UrlPathSchema = import_v44.z.string().regex(/^\/(?:[a-zA-Z0-9-_]+(?:\/[a-zA-Z0-9-_]+)*\/?)?$/, {
|
|
126
|
-
message: "Invalid URL path format. Must start with '/' and can contain letters, numbers, hyphens, and underscores."
|
|
127
|
-
});
|
|
128
|
-
var UrlOrPathSchema = import_v44.z.union([UrlSchema, UrlPathSchema]);
|
|
129
|
-
|
|
130
|
-
// src/validation/dot-env.schema.ts
|
|
131
|
-
var DotEnvSchema = import_v45.z.object({
|
|
132
|
-
/** Base URL of the SettleMint platform instance */
|
|
133
|
-
SETTLEMINT_INSTANCE: UrlSchema.default("https://console.settlemint.com"),
|
|
134
|
-
/** Application access token for authenticating with SettleMint services */
|
|
135
|
-
SETTLEMINT_ACCESS_TOKEN: ApplicationAccessTokenSchema.optional(),
|
|
136
|
-
/** @internal */
|
|
137
|
-
SETTLEMINT_PERSONAL_ACCESS_TOKEN: PersonalAccessTokenSchema.optional(),
|
|
138
|
-
/** Unique name of the workspace */
|
|
139
|
-
SETTLEMINT_WORKSPACE: UniqueNameSchema.optional(),
|
|
140
|
-
/** Unique name of the application */
|
|
141
|
-
SETTLEMINT_APPLICATION: UniqueNameSchema.optional(),
|
|
142
|
-
/** Unique name of the blockchain network */
|
|
143
|
-
SETTLEMINT_BLOCKCHAIN_NETWORK: UniqueNameSchema.optional(),
|
|
144
|
-
/** Chain ID of the blockchain network */
|
|
145
|
-
SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID: import_v45.z.string().optional(),
|
|
146
|
-
/** Unique name of the blockchain node (should have a private key for signing transactions) */
|
|
147
|
-
SETTLEMINT_BLOCKCHAIN_NODE: UniqueNameSchema.optional(),
|
|
148
|
-
/** JSON RPC endpoint for the blockchain node */
|
|
149
|
-
SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: UrlSchema.optional(),
|
|
150
|
-
/** Unique name of the blockchain node or load balancer */
|
|
151
|
-
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: UniqueNameSchema.optional(),
|
|
152
|
-
/** JSON RPC endpoint for the blockchain node or load balancer */
|
|
153
|
-
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT: UrlSchema.optional(),
|
|
154
|
-
/** Unique name of the Hasura instance */
|
|
155
|
-
SETTLEMINT_HASURA: UniqueNameSchema.optional(),
|
|
156
|
-
/** Endpoint URL for the Hasura GraphQL API */
|
|
157
|
-
SETTLEMINT_HASURA_ENDPOINT: UrlSchema.optional(),
|
|
158
|
-
/** Admin secret for authenticating with Hasura */
|
|
159
|
-
SETTLEMINT_HASURA_ADMIN_SECRET: import_v45.z.string().optional(),
|
|
160
|
-
/** Database connection URL for Hasura */
|
|
161
|
-
SETTLEMINT_HASURA_DATABASE_URL: import_v45.z.string().optional(),
|
|
162
|
-
/** Unique name of The Graph instance */
|
|
163
|
-
SETTLEMINT_THEGRAPH: UniqueNameSchema.optional(),
|
|
164
|
-
/** Array of endpoint URLs for The Graph subgraphs */
|
|
165
|
-
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: import_v45.z.preprocess(
|
|
166
|
-
(value) => tryParseJson(value, []),
|
|
167
|
-
import_v45.z.array(UrlSchema).optional()
|
|
168
|
-
),
|
|
169
|
-
/** Default The Graph subgraph to use */
|
|
170
|
-
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: import_v45.z.string().optional(),
|
|
171
|
-
/** Unique name of the Smart Contract Portal instance */
|
|
172
|
-
SETTLEMINT_PORTAL: UniqueNameSchema.optional(),
|
|
173
|
-
/** GraphQL endpoint URL for the Portal */
|
|
174
|
-
SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: UrlSchema.optional(),
|
|
175
|
-
/** REST endpoint URL for the Portal */
|
|
176
|
-
SETTLEMINT_PORTAL_REST_ENDPOINT: UrlSchema.optional(),
|
|
177
|
-
/** WebSocket endpoint URL for the Portal */
|
|
178
|
-
SETTLEMINT_PORTAL_WS_ENDPOINT: UrlSchema.optional(),
|
|
179
|
-
/** Unique name of the HD private key */
|
|
180
|
-
SETTLEMINT_HD_PRIVATE_KEY: UniqueNameSchema.optional(),
|
|
181
|
-
/** Address of the HD private key forwarder */
|
|
182
|
-
SETTLEMINT_HD_PRIVATE_KEY_FORWARDER_ADDRESS: import_v45.z.string().optional(),
|
|
183
|
-
/** Unique name of the accessible private key */
|
|
184
|
-
SETTLEMINT_ACCESSIBLE_PRIVATE_KEY: UniqueNameSchema.optional(),
|
|
185
|
-
/** Unique name of the MinIO instance */
|
|
186
|
-
SETTLEMINT_MINIO: UniqueNameSchema.optional(),
|
|
187
|
-
/** Endpoint URL for MinIO */
|
|
188
|
-
SETTLEMINT_MINIO_ENDPOINT: UrlSchema.optional(),
|
|
189
|
-
/** Access key for MinIO authentication */
|
|
190
|
-
SETTLEMINT_MINIO_ACCESS_KEY: import_v45.z.string().optional(),
|
|
191
|
-
/** Secret key for MinIO authentication */
|
|
192
|
-
SETTLEMINT_MINIO_SECRET_KEY: import_v45.z.string().optional(),
|
|
193
|
-
/** Unique name of the IPFS instance */
|
|
194
|
-
SETTLEMINT_IPFS: UniqueNameSchema.optional(),
|
|
195
|
-
/** API endpoint URL for IPFS */
|
|
196
|
-
SETTLEMINT_IPFS_API_ENDPOINT: UrlSchema.optional(),
|
|
197
|
-
/** Pinning service endpoint URL for IPFS */
|
|
198
|
-
SETTLEMINT_IPFS_PINNING_ENDPOINT: UrlSchema.optional(),
|
|
199
|
-
/** Gateway endpoint URL for IPFS */
|
|
200
|
-
SETTLEMINT_IPFS_GATEWAY_ENDPOINT: UrlSchema.optional(),
|
|
201
|
-
/** Unique name of the custom deployment */
|
|
202
|
-
SETTLEMINT_CUSTOM_DEPLOYMENT: UniqueNameSchema.optional(),
|
|
203
|
-
/** Endpoint URL for the custom deployment */
|
|
204
|
-
SETTLEMINT_CUSTOM_DEPLOYMENT_ENDPOINT: UrlSchema.optional(),
|
|
205
|
-
/** Unique name of the Blockscout instance */
|
|
206
|
-
SETTLEMINT_BLOCKSCOUT: UniqueNameSchema.optional(),
|
|
207
|
-
/** GraphQL endpoint URL for Blockscout */
|
|
208
|
-
SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT: UrlSchema.optional(),
|
|
209
|
-
/** UI endpoint URL for Blockscout */
|
|
210
|
-
SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT: UrlSchema.optional(),
|
|
211
|
-
/** Name of the new project being created */
|
|
212
|
-
SETTLEMINT_NEW_PROJECT_NAME: import_v45.z.string().optional(),
|
|
213
|
-
/** The log level to use */
|
|
214
|
-
SETTLEMINT_LOG_LEVEL: import_v45.z.enum(["debug", "info", "warn", "error", "none"]).default("warn")
|
|
215
32
|
});
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var IdSchema = import_v46.z.union([
|
|
221
|
-
import_v46.z.string().uuid(),
|
|
222
|
-
// PostgreSQL UUID
|
|
223
|
-
import_v46.z.string().regex(/^[0-9a-fA-F]{24}$/)
|
|
224
|
-
// MongoDB ObjectID
|
|
225
|
-
]);
|
|
226
|
-
|
|
227
|
-
// src/environment/load-env.ts
|
|
228
|
-
var import_dotenvx = require("@dotenvx/dotenvx");
|
|
229
|
-
async function loadEnv(validateEnv, prod, path = process.cwd()) {
|
|
230
|
-
return loadEnvironmentEnv(validateEnv, !!prod, path);
|
|
231
|
-
}
|
|
232
|
-
async function loadEnvironmentEnv(validateEnv, prod, path = process.cwd()) {
|
|
233
|
-
if (prod) {
|
|
234
|
-
process.env.NODE_ENV = "production";
|
|
235
|
-
}
|
|
236
|
-
let { parsed } = (0, import_dotenvx.config)({
|
|
237
|
-
convention: "nextjs",
|
|
238
|
-
logLevel: "error",
|
|
239
|
-
overload: true,
|
|
240
|
-
quiet: true,
|
|
241
|
-
path: [(0, import_node_path.join)(path, ".env"), (0, import_node_path.join)(path, ".env.local")]
|
|
242
|
-
});
|
|
243
|
-
if (!parsed) {
|
|
244
|
-
parsed = {};
|
|
245
|
-
}
|
|
246
|
-
const defaultEnv = Object.fromEntries(
|
|
247
|
-
Object.entries(process.env).filter(([_, value]) => typeof value === "string" && value !== "")
|
|
248
|
-
);
|
|
249
|
-
try {
|
|
250
|
-
return validate(validateEnv ? DotEnvSchema : DotEnvSchemaPartial, {
|
|
251
|
-
...parsed,
|
|
252
|
-
...defaultEnv
|
|
253
|
-
});
|
|
254
|
-
} catch (error) {
|
|
255
|
-
cancel(error.message);
|
|
256
|
-
return {};
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/environment/write-env.ts
|
|
261
|
-
var import_promises3 = require("fs/promises");
|
|
262
|
-
var import_node_path4 = require("path");
|
|
263
|
-
|
|
264
|
-
// src/filesystem/project-root.ts
|
|
265
|
-
var import_node_path2 = require("path");
|
|
266
|
-
var import_find_up = require("find-up");
|
|
267
|
-
async function projectRoot(fallbackToCwd = false, cwd) {
|
|
268
|
-
const packageJsonPath = await (0, import_find_up.findUp)("package.json", { cwd });
|
|
269
|
-
if (!packageJsonPath) {
|
|
270
|
-
if (fallbackToCwd) {
|
|
271
|
-
return process.cwd();
|
|
272
|
-
}
|
|
273
|
-
throw new Error("Unable to find project root (no package.json found)");
|
|
274
|
-
}
|
|
275
|
-
return (0, import_node_path2.dirname)(packageJsonPath);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// src/filesystem/exists.ts
|
|
279
|
-
var import_promises = require("fs/promises");
|
|
280
|
-
async function exists(path) {
|
|
281
|
-
try {
|
|
282
|
-
await (0, import_promises.stat)(path);
|
|
283
|
-
return true;
|
|
284
|
-
} catch {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// src/filesystem/mono-repo.ts
|
|
290
|
-
var import_promises2 = require("fs/promises");
|
|
291
|
-
var import_node_path3 = require("path");
|
|
292
|
-
var import_find_up2 = require("find-up");
|
|
293
|
-
var import_glob = require("glob");
|
|
294
|
-
async function findMonoRepoRoot(startDir) {
|
|
295
|
-
const lockFilePath = await (0, import_find_up2.findUp)(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock"], {
|
|
296
|
-
cwd: startDir
|
|
297
|
-
});
|
|
298
|
-
if (lockFilePath) {
|
|
299
|
-
const packageJsonPath = (0, import_node_path3.join)((0, import_node_path3.dirname)(lockFilePath), "package.json");
|
|
300
|
-
const hasWorkSpaces = await packageJsonHasWorkspaces(packageJsonPath);
|
|
301
|
-
return hasWorkSpaces ? (0, import_node_path3.dirname)(lockFilePath) : null;
|
|
33
|
+
Object.defineProperty(exports, 'writeEnv', {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return src_environment_write_env_js.writeEnv;
|
|
302
37
|
}
|
|
303
|
-
|
|
304
|
-
while (currentDir !== "/") {
|
|
305
|
-
const packageJsonPath = (0, import_node_path3.join)(currentDir, "package.json");
|
|
306
|
-
if (await packageJsonHasWorkspaces(packageJsonPath)) {
|
|
307
|
-
return currentDir;
|
|
308
|
-
}
|
|
309
|
-
const parentDir = (0, import_node_path3.dirname)(currentDir);
|
|
310
|
-
if (parentDir === currentDir) {
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
currentDir = parentDir;
|
|
314
|
-
}
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
async function findMonoRepoPackages(projectDir) {
|
|
318
|
-
try {
|
|
319
|
-
const monoRepoRoot = await findMonoRepoRoot(projectDir);
|
|
320
|
-
if (!monoRepoRoot) {
|
|
321
|
-
return [projectDir];
|
|
322
|
-
}
|
|
323
|
-
const packageJsonPath = (0, import_node_path3.join)(monoRepoRoot, "package.json");
|
|
324
|
-
const packageJson = tryParseJson(await (0, import_promises2.readFile)(packageJsonPath, "utf-8"));
|
|
325
|
-
const workspaces = packageJson?.workspaces ?? [];
|
|
326
|
-
const packagePaths = await Promise.all(
|
|
327
|
-
workspaces.map(async (workspace) => {
|
|
328
|
-
const matches = await (0, import_glob.glob)((0, import_node_path3.join)(monoRepoRoot, workspace, "package.json"));
|
|
329
|
-
return matches.map((match) => (0, import_node_path3.join)(match, ".."));
|
|
330
|
-
})
|
|
331
|
-
);
|
|
332
|
-
const allPaths = packagePaths.flat();
|
|
333
|
-
return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];
|
|
334
|
-
} catch (error) {
|
|
335
|
-
return [projectDir];
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
async function packageJsonHasWorkspaces(packageJsonPath) {
|
|
339
|
-
if (await exists(packageJsonPath)) {
|
|
340
|
-
const packageJson = tryParseJson(await (0, import_promises2.readFile)(packageJsonPath, "utf-8"));
|
|
341
|
-
if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// src/environment/write-env.ts
|
|
349
|
-
var import_dotenvx2 = require("@dotenvx/dotenvx");
|
|
350
|
-
var import_deepmerge_ts = require("deepmerge-ts");
|
|
351
|
-
async function writeEnv({
|
|
352
|
-
prod,
|
|
353
|
-
env,
|
|
354
|
-
secrets,
|
|
355
|
-
cwd
|
|
356
|
-
}) {
|
|
357
|
-
const projectDir = await projectRoot(true, cwd);
|
|
358
|
-
if (prod) {
|
|
359
|
-
process.env.NODE_ENV = "production";
|
|
360
|
-
}
|
|
361
|
-
const targetDirs = await findMonoRepoPackages(projectDir);
|
|
362
|
-
await Promise.all(
|
|
363
|
-
targetDirs.map(async (dir) => {
|
|
364
|
-
const envFile = (0, import_node_path4.join)(
|
|
365
|
-
dir,
|
|
366
|
-
secrets ? `.env${prod ? ".production" : ""}.local` : `.env${prod ? ".production" : ""}`
|
|
367
|
-
);
|
|
368
|
-
let { parsed: currentEnv } = await exists(envFile) ? (0, import_dotenvx2.config)({
|
|
369
|
-
path: envFile,
|
|
370
|
-
logLevel: "error",
|
|
371
|
-
quiet: true
|
|
372
|
-
}) : { parsed: {} };
|
|
373
|
-
if (!currentEnv) {
|
|
374
|
-
currentEnv = {};
|
|
375
|
-
}
|
|
376
|
-
const prunedEnv = pruneCurrentEnv(currentEnv, env);
|
|
377
|
-
const mergedEnv = (0, import_deepmerge_ts.deepmerge)(prunedEnv, env);
|
|
378
|
-
await (0, import_promises3.writeFile)(envFile, stringify(mergedEnv));
|
|
379
|
-
})
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
var quote = /[\s"'#]/;
|
|
383
|
-
function stringifyPair([key, val]) {
|
|
384
|
-
if (val === void 0) {
|
|
385
|
-
return void 0;
|
|
386
|
-
}
|
|
387
|
-
if (val === null) {
|
|
388
|
-
return `${key}=""`;
|
|
389
|
-
}
|
|
390
|
-
const type = typeof val;
|
|
391
|
-
if (type === "string") {
|
|
392
|
-
return `${key}=${quote.test(val) ? JSON.stringify(val) : val}`;
|
|
393
|
-
}
|
|
394
|
-
if (type === "boolean" || type === "number") {
|
|
395
|
-
return `${key}=${val}`;
|
|
396
|
-
}
|
|
397
|
-
if (type === "object") {
|
|
398
|
-
return `${key}=${JSON.stringify(val)}`;
|
|
399
|
-
}
|
|
400
|
-
throw new Error(`Unsupported type for key "${key}": ${type}`);
|
|
401
|
-
}
|
|
402
|
-
function stringify(obj) {
|
|
403
|
-
return Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)).map(stringifyPair).filter((value) => value !== void 0).join("\n");
|
|
404
|
-
}
|
|
405
|
-
function pruneCurrentEnv(currentEnv, env) {
|
|
406
|
-
const dotEnvKeys = Object.keys(DotEnvSchema.shape);
|
|
407
|
-
return Object.fromEntries(
|
|
408
|
-
Object.entries(currentEnv).filter(([key]) => {
|
|
409
|
-
if (dotEnvKeys.includes(key) && !env[key]) {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
return true;
|
|
413
|
-
})
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
417
|
-
0 && (module.exports = {
|
|
418
|
-
loadEnv,
|
|
419
|
-
writeEnv
|
|
420
|
-
});
|
|
421
|
-
//# sourceMappingURL=environment.cjs.map
|
|
38
|
+
});
|