@dev-blinq/cucumber-js 1.0.30 → 1.0.32

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.
@@ -0,0 +1,131 @@
1
+ const { argv } = require('node:process')
2
+ const fs = require('fs')
3
+ const path = require('path')
4
+ const JSZip = require('jszip')
5
+ const { mkdirSync, writeFileSync } = require('node:fs')
6
+ const axios = require('axios').default
7
+ let token = null
8
+ let extractPath = null
9
+ const getSSoUrl = () => {
10
+ switch (process.env.NODE_ENV_BLINQ) {
11
+ case 'local':
12
+ return 'http://localhost:5000/api/auth'
13
+ case 'dev':
14
+ return 'https://dev.api.blinq.io/api/auth'
15
+ default:
16
+ return 'https://api.blinq.io/api/auth'
17
+ }
18
+ }
19
+
20
+ const getWorkSpaceUrl = () => {
21
+ switch (process.env.NODE_ENV_BLINQ) {
22
+ case 'local':
23
+ return 'http://localhost:6000/api/workspace'
24
+ case 'dev':
25
+ return 'https://dev.api.blinq.io/api/workspace'
26
+ default:
27
+ return 'https://api.blinq.io/api/workspace'
28
+ }
29
+ }
30
+
31
+ for (let i = 2; i < argv.length; i++) {
32
+ const arg = argv[i]
33
+ switch (arg) {
34
+ case '--token':
35
+ if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
36
+ token = argv[++i]
37
+ } else {
38
+ console.error('Error: --token argument provided without a token.')
39
+ process.exit(1)
40
+ }
41
+ break
42
+ case '--extractPath':
43
+ if (i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
44
+ extractPath = argv[++i]
45
+ } else {
46
+ console.error('Error: --extractPath argument provided without a path.')
47
+ process.exit(1)
48
+ }
49
+ break
50
+ default:
51
+ console.error(`Unexpected argument: ${arg}`)
52
+ process.exit(1)
53
+ }
54
+ }
55
+
56
+ if (token === null || token === undefined || token === '') {
57
+ console.error('Error: --token argument not provided')
58
+ process.exit(1)
59
+ }
60
+ if (extractPath === '' || extractPath === null || extractPath === undefined) {
61
+ console.error('Error: --extractPath argument not provided')
62
+ process.exit(1)
63
+ }
64
+ const dirExists = (path) => {
65
+ try {
66
+ return fs.statSync(path).isDirectory()
67
+ } catch (e) {
68
+ if (e.code == 'ENOENT') {
69
+ // no such file or directory. File really does not exist
70
+ console.log('Not a valid directory: ' + path)
71
+ return false
72
+ }
73
+
74
+ console.log('Exception fs.statSync (' + path + '): ' + e)
75
+ throw e // something else went wrong, we don't have rights, ...
76
+ }
77
+ }
78
+ const ssoUrl = getSSoUrl()
79
+
80
+ const downloadAndInstall = async (extractPath, token) => {
81
+ if (!dirExists(extractPath)) {
82
+ console.error('Invalid directory path')
83
+ process.exit(1)
84
+ }
85
+ try {
86
+ const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`
87
+ const response = await axios.post(accessKeyUrl, {
88
+ access_key: token,
89
+ })
90
+ if(response.data.status !== true){
91
+ console.error('Error: Invalid access key')
92
+ process.exit(1)
93
+ }
94
+
95
+ const workspaceUrl = getWorkSpaceUrl() + '/pull-workspace'
96
+
97
+ const res = await axios.get(workspaceUrl, {
98
+ params: {
99
+ projectId: response.data.project._id,
100
+ },
101
+ responseType: 'arraybuffer',
102
+ headers: {
103
+ Authorization: `Bearer ${token}`,
104
+ 'Response-Type': 'arraybuffer',
105
+ },
106
+ })
107
+ if(res.data.status !== true){
108
+ console.error('Error: Download failed')
109
+ process.exit(1)
110
+ }
111
+
112
+ const zip = await JSZip.loadAsync(res.data)
113
+ for (const filename of Object.keys(zip.files)) {
114
+ const fileData = zip.files[filename]
115
+ if (!fileData.dir) {
116
+ const content = await fileData.async('nodebuffer')
117
+ const filePath = path.join(extractPath, filename)
118
+ mkdirSync(path.dirname(filePath), { recursive: true })
119
+ writeFileSync(filePath, content)
120
+ }
121
+ }
122
+
123
+ console.log('Extraction completed to:', extractPath)
124
+ } catch (error) {
125
+ console.error('Error:', error)
126
+ }
127
+ }
128
+
129
+ downloadAndInstall(extractPath, token).then(() =>
130
+ console.log('Download completed!')
131
+ )
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.0.30";
1
+ export declare const version = "1.0.32";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '1.0.30';
5
+ exports.version = '1.0.32';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.30'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.32'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "1.0.30",
11
+ "version": "1.0.32",
12
12
  "homepage": "https://github.com/blinq-io/cucumber-js",
13
13
  "author": "blinq.io",
14
14
  "contributors": [
@@ -182,7 +182,8 @@
182
182
  "update-dependencies": "npx npm-check-updates --upgrade"
183
183
  },
184
184
  "bin": {
185
- "cucumber-js": "bin/cucumber.js"
185
+ "cucumber-js": "bin/cucumber.js",
186
+ "download-install": "bin/download-install.js"
186
187
  },
187
188
  "license": "MIT",
188
189
  "files": [