@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.
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +1 -9
- package/dist/api/control-plane.js +2 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +4 -1
- package/dist/auth/token-store.js +14 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +61 -23
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +163 -78
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/db-content-api/index.d.ts +1 -1
- package/dist/db-content-api/index.js +90 -55
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/stringifyNumericIds.d.ts +1 -0
- package/dist/db-content-api/utilities/data/stringifyNumericIds.js +19 -0
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.js +6 -4
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/plugin/build-config.js +32 -3
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +78 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +51 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +169 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +2 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +9 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +23 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +27 -0
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/adapters/nextjs.d.ts +3 -3
- package/dist/utils/adapters/nextjs.js +9 -7
- package/dist/utils/adapters/nitro.d.ts +3 -3
- package/dist/utils/adapters/nitro.js +73 -77
- package/dist/utils/adapters/vite.d.ts +1 -1
- package/dist/utils/adapters/vite.js +8 -7
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/asset-collection.d.ts +2 -2
- package/dist/utils/asset-collection.js +10 -15
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/build-lambda-zip.d.ts +5 -6
- package/dist/utils/build-lambda-zip.js +31 -48
- package/dist/utils/deploy-adapter.d.ts +4 -4
- package/dist/utils/deploy-adapter.js +12 -8
- package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/utils/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/utils/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/utils/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/utils/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/utils/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/utils/deploy-output/isFile.d.ts +1 -0
- package/dist/utils/deploy-output/isFile.js +4 -0
- package/dist/utils/deploy-output/readJson.d.ts +1 -0
- package/dist/utils/deploy-output/readJson.js +9 -0
- package/dist/utils/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/utils/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/utils/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/utils/deploy-output/resolveOutputPath.js +9 -0
- package/dist/utils/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/utils/deploy-output/resolveWithin.js +12 -0
- package/dist/utils/lambda-config.js +4 -14
- package/dist/utils/messages.js +24 -3
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/package.json +6 -5
- package/dist/lib/download-skill.d.ts +0 -12
- 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
|
-
//
|
|
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
|
-
|
|
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 {
|
|
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
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -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 {
|
|
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
|
-
//
|
|
68
|
-
if (!await isInProjectDirectory(projectPath)) {
|
|
69
|
-
p.log.error(pc.red(
|
|
70
|
-
p.note('
|
|
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(
|
|
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(
|
|
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,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
|
+
}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface InitCommandOptions {
|
|
|
12
12
|
id?: string;
|
|
13
13
|
/** Project name (for scaffolding) */
|
|
14
14
|
name?: string;
|
|
15
|
-
/** Skip
|
|
16
|
-
|
|
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) */
|