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.
Files changed (108) hide show
  1. package/.turbo/turbo-build.log +112 -0
  2. package/LICENSE +1 -1
  3. package/babel.config.cjs +4 -0
  4. package/bin/jitsu-cli +1 -1
  5. package/compiled/package.json +66 -0
  6. package/compiled/src/commands/build.js +55 -0
  7. package/compiled/src/commands/deploy.js +124 -0
  8. package/compiled/src/commands/init.js +38 -0
  9. package/compiled/src/commands/login.js +94 -0
  10. package/compiled/src/commands/run.js +87 -0
  11. package/compiled/src/commands/shared.js +26 -0
  12. package/{lib/cli/extension → compiled/src/commands}/template.js +10 -11
  13. package/compiled/src/commands/test.js +15 -0
  14. package/compiled/src/index.js +49 -0
  15. package/{lib → compiled/src}/lib/chalk-code-highlight.js +0 -1
  16. package/{lib → compiled/src}/lib/errors.js +0 -1
  17. package/{lib → compiled/src}/lib/indent.js +0 -1
  18. package/{lib → compiled/src}/lib/log.js +7 -7
  19. package/{lib → compiled/src}/lib/template.js +1 -2
  20. package/{lib → compiled/src}/lib/version.js +1 -3
  21. package/compiled/src/templates/functions.js +67 -0
  22. package/dist/10546bf325e211cf9719.js +886 -0
  23. package/dist/1463a26331df3b0b4d694b076097b2dd.node +0 -0
  24. package/dist/230.js +4890 -0
  25. package/dist/230.js.map +1 -0
  26. package/dist/535.js +112 -0
  27. package/dist/535.js.map +1 -0
  28. package/dist/718.js +452 -0
  29. package/dist/718.js.map +1 -0
  30. package/dist/main.js +350126 -0
  31. package/dist/main.js.map +1 -0
  32. package/package.json +53 -64
  33. package/src/commands/build.ts +63 -0
  34. package/src/commands/deploy.ts +126 -0
  35. package/src/commands/init.ts +45 -0
  36. package/src/commands/login.ts +91 -0
  37. package/src/commands/run.ts +85 -0
  38. package/src/commands/shared.ts +26 -0
  39. package/src/commands/test.ts +16 -0
  40. package/src/index.ts +69 -0
  41. package/src/lib/chalk-code-highlight.ts +46 -0
  42. package/src/lib/indent.ts +42 -0
  43. package/src/lib/template.ts +37 -0
  44. package/src/lib/version.ts +35 -0
  45. package/src/templates/functions.ts +73 -0
  46. package/tsconfig.json +28 -0
  47. package/webpack.config.js +43 -0
  48. package/README.md +0 -11
  49. package/bin/jiu +0 -3
  50. package/lib/cli/cli.d.ts +0 -1
  51. package/lib/cli/cli.js +0 -308
  52. package/lib/cli/cli.js.map +0 -1
  53. package/lib/cli/config/index.d.ts +0 -12
  54. package/lib/cli/config/index.js +0 -3
  55. package/lib/cli/config/index.js.map +0 -1
  56. package/lib/cli/extension/build.d.ts +0 -3
  57. package/lib/cli/extension/build.js +0 -142
  58. package/lib/cli/extension/build.js.map +0 -1
  59. package/lib/cli/extension/create.d.ts +0 -3
  60. package/lib/cli/extension/create.js +0 -89
  61. package/lib/cli/extension/create.js.map +0 -1
  62. package/lib/cli/extension/exec.d.ts +0 -7
  63. package/lib/cli/extension/exec.js +0 -350
  64. package/lib/cli/extension/exec.js.map +0 -1
  65. package/lib/cli/extension/index.d.ts +0 -6
  66. package/lib/cli/extension/index.js +0 -66
  67. package/lib/cli/extension/index.js.map +0 -1
  68. package/lib/cli/extension/template.d.ts +0 -30
  69. package/lib/cli/extension/template.js.map +0 -1
  70. package/lib/cli/extension/test.d.ts +0 -3
  71. package/lib/cli/extension/test.js +0 -35
  72. package/lib/cli/extension/test.js.map +0 -1
  73. package/lib/cli/extension/validate-config.d.ts +0 -3
  74. package/lib/cli/extension/validate-config.js +0 -62
  75. package/lib/cli/extension/validate-config.js.map +0 -1
  76. package/lib/cli/router.d.ts +0 -24
  77. package/lib/cli/router.js +0 -135
  78. package/lib/cli/router.js.map +0 -1
  79. package/lib/config-store.d.ts +0 -16
  80. package/lib/config-store.js +0 -73
  81. package/lib/config-store.js.map +0 -1
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +0 -7
  84. package/lib/index.js.map +0 -1
  85. package/lib/lib/chalk-code-highlight.d.ts +0 -14
  86. package/lib/lib/chalk-code-highlight.js.map +0 -1
  87. package/lib/lib/command/index.d.ts +0 -3
  88. package/lib/lib/command/index.js +0 -120
  89. package/lib/lib/command/index.js.map +0 -1
  90. package/lib/lib/errors.d.ts +0 -1
  91. package/lib/lib/errors.js.map +0 -1
  92. package/lib/lib/indent.d.ts +0 -9
  93. package/lib/lib/indent.js.map +0 -1
  94. package/lib/lib/log.d.ts +0 -8
  95. package/lib/lib/log.js.map +0 -1
  96. package/lib/lib/template.d.ts +0 -5
  97. package/lib/lib/template.js.map +0 -1
  98. package/lib/lib/validation.d.ts +0 -2
  99. package/lib/lib/validation.js +0 -24
  100. package/lib/lib/validation.js.map +0 -1
  101. package/lib/lib/version.d.ts +0 -5
  102. package/lib/lib/version.js.map +0 -1
  103. package/lib/model/destination.json +0 -123
  104. package/lib/model/stream.json +0 -44
  105. package/lib/package.json +0 -77
  106. package/lib/tests.d.ts +0 -2
  107. package/lib/tests.js +0 -11
  108. package/lib/tests.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extensionProjectTemplate = exports.packageJsonTemplate = void 0;
4
- const version_1 = require("../../lib/version");
5
- const router_1 = require("../router");
4
+ const version_1 = require("../lib/version");
5
+ const index_1 = require("../index");
6
6
  const packageJsonTemplate = ({ packageName, type, jitsuVersion = undefined }) => {
7
7
  const res = {
8
8
  name: `${packageName}`,
@@ -12,22 +12,22 @@ const packageJsonTemplate = ({ packageName, type, jitsuVersion = undefined }) =>
12
12
  main: `dist/${packageName}.js`,
13
13
  scripts: {
14
14
  clean: "rm -rf ./dist",
15
- build: `${router_1.binName} extension build`,
16
- test: `${router_1.binName} extension test`,
17
- execute: `${router_1.binName} extension exec`,
15
+ build: `${index_1.binName} extension build`,
16
+ test: `${index_1.binName} extension test`,
17
+ execute: `${index_1.binName} extension exec`,
18
18
  },
19
19
  devDependencies: {
20
20
  "@jitsu/types": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
21
21
  "@jitsu/jlib": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
22
22
  "ts-jest": "^27.0.7",
23
- [router_1.binName]: `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
23
+ [index_1.binName]: `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
24
24
  tslib: "^2.3.1",
25
25
  typescript: "^4.5.2",
26
26
  },
27
27
  dependencies: {},
28
28
  };
29
29
  if (type === "destination" || type === "source") {
30
- res.scripts["validate-config"] = `${router_1.binName} extension validate-config`;
30
+ res.scripts["validate-config"] = `${index_1.binName} extension validate-config`;
31
31
  }
32
32
  return res;
33
33
  };
@@ -38,7 +38,7 @@ let destinationTest = ({ type = "destination" }) => {
38
38
  }
39
39
  return `
40
40
  import { JitsuDestinationContext } from "@jitsu/types/extension"
41
- import { testDestination } from "${router_1.binName}/lib/tests"
41
+ import { testDestination } from "${index_1.binName}/lib/tests"
42
42
  import { destination } from "../src"
43
43
 
44
44
  testDestination({
@@ -198,7 +198,7 @@ descriptor["destination"] = (vars) => `
198
198
  id: "${vars.packageName}",
199
199
  displayName: "${vars.packageName}",
200
200
  icon: "",
201
- description: "Jitsu destination - ${vars.packageName} (generated by \`${router_1.binName} extension create\`)",
201
+ description: "Jitsu destination - ${vars.packageName} (generated by \`${index_1.binName} extension create\`)",
202
202
  configurationParameters: [
203
203
  {id: "exampleParam", type: "string", required: true, displayName: "Example param", documentation: "Documentation"}
204
204
  ],
@@ -214,7 +214,7 @@ descriptor["transform"] = (vars) => `
214
214
  id: "${vars.packageName}",
215
215
  displayName: "${vars.packageName}",
216
216
  icon: "",
217
- description: "Jitsu ${vars.type} - ${vars.packageName} (generated by \`${router_1.binName} extension create)\`"
217
+ description: "Jitsu ${vars.type} - ${vars.packageName} (generated by \`${index_1.binName} extension create)\`"
218
218
  }
219
219
 
220
220
  export {descriptor, transform}
@@ -237,4 +237,3 @@ exports.extensionProjectTemplate = {
237
237
  include: ["./src", "__test__"],
238
238
  },
239
239
  };
240
- //# sourceMappingURL=template.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.test = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const jest_cli_1 = require("jest-cli");
7
+ const shared_1 = require("./shared");
8
+ async function test({ dir }) {
9
+ const projectDir = dir || process.cwd();
10
+ console.log(`Running tests in ${chalk_1.default.bold(projectDir)}`);
11
+ const packageJson = (0, shared_1.loadPackageJson)(projectDir);
12
+ const jestArgs = ["--passWithNoTests", "--projects", projectDir, "--preset", "ts-jest"];
13
+ await (0, jest_cli_1.run)(jestArgs);
14
+ }
15
+ exports.test = test;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const figlet_1 = tslib_1.__importDefault(require("figlet"));
5
+ const commander_1 = require("commander");
6
+ const login_1 = require("./commands/login");
7
+ const deploy_1 = require("./commands/deploy");
8
+ const init_1 = require("./commands/init");
9
+ const build_1 = require("./commands/build");
10
+ const test_1 = require("./commands/test");
11
+ const run_1 = require("./commands/run");
12
+ const version_1 = require("./lib/version");
13
+ console.log(figlet_1.default.textSync("Jitsu CLI", { horizontalLayout: "full" }));
14
+ const p = new commander_1.Command();
15
+ p.name(version_1.jitsuPackageName).description("CLI command to create, test and deploy extensions for Jitsu Next");
16
+ p.command("init")
17
+ .description("Initialize a new Jitsu extension project")
18
+ .option("-n, --name <name>", "the name of the project. (Optional). By default, interactive prompt is shown to enter the name.")
19
+ .option("-p, --parent <dir>", "the parent directory of project. (Optional). By default, interactive prompt is shown to enter the parent directory.")
20
+ .action(init_1.init);
21
+ p.command("build")
22
+ .description("Build the extension")
23
+ .option("-d, --dir <dir>", "the directory of project. (Optional). By default, current directory is used")
24
+ .action(build_1.build);
25
+ p.command("test")
26
+ .description("Run test provided with the extension")
27
+ .option("-d, --dir <dir>", "the directory of project. (Optional). By default, current directory is used")
28
+ .action(test_1.test);
29
+ p.command("run")
30
+ .description("Check extensions on provided event, config and persistent storage state")
31
+ .option("-d, --dir <dir>", "the directory of project. (Optional). By default, current directory is used")
32
+ .option("-n, --name <name>", "name of function to check (optional). Required if multiple functions are defined in project")
33
+ .option("-t, --type <type>", "entity type to run", "function")
34
+ .requiredOption("-e, --event <file_or_json>", "path to file with event json or event json as a string")
35
+ .option("-p, --props <file_or_json>", "path to file with config json or config json as a string (optional)")
36
+ .option("-s, --store <file_or_json>", "path to file with state json or state json as a string (optional)")
37
+ .action(run_1.run);
38
+ p.command("login")
39
+ .description("Login to Jitsu and remember credentials in `~/.jitsu/jitsu-cli.json` file")
40
+ .option("--host <host>", "Jitsu host or base url", "https://use.jitsu.com")
41
+ .option("-k, --apikey <api-key>", "Jitsu user's Api Key (optional). Disables interactive login.")
42
+ .action(login_1.login);
43
+ p.command("deploy")
44
+ .description("Deploy functions to Jitsu project")
45
+ .option("-d, --dir <dir>", "the directory of project. (Optional). By default, current directory is used")
46
+ .option("-w, --workspace <workspace-id>", "Id of workspace where to deploy function (Optional). By default, interactive prompt is shown to select workspace")
47
+ .option("-t, --type <type>", "entity type to deploy", "function")
48
+ .action(deploy_1.deploy);
49
+ p.parse();
@@ -39,4 +39,3 @@ chalkCode.typescript = (code, colorScheme = exports.defaultColorScheme) => {
39
39
  chalkCode.json = (code, colorScheme = exports.defaultColorScheme) => {
40
40
  return chalkCode(typeof code === "string" ? code : code.join("\n"), prismjs_1.default.languages.json, colorScheme);
41
41
  };
42
- //# sourceMappingURL=chalk-code-highlight.js.map
@@ -16,4 +16,3 @@ function appendError(msg, cause) {
16
16
  }
17
17
  }
18
18
  exports.appendError = appendError;
19
- //# sourceMappingURL=errors.js.map
@@ -39,4 +39,3 @@ function jsonify(obj) {
39
39
  return obj;
40
40
  }
41
41
  exports.jsonify = jsonify;
42
- //# sourceMappingURL=indent.js.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
- function log(delegate, styling, msg, args) {
5
+ function log0(delegate, styling, msg, args) {
6
6
  if (!msg) {
7
7
  delegate("");
8
8
  return;
@@ -18,19 +18,19 @@ function log(delegate, styling, msg, args) {
18
18
  function getLog() {
19
19
  return {
20
20
  error(msg, ...args) {
21
- log(console.error, { prefix: "error", color: "red" }, msg, args);
21
+ log0(console.error, { prefix: "error", color: "red" }, msg, args);
22
22
  },
23
23
  warn(msg, ...args) {
24
- log(console.warn, { prefix: "warn ", color: "yellow" }, msg, args);
24
+ log0(console.warn, { prefix: "warn ", color: "yellow" }, msg, args);
25
25
  },
26
26
  spinInfo(args) { },
27
27
  info(msg, ...args) {
28
- log(console.info, { prefix: "info ", color: "cyan" }, msg, args);
28
+ log0(console.info, { prefix: "info ", color: "cyan" }, msg, args);
29
29
  },
30
30
  debug(msg, ...args) {
31
- log(console.debug, { prefix: "debug", color: "gray" }, msg, args);
31
+ log0(console.debug, { prefix: "debug", color: "gray" }, msg, args);
32
32
  },
33
33
  };
34
34
  }
35
- exports.default = getLog;
36
- //# sourceMappingURL=log.js.map
35
+ const log = getLog();
36
+ exports.default = log;
@@ -17,7 +17,7 @@ function toTemplateFunction(template) {
17
17
  }
18
18
  }
19
19
  function write(dir, template, vars) {
20
- Object.entries(template).forEach(([fileName, template]) => {
20
+ Object.entries(template(vars)).forEach(([fileName, template]) => {
21
21
  let filePath = path_1.default.resolve(dir, fileName);
22
22
  let fileDir = path_1.default.dirname(filePath);
23
23
  if (!fs.existsSync(fileDir)) {
@@ -34,4 +34,3 @@ function write(dir, template, vars) {
34
34
  });
35
35
  }
36
36
  exports.write = write;
37
- //# sourceMappingURL=template.js.map
@@ -4,7 +4,6 @@ exports.hasNewerVersion = exports.box = exports.getUpgradeMessage = exports.jits
4
4
  const tslib_1 = require("tslib");
5
5
  const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const log_1 = tslib_1.__importDefault(require("./log"));
8
7
  const preload_1 = tslib_1.__importDefault(require("semver/preload"));
9
8
  const fetch = require("cross-fetch");
10
9
  exports.jitsuCliVersion = package_json_1.default.version;
@@ -29,8 +28,7 @@ async function hasNewerVersion() {
29
28
  return preload_1.default.gt(latestVersion, exports.jitsuCliVersion) ? latestVersion : undefined;
30
29
  }
31
30
  catch (e) {
32
- (0, log_1.default)().debug(`Failed to fetch latest version of ${exports.jitsuPackageName}: ${e?.message}`);
31
+ console.debug(`Failed to fetch latest version of ${exports.jitsuPackageName}: ${e?.message}`);
33
32
  }
34
33
  }
35
34
  exports.hasNewerVersion = hasNewerVersion;
36
- //# sourceMappingURL=version.js.map
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionProjectTemplate = exports.packageJsonTemplate = void 0;
4
+ const version_1 = require("../lib/version");
5
+ const juava_1 = require("juava");
6
+ const packageJsonTemplate = ({ packageName, license = "MIT", jitsuVersion = undefined }) => ({
7
+ name: `${packageName}`,
8
+ version: "0.0.1",
9
+ description: `Jitsu extension - ${packageName}`,
10
+ license: license,
11
+ keywords: ["jitsu", "jitsu-cli", "function", `jitsu-extension`],
12
+ main: `dist/index.js`,
13
+ scripts: {
14
+ clean: "rm -rf ./dist",
15
+ build: `${version_1.jitsuPackageName} build`,
16
+ test: `${version_1.jitsuPackageName} test`,
17
+ deploy: `${version_1.jitsuPackageName} deploy`,
18
+ },
19
+ devDependencies: {
20
+ "jitsu-cli": `${version_1.jitsuCliVersion}`,
21
+ "@jitsu/protocols": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
22
+ "@types/jest": "^29.5.5",
23
+ "ts-jest": "^29.1.1",
24
+ },
25
+ dependencies: {},
26
+ });
27
+ exports.packageJsonTemplate = packageJsonTemplate;
28
+ let functionTest = ({ packageName }) => {
29
+ return `
30
+ test("${(0, juava_1.sanitize)(packageName)} test", () => {
31
+ //TODO: implement test
32
+ });
33
+ `;
34
+ };
35
+ let functionCode = ({ packageName }) => {
36
+ return `
37
+ import { JitsuFunction } from "@jitsu/protocols/functions";
38
+ import { AnalyticsServerEvent } from "@jitsu/protocols/analytics";
39
+
40
+ const ${(0, juava_1.sanitize)(packageName)}: JitsuFunction<AnalyticsServerEvent, any> = async (event, ctx) => {
41
+ //TODO: implement function logic
42
+ };
43
+
44
+ export default ${(0, juava_1.sanitize)(packageName)};
45
+ `;
46
+ };
47
+ const functionProjectTemplate = ({ packageName }) => ({
48
+ [`__test__/${(0, juava_1.sanitize)(packageName)}.test.ts`]: functionTest,
49
+ [`src/index.ts`]: functionCode,
50
+ "package.json": exports.packageJsonTemplate,
51
+ "tsconfig.json": {
52
+ compilerOptions: {
53
+ rootDir: "./src",
54
+ outDir: "./dist",
55
+ declaration: true,
56
+ esModuleInterop: true,
57
+ importHelpers: false,
58
+ module: "esnext",
59
+ lib: ["esnext", "dom"],
60
+ noEmit: false,
61
+ target: "esnext",
62
+ },
63
+ target: "esnext",
64
+ exclude: ["__tests__", "node_modules", "dist"],
65
+ },
66
+ });
67
+ exports.functionProjectTemplate = functionProjectTemplate;