jitsu-cli 0.7.0 → 0.7.5

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.
@@ -14,7 +14,7 @@ const plugin_node_resolve_1 = (0, tslib_1.__importDefault)(require("@rollup/plug
14
14
  const plugin_commonjs_1 = (0, tslib_1.__importDefault)(require("@rollup/plugin-commonjs"));
15
15
  const version_1 = require("../../lib/version");
16
16
  const _1 = require("./");
17
- const JSON5_1 = (0, tslib_1.__importDefault)(require("JSON5"));
17
+ const json5_1 = (0, tslib_1.__importDefault)(require("json5"));
18
18
  async function build(args) {
19
19
  const directory = args?.[0] || "";
20
20
  let projectBase = path_1.default.isAbsolute(directory) ? directory : path_1.default.resolve(process.cwd() + "/" + directory);
@@ -28,7 +28,7 @@ async function build(args) {
28
28
  }
29
29
  let packageJson;
30
30
  try {
31
- packageJson = JSON5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf8"));
31
+ packageJson = json5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf8"));
32
32
  }
33
33
  catch (e) {
34
34
  throw new Error((0, errors_1.appendError)(`Failed to parse package.json at ${projectBase}`, e));
@@ -6,7 +6,7 @@ const commander_1 = (0, tslib_1.__importDefault)(require("commander"));
6
6
  const log_1 = (0, tslib_1.__importDefault)(require("../../lib/log"));
7
7
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
8
8
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
9
- const JSON5_1 = (0, tslib_1.__importDefault)(require("JSON5"));
9
+ const json5_1 = (0, tslib_1.__importDefault)(require("json5"));
10
10
  const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
11
11
  const index_1 = require("./index");
12
12
  const indent_1 = require("../../lib/indent");
@@ -15,13 +15,13 @@ const validator_helper_1 = require("../../lib/validator-helper");
15
15
  const errors_1 = require("../../lib/errors");
16
16
  function getJson(json, file) {
17
17
  if (json) {
18
- return JSON5_1.default.parse(json);
18
+ return json5_1.default.parse(json);
19
19
  }
20
20
  else {
21
21
  if (!fs_1.default.existsSync(file)) {
22
22
  throw new Error(`File ${file} does not exist!`);
23
23
  }
24
- return JSON5_1.default.parse(fs_1.default.readFileSync(file, "utf-8"));
24
+ return json5_1.default.parse(fs_1.default.readFileSync(file, "utf-8"));
25
25
  }
26
26
  }
27
27
  function ellipsis(str, opts = { maxLen: 80 }) {
@@ -67,7 +67,7 @@ async function execExtension(args) {
67
67
  (0, log_1.default)().info("🛂 Executing tests destination on " + chalk_1.default.bold(projectBase));
68
68
  let events = toArray(getJson(cliOpts.json, cliOpts.file));
69
69
  let config = getJson(cliOpts.configObject, cliOpts.config);
70
- let distFile = path_1.default.resolve(projectBase, (0, index_1.getDistFile)(JSON5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf-8"))));
70
+ let distFile = path_1.default.resolve(projectBase, (0, index_1.getDistFile)(json5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf-8"))));
71
71
  (0, log_1.default)().info("⌛️ Loading destination plugin (don't forget to build it before running exec!). Source: " + chalk_1.default.bold(distFile));
72
72
  if (!fs_1.default.existsSync(path_1.default.resolve(projectBase, distFile))) {
73
73
  return {
@@ -11,7 +11,7 @@ const build_1 = require("./build");
11
11
  const test_1 = require("./test");
12
12
  const validate_config_1 = require("./validate-config");
13
13
  const template_1 = require("./template");
14
- const JSON5_1 = (0, tslib_1.__importDefault)(require("JSON5"));
14
+ const json5_1 = (0, tslib_1.__importDefault)(require("json5"));
15
15
  const exec_1 = require("./exec");
16
16
  global.fetch = require("cross-fetch");
17
17
  const usage = `
@@ -86,7 +86,7 @@ exports.extensionCommands = {
86
86
  function validateTsConfig(tsConfigPath) {
87
87
  let tsConfig;
88
88
  try {
89
- tsConfig = JSON5_1.default.parse(fs.readFileSync(tsConfigPath, "utf8"));
89
+ tsConfig = json5_1.default.parse(fs.readFileSync(tsConfigPath, "utf8"));
90
90
  }
91
91
  catch (e) {
92
92
  throw new Error(`${chalk_1.default.bold(tsConfigPath)} - syntax error: ${e.message}`);
@@ -14,6 +14,7 @@ export declare const packageJsonTemplate: ({ packageName, type, jitsuVersion }:
14
14
  build: string;
15
15
  test: string;
16
16
  "validate-config": string;
17
+ execute: string;
17
18
  };
18
19
  devDependencies: {
19
20
  "@jitsu/types": string;
@@ -11,6 +11,7 @@ const packageJsonTemplate = ({ packageName, type, jitsuVersion = undefined }) =>
11
11
  build: "jitsu-cli extension build",
12
12
  test: "jitsu-cli extension test",
13
13
  "validate-config": "jitsu-cli extension validate-config",
14
+ execute: 'jitsu-cli extension exec'
14
15
  },
15
16
  devDependencies: {
16
17
  "@jitsu/types": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
@@ -6,7 +6,7 @@ const commander_1 = (0, tslib_1.__importDefault)(require("commander"));
6
6
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
7
7
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
8
8
  const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
9
- const JSON5_1 = (0, tslib_1.__importDefault)(require("JSON5"));
9
+ const json5_1 = (0, tslib_1.__importDefault)(require("json5"));
10
10
  const log_1 = (0, tslib_1.__importDefault)(require("../../lib/log"));
11
11
  const index_1 = require("./index");
12
12
  const validator_helper_1 = require("../../lib/validator-helper");
@@ -27,7 +27,7 @@ async function validateConfig(args) {
27
27
  let configObj;
28
28
  if (opts.configObject) {
29
29
  try {
30
- configObj = JSON5_1.default.parse(opts.configObject);
30
+ configObj = json5_1.default.parse(opts.configObject);
31
31
  }
32
32
  catch (e) {
33
33
  return { success: false, message: `Malformed json (-j): ${e.message}` };
@@ -38,7 +38,7 @@ async function validateConfig(args) {
38
38
  return { success: false, message: `${opts.config} (-f) doesn't exist!` };
39
39
  }
40
40
  try {
41
- configObj = JSON5_1.default.parse(fs_1.default.readFileSync(opts.config, "utf8"));
41
+ configObj = json5_1.default.parse(fs_1.default.readFileSync(opts.config, "utf8"));
42
42
  }
43
43
  catch (e) {
44
44
  return { success: false, message: `Malformed json in file ${opts.config} (-f): ${e.message}` };
@@ -50,7 +50,7 @@ async function validateConfig(args) {
50
50
  if (!fs_1.default.existsSync(packageFile)) {
51
51
  return { success: false, message: `Can't find package file ${packageFile}` };
52
52
  }
53
- let packageObj = JSON5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf8"));
53
+ let packageObj = json5_1.default.parse(fs_1.default.readFileSync(packageFile, "utf8"));
54
54
  let distFile = path_1.default.resolve(projectDir, (0, index_1.getDistFile)(packageObj));
55
55
  (0, log_1.default)().info("Dist file: " + distFile);
56
56
  if (!fs_1.default.existsSync(distFile)) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.write = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const posix_1 = (0, tslib_1.__importDefault)(require("path/posix"));
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
6
  const fs = (0, tslib_1.__importStar)(require("fs"));
7
7
  const indent_1 = require("./indent");
8
8
  function toTemplateFunction(template) {
@@ -18,8 +18,8 @@ function toTemplateFunction(template) {
18
18
  }
19
19
  function write(dir, template, vars) {
20
20
  Object.entries(template).forEach(([fileName, template]) => {
21
- let filePath = posix_1.default.resolve(dir, fileName);
22
- let fileDir = posix_1.default.dirname(filePath);
21
+ let filePath = path_1.default.resolve(dir, fileName);
22
+ let fileDir = path_1.default.dirname(filePath);
23
23
  if (!fs.existsSync(fileDir)) {
24
24
  fs.mkdirSync(fileDir, { recursive: true });
25
25
  }
@@ -1,3 +1,2 @@
1
- import { ConfigValidationResult, ConfigValidator } from "@jitsu/types/extension";
2
- export declare function validationResultToError(validationResult: ConfigValidationResult): string | undefined;
1
+ import { ConfigValidator } from "@jitsu/types/extension";
3
2
  export declare function validateConfiguration(config: any, validator: ConfigValidator): Promise<(string | undefined)>;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateConfiguration = exports.validationResultToError = void 0;
4
- function validationResultToError(validationResult) {
5
- if (typeof validationResult === "boolean" && !validationResult) {
6
- return "Config is not valid, an exact reason isn't specified by validator";
7
- }
8
- else if (typeof validationResult === "string") {
9
- return "Config is not valid: " + validationResult;
3
+ exports.validateConfiguration = void 0;
4
+ async function validateConfiguration(config, validator) {
5
+ try {
6
+ const result = await validator(config);
7
+ if (typeof result === "boolean" && !result) {
8
+ return "Unknown error";
9
+ }
10
+ else if (typeof result === "object" && !result.ok) {
11
+ return result.message || "Unknown error";
12
+ }
13
+ else if (typeof result === "string") {
14
+ return result;
15
+ }
10
16
  }
11
- else if (typeof validationResult === "object" && !validationResult.ok) {
12
- return "Config is not valid: " + validationResult.message;
17
+ catch (e) {
18
+ return e?.message || "Unknown error";
13
19
  }
14
- return undefined;
15
- }
16
- exports.validationResultToError = validationResultToError;
17
- async function validateConfiguration(config, validator) {
18
- let validationResult = await validator(config);
19
- return validationResultToError(validationResult);
20
20
  }
21
21
  exports.validateConfiguration = validateConfiguration;
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitsu-cli",
3
- "version": "0.6.0",
3
+ "version": "0.7.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -65,5 +65,5 @@
65
65
  "typescript": "^4.5.2",
66
66
  "validate-npm-package-name": "^3.0.0"
67
67
  },
68
- "gitHead": "4a5222ce49da3cb6be58648c78b1111b39764fe1"
68
+ "gitHead": "ede64e6fc3d51e3f38315fde5633d385e0bc9178"
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitsu-cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -65,5 +65,5 @@
65
65
  "typescript": "^4.5.2",
66
66
  "validate-npm-package-name": "^3.0.0"
67
67
  },
68
- "gitHead": "4d54aac819fd941c52c15e1f7716c628d80bbdc5"
68
+ "gitHead": "ed8f516180f0dc2feb6dc4473127f6227132e9ad"
69
69
  }