@fat-zebra/sdk 1.5.0 → 1.5.2

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.
@@ -18,7 +18,7 @@
18
18
  "properties": {
19
19
  "amount": {
20
20
  "type": "number",
21
- "minimum": 0.01
21
+ "minimum": 0
22
22
  },
23
23
  "currency": {
24
24
  "type": "string"
@@ -0,0 +1 @@
1
+ export declare const version = "1.5.2";
@@ -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.0",
3
+ "version": "1.5.2",
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": "yarn tsc -p tsconfig.package.json && node build-styles.js",
12
+ "build:package": "tsc -p tsconfig.package.json && 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": "^3.0.0",
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": "^0.21.1",
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/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # CHANGELOG
2
-
3
- v1.2.1
4
- * PAY-1731: Provide merchant username in API request headers.
5
-
6
- v1.2.0
7
- * FEAT-43: Emit HPP form validation error messages via events
8
-
9
- v1.1.5
10
- * PAY-1710: Update README and include jwt generation script
11
-
12
- v1.1.4 (Rolled back. Scheduled for later release.)
13
- * PAY-1568: Conditionally require customer object depending on enableSca