@fat-zebra/sdk 1.5.1 → 1.5.3-beta.1
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/.idea/fatzebra-js.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.dev.md +38 -0
- package/README.md +4 -1
- package/build-styles.js +8 -1
- package/dist/index.js +3 -2
- package/dist/sca/cardinal.js +1 -2
- package/dist/sca/index.js +0 -1
- package/dist/shared/util.d.ts +1 -1
- package/dist/shared/util.js +2 -2
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +7 -6
- package/scripts/release-package.js +113 -0
- package/tsconfig.package.json +2 -1
- package/dist/local/fatzebra.js.map +0 -1
- package/dist/local/index.html +0 -247
- package/dist/paypal/paypal-button.d.ts +0 -31
- package/dist/paypal/paypal-button.js +0 -199
- package/dist/paypal/paypal-checkout.d.ts +0 -21
- package/dist/paypal/paypal-checkout.js +0 -100
- package/dist/paypal/types.d.ts +0 -188
- package/dist/paypal/types.js +0 -5
- package/dist/paypal/validation.d.ts +0 -4
- package/dist/paypal/validation.js +0 -65
- package/dist/production/fatzebra.js.LICENSE.txt +0 -1
- package/dist/react/url.d.ts +0 -12
- package/dist/react/url.js +0 -33
- package/dist/src/applepay/applepay.js +0 -198
- package/dist/src/applepay/applepay.js.map +0 -1
- package/dist/src/applepay/clients/apple-pay-client.js +0 -66
- package/dist/src/applepay/clients/apple-pay-client.js.map +0 -1
- package/dist/src/applepay/clients/paynow-client.js +0 -96
- package/dist/src/applepay/clients/paynow-client.js.map +0 -1
- package/dist/src/applepay/index.js +0 -6
- package/dist/src/applepay/index.js.map +0 -1
- package/dist/src/click_to_pay/index.js +0 -88
- package/dist/src/click_to_pay/index.js.map +0 -1
- package/dist/src/click_to_pay/types.js +0 -3
- package/dist/src/click_to_pay/types.js.map +0 -1
- package/dist/src/hpp/hpp.js +0 -230
- package/dist/src/hpp/hpp.js.map +0 -1
- package/dist/src/hpp/hpp.test.js +0 -135
- package/dist/src/hpp/hpp.test.js.map +0 -1
- package/dist/src/hpp/index.js +0 -6
- package/dist/src/hpp/index.js.map +0 -1
- package/dist/src/index.js +0 -14
- package/dist/src/index.js.map +0 -1
- package/dist/src/main.js +0 -243
- package/dist/src/main.js.map +0 -1
- package/dist/src/main.test.js +0 -236
- package/dist/src/main.test.js.map +0 -1
- package/dist/src/paypal/paypal-button.js +0 -311
- package/dist/src/paypal/paypal-button.js.map +0 -1
- package/dist/src/paypal/paypal-button.test.js +0 -41
- package/dist/src/paypal/paypal-button.test.js.map +0 -1
- package/dist/src/paypal/paypal-checkout.js +0 -111
- package/dist/src/paypal/paypal-checkout.js.map +0 -1
- package/dist/src/paypal/paypal-checkout.test.js +0 -167
- package/dist/src/paypal/paypal-checkout.test.js.map +0 -1
- package/dist/src/paypal/types.js +0 -9
- package/dist/src/paypal/types.js.map +0 -1
- package/dist/src/paypal/validation.js +0 -73
- package/dist/src/paypal/validation.js.map +0 -1
- package/dist/src/react/VerifyCard.js +0 -29
- package/dist/src/react/VerifyCard.js.map +0 -1
- package/dist/src/react/index.js +0 -11
- package/dist/src/react/index.js.map +0 -1
- package/dist/src/react/submitForm.js +0 -13
- package/dist/src/react/submitForm.js.map +0 -1
- package/dist/src/react/url.js +0 -60
- package/dist/src/react/url.js.map +0 -1
- package/dist/src/react/url.test.js +0 -88
- package/dist/src/react/url.test.js.map +0 -1
- package/dist/src/react/useFatZebra.js +0 -119
- package/dist/src/react/useFatZebra.js.map +0 -1
- package/dist/src/sca/cardinal.js +0 -110
- package/dist/src/sca/cardinal.js.map +0 -1
- package/dist/src/sca/eci-mappings.js +0 -63
- package/dist/src/sca/eci-mappings.js.map +0 -1
- package/dist/src/sca/eci-mappings.test.js +0 -31
- package/dist/src/sca/eci-mappings.test.js.map +0 -1
- package/dist/src/sca/index.js +0 -363
- package/dist/src/sca/index.js.map +0 -1
- package/dist/src/sca/index.test.js +0 -620
- package/dist/src/sca/index.test.js.map +0 -1
- package/dist/src/sca/scenarios/enrollment.js +0 -161
- package/dist/src/sca/scenarios/enrollment.js.map +0 -1
- package/dist/src/sca/scenarios/index.js +0 -8
- package/dist/src/sca/scenarios/index.js.map +0 -1
- package/dist/src/sca/scenarios/validation.js +0 -139
- package/dist/src/sca/scenarios/validation.js.map +0 -1
- package/dist/src/sca/types.js +0 -57
- package/dist/src/sca/types.js.map +0 -1
- package/dist/src/shared/api-gateway-client.js +0 -184
- package/dist/src/shared/api-gateway-client.js.map +0 -1
- package/dist/src/shared/bridge-client.js +0 -24
- package/dist/src/shared/bridge-client.js.map +0 -1
- package/dist/src/shared/constants.js +0 -19
- package/dist/src/shared/constants.js.map +0 -1
- package/dist/src/shared/env.development.js +0 -12
- package/dist/src/shared/env.development.js.map +0 -1
- package/dist/src/shared/env.js +0 -46
- package/dist/src/shared/env.js.map +0 -1
- package/dist/src/shared/envs/local.js +0 -12
- package/dist/src/shared/envs/local.js.map +0 -1
- package/dist/src/shared/envs/production.js +0 -12
- package/dist/src/shared/envs/production.js.map +0 -1
- package/dist/src/shared/envs/sandbox.js +0 -12
- package/dist/src/shared/envs/sandbox.js.map +0 -1
- package/dist/src/shared/envs/staging.js +0 -12
- package/dist/src/shared/envs/staging.js.map +0 -1
- package/dist/src/shared/event-manager.js +0 -14
- package/dist/src/shared/event-manager.js.map +0 -1
- package/dist/src/shared/post-message-client.js +0 -107
- package/dist/src/shared/post-message-client.js.map +0 -1
- package/dist/src/shared/post-message-client.test.js +0 -58
- package/dist/src/shared/post-message-client.test.js.map +0 -1
- package/dist/src/shared/types.js +0 -47
- package/dist/src/shared/types.js.map +0 -1
- package/dist/src/shared/types.test.js +0 -55
- package/dist/src/shared/types.test.js.map +0 -1
- package/dist/src/shared/util.js +0 -96
- package/dist/src/shared/util.js.map +0 -1
- package/dist/src/shared/util.test.js +0 -148
- package/dist/src/shared/util.test.js.map +0 -1
- package/dist/src/validation/index.js +0 -12
- package/dist/src/validation/index.js.map +0 -1
- package/dist/src/validation/schemas/click-to-pay/load-params.json +0 -34
- package/dist/src/validation/schemas/click-to-pay/options.json +0 -23
- package/dist/src/validation/schemas/click-to-pay/payment-intent.json +0 -42
- package/dist/src/validation/schemas/customer.json +0 -38
- package/dist/src/validation/schemas/hpp-load-params.json +0 -40
- package/dist/src/validation/schemas/hpp-options.json +0 -48
- package/dist/src/validation/schemas/payment-intent.json +0 -48
- package/dist/src/validation/schemas/payment-method.json +0 -83
- package/dist/src/validation/schemas/verify-card-options.json +0 -15
- package/dist/src/validation/schemas/verify-card-params.json +0 -24
- package/dist/src/validation/validation-helper.js +0 -10
- package/dist/src/validation/validation-helper.js.map +0 -1
- package/dist/src/validation/validation-helper.test.js +0 -34
- package/dist/src/validation/validation-helper.test.js.map +0 -1
- package/dist/src/validation/validators/click-to-pay-load-params-validator.js +0 -19
- package/dist/src/validation/validators/click-to-pay-load-params-validator.js.map +0 -1
- package/dist/src/validation/validators/hpp-load-params-validator.js +0 -21
- package/dist/src/validation/validators/hpp-load-params-validator.js.map +0 -1
- package/dist/src/validation/validators/hpp-load-params-validator.test.js +0 -56
- package/dist/src/validation/validators/hpp-load-params-validator.test.js.map +0 -1
- package/dist/src/validation/validators/verify-card-params-validator.js +0 -23
- package/dist/src/validation/validators/verify-card-params-validator.js.map +0 -1
- package/dist/tests/helpers/api-gateway-mock.js +0 -37
- package/dist/tests/helpers/api-gateway-mock.js.map +0 -1
- /package/dist/{local/fatzebra.css → fatzebra.css} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/fatzebra-js.iml" filepath="$PROJECT_DIR$/.idea/fatzebra-js.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/README.dev.md
CHANGED
|
@@ -130,6 +130,39 @@ The deployed SDKs are available from the following URLs.
|
|
|
130
130
|
* Sandbox: https://cdn.pmnts-sandbox.io/sdk/v1/fatzebra.js
|
|
131
131
|
* Production: https://cdn.pmnts.io/sdk/v1/fatzebra.js
|
|
132
132
|
|
|
133
|
+
## Release react npm package
|
|
134
|
+
|
|
135
|
+
Prerequisite: it is essential that you have been added to the https://www.npmjs.com/ group account.
|
|
136
|
+
|
|
137
|
+
To release the react npm package
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
git checkout master
|
|
141
|
+
git pull
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
then run
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
npm run npm:publish
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
You will be prompted with:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
enter (y) for minor release or (n) for patch release
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
if it is a major release i.e. a breaking change please update the script/consult with management as major release would indicate a breaking change.
|
|
157
|
+
|
|
158
|
+
You will then see the project build and finally be prompted to:
|
|
159
|
+
```
|
|
160
|
+
Press ENTER to open in the browser...
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
from here enter your 2FA code and voila! You have published a new version of the SDK. Go tell some merchants.
|
|
164
|
+
|
|
165
|
+
|
|
133
166
|
## Release Management
|
|
134
167
|
|
|
135
168
|
The release of the sdk follows a weekly schedule. In the beginning of a new release cycle, do the following
|
|
@@ -147,3 +180,8 @@ The release of the sdk follows a weekly schedule. In the beginning of a new rele
|
|
|
147
180
|
11. Push git tag. `git push origin vX.X.X`.
|
|
148
181
|
|
|
149
182
|
Upon successful CI , a new entry with title 'Merged in release/vX.X,X' will be visible in the master branch page. This provides us with a clear view of what gets released in the past. Moreoever, we can quickly find out the list of features/bug fixes in a release by referring to the PR of the release candidate.
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## Rollback management
|
|
186
|
+
|
|
187
|
+
The CDN is now versioned across staging, sandbox and production environments. The pipeline will upload a version to override the existing deployment, but also a version of the build to a folder in s3. The folder will be a shortened version of the commit hash. This will allow us to advise merchants to rollback to a specific working commit hash, or for us to test different versions in gazelle to facilitate a rollback if necessary.
|
package/README.md
CHANGED
package/build-styles.js
CHANGED
|
@@ -3,7 +3,14 @@ const path = require('path');
|
|
|
3
3
|
|
|
4
4
|
// Define the source file and the destination folder
|
|
5
5
|
const sourceFile = path.join(__dirname, './src/styles.css');
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
let destinationFolder;
|
|
8
|
+
if (process.env.REACT) {
|
|
9
|
+
destinationFolder = path.join(__dirname, 'dist');
|
|
10
|
+
} else {
|
|
11
|
+
destinationFolder = path.join(__dirname, 'dist/' + process.env.ENVIRONMENT);
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
const destinationFile = path.join(destinationFolder, 'fatzebra.css');
|
|
8
15
|
|
|
9
16
|
// Copy the file
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "ts-polyfill";
|
|
2
2
|
import "custom-event-polyfill";
|
|
3
|
-
|
|
3
|
+
const FatZebra = require("./main").FatZebra;
|
|
4
4
|
import { PublicEvent } from "./shared/types";
|
|
5
5
|
import { Environment } from "./shared/env";
|
|
6
6
|
export { PublicEvent, Environment };
|
|
7
|
-
|
|
7
|
+
// Assign window.FatZebra conditionally
|
|
8
|
+
if (typeof window !== "undefined" && FatZebra) {
|
|
8
9
|
window.FatZebra = FatZebra;
|
|
9
10
|
}
|
package/dist/sca/cardinal.js
CHANGED
|
@@ -21,7 +21,7 @@ export const defaultConfig = {
|
|
|
21
21
|
timeout: 8000,
|
|
22
22
|
maxRequestRetries: 3,
|
|
23
23
|
logging: {
|
|
24
|
-
level: '
|
|
24
|
+
level: 'on'
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
export default class CardinalManager {
|
|
@@ -50,7 +50,6 @@ export default class CardinalManager {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
setup(jwt) {
|
|
53
|
-
console.log("CARDINAL SETUP", jwt);
|
|
54
53
|
window.Cardinal.setup(CardinalWorkflow.INIT, { jwt });
|
|
55
54
|
}
|
|
56
55
|
onPaymentValidated(handler) {
|
package/dist/sca/index.js
CHANGED
package/dist/shared/util.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ declare const toCamelCase: (s: string) => string;
|
|
|
2
2
|
declare const toSnakeCase: (s: string) => string;
|
|
3
3
|
declare const toObjectWithSnakeCaseKeys: (o: any) => any;
|
|
4
4
|
declare const toObjectWithCamelCaseKeys: (o: any) => any;
|
|
5
|
-
declare const getSdkVersionNumber: () =>
|
|
5
|
+
declare const getSdkVersionNumber: () => string;
|
|
6
6
|
export { toCamelCase, toSnakeCase, toObjectWithCamelCaseKeys, toObjectWithSnakeCaseKeys, getSdkVersionNumber, };
|
package/dist/shared/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { version } from '../version';
|
|
2
2
|
const toCamelCase = (s) => {
|
|
3
3
|
return s.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
4
4
|
};
|
|
@@ -77,6 +77,6 @@ const toObjectWithCamelCaseKeys = (o) => {
|
|
|
77
77
|
return converted;
|
|
78
78
|
};
|
|
79
79
|
const getSdkVersionNumber = () => {
|
|
80
|
-
return
|
|
80
|
+
return version;
|
|
81
81
|
};
|
|
82
82
|
export { toCamelCase, toSnakeCase, toObjectWithCamelCaseKeys, toObjectWithSnakeCaseKeys, getSdkVersionNumber, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.5.2";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = '1.5.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fat-zebra/sdk",
|
|
3
|
-
"version": "1.5.1",
|
|
3
|
+
"version": "1.5.3-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
"build:staging": "cp .env.staging .env && export ENVIRONMENT=staging && npx webpack --config webpack.config.dev.js && node build-styles.js",
|
|
10
10
|
"build:sandbox": "cp .env.sandbox .env && export ENVIRONMENT=sandbox && npx webpack --config webpack.config.prod.js && node build-styles.js",
|
|
11
11
|
"build:production": "cp .env.production .env && export ENVIRONMENT=production && npx webpack --config webpack.config.prod.js && node build-styles.js",
|
|
12
|
-
"build:package": "
|
|
12
|
+
"build:package": "tsc -p tsconfig.package.json && REACT=true ENVIRONMENT=production node build-styles.js",
|
|
13
13
|
"start:local:api": "export MERCHANT_MODE=api && npm run build:local --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
|
|
14
14
|
"start:local:hpp": "export MERCHANT_MODE=hpp && npm run build:local --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
|
|
15
15
|
"start:staging:api": "export MERCHANT_MODE=api && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
|
|
16
16
|
"start:staging:hpp": "export MERCHANT_MODE=hpp && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
|
|
17
17
|
"start:staging:es5": "export MERCHANT_MODE=es5 && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
|
|
18
18
|
"start:docker": "npm run build:dev --watch && webpack serve --config webpack.config.dev.js --host 0.0.0.0",
|
|
19
|
-
"generate:jwt": "node scripts/generate-access-token.js"
|
|
19
|
+
"generate:jwt": "node scripts/generate-access-token.js",
|
|
20
|
+
"npm:publish": "node scripts/release-package.js"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [],
|
|
22
23
|
"author": "",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"@types/nock": "^11.1.0",
|
|
31
32
|
"@types/react": "^18.2.15",
|
|
32
33
|
"@types/react-dom": "^18.2.7",
|
|
33
|
-
"audit-ci": "^
|
|
34
|
+
"audit-ci": "^6.6.1",
|
|
34
35
|
"dotenv": "^16.0.1",
|
|
35
36
|
"dotenv-webpack": "^8.0.0",
|
|
36
37
|
"ejs": "^3.0.1",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"ajv": "^6.12.3",
|
|
55
|
-
"axios": "^
|
|
56
|
+
"axios": "^1.6.4",
|
|
56
57
|
"custom-event-polyfill": "^1.0.7",
|
|
57
58
|
"ts-polyfill": "^3.8.2",
|
|
58
59
|
"url-template": "^3.1.0"
|
|
@@ -61,4 +62,4 @@
|
|
|
61
62
|
"react": ">= 16",
|
|
62
63
|
"react-dom": ">= 16"
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const shell = process.env.SHELL;
|
|
3
|
+
|
|
4
|
+
const readline = require('node:readline').createInterface({
|
|
5
|
+
input: process.stdin,
|
|
6
|
+
output: process.stdout,
|
|
7
|
+
});
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
/**
|
|
11
|
+
* Builds and publishes to npm (for production)
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function publish() {
|
|
15
|
+
console.log("running build...");
|
|
16
|
+
try {
|
|
17
|
+
// Running the command synchronously and inheriting the shell
|
|
18
|
+
execSync(`${shell} -c "npm run build:package && npm publish"`, { stdio: 'inherit' });
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// This will catch any errors that occur during the execution of the command
|
|
21
|
+
console.error(`Execution error: ${error}`);
|
|
22
|
+
console.error(`stderr: ${error.stderr}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Writes version number to package.json and to another file to read from
|
|
28
|
+
*
|
|
29
|
+
* @param {string} path - path to where the file will be written (package.json | version.ts).
|
|
30
|
+
* @param {string} content - content of file (version number).
|
|
31
|
+
*/
|
|
32
|
+
function writeToFile(path, content) {
|
|
33
|
+
fs.writeFileSync(path, content, 'utf8', (err) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
console.error('Error writing version to file:', err);
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`content: ${content} written to ${path}`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* take data from package.json and applies increment (depending on major/minor upgrade)
|
|
44
|
+
*
|
|
45
|
+
* @param {string} data - package.json data
|
|
46
|
+
* @param {string} releaseType - minor or major release
|
|
47
|
+
* @returns {Object|null} The updated package.json object with the incremented version, or null if parsing fails.
|
|
48
|
+
*/
|
|
49
|
+
function increment(data, releaseType) {
|
|
50
|
+
let packageJson;
|
|
51
|
+
try {
|
|
52
|
+
packageJson = JSON.parse(data);
|
|
53
|
+
} catch (parseErr) {
|
|
54
|
+
console.error('Error parsing package.json:', parseErr);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let [major, minor, patch] = packageJson.version.split('.').map(Number);
|
|
59
|
+
|
|
60
|
+
if (releaseType === 'minor') {
|
|
61
|
+
minor++;
|
|
62
|
+
patch = 0; // Reset patch version on minor update
|
|
63
|
+
} else {
|
|
64
|
+
patch++;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
packageJson.version = [major, minor, patch].join('.');
|
|
68
|
+
return packageJson
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Increments the version number in package.json based on the release type.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} releaseType - The type of release (minor or patch).
|
|
75
|
+
*/
|
|
76
|
+
function incrementAndPublish(releaseType) {
|
|
77
|
+
const packagePath = path.join(__dirname, '../package.json');
|
|
78
|
+
const versionPath = path.join(__dirname, '../src/version.ts')
|
|
79
|
+
fs.readFile(packagePath, 'utf8', (err, data) => {
|
|
80
|
+
if (err) {
|
|
81
|
+
console.error('Error reading package.json:', err);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let packageJson = increment(data, releaseType)
|
|
86
|
+
|
|
87
|
+
writeToFile(packagePath, JSON.stringify(packageJson, null, 2))
|
|
88
|
+
const fileContent = `export const version = '${packageJson.version}';\n`;
|
|
89
|
+
writeToFile(versionPath, fileContent)
|
|
90
|
+
publish()
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Asks the user whether the release is a minor release or a patch.
|
|
96
|
+
*/
|
|
97
|
+
function askReleaseType() {
|
|
98
|
+
readline.question(`enter (y) for minor release or (n) for patch release `, releaseType => {
|
|
99
|
+
releaseType = releaseType.trim().toLowerCase();
|
|
100
|
+
|
|
101
|
+
if (releaseType === 'y') {
|
|
102
|
+
incrementAndPublish('minor');
|
|
103
|
+
} else if (releaseType === 'n') {
|
|
104
|
+
incrementAndPublish('patch');
|
|
105
|
+
} else {
|
|
106
|
+
console.log("Please answer 'y' (yes) or 'n' (no).");
|
|
107
|
+
askReleaseType(); // Recursively ask again if the input is not y/n
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
askReleaseType();
|
|
113
|
+
|
package/tsconfig.package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"declaration": true,
|
|
4
4
|
"outDir": "./dist/",
|
|
5
5
|
"jsx": "react",
|
|
6
|
+
"skipLibCheck": true,
|
|
6
7
|
"esModuleInterop": true,
|
|
7
8
|
"sourceMap": false,
|
|
8
9
|
"noImplicitAny": true,
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"isolatedModules": true,
|
|
17
18
|
},
|
|
18
19
|
"include": [
|
|
19
|
-
"./src/**/*"
|
|
20
|
+
"./src/**/*",
|
|
20
21
|
],
|
|
21
22
|
"exclude": [
|
|
22
23
|
"node_modules",
|