@canva/cli 0.0.1-beta.1

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 (109) hide show
  1. package/LICENSE.md +48 -0
  2. package/README.md +206 -0
  3. package/cli.js +566 -0
  4. package/package.json +30 -0
  5. package/templates/base/backend/database/database.ts +42 -0
  6. package/templates/base/backend/routers/auth.ts +285 -0
  7. package/templates/base/declarations/declarations.d.ts +29 -0
  8. package/templates/base/eslint.config.mjs +309 -0
  9. package/templates/base/package.json +83 -0
  10. package/templates/base/scripts/ssl/ssl.ts +131 -0
  11. package/templates/base/scripts/start/app_runner.ts +164 -0
  12. package/templates/base/scripts/start/context.ts +165 -0
  13. package/templates/base/scripts/start/start.ts +35 -0
  14. package/templates/base/styles/components.css +38 -0
  15. package/templates/base/tsconfig.json +54 -0
  16. package/templates/base/utils/backend/base_backend/create.ts +104 -0
  17. package/templates/base/utils/backend/jwt_middleware/index.ts +1 -0
  18. package/templates/base/utils/backend/jwt_middleware/jwt_middleware.ts +229 -0
  19. package/templates/base/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +630 -0
  20. package/templates/base/webpack.config.cjs +270 -0
  21. package/templates/common/.env.template +6 -0
  22. package/templates/common/.gitignore.template +9 -0
  23. package/templates/common/LICENSE.md +48 -0
  24. package/templates/common/README.md +250 -0
  25. package/templates/common/jest.config.mjs +8 -0
  26. package/templates/dam/backend/database/database.ts +42 -0
  27. package/templates/dam/backend/routers/auth.ts +285 -0
  28. package/templates/dam/backend/routers/dam.ts +86 -0
  29. package/templates/dam/backend/server.ts +65 -0
  30. package/templates/dam/declarations/declarations.d.ts +29 -0
  31. package/templates/dam/eslint.config.mjs +309 -0
  32. package/templates/dam/package.json +90 -0
  33. package/templates/dam/scripts/ssl/ssl.ts +131 -0
  34. package/templates/dam/scripts/start/app_runner.ts +164 -0
  35. package/templates/dam/scripts/start/context.ts +165 -0
  36. package/templates/dam/scripts/start/start.ts +35 -0
  37. package/templates/dam/src/adapter.ts +44 -0
  38. package/templates/dam/src/app.tsx +147 -0
  39. package/templates/dam/src/config.ts +95 -0
  40. package/templates/dam/src/index.css +10 -0
  41. package/templates/dam/src/index.tsx +22 -0
  42. package/templates/dam/tsconfig.json +54 -0
  43. package/templates/dam/utils/backend/base_backend/create.ts +104 -0
  44. package/templates/dam/utils/backend/jwt_middleware/index.ts +1 -0
  45. package/templates/dam/utils/backend/jwt_middleware/jwt_middleware.ts +229 -0
  46. package/templates/dam/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +630 -0
  47. package/templates/dam/webpack.config.cjs +270 -0
  48. package/templates/gen_ai/README.md +27 -0
  49. package/templates/gen_ai/backend/database/database.ts +42 -0
  50. package/templates/gen_ai/backend/routers/auth.ts +285 -0
  51. package/templates/gen_ai/backend/routers/image.ts +234 -0
  52. package/templates/gen_ai/backend/server.ts +56 -0
  53. package/templates/gen_ai/declarations/declarations.d.ts +29 -0
  54. package/templates/gen_ai/eslint.config.mjs +309 -0
  55. package/templates/gen_ai/package.json +92 -0
  56. package/templates/gen_ai/scripts/ssl/ssl.ts +131 -0
  57. package/templates/gen_ai/scripts/start/app_runner.ts +164 -0
  58. package/templates/gen_ai/scripts/start/context.ts +165 -0
  59. package/templates/gen_ai/scripts/start/start.ts +35 -0
  60. package/templates/gen_ai/src/api/api.ts +228 -0
  61. package/templates/gen_ai/src/api/index.ts +1 -0
  62. package/templates/gen_ai/src/app.tsx +13 -0
  63. package/templates/gen_ai/src/components/app_error.tsx +18 -0
  64. package/templates/gen_ai/src/components/footer.messages.ts +53 -0
  65. package/templates/gen_ai/src/components/footer.tsx +157 -0
  66. package/templates/gen_ai/src/components/image_grid.tsx +96 -0
  67. package/templates/gen_ai/src/components/index.ts +8 -0
  68. package/templates/gen_ai/src/components/loading_results.tsx +169 -0
  69. package/templates/gen_ai/src/components/logged_in_status.tsx +44 -0
  70. package/templates/gen_ai/src/components/prompt_input.messages.ts +14 -0
  71. package/templates/gen_ai/src/components/prompt_input.tsx +149 -0
  72. package/templates/gen_ai/src/components/remaining_credits.tsx +75 -0
  73. package/templates/gen_ai/src/components/report_box.tsx +53 -0
  74. package/templates/gen_ai/src/config.ts +21 -0
  75. package/templates/gen_ai/src/context/app_context.tsx +174 -0
  76. package/templates/gen_ai/src/context/context.messages.ts +41 -0
  77. package/templates/gen_ai/src/context/index.ts +2 -0
  78. package/templates/gen_ai/src/context/use_app_context.ts +17 -0
  79. package/templates/gen_ai/src/index.tsx +31 -0
  80. package/templates/gen_ai/src/pages/error.tsx +41 -0
  81. package/templates/gen_ai/src/pages/generate.tsx +9 -0
  82. package/templates/gen_ai/src/pages/index.ts +3 -0
  83. package/templates/gen_ai/src/pages/results.tsx +31 -0
  84. package/templates/gen_ai/src/routes/index.ts +1 -0
  85. package/templates/gen_ai/src/routes/routes.tsx +26 -0
  86. package/templates/gen_ai/src/services/auth.tsx +31 -0
  87. package/templates/gen_ai/src/services/index.ts +1 -0
  88. package/templates/gen_ai/src/utils/index.ts +1 -0
  89. package/templates/gen_ai/src/utils/obscenity_filter.ts +33 -0
  90. package/templates/gen_ai/styles/components.css +38 -0
  91. package/templates/gen_ai/styles/utils.css +3 -0
  92. package/templates/gen_ai/tsconfig.json +54 -0
  93. package/templates/gen_ai/utils/backend/base_backend/create.ts +104 -0
  94. package/templates/gen_ai/utils/backend/jwt_middleware/index.ts +1 -0
  95. package/templates/gen_ai/utils/backend/jwt_middleware/jwt_middleware.ts +229 -0
  96. package/templates/gen_ai/utils/backend/jwt_middleware/tests/jwt_middleware.tests.ts +630 -0
  97. package/templates/gen_ai/webpack.config.cjs +270 -0
  98. package/templates/hello_world/declarations/declarations.d.ts +29 -0
  99. package/templates/hello_world/eslint.config.mjs +309 -0
  100. package/templates/hello_world/package.json +73 -0
  101. package/templates/hello_world/scripts/ssl/ssl.ts +131 -0
  102. package/templates/hello_world/scripts/start/app_runner.ts +164 -0
  103. package/templates/hello_world/scripts/start/context.ts +165 -0
  104. package/templates/hello_world/scripts/start/start.ts +35 -0
  105. package/templates/hello_world/src/app.tsx +41 -0
  106. package/templates/hello_world/src/index.tsx +22 -0
  107. package/templates/hello_world/styles/components.css +38 -0
  108. package/templates/hello_world/tsconfig.json +54 -0
  109. package/templates/hello_world/webpack.config.cjs +270 -0
package/LICENSE.md ADDED
@@ -0,0 +1,48 @@
1
+ # A message from Canva
2
+
3
+ By making these software components available to you, our goal is to give you
4
+ the right to use the components to build your apps for Canva's ecosystem. See
5
+ below for the specific licence terms that apply to your use.
6
+
7
+ # Licence
8
+
9
+ Canva Pty Ltd (ACN 158 929 938) ("Canva") owns the copyright in the software and
10
+ associated documentation files to which this Licence relates (each a "Software
11
+ Component"). Canva reserves all of its rights.
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
14
+ the Software Components ("You"), to use the Software Components, but strictly
15
+ subject to the following restrictions and conditions:
16
+
17
+ 1. You must only use the Software Components and any Derivative on the Canva
18
+ Platform.
19
+
20
+ 2. You must only use the Software Components and any Derivative for the purpose
21
+ of building or updating Permitted Apps, and for no other purpose.
22
+
23
+ 3. You must include a copy of this Licence in all copies of any Software
24
+ Component and Derivative.
25
+
26
+ 4. To the fullest extent permitted by law, the Software Components are provided
27
+ "as is", without warranty of any kind, express or implied, including but not
28
+ limited to the warranties of merchantability, fitness for a particular
29
+ purpose and non-infringement. To the fullest extent permitted by law, in no
30
+ event shall the authors or copyright holders be liable for any claim,
31
+ damages or other liability, whether in an action of contract, tort or
32
+ otherwise, arising from, out of or in connection with the Software Components
33
+ or any Derivative, or the use of or other dealings in the Software Components
34
+ or any Derivative.
35
+
36
+ 5. In this Licence:
37
+
38
+ (a) "Canva Platform" means the visual communications platform owned and
39
+ operated by Canva that is made available on Canva.com (as well as any
40
+ sub-domains and international versions) and via mobile applications, desktop
41
+ applications, and in other forms provided or made available by Canva;
42
+
43
+ (b) "Derivative" means any software, document or other material that: (i)
44
+ contains any Software Component; and/or (ii) comprises or contains a
45
+ derivative, adaptation or substantial part of any Software Component; and
46
+
47
+ (c) "Permitted App" means a software application that is solely offered to
48
+ end-users on the Canva Platform.
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ # @canva/cli
2
+
3
+ CLI for creating and managing Canva Apps.
4
+
5
+ ![](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB) ![](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
6
+
7
+ ## Table of contents
8
+
9
+ - [Introduction](#introduction)
10
+ - [Features](#features)
11
+ - [Usage](#usage)
12
+ - [CLI reference](#cli-reference)
13
+ - [Flags](#flags)
14
+ - [Commands](#commands)
15
+ - [Next steps](#next-steps)
16
+ - [Limitations](#limitations)
17
+ - [Updating](#updating)
18
+ - [Contributing](#contributing)
19
+ - [License](#license)
20
+
21
+ ## Introduction
22
+
23
+ `@canva/cli` is a command line tool designed for creating and managing Canva Apps. To learn more about app development, visit [the official documentation](https://www.canva.dev/docs/apps).
24
+
25
+ ## Features
26
+
27
+ - Log in to your Canva account.
28
+ - Create and manage apps directly from the command line.
29
+ - Utilize Canva's recommended development tools and templates.
30
+
31
+ ## Prerequisites
32
+
33
+ Before using the CLI, ensure that you have the following installed:
34
+
35
+ - Node.js `v18.20.4` or `v20.17.0`
36
+ - npm `v9` or `v10`
37
+
38
+ ## Usage
39
+
40
+ To start using the CLI, first install it globally:
41
+
42
+ ```bash
43
+ npm install -g @canva/cli
44
+ ```
45
+
46
+ After installation, you can use the CLI by running:
47
+
48
+ ```bash
49
+ canva <command>
50
+ ```
51
+
52
+ ## CLI Reference
53
+
54
+ ### Flags
55
+
56
+ Top-level flags applicable across commands:
57
+
58
+ - `--help`: Display help information about commands and flags.
59
+ - `--lite`: Enable a simplified CLI interface for enhanced accessibility.
60
+ - `--version`: Show the version number of the CLI.
61
+
62
+ ### Commands
63
+
64
+ #### welcome
65
+
66
+ Display the welcome page and general information.
67
+
68
+ - **Usage**:
69
+
70
+ ```bash
71
+ canva welcome
72
+ ```
73
+
74
+ #### tip
75
+
76
+ Get a random development tip for working with the Apps SDK.
77
+
78
+ - **Usage**:
79
+
80
+ ```bash
81
+ canva tip
82
+ ```
83
+
84
+ - **Aliases**: `tips`
85
+
86
+ #### login
87
+
88
+ Log in to the Canva CLI.
89
+
90
+ - **Usage**:
91
+
92
+ ```bash
93
+ canva login
94
+ ```
95
+
96
+ #### apps
97
+
98
+ Manage your Canva apps.
99
+
100
+ - **Usage**:
101
+
102
+ ```bash
103
+ canva apps
104
+ ```
105
+
106
+ - **Sub-Commands**:
107
+
108
+ - `create [name]`: Create a new Canva app.
109
+
110
+ - **Usage**:
111
+
112
+ ```bash
113
+ canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
114
+ ```
115
+
116
+ - **Arguments**:
117
+ - `[name]`: Sets the app's name. Provide the desired name of the app when using this command.
118
+ - **Flags**:
119
+
120
+ - `--template`: Specifies the starting template for the app.
121
+
122
+ Available templates:
123
+
124
+ - `"hello_world"`: Basic starting point.
125
+ - `"dam"`: Digital asset management integration.
126
+ - `"gen_ai"`: Generative AI app creation.
127
+
128
+ - `--distribution`: Sets the app's distribution type.
129
+
130
+ Options:
131
+
132
+ - `"public"`: Available to all Canva users, subject to Canva review.
133
+ - `"private"`: Only available to your team, requires team admin approval.
134
+
135
+ > [!Note]
136
+ > This setting cannot be changed after the app is created.
137
+
138
+ - `--git`: Initializes a Git repository in the project directory.
139
+
140
+ - `--installDependencies`: Automatically installs necessary npm dependencies.
141
+
142
+ - `list`: List all Canva apps.
143
+
144
+ - **Usage**:
145
+
146
+ ```bash
147
+ canva apps list
148
+ ```
149
+
150
+ #### logout
151
+
152
+ Log out and revoke access from the CLI.
153
+
154
+ - **Usage**:
155
+
156
+ ```bash
157
+ canva logout
158
+ ```
159
+
160
+ ## Next Steps
161
+
162
+ - [Preview your app in the Canva editor](https://www.canva.dev/docs/apps/previewing-apps/)
163
+ - [Integrate your app with Canva using the Apps SDK](https://www.canva.dev/docs/apps/integrating-canva/)
164
+
165
+ ## Limitations
166
+
167
+ Once an app is created, it must be managed through Canva's [Developer Portal](https://www.canva.com/developers/apps) and cannot be fully managed via the CLI.
168
+
169
+ ## Updating
170
+
171
+ To update the CLI to the latest version, run:
172
+
173
+ ```bash
174
+ npm update -g @canva/cli
175
+ ```
176
+
177
+ ## Token Storage and Removal
178
+
179
+ When you log in using the `canva login` command, the Auth token is encrypted and stored locally on your machine. This token is used to authenticate future requests made by the CLI, so you don’t have to log in repeatedly.
180
+
181
+ ### Token Location
182
+
183
+ The token is stored in a credentials file located in your home directory under the `.canva-cli` folder:
184
+
185
+ ### Removing the Token
186
+
187
+ To remove the token and log out of the CLI, you can either:
188
+
189
+ 1. Use the `canva logout` command to revoke access and delete the stored token:
190
+
191
+ ```bash
192
+ canva logout
193
+ ```
194
+
195
+ 2. Manually delete the credentials file:
196
+
197
+ - **macOS/Linux**: The token is stored in `~/.canva-cli/credentials`.
198
+ - **Windows**: The token is stored in `%USERPROFILE%\.canva-cli\credentials`.
199
+
200
+ ## Contributing
201
+
202
+ We're in active development and currently do not accept third-party contributions. Please submit any feature requests through the [Canva Developers Community](https://community.canva.dev/).
203
+
204
+ ## License
205
+
206
+ Refer to the `LICENSE.md` file for licensing details.