+
Skip to content

Improve log file UI, prevent editing #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 14, 2022
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Find out in seconds whether the setup is right, all in your local.

## License Key

Local CI requires a [license key](https://getlocalci.com/pricing/?utm_medium=extension&utm_source=readme) for $10 per month.
Local CI requires a [license key](https://getlocalci.com/pricing/?utm_medium=extension&utm_source=readme) for $15 per month.

But first you'll get a free 15-day preview, no sign-up or credit card needed.

Expand Down
1 change: 0 additions & 1 deletion node/binary.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export function install(): void;
export function uninstall(): void;
export function getBinaryPath(): string;
3 changes: 0 additions & 3 deletions node/uninstall.js

This file was deleted.

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@
"href": "https://getlocalci.com/pricing/?utm_medium=extension&utm_source=badge",
"description": "15 day free preview"
},
{
"url": "https://vsmarketplacebadge.apphb.com/trending-monthly/LocalCI.local-ci.svg?logo=tinder&color=orange&logoColor=white&label=trending%20monthly",
"href": "https://marketplace.visualstudio.com/items?itemName=LocalCI.local-ci",
"description": "Trending Monthly"
},
{
"url": "https://img.shields.io/badge/platform-macOS-yellow",
"href": "https://en.wikipedia.org/wiki/MacOS",
Expand All @@ -277,8 +272,7 @@
"pretest": "npm run test-compile && npm run lint",
"lint": "eslint src --ext ts",
"lint:fix": "eslint src --ext ts --fix",
"test": "node ./out/test/runTest.js",
"vscode:uninstall": "node ./node/uninstall"
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@cloudflare/binary-install": "^0.2.0",
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode';
import { SHOW_LOG_FILE_COMMAND } from '../constants';

export default class Log extends vscode.TreeItem {
constructor(public readonly label: string, public readonly filePath: string) {
Expand All @@ -7,7 +8,7 @@ export default class Log extends vscode.TreeItem {
this.collapsibleState = vscode.TreeItemCollapsibleState.None;
this.command = {
title: label,
command: 'vscode.open',
command: SHOW_LOG_FILE_COMMAND,
tooltip,
arguments: [filePath],
};
Expand Down
8 changes: 8 additions & 0 deletions src/classes/LogProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as fs from 'fs';
import * as vscode from 'vscode';

export default class LogProvider implements vscode.TextDocumentContentProvider {
provideTextDocumentContent(uri: vscode.Uri): string {
return fs.readFileSync(uri.fsPath, 'utf8');
}
}
4 changes: 3 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ export const DYNAMIC_CONFIG_PATH_IN_CONTAINER = path.join(
CONTAINER_STORAGE_DIRECTORY,
DYNAMIC_CONFIG_FILE_NAME
);
export const HOST_TMP_DIRECTORY = '/tmp/local-ci'; // Also hard-coded in node/uninstall.js, change that if this changes. Be careful changing this, as there's an rm -rf for it.
export const HOST_TMP_DIRECTORY = '/tmp/local-ci';
export const RUN_JOB_COMMAND = 'local-ci.job.run';
export const CREATE_CONFIG_FILE_COMMAND = 'local-ci.create.config';
export const SHOW_LOG_FILE_COMMAND = 'local-ci.show.log-file';
export const LOG_FILE_SCHEME = 'local-ci-log';
export const CONTINUE_PIPELINE_STEP_NAME = 'Continue the pipeline';
export const SCHEDULE_INTERVIEW_URL =
'https://tidycal.com/localci/30-minute-meeting';
Expand Down
11 changes: 11 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Delayer from './classes/Delayer';
import Job from './classes/Job';
import JobProvider from './classes/JobProvider';
import LicenseProvider from './classes/LicenseProvider';
import LogProvider from './classes/LogProvider';
import {
COMMITTED_IMAGE_NAMESPACE,
CREATE_CONFIG_FILE_COMMAND,
Expand All @@ -18,9 +19,11 @@ import {
HELP_URL,
HOST_TMP_DIRECTORY,
JOB_TREE_VIEW_ID,
LOG_FILE_SCHEME,
PROCESS_TRY_AGAIN_COMMAND,
RUN_JOB_COMMAND,
SELECTED_CONFIG_PATH,
SHOW_LOG_FILE_COMMAND,
TELEMETRY_KEY,
TRIAL_STARTED_TIMESTAMP,
} from './constants';
Expand All @@ -38,6 +41,7 @@ import getStarterConfig from './utils/getStarterConfig';
import prepareConfig from './utils/prepareConfig';
import runJob from './utils/runJob';
import showLicenseInput from './utils/showLicenseInput';
import showLogFile from './utils/showLogFile';

const reporter = new TelemetryReporter(
EXTENSION_ID,
Expand Down Expand Up @@ -83,6 +87,10 @@ export function activate(context: vscode.ExtensionContext): void {
vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.refresh`, () =>
jobProvider.hardRefresh()
),
vscode.workspace.registerTextDocumentContentProvider(
LOG_FILE_SCHEME,
new LogProvider()
),
vscode.commands.registerCommand(PROCESS_TRY_AGAIN_COMMAND, async () => {
// There might have been a problem with the dynamic config file, so remove it.
const dynamicConfig = getDynamicConfigPath(
Expand Down Expand Up @@ -385,6 +393,9 @@ export function activate(context: vscode.ExtensionContext): void {
{ detail: 'Starter config file' }
);
jobProvider.hardRefresh();
}),
vscode.commands.registerCommand(SHOW_LOG_FILE_COMMAND, (logFilePath) => {
showLogFile(logFilePath);
})
);

Expand Down
9 changes: 3 additions & 6 deletions src/utils/listenToJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import getConfigFilePath from './getConfigFilePath';
import getConfigFromPath from './getConfigFromPath';
import getDynamicConfigPath from './getDynamicConfigPath';
import getSpawnOptions from './getSpawnOptions';
import showLogFile from './showLogFile';

function handleExit(
job: Job | undefined,
Expand All @@ -30,13 +31,9 @@ function handleExit(
title: showJobOutput,
}
)
.then(async (clicked) => {
.then((clicked) => {
if (clicked?.title === showJobOutput) {
vscode.window.showTextDocument(
folderUri.with({
path: logFilePath,
})
);
showLogFile(logFilePath);
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions src/utils/showLogFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as vscode from 'vscode';
import { LOG_FILE_SCHEME } from '../constants';

export default async function showLogFile(logFilePath: string): Promise<void> {
await vscode.window.showTextDocument(
await vscode.workspace.openTextDocument(
vscode.Uri.parse(`${LOG_FILE_SCHEME}:${logFilePath}`)
)
);
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载