jitsu-cli 0.9.1 → 1.2.0-canary.231.20230920065613
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/.turbo/turbo-build.log +112 -0
- package/LICENSE +1 -1
- package/babel.config.cjs +4 -0
- package/bin/jitsu-cli +1 -1
- package/compiled/package.json +66 -0
- package/compiled/src/commands/build.js +55 -0
- package/compiled/src/commands/deploy.js +124 -0
- package/compiled/src/commands/init.js +38 -0
- package/compiled/src/commands/login.js +94 -0
- package/compiled/src/commands/run.js +87 -0
- package/compiled/src/commands/shared.js +26 -0
- package/{lib/cli/extension → compiled/src/commands}/template.js +10 -11
- package/compiled/src/commands/test.js +15 -0
- package/compiled/src/index.js +49 -0
- package/{lib → compiled/src}/lib/chalk-code-highlight.js +0 -1
- package/{lib → compiled/src}/lib/errors.js +0 -1
- package/{lib → compiled/src}/lib/indent.js +0 -1
- package/{lib → compiled/src}/lib/log.js +7 -7
- package/{lib → compiled/src}/lib/template.js +1 -2
- package/{lib → compiled/src}/lib/version.js +1 -3
- package/compiled/src/templates/functions.js +67 -0
- package/dist/10546bf325e211cf9719.js +886 -0
- package/dist/1463a26331df3b0b4d694b076097b2dd.node +0 -0
- package/dist/230.js +4890 -0
- package/dist/230.js.map +1 -0
- package/dist/535.js +112 -0
- package/dist/535.js.map +1 -0
- package/dist/718.js +452 -0
- package/dist/718.js.map +1 -0
- package/dist/main.js +350126 -0
- package/dist/main.js.map +1 -0
- package/package.json +53 -64
- package/src/commands/build.ts +63 -0
- package/src/commands/deploy.ts +126 -0
- package/src/commands/init.ts +45 -0
- package/src/commands/login.ts +91 -0
- package/src/commands/run.ts +85 -0
- package/src/commands/shared.ts +26 -0
- package/src/commands/test.ts +16 -0
- package/src/index.ts +69 -0
- package/src/lib/chalk-code-highlight.ts +46 -0
- package/src/lib/indent.ts +42 -0
- package/src/lib/template.ts +37 -0
- package/src/lib/version.ts +35 -0
- package/src/templates/functions.ts +73 -0
- package/tsconfig.json +28 -0
- package/webpack.config.js +43 -0
- package/README.md +0 -11
- package/bin/jiu +0 -3
- package/lib/cli/cli.d.ts +0 -1
- package/lib/cli/cli.js +0 -308
- package/lib/cli/cli.js.map +0 -1
- package/lib/cli/config/index.d.ts +0 -12
- package/lib/cli/config/index.js +0 -3
- package/lib/cli/config/index.js.map +0 -1
- package/lib/cli/extension/build.d.ts +0 -3
- package/lib/cli/extension/build.js +0 -142
- package/lib/cli/extension/build.js.map +0 -1
- package/lib/cli/extension/create.d.ts +0 -3
- package/lib/cli/extension/create.js +0 -89
- package/lib/cli/extension/create.js.map +0 -1
- package/lib/cli/extension/exec.d.ts +0 -7
- package/lib/cli/extension/exec.js +0 -350
- package/lib/cli/extension/exec.js.map +0 -1
- package/lib/cli/extension/index.d.ts +0 -6
- package/lib/cli/extension/index.js +0 -66
- package/lib/cli/extension/index.js.map +0 -1
- package/lib/cli/extension/template.d.ts +0 -30
- package/lib/cli/extension/template.js.map +0 -1
- package/lib/cli/extension/test.d.ts +0 -3
- package/lib/cli/extension/test.js +0 -35
- package/lib/cli/extension/test.js.map +0 -1
- package/lib/cli/extension/validate-config.d.ts +0 -3
- package/lib/cli/extension/validate-config.js +0 -62
- package/lib/cli/extension/validate-config.js.map +0 -1
- package/lib/cli/router.d.ts +0 -24
- package/lib/cli/router.js +0 -135
- package/lib/cli/router.js.map +0 -1
- package/lib/config-store.d.ts +0 -16
- package/lib/config-store.js +0 -73
- package/lib/config-store.js.map +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +0 -1
- package/lib/lib/chalk-code-highlight.d.ts +0 -14
- package/lib/lib/chalk-code-highlight.js.map +0 -1
- package/lib/lib/command/index.d.ts +0 -3
- package/lib/lib/command/index.js +0 -120
- package/lib/lib/command/index.js.map +0 -1
- package/lib/lib/errors.d.ts +0 -1
- package/lib/lib/errors.js.map +0 -1
- package/lib/lib/indent.d.ts +0 -9
- package/lib/lib/indent.js.map +0 -1
- package/lib/lib/log.d.ts +0 -8
- package/lib/lib/log.js.map +0 -1
- package/lib/lib/template.d.ts +0 -5
- package/lib/lib/template.js.map +0 -1
- package/lib/lib/validation.d.ts +0 -2
- package/lib/lib/validation.js +0 -24
- package/lib/lib/validation.js.map +0 -1
- package/lib/lib/version.d.ts +0 -5
- package/lib/lib/version.js.map +0 -1
- package/lib/model/destination.json +0 -123
- package/lib/model/stream.json +0 -44
- package/lib/package.json +0 -77
- package/lib/tests.d.ts +0 -2
- package/lib/tests.js +0 -11
- package/lib/tests.js.map +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
jitsu-cli:build: cache hit, replaying output [2m2dfdb8ce978d7167[0m
|
|
2
|
+
[35mjitsu-cli:build: [0m
|
|
3
|
+
[35mjitsu-cli:build: [0m> jitsu-cli@0.0.0 build /Users/ildarnurislamov/Projects/newjitsu/cli/jitsu-cli
|
|
4
|
+
[35mjitsu-cli:build: [0m> pnpm compile && webpack
|
|
5
|
+
[35mjitsu-cli:build: [0m
|
|
6
|
+
[35mjitsu-cli:build: [0m
|
|
7
|
+
[35mjitsu-cli:build: [0m> jitsu-cli@0.0.0 compile /Users/ildarnurislamov/Projects/newjitsu/cli/jitsu-cli
|
|
8
|
+
[35mjitsu-cli:build: [0m> rm -rf ./dist && tsc -p .
|
|
9
|
+
[35mjitsu-cli:build: [0m
|
|
10
|
+
[35mjitsu-cli:build: [0masset main.js 14.6 MiB [emitted] (name: main) 1 related asset
|
|
11
|
+
[35mjitsu-cli:build: [0masset 1463a26331df3b0b4d694b076097b2dd.node 144 KiB [emitted]
|
|
12
|
+
[35mjitsu-cli:build: [0masset 230.js 130 KiB [emitted] (id hint: vendors) 1 related asset
|
|
13
|
+
[35mjitsu-cli:build: [0masset 10546bf325e211cf9719.js 36.9 KiB [emitted] [immutable] [from: ../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.3_rollup@3.29.1_tslib@2.6.2_typescript@5.2.2/node_modules/@rollup/plugin-typescript/dist/es/index.js] (auxiliary name: main)
|
|
14
|
+
[35mjitsu-cli:build: [0masset 718.js 10 KiB [emitted] 1 related asset
|
|
15
|
+
[35mjitsu-cli:build: [0masset 535.js 2.97 KiB [emitted] 1 related asset
|
|
16
|
+
[35mjitsu-cli:build: [0morphan modules 1.26 MiB [orphan] 179 modules
|
|
17
|
+
[35mjitsu-cli:build: [0mruntime modules 3.62 KiB 10 modules
|
|
18
|
+
[35mjitsu-cli:build: [0mcacheable modules 13.2 MiB (javascript) 36.9 KiB (asset)
|
|
19
|
+
[35mjitsu-cli:build: [0m javascript modules 12.6 MiB 938 modules
|
|
20
|
+
[35mjitsu-cli:build: [0m json modules 668 KiB
|
|
21
|
+
[35mjitsu-cli:build: [0m modules by path ../../node_modules/.pnpm/iconv-lite@0.4.24/node_modules/iconv-lite/ 86.7 KiB 8 modules
|
|
22
|
+
[35mjitsu-cli:build: [0m + 9 modules
|
|
23
|
+
[35mjitsu-cli:build: [0m ../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.3_rollup@3.29.1_tslib@2....(truncated) 42 bytes (javascript) 36.9 KiB (asset) [built] [code generated]
|
|
24
|
+
[35mjitsu-cli:build: [0moptional modules 488 bytes [optional]
|
|
25
|
+
[35mjitsu-cli:build: [0m modules by path ../../node_modules/.pnpm/ 320 bytes
|
|
26
|
+
[35mjitsu-cli:build: [0m ../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/ sync 160 bytes [optional] [built] [code generated]
|
|
27
|
+
[35mjitsu-cli:build: [0m ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/ sync 160 bytes [optional] [built] [code generated]
|
|
28
|
+
[35mjitsu-cli:build: [0m + 4 modules
|
|
29
|
+
[35mjitsu-cli:build: [0m+ 36 modules
|
|
30
|
+
[35mjitsu-cli:build: [0m
|
|
31
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/express@4.18.2/node_modules/express/lib/view.js 81:13-25
|
|
32
|
+
[35mjitsu-cli:build: [0mCritical dependency: the request of a dependency is an expression
|
|
33
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/express@4.18.2/node_modules/express/lib/application.js 22:11-28
|
|
34
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/express@4.18.2/node_modules/express/lib/express.js 18:12-36
|
|
35
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/express@4.18.2/node_modules/express/index.js 11:0-41
|
|
36
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/login.ts 7:0-30 44:18-25
|
|
37
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 3:0-41 19:287-292
|
|
38
|
+
[35mjitsu-cli:build: [0m
|
|
39
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/deps.js 22:4-42
|
|
40
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve 'kerberos' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
41
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 105:13-30
|
|
42
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
43
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
44
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
45
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
46
|
+
[35mjitsu-cli:build: [0m
|
|
47
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/deps.js 27:4-51
|
|
48
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve '@mongodb-js/zstd' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
49
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 105:13-30
|
|
50
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
51
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
52
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
53
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
54
|
+
[35mjitsu-cli:build: [0m
|
|
55
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/deps.js 33:35-75
|
|
56
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve '@aws-sdk/credential-providers' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
57
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 105:13-30
|
|
58
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
59
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
60
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
61
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
62
|
+
[35mjitsu-cli:build: [0m
|
|
63
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/deps.js 45:4-38
|
|
64
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve 'snappy' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
65
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 105:13-30
|
|
66
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
67
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
68
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
69
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
70
|
+
[35mjitsu-cli:build: [0m
|
|
71
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/deps.js 58:4-34
|
|
72
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve 'aws4' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
73
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 105:13-30
|
|
74
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
75
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
76
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
77
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
78
|
+
[35mjitsu-cli:build: [0m
|
|
79
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/utils.js 949:38-93
|
|
80
|
+
[35mjitsu-cli:build: [0mCritical dependency: the request of a dependency is an expression
|
|
81
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/change_stream.js 11:16-34
|
|
82
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 12:24-50
|
|
83
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
84
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
85
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
86
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
87
|
+
[35mjitsu-cli:build: [0m
|
|
88
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/utils.js 960:38-74
|
|
89
|
+
[35mjitsu-cli:build: [0mModule not found: Error: Can't resolve 'mongodb-client-encryption' in '/Users/ildarnurislamov/Projects/newjitsu/node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib'
|
|
90
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/change_stream.js 11:16-34
|
|
91
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/mongodb@5.2.0/node_modules/mongodb/lib/index.js 12:24-50
|
|
92
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/functions/lib/mongodb.ts 12:0-48 28:23-34 91:32-40
|
|
93
|
+
[35mjitsu-cli:build: [0m @ ../../libs/core-functions/src/index.ts 59:0-77 59:0-77 59:0-77
|
|
94
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/run.ts 12:0-51 44:17-27
|
|
95
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 8:0-37 18:718-721
|
|
96
|
+
[35mjitsu-cli:build: [0m
|
|
97
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/typescript.js 3098:22-44
|
|
98
|
+
[35mjitsu-cli:build: [0mCritical dependency: the request of a dependency is an expression
|
|
99
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.3_rollup@3.29.1_tslib@2.6.2_typescript@5.2.2/node_modules/@rollup/plugin-typescript/dist/es/index.js 4:0-38 108:34-46 226:59-71 488:23-35 597:31-43
|
|
100
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/build.ts 9:0-51 33:27-37
|
|
101
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 6:0-41 16:166-171
|
|
102
|
+
[35mjitsu-cli:build: [0m
|
|
103
|
+
[35mjitsu-cli:build: [0mWARNING in ../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/typescript.js 6269:35-54
|
|
104
|
+
[35mjitsu-cli:build: [0mCritical dependency: the request of a dependency is an expression
|
|
105
|
+
[35mjitsu-cli:build: [0m @ ../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.3_rollup@3.29.1_tslib@2.6.2_typescript@5.2.2/node_modules/@rollup/plugin-typescript/dist/es/index.js 4:0-38 108:34-46 226:59-71 488:23-35 597:31-43
|
|
106
|
+
[35mjitsu-cli:build: [0m @ ./src/commands/build.ts 9:0-51 33:27-37
|
|
107
|
+
[35mjitsu-cli:build: [0m @ ./src/index.ts 6:0-41 16:166-171
|
|
108
|
+
[35mjitsu-cli:build: [0m
|
|
109
|
+
[35mjitsu-cli:build: [0m10 warnings have detailed information that is not shown.
|
|
110
|
+
[35mjitsu-cli:build: [0mUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
|
|
111
|
+
[35mjitsu-cli:build: [0m
|
|
112
|
+
[35mjitsu-cli:build: [0mwebpack 5.88.2 compiled with 10 warnings in 8165 ms
|
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/babel.config.cjs
ADDED
package/bin/jitsu-cli
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jitsu-cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "Jitsu Dev Team <dev@jitsu.com>",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"bin": "./bin/jitsu-cli",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"private": false,
|
|
12
|
+
"scripts": {
|
|
13
|
+
"compile": "rm -rf ./dist && tsc -p . ",
|
|
14
|
+
"build": "pnpm compile && webpack",
|
|
15
|
+
"run": "node dist/main.js"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"express": "^4.18.2",
|
|
19
|
+
"etag": "^1.8.1",
|
|
20
|
+
"open": "^9.1.0",
|
|
21
|
+
"chalk": "^5.3.0",
|
|
22
|
+
"prismjs": "^1.29.0",
|
|
23
|
+
"semver": "^7.5.4",
|
|
24
|
+
"inquirer": "^9.2.11",
|
|
25
|
+
"figlet": "^1.6.0",
|
|
26
|
+
"commander": "^11.0.0",
|
|
27
|
+
"tslib": "^2.6.2",
|
|
28
|
+
"cross-fetch": "^4.0.0",
|
|
29
|
+
"juava": "workspace:*",
|
|
30
|
+
"@rollup/plugin-typescript": "^11.1.3",
|
|
31
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
32
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
34
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
35
|
+
"rollup": "^3.29.1",
|
|
36
|
+
"jest": "^29.7.0",
|
|
37
|
+
"jest-cli": "^29.7.0",
|
|
38
|
+
"ts-jest": "^29.1.1",
|
|
39
|
+
"@jitsu/core-functions": "workspace:*",
|
|
40
|
+
"node-fetch": "^3.3.2",
|
|
41
|
+
"vm2": "^3.9.19",
|
|
42
|
+
"@swc/core": "^1.3.40",
|
|
43
|
+
"@swc/wasm": "^1.3.40",
|
|
44
|
+
"json5": "^2.2.3",
|
|
45
|
+
"cuid": "^2.1.8"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "^5.2.2",
|
|
49
|
+
"@babel/preset-env": "^7.22.15",
|
|
50
|
+
"@babel/preset-typescript": "^7.22.15",
|
|
51
|
+
"@types/node": "^18.15.3",
|
|
52
|
+
"@types/jest": "^29.5.5",
|
|
53
|
+
"@types/express": "^4.17.17",
|
|
54
|
+
"@types/chalk": "^2.2.0",
|
|
55
|
+
"@types/inquirer": "^9.0.3",
|
|
56
|
+
"@types/commander": "^2.12.2",
|
|
57
|
+
"@types/lodash": "^4.14.198",
|
|
58
|
+
"webpack": "^5.88.2",
|
|
59
|
+
"webpack-cli": "^5.1.4",
|
|
60
|
+
"@types/webpack": "^5.28.2",
|
|
61
|
+
"@webpack-cli/generators": "^3.0.7",
|
|
62
|
+
"babel-loader": "^9.1.3",
|
|
63
|
+
"node-loader": "^2.0.0",
|
|
64
|
+
"ts-loader": "^9.4.4"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const plugin_typescript_1 = tslib_1.__importDefault(require("@rollup/plugin-typescript"));
|
|
9
|
+
const plugin_node_resolve_1 = tslib_1.__importDefault(require("@rollup/plugin-node-resolve"));
|
|
10
|
+
const plugin_commonjs_1 = tslib_1.__importDefault(require("@rollup/plugin-commonjs"));
|
|
11
|
+
const plugin_json_1 = tslib_1.__importDefault(require("@rollup/plugin-json"));
|
|
12
|
+
const rollup_1 = require("rollup");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const shared_1 = require("./shared");
|
|
15
|
+
async function build({ dir }) {
|
|
16
|
+
const projectDir = dir || process.cwd();
|
|
17
|
+
console.log(`Building project in ${chalk_1.default.bold(projectDir)}`);
|
|
18
|
+
const packageJson = (0, shared_1.loadPackageJson)(projectDir);
|
|
19
|
+
const indexFile = path_1.default.resolve(projectDir, "src/index.ts");
|
|
20
|
+
process.chdir(projectDir);
|
|
21
|
+
const tsconfigPath = path_1.default.resolve(projectDir, "tsconfig.json");
|
|
22
|
+
if (!(0, fs_1.existsSync)(tsconfigPath)) {
|
|
23
|
+
(0, fs_1.writeFileSync)(tsconfigPath, "{}");
|
|
24
|
+
}
|
|
25
|
+
const rollupPlugins = [
|
|
26
|
+
(0, plugin_typescript_1.default)(),
|
|
27
|
+
(0, plugin_node_resolve_1.default)({ preferBuiltins: false }),
|
|
28
|
+
(0, plugin_commonjs_1.default)(),
|
|
29
|
+
(0, plugin_json_1.default)(),
|
|
30
|
+
];
|
|
31
|
+
const bundle = await (0, rollup_1.rollup)({
|
|
32
|
+
input: [indexFile],
|
|
33
|
+
plugins: rollupPlugins,
|
|
34
|
+
});
|
|
35
|
+
let format = "es";
|
|
36
|
+
let output = await bundle.generate({
|
|
37
|
+
dir: projectDir,
|
|
38
|
+
format: format,
|
|
39
|
+
});
|
|
40
|
+
(0, fs_1.mkdirSync)(path_1.default.resolve(projectDir, "dist"), { recursive: true });
|
|
41
|
+
(0, fs_1.writeFileSync)(path_1.default.resolve(projectDir, "dist/index.js"), output.output[0].code);
|
|
42
|
+
console.log(`\nBuild finished.`);
|
|
43
|
+
}
|
|
44
|
+
exports.build = build;
|
|
45
|
+
const run = async (cmd) => {
|
|
46
|
+
const child = (0, child_process_1.exec)(cmd, err => {
|
|
47
|
+
if (err) {
|
|
48
|
+
console.error(err);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
child.stdout?.pipe(process.stdout);
|
|
53
|
+
child.stderr?.pipe(process.stderr);
|
|
54
|
+
return new Promise(resolve => child.on("close", resolve));
|
|
55
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deploy = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const os_1 = require("os");
|
|
8
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
9
|
+
const cuid_1 = tslib_1.__importDefault(require("cuid"));
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const shared_1 = require("./shared");
|
|
12
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
13
|
+
async function deploy({ dir, workspace }) {
|
|
14
|
+
const projectDir = dir || process.cwd();
|
|
15
|
+
console.log(`Deploying ${chalk_1.default.bold(projectDir)}`);
|
|
16
|
+
const packageJson = (0, shared_1.loadPackageJson)(projectDir);
|
|
17
|
+
const configFile = `${(0, os_1.homedir)()}/.jitsu/jitsu-cli.json`;
|
|
18
|
+
if (!(0, fs_1.existsSync)(configFile)) {
|
|
19
|
+
console.error(`${chalk_1.default.red("Please login first.")}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const { host, apikey } = JSON.parse((0, fs_1.readFileSync)(configFile, "utf-8"));
|
|
23
|
+
const res = await (0, node_fetch_1.default)(`${host}/api/workspace`, {
|
|
24
|
+
method: "GET",
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${apikey}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (!res.ok) {
|
|
30
|
+
console.error(`${chalk_1.default.red("Cannot get workspace list:")}\n${chalk_1.default.bold(await res.text())}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const workspaces = (await res.json());
|
|
34
|
+
let workspaceId = workspace;
|
|
35
|
+
if (!workspace) {
|
|
36
|
+
if (workspaces.length === 0) {
|
|
37
|
+
console.error(`${chalk_1.default.red("No workspaces found")}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
else if (workspaces.length === 1) {
|
|
41
|
+
workspaceId = workspaces[0].id;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
workspaceId = (await inquirer_1.default.prompt([
|
|
45
|
+
{
|
|
46
|
+
type: "list",
|
|
47
|
+
name: "workspaceId",
|
|
48
|
+
message: `Select workspace:`,
|
|
49
|
+
choices: workspaces.map(w => ({
|
|
50
|
+
name: w.name,
|
|
51
|
+
value: w.id,
|
|
52
|
+
})),
|
|
53
|
+
},
|
|
54
|
+
])).workspaceId;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const workspaceName = workspaces.find(w => w.id === workspaceId)?.name;
|
|
58
|
+
if (!workspaceId || !workspaceName) {
|
|
59
|
+
console.error(`${chalk_1.default.red(`Workspace with id ${workspaceId} not found`)}`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
console.log(chalk_1.default.bold(`Deploying function to workspace '${workspaceName}'`));
|
|
63
|
+
let existingFunctionId;
|
|
64
|
+
const jitsuJsonPath = path_1.default.resolve(projectDir, "jitsu.json");
|
|
65
|
+
let jitsuJson = {};
|
|
66
|
+
if ((0, fs_1.existsSync)(jitsuJsonPath)) {
|
|
67
|
+
jitsuJson = JSON.parse((0, fs_1.readFileSync)(path_1.default.resolve(projectDir, "jitsu.json"), "utf-8"));
|
|
68
|
+
existingFunctionId = jitsuJson[workspaceId];
|
|
69
|
+
}
|
|
70
|
+
const distFile = (0, shared_1.getDistFile)(projectDir, packageJson);
|
|
71
|
+
const name = packageJson.name || "function";
|
|
72
|
+
const code = (0, fs_1.readFileSync)(distFile, "utf-8");
|
|
73
|
+
if (!existingFunctionId) {
|
|
74
|
+
const id = (0, cuid_1.default)();
|
|
75
|
+
const res = await (0, node_fetch_1.default)(`${host}/api/${workspaceId}/config/function`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: {
|
|
78
|
+
Authorization: `Bearer ${apikey}`,
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
id: id,
|
|
82
|
+
workspaceId,
|
|
83
|
+
type: "function",
|
|
84
|
+
origin: "jitsu-cli",
|
|
85
|
+
name,
|
|
86
|
+
code,
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
if (!res.ok) {
|
|
90
|
+
console.error(`${chalk_1.default.red("Cannot add function to workspace:")}\n${chalk_1.default.bold(await res.text())}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
(0, fs_1.writeFileSync)(jitsuJsonPath, JSON.stringify({ ...jitsuJson, [workspaceId]: id }, null, 2));
|
|
95
|
+
console.log(`Function ${chalk_1.default.bold(name)} with id: ${id} successfully added to workspace ${workspaceName}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const id = existingFunctionId;
|
|
100
|
+
const res = await (0, node_fetch_1.default)(`${host}/api/${workspaceId}/config/function/${id}`, {
|
|
101
|
+
method: "PUT",
|
|
102
|
+
headers: {
|
|
103
|
+
Authorization: `Bearer ${apikey}`,
|
|
104
|
+
},
|
|
105
|
+
body: JSON.stringify({
|
|
106
|
+
id: id,
|
|
107
|
+
workspaceId,
|
|
108
|
+
type: "function",
|
|
109
|
+
origin: "jitsu-cli",
|
|
110
|
+
name,
|
|
111
|
+
code,
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
if (!res.ok) {
|
|
115
|
+
console.error(`${chalk_1.default.red(`Cannot patch function ${name}(${id}):`)}\n${chalk_1.default.bold(await res.text())}`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
(0, fs_1.writeFileSync)(jitsuJsonPath, JSON.stringify({ ...jitsuJson, [workspaceId]: id }, null, 2));
|
|
120
|
+
console.log(`Function ${chalk_1.default.bold(name)} with id: ${id} successfully updated in workspace ${workspaceName}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.deploy = deploy;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.init = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const juava_1 = require("juava");
|
|
9
|
+
const template_1 = require("../lib/template");
|
|
10
|
+
const functions_1 = require("../templates/functions");
|
|
11
|
+
const version_1 = require("../lib/version");
|
|
12
|
+
async function init({ name, parent }) {
|
|
13
|
+
const currentDir = process.cwd();
|
|
14
|
+
const projectName = name ||
|
|
15
|
+
(await inquirer_1.default.prompt([
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "project",
|
|
19
|
+
message: `Enter project name. It will be used as a package name and directory name:`,
|
|
20
|
+
},
|
|
21
|
+
])).project;
|
|
22
|
+
const parentDir = parent ||
|
|
23
|
+
(await inquirer_1.default.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: "input",
|
|
26
|
+
name: "dir",
|
|
27
|
+
default: currentDir,
|
|
28
|
+
message: `Enter parent directory of project:`,
|
|
29
|
+
},
|
|
30
|
+
])).dir;
|
|
31
|
+
const projectDir = path_1.default.resolve(parentDir, (0, juava_1.sanitize)(projectName));
|
|
32
|
+
console.log(`Creating project ${chalk_1.default.bold(projectName)}. Path: ${projectDir}`);
|
|
33
|
+
(0, template_1.write)(projectDir, functions_1.functionProjectTemplate, {
|
|
34
|
+
packageName: projectName,
|
|
35
|
+
jitsuVersion: version_1.jitsuCliVersion,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.init = init;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.login = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const open_1 = tslib_1.__importDefault(require("open"));
|
|
6
|
+
const express_1 = tslib_1.__importDefault(require("express"));
|
|
7
|
+
const juava_1 = require("juava");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const os_1 = require("os");
|
|
10
|
+
const readline_1 = tslib_1.__importDefault(require("readline"));
|
|
11
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
12
|
+
const origin = "jitsu-cli";
|
|
13
|
+
async function login({ host, apikey }) {
|
|
14
|
+
if (apikey) {
|
|
15
|
+
(0, fs_1.writeFileSync)(`${(0, os_1.homedir)()}/.jitsu/jitsu-cli.json`, JSON.stringify({ host, apikey }, null, 2));
|
|
16
|
+
console.info(`\nSuccess!`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let url = host;
|
|
20
|
+
if (!url.startsWith("http")) {
|
|
21
|
+
if (url.startsWith("localhost") || url.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)) {
|
|
22
|
+
url = "http://" + url;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
url = "https://" + url;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!url.endsWith("/")) {
|
|
29
|
+
url += "/";
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const app = (0, express_1.default)();
|
|
33
|
+
const c = (0, juava_1.randomId)(32);
|
|
34
|
+
const server = app.listen(0, async () => {
|
|
35
|
+
const addr = server.address();
|
|
36
|
+
const r = await (0, open_1.default)(`${url}?origin=${origin}&c=${c}&redirect=http://localhost:${addr.port}/`);
|
|
37
|
+
const int = setInterval(() => {
|
|
38
|
+
if (r.exitCode !== null) {
|
|
39
|
+
clearInterval(int);
|
|
40
|
+
if (r.exitCode !== 0) {
|
|
41
|
+
console.log(`Please open this url in your browser:\n${url}?origin=${origin}&c=${c}`);
|
|
42
|
+
const rl = readline_1.default.createInterface({
|
|
43
|
+
input: process.stdin,
|
|
44
|
+
output: process.stdout,
|
|
45
|
+
});
|
|
46
|
+
console.log("\nSuccessful authorization will provide you with a code.");
|
|
47
|
+
rl.question("Please paste it here: ", code => {
|
|
48
|
+
processCode(code, c, host);
|
|
49
|
+
rl.close();
|
|
50
|
+
});
|
|
51
|
+
server.close();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, 100);
|
|
55
|
+
});
|
|
56
|
+
app.get("/", (req, res) => {
|
|
57
|
+
if (req.query.code) {
|
|
58
|
+
processCode(req.query.code, c, host);
|
|
59
|
+
res.setHeader("Location", `${url}/cli`);
|
|
60
|
+
res.status(302).send();
|
|
61
|
+
server.close();
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const err = req.query.err;
|
|
66
|
+
console.error(chalk_1.default.red(`${chalk_1.default.red("Error: ")}${err}`));
|
|
67
|
+
res.setHeader("Location", `${url}/cli?err=${err}`);
|
|
68
|
+
res.status(302).send();
|
|
69
|
+
server.close();
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error(e);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.login = login;
|
|
80
|
+
function processCode(code, key, host) {
|
|
81
|
+
try {
|
|
82
|
+
const iv = `${origin}${code.substring(0, 16 - origin.length)}`;
|
|
83
|
+
const enc = code.substring(16 - origin.length);
|
|
84
|
+
const decoded = (0, juava_1.decrypt)(key, iv, enc);
|
|
85
|
+
const { plaintext, id } = JSON.parse(decoded);
|
|
86
|
+
(0, fs_1.mkdirSync)(`${(0, os_1.homedir)()}/.jitsu`, { recursive: true });
|
|
87
|
+
(0, fs_1.writeFileSync)(`${(0, os_1.homedir)()}/.jitsu/jitsu-cli.json`, JSON.stringify({ host, apikey: `${id}:${plaintext}` }, null, 2));
|
|
88
|
+
console.info(`\nSuccess!`);
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
console.error(`\n${chalk_1.default.red("Incorrect code value")}`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const core_functions_1 = require("@jitsu/core-functions");
|
|
9
|
+
const juava_1 = require("juava");
|
|
10
|
+
const http_agent_1 = require("@jitsu/core-functions/src/functions/lib/http-agent");
|
|
11
|
+
const json5_1 = tslib_1.__importDefault(require("json5"));
|
|
12
|
+
const shared_1 = require("./shared");
|
|
13
|
+
const currentDir = process.cwd();
|
|
14
|
+
async function run({ dir, event, store, props }) {
|
|
15
|
+
const projectDir = dir || currentDir;
|
|
16
|
+
console.log(`Running ${chalk_1.default.bold(projectDir)}`);
|
|
17
|
+
const packageJson = (0, shared_1.loadPackageJson)(projectDir);
|
|
18
|
+
const eventJson = parseJson5("event", event);
|
|
19
|
+
const propsJson = parseJson5("props", props);
|
|
20
|
+
const storeJson = parseJson5("store", store);
|
|
21
|
+
const file = (0, shared_1.getDistFile)(projectDir, packageJson);
|
|
22
|
+
const name = packageJson.name || "function";
|
|
23
|
+
const log = (0, juava_1.getLog)({
|
|
24
|
+
level: "debug",
|
|
25
|
+
component: name,
|
|
26
|
+
});
|
|
27
|
+
await http_agent_1.httpAgent.waitInit();
|
|
28
|
+
await http_agent_1.httpsAgent.waitInit();
|
|
29
|
+
const result = await (0, core_functions_1.UDFTestRun)({
|
|
30
|
+
functionId: "test",
|
|
31
|
+
functionName: "test",
|
|
32
|
+
event: eventJson,
|
|
33
|
+
config: propsJson,
|
|
34
|
+
store: storeJson,
|
|
35
|
+
code: (0, fs_1.readFileSync)(file, "utf-8"),
|
|
36
|
+
workspaceId: "test",
|
|
37
|
+
});
|
|
38
|
+
console.log(chalk_1.default.bold("Function logs:"));
|
|
39
|
+
for (const logItem of result.logs) {
|
|
40
|
+
const logFunc = (() => {
|
|
41
|
+
switch (logItem.level) {
|
|
42
|
+
case "error":
|
|
43
|
+
return log.atError();
|
|
44
|
+
case "warn":
|
|
45
|
+
return log.atWarn();
|
|
46
|
+
case "debug":
|
|
47
|
+
return log.atDebug();
|
|
48
|
+
default:
|
|
49
|
+
return log.atInfo();
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
logFunc.log(logItem.message);
|
|
53
|
+
}
|
|
54
|
+
console.log(chalk_1.default.bold("Function result:"));
|
|
55
|
+
if (result.error) {
|
|
56
|
+
log.atError().log("Error:", result.error);
|
|
57
|
+
}
|
|
58
|
+
else if (result.dropped) {
|
|
59
|
+
log.atInfo().log(`Further processing will be SKIPPED. Function returned: ${JSON.stringify(result)}`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.log(JSON.stringify(result.result, null, 2));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.run = run;
|
|
66
|
+
function parseJson5(name, jsonOrFilename) {
|
|
67
|
+
if (!jsonOrFilename) {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
if (jsonOrFilename.startsWith("{")) {
|
|
71
|
+
try {
|
|
72
|
+
return json5_1.default.parse(jsonOrFilename);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
throw new Error(`Failed to parse JSON for ${chalk_1.default.underline(name)}: ${e.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const jsonPath = path_1.default.resolve(currentDir, jsonOrFilename);
|
|
80
|
+
try {
|
|
81
|
+
return json5_1.default.parse((0, fs_1.readFileSync)(jsonPath, "utf-8"));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
throw new Error(`Failed to parse JSON for ${chalk_1.default.underline(name)} from ${jsonPath}: ${e.message}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDistFile = exports.loadPackageJson = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
function loadPackageJson(projectDir) {
|
|
9
|
+
const packageJsonPath = path_1.default.resolve(projectDir, "package.json");
|
|
10
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
11
|
+
console.error(`${chalk_1.default.red("Can't find node.js project in:")} ${chalk_1.default.bold(projectDir)}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, "utf-8"));
|
|
15
|
+
return packageJson;
|
|
16
|
+
}
|
|
17
|
+
exports.loadPackageJson = loadPackageJson;
|
|
18
|
+
function getDistFile(projectDir, packageJson) {
|
|
19
|
+
const distFile = path_1.default.resolve(projectDir, packageJson.main || "dist/index.js");
|
|
20
|
+
if (!(0, fs_1.existsSync)(distFile)) {
|
|
21
|
+
console.error(`${chalk_1.default.red("Can't find dist file:")} ${chalk_1.default.bold(distFile)} . Please build project first.`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
return distFile;
|
|
25
|
+
}
|
|
26
|
+
exports.getDistFile = getDistFile;
|