@payloadcms/figma 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (219) hide show
  1. package/dist/api/check-project-subdomain-availability.d.ts +12 -0
  2. package/dist/api/check-project-subdomain-availability.js +32 -0
  3. package/dist/api/control-plane-error.d.ts +6 -0
  4. package/dist/api/control-plane-error.js +8 -0
  5. package/dist/api/control-plane-fetch.d.ts +7 -0
  6. package/dist/api/control-plane-fetch.js +37 -0
  7. package/dist/api/control-plane.d.ts +1 -9
  8. package/dist/api/control-plane.js +2 -48
  9. package/dist/api/create-project.d.ts +18 -0
  10. package/dist/api/create-project.js +37 -0
  11. package/dist/api/list-project-workspaces.d.ts +8 -0
  12. package/dist/api/list-project-workspaces.js +28 -0
  13. package/dist/api/project-resource-type.d.ts +1 -0
  14. package/dist/api/project-resource-type.js +1 -0
  15. package/dist/auth/headless-oauth-flow.d.ts +23 -0
  16. package/dist/auth/headless-oauth-flow.js +69 -0
  17. package/dist/auth/oauth-flow.d.ts +2 -0
  18. package/dist/auth/oauth-flow.js +13 -8
  19. package/dist/auth/token-store.d.ts +4 -1
  20. package/dist/auth/token-store.js +14 -0
  21. package/dist/auth/types.d.ts +12 -0
  22. package/dist/cli.d.ts +39 -0
  23. package/dist/cli.js +71 -36
  24. package/dist/commands/bootstrap.js +2 -1
  25. package/dist/commands/deploy.d.ts +12 -0
  26. package/dist/commands/deploy.js +61 -23
  27. package/dist/commands/detect-project-resource-type.d.ts +3 -0
  28. package/dist/commands/detect-project-resource-type.js +28 -0
  29. package/dist/commands/init.d.ts +2 -2
  30. package/dist/commands/init.js +163 -78
  31. package/dist/commands/login.d.ts +11 -1
  32. package/dist/commands/login.js +66 -4
  33. package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
  34. package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
  35. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
  36. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
  37. package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
  38. package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
  39. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
  40. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
  41. package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
  42. package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
  43. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
  44. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
  45. package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
  46. package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
  47. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
  48. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
  49. package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
  50. package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
  51. package/dist/commands/prompt-to-create-project.d.ts +24 -0
  52. package/dist/commands/prompt-to-create-project.js +69 -0
  53. package/dist/commands/setup-agent.d.ts +12 -0
  54. package/dist/commands/setup-agent.js +123 -0
  55. package/dist/commands/write-project-configuration.d.ts +12 -0
  56. package/dist/commands/write-project-configuration.js +16 -0
  57. package/dist/db-content-api/index.d.ts +1 -1
  58. package/dist/db-content-api/index.js +90 -55
  59. package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
  60. package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
  61. package/dist/db-content-api/utilities/data/stringifyNumericIds.d.ts +1 -0
  62. package/dist/db-content-api/utilities/data/stringifyNumericIds.js +19 -0
  63. package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
  64. package/dist/db-content-api/utilities/isRecord.js +19 -0
  65. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  66. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  67. package/dist/db-content-api/utilities/where.js +6 -4
  68. package/dist/exports/client.d.ts +2 -0
  69. package/dist/exports/client.js +2 -0
  70. package/dist/lib/write-agent-config.d.ts +12 -0
  71. package/dist/lib/write-agent-config.js +52 -0
  72. package/dist/plugin/build-config.js +32 -3
  73. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
  74. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +78 -0
  75. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +51 -0
  76. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +7 -0
  77. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +169 -0
  78. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +2 -0
  79. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  80. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +9 -0
  81. package/dist/plugin/cloud-limits/SlugTracker/index.js +23 -0
  82. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
  83. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  84. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  85. package/dist/plugin/cloud-limits/shared.js +27 -0
  86. package/dist/skills/deploy-to-figma/SKILL.md +234 -0
  87. package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
  88. package/dist/translations/ar.d.ts +12 -0
  89. package/dist/translations/ar.js +12 -0
  90. package/dist/translations/az.d.ts +12 -0
  91. package/dist/translations/az.js +12 -0
  92. package/dist/translations/bg.d.ts +12 -0
  93. package/dist/translations/bg.js +12 -0
  94. package/dist/translations/bnBd.d.ts +12 -0
  95. package/dist/translations/bnBd.js +12 -0
  96. package/dist/translations/bnIn.d.ts +12 -0
  97. package/dist/translations/bnIn.js +12 -0
  98. package/dist/translations/ca.d.ts +12 -0
  99. package/dist/translations/ca.js +12 -0
  100. package/dist/translations/cs.d.ts +12 -0
  101. package/dist/translations/cs.js +12 -0
  102. package/dist/translations/da.d.ts +12 -0
  103. package/dist/translations/da.js +12 -0
  104. package/dist/translations/de.d.ts +12 -0
  105. package/dist/translations/de.js +12 -0
  106. package/dist/translations/en.d.ts +12 -0
  107. package/dist/translations/en.js +12 -0
  108. package/dist/translations/es.d.ts +12 -0
  109. package/dist/translations/es.js +12 -0
  110. package/dist/translations/et.d.ts +12 -0
  111. package/dist/translations/et.js +12 -0
  112. package/dist/translations/fa.d.ts +12 -0
  113. package/dist/translations/fa.js +12 -0
  114. package/dist/translations/fr.d.ts +12 -0
  115. package/dist/translations/fr.js +12 -0
  116. package/dist/translations/he.d.ts +12 -0
  117. package/dist/translations/he.js +12 -0
  118. package/dist/translations/hr.d.ts +12 -0
  119. package/dist/translations/hr.js +12 -0
  120. package/dist/translations/hu.d.ts +12 -0
  121. package/dist/translations/hu.js +12 -0
  122. package/dist/translations/hy.d.ts +12 -0
  123. package/dist/translations/hy.js +12 -0
  124. package/dist/translations/id.d.ts +12 -0
  125. package/dist/translations/id.js +12 -0
  126. package/dist/translations/index.d.ts +533 -0
  127. package/dist/translations/index.js +90 -0
  128. package/dist/translations/is.d.ts +12 -0
  129. package/dist/translations/is.js +12 -0
  130. package/dist/translations/it.d.ts +12 -0
  131. package/dist/translations/it.js +12 -0
  132. package/dist/translations/ja.d.ts +12 -0
  133. package/dist/translations/ja.js +12 -0
  134. package/dist/translations/ko.d.ts +12 -0
  135. package/dist/translations/ko.js +12 -0
  136. package/dist/translations/lt.d.ts +12 -0
  137. package/dist/translations/lt.js +12 -0
  138. package/dist/translations/lv.d.ts +12 -0
  139. package/dist/translations/lv.js +12 -0
  140. package/dist/translations/my.d.ts +12 -0
  141. package/dist/translations/my.js +12 -0
  142. package/dist/translations/nb.d.ts +12 -0
  143. package/dist/translations/nb.js +12 -0
  144. package/dist/translations/nl.d.ts +12 -0
  145. package/dist/translations/nl.js +12 -0
  146. package/dist/translations/pl.d.ts +12 -0
  147. package/dist/translations/pl.js +12 -0
  148. package/dist/translations/pt.d.ts +12 -0
  149. package/dist/translations/pt.js +12 -0
  150. package/dist/translations/ro.d.ts +12 -0
  151. package/dist/translations/ro.js +12 -0
  152. package/dist/translations/rs.d.ts +12 -0
  153. package/dist/translations/rs.js +12 -0
  154. package/dist/translations/rsLatin.d.ts +12 -0
  155. package/dist/translations/rsLatin.js +12 -0
  156. package/dist/translations/ru.d.ts +12 -0
  157. package/dist/translations/ru.js +12 -0
  158. package/dist/translations/sk.d.ts +12 -0
  159. package/dist/translations/sk.js +12 -0
  160. package/dist/translations/sl.d.ts +12 -0
  161. package/dist/translations/sl.js +12 -0
  162. package/dist/translations/sv.d.ts +12 -0
  163. package/dist/translations/sv.js +12 -0
  164. package/dist/translations/ta.d.ts +12 -0
  165. package/dist/translations/ta.js +12 -0
  166. package/dist/translations/th.d.ts +12 -0
  167. package/dist/translations/th.js +12 -0
  168. package/dist/translations/tr.d.ts +12 -0
  169. package/dist/translations/tr.js +12 -0
  170. package/dist/translations/uk.d.ts +12 -0
  171. package/dist/translations/uk.js +12 -0
  172. package/dist/translations/vi.d.ts +12 -0
  173. package/dist/translations/vi.js +12 -0
  174. package/dist/translations/zh.d.ts +12 -0
  175. package/dist/translations/zh.js +12 -0
  176. package/dist/translations/zhTw.d.ts +12 -0
  177. package/dist/translations/zhTw.js +12 -0
  178. package/dist/types.d.ts +11 -0
  179. package/dist/utils/adapters/nextjs.d.ts +3 -3
  180. package/dist/utils/adapters/nextjs.js +9 -7
  181. package/dist/utils/adapters/nitro.d.ts +3 -3
  182. package/dist/utils/adapters/nitro.js +73 -77
  183. package/dist/utils/adapters/vite.d.ts +1 -1
  184. package/dist/utils/adapters/vite.js +8 -7
  185. package/dist/utils/assert-never.d.ts +1 -0
  186. package/dist/utils/assert-never.js +3 -0
  187. package/dist/utils/asset-collection.d.ts +2 -2
  188. package/dist/utils/asset-collection.js +10 -15
  189. package/dist/utils/build-detection.d.ts +6 -1
  190. package/dist/utils/build-detection.js +68 -89
  191. package/dist/utils/build-lambda-zip.d.ts +5 -6
  192. package/dist/utils/build-lambda-zip.js +31 -48
  193. package/dist/utils/deploy-adapter.d.ts +4 -4
  194. package/dist/utils/deploy-adapter.js +12 -8
  195. package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  196. package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  197. package/dist/utils/deploy-output/inspectNextjsOutput.d.ts +12 -0
  198. package/dist/utils/deploy-output/inspectNextjsOutput.js +28 -0
  199. package/dist/utils/deploy-output/inspectNitroOutput.d.ts +9 -0
  200. package/dist/utils/deploy-output/inspectNitroOutput.js +13 -0
  201. package/dist/utils/deploy-output/isFile.d.ts +1 -0
  202. package/dist/utils/deploy-output/isFile.js +4 -0
  203. package/dist/utils/deploy-output/readJson.d.ts +1 -0
  204. package/dist/utils/deploy-output/readJson.js +9 -0
  205. package/dist/utils/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  206. package/dist/utils/deploy-output/resolveNitroOutputLayout.js +16 -0
  207. package/dist/utils/deploy-output/resolveOutputPath.d.ts +2 -0
  208. package/dist/utils/deploy-output/resolveOutputPath.js +9 -0
  209. package/dist/utils/deploy-output/resolveWithin.d.ts +1 -0
  210. package/dist/utils/deploy-output/resolveWithin.js +12 -0
  211. package/dist/utils/lambda-config.js +4 -14
  212. package/dist/utils/messages.js +24 -3
  213. package/dist/utils/payload-generate.d.ts +10 -0
  214. package/dist/utils/payload-generate.js +59 -0
  215. package/dist/utils/pnpm-builds.d.ts +14 -0
  216. package/dist/utils/pnpm-builds.js +125 -0
  217. package/package.json +6 -5
  218. package/dist/lib/download-skill.d.ts +0 -12
  219. package/dist/lib/download-skill.js +0 -77
package/dist/cli.js CHANGED
@@ -11,10 +11,51 @@ import { initCommand } from './commands/init.js';
11
11
  import { listTokensCommand } from './commands/list-tokens.js';
12
12
  import { loginCommand } from './commands/login.js';
13
13
  import { logoutCommand } from './commands/logout.js';
14
+ import { setupAgentCommand } from './commands/setup-agent.js';
14
15
  import { upgradeCommand } from './commands/upgrade.js';
15
16
  import { uploadSchemaCommand } from './commands/upload-schema.js';
16
17
  import { setInfraEnvironment } from './constants.js';
17
18
  import { helpMessage } from './utils/messages.js';
19
+ export const cliArgSpec = {
20
+ '--adapter': String,
21
+ '--all': Boolean,
22
+ '--callback-url': String,
23
+ '--complete': String,
24
+ '--debug': Boolean,
25
+ '--description': String,
26
+ '--dry-run': Boolean,
27
+ '--env': String,
28
+ '--force': Boolean,
29
+ '--global': Boolean,
30
+ '--headless': Boolean,
31
+ '--help': Boolean,
32
+ '--id': String,
33
+ '--infra-env': String,
34
+ '--json': Boolean,
35
+ '--name': String,
36
+ '--no-agent': Boolean,
37
+ '--output': String,
38
+ '--payload-version': String,
39
+ '--project': Boolean,
40
+ '--region': String,
41
+ '--skip-auth': Boolean,
42
+ '--skip-build': Boolean,
43
+ '--skip-size-check': Boolean,
44
+ '--subdomain': String,
45
+ '--template': String,
46
+ '--version': Boolean,
47
+ '--workspace': String,
48
+ '--yes': Boolean,
49
+ // Aliases
50
+ '--environment': '--env',
51
+ '-e': '--env',
52
+ '-f': '--force',
53
+ '-h': '--help',
54
+ '-n': '--name',
55
+ '-t': '--template',
56
+ '-v': '--version',
57
+ '-y': '--yes'
58
+ };
18
59
  /**
19
60
  * Entrypoint for bin/cli.js
20
61
  */ export async function main() {
@@ -31,39 +72,7 @@ class Main {
31
72
  args;
32
73
  constructor(){
33
74
  // @ts-expect-error bad typings
34
- this.args = arg({
35
- // Hidden flag — intentionally not displayed in help output yet.
36
- // Auto-detection covers most cases; this is an escape hatch for testing.
37
- // May expose in help text once multi-framework support is public.
38
- '--adapter': String,
39
- '--all': Boolean,
40
- '--debug': Boolean,
41
- '--dry-run': Boolean,
42
- '--env': String,
43
- '--force': Boolean,
44
- '--help': Boolean,
45
- '--id': String,
46
- '--infra-env': String,
47
- '--json': Boolean,
48
- '--name': String,
49
- '--no-skill': Boolean,
50
- '--payload-version': String,
51
- '--skip-auth': Boolean,
52
- '--skip-build': Boolean,
53
- '--skip-size-check': Boolean,
54
- '--template': String,
55
- '--version': Boolean,
56
- '--yes': Boolean,
57
- // Aliases
58
- '--environment': '--env',
59
- '-e': '--env',
60
- '-f': '--force',
61
- '-h': '--help',
62
- '-n': '--name',
63
- '-t': '--template',
64
- '-v': '--version',
65
- '-y': '--yes'
66
- }, {
75
+ this.args = arg(cliArgSpec, {
67
76
  permissive: true
68
77
  });
69
78
  // Set debug flag globally
@@ -105,7 +114,16 @@ class Main {
105
114
  helpMessage();
106
115
  process.exit(0);
107
116
  }
108
- // Debug command outputs plain text for copy-paste — skip styled intro
117
+ // JSON and debug commands output plain text — skip styled intro.
118
+ if (subcommand === 'login' && this.args['--json']) {
119
+ await loginCommand({
120
+ callbackUrl: this.args['--callback-url'],
121
+ completeSessionId: this.args['--complete'],
122
+ headless: this.args['--headless'],
123
+ json: true
124
+ });
125
+ process.exit(0);
126
+ }
109
127
  if (subcommand === 'debug') {
110
128
  await debugCommand();
111
129
  process.exit(0);
@@ -133,11 +151,17 @@ class Main {
133
151
  case 'deploy':
134
152
  await deployCommand({
135
153
  id: this.args['--id'],
154
+ name: this.args['--name'],
136
155
  adapter: this.args['--adapter'],
137
156
  debug: this.args['--debug'],
157
+ description: this.args['--description'],
138
158
  env: this.args['--env'],
159
+ output: this.args['--output'],
160
+ region: this.args['--region'],
139
161
  skipBuild: this.args['--skip-build'],
140
162
  skipSizeCheck: this.args['--skip-size-check'],
163
+ subdomain: this.args['--subdomain'],
164
+ workspace: this.args['--workspace'],
141
165
  yes: this.args['--yes']
142
166
  });
143
167
  break;
@@ -153,7 +177,7 @@ class Main {
153
177
  debug: this.args['--debug'],
154
178
  env: this.args['--env'],
155
179
  force: this.args['--force'],
156
- noSkill: this.args['--no-skill'],
180
+ noAgent: this.args['--no-agent'],
157
181
  payloadVersion: this.args['--payload-version'],
158
182
  skipAuth: this.args['--skip-auth'],
159
183
  template: this.args['--template']
@@ -166,7 +190,11 @@ class Main {
166
190
  });
167
191
  break;
168
192
  case 'login':
169
- await loginCommand();
193
+ await loginCommand({
194
+ callbackUrl: this.args['--callback-url'],
195
+ completeSessionId: this.args['--complete'],
196
+ headless: this.args['--headless']
197
+ });
170
198
  break;
171
199
  case 'logout':
172
200
  await logoutCommand({
@@ -174,6 +202,13 @@ class Main {
174
202
  debug: this.args['--debug']
175
203
  });
176
204
  break;
205
+ case 'setup-agent':
206
+ await setupAgentCommand({
207
+ global: this.args['--global'],
208
+ project: this.args['--project'],
209
+ yes: this.args['--yes']
210
+ });
211
+ break;
177
212
  case 'upgrade':
178
213
  await upgradeCommand({
179
214
  isDryRun: this.args['--dry-run']
@@ -1,6 +1,7 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { ControlPlaneError, getBootstrapInfo } from '../api/control-plane.js';
3
+ import { getBootstrapInfo } from '../api/control-plane.js';
4
+ import { ControlPlaneError } from '../api/control-plane-error.js';
4
5
  import { getValidCredential } from '../auth/oauth-flow.js';
5
6
  import { getTokenStore } from '../auth/token-store.js';
6
7
  import { getInfraEnvironment } from '../constants.js';
@@ -7,14 +7,26 @@ export interface DeployCommandOptions {
7
7
  adapter?: AdapterName;
8
8
  /** Enable debug mode */
9
9
  debug?: boolean;
10
+ /** Description used when creating an uninitialized project */
11
+ description?: string;
10
12
  /** Figma environment name (e.g. 'production', 'staging') */
11
13
  env?: string;
12
14
  /** CMS Resource ID (overrides FIGMA_PROJECT_ID) */
13
15
  id?: string;
16
+ /** Name used when creating an uninitialized project */
17
+ name?: string;
18
+ /** Exact framework build output root */
19
+ output?: string;
20
+ /** Region used when creating an uninitialized project */
21
+ region?: string;
14
22
  /** Skip the build step (use existing build) */
15
23
  skipBuild?: boolean;
16
24
  /** Skip the client-side unzipped bundle size pre-flight check */
17
25
  skipSizeCheck?: boolean;
26
+ /** Subdomain used when creating an uninitialized project */
27
+ subdomain?: string;
28
+ /** Workspace plan key used when creating an uninitialized project */
29
+ workspace?: string;
18
30
  /** Skip confirmation prompts */
19
31
  yes?: boolean;
20
32
  }
@@ -1,7 +1,9 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import spawn from 'cross-spawn';
3
+ import path from 'path';
3
4
  import pc from 'picocolors';
4
- import { ControlPlaneError, createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
5
+ import { createDeployment, getBootstrapInfo, performDeployment } from '../api/control-plane.js';
6
+ import { ControlPlaneError } from '../api/control-plane-error.js';
5
7
  import { tryGetCredential } from '../auth/oauth-flow.js';
6
8
  import { getTokenStore } from '../auth/token-store.js';
7
9
  import { getInfraEnvironment, getProjectNotFoundMessage } from '../constants.js';
@@ -15,7 +17,10 @@ import { getPackageManager } from '../utils/package-manager.js';
15
17
  import { isInProjectDirectory } from '../utils/project.js';
16
18
  import { resolveEnvironment } from '../utils/resolve-environment.js';
17
19
  import { uploadLambdaZip, uploadStaticAssets } from '../utils/s3-upload.js';
20
+ import { detectProjectResourceType } from './detect-project-resource-type.js';
18
21
  import { loginCommand } from './login.js';
22
+ import { promptToCreateProject } from './prompt-to-create-project.js';
23
+ import { writeProjectConfiguration } from './write-project-configuration.js';
19
24
  /**
20
25
  * Format bytes to human-readable string
21
26
  */ function formatBytes(bytes) {
@@ -51,23 +56,14 @@ import { loginCommand } from './login.js';
51
56
  */ export async function deployCommand(options) {
52
57
  const projectPath = process.cwd();
53
58
  const spinner = p.spinner();
54
- // Resolve project ID
55
- let projectId = options.id;
56
- if (!projectId) {
57
- projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
58
- }
59
- if (!projectId) {
60
- p.log.error(pc.red('✗ Project ID not found. Run `@payloadcms/figma init` first, or use --id.'));
61
- process.exit(1);
62
- }
63
59
  // Resolve environment name
64
60
  const environmentName = options.env ?? await getEnvVar(projectPath, 'FIGMA_ENVIRONMENT_NAME') ?? undefined;
65
61
  try {
66
62
  // ===== PRE-FLIGHT CHECKS =====
67
- // Check if in project directory
68
- if (!await isInProjectDirectory(projectPath)) {
69
- p.log.error(pc.red("'deploy' command is not available outside of a Payload project."));
70
- p.note('Create a project or connect an existing one to Figma: npx @payloadcms/figma init', 'Tip');
63
+ // Building requires package.json, but --skip-build can deploy a prebuilt artifact directly.
64
+ if (!options.skipBuild && !await isInProjectDirectory(projectPath)) {
65
+ p.log.error(pc.red('Cannot build because package.json was not found in this directory.'));
66
+ p.note('Run from a package directory, or deploy prebuilt output with --skip-build --output <path>.', 'Tip');
71
67
  process.exit(1);
72
68
  }
73
69
  // Check authentication
@@ -75,13 +71,38 @@ import { loginCommand } from './login.js';
75
71
  let credential = await tryGetCredential(tokenStore);
76
72
  if (!credential) {
77
73
  p.log.message('Please log in to continue');
78
- await loginCommand();
74
+ await loginCommand({
75
+ openBrowserWithoutPrompt: options.yes
76
+ });
79
77
  credential = await tryGetCredential(tokenStore);
80
78
  if (!credential) {
81
79
  p.log.error(pc.red('✗ Authentication failed'));
82
80
  process.exit(1);
83
81
  }
84
82
  }
83
+ // Resolve or create the CMS project.
84
+ let projectId = options.id;
85
+ if (!projectId) {
86
+ projectId = await getEnvVar(projectPath, 'FIGMA_PROJECT_ID') ?? undefined;
87
+ }
88
+ const isProjectCreated = !projectId;
89
+ if (!projectId) {
90
+ const resourceType = options.adapter === 'vite' ? 'vite' : options.adapter ? 'payload' : await detectProjectResourceType(projectPath);
91
+ const project = await promptToCreateProject({
92
+ credential,
93
+ inputs: {
94
+ name: options.name,
95
+ description: options.description,
96
+ region: options.region,
97
+ subdomain: options.subdomain,
98
+ workspacePlanKey: options.workspace
99
+ },
100
+ nonInteractive: options.yes,
101
+ projectPath,
102
+ resourceType
103
+ });
104
+ projectId = project.id;
105
+ }
85
106
  // Resolve tenant instance ID via bootstrap
86
107
  spinner.start('Resolving deployment target...');
87
108
  let tenantInstanceId;
@@ -92,6 +113,14 @@ import { loginCommand } from './login.js';
92
113
  environments: bootstrapInfo.environments
93
114
  });
94
115
  tenantInstanceId = resolvedEnv.tenantInstanceId;
116
+ await writeProjectConfiguration({
117
+ bootstrapInfo,
118
+ environmentName: resolvedEnv.name,
119
+ projectDir: projectPath,
120
+ projectId,
121
+ shouldWriteEnvironmentVariables: isProjectCreated,
122
+ tokenStore
123
+ });
95
124
  spinner.stop(pc.green(`✓ Target: ${resolvedEnv.name}`));
96
125
  } catch (error) {
97
126
  if (error instanceof ControlPlaneError && (error.statusCode === 404 || error.statusCode === 410)) {
@@ -110,13 +139,18 @@ import { loginCommand } from './login.js';
110
139
  process.env.FIGMA_EXTRACT_SCHEDULES = 'true';
111
140
  // ===== BUILD =====
112
141
  let buildInfo;
142
+ const buildOptions = {
143
+ adapter: options.adapter,
144
+ output: options.output
145
+ };
113
146
  if (options.skipBuild) {
114
147
  // User asserts build exists - verify it
115
148
  spinner.start('Checking for build...');
116
- buildInfo = await detectBuild(projectPath);
149
+ buildInfo = await detectBuild(projectPath, buildOptions);
117
150
  if (!buildInfo) {
118
151
  spinner.stop(pc.red('✗ No build found'));
119
- p.log.error('Use deploy without --skip-build to build first.');
152
+ p.log.error(getMissingBuildMessage(projectPath, options));
153
+ p.note('Use deploy without --skip-build to build first.', 'Tip');
120
154
  process.exit(1);
121
155
  }
122
156
  spinner.stop(pc.green('✓ Build found'));
@@ -182,9 +216,9 @@ import { loginCommand } from './login.js';
182
216
  process.exit(1);
183
217
  }
184
218
  // Verify build output
185
- buildInfo = await detectBuild(projectPath);
219
+ buildInfo = await detectBuild(projectPath, buildOptions);
186
220
  if (!buildInfo) {
187
- p.log.error(pc.red('✗ Build completed but build output not found'));
221
+ p.log.error(pc.red(`✗ ${getMissingBuildMessage(projectPath, options)}`));
188
222
  p.note('Ensure your build produces a valid output directory.', 'Check Build Configuration');
189
223
  process.exit(1);
190
224
  }
@@ -192,12 +226,12 @@ import { loginCommand } from './login.js';
192
226
  // ===== DEPLOYMENT PREPARATION =====
193
227
  // Detect framework adapter
194
228
  spinner.start('Detecting framework...');
195
- const adapter = await detectAdapter(projectPath, options.adapter);
229
+ const adapter = await detectAdapter(projectPath, options.adapter, options.output);
196
230
  spinner.stop(pc.green(`✓ Detected ${adapter.name} adapter`));
197
231
  // Collect pages and assets
198
232
  spinner.start('Collecting assets...');
199
- const pages = await adapter.collectPages(projectPath);
200
- const assets = await adapter.collectAssets(projectPath);
233
+ const pages = await adapter.collectPages(projectPath, options.output);
234
+ const assets = await adapter.collectAssets(projectPath, options.output);
201
235
  spinner.stop(pc.green(`✓ ${pages.routes.length} pages, ${assets.routes.length} assets detected`));
202
236
  // Create deployment package (if server adapter)
203
237
  let zipPath = null;
@@ -205,7 +239,7 @@ import { loginCommand } from './login.js';
205
239
  let unzippedBytes = 0;
206
240
  spinner.start('Creating deployment package...');
207
241
  try {
208
- const bundle = await adapter.prepareLambdaBundle(projectPath);
242
+ const bundle = await adapter.prepareLambdaBundle(projectPath, options.output);
209
243
  if (bundle) {
210
244
  zipPath = bundle.zipPath;
211
245
  unzippedBytes = bundle.unzippedBytes;
@@ -342,3 +376,7 @@ import { loginCommand } from './login.js';
342
376
  process.exit(1);
343
377
  }
344
378
  }
379
+ function getMissingBuildMessage(projectPath, options) {
380
+ const location = options.output ? ` at ${path.resolve(projectPath, options.output)}` : '';
381
+ return options.adapter ? `No ${options.adapter} build found${location}.` : `No supported build found${location}.`;
382
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProjectResourceType } from '../api/project-resource-type.js';
2
+ /** Detect whether project provisioning should use static Vite or Payload infrastructure. */
3
+ export declare function detectProjectResourceType(projectPath?: string): Promise<ProjectResourceType>;
@@ -0,0 +1,28 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ /** Detect whether project provisioning should use static Vite or Payload infrastructure. */ export async function detectProjectResourceType(projectPath = process.cwd()) {
4
+ try {
5
+ const content = await fs.readFile(path.join(projectPath, 'package.json'), 'utf-8');
6
+ const packageJson = JSON.parse(content);
7
+ const dependencies = {
8
+ ...packageJson.dependencies,
9
+ ...packageJson.devDependencies
10
+ };
11
+ if (dependencies.payload) {
12
+ return 'payload';
13
+ }
14
+ if (dependencies.vite || Object.values(packageJson.scripts ?? {}).some((script)=>/\bvite\b/.test(script))) {
15
+ return 'vite';
16
+ }
17
+ } catch (error) {
18
+ if (error.code !== 'ENOENT') {
19
+ return 'payload';
20
+ }
21
+ }
22
+ try {
23
+ await fs.access(path.join(projectPath, 'index.html'));
24
+ return 'vite';
25
+ } catch {
26
+ return 'payload';
27
+ }
28
+ }
@@ -12,8 +12,8 @@ export interface InitCommandOptions {
12
12
  id?: string;
13
13
  /** Project name (for scaffolding) */
14
14
  name?: string;
15
- /** Skip Payload skill installation */
16
- noSkill?: boolean;
15
+ /** Skip writing AI agent config files (AGENTS.md, CLAUDE.md) */
16
+ noAgent?: boolean;
17
17
  /** npm dist-tag or explicit version for core payload packages (e.g. 'canary', 'latest', '4.0.0-canary.16'); defaults to 'canary' */
18
18
  payloadVersion?: string;
19
19
  /** Skip authentication check (for testing/development) */