@embeddable.com/sdk-core 3.9.14 → 3.10.0

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/bin/embeddable CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- const { pathToFileURL } = require("url");
4
+ import { pathToFileURL } from "url";
5
5
 
6
- const { spawn } = require("child_process");
7
- const path = require("path");
6
+ import { spawn } from "child_process";
7
+ import path from "path";
8
8
 
9
9
  // Check if the loader is already applied to avoid infinite spawning
10
10
  if (!process.env.LOADER_APPLIED) {
@@ -13,9 +13,12 @@ if (!process.env.LOADER_APPLIED) {
13
13
  LOADER_APPLIED: "1",
14
14
  VITE_CJS_IGNORE_WARNING: "true", // see https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
15
15
  };
16
- const entryPointPath = path.join(__dirname, "../src/entryPoint.js");
16
+
17
+ const dirname = path.dirname(new URL(import.meta.url).pathname);
18
+
19
+ const entryPointPath = path.join(dirname, "../loader/entryPoint.js");
17
20
  const customLoaderPath = path.join(
18
- __dirname,
21
+ dirname,
19
22
  "../loader/custom-esm-loader.mjs",
20
23
  );
21
24
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/lib/index.esm.js CHANGED
@@ -21993,7 +21993,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
21993
21993
  };
21994
21994
 
21995
21995
  var name = "@embeddable.com/sdk-core";
21996
- var version = "3.9.14";
21996
+ var version = "3.10.0";
21997
21997
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
21998
21998
  var keywords = [
21999
21999
  "embeddable",
@@ -22032,26 +22032,26 @@ var engines = {
22032
22032
  var license = "MIT";
22033
22033
  var dependencies = {
22034
22034
  "@embeddable.com/sdk-utils": "*",
22035
- "@inquirer/prompts": "^7.0.0",
22036
- "@stencil/core": "^4.22.0",
22035
+ "@inquirer/prompts": "^7.1.0",
22036
+ "@stencil/core": "^4.22.2",
22037
22037
  "@swc-node/register": "^1.10.9",
22038
- archiver: "^5.3.1",
22039
- axios: "^1.7.2",
22040
- chokidar: "^3.6.0",
22041
- finalhandler: "^1.2.0",
22038
+ archiver: "^5.3.2",
22039
+ axios: "^1.7.7",
22040
+ chokidar: "^4.0.1",
22041
+ finalhandler: "^1.3.1",
22042
22042
  "formdata-node": "^6.0.3",
22043
22043
  minimist: "^1.2.8",
22044
22044
  open: "^9.1.0",
22045
- ora: "^8.0.1",
22046
- "serve-static": "^1.15.0",
22047
- sorcery: "^0.11.0",
22048
- vite: "^5.4.8",
22049
- ws: "^8.17.0",
22050
- yaml: "^2.3.3"
22045
+ ora: "^8.1.1",
22046
+ "serve-static": "^1.16.2",
22047
+ sorcery: "^0.11.1",
22048
+ vite: "^5.4.11",
22049
+ ws: "^8.18.0",
22050
+ yaml: "^2.6.0"
22051
22051
  };
22052
22052
  var devDependencies = {
22053
22053
  "@types/archiver": "^5.3.4",
22054
- "@types/ws": "^8.5.10"
22054
+ "@types/ws": "^8.5.13"
22055
22055
  };
22056
22056
  var _package = {
22057
22057
  name: name,
package/lib/index.js CHANGED
@@ -22021,7 +22021,7 @@ var defineConfig = ({ plugins, pushBaseUrl, audienceUrl, authDomain, authClientI
22021
22021
  };
22022
22022
 
22023
22023
  var name = "@embeddable.com/sdk-core";
22024
- var version = "3.9.14";
22024
+ var version = "3.10.0";
22025
22025
  var description = "Core Embeddable SDK module responsible for web-components bundling and publishing.";
22026
22026
  var keywords = [
22027
22027
  "embeddable",
@@ -22060,26 +22060,26 @@ var engines = {
22060
22060
  var license = "MIT";
22061
22061
  var dependencies = {
22062
22062
  "@embeddable.com/sdk-utils": "*",
22063
- "@inquirer/prompts": "^7.0.0",
22064
- "@stencil/core": "^4.22.0",
22063
+ "@inquirer/prompts": "^7.1.0",
22064
+ "@stencil/core": "^4.22.2",
22065
22065
  "@swc-node/register": "^1.10.9",
22066
- archiver: "^5.3.1",
22067
- axios: "^1.7.2",
22068
- chokidar: "^3.6.0",
22069
- finalhandler: "^1.2.0",
22066
+ archiver: "^5.3.2",
22067
+ axios: "^1.7.7",
22068
+ chokidar: "^4.0.1",
22069
+ finalhandler: "^1.3.1",
22070
22070
  "formdata-node": "^6.0.3",
22071
22071
  minimist: "^1.2.8",
22072
22072
  open: "^9.1.0",
22073
- ora: "^8.0.1",
22074
- "serve-static": "^1.15.0",
22075
- sorcery: "^0.11.0",
22076
- vite: "^5.4.8",
22077
- ws: "^8.17.0",
22078
- yaml: "^2.3.3"
22073
+ ora: "^8.1.1",
22074
+ "serve-static": "^1.16.2",
22075
+ sorcery: "^0.11.1",
22076
+ vite: "^5.4.11",
22077
+ ws: "^8.18.0",
22078
+ yaml: "^2.6.0"
22079
22079
  };
22080
22080
  var devDependencies = {
22081
22081
  "@types/archiver": "^5.3.4",
22082
- "@types/ws": "^8.5.10"
22082
+ "@types/ws": "^8.5.13"
22083
22083
  };
22084
22084
  var _package = {
22085
22085
  name: name,
@@ -0,0 +1,75 @@
1
+ import COMMANDS_MAP from "../lib/index.js";
2
+ import { spawn } from "child_process";
3
+ import path from "path";
4
+ import fs from "fs";
5
+
6
+ export async function main() {
7
+ const command = process.argv[2];
8
+ const runScript = COMMANDS_MAP[command];
9
+ const args = process.argv.slice(2);
10
+ const skipTypeCheck = args.includes("--force");
11
+
12
+ if (!runScript) {
13
+ process.exit(1);
14
+ }
15
+
16
+ if (command === "build") {
17
+ await runTypeScriptCheck(skipTypeCheck);
18
+ }
19
+
20
+ await runScript();
21
+ }
22
+
23
+ async function outputWarning(message) {
24
+ console.warn(`\x1b[33m⚠️ WARNING: ${message}\x1b[0m`);
25
+ }
26
+
27
+ async function runTypeScriptCheck(skipTypeCheck = false) {
28
+ const skipTypeCheckWarning =
29
+ "You can skip type checking by running with the --force flag, if you know what you are doing.";
30
+ return new Promise((resolve) => {
31
+ const customerProjectDir = process.cwd();
32
+ const tsconfigPath = path.join(customerProjectDir, "tsconfig.json");
33
+
34
+ if (skipTypeCheck) {
35
+ outputWarning("Type checking skipped.");
36
+ }
37
+
38
+ if (!fs.existsSync(tsconfigPath) || skipTypeCheck) {
39
+ resolve();
40
+ return;
41
+ }
42
+
43
+ const tscPath = path.join(
44
+ customerProjectDir,
45
+ "node_modules",
46
+ ".bin",
47
+ process.platform === "win32" ? "tsc.cmd" : "tsc",
48
+ );
49
+
50
+ if (!fs.existsSync(tscPath) && !skipTypeCheck) {
51
+ outputWarning(
52
+ "TypeScript compiler not found. Please ensure 'typescript' is installed in your project dependencies.",
53
+ );
54
+ outputWarning(skipTypeCheckWarning);
55
+ process.exit(1);
56
+ }
57
+
58
+ const tsc = spawn(tscPath, ["--noEmit", "--pretty"], {
59
+ cwd: customerProjectDir,
60
+ stdio: "inherit",
61
+ env: { ...process.env, FORCE_COLOR: "true" },
62
+ });
63
+
64
+ tsc.on("exit", (code) => {
65
+ if (code !== 0) {
66
+ outputWarning(skipTypeCheckWarning);
67
+ process.exit(1);
68
+ } else {
69
+ resolve();
70
+ }
71
+ });
72
+ });
73
+ }
74
+
75
+ main();
@@ -0,0 +1,122 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { spawn } from "child_process";
3
+ import fs from "fs";
4
+ import path from "path";
5
+
6
+ // Mock the dependencies
7
+ vi.mock("child_process");
8
+ vi.mock("fs");
9
+ vi.mock("path");
10
+ vi.mock("../lib/index.js", () => ({
11
+ default: {
12
+ build: vi.fn().mockResolvedValue(undefined),
13
+ someOtherCommand: vi.fn().mockResolvedValue(undefined),
14
+ },
15
+ }));
16
+
17
+ describe("entryPoint", () => {
18
+ let originalWarn;
19
+ let main;
20
+ beforeEach(async () => {
21
+ // Reset all mocks before each test
22
+ vi.clearAllMocks();
23
+ originalWarn = console.warn;
24
+ console.warn = vi.fn();
25
+
26
+ fs.existsSync.mockReturnValue(true);
27
+
28
+ // Mock process.on to avoid actually setting up process listeners
29
+ vi.spyOn(process, "on").mockImplementation(() => process);
30
+ vi.spyOn(process, "exit").mockImplementation(() => {
31
+ throw new Error("Process.exit called with code 1");
32
+ });
33
+
34
+ // Mock path.join to return predictable paths
35
+ path.join.mockImplementation((...args) => args.join("/"));
36
+
37
+ // Mock spawn
38
+ spawn.mockReturnValue({
39
+ on: vi.fn().mockImplementation((event, cb) => {
40
+ if (event === "exit") {
41
+ cb(0); // Success by default
42
+ }
43
+ }),
44
+ });
45
+
46
+ // Set up process.argv for the test
47
+ process.argv = ["node", "script.js", "someOtherCommand"];
48
+
49
+ // Dynamically import main after mocking process.exit
50
+ const entryPoint = await import("./entryPoint.js");
51
+ main = entryPoint.main;
52
+ });
53
+
54
+ afterEach(() => {
55
+ console.warn = originalWarn;
56
+ });
57
+
58
+ it("should run typescript check before build command", async () => {
59
+ process.argv = ["node", "script.js", "build"];
60
+ await main();
61
+
62
+ expect(spawn).toHaveBeenCalledWith(
63
+ expect.stringContaining("tsc"),
64
+ ["--noEmit", "--pretty"],
65
+ expect.any(Object),
66
+ );
67
+ });
68
+
69
+ it("should skip typescript check with --force flag", async () => {
70
+ process.argv = ["node", "script.js", "build", "--force"];
71
+ await main();
72
+
73
+ expect(spawn).not.toHaveBeenCalled();
74
+ expect(console.warn).toHaveBeenCalled();
75
+ });
76
+
77
+ it("should handle missing tsconfig.json", async () => {
78
+ process.argv = ["node", "script.js", "build"];
79
+ fs.existsSync.mockImplementation((path) => {
80
+ return !path.includes("tsconfig.json");
81
+ });
82
+
83
+ await main();
84
+ expect(spawn).not.toHaveBeenCalled();
85
+ });
86
+
87
+ it("should exit if typescript check fails", async () => {
88
+ process.argv = ["node", "script.js", "build"];
89
+
90
+ spawn.mockReturnValue({
91
+ on: vi.fn().mockImplementation((event, cb) => {
92
+ if (event === "exit") {
93
+ cb(1); // Simulate failure
94
+ }
95
+ }),
96
+ });
97
+
98
+ try {
99
+ await main();
100
+ } catch (error) {
101
+ expect(error.message).toBe("Process.exit called with code 1");
102
+ expect(console.warn).toHaveBeenCalled();
103
+ }
104
+ });
105
+
106
+ it("should handle missing typescript compiler", async () => {
107
+ process.argv = ["node", "script.js", "build"];
108
+
109
+ // Mock both tsconfig.json existence and tsc missing
110
+ fs.existsSync.mockImplementation((filePath) => {
111
+ if (filePath.includes("tsconfig.json")) return true;
112
+ if (filePath.includes("tsc")) return false;
113
+ return true;
114
+ });
115
+
116
+ try {
117
+ await main();
118
+ } catch (error) {
119
+ expect(error.message).toBe("Process.exit called with code 1");
120
+ }
121
+ });
122
+ });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable.com/sdk-core",
3
- "version": "3.9.14",
3
+ "version": "3.10.0",
4
4
  "description": "Core Embeddable SDK module responsible for web-components bundling and publishing.",
5
5
  "keywords": [
6
6
  "embeddable",
@@ -39,22 +39,22 @@
39
39
  "license": "MIT",
40
40
  "dependencies": {
41
41
  "@embeddable.com/sdk-utils": "*",
42
- "@inquirer/prompts": "^7.0.0",
43
- "@stencil/core": "^4.22.0",
42
+ "@inquirer/prompts": "^7.1.0",
43
+ "@stencil/core": "^4.22.2",
44
44
  "@swc-node/register": "^1.10.9",
45
- "archiver": "^5.3.1",
46
- "axios": "^1.7.2",
47
- "chokidar": "^3.6.0",
48
- "finalhandler": "^1.2.0",
45
+ "archiver": "^5.3.2",
46
+ "axios": "^1.7.7",
47
+ "chokidar": "^4.0.1",
48
+ "finalhandler": "^1.3.1",
49
49
  "formdata-node": "^6.0.3",
50
50
  "minimist": "^1.2.8",
51
51
  "open": "^9.1.0",
52
- "ora": "^8.0.1",
53
- "serve-static": "^1.15.0",
54
- "sorcery": "^0.11.0",
55
- "vite": "^5.4.8",
56
- "ws": "^8.17.0",
57
- "yaml": "^2.3.3"
52
+ "ora": "^8.1.1",
53
+ "serve-static": "^1.16.2",
54
+ "sorcery": "^0.11.1",
55
+ "vite": "^5.4.11",
56
+ "ws": "^8.18.0",
57
+ "yaml": "^2.6.0"
58
58
  },
59
59
  "lint-staged": {
60
60
  "*.{js,ts,json}": [
@@ -63,6 +63,6 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/archiver": "^5.3.4",
66
- "@types/ws": "^8.5.10"
66
+ "@types/ws": "^8.5.13"
67
67
  }
68
68
  }
package/src/build.test.ts CHANGED
@@ -5,7 +5,6 @@ import buildTypes from "./buildTypes";
5
5
  import provideConfig from "./provideConfig";
6
6
  import generate from "./generate";
7
7
  import cleanup from "./cleanup";
8
- import { initLogger, logError } from "./logger";
9
8
 
10
9
  // @ts-ignore
11
10
  import reportErrorToRollbar from "./rollbar.mjs";
@@ -5,7 +5,6 @@ import Rollbar from "rollbar";
5
5
  import * as path from "node:path";
6
6
  import * as fs from "node:fs/promises";
7
7
  import { jwtDecode } from "jwt-decode";
8
- import { readFile } from "node:fs";
9
8
 
10
9
  const config = {
11
10
  applicationEnvironment: "test",
package/src/entryPoint.js DELETED
@@ -1,12 +0,0 @@
1
- const COMMANDS_MAP = require("../lib/index.js");
2
-
3
- async function main() {
4
- const command = process.argv[2];
5
- const runScript = COMMANDS_MAP[command];
6
-
7
- if (!runScript) process.exit(1);
8
-
9
- await runScript();
10
- }
11
-
12
- main();