Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/void/src/cli/cf-version-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,8 @@ export function createCfVersionRunner(options: {
'versions',
'create',
'--prebuilt',
...(operation.message ? ['--message', operation.message] : []),
// One argv item, so a message that starts with "-" is not read as a flag.
...(operation.message ? [`--message=${operation.message}`] : []),
...(operation.secretsFilePath ? ['--secrets-file', operation.secretsFilePath] : []),
...(operation.previewAlias ? ['--preview-alias', operation.previewAlias] : []),
],
Expand Down Expand Up @@ -696,7 +697,8 @@ export function createCfVersionRunner(options: {
[
'deploy',
'--prebuilt',
...(operation.message ? ['--message', operation.message] : []),
// One argv item, so a message that starts with "-" is not read as a flag.
...(operation.message ? [`--message=${operation.message}`] : []),
...(operation.secretsFilePath ? ['--secrets-file', operation.secretsFilePath] : []),
],
command.capture,
Expand Down
6 changes: 4 additions & 2 deletions packages/void/src/cli/cloudflare-operation-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ async function resources(): Promise<Result> {
switch (operation.type) {
case 'd1.execute': {
const database = d1Database(operation.database);
return runCf(['d1', 'query', database.id, '--sql', operation.sql]);
// One argv item, so cf cannot read SQL that starts with "-" (such as a comment) as a flag.
return runCf(['d1', 'query', database.id, `--sql=${operation.sql}`]);
}
case 'd1.migrations.list':
case 'd1.migrations.apply': {
Expand Down Expand Up @@ -1116,7 +1117,8 @@ async function workerChanges(): Promise<Result> {
[
...(request.type === 'worker.deploy' ? ['deploy'] : ['workers', 'versions', 'create']),
'--prebuilt',
...(request.message ? ['--message', request.message] : []),
// One argv item, so a message that starts with "-" is not read as a flag.
...(request.message ? [`--message=${request.message}`] : []),
...(request.secretsFilePath ? ['--secrets-file', request.secretsFilePath] : []),
],
directory,
Expand Down
3 changes: 1 addition & 2 deletions packages/void/test/unit/cf-version-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2547,8 +2547,7 @@ it('preserves activation metadata and sorts cf version history for the existing
'versions',
'create',
'--prebuilt',
'--message',
'void:metadata',
'--message=void:metadata',
'--preview-alias',
'void-ready',
]);
Expand Down
44 changes: 41 additions & 3 deletions packages/void/test/unit/cloudflare-operation-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,45 @@ it('uses pinned cf despite a project-local CLI and preserves D1 results and the
]);
}, 30_000);

it('sends D1 SQL that starts with a comment as one --sql value through the pinned cf', async () => {
const directory = temporaryDirectory('void-cf-d1-comment-sql-');
const bodies: Array<unknown> = [];
const api = await listen(
createServer(async (request, response) => {
let body = '';
for await (const chunk of request) {
body += chunk;
}
bodies.push(JSON.parse(body));
response.setHeader('Content-Type', 'application/json');
response.end(
JSON.stringify({
success: true,
errors: [],
messages: [],
result: [{ results: [], success: true, meta: {} }],
}),
);
}),
);
const configPath = join(directory, 'wrangler.json');
writeFileSync(
configPath,
JSON.stringify({
account_id: 'test-account',
d1_databases: [{ binding: 'DB', database_id: 'test-database' }],
}),
);
const sql = '-- leading comment\nSELECT 1;';
const output = await runOperation(
directory,
{ type: 'd1.execute', database: 'DB', sql, configPath },
tokenEnv(api, 'CF_API_TOKEN'),
);
expect(output.status, output.stderr).toBe(0);
expect(bodies).toEqual([{ sql }]);
}, 30_000);

it('uses the configured HTTP proxy for cf resource requests', async () => {
const directory = temporaryDirectory('void-cf-resource-proxy-');
let proxied = 0;
Expand Down Expand Up @@ -1405,7 +1444,7 @@ syncBuiltinESMExports();`,
{
type: 'versions.upload',
configPath,
message: 'review',
message: '-review',
...(interactive ? { interactive } : {}),
},
unproxiedEnv(api),
Expand All @@ -1418,8 +1457,7 @@ syncBuiltinESMExports();`,
'versions',
'create',
'--prebuilt',
'--message',
'review',
'--message=-review',
]);
if (interactive) {
expect(called.stdio).toBe('inherit');
Expand Down