Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/commands/restart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {useRef, useState} from 'react';
import type {Step} from '../components/StepRunner.js';
import StepRunner from '../components/StepRunner.js';
import {ensureAgentRunning} from '../lib/agent.js';
import {writeApacheConf} from '../lib/apache-conf.js';
import {writeProjectCompose} from '../lib/compose.js';
import {readLocalConfig, readProjectConfig, writeLocalConfig} from '../lib/config.js';
import {
Expand All @@ -16,7 +17,6 @@ import {
import {buildProjectHostname} from '../lib/hostname.js';
import {validateWordPressPhp} from '../lib/image-tags.js';
import {writeMuPlugin} from '../lib/mu-plugin.js';
import {writeApacheConf} from '../lib/apache-conf.js';
import {
getProjectPluginsDir,
getProjectRuntimeDir,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/up.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {useRef, useState} from 'react';
import type {Step} from '../components/StepRunner.js';
import StepRunner from '../components/StepRunner.js';
import {ensureAgentRunning} from '../lib/agent.js';
import {writeApacheConf} from '../lib/apache-conf.js';
import {writeProjectCompose} from '../lib/compose.js';
import {
projectConfigExists,
Expand All @@ -24,7 +25,6 @@ import {
import {buildProjectHostname} from '../lib/hostname.js';
import {validateWordPressPhp} from '../lib/image-tags.js';
import {writeMuPlugin} from '../lib/mu-plugin.js';
import {writeApacheConf} from '../lib/apache-conf.js';
import {
getProjectPluginsDir,
getProjectRuntimeDir,
Expand Down
11 changes: 5 additions & 6 deletions src/lib/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export const SHARE_URL_CONTAINER_PATH = '/tmp/kiqr-share-url';
export function resolveProjectContainerId(
projectId: string,
service: string,
exec: (cmd: string) => string = (cmd) =>
execSync(cmd, {stdio: 'pipe'}).toString(),
exec: (cmd: string) => string = (cmd) => execSync(cmd, {stdio: 'pipe'}).toString(),
): string | null {
try {
const out = exec(
Expand Down Expand Up @@ -126,13 +125,13 @@ export function writeShareUrlToContainer(
}
const id = resolveProjectContainerId(projectId, 'wordpress');
if (!id) {
onError?.(new Error(`Could not resolve WordPress container for project ${projectId}`));
onError?.(
new Error(`Could not resolve WordPress container for project ${projectId}`),
);
return;
}
try {
exec(
`docker exec ${id} sh -c 'printf %s ${url} > ${SHARE_URL_CONTAINER_PATH}'`,
);
exec(`docker exec ${id} sh -c 'printf %s ${url} > ${SHARE_URL_CONTAINER_PATH}'`);
} catch (err) {
onError?.(err);
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/BitnamiRuntimeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export class BitnamiRuntimeProvider implements RuntimeProvider {
"$$fwd_host = !empty($$_SERVER['HTTP_X_FORWARDED_HOST']) ? trim(explode(',', $$_SERVER['HTTP_X_FORWARDED_HOST'])[0]) : ''; " +
"$$fwd_proto = !empty($$_SERVER['HTTP_X_FORWARDED_PROTO']) ? strtolower(trim(explode(',', $$_SERVER['HTTP_X_FORWARDED_PROTO'])[0])) : ''; " +
"$$share_url = ($$fwd_proto === 'https' && is_readable('/tmp/kiqr-share-url')) ? trim(@file_get_contents('/tmp/kiqr-share-url')) : ''; " +
"$$share_parts = $$share_url ? parse_url($$share_url) : false; " +
'$$share_parts = $$share_url ? parse_url($$share_url) : false; ' +
"if (is_array($$share_parts) && !empty($$share_parts['host'])) { " +
" $$host = $$share_parts['host']; " +
" $$proto = strtolower($$share_parts['scheme'] ?? 'https'); " +
" $$_SERVER['HTTP_HOST'] = $$host; " +
"} else { " +
'} else { ' +
" $$host = $$fwd_host ?: ($$_SERVER['HTTP_HOST'] ?? 'localhost'); " +
" $$proto = ($$fwd_proto === 'https') ? 'https' : 'http'; " +
"} " +
'} ' +
"if ($$proto === 'https') { $$_SERVER['HTTPS'] = 'on'; $$_SERVER['SERVER_PORT'] = 443; } " +
"define('WP_HOME', $$proto . '://' . $$host); " +
"define('WP_SITEURL', $$proto . '://' . $$host);",
Expand Down
4 changes: 1 addition & 3 deletions tests/lib/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ describe('generateAgentCompose', () => {
const parsed = YAML.parse(yaml);
const command = parsed.services.traefik.command as string[];
expect(
command.some(
(c) => c === '--entrypoints.web.forwardedHeaders.insecure=true',
),
command.some((c) => c === '--entrypoints.web.forwardedHeaders.insecure=true'),
).toBe(true);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/mu-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('writeMuPlugin', () => {
// production concern; in dev we want pages to render wherever requested.
const content = fs.readFileSync(writeMuPlugin(tmp), 'utf-8');
expect(content).toContain("remove_filter('template_redirect', 'redirect_canonical')");
expect(content).toContain("WPSEO_Frontend");
expect(content).toContain('WPSEO_Frontend');
});

it('rewrites absolute production URLs in the response body to the current dynamic URL', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/share.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('writeShareUrlToContainer', () => {
});

describe('clearShareUrlFromContainer', () => {
it('is a no-op when no matching container is running (doesn\'t throw)', () => {
it("is a no-op when no matching container is running (doesn't throw)", () => {
// Same rationale as writeShareUrlToContainer: when the container is
// already gone there is nothing to clean and we mustn't fail the
// tunnel-exit path.
Expand Down
Loading