@joripspace/cli 0.4.2 → 0.5.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.
- package/README.md +27 -5
- package/bin/joripspace.js +1623 -1610
- package/lib/checkpoint-commands.js +210 -210
- package/lib/deploy-files.js +245 -245
- package/lib/deployment-error.js +14 -14
- package/lib/github-commands.js +185 -0
- package/lib/help.js +138 -137
- package/lib/installer-args.js +28 -28
- package/lib/installer-target.js +134 -134
- package/lib/mcp-config.js +981 -981
- package/lib/project-env.js +198 -198
- package/lib/project-paths.js +257 -257
- package/lib/remote-commands.js +392 -392
- package/lib/start-command.js +140 -129
- package/lib/start.js +1440 -1423
- package/lib/template-commands.js +812 -812
- package/package.json +1 -1
- package/vendor/core/cli-onboarding.cjs +79 -0
- package/vendor/core/github-workflow.cjs +199 -186
- package/vendor/core/onboarding.cjs +2409 -2405
- package/vendor/core/template-publish-workflow.cjs +169 -169
- package/vendor/templates/index.js +104 -104
- package/vendor/templates/templates/basic-worker/files/worker.js +9 -9
- package/vendor/templates/templates/basic-worker/manifest.json +14 -14
- package/vendor/templates/templates/r2-file-api/files/worker.js +42 -42
- package/vendor/templates/templates/r2-file-api/manifest.json +7 -7
|
@@ -1,210 +1,210 @@
|
|
|
1
|
-
const fs = require('node:fs');
|
|
2
|
-
const os = require('node:os');
|
|
3
|
-
const path = require('node:path');
|
|
4
|
-
const { runCheckpointOperation } = require('./checkpoint-client');
|
|
5
|
-
|
|
6
|
-
function createCheckpointCommands(deps) {
|
|
7
|
-
async function command(rest, flags) {
|
|
8
|
-
const subcommand = rest[0] || 'list';
|
|
9
|
-
const project = deps.requireProjectId(flags);
|
|
10
|
-
const checkpointId =
|
|
11
|
-
deps.stringFlag(flags, 'checkpoint') || deps.stringFlag(flags, 'checkpoint-id') || rest[1] || '';
|
|
12
|
-
if (subcommand === 'save' || subcommand === 'restore') {
|
|
13
|
-
await runLocalOperation(subcommand, flags, checkpointId);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (subcommand === 'list') {
|
|
17
|
-
const params = new URLSearchParams();
|
|
18
|
-
const limit = deps.positiveIntegerFlag(flags, 'limit');
|
|
19
|
-
const cursor = deps.stringFlag(flags, 'cursor');
|
|
20
|
-
if (limit) params.set('limit', String(limit));
|
|
21
|
-
if (cursor) params.set('cursor', cursor);
|
|
22
|
-
const body = await deps.apiRequest(
|
|
23
|
-
flags,
|
|
24
|
-
`/v1/projects/${encodeURIComponent(project)}/checkpoints${params.size ? `?${params}` : ''}`,
|
|
25
|
-
{ method: 'GET', ...deps.projectAuth(flags) }
|
|
26
|
-
);
|
|
27
|
-
deps.output(flags, body, (value) => {
|
|
28
|
-
for (const item of value.checkpoints || []) {
|
|
29
|
-
console.log(
|
|
30
|
-
`#${item.sequence}\t${item.checkpoint_id}\t${item.label || '(이름 없음)'}\t${item.status}\t${item.deployable ? '배포 가능' : '백업 전용'}`
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
if (value.next_cursor) console.log(`다음 cursor: ${value.next_cursor}`);
|
|
34
|
-
});
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!checkpointId) throw new Error(`checkpoint ${subcommand} requires --checkpoint`);
|
|
38
|
-
const itemPath = `/v1/projects/${encodeURIComponent(project)}/checkpoints/${encodeURIComponent(checkpointId)}`;
|
|
39
|
-
if (subcommand === 'get') {
|
|
40
|
-
const body = await deps.apiRequest(flags, itemPath, { method: 'GET', ...deps.projectAuth(flags) });
|
|
41
|
-
deps.output(flags, body, (value) => {
|
|
42
|
-
console.log(`#${value.sequence} ${value.label || '(이름 없음)'}`);
|
|
43
|
-
console.log(`상태: ${value.status}`);
|
|
44
|
-
console.log(`배포: ${value.deployable ? '가능' : '백업 전용'}`);
|
|
45
|
-
console.log(`파일: ${value.file_count || 0}개`);
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (subcommand === 'update') {
|
|
50
|
-
const bodyInput = {};
|
|
51
|
-
if (flags.label !== undefined) bodyInput.label = deps.stringFlag(flags, 'label');
|
|
52
|
-
if (flags.pin) bodyInput.pinned = true;
|
|
53
|
-
if (flags.unpin) bodyInput.pinned = false;
|
|
54
|
-
const pinned = deps.stringFlag(flags, 'pinned');
|
|
55
|
-
if (pinned) bodyInput.pinned = pinned === 'true' || pinned === '1';
|
|
56
|
-
const body = await deps.apiRequest(flags, itemPath, {
|
|
57
|
-
method: 'PATCH',
|
|
58
|
-
...deps.projectAuth(flags),
|
|
59
|
-
body: bodyInput,
|
|
60
|
-
});
|
|
61
|
-
deps.output(flags, body, (value) => console.log(`저장본 #${value.sequence} 정보를 변경했습니다.`));
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (subcommand === 'delete') {
|
|
65
|
-
if (!deps.booleanFlag(flags, 'yes')) throw new Error('checkpoint delete requires --yes');
|
|
66
|
-
const body = await deps.apiRequest(flags, itemPath, { method: 'DELETE', ...deps.projectAuth(flags) });
|
|
67
|
-
deps.output(flags, body, () => console.log('저장본을 삭제했습니다.'));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (subcommand === 'deploy') {
|
|
71
|
-
const body = await deps.apiRequest(flags, `${itemPath}/deploy`, {
|
|
72
|
-
method: 'POST',
|
|
73
|
-
...deps.projectAuth(flags),
|
|
74
|
-
body: {},
|
|
75
|
-
});
|
|
76
|
-
deps.output(flags, body, (value) => {
|
|
77
|
-
console.log(`저장본을 배포했습니다: ${value.url || project}`);
|
|
78
|
-
console.log(`Deployment: ${value.deployment_id}`);
|
|
79
|
-
printCheckpointWarnings(value.warnings);
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
throw new Error(`Unknown checkpoint command: ${subcommand}`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function runLocalOperation(operation, flags, checkpointId) {
|
|
87
|
-
const connection = deps.resolveConnection(flags);
|
|
88
|
-
const value = await runCheckpointOperation(operation, {
|
|
89
|
-
workspaceDir: deps.projectWorkspaceDir(flags),
|
|
90
|
-
projectId: deps.requireProjectId(flags),
|
|
91
|
-
apiBaseUrl: connection.apiBaseUrl,
|
|
92
|
-
apiToken: deps.requireApiToken(flags, connection),
|
|
93
|
-
checkpointId,
|
|
94
|
-
label: deps.stringFlag(flags, 'label'),
|
|
95
|
-
apply: deps.booleanFlag(flags, 'apply'),
|
|
96
|
-
deploy: deps.booleanFlag(flags, 'deploy'),
|
|
97
|
-
});
|
|
98
|
-
deps.output(flags, value, (result) => {
|
|
99
|
-
if (result.status === 'saved') {
|
|
100
|
-
console.log(`저장본 #${result.checkpoint.sequence}을 만들었습니다. 파일 ${result.file_count}개`);
|
|
101
|
-
printCheckpointWarnings(result.checkpoint.warnings);
|
|
102
|
-
if (result.deployment) {
|
|
103
|
-
console.log(
|
|
104
|
-
`같은 저장본으로 배포했습니다: ${result.deployment.url || result.checkpoint.checkpoint_id}`
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
console.log(
|
|
110
|
-
`추가 ${result.additions.length}개, 덮어쓰기 ${result.overwrites.length}개, 삭제 ${result.deletions.length}개`
|
|
111
|
-
);
|
|
112
|
-
if (result.status === 'preview') {
|
|
113
|
-
console.log('미리보기만 했습니다. 승인 후 --apply를 붙여 다시 실행하세요.');
|
|
114
|
-
} else console.log(`로컬 파일을 복원했습니다. 백업: ${result.backup_root}`);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function deployArchive(flags, project, label, reason, options = {}) {
|
|
119
|
-
const staged = stageArchive(flags);
|
|
120
|
-
const connection = deps.resolveConnection(flags);
|
|
121
|
-
try {
|
|
122
|
-
const result = await runCheckpointOperation('save', {
|
|
123
|
-
workspaceDir: staged.root,
|
|
124
|
-
projectId: project,
|
|
125
|
-
apiBaseUrl: connection.apiBaseUrl,
|
|
126
|
-
apiToken: deps.requireApiToken(flags, connection),
|
|
127
|
-
entrypoint: staged.entrypoint,
|
|
128
|
-
label,
|
|
129
|
-
deploy: true,
|
|
130
|
-
sourceType: 'agent',
|
|
131
|
-
});
|
|
132
|
-
const value = {
|
|
133
|
-
...(result.deployment || {}),
|
|
134
|
-
checkpoint_id: result.checkpoint.checkpoint_id,
|
|
135
|
-
transport: 'verified_chunked_archive',
|
|
136
|
-
archive_bytes: result.archive_bytes,
|
|
137
|
-
file_count: result.file_count,
|
|
138
|
-
transport_reason: reason,
|
|
139
|
-
};
|
|
140
|
-
if (options.output !== false) {
|
|
141
|
-
deps.output(flags, value, (body) => {
|
|
142
|
-
console.log(`Deployment: ${body.deployment_id || body.checkpoint_id}`);
|
|
143
|
-
console.log(`Status: ${body.status || 'deployed'}`);
|
|
144
|
-
if (body.url || body.default_url) console.log(`URL: ${body.url || body.default_url}`);
|
|
145
|
-
console.log(`Transport: ${body.transport}`);
|
|
146
|
-
printCheckpointWarnings(result.checkpoint.warnings);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return value;
|
|
150
|
-
} finally {
|
|
151
|
-
if (staged.temporary) fs.rmSync(staged.root, { recursive: true, force: true });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function stageArchive(flags) {
|
|
156
|
-
const source = deps.stringFlag(flags, 'source');
|
|
157
|
-
const directory = deps.stringFlag(flags, 'dir');
|
|
158
|
-
const mappings = deps.arrayFlag(flags, 'file');
|
|
159
|
-
if (directory) {
|
|
160
|
-
const root = deps.resolveDeploySourceDirectory(directory, deps.projectWorkspaceDir(flags)).path;
|
|
161
|
-
const entrypoint = deps.safeProjectRelativePath(deps.stringFlag(flags, 'entrypoint'));
|
|
162
|
-
if (!fs.existsSync(path.join(root, ...entrypoint.split('/')))) {
|
|
163
|
-
throw new Error(`entrypoint not found in --dir: ${entrypoint}`);
|
|
164
|
-
}
|
|
165
|
-
deps.resolveDeploySourceFile(path.join(root, ...entrypoint.split('/')), root);
|
|
166
|
-
return { root, entrypoint, temporary: false };
|
|
167
|
-
}
|
|
168
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'joripspace-deploy-'));
|
|
169
|
-
try {
|
|
170
|
-
if (source) {
|
|
171
|
-
const entrypoint = deps.safeProjectRelativePath(
|
|
172
|
-
deps.stringFlag(flags, 'entrypoint') || path.basename(source)
|
|
173
|
-
);
|
|
174
|
-
copySource(root, entrypoint, source, deps.projectWorkspaceDir(flags));
|
|
175
|
-
return { root, entrypoint, temporary: true };
|
|
176
|
-
}
|
|
177
|
-
if (mappings.length) {
|
|
178
|
-
const entrypoint = deps.safeProjectRelativePath(deps.stringFlag(flags, 'entrypoint'));
|
|
179
|
-
for (const mapping of mappings) {
|
|
180
|
-
const [name, filePath] = deps.splitFileMapping(mapping);
|
|
181
|
-
copySource(root, deps.safeProjectRelativePath(name), filePath, deps.projectWorkspaceDir(flags));
|
|
182
|
-
}
|
|
183
|
-
if (!fs.existsSync(path.join(root, ...entrypoint.split('/')))) {
|
|
184
|
-
throw new Error(`entrypoint not found in --file mappings: ${entrypoint}`);
|
|
185
|
-
}
|
|
186
|
-
return { root, entrypoint, temporary: true };
|
|
187
|
-
}
|
|
188
|
-
throw new Error('deploy requires --source, --dir, or --file');
|
|
189
|
-
} catch (error) {
|
|
190
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
191
|
-
throw error;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function copySource(root, relative, source, workspaceDir) {
|
|
196
|
-
deps.assertDeployableProjectPath(relative);
|
|
197
|
-
const resolved = deps.resolveDeploySourceFile(source, workspaceDir);
|
|
198
|
-
const target = path.join(root, ...relative.split('/'));
|
|
199
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
200
|
-
fs.copyFileSync(resolved.path, target);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return { command, deployArchive };
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function printCheckpointWarnings(warnings) {
|
|
207
|
-
for (const warning of warnings || []) console.warn(`경고: ${warning.message}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
module.exports = { createCheckpointCommands };
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const os = require('node:os');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { runCheckpointOperation } = require('./checkpoint-client');
|
|
5
|
+
|
|
6
|
+
function createCheckpointCommands(deps) {
|
|
7
|
+
async function command(rest, flags) {
|
|
8
|
+
const subcommand = rest[0] || 'list';
|
|
9
|
+
const project = deps.requireProjectId(flags);
|
|
10
|
+
const checkpointId =
|
|
11
|
+
deps.stringFlag(flags, 'checkpoint') || deps.stringFlag(flags, 'checkpoint-id') || rest[1] || '';
|
|
12
|
+
if (subcommand === 'save' || subcommand === 'restore') {
|
|
13
|
+
await runLocalOperation(subcommand, flags, checkpointId);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (subcommand === 'list') {
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
const limit = deps.positiveIntegerFlag(flags, 'limit');
|
|
19
|
+
const cursor = deps.stringFlag(flags, 'cursor');
|
|
20
|
+
if (limit) params.set('limit', String(limit));
|
|
21
|
+
if (cursor) params.set('cursor', cursor);
|
|
22
|
+
const body = await deps.apiRequest(
|
|
23
|
+
flags,
|
|
24
|
+
`/v1/projects/${encodeURIComponent(project)}/checkpoints${params.size ? `?${params}` : ''}`,
|
|
25
|
+
{ method: 'GET', ...deps.projectAuth(flags) }
|
|
26
|
+
);
|
|
27
|
+
deps.output(flags, body, (value) => {
|
|
28
|
+
for (const item of value.checkpoints || []) {
|
|
29
|
+
console.log(
|
|
30
|
+
`#${item.sequence}\t${item.checkpoint_id}\t${item.label || '(이름 없음)'}\t${item.status}\t${item.deployable ? '배포 가능' : '백업 전용'}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (value.next_cursor) console.log(`다음 cursor: ${value.next_cursor}`);
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!checkpointId) throw new Error(`checkpoint ${subcommand} requires --checkpoint`);
|
|
38
|
+
const itemPath = `/v1/projects/${encodeURIComponent(project)}/checkpoints/${encodeURIComponent(checkpointId)}`;
|
|
39
|
+
if (subcommand === 'get') {
|
|
40
|
+
const body = await deps.apiRequest(flags, itemPath, { method: 'GET', ...deps.projectAuth(flags) });
|
|
41
|
+
deps.output(flags, body, (value) => {
|
|
42
|
+
console.log(`#${value.sequence} ${value.label || '(이름 없음)'}`);
|
|
43
|
+
console.log(`상태: ${value.status}`);
|
|
44
|
+
console.log(`배포: ${value.deployable ? '가능' : '백업 전용'}`);
|
|
45
|
+
console.log(`파일: ${value.file_count || 0}개`);
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (subcommand === 'update') {
|
|
50
|
+
const bodyInput = {};
|
|
51
|
+
if (flags.label !== undefined) bodyInput.label = deps.stringFlag(flags, 'label');
|
|
52
|
+
if (flags.pin) bodyInput.pinned = true;
|
|
53
|
+
if (flags.unpin) bodyInput.pinned = false;
|
|
54
|
+
const pinned = deps.stringFlag(flags, 'pinned');
|
|
55
|
+
if (pinned) bodyInput.pinned = pinned === 'true' || pinned === '1';
|
|
56
|
+
const body = await deps.apiRequest(flags, itemPath, {
|
|
57
|
+
method: 'PATCH',
|
|
58
|
+
...deps.projectAuth(flags),
|
|
59
|
+
body: bodyInput,
|
|
60
|
+
});
|
|
61
|
+
deps.output(flags, body, (value) => console.log(`저장본 #${value.sequence} 정보를 변경했습니다.`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (subcommand === 'delete') {
|
|
65
|
+
if (!deps.booleanFlag(flags, 'yes')) throw new Error('checkpoint delete requires --yes');
|
|
66
|
+
const body = await deps.apiRequest(flags, itemPath, { method: 'DELETE', ...deps.projectAuth(flags) });
|
|
67
|
+
deps.output(flags, body, () => console.log('저장본을 삭제했습니다.'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (subcommand === 'deploy') {
|
|
71
|
+
const body = await deps.apiRequest(flags, `${itemPath}/deploy`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
...deps.projectAuth(flags),
|
|
74
|
+
body: {},
|
|
75
|
+
});
|
|
76
|
+
deps.output(flags, body, (value) => {
|
|
77
|
+
console.log(`저장본을 배포했습니다: ${value.url || project}`);
|
|
78
|
+
console.log(`Deployment: ${value.deployment_id}`);
|
|
79
|
+
printCheckpointWarnings(value.warnings);
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`Unknown checkpoint command: ${subcommand}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function runLocalOperation(operation, flags, checkpointId) {
|
|
87
|
+
const connection = deps.resolveConnection(flags);
|
|
88
|
+
const value = await runCheckpointOperation(operation, {
|
|
89
|
+
workspaceDir: deps.projectWorkspaceDir(flags),
|
|
90
|
+
projectId: deps.requireProjectId(flags),
|
|
91
|
+
apiBaseUrl: connection.apiBaseUrl,
|
|
92
|
+
apiToken: deps.requireApiToken(flags, connection),
|
|
93
|
+
checkpointId,
|
|
94
|
+
label: deps.stringFlag(flags, 'label'),
|
|
95
|
+
apply: deps.booleanFlag(flags, 'apply'),
|
|
96
|
+
deploy: deps.booleanFlag(flags, 'deploy'),
|
|
97
|
+
});
|
|
98
|
+
deps.output(flags, value, (result) => {
|
|
99
|
+
if (result.status === 'saved') {
|
|
100
|
+
console.log(`저장본 #${result.checkpoint.sequence}을 만들었습니다. 파일 ${result.file_count}개`);
|
|
101
|
+
printCheckpointWarnings(result.checkpoint.warnings);
|
|
102
|
+
if (result.deployment) {
|
|
103
|
+
console.log(
|
|
104
|
+
`같은 저장본으로 배포했습니다: ${result.deployment.url || result.checkpoint.checkpoint_id}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.log(
|
|
110
|
+
`추가 ${result.additions.length}개, 덮어쓰기 ${result.overwrites.length}개, 삭제 ${result.deletions.length}개`
|
|
111
|
+
);
|
|
112
|
+
if (result.status === 'preview') {
|
|
113
|
+
console.log('미리보기만 했습니다. 승인 후 --apply를 붙여 다시 실행하세요.');
|
|
114
|
+
} else console.log(`로컬 파일을 복원했습니다. 백업: ${result.backup_root}`);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function deployArchive(flags, project, label, reason, options = {}) {
|
|
119
|
+
const staged = stageArchive(flags);
|
|
120
|
+
const connection = deps.resolveConnection(flags);
|
|
121
|
+
try {
|
|
122
|
+
const result = await runCheckpointOperation('save', {
|
|
123
|
+
workspaceDir: staged.root,
|
|
124
|
+
projectId: project,
|
|
125
|
+
apiBaseUrl: connection.apiBaseUrl,
|
|
126
|
+
apiToken: deps.requireApiToken(flags, connection),
|
|
127
|
+
entrypoint: staged.entrypoint,
|
|
128
|
+
label,
|
|
129
|
+
deploy: true,
|
|
130
|
+
sourceType: 'agent',
|
|
131
|
+
});
|
|
132
|
+
const value = {
|
|
133
|
+
...(result.deployment || {}),
|
|
134
|
+
checkpoint_id: result.checkpoint.checkpoint_id,
|
|
135
|
+
transport: 'verified_chunked_archive',
|
|
136
|
+
archive_bytes: result.archive_bytes,
|
|
137
|
+
file_count: result.file_count,
|
|
138
|
+
transport_reason: reason,
|
|
139
|
+
};
|
|
140
|
+
if (options.output !== false) {
|
|
141
|
+
deps.output(flags, value, (body) => {
|
|
142
|
+
console.log(`Deployment: ${body.deployment_id || body.checkpoint_id}`);
|
|
143
|
+
console.log(`Status: ${body.status || 'deployed'}`);
|
|
144
|
+
if (body.url || body.default_url) console.log(`URL: ${body.url || body.default_url}`);
|
|
145
|
+
console.log(`Transport: ${body.transport}`);
|
|
146
|
+
printCheckpointWarnings(result.checkpoint.warnings);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
} finally {
|
|
151
|
+
if (staged.temporary) fs.rmSync(staged.root, { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function stageArchive(flags) {
|
|
156
|
+
const source = deps.stringFlag(flags, 'source');
|
|
157
|
+
const directory = deps.stringFlag(flags, 'dir');
|
|
158
|
+
const mappings = deps.arrayFlag(flags, 'file');
|
|
159
|
+
if (directory) {
|
|
160
|
+
const root = deps.resolveDeploySourceDirectory(directory, deps.projectWorkspaceDir(flags)).path;
|
|
161
|
+
const entrypoint = deps.safeProjectRelativePath(deps.stringFlag(flags, 'entrypoint'));
|
|
162
|
+
if (!fs.existsSync(path.join(root, ...entrypoint.split('/')))) {
|
|
163
|
+
throw new Error(`entrypoint not found in --dir: ${entrypoint}`);
|
|
164
|
+
}
|
|
165
|
+
deps.resolveDeploySourceFile(path.join(root, ...entrypoint.split('/')), root);
|
|
166
|
+
return { root, entrypoint, temporary: false };
|
|
167
|
+
}
|
|
168
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'joripspace-deploy-'));
|
|
169
|
+
try {
|
|
170
|
+
if (source) {
|
|
171
|
+
const entrypoint = deps.safeProjectRelativePath(
|
|
172
|
+
deps.stringFlag(flags, 'entrypoint') || path.basename(source)
|
|
173
|
+
);
|
|
174
|
+
copySource(root, entrypoint, source, deps.projectWorkspaceDir(flags));
|
|
175
|
+
return { root, entrypoint, temporary: true };
|
|
176
|
+
}
|
|
177
|
+
if (mappings.length) {
|
|
178
|
+
const entrypoint = deps.safeProjectRelativePath(deps.stringFlag(flags, 'entrypoint'));
|
|
179
|
+
for (const mapping of mappings) {
|
|
180
|
+
const [name, filePath] = deps.splitFileMapping(mapping);
|
|
181
|
+
copySource(root, deps.safeProjectRelativePath(name), filePath, deps.projectWorkspaceDir(flags));
|
|
182
|
+
}
|
|
183
|
+
if (!fs.existsSync(path.join(root, ...entrypoint.split('/')))) {
|
|
184
|
+
throw new Error(`entrypoint not found in --file mappings: ${entrypoint}`);
|
|
185
|
+
}
|
|
186
|
+
return { root, entrypoint, temporary: true };
|
|
187
|
+
}
|
|
188
|
+
throw new Error('deploy requires --source, --dir, or --file');
|
|
189
|
+
} catch (error) {
|
|
190
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function copySource(root, relative, source, workspaceDir) {
|
|
196
|
+
deps.assertDeployableProjectPath(relative);
|
|
197
|
+
const resolved = deps.resolveDeploySourceFile(source, workspaceDir);
|
|
198
|
+
const target = path.join(root, ...relative.split('/'));
|
|
199
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
200
|
+
fs.copyFileSync(resolved.path, target);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return { command, deployArchive };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function printCheckpointWarnings(warnings) {
|
|
207
|
+
for (const warning of warnings || []) console.warn(`경고: ${warning.message}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
module.exports = { createCheckpointCommands };
|