Skip to content

Commit a6a4d44

Browse files
committed
chore(blockfrost-client): update Blockfrost providers to the latest codebase
1 parent d710419 commit a6a4d44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+695
-649
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ COPY packages/cardano-services/config/network/${NETWORK} /config/
2929
WORKDIR /app
3030
COPY build build
3131
COPY packages/cardano-services/package.json packages/cardano-services/package.json
32+
COPY packages/blockfrost-client/package.json packages/blockfrost-client/package.json
3233
COPY packages/cardano-services-client/package.json packages/cardano-services-client/package.json
3334
COPY packages/core/package.json packages/core/package.json
3435
COPY packages/crypto/package.json packages/crypto/package.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A suite of TypeScript packages suitable for both Node.js and browser-based devel
3131
- [@cardano-sdk/cardano-services-client](./packages/cardano-services-client)
3232

3333
### External Provider Implementations
34-
- [@cardano-sdk/blockfrost](packages/blockfrost)
34+
- [@cardano-sdk/blockfrost-client](./packages/blockfrost-client)
3535

3636
### Supported Environments
3737

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
dist
2+
dist
3+
secrets
4+
coverage
Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +0,0 @@
1-
# Change Log
2-
3-
All notable changes to this project will be documented in this file.
4-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5-
6-
## [0.5.0](https://github.com/input-output-hk/cardano-js-sdk/compare/@cardano-sdk/[email protected]...@cardano-sdk/[email protected]) (2022-08-30)
7-
8-
9-
### ⚠ BREAKING CHANGES
10-
11-
* rm TxAlonzo.implicitCoin
12-
* replace `NetworkInfoProvider.timeSettings` with `eraSummaries`
13-
* logger is now required
14-
15-
### Features
16-
17-
* replace `NetworkInfoProvider.timeSettings` with `eraSummaries` ([58f6fc7](https://github.com/input-output-hk/cardano-js-sdk/commit/58f6fc7c5ace703583c36f95d3d6962483ad924d))
18-
19-
20-
### Bug Fixes
21-
22-
* **blockfrost:** avoid cip 25 mapping for AssetInfo.TokenMetadata ([9f7b914](https://github.com/input-output-hk/cardano-js-sdk/commit/9f7b9142feadc404d7ae39e3ebfd6ef1496f81ce))
23-
24-
25-
### Code Refactoring
26-
27-
* logger is now required ([cc82bc2](https://github.com/input-output-hk/cardano-js-sdk/commit/cc82bc27539e3ff07f7c2d5816fa7e70c32d06ac))
28-
* rm TxAlonzo.implicitCoin ([167d205](https://github.com/input-output-hk/cardano-js-sdk/commit/167d205dd15c857b229f968ab53a6e52e5504d3f))
29-
30-
31-
32-
## [0.4.0](https://github.com/input-output-hk/cardano-js-sdk/compare/0.3.0...@cardano-sdk/[email protected]) (2022-07-25)
33-
34-
## 0.3.0 (2022-06-24)
35-
36-
37-
### ⚠ BREAKING CHANGES
38-
39-
* remove transactions and blocks methods from blockfrost wallet provider
40-
* move stakePoolStats from wallet provider to stake pool provider
41-
* move jsonToMetadatum from blockfrost package to core.ProviderUtil
42-
* remove TimeSettingsProvider and NetworkInfo.currentEpoch
43-
* split up WalletProvider.utxoDelegationAndRewards
44-
* rename some WalletProvider functions
45-
* validate the correct Ed25519KeyHash length (28 bytes)
46-
* **core:** change WalletProvider.rewardsHistory return type to Map
47-
* make blockfrost API instance a parameter of the providers
48-
* Given transaction submission is really an independent behaviour,
49-
as evidenced by microservices such as the HTTP submission API,
50-
it's more flexible modelled as an independent provider.
51-
* change MetadatumMap type to allow any metadatum as key
52-
* rename AssetInfo metadata->tokenMetadata
53-
* move asset info type from Cardano to Asset
54-
* rename AssetMetadata->TokenMetadata, update fields
55-
* **blockfrost:** update blockHeader fields to new core type
56-
* **blockfrost:** use hex-encoded asset name
57-
58-
### Features
59-
60-
* add optional 'sinceBlock' argument to queryTransactionsByAddresses ([94fdd65](https://github.com/input-output-hk/cardano-js-sdk/commit/94fdd65e0f5b7901081d847eb619a88a1211402c))
61-
* add Provider interface, use as base for TxSubmitProvider ([e155ed4](https://github.com/input-output-hk/cardano-js-sdk/commit/e155ed4efcd1338a54099d1a9034ccbeddeef1cc))
62-
* add WalletProvider.genesisParameters ([1d824fc](https://github.com/input-output-hk/cardano-js-sdk/commit/1d824fc4c7ded176eb045a253b406d6aa31b016a))
63-
* add WalletProvider.queryBlocksByHashes ([f0431b7](https://github.com/input-output-hk/cardano-js-sdk/commit/f0431b7398c9525f50c0b803748cf2fb6195a36f))
64-
* add WalletProvider.rewardsHistory ([d84c980](https://github.com/input-output-hk/cardano-js-sdk/commit/d84c98086a8cb49de47a2ffd78448899cb47036b))
65-
* **blockfrost:** add blockfrostAssetProvider ([8b5acbc](https://github.com/input-output-hk/cardano-js-sdk/commit/8b5acbcfa96b9fa04f43a8747727b75e8d139bd1))
66-
* **blockfrost:** fetch tx metadata, update blockfrost sdk to 2.0.2 ([f5c16a6](https://github.com/input-output-hk/cardano-js-sdk/commit/f5c16a629465df6b4c4db4bb4470420d860b1c7b))
67-
* **blockfrost:** implement TxBodyAlonzo.implicitCoin ([99d9b41](https://github.com/input-output-hk/cardano-js-sdk/commit/99d9b416dd173fe595c868c67e8e838e4cad9127))
68-
* **blockfrost:** wrap submitTx error in UnknownTxSubmissionError ([8244f6b](https://github.com/input-output-hk/cardano-js-sdk/commit/8244f6b814b4483e3d0c279573f3ee360e358134))
69-
* **core:** add cslToCore.txInputs, make ProtocolParamsRequiredByWallet fields required ([d67097e](https://github.com/input-output-hk/cardano-js-sdk/commit/d67097ee1fe4c38bd5b37c40795c4737e9a19f68))
70-
* extend NetworkInfo interface ([7b40bca](https://github.com/input-output-hk/cardano-js-sdk/commit/7b40bca2a34c80e9f746339939ed5ce9412e52e9))
71-
72-
73-
### Bug Fixes
74-
75-
* **blockfrost:** add e2e test for getAsset, fix it to call blockfrost method on api obj ([10a79bc](https://github.com/input-output-hk/cardano-js-sdk/commit/10a79bc951ea7442f0526e0a84010adb4491deb5))
76-
* **blockfrost:** add support to genesis delegate as slot leader ([ab8766f](https://github.com/input-output-hk/cardano-js-sdk/commit/ab8766f40a270f9db74526185dc3b929900a080a))
77-
* **blockfrost:** added e2e test and fix for collaterals ([c53263e](https://github.com/input-output-hk/cardano-js-sdk/commit/c53263eb44088fc5e254564df49354efd790d8a8))
78-
* **blockfrost:** do not re-fetch protocol parameters for every tx ([3748065](https://github.com/input-output-hk/cardano-js-sdk/commit/37480659aabda979892c5bfa2c7c54af111249fb))
79-
* **blockfrost:** ensure tx metadata number type aligns with core ([ad0eafd](https://github.com/input-output-hk/cardano-js-sdk/commit/ad0eafdeb0953f96ea201b1d0f9a10080ca2b71e))
80-
* **blockfrost:** interpret 404s in Blockfrost provider and optimise batching ([a795e4c](https://github.com/input-output-hk/cardano-js-sdk/commit/a795e4c70464ad0bbed714b69e826ee3f11be92c))
81-
* **blockfrost:** refactored BlockfrostToCore ([112a1c2](https://github.com/input-output-hk/cardano-js-sdk/commit/112a1c21387c2bd819d7cbfccbd40073b40091a4))
82-
* **blockfrost:** set correct testnet network magic ([b0db9dd](https://github.com/input-output-hk/cardano-js-sdk/commit/b0db9dd687bb4f1692d37d4cc43cb1e73372ed69))
83-
* **blockfrost:** sort certificates by cert_index ([8a04a27](https://github.com/input-output-hk/cardano-js-sdk/commit/8a04a27514ec2f7dbf74b1962f992d47074f9e88))
84-
* change stakepool metadata extVkey field type to bech32 string ([ec523a7](https://github.com/input-output-hk/cardano-js-sdk/commit/ec523a78e62ba30c4297ccd71eb6070dbd58acc3))
85-
* **cip2:** remove hardcoded value in minimum cost selection constraint ([ad6d133](https://github.com/input-output-hk/cardano-js-sdk/commit/ad6d133a0ba1f865bf2ae1ca3f46b8e6f918502b))
86-
* resolve issues preventing to make a delegation tx ([7429f46](https://github.com/input-output-hk/cardano-js-sdk/commit/7429f466763342b08b6bed44f23d3bf24dbf92f2))
87-
* validate the correct Ed25519KeyHash length (28 bytes) ([0e0b592](https://github.com/input-output-hk/cardano-js-sdk/commit/0e0b592e2b4b0689f592076cd79dfaac88b43c57))
88-
89-
90-
### Code Refactoring
91-
92-
* **blockfrost:** update blockHeader fields to new core type ([2a20818](https://github.com/input-output-hk/cardano-js-sdk/commit/2a20818507ec44e9d4aff2647a8095aa92a7a5b9))
93-
* **blockfrost:** use hex-encoded asset name ([41f3039](https://github.com/input-output-hk/cardano-js-sdk/commit/41f30394c53bd7e16728ae1e3862e659822253f9))
94-
* change MetadatumMap type to allow any metadatum as key ([48c33e5](https://github.com/input-output-hk/cardano-js-sdk/commit/48c33e552406cce35ea19d720451a1ba641ff51b))
95-
* **core:** change WalletProvider.rewardsHistory return type to Map ([07ace58](https://github.com/input-output-hk/cardano-js-sdk/commit/07ace5887e9fed02f5ccb8090594022cd3df28d9))
96-
* extract tx submit into own provider ([1d7ac73](https://github.com/input-output-hk/cardano-js-sdk/commit/1d7ac7393fbd669f08b516c4067883d982f2e711))
97-
* make blockfrost API instance a parameter of the providers ([52b2bda](https://github.com/input-output-hk/cardano-js-sdk/commit/52b2bda4574cb9c7cacf2e3e02ced5ada2c58dd3))
98-
* move asset info type from Cardano to Asset ([212b670](https://github.com/input-output-hk/cardano-js-sdk/commit/212b67041598cbcc2c2cf4f5678928943de7aa29))
99-
* move jsonToMetadatum from blockfrost package to core.ProviderUtil ([adeb02c](https://github.com/input-output-hk/cardano-js-sdk/commit/adeb02cdbb1401ff4e9c43d28263357d6f27b0d6))
100-
* move stakePoolStats from wallet provider to stake pool provider ([52d71a7](https://github.com/input-output-hk/cardano-js-sdk/commit/52d71a70700b05902cca6205fe01a63f811ba5af))
101-
* remove TimeSettingsProvider and NetworkInfo.currentEpoch ([4a8f72f](https://github.com/input-output-hk/cardano-js-sdk/commit/4a8f72f57f699f7c0bf4a9a4b742fc0a3e4aa8ce))
102-
* remove transactions and blocks methods from blockfrost wallet provider ([e4de136](https://github.com/input-output-hk/cardano-js-sdk/commit/e4de13650f0d387b8e7126077e8721f353af8c85))
103-
* rename AssetInfo metadata->tokenMetadata ([f064f37](https://github.com/input-output-hk/cardano-js-sdk/commit/f064f372b3d7273c24d78695ceac7254fa55e51f))
104-
* rename AssetMetadata->TokenMetadata, update fields ([a83b897](https://github.com/input-output-hk/cardano-js-sdk/commit/a83b89748ec7efe7dcdbb849ab4b369dd49e5fcc))
105-
* rename some WalletProvider functions ([72ad875](https://github.com/input-output-hk/cardano-js-sdk/commit/72ad875ca8e9c3b65c23794a95ca4110cf34a034))
106-
* split up WalletProvider.utxoDelegationAndRewards ([18f5a57](https://github.com/input-output-hk/cardano-js-sdk/commit/18f5a571cb9d581007182b39d2c68b38491c70e6))
107-
108-
### 0.1.5 (2021-10-27)
109-
110-
111-
### Features
112-
113-
* add WalletProvider.transactionDetails, add address to TxIn ([889a39b](https://github.com/input-output-hk/cardano-js-sdk/commit/889a39b1feb988144dd2249c6c47f91e8096fd48))
114-
* **cardano-graphql:** implement CardanoGraphQLStakePoolSearchProvider (wip) ([80deda6](https://github.com/input-output-hk/cardano-js-sdk/commit/80deda6963a0c07b2f0b24a0a5465c488305d83c))
115-
116-
117-
### Bug Fixes
118-
119-
* **blockfrost:** early return from tallyPools function ([2ab1afc](https://github.com/input-output-hk/cardano-js-sdk/commit/2ab1afcce3f7b02b17352a8abe82b5adb17d8d52))
120-
* **blockfrost:** invalid handling of timestamp ([eed927c](https://github.com/input-output-hk/cardano-js-sdk/commit/eed927ce579426eef38a15797d2223e8df21a40f))
121-
122-
### 0.1.3 (2021-10-05)
123-
124-
### 0.1.2 (2021-09-30)
125-
126-
### 0.1.1 (2021-09-30)
127-
128-
129-
### Features
130-
131-
* add CardanoProvider.networkInfo ([1596ac2](https://github.com/input-output-hk/cardano-js-sdk/commit/1596ac27b3fa3494f784db37831f85e06a8e0e03))
132-
* add CardanoProvider.stakePoolStats ([c25e570](https://github.com/input-output-hk/cardano-js-sdk/commit/c25e5704be13a9c259fa399e35a3771caad58d38))
133-
* add maxTxSize to `ProtocolParametersRequiredByWallet` ([a9a5d16](https://github.com/input-output-hk/cardano-js-sdk/commit/a9a5d16db18fbf2a4cbbad1ad1cdf3f42ef891f9))
134-
* add Provider.ledgerTip ([0e7d224](https://github.com/input-output-hk/cardano-js-sdk/commit/0e7d224a8b3315991785a1a6393d60f35b757e6a))
135-
* **blockfrost:** create new provider called blockfrost ([b8bd72f](https://github.com/input-output-hk/cardano-js-sdk/commit/b8bd72ffc91769e525400a898cf8e7a749b7d610))
136-
* **cip-30:** create cip-30 package ([266e719](https://github.com/input-output-hk/cardano-js-sdk/commit/266e719d8c0b8550e05ff4d8da199a4575c0664e))
137-
* **core|blockfrost:** modify utxo method on provider to return delegations & rewards ([e0a1bf0](https://github.com/input-output-hk/cardano-js-sdk/commit/e0a1bf020c54d66d2c7920e21dc1369cfc912cbf))
138-
* **core:** add `currentWalletProtocolParameters` method to `CardanoProvider` ([af741c0](https://github.com/input-output-hk/cardano-js-sdk/commit/af741c073c48f7f5ad2f065fd50a48af741c133c))
139-
* create in-memory-key-manager package ([a819e5e](https://github.com/input-output-hk/cardano-js-sdk/commit/a819e5e2161a0cd6bd45c61825957efa810530d3))
140-
141-
142-
### Bug Fixes
143-
144-
* add missing yarn script, and rename ([840135f](https://github.com/input-output-hk/cardano-js-sdk/commit/840135f7d100c9a00ff410147758ee7d02112897))
145-
* blockfrost types ([4f77001](https://github.com/input-output-hk/cardano-js-sdk/commit/4f77001f5f6264bd6dd254c4e0ef0a8a14cfb820))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Cardano JS SDK | Blockfrost
1+
# Cardano JS SDK | Blockfrost Client

packages/blockfrost-client/package.json

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,60 @@
11
{
2-
"name": "@cardano-sdk/blockfrost",
3-
"version": "0.5.0",
4-
"description": "Blockfrost provider for Cardano JS SDK",
2+
"name": "@cardano-sdk/blockfrost-client",
3+
"version": "0.1.0",
4+
"description": "Blockfrost Client",
55
"engines": {
6-
"node": "^14"
6+
"node": ">=16.20.2"
77
},
88
"main": "dist/cjs/index.js",
99
"module": "dist/esm/index.js",
1010
"exports": {
1111
".": {
12+
"development": "./src/index.ts",
1213
"import": "./dist/esm/index.js",
1314
"require": "./dist/cjs/index.js"
1415
}
1516
},
17+
"sideEffects": false,
1618
"repository": "https://github.com/input-output-hk/cardano-js-sdk",
1719
"publishConfig": {
1820
"access": "public"
1921
},
20-
"contributors": [
21-
"Rhys Bartels-Waller <[email protected]> (https://iohk.io)",
22-
"Martynas Kazlauskas <[email protected]> (https://iohk.io)",
23-
"Daniele Ricci <[email protected]> (https://iohk.io)",
24-
"Ivaylo Andonov <[email protected]> (https://iohk.io)",
25-
"Mircea Hasegan <[email protected]> (https://iohk.io)",
26-
"Angel Castillo Bacigalupi <[email protected]> (https://iohk.io)",
27-
"Seung Eun Song <[email protected]> (https://iohk.io)",
28-
"Dmytro Iakymenko <[email protected]> (https://iohk.io)",
29-
"Tomislav Horaček <[email protected]> (https://iohk.io)",
30-
"Michael Chappell <[email protected]> (https://iohk.io)",
31-
"Leonel Gobbi <[email protected]> (https://www.globant.com)",
32-
"Juan Cruz Vieiro <[email protected]> (https://www.globant.com)"
33-
],
3422
"license": "Apache-2.0",
3523
"scripts": {
36-
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
37-
"build:cjs": "tsc --build src",
38-
"build": "run-s build:cjs build:esm module-fixup",
39-
"module-fixup": "shx cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
40-
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
41-
"cleanup:dist": "shx rm -rf dist",
42-
"cleanup:nm": "shx rm -rf node_modules",
43-
"cleanup": "run-s cleanup:dist cleanup:nm",
24+
"build": "yarn build:cjs && tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020 && tsc-alias -p src/tsconfig.json --outDir ./dist/esm && cp ../../build/esm-package.json ./dist/esm/package.json",
25+
"build:cjs": "yarn build:version && tsc --build src && cp ./package.json dist/ && cp ../../build/cjs-package.json ./dist/cjs/package.json",
26+
"tscNoEmit": "echo typescript --noEmit command not implemented yet",
27+
"cleanup:dist": "rm -rf dist",
28+
"circular-deps:check": "madge --circular dist/cjs",
29+
"cleanup:nm": "rm -rf node_modules",
30+
"cleanup": "rm -rf dist node_modules",
4431
"lint": "eslint -c ../../complete.eslintrc.js \"src/**/*.ts\" \"test/**/*.ts\"",
4532
"lint:fix": "yarn lint --fix",
46-
"test": "jest -c ./jest.config.js",
33+
"test": "yarn build:version && jest -c ./jest.config.js",
4734
"test:build:verify": "tsc --build ./test",
48-
"test:e2e": "shx echo 'test:e2e' command not implemented yet",
49-
"coverage": "shx echo No coverage report for this package",
50-
"prepack": "yarn build"
35+
"test:e2e": "echo 'test:e2e' command not implemented yet",
36+
"coverage": "yarn test --coverage || true",
37+
"prepack": "yarn build",
38+
"test:debug": "DEBUG=true yarn test"
5139
},
5240
"devDependencies": {
41+
"@cardano-sdk/util-dev": "workspace:~",
42+
"@types/validator": "^13.7.1",
5343
"eslint": "^7.32.0",
5444
"jest": "^28.1.3",
45+
"madge": "^5.0.1",
5546
"npm-run-all": "^4.1.5",
56-
"shx": "^0.3.3",
5747
"ts-jest": "^28.0.7",
48+
"tsc-alias": "^1.8.10",
5849
"typescript": "^4.7.4"
5950
},
6051
"dependencies": {
61-
"@blockfrost/blockfrost-js": "npm:[email protected]",
62-
"@cardano-sdk/core": "^0.5.0",
63-
"@cardano-sdk/util": "^0.5.0",
64-
"lodash": "^4.17.21",
52+
"@blockfrost/blockfrost-js": "5.5.0",
53+
"@cardano-sdk/core": "workspace:~",
54+
"@cardano-sdk/crypto": "workspace:~",
55+
"@cardano-sdk/util": "workspace:~",
56+
"class-validator": "^0.14.0",
57+
"json-bigint": "~1.0.0",
6558
"ts-log": "^2.2.4"
6659
},
6760
"files": [
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { argv, exit } = require('process');
4+
const { deepEqual } = require('assert');
5+
6+
const cardanoServicesSrc = path.join('..', '..', 'cardano-services', 'src');
7+
8+
const apiVersion = Object.fromEntries(
9+
Object.entries({
10+
assetInfo: 'Asset',
11+
chainHistory: 'ChainHistory',
12+
handle: 'Handle',
13+
networkInfo: 'NetworkInfo',
14+
rewards: 'Rewards',
15+
root: 'Http',
16+
stakePool: 'StakePool',
17+
txSubmit: 'TxSubmit',
18+
utxo: 'Utxo'
19+
}).map(([providerName, openApiDir]) => [
20+
providerName,
21+
require(path.join(cardanoServicesSrc, openApiDir, 'openApi.json')).info.version
22+
])
23+
);
24+
25+
const supportedVersionsFile = path.join(__dirname, '../supportedVersions.json');
26+
const sameMajorVersion = (a) => (b) => {
27+
const [majorA] = a.split('.');
28+
const [majorB] = b.split('.');
29+
return majorA === majorB;
30+
};
31+
const supportedVersions = (() => {
32+
let rv = {};
33+
if (fs.existsSync(supportedVersionsFile)) {
34+
const data = fs.readFileSync(supportedVersionsFile, { encoding: 'utf8' });
35+
rv = JSON.parse(data);
36+
}
37+
for (const [api, version] of Object.entries(apiVersion)) {
38+
const previouslySupported = rv[api] ?? [];
39+
rv[api] = previouslySupported.includes(apiVersion[api])
40+
? previouslySupported
41+
: [...previouslySupported.filter(sameMajorVersion(version)), version];
42+
}
43+
return rv;
44+
})();
45+
46+
const create = () => {
47+
fs.writeFileSync(supportedVersionsFile, `${JSON.stringify(supportedVersions, null, 2)}\n`, {
48+
encoding: 'utf8',
49+
flag: 'w'
50+
});
51+
const contents = `// auto-generated using ../scripts/createVersionSource.js
52+
export const apiVersion = ${JSON.stringify(apiVersion, null, 2)};
53+
`;
54+
fs.writeFileSync(path.join(__dirname, '../src/version.ts'), contents, { encoding: 'utf8', flag: 'w' });
55+
};
56+
57+
switch (argv[2]) {
58+
case '--check':
59+
try {
60+
deepEqual(JSON.parse(fs.readFileSync(supportedVersionsFile, { encoding: 'utf8' })), supportedVersions);
61+
exit(1);
62+
} catch {
63+
exit(0);
64+
}
65+
// eslint-disable-next-line no-fallthrough
66+
case '--create':
67+
create();
68+
break;
69+
default:
70+
// eslint-disable-next-line no-console
71+
console.error('Usage: createVersionSource [--check|--create]');
72+
exit(1);
73+
}

0 commit comments

Comments
 (0)