Skip to content

Commit

Permalink
feat: separate "git export" module
Browse files Browse the repository at this point in the history
user shouldn't load code that is rarely used
  • Loading branch information
senyai committed May 9, 2024
1 parent 74c4851 commit 37c47ae
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 183 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/fossil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: 18
- name: Install dependencies
run: npm ci
- name: Run ESLint
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:

- name: Package
if: startsWith(github.ref, 'refs/tags/v')
run: rm -rf out && npm run package -- --allow-star-activation
run: rm -rf out && npm run package

- name: Release
uses: softprops/action-gh-release@v2
Expand Down
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.github/
.mocharc.js
esbuild.config.js
.nycrc
.vscode
**/.gitignore
Expand Down
299 changes: 138 additions & 161 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1119,36 +1119,34 @@
]
},
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify && npm run esbuild-preview -- --minify",
"compile": "tsc -p ./ && npm run esbuild-preview",
"esbuild-preview": "esbuild ./media/preview.ts --bundle --outfile=media/preview.js --platform=browser --format=iife",
"package": "vsce package",
"vscode:prepublish": "npm run bundle -- --minify",
"bundle": "node ./esbuild.config.js",
"compile": "tsc -p ./",
"package": "vsce package --allow-star-activation",
"deploy": "vsce publish",
"pretest": "npm run compile",
"test": "node ./out/test/runTest.js",
"coverage": "node ./node_modules/c8/bin/c8.js --reporter lcov --check-coverage npm run test",
"coverage-ci": "node ./node_modules/c8/bin/c8.js --reporter json-summary --check-coverage npm run test && node ./out/test/summary_as_markdown.js coverage/coverage-summary.json",
"lint": "eslint ./src --ext .ts src media",
"lint:fix": "eslint --fix --ext .ts src media",
"esbuild-base": "esbuild ./src/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap",
"grammar-test": "vscode-tmgrammar-test ./pikchr/test/*.test.pikchr"
},
"dependencies": {
"vscode-nls": "^5.0.1"
},
"devDependencies": {
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@octokit/rest": "^20.1.0",
"@types/mocha": "~10.0.1",
"@types/node": "^16.18.32",
"@types/node": "^18",
"@types/sinon": "~17.0.3",
"@types/vscode": "^1.36.0",
"@types/vscode-webview": "^1.57.0",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@vscode/test-electron": "~2.3.9",
"@vscode/vsce": "~2.26.0",
"@octokit/rest": "~20.1.0",
"@vscode/vsce": "~2.26.1",
"c8": "^8.0.1",
"esbuild": "~0.20.2",
"eslint": "^8.52.0",
Expand Down
21 changes: 13 additions & 8 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
ResourceStatus,
ResourcePath,
} from './openedRepository';
import { Model } from './model';
import type { Model } from './model';
import {
FossilResource,
CommitOptions,
Expand All @@ -51,8 +51,7 @@ import { FossilPreviewManager } from './preview';
import { FossilExecutable, FossilCWD } from './fossilExecutable';

import { localize } from './main';
import { PraiseAnnotator } from './praise';
import { Credentials, exportGit, inputExportOptions } from './gitExport';
import type { Credentials } from './gitExport';

type CommandKey =
| 'add'
Expand Down Expand Up @@ -178,7 +177,7 @@ function command(repository?: 1) {
export class CommandCenter {
private readonly disposables: Disposable[];
private readonly previewManager: FossilPreviewManager;
private readonly credentials = new Credentials();
private credentials: Credentials | undefined;

constructor(
private readonly executable: FossilExecutable,
Expand Down Expand Up @@ -1411,7 +1410,8 @@ export class CommandCenter {
if (!editor) {
return;
}
if (PraiseAnnotator.tryDelete(editor)) {
const praise = await require('./praise');
if (praise.PraiseAnnotator.tryDelete(editor)) {
return;
}
const uri = editor.document.uri;
Expand All @@ -1420,18 +1420,23 @@ export class CommandCenter {
return;
}
const praises = await repository.praise(uri.fsPath);
await PraiseAnnotator.create(repository, editor, praises);
await praise.PraiseAnnotator.create(repository, editor, praises);
}

@command(Inline.Repository)
async gitPublish(repository: Repository): Promise<void> {
const options = await inputExportOptions(
const gitExport = await require('./gitExport');

if (!this.credentials) {
this.credentials = new gitExport.Credentials();
}
const options = await gitExport.inputExportOptions(
this.credentials,
repository,
this.disposables
);
if (options) {
await exportGit(options, repository);
await gitExport.exportGit(options, repository);
}
}
@command(Inline.Repository)
Expand Down
4 changes: 2 additions & 2 deletions src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ import {
AutoIncomingOutgoing,
} from './autoinout';
import * as interaction from './interaction';
import { InteractionAPI, NewBranchOptions } from './interaction';
import type { InteractionAPI, NewBranchOptions } from './interaction';
import { FossilUriParams, toFossilUri } from './uri';

import { localize } from './main';
import { ExecFailure, ExecResult } from './fossilExecutable';
import type { ExecFailure, ExecResult } from './fossilExecutable';
const iconsRootPath = path.join(path.dirname(__dirname), 'resources', 'icons');

type AvailableIcons =
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/timelineSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as vscode from 'vscode';
import { window } from 'vscode';
import * as assert from 'assert/strict';
import { FossilUriParams, toFossilUri } from '../../uri';
import { FossilCWD } from '../../fossilExecutable';
import type { FossilCWD } from '../../fossilExecutable';
import { add, cleanupFossil, getExecutable, getRepository } from './common';
import { Suite, before } from 'mocha';
import * as sinon from 'sinon';
import { FossilCheckin } from '../../openedRepository';
import type { FossilCheckin } from '../../openedRepository';

// separate function because hash size is different
const uriMatch = (uri: vscode.Uri, checkin: FossilCheckin) =>
Expand Down

0 comments on commit 37c47ae

Please sign in to comment.