@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
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/** Fallback builds when package.json declares none. */ const DEFAULT_BUILDS = [
|
|
4
|
+
'sharp',
|
|
5
|
+
'esbuild',
|
|
6
|
+
'unrs-resolver'
|
|
7
|
+
];
|
|
8
|
+
/**
|
|
9
|
+
* Write init's pnpm-workspace.yaml: hoisted node linker (the Lambda runtime needs a
|
|
10
|
+
* flat node_modules) plus build approvals, migrating off the now-ignored package.json
|
|
11
|
+
* `pnpm.onlyBuiltDependencies`. Written for every project so an npx/npm scaffold still
|
|
12
|
+
* installs cleanly when the user later switches to pnpm.
|
|
13
|
+
*/ export async function ensurePnpmWorkspace(projectPath) {
|
|
14
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
15
|
+
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
|
|
16
|
+
const pnpmField = packageJson.pnpm;
|
|
17
|
+
const configured = pnpmField?.onlyBuiltDependencies;
|
|
18
|
+
const builds = configured && configured.length > 0 ? configured : DEFAULT_BUILDS;
|
|
19
|
+
const workspacePath = path.join(projectPath, 'pnpm-workspace.yaml');
|
|
20
|
+
let yaml = '';
|
|
21
|
+
try {
|
|
22
|
+
yaml = await fs.readFile(workspacePath, 'utf-8');
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// Rethrow on a present-but-unreadable file; the write below would clobber it.
|
|
25
|
+
if (error.code !== 'ENOENT') {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
yaml = upsertTopLevelScalar(yaml, 'nodeLinker', 'hoisted');
|
|
30
|
+
yaml = upsertBuildApprovals(yaml, builds);
|
|
31
|
+
await fs.writeFile(workspacePath, yaml, 'utf-8');
|
|
32
|
+
if (pnpmField) {
|
|
33
|
+
delete pnpmField.onlyBuiltDependencies;
|
|
34
|
+
if (Object.keys(pnpmField).length === 0) {
|
|
35
|
+
delete packageJson.pnpm;
|
|
36
|
+
}
|
|
37
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set each build `true` under `allowBuilds` and drop it from any `ignoredBuiltDependencies`
|
|
42
|
+
* denylist. Pure and idempotent. pnpm v11 reads approvals only from pnpm-workspace.yaml.
|
|
43
|
+
*/ export function upsertBuildApprovals(content, builds) {
|
|
44
|
+
const blocks = toTopLevelBlocks(content);
|
|
45
|
+
const ignored = blocks.find((block)=>block.key === 'ignoredBuiltDependencies');
|
|
46
|
+
if (ignored) {
|
|
47
|
+
ignored.lines = ignored.lines.filter((line, index)=>{
|
|
48
|
+
if (index === 0) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
const name = /^\s*-\s*'?([^'\s]+)'?\s*$/.exec(line)?.[1];
|
|
52
|
+
return !(name && builds.includes(name));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const allow = blocks.find((block)=>block.key === 'allowBuilds');
|
|
56
|
+
if (allow) {
|
|
57
|
+
for (const name of builds){
|
|
58
|
+
const pattern = new RegExp(`^\\s+'?${escapeRegExp(name)}'?:`);
|
|
59
|
+
const index = allow.lines.findIndex((line)=>pattern.test(line));
|
|
60
|
+
if (index >= 0) {
|
|
61
|
+
allow.lines[index] = ` ${name}: true`;
|
|
62
|
+
} else {
|
|
63
|
+
allow.lines.push(` ${name}: true`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
blocks.push({
|
|
68
|
+
key: 'allowBuilds',
|
|
69
|
+
lines: [
|
|
70
|
+
'allowBuilds:',
|
|
71
|
+
...builds.map((name)=>` ${name}: true`)
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const output = blocks.flatMap((block)=>block.lines).join('\n');
|
|
76
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
77
|
+
}
|
|
78
|
+
/** Set a top-level `key: value` scalar, replacing any existing one. Pure and idempotent. */ export function upsertTopLevelScalar(content, key, value) {
|
|
79
|
+
const blocks = toTopLevelBlocks(content);
|
|
80
|
+
const line = `${key}: ${value}`;
|
|
81
|
+
const existing = blocks.find((block)=>block.key === key);
|
|
82
|
+
if (existing) {
|
|
83
|
+
existing.lines = [
|
|
84
|
+
line
|
|
85
|
+
];
|
|
86
|
+
} else {
|
|
87
|
+
blocks.push({
|
|
88
|
+
key,
|
|
89
|
+
lines: [
|
|
90
|
+
line
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const output = blocks.flatMap((block)=>block.lines).join('\n');
|
|
95
|
+
return output.endsWith('\n') ? output : `${output}\n`;
|
|
96
|
+
}
|
|
97
|
+
function toTopLevelBlocks(content) {
|
|
98
|
+
const lines = content.length ? content.replace(/\n$/, '').split('\n') : [];
|
|
99
|
+
const blocks = [];
|
|
100
|
+
for (const line of lines){
|
|
101
|
+
const key = /^[^\s#]/.test(line) ? /^([^:]+):/.exec(line)?.[1] : undefined;
|
|
102
|
+
const current = blocks[blocks.length - 1];
|
|
103
|
+
if (key !== undefined) {
|
|
104
|
+
blocks.push({
|
|
105
|
+
key,
|
|
106
|
+
lines: [
|
|
107
|
+
line
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
} else if (current) {
|
|
111
|
+
current.lines.push(line);
|
|
112
|
+
} else {
|
|
113
|
+
blocks.push({
|
|
114
|
+
key: null,
|
|
115
|
+
lines: [
|
|
116
|
+
line
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return blocks;
|
|
122
|
+
}
|
|
123
|
+
function escapeRegExp(value) {
|
|
124
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/figma",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"open": "^10.2.0",
|
|
42
42
|
"openapi-fetch": "0.15.0",
|
|
43
43
|
"picocolors": "1.1.1",
|
|
44
|
+
"skills": "1.4.4",
|
|
44
45
|
"tar": "^7.5.13",
|
|
45
46
|
"terminal-link": "^5.0.0",
|
|
46
47
|
"ts-morph": "^21.0.1",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@payloadcms/eslint-config": "3.28.0",
|
|
51
52
|
"@payloadcms/eslint-plugin": "3.28.0",
|
|
52
|
-
"@payloadcms/next": "4.0.0-canary.
|
|
53
|
+
"@payloadcms/next": "4.0.0-canary.24",
|
|
53
54
|
"@swc/cli": "0.7.7",
|
|
54
55
|
"@types/archiver": "7.0.0",
|
|
55
56
|
"@types/cross-spawn": "6.0.6",
|
|
@@ -66,9 +67,9 @@
|
|
|
66
67
|
"vitest": "4.0.15"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
|
-
"@payloadcms/plugin-cloud-storage": ">=4.0.0-canary.
|
|
70
|
-
"@payloadcms/richtext-lexical": ">=4.0.0-canary.
|
|
71
|
-
"payload": ">=4.0.0-canary.
|
|
70
|
+
"@payloadcms/plugin-cloud-storage": ">=4.0.0-canary.24 <4.0.0-internal",
|
|
71
|
+
"@payloadcms/richtext-lexical": ">=4.0.0-canary.24 <4.0.0-internal",
|
|
72
|
+
"payload": ">=4.0.0-canary.24 <4.0.0-internal"
|
|
72
73
|
},
|
|
73
74
|
"peerDependenciesMeta": {
|
|
74
75
|
"@payloadcms/plugin-cloud-storage": {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type DownloadSkillResult = {
|
|
2
|
-
detail?: string;
|
|
3
|
-
ok: false;
|
|
4
|
-
reason: 'already-installed' | 'empty-extract' | 'error' | 'fetch-failed';
|
|
5
|
-
} | {
|
|
6
|
-
ok: true;
|
|
7
|
-
};
|
|
8
|
-
export declare function downloadSkill(args: {
|
|
9
|
-
branch?: string;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
projectDir: string;
|
|
12
|
-
}): Promise<DownloadSkillResult>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
import { pipeline } from 'node:stream/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { x } from 'tar';
|
|
6
|
-
export async function downloadSkill(args) {
|
|
7
|
-
const { branch = 'main', debug, projectDir } = args;
|
|
8
|
-
const destDir = path.join(projectDir, '.claude', 'skills', 'payload');
|
|
9
|
-
if (await pathExists(path.join(destDir, 'SKILL.md'))) {
|
|
10
|
-
return {
|
|
11
|
-
ok: false,
|
|
12
|
-
reason: 'already-installed'
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branch}`;
|
|
16
|
-
const filter = `payload-${branch.replace(/^v/, '').replaceAll('/', '-')}/tools/claude-plugin/skills/payload/`;
|
|
17
|
-
if (debug) {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.log(`[download-skill] url=${url} dest=${destDir}`);
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const res = await fetch(url);
|
|
23
|
-
if (!res.ok) {
|
|
24
|
-
return {
|
|
25
|
-
detail: `${res.status} ${res.statusText}`,
|
|
26
|
-
ok: false,
|
|
27
|
-
reason: 'fetch-failed'
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (!res.body) {
|
|
31
|
-
return {
|
|
32
|
-
detail: 'empty response body',
|
|
33
|
-
ok: false,
|
|
34
|
-
reason: 'fetch-failed'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
await fs.mkdir(destDir, {
|
|
38
|
-
recursive: true
|
|
39
|
-
});
|
|
40
|
-
await pipeline(Readable.from(res.body), x({
|
|
41
|
-
cwd: destDir,
|
|
42
|
-
filter: (p)=>p.includes(filter),
|
|
43
|
-
strip: filter.split('/').length - 1
|
|
44
|
-
}));
|
|
45
|
-
if (!await pathExists(path.join(destDir, 'SKILL.md'))) {
|
|
46
|
-
await fs.rm(destDir, {
|
|
47
|
-
force: true,
|
|
48
|
-
recursive: true
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
ok: false,
|
|
52
|
-
reason: 'empty-extract'
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
ok: true
|
|
57
|
-
};
|
|
58
|
-
} catch (err) {
|
|
59
|
-
await fs.rm(destDir, {
|
|
60
|
-
force: true,
|
|
61
|
-
recursive: true
|
|
62
|
-
}).catch(()=>{});
|
|
63
|
-
return {
|
|
64
|
-
detail: err instanceof Error ? err.message : String(err),
|
|
65
|
-
ok: false,
|
|
66
|
-
reason: 'error'
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function pathExists(p) {
|
|
71
|
-
try {
|
|
72
|
-
await fs.access(p);
|
|
73
|
-
return true;
|
|
74
|
-
} catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|