@canva/cli 0.0.1-beta.35 → 0.0.1-beta.37

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 (79) hide show
  1. package/cli.js +612 -612
  2. package/lib/cjs/index.cjs +3 -3
  3. package/lib/esm/index.mjs +4 -4
  4. package/package.json +1 -1
  5. package/templates/base/backend/routers/auth.ts +4 -4
  6. package/templates/base/backend/routers/oauth.ts +2 -2
  7. package/templates/base/scripts/ssl/ssl.ts +1 -1
  8. package/templates/base/scripts/start/app_runner.ts +6 -6
  9. package/templates/base/scripts/start/start.ts +1 -1
  10. package/templates/base/utils/backend/base_backend/create.ts +3 -3
  11. package/templates/base/utils/backend/bearer_middleware/bearer_middleware.ts +1 -1
  12. package/templates/base/utils/backend/jwt_middleware/jwt_middleware.ts +3 -3
  13. package/templates/base/utils/use_add_element.ts +1 -1
  14. package/templates/base/utils/use_feature_support.ts +1 -1
  15. package/templates/base/webpack.config.ts +1 -1
  16. package/templates/common/utils/backend/base_backend/create.ts +3 -3
  17. package/templates/common/utils/backend/jwt_middleware/jwt_middleware.ts +3 -3
  18. package/templates/common/utils/tests/table_wrapper.tests.ts +1 -1
  19. package/templates/common/utils/use_add_element.ts +1 -1
  20. package/templates/common/utils/use_feature_support.ts +1 -1
  21. package/templates/dam/backend/routers/dam.ts +2 -2
  22. package/templates/dam/backend/server.ts +1 -1
  23. package/templates/dam/scripts/ssl/ssl.ts +1 -1
  24. package/templates/dam/scripts/start/app_runner.ts +6 -6
  25. package/templates/dam/scripts/start/start.ts +1 -1
  26. package/templates/dam/src/app.tsx +1 -1
  27. package/templates/dam/src/index.tsx +1 -1
  28. package/templates/dam/utils/backend/base_backend/create.ts +3 -3
  29. package/templates/dam/utils/backend/jwt_middleware/jwt_middleware.ts +3 -3
  30. package/templates/dam/webpack.config.ts +1 -1
  31. package/templates/data_connector/scripts/ssl/ssl.ts +1 -1
  32. package/templates/data_connector/scripts/start/app_runner.ts +6 -6
  33. package/templates/data_connector/scripts/start/start.ts +1 -1
  34. package/templates/data_connector/src/api/data_source.ts +1 -1
  35. package/templates/data_connector/src/api/data_sources/designs.tsx +9 -9
  36. package/templates/data_connector/src/api/data_sources/templates.tsx +9 -9
  37. package/templates/data_connector/src/api/fetch_data_table.ts +1 -1
  38. package/templates/data_connector/src/api/tests/data_source.test.tsx +2 -2
  39. package/templates/data_connector/src/app.tsx +5 -5
  40. package/templates/data_connector/src/components/footer.tsx +1 -1
  41. package/templates/data_connector/src/components/header.tsx +1 -1
  42. package/templates/data_connector/src/context/app_context.tsx +1 -1
  43. package/templates/data_connector/src/entrypoint.tsx +7 -7
  44. package/templates/data_connector/src/home.tsx +2 -2
  45. package/templates/data_connector/src/index.tsx +5 -6
  46. package/templates/data_connector/src/pages/error.tsx +2 -2
  47. package/templates/data_connector/src/pages/login.tsx +7 -7
  48. package/templates/data_connector/src/routes/routes.tsx +1 -1
  49. package/templates/data_connector/src/utils/data_table.ts +1 -1
  50. package/templates/data_connector/src/utils/fetch_result.ts +1 -1
  51. package/templates/data_connector/src/utils/tests/data_table.test.ts +5 -5
  52. package/templates/data_connector/webpack.config.ts +1 -1
  53. package/templates/gen_ai/backend/server.ts +1 -1
  54. package/templates/gen_ai/scripts/ssl/ssl.ts +1 -1
  55. package/templates/gen_ai/scripts/start/app_runner.ts +6 -6
  56. package/templates/gen_ai/scripts/start/start.ts +1 -1
  57. package/templates/gen_ai/src/app.tsx +3 -3
  58. package/templates/gen_ai/src/components/footer.tsx +4 -4
  59. package/templates/gen_ai/src/components/image_grid.tsx +1 -1
  60. package/templates/gen_ai/src/components/loading_results.tsx +8 -8
  61. package/templates/gen_ai/src/components/prompt_input.tsx +3 -3
  62. package/templates/gen_ai/src/components/remaining_credits.tsx +1 -1
  63. package/templates/gen_ai/src/components/report_box.tsx +1 -1
  64. package/templates/gen_ai/src/components/tests/remaining_credit.tests.tsx +2 -2
  65. package/templates/gen_ai/src/home.tsx +2 -2
  66. package/templates/gen_ai/src/pages/error.tsx +2 -2
  67. package/templates/gen_ai/src/pages/results.tsx +1 -1
  68. package/templates/gen_ai/utils/backend/base_backend/create.ts +3 -3
  69. package/templates/gen_ai/utils/backend/bearer_middleware/bearer_middleware.ts +1 -1
  70. package/templates/gen_ai/webpack.config.ts +1 -1
  71. package/templates/hello_world/scripts/ssl/ssl.ts +1 -1
  72. package/templates/hello_world/scripts/start/app_runner.ts +6 -6
  73. package/templates/hello_world/scripts/start/start.ts +1 -1
  74. package/templates/hello_world/src/app.tsx +1 -1
  75. package/templates/hello_world/src/index.tsx +1 -1
  76. package/templates/hello_world/src/tests/app.tests.tsx +3 -3
  77. package/templates/hello_world/utils/use_add_element.ts +1 -1
  78. package/templates/hello_world/utils/use_feature_support.ts +1 -1
  79. package/templates/hello_world/webpack.config.ts +1 -1
@@ -1,5 +1,3 @@
1
- import { useState } from "react";
2
- import { useLocation } from "react-router-dom";
3
1
  import {
4
2
  Box,
5
3
  Button,
@@ -7,10 +5,12 @@ import {
7
5
  LightBulbIcon,
8
6
  MultilineInput,
9
7
  } from "@canva/app-ui-kit";
8
+ import { useState } from "react";
9
+ import { useIntl } from "react-intl";
10
+ import { useLocation } from "react-router-dom";
10
11
  import { useAppContext } from "src/context";
11
12
  import { Paths } from "src/routes";
12
13
  import { PromptInputMessages as Messages } from "./prompt_input.messages";
13
- import { useIntl } from "react-intl";
14
14
 
15
15
  // @TODO: Adjust according to your specific requirements.
16
16
  const MAX_INPUT_LENGTH = 280;
@@ -1,7 +1,7 @@
1
1
  import { Link, Rows, Text, TextPlaceholder } from "@canva/app-ui-kit";
2
2
  import { requestOpenExternalUrl } from "@canva/platform";
3
- import { useAppContext } from "src/context";
4
3
  import { FormattedMessage, useIntl } from "react-intl";
4
+ import { useAppContext } from "src/context";
5
5
 
6
6
  // @TODO: Replace this URL with your custom upselling link.
7
7
  const PURCHASE_URL = "https://example.com";
@@ -1,4 +1,4 @@
1
- import { Box, Columns, Column, FlagIcon, Text, Link } from "@canva/app-ui-kit";
1
+ import { Box, Column, Columns, FlagIcon, Link, Text } from "@canva/app-ui-kit";
2
2
  import { requestOpenExternalUrl } from "@canva/platform";
3
3
  import { FormattedMessage, useIntl } from "react-intl";
4
4
  import { APP_NAME } from "src/config";
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable formatjs/no-literal-string-in-jsx */
2
- import { TestAppUiProvider } from "@canva/app-ui-kit";
3
2
  import { TestAppI18nProvider } from "@canva/app-i18n-kit";
3
+ import { TestAppUiProvider } from "@canva/app-ui-kit";
4
+ import { requestOpenExternalUrl } from "@canva/platform";
4
5
  import type { RenderResult } from "@testing-library/react";
5
6
  import { fireEvent, render } from "@testing-library/react";
6
7
  import React from "react";
7
8
  import { RemainingCredits } from "../remaining_credits";
8
- import { requestOpenExternalUrl } from "@canva/platform";
9
9
 
10
10
  function renderInTestProvider(node: React.ReactNode): RenderResult {
11
11
  return render(
@@ -1,7 +1,7 @@
1
- import { Outlet } from "react-router-dom";
2
1
  import { Rows } from "@canva/app-ui-kit";
3
- import { Footer } from "./components";
2
+ import { Outlet } from "react-router-dom";
4
3
  import * as styles from "styles/components.css";
4
+ import { Footer } from "./components";
5
5
 
6
6
  export const Home = () => (
7
7
  <div className={styles.scrollContainer}>
@@ -1,9 +1,9 @@
1
- import { useNavigate } from "react-router-dom";
2
1
  import { Button, Rows, Text } from "@canva/app-ui-kit";
2
+ import { FormattedMessage, useIntl } from "react-intl";
3
+ import { useNavigate } from "react-router-dom";
3
4
  import { useAppContext } from "src/context";
4
5
  import { Paths } from "src/routes";
5
6
  import * as styles from "styles/components.css";
6
- import { FormattedMessage, useIntl } from "react-intl";
7
7
 
8
8
  /**
9
9
  * Bare bones Error Page, please add relevant information and behavior that your app requires.
@@ -6,8 +6,8 @@ import {
6
6
  PromptInput,
7
7
  ReportBox,
8
8
  } from "src/components";
9
- import { useAppContext } from "src/context";
10
9
  import { EXPECTED_LOADING_TIME_IN_SECONDS } from "src/config";
10
+ import { useAppContext } from "src/context";
11
11
 
12
12
  export const ResultsPage = () => {
13
13
  const { isLoadingImages } = useAppContext();
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable no-console */
2
+ import debug from "debug";
2
3
  import * as express from "express";
4
+ import type { NextFunction, Request, Response } from "express";
5
+ import * as fs from "fs";
3
6
  import * as http from "http";
4
7
  import * as https from "https";
5
- import * as fs from "fs";
6
- import type { Request, Response, NextFunction } from "express";
7
- import debug from "debug";
8
8
 
9
9
  const serverDebug = debug("server");
10
10
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
  import * as debug from "debug";
3
- import type { Request, Response, NextFunction } from "express";
3
+ import type { NextFunction, Request, Response } from "express";
4
4
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
5
  import Express from "express-serve-static-core";
6
6
 
@@ -182,7 +182,7 @@ export function buildConfig({
182
182
  new DefinePlugin({
183
183
  BACKEND_HOST: JSON.stringify(backendHost),
184
184
  }),
185
- // Apps can only submit a single JS file via the developer portal
185
+ // Apps can only submit a single JS file via the Developer Portal
186
186
  new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
187
187
  ].filter(Boolean),
188
188
  ...buildDevConfig(devConfig),
@@ -1,7 +1,7 @@
1
1
  import * as crypto from "crypto";
2
+ import * as fs from "fs/promises";
2
3
  import { pki } from "node-forge";
3
4
  import * as path from "path";
4
- import * as fs from "fs/promises";
5
5
 
6
6
  const SSL_CERT_DIR = path.resolve(process.cwd(), "..", "..", ".ssl");
7
7
  const CERT_FILE = path.resolve(SSL_CERT_DIR, "certificate.pem");
@@ -1,16 +1,16 @@
1
1
  /* eslint-disable no-console */
2
- import type { Context } from "./context";
3
- import * as chalk from "chalk";
4
- import { buildConfig } from "../../webpack.config";
2
+ import { generatePreviewUrl } from "@canva/cli";
5
3
  import * as ngrok from "@ngrok/ngrok";
6
- import * as nodemon from "nodemon";
4
+ import * as chalk from "chalk";
7
5
  import * as Table from "cli-table3";
6
+ import * as nodemon from "nodemon";
7
+ import * as open from "open";
8
8
  import * as webpack from "webpack";
9
9
  import * as WebpackDevServer from "webpack-dev-server";
10
- import * as open from "open";
11
- import { generatePreviewUrl } from "@canva/cli";
10
+ import { buildConfig } from "../../webpack.config";
12
11
  import type { Certificate } from "../ssl/ssl";
13
12
  import { createOrRetrieveCertificate } from "../ssl/ssl";
13
+ import type { Context } from "./context";
14
14
 
15
15
  export const infoChalk = chalk.blue.bold;
16
16
  export const warnChalk = chalk.bgYellow.bold;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import * as yargs from "yargs";
3
- import { AppRunner } from "./app_runner";
4
3
  import { hideBin } from "yargs/helpers";
4
+ import { AppRunner } from "./app_runner";
5
5
  import { Context } from "./context";
6
6
 
7
7
  const appRunner = new AppRunner();
@@ -1,8 +1,8 @@
1
1
  import { Button, Rows, Text } from "@canva/app-ui-kit";
2
2
  import { requestOpenExternalUrl } from "@canva/platform";
3
3
  import { FormattedMessage, useIntl } from "react-intl";
4
- import * as styles from "styles/components.css";
5
4
  import { useAddElement } from "utils/use_add_element";
5
+ import * as styles from "styles/components.css";
6
6
 
7
7
  export const DOCS_URL = "https://www.canva.dev/docs/apps/";
8
8
 
@@ -1,8 +1,8 @@
1
+ import { AppI18nProvider } from "@canva/app-i18n-kit";
1
2
  import { AppUiProvider } from "@canva/app-ui-kit";
2
3
  import { createRoot } from "react-dom/client";
3
4
  import { App } from "./app";
4
5
  import "@canva/app-ui-kit/styles.css";
5
- import { AppI18nProvider } from "@canva/app-i18n-kit";
6
6
 
7
7
  const root = createRoot(document.getElementById("root") as Element);
8
8
  function render() {
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable formatjs/no-literal-string-in-jsx */
2
- import React from "react";
3
- import type { RenderResult } from "@testing-library/react";
4
- import { fireEvent, render } from "@testing-library/react";
5
2
  import { TestAppI18nProvider } from "@canva/app-i18n-kit";
6
3
  import { TestAppUiProvider } from "@canva/app-ui-kit";
7
4
  import { requestOpenExternalUrl } from "@canva/platform";
5
+ import { fireEvent, render } from "@testing-library/react";
6
+ import type { RenderResult } from "@testing-library/react";
7
+ import React from "react";
8
8
  import { useAddElement } from "utils/use_add_element";
9
9
  import { App, DOCS_URL } from "../app";
10
10
 
@@ -7,9 +7,9 @@ import type {
7
7
  VideoElement,
8
8
  } from "@canva/design";
9
9
  import { addElementAtCursor, addElementAtPoint } from "@canva/design";
10
- import { useFeatureSupport } from "./use_feature_support";
11
10
  import { features } from "@canva/platform";
12
11
  import { useEffect, useState } from "react";
12
+ import { useFeatureSupport } from "./use_feature_support";
13
13
 
14
14
  type AddElementParams =
15
15
  | ImageElement
@@ -1,6 +1,6 @@
1
1
  import { features } from "@canva/platform";
2
2
  import type { Feature } from "@canva/platform";
3
- import { useState, useEffect } from "react";
3
+ import { useEffect, useState } from "react";
4
4
 
5
5
  /**
6
6
  * This hook allows re-rendering of a React component whenever
@@ -182,7 +182,7 @@ export function buildConfig({
182
182
  new DefinePlugin({
183
183
  BACKEND_HOST: JSON.stringify(backendHost),
184
184
  }),
185
- // Apps can only submit a single JS file via the developer portal
185
+ // Apps can only submit a single JS file via the Developer Portal
186
186
  new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
187
187
  ].filter(Boolean),
188
188
  ...buildDevConfig(devConfig),