create-nube-app 0.21.0 → 0.22.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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Create Nube App",
4
4
  "author": "Tiendanube / Nuvemshop",
5
5
  "license": "MIT",
6
- "version": "0.21.0",
6
+ "version": "0.22.0",
7
7
  "bin": {
8
8
  "create-nube-app": "dist/index.js"
9
9
  },
@@ -13,7 +13,7 @@
13
13
  "author": "Tiendanube / Nuvemshop",
14
14
  "devDependencies": {
15
15
  "@biomejs/biome": "^1.9.4",
16
- "@tiendanube/nube-sdk-types": "^0.42.0",
16
+ "@tiendanube/nube-sdk-types": "^0.51.0",
17
17
  "@vitest/coverage-v8": "^3.0.9",
18
18
  "concurrently": "^9.1.2",
19
19
  "serve": "^14.2.4",
@@ -14,8 +14,8 @@
14
14
  "author": "Tiendanube / Nuvemshop",
15
15
  "devDependencies": {
16
16
  "@biomejs/biome": "^1.9.4",
17
- "@tiendanube/nube-sdk-ui": "^0.14.0",
18
- "@tiendanube/nube-sdk-types": "^0.42.0",
17
+ "@tiendanube/nube-sdk-ui": "^0.17.0",
18
+ "@tiendanube/nube-sdk-types": "^0.51.0",
19
19
  "@vitest/coverage-v8": "^3.0.9",
20
20
  "concurrently": "^9.1.2",
21
21
  "serve": "^14.2.4",
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Logo } from "./Logo";
3
+
4
+ // Mock the SDK functions
5
+ vi.mock("@tiendanube/nube-sdk-ui", () => ({
6
+ svgRoot: vi.fn((props) => props),
7
+ svgPath: vi.fn((props) => ({ type: "path", ...props })),
8
+ }));
9
+
10
+ describe("Logo", () => {
11
+ it("should return a valid SVG element", () => {
12
+ const result = Logo();
13
+ expect(result).toBeDefined();
14
+ expect(result.xmlns).toBe("http://www.w3.org/2000/svg");
15
+ expect(result.width).toBe("246");
16
+ expect(result.height).toBe("40");
17
+ expect(result.viewBox).toBe("0 0 123 20");
18
+ });
19
+ });
@@ -0,0 +1,53 @@
1
+ import { svgPath, svgRoot } from "@tiendanube/nube-sdk-ui";
2
+
3
+ export function Logo() {
4
+ return svgRoot({
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ width: "246",
7
+ height: "40",
8
+ viewBox: "0 0 123 20",
9
+ fill: "none",
10
+ children: [
11
+ svgPath({
12
+ d: "M35.4705 15.5619H33.3642V6.66537H35.4705V7.8454C35.7651 7.3963 36.1712 7.03139 36.6492 6.78641C37.1271 6.54143 37.6605 6.42479 38.1971 6.44789C40.3719 6.44789 41.6445 7.88164 41.6445 10.2054V15.5619H39.5382V10.6042C39.5382 9.22276 38.8495 8.38909 37.5607 8.38909C36.272 8.38909 35.4705 9.35164 35.4705 10.878V15.5619Z",
13
+ fill: "#0050c3",
14
+ }),
15
+ svgPath({
16
+ d: "M43.1709 11.7278V6.66537H45.2732V11.611C45.2732 13.0085 45.9659 13.8422 47.1258 13.8422C48.2857 13.8422 48.9784 13.0085 48.9784 11.611V6.66537H51.0847V11.7278C51.0847 14.2892 49.5946 15.7793 47.1258 15.7793C44.657 15.7793 43.1709 14.2892 43.1709 11.7278Z",
17
+ fill: "#0050c3",
18
+ }),
19
+ svgPath({
20
+ d: "M51.717 6.66538H53.9522L56.3284 12.8192L58.7448 6.64927H60.9236L57.2587 15.5458H55.4061L51.717 6.66538Z",
21
+ fill: "#0050c3",
22
+ }),
23
+ svgPath({
24
+ d: "M69.4013 13.4717C69.0175 14.1983 68.4352 14.801 67.7222 15.2096C67.0092 15.6181 66.1948 15.8157 65.3739 15.7794C62.6675 15.7794 60.7424 13.8543 60.7424 11.1116C60.7424 8.44548 62.7037 6.4479 65.2651 6.4479C67.8265 6.4479 69.6953 8.46159 69.6953 11.1116C69.6953 11.2767 69.6952 11.5143 69.6751 11.7479H62.8286C62.8914 12.3769 63.1901 12.9588 63.6646 13.3764C64.1391 13.7941 64.7541 14.0166 65.3859 13.9992C66.5499 13.9992 67.1459 13.4354 67.6574 12.6541L69.4013 13.4717ZM67.6211 10.2216C67.5565 9.64322 67.2758 9.11065 66.8352 8.73051C66.3945 8.35038 65.8265 8.15075 65.245 8.17162C64.6726 8.18618 64.1229 8.39827 63.6891 8.77189C63.2553 9.14552 62.9641 9.65769 62.8648 10.2216H67.6211Z",
25
+ fill: "#0050c3",
26
+ }),
27
+ svgPath({
28
+ d: "M72.9413 15.5619H70.835V6.66538H72.9413V7.8454C73.1927 7.39888 73.5638 7.03145 74.0128 6.78453C74.4619 6.53761 74.9709 6.42102 75.4826 6.4479C76.0466 6.42085 76.6058 6.56379 77.0876 6.8582C77.5694 7.15261 77.9517 7.58492 78.185 8.09913C78.4845 7.58327 78.9174 7.15767 79.4383 6.86709C79.9593 6.57651 80.5489 6.4317 81.1451 6.4479C83.1991 6.4479 84.367 7.86151 84.367 10.0967V15.5619H82.2607V10.4954C82.2607 9.18652 81.6606 8.37299 80.5531 8.37299C79.4456 8.37299 78.6643 9.29526 78.6481 10.7491V15.582H76.5418V10.5679C76.5418 9.18652 75.9417 8.37299 74.8342 8.37299C73.7267 8.37299 72.9293 9.3154 72.9293 10.8418L72.9413 15.5619Z",
29
+ fill: "#0050c3",
30
+ }),
31
+ svgPath({
32
+ d: "M86.9365 12.6179C87.0561 13.0009 87.2915 13.3375 87.6103 13.5813C87.9291 13.8251 88.3156 13.9641 88.7166 13.9791C89.3691 13.9791 89.9248 13.6892 89.9248 13.0569C89.9248 12.5655 89.6188 12.3118 88.9099 12.0943L87.8387 11.748C86.3324 11.2566 85.5672 10.4028 85.5672 9.17042C85.5672 7.49906 86.9647 6.44791 88.6361 6.44791C89.3107 6.43412 89.9747 6.61724 90.547 6.97488C91.1192 7.33251 91.5748 7.84915 91.858 8.4616L90.1665 9.36777C89.8242 8.66297 89.2966 8.18774 88.624 8.18774C88.0239 8.18774 87.5527 8.49785 87.5527 8.99322C87.5527 9.39596 87.8789 9.73829 88.5515 9.95576L89.6067 10.3021C91.274 10.866 91.9466 11.7157 91.9466 12.8958C91.9466 14.7121 90.4202 15.7673 88.6804 15.7673C87.9386 15.8033 87.2046 15.6027 86.5842 15.1944C85.9638 14.7862 85.4892 14.1914 85.2289 13.4958L86.9365 12.6179Z",
33
+ fill: "#0050c3",
34
+ }),
35
+ svgPath({
36
+ d: "M95.104 15.5619H92.9977V3.33474H95.104V7.84541C95.3982 7.39691 95.8037 7.03238 96.2809 6.78744C96.7581 6.54249 97.2906 6.42551 97.8265 6.44791C100.005 6.44791 101.278 7.88166 101.278 10.2055V15.5619H99.1717V10.6042C99.1717 9.22277 98.483 8.38911 97.1942 8.38911C95.9055 8.38911 95.104 9.35165 95.104 10.878V15.5619Z",
37
+ fill: "#0050c3",
38
+ }),
39
+ svgPath({
40
+ d: "M111.85 11.1116C111.865 12.0523 111.6 12.9761 111.089 13.7657C110.577 14.5552 109.842 15.1747 108.977 15.5452C108.113 15.9157 107.157 16.0206 106.233 15.8464C105.308 15.6723 104.456 15.2269 103.786 14.5672C103.115 13.9074 102.656 13.063 102.467 12.1414C102.278 11.2199 102.367 10.2629 102.723 9.39225C103.08 8.52162 103.687 7.77673 104.468 7.25241C105.249 6.72808 106.169 6.44803 107.11 6.44791C107.73 6.43165 108.348 6.54059 108.925 6.76823C109.502 6.99587 110.028 7.33755 110.47 7.77285C110.913 8.20815 111.263 8.72815 111.5 9.3018C111.737 9.87545 111.856 10.491 111.85 11.1116ZM104.46 11.1116C104.477 11.6316 104.647 12.135 104.949 12.559C105.25 12.983 105.67 13.3088 106.155 13.4958C106.641 13.6829 107.171 13.7229 107.679 13.6109C108.187 13.4988 108.651 13.2397 109.013 12.8658C109.374 12.4919 109.618 12.0198 109.713 11.5083C109.809 10.9968 109.751 10.4686 109.548 9.98949C109.345 9.51041 109.006 9.10165 108.572 8.81419C108.139 8.52673 107.63 8.37329 107.11 8.373C106.756 8.37769 106.407 8.45247 106.082 8.59301C105.758 8.73355 105.464 8.93706 105.219 9.19175C104.974 9.44645 104.781 9.74728 104.653 10.0768C104.525 10.4064 104.463 10.7581 104.472 11.1116H104.46Z",
41
+ fill: "#0050c3",
42
+ }),
43
+ svgPath({
44
+ d: "M115.164 6.66538V7.934C115.512 7.46384 115.966 7.08358 116.49 6.82504C117.014 6.5665 117.593 6.43718 118.177 6.4479C120.63 6.4479 122.518 8.46159 122.518 11.1116C122.518 13.7616 120.63 15.7794 118.177 15.7794C117.597 15.7991 117.02 15.6792 116.496 15.4297C115.972 15.1802 115.515 14.8084 115.164 14.3456V18.8845H113.058V6.66538H115.164ZM117.742 8.35285C117.193 8.33521 116.651 8.48189 116.186 8.7741C115.721 9.06632 115.353 9.49075 115.131 9.99304C114.908 10.4953 114.841 11.0526 114.937 11.5934C115.034 12.1343 115.289 12.6341 115.671 13.0288C116.053 13.4236 116.544 13.6952 117.082 13.8091C117.619 13.9229 118.178 13.8737 118.688 13.6677C119.197 13.4618 119.633 13.1085 119.94 12.6531C120.248 12.1977 120.412 11.661 120.412 11.1116C120.421 10.7544 120.358 10.3991 120.228 10.0663C120.098 9.73356 119.903 9.42997 119.655 9.17324C119.406 8.91652 119.109 8.71177 118.781 8.57093C118.452 8.43008 118.099 8.35596 117.742 8.35285Z",
45
+ fill: "#0050c3",
46
+ }),
47
+ svgPath({
48
+ d: "M17.7661 5.51016e-05C15.1695 0.00074292 12.6751 1.0118 10.8108 2.81923C9.62785 2.31908 8.33944 2.11956 7.06058 2.23846C5.78172 2.35737 4.55218 2.791 3.48167 3.50066C2.41116 4.21033 1.53297 5.17395 0.925454 6.30557C0.31794 7.43718 0 8.70158 0 9.98596C0 11.2703 0.31794 12.5347 0.925454 13.6664C1.53297 14.798 2.41116 15.7616 3.48167 16.4713C4.55218 17.1809 5.78172 17.6146 7.06058 17.7335C8.33944 17.8524 9.62785 17.6528 10.8108 17.1527C11.9846 18.2995 13.4225 19.1398 14.9978 19.5996C16.5731 20.0593 18.2373 20.1243 19.8437 19.7888C21.45 19.4533 22.9491 18.7277 24.2088 17.6759C25.4684 16.6241 26.4498 15.2785 27.0664 13.7578C27.6831 12.237 27.916 10.5879 27.7447 8.95587C27.5733 7.32384 27.003 5.75905 26.0839 4.39954C25.1649 3.04004 23.9254 1.92759 22.4748 1.16034C21.0242 0.393086 19.4071 -0.00539192 17.7661 5.51016e-05ZM17.7661 17.781C16.7423 17.7836 15.7279 17.5844 14.7811 17.1946C13.8343 16.8049 12.9736 16.2323 12.2483 15.5096C11.523 14.7869 10.9473 13.9283 10.5542 12.9829C10.161 12.0376 9.95809 11.0239 9.95704 10.0001H7.746C7.74544 11.89 8.28327 13.741 9.29655 15.3363C8.79677 15.4825 8.2788 15.5571 7.75808 15.5578C6.28407 15.5578 4.87042 14.9723 3.82813 13.93C2.78584 12.8877 2.20029 11.4741 2.20029 10.0001C2.20029 8.52604 2.78584 7.11239 3.82813 6.0701C4.87042 5.02781 6.28407 4.44226 7.75808 4.44226C8.48794 4.44226 9.21066 4.58602 9.88496 4.86532C10.5593 5.14463 11.1719 5.55401 11.688 6.0701C12.2041 6.58619 12.6135 7.19888 12.8928 7.87318C13.1721 8.54748 13.3159 9.2702 13.3159 10.0001H15.539C15.5451 8.86508 15.3007 7.74273 14.8231 6.71311C14.3456 5.68348 13.6466 4.77194 12.7762 4.04355C13.735 3.24008 14.8734 2.67974 16.0949 2.41008C17.3164 2.14042 18.5849 2.16939 19.7928 2.49455C21.0008 2.8197 22.1124 3.43144 23.0335 4.27786C23.9546 5.12427 24.6579 6.18038 25.0837 7.35657C25.5096 8.53277 25.6454 9.79433 25.4797 11.0342C25.314 12.2741 24.8517 13.4557 24.1319 14.4788C23.4122 15.5019 22.4562 16.3363 21.3452 16.9112C20.2342 17.486 19.0009 17.7844 17.75 17.781H17.7661Z",
49
+ fill: "#0050c3",
50
+ }),
51
+ ],
52
+ });
53
+ }
@@ -1,12 +1,40 @@
1
1
  import type { NubeSDK } from "@tiendanube/nube-sdk-types";
2
- import { MyCustomField } from "./components/MyCustomField";
2
+ import { column, text } from "@tiendanube/nube-sdk-ui";
3
+ import { Logo } from "./components/Logo";
3
4
 
4
5
  export function App(nube: NubeSDK) {
5
- nube.send("ui:slot:set", () => ({
6
- ui: {
7
- slots: {
8
- after_line_items: MyCustomField(),
6
+ nube.render(
7
+ "before_main_content",
8
+ column({
9
+ style: {
10
+ display: "flex",
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ paddingTop: "20px",
9
14
  },
10
- },
11
- }));
15
+ children: [
16
+ Logo(),
17
+ text({
18
+ color: "#626262",
19
+ children: "+",
20
+ }),
21
+ text({
22
+ heading: 1,
23
+ style: {
24
+ fontSize: "24px",
25
+ fontWeight: 600,
26
+ color: "#0050c3",
27
+ margin: "0",
28
+ padding: "0",
29
+ },
30
+ children: "NubeSDK",
31
+ }),
32
+ text({
33
+ color: "#626262",
34
+ children:
35
+ "https://dev.nuvemshop.com.br/docs/applications/nube-sdk/overview",
36
+ }),
37
+ ],
38
+ }),
39
+ );
12
40
  }
@@ -14,9 +14,9 @@
14
14
  "author": "Tiendanube / Nuvemshop",
15
15
  "devDependencies": {
16
16
  "@biomejs/biome": "^1.9.4",
17
- "@tiendanube/nube-sdk-ui": "^0.14.0",
18
- "@tiendanube/nube-sdk-jsx": "^0.13.0",
19
- "@tiendanube/nube-sdk-types": "^0.42.0",
17
+ "@tiendanube/nube-sdk-ui": "^0.17.0",
18
+ "@tiendanube/nube-sdk-jsx": "^0.16.0",
19
+ "@tiendanube/nube-sdk-types": "^0.51.0",
20
20
  "@vitest/coverage-v8": "^3.0.9",
21
21
  "concurrently": "^9.1.2",
22
22
  "serve": "^14.2.4",
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { Logo } from "./Logo";
3
+
4
+ // Mock the SDK SVG components
5
+ vi.mock("@tiendanube/nube-sdk-jsx", () => {
6
+ const createMockComponent = (name: string) => {
7
+ const Component = (props: Record<string, unknown>) => {
8
+ const { children, ...restProps } = props;
9
+ return {
10
+ type: name,
11
+ props: restProps,
12
+ children: children || [],
13
+ };
14
+ };
15
+ Component.displayName = name;
16
+ return Component;
17
+ };
18
+
19
+ return {
20
+ Svg: {
21
+ Root: createMockComponent("Svg.Root"),
22
+ Path: createMockComponent("Svg.Path"),
23
+ },
24
+ };
25
+ });
26
+
27
+ describe("Logo", () => {
28
+ it("should render", () => {
29
+ const result = Logo();
30
+ expect(result).toBeDefined();
31
+ });
32
+ });
@@ -1,6 +1,6 @@
1
+ import { Column, Text } from "@tiendanube/nube-sdk-jsx";
1
2
  import type { NubeSDK } from "@tiendanube/nube-sdk-types";
2
3
  import { styled } from "@tiendanube/nube-sdk-ui";
3
- import { Column, Text } from "@tiendanube/nube-sdk-jsx";
4
4
  import { Logo } from "./components/Logo";
5
5
 
6
6
  const StyledColumn = styled(Column)`
@@ -1,51 +0,0 @@
1
- import type {
2
- NubeComponent,
3
- NubeComponentBox,
4
- NubeComponentField,
5
- NubeSDKState,
6
- } from "@tiendanube/nube-sdk-types";
7
- import { describe, expect, it, vi } from "vitest";
8
- import { MyCustomField } from "./MyCustomField";
9
-
10
- describe("MyCustomField", () => {
11
- it("should render a Box with correct dimensions", () => {
12
- const result = MyCustomField() as NubeComponentBox;
13
-
14
- expect(result).toEqual({
15
- type: "box",
16
- width: 100,
17
- height: 200,
18
- children: expect.any(Array),
19
- });
20
- });
21
-
22
- it("should render a Field component with correct props", () => {
23
- const result = MyCustomField() as NubeComponentBox;
24
- const children = result.children as NubeComponent[];
25
- const field = children[0] as NubeComponentField;
26
-
27
- expect(field).toEqual({
28
- type: "field",
29
- id: "my-custom-field",
30
- label: "Name",
31
- name: "Name",
32
- onChange: expect.any(Function),
33
- });
34
- });
35
-
36
- it("should log user input when field changes", () => {
37
- const consoleSpy = vi.spyOn(console, "log");
38
- const result = MyCustomField() as NubeComponentBox;
39
- const children = result.children as NubeComponent[];
40
- const field = children[0] as NubeComponentField;
41
-
42
- // Simulate field change event
43
- field.onChange?.({
44
- type: "change",
45
- state: {} as NubeSDKState,
46
- value: "John Doe",
47
- });
48
-
49
- expect(consoleSpy).toHaveBeenCalledWith("User name: John Doe");
50
- });
51
- });
@@ -1,18 +0,0 @@
1
- import { box, field } from "@tiendanube/nube-sdk-ui";
2
-
3
- export function MyCustomField() {
4
- return box({
5
- width: 100,
6
- height: 200,
7
- children: [
8
- field({
9
- id: "my-custom-field",
10
- label: "Name",
11
- name: "Name",
12
- onChange: (e) => {
13
- console.log(`User name: ${e.value}`);
14
- },
15
- }),
16
- ],
17
- });
18
- }
@@ -1,52 +0,0 @@
1
- import type { NubeSDK, NubeSDKState } from "@tiendanube/nube-sdk-types";
2
- import { describe, expect, it, vi } from "vitest";
3
- import { App } from "./main";
4
-
5
- // Mock do componente MyCustomField
6
- vi.mock("./components/MyCustomField", () => ({
7
- MyCustomField: vi.fn(() => ({
8
- type: "box",
9
- width: 100,
10
- height: 100,
11
- })),
12
- }));
13
-
14
- describe("App", () => {
15
- it("should set MyCustomField component in after_line_items slot", () => {
16
- // Mock NubeSDK
17
- const mockNube: Partial<NubeSDK> = {
18
- send: vi.fn(),
19
- };
20
-
21
- // Execute App function with mock
22
- App(mockNube as NubeSDK);
23
-
24
- // Verify if send was called with correct parameters
25
- expect(mockNube.send).toHaveBeenCalledWith(
26
- "ui:slot:set",
27
- expect.any(Function),
28
- );
29
-
30
- // Get the slot setter function
31
- const slotSetter = (mockNube.send as ReturnType<typeof vi.fn>).mock
32
- .calls[0][1] as (state: NubeSDKState) => {
33
- ui: { slots: { after_line_items: unknown } };
34
- };
35
-
36
- // Execute the slot setter function
37
- const result = slotSetter({} as NubeSDKState);
38
-
39
- // Verify if the slot was set with MyCustomField component
40
- expect(result).toEqual({
41
- ui: {
42
- slots: {
43
- after_line_items: expect.objectContaining({
44
- type: "box",
45
- width: 100,
46
- height: 100,
47
- }),
48
- },
49
- },
50
- });
51
- });
52
- });
@@ -1,52 +0,0 @@
1
- import type { NubeSDK, NubeSDKState } from "@tiendanube/nube-sdk-types";
2
- import { describe, expect, it, vi } from "vitest";
3
- import { App } from "./main";
4
-
5
- // Mock do componente MyCustomField
6
- vi.mock("./components/MyCustomField", () => ({
7
- MyCustomField: vi.fn(() => ({
8
- type: "box",
9
- width: 100,
10
- height: 100,
11
- })),
12
- }));
13
-
14
- describe("App", () => {
15
- it("should set MyCustomField component in after_line_items slot", () => {
16
- // Mock NubeSDK
17
- const mockNube: Partial<NubeSDK> = {
18
- send: vi.fn(),
19
- };
20
-
21
- // Execute App function with mock
22
- App(mockNube as NubeSDK);
23
-
24
- // Verify if send was called with correct parameters
25
- expect(mockNube.send).toHaveBeenCalledWith(
26
- "ui:slot:set",
27
- expect.any(Function),
28
- );
29
-
30
- // Get the slot setter function
31
- const slotSetter = (mockNube.send as ReturnType<typeof vi.fn>).mock
32
- .calls[0][1] as (state: NubeSDKState) => {
33
- ui: { slots: { after_line_items: unknown } };
34
- };
35
-
36
- // Execute the slot setter function
37
- const result = slotSetter({} as NubeSDKState);
38
-
39
- // Verify if the slot was set with MyCustomField component
40
- expect(result).toEqual({
41
- ui: {
42
- slots: {
43
- after_line_items: expect.objectContaining({
44
- type: "box",
45
- width: 100,
46
- height: 100,
47
- }),
48
- },
49
- },
50
- });
51
- });
52
- });