@canva/cli 0.0.1-beta.15 → 0.0.1-beta.17

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 (28) hide show
  1. package/cli.js +450 -454
  2. package/lib/cjs/index.cjs +318 -322
  3. package/lib/esm/index.mjs +388 -0
  4. package/package.json +2 -2
  5. package/templates/base/eslint.config.mjs +2 -2
  6. package/templates/base/package.json +4 -4
  7. package/templates/base/scripts/start/app_runner.ts +1 -1
  8. package/templates/{dam/webpack.config.cjs → base/webpack.config.ts} +33 -43
  9. package/templates/common/conf/{eslint-general.mjs → eslint_general.mjs} +8 -0
  10. package/templates/dam/eslint.config.mjs +2 -2
  11. package/templates/dam/package.json +15 -14
  12. package/templates/dam/scripts/start/app_runner.ts +1 -1
  13. package/templates/{gen_ai/webpack.config.cjs → dam/webpack.config.ts} +33 -43
  14. package/templates/gen_ai/eslint.config.mjs +2 -2
  15. package/templates/gen_ai/package.json +18 -15
  16. package/templates/gen_ai/scripts/start/app_runner.ts +1 -1
  17. package/templates/{base/webpack.config.cjs → gen_ai/webpack.config.ts} +33 -43
  18. package/templates/hello_world/eslint.config.mjs +2 -2
  19. package/templates/hello_world/package.json +15 -14
  20. package/templates/hello_world/scripts/start/app_runner.ts +1 -1
  21. package/templates/hello_world/src/tests/__snapshots__/app.tests.tsx.snap +3 -3
  22. package/templates/hello_world/{webpack.config.cjs → webpack.config.ts} +33 -43
  23. package/lib/esm/index.esm +0 -392
  24. /package/templates/base/scripts/{copy-env.ts → copy_env.ts} +0 -0
  25. /package/templates/common/conf/{eslint-i18n.mjs → eslint_i18n.mjs} +0 -0
  26. /package/templates/dam/scripts/{copy-env.ts → copy_env.ts} +0 -0
  27. /package/templates/gen_ai/scripts/{copy-env.ts → copy_env.ts} +0 -0
  28. /package/templates/hello_world/scripts/{copy-env.ts → copy_env.ts} +0 -0
@@ -4,7 +4,7 @@
4
4
  "description": "An empty Canva App",
5
5
  "scripts": {
6
6
  "extract": "formatjs extract \"src/**/*.{ts,tsx}\" --out-file dist/messages_en.json",
7
- "build": "webpack --config webpack.config.cjs --mode production && npm run extract",
7
+ "build": "webpack --config webpack.config.ts --mode production && npm run extract",
8
8
  "format": "prettier '**/*.{css,ts,tsx}' --no-config --write",
9
9
  "format:check": "prettier '**/*.{css,ts,tsx}' --no-config --check --ignore-path",
10
10
  "format:file": "prettier $1 --no-config --write",
@@ -15,11 +15,11 @@
15
15
  "test": "jest --no-cache",
16
16
  "test:watch": "jest --watchAll",
17
17
  "test:update": "npm run test -- -u",
18
- "postinstall": "ts-node ./scripts/copy-env.ts"
18
+ "postinstall": "ts-node ./scripts/copy_env.ts"
19
19
  },
20
20
  "dependencies": {
21
21
  "@canva/app-i18n-kit": "^1.0.2",
22
- "@canva/app-ui-kit": "^4.5.0",
22
+ "@canva/app-ui-kit": "^4.7.0",
23
23
  "@canva/asset": "^2.1.0",
24
24
  "@canva/design": "^2.3.0",
25
25
  "@canva/error": "^2.1.0",
@@ -32,9 +32,9 @@
32
32
  "devDependencies": {
33
33
  "@canva/cli": ">= 0.0.1-beta.13 < 0.0.2",
34
34
  "@eslint/eslintrc": "3.2.0",
35
- "@eslint/js": "9.16.0",
36
- "@formatjs/cli": "6.3.14",
37
- "@formatjs/ts-transformer": "3.13.26",
35
+ "@eslint/js": "9.18.0",
36
+ "@formatjs/cli": "6.3.15",
37
+ "@formatjs/ts-transformer": "3.13.27",
38
38
  "@ngrok/ngrok": "1.4.1",
39
39
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
40
40
  "@svgr/webpack": "8.1.0",
@@ -50,8 +50,8 @@
50
50
  "@types/react": "18.3.12",
51
51
  "@types/react-dom": "18.3.1",
52
52
  "@types/webpack-env": "1.18.5",
53
- "@typescript-eslint/eslint-plugin": "8.18.0",
54
- "@typescript-eslint/parser": "8.18.0",
53
+ "@typescript-eslint/eslint-plugin": "8.20.0",
54
+ "@typescript-eslint/parser": "8.20.0",
55
55
  "chalk": "4.1.2",
56
56
  "cli-table3": "0.6.5",
57
57
  "css-loader": "7.1.2",
@@ -59,10 +59,11 @@
59
59
  "cssnano": "7.0.6",
60
60
  "debug": "4.4.0",
61
61
  "dotenv": "16.4.7",
62
- "eslint": "9.16.0",
62
+ "eslint": "9.18.0",
63
63
  "eslint-plugin-formatjs": "5.2.8",
64
- "eslint-plugin-jest": "28.9.0",
65
- "eslint-plugin-react": "7.37.2",
64
+ "eslint-plugin-jest": "28.11.0",
65
+ "eslint-plugin-react": "7.37.4",
66
+ "eslint-plugin-unicorn": "56.0.1",
66
67
  "express": "4.21.2",
67
68
  "express-basic-auth": "1.2.1",
68
69
  "jest": "29.7.0",
@@ -79,15 +80,15 @@
79
80
  "prettier": "3.4.2",
80
81
  "react-refresh": "0.16.0",
81
82
  "style-loader": "4.0.0",
82
- "terser-webpack-plugin": "5.3.10",
83
+ "terser-webpack-plugin": "5.3.11",
83
84
  "ts-jest": "29.2.5",
84
- "ts-loader": "9.5.1",
85
+ "ts-loader": "9.5.2",
85
86
  "ts-node": "10.9.2",
86
87
  "typescript": "5.5.4",
87
88
  "url-loader": "4.1.1",
88
89
  "webpack": "5.97.1",
89
90
  "webpack-cli": "5.1.4",
90
- "webpack-dev-server": "5.1.0",
91
+ "webpack-dev-server": "5.2.0",
91
92
  "yargs": "17.7.2"
92
93
  }
93
94
  }
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  import type { Context } from "./context";
3
3
  import * as chalk from "chalk";
4
- import { buildConfig } from "../../webpack.config.cjs";
4
+ import { buildConfig } from "../../webpack.config.js";
5
5
  import * as ngrok from "@ngrok/ngrok";
6
6
  import * as nodemon from "nodemon";
7
7
  import * as Table from "cli-table3";
@@ -10,7 +10,7 @@ exports[`Hello World Tests should have a consistent snapshot 1`] = `
10
10
  style="--NZu1Zw: 16px;"
11
11
  >
12
12
  <p
13
- class="D6xAvw E44aNA rU8RQQ"
13
+ class="aWBg0w aZskFA u16U_g"
14
14
  >
15
15
  To make changes to this app, edit the
16
16
  <code>
@@ -19,7 +19,7 @@ exports[`Hello World Tests should have a consistent snapshot 1`] = `
19
19
  file, then close and reopen the app in the editor to preview the changes.
20
20
  </p>
21
21
  <button
22
- class="_5KtATA LQzFZw xwTbNA _8ERLTg rV61VQ LQzFZw xwTbNA _4_iekA _3oHQrw j34Zww aqbYPg _3FvZZg"
22
+ class="_5KtATA LQzFZw VgvqkQ _8ERLTg rV61VQ LQzFZw VgvqkQ _4_iekA _3oHQrw j34Zww aqbYPg _3FvZZg"
23
23
  type="button"
24
24
  >
25
25
  <span
@@ -29,7 +29,7 @@ exports[`Hello World Tests should have a consistent snapshot 1`] = `
29
29
  </span>
30
30
  </button>
31
31
  <button
32
- class="_5KtATA LQzFZw xwTbNA _8ERLTg Z3nT2A LQzFZw xwTbNA _4_iekA j34Zww aqbYPg _3FvZZg"
32
+ class="_5KtATA LQzFZw VgvqkQ _8ERLTg Z3nT2A LQzFZw VgvqkQ _4_iekA j34Zww aqbYPg _3FvZZg"
33
33
  type="button"
34
34
  >
35
35
  <span
@@ -1,31 +1,33 @@
1
- require("dotenv").config();
2
- const path = require("path");
3
- const TerserPlugin = require("terser-webpack-plugin");
4
- const { DefinePlugin, optimize } = require("webpack");
5
- const chalk = require("chalk");
6
- const { transform } = require("@formatjs/ts-transformer");
7
- const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
1
+ import type { Configuration } from "webpack";
2
+ import { DefinePlugin, optimize } from "webpack";
3
+ import * as path from "path";
4
+ import * as TerserPlugin from "terser-webpack-plugin";
5
+ import { transform } from "@formatjs/ts-transformer";
6
+ import * as chalk from "chalk";
7
+ import { config } from "dotenv";
8
+ import { Configuration as DevServerConfiguration } from "webpack-dev-server";
8
9
 
9
- /**
10
- *
11
- * @param {Object} [options]
12
- * @param {string} [options.appEntry=./src/index.tsx]
13
- * @param {string} [options.backendHost]
14
- * @param {Object} [options.devConfig]
15
- * @param {number} [options.devConfig.port]
16
- * @param {boolean} [options.devConfig.enableHmr]
17
- * @param {boolean} [options.devConfig.enableHttps]
18
- * @param {string} [options.devConfig.appOrigin]
19
- * @param {string} [options.devConfig.appId] - Deprecated in favour of appOrigin
20
- * @param {string} [options.devConfig.certFile]
21
- * @param {string} [options.devConfig.keyFile]
22
- * @returns {Object}
23
- */
24
- function buildConfig({
10
+ config();
11
+
12
+ type DevConfig = {
13
+ port: number;
14
+ enableHmr: boolean;
15
+ enableHttps: boolean;
16
+ appOrigin?: string;
17
+ appId?: string; // Deprecated in favour of appOrigin
18
+ certFile?: string;
19
+ keyFile?: string;
20
+ };
21
+
22
+ export function buildConfig({
25
23
  devConfig,
26
24
  appEntry = path.join(process.cwd(), "src", "index.tsx"),
27
25
  backendHost = process.env.CANVA_BACKEND_HOST,
28
- } = {}) {
26
+ }: {
27
+ devConfig?: DevConfig;
28
+ appEntry?: string;
29
+ backendHost?: string;
30
+ } = {}): Configuration & DevServerConfiguration {
29
31
  const mode = devConfig ? "development" : "production";
30
32
 
31
33
  if (!backendHost) {
@@ -174,33 +176,23 @@ function buildConfig({
174
176
  }),
175
177
  // Apps can only submit a single JS file via the developer portal
176
178
  new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
177
- mode === "development" && new ReactRefreshWebpackPlugin(),
178
179
  ].filter(Boolean),
179
180
  ...buildDevConfig(devConfig),
180
181
  };
181
182
  }
182
183
 
183
- /**
184
- *
185
- * @param {Object} [options]
186
- * @param {number} [options.port]
187
- * @param {boolean} [options.enableHmr]
188
- * @param {boolean} [options.enableHttps]
189
- * @param {string} [options.appOrigin]
190
- * @param {string} [options.appId] - Deprecated in favour of appOrigin
191
- * @param {string} [options.certFile]
192
- * @param {string} [options.keyFile]
193
- * @returns {Object|null}
194
- */
195
- function buildDevConfig(options) {
184
+ function buildDevConfig(options?: DevConfig): {
185
+ devtool?: string;
186
+ devServer?: DevServerConfiguration;
187
+ } {
196
188
  if (!options) {
197
- return null;
189
+ return {};
198
190
  }
199
191
 
200
192
  const { port, enableHmr, appOrigin, appId, enableHttps, certFile, keyFile } =
201
193
  options;
202
194
 
203
- let devServer = {
195
+ let devServer: DevServerConfiguration = {
204
196
  server: enableHttps
205
197
  ? {
206
198
  type: "https",
@@ -267,6 +259,4 @@ function buildDevConfig(options) {
267
259
  };
268
260
  }
269
261
 
270
- module.exports = () => buildConfig();
271
-
272
- module.exports.buildConfig = buildConfig;
262
+ export default buildConfig;