From c45cf9278a519254fb88ec6a4e9967a0deeef0be Mon Sep 17 00:00:00 2001 From: uctakeoff Date: Thu, 1 Aug 2024 08:10:38 +0900 Subject: [PATCH] feat: support for output outside the workspace --- .vscodeignore | 1 - src.zip | Bin 0 -> 22448 bytes src/extension.ts | 37 +++++++++++++++---------------- src/test/runTest.ts | 23 +++++++++++++++++++ src/test/suite/Gitignore.test.ts | 18 +++++++++++++++ src/test/suite/extension.test.ts | 15 +++++++++++++ src/test/suite/index.ts | 37 +++++++++++++++++++++++++++++++ src/vscode-utils.ts | 29 ++++++++++++------------ 8 files changed, 126 insertions(+), 34 deletions(-) create mode 100644 src.zip create mode 100644 src/test/runTest.ts create mode 100644 src/test/suite/Gitignore.test.ts create mode 100644 src/test/suite/extension.test.ts create mode 100644 src/test/suite/index.ts diff --git a/.vscodeignore b/.vscodeignore index 3662890..a8a8b40 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -3,7 +3,6 @@ .VSCodeCounter/** out/test/** src/** -.gitignore vsc-extension-quickstart.md **/tsconfig.json **/tslint.json diff --git a/src.zip b/src.zip new file mode 100644 index 0000000000000000000000000000000000000000..86fc61b1f59370d7773ed88233f39f8b0cb1cf83 GIT binary patch literal 22448 zcmbTdV{~QFwk;gnsMxk`JE_>I*cIEhZS2^t*tTukMkO!j>fH0*YhQc!TdnQA*N?H* znyrsM`RnxfcC!! z#q|Gv6Jrx60}E?M`rpP)iM=tIj7TBZyun2}ZAz>9P|&+t3wj>w8^VZsX`*V;;nodn zlI|~4`jT_bjm>;3Ik!>Wuj$CJYW}E7tCZzIplbE3QVnS(Oxv}jbPXM{C{a?N(dU!t zO(weP-Yiae*C9fuFKOI4Ypt{* z@ee2Bx#lJImOPV?#UjDqrPcuBrHYXVE5Z2*`-Cy(2^zenMds1Ww@&-Zx;F+`!%Xe? zEvbmHOs-!t-0lmV{$`;8DbH7^0L3o)0jL#D|LkM%de4c@9mWMX5da;>I6%=tlJhaIma}k!QvFg5V-R*tdsP7irxHsUN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5W&H&R0NLHCQZj<9{!kU0uZO?RltNII8WCiVdqPFU6zHtMTS zbk*|2hS!eWfgHx(Gu7K+(f61>Z}a)AbDdi-ib$sPzJW&;#u|bsHP4GE|1oK3N*@YlDpMx! z7=OsUOXAZVmCsf$u6sJkDr@AO6Iko?dnPzpy)B~y7jZX!|7o;K2t2TKA|I|5oA_?Y z8t%aEx7%{U(L%XY9FMr)T33x)evgr7V};yx$Ld0hby(F3t{hCe{o;+qRqsjr-rheg zpokHJs!)&i*0(8++oo5QK0ND5V#0%!@_5iUN6Sp*F5|kNWE4BfA*bhR#MTVeFf5{P zAB3M64RCb+u*CJCTXK&P^sthU`|8fPYj`Q&2e&kNn(QAaPRXq@YGBsO0qo~FnH!NfmJn{*qx!B8OCNC0q2k7XPK>y47>@e}6h4dl4A5Z#_ zo=I6Y?#DqOIuJJ~$PpA7alD(Zp!Zo+#85Y#&!Lt=7ltl6;Hb2AX~0nh{~DFbJPinm zE;f;b6CvA-FFqnc22P*Z=>IVrItYH{{@tQBi_!Frj07WTg8r|bOZZ0Iw(!GfI3EqmBnAsLGl;^3OM`} zxiJ^iEp;L&jkJIQt}y(X0B01CPfk2_OU?OafU0$@K`B2$Z+^Mk2^9^U=*d zwFpWhAfSj6VtMTsMf|&ifzs{C-?caWY1R0_s8!1XawT6NawsdOohnr90s1#9R6qa+IKKcG1vx6}C@3qmWB@4&4O#%;MA(1ZjyacGHAElo|N7|BVz?Bp*jO6&t;q%G_LiLlTQ3v&jv5%mM-}>X3T> E1-84cfB*mh literal 0 HcmV?d00001 diff --git a/src/extension.ts b/src/extension.ts index 8ac020f..050d831 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,7 +6,7 @@ import * as path from 'path'; import { Count } from './LineCounter'; import { LanguageConf, LineCounterTable } from './LineCounterTable'; import Gitignore from './Gitignore'; -import { buildUri, createTextDecoder, currentWorkspaceFolder, dirUri, makeDirectories, parseUriOrFile, readJsonFile, readUtf8Files, showTextPreview, writeTextFile } from './vscode-utils'; +import { buildUri, createTextDecoder, currentWorkspaceFolder, dirUri, makeDirectories, readJsonFile, readUtf8Files, showTextPreview, writeTextFile } from './vscode-utils'; import { internalDefinitions } from './internalDefinitions'; const EXTENSION_ID = 'uctakeoff.vscode-counter'; @@ -119,10 +119,9 @@ class CodeCounterController { // create a combined disposable from both event subscriptions this.disposable = vscode.Disposable.from(...subscriptions); - currentWorkspaceFolder().then((workFolder) => { - vscode.workspace.fs.stat(buildUri(workFolder.uri, this.conf.outputDirectory, REALTIME_COUNTER_FILE)) - .then(() => this.toggleVisible(), log); - }); + currentWorkspaceFolder() + .then((workFolder) => vscode.workspace.fs.stat(buildUri(workFolder.uri, this.conf.outputDirectory, REALTIME_COUNTER_FILE))) + .then(() => this.toggleVisible(), log); } dispose() { this.statusBarItem?.dispose(); @@ -259,9 +258,9 @@ class CodeCounterController { .filter(d => ((d[1] & vscode.FileType.Directory) != 0) && regex.test(d[0])) .map(d => d[0]) .sort() - .map(d => buildUri(outputDir, d)); + .map(d => vscode.Uri.joinPath(outputDir, d)); - const outSubdir = buildUri(outputDir, toLocalDateString(date, ['-', '_', '-'])); + const outSubdir = vscode.Uri.joinPath(outputDir, toLocalDateString(date, ['-', '_', '-'])); await outputResults(date, targetUri, results, outSubdir, histories[histories.length - 1], this.conf); if (histories.length >= this.conf.history) { @@ -423,7 +422,7 @@ const collectLanguageConfigurations = (langs: Map): Promis const langExt = append(langs, l.id, l); if (l.configuration) { const confUrl = vscode.Uri.file(path.join(ex.extensionPath, l.configuration)); - const langConf = await readJsonFile(confUrl, undefined, {}); + const langConf = await readJsonFile(confUrl, {}); // log(`"${confUrl.fsPath}" :${l.id}\n aliases:${l.aliases}\n extensions:${l.extensions}\n filenames:${l.filenames}`, l); if (langConf.comments) { if (langConf.comments.lineComment) { @@ -470,7 +469,7 @@ const saveLanguageConfigurations = async (langs: { [key: string]: LanguageConf } } case "use languageConfUri":{ const workFolder = await currentWorkspaceFolder(); - await writeTextFile(parseUriOrFile(conf.languageConfUri, workFolder.uri), JSON.stringify(langs), {recursive: true}); + await writeTextFile(buildUri(workFolder.uri, conf.languageConfUri), JSON.stringify(langs), {recursive: true}); break; } default: break; @@ -486,10 +485,10 @@ const loadLanguageConfigurations = async (conf: Config): Promise<{ [key: string] case "output directory": const workFolder = await currentWorkspaceFolder(); const outputDir = buildUri(workFolder.uri, conf.outputDirectory); - return await readJsonFile<{ [key: string]: Partial }>(outputDir, 'languages.json', {}); + return await readJsonFile<{ [key: string]: Partial }>(vscode.Uri.joinPath(outputDir, 'languages.json'), {}); case "use languageConfUri":{ const workFolder = await currentWorkspaceFolder(); - return await readJsonFile<{ [key: string]: Partial }>(parseUriOrFile(conf.languageConfUri, workFolder.uri), undefined, {}); + return await readJsonFile<{ [key: string]: Partial }>(buildUri(workFolder.uri, conf.languageConfUri), {}); } default: break; } @@ -509,7 +508,7 @@ const previewFiles = new Map([ ]); const outputResults = async (date: Date, targetDirUri: vscode.Uri, results: Result[], outputDir: vscode.Uri, prevOutputDir: vscode.Uri | undefined, conf: Config) => { await makeDirectories(outputDir); - writeTextFile(buildUri(outputDir, `results.json`), resultsToJson(results)); + writeTextFile(vscode.Uri.joinPath(outputDir, `results.json`), resultsToJson(results)); const resultTable = new ResultFormatter(targetDirUri, results, conf); log(`OutputDir : ${outputDir}, count ${results.length} files`); @@ -517,7 +516,7 @@ const outputResults = async (date: Date, targetDirUri: vscode.Uri, results: Resu const diffs: Result[] = []; if (prevOutputDir) { try { - const prevResults = await readJsonFile<{ [uri: string]: Count & { language: string } }>(prevOutputDir, 'results.json', {}); + const prevResults = await readJsonFile<{ [uri: string]: Count & { language: string } }>(vscode.Uri.joinPath(prevOutputDir, 'results.json'), {}); log(`Previous OutputDir : ${prevOutputDir}, count ${Object.keys(prevResults).length} files`); results.forEach(r => { const p = prevResults[r.uri.toString()]; @@ -542,12 +541,12 @@ const outputResults = async (date: Date, targetDirUri: vscode.Uri, results: Resu const diffTable = new ResultFormatter(targetDirUri, diffs, conf); if (conf.outputAsText) { - await writeTextFile(buildUri(outputDir, 'results.txt'), resultTable.toTextLines(date)); - await writeTextFile(buildUri(outputDir, 'diff.txt'), diffTable.toTextLines(date)); + await writeTextFile(vscode.Uri.joinPath(outputDir, 'results.txt'), resultTable.toTextLines(date)); + await writeTextFile(vscode.Uri.joinPath(outputDir, 'diff.txt'), diffTable.toTextLines(date)); } if (conf.outputAsCSV) { - await writeTextFile(buildUri(outputDir, 'results.csv'), resultTable.toCSVLines()); - await writeTextFile(buildUri(outputDir, 'diff.csv'), diffTable.toCSVLines()); + await writeTextFile(vscode.Uri.joinPath(outputDir, 'results.csv'), resultTable.toCSVLines()); + await writeTextFile(vscode.Uri.joinPath(outputDir, 'diff.csv'), diffTable.toCSVLines()); } if (conf.outputAsMarkdown) { const mds = [ @@ -557,12 +556,12 @@ const outputResults = async (date: Date, targetDirUri: vscode.Uri, results: Resu { title: 'Diff Details', path: 'diff-details.md', table: diffTable, detail: true }, ]; await Promise.all(mds.map(({ title, path, table, detail }, index) => { - return writeTextFile(buildUri(outputDir, path), table.toMarkdown(date, title, detail, mds.map((f, i) => [f.title, i === index ? undefined : f.path]))); + return writeTextFile(vscode.Uri.joinPath(outputDir, path), table.toMarkdown(date, title, detail, mds.map((f, i) => [f.title, i === index ? undefined : f.path]))); })); } const previewFile = previewFiles.get(conf.outputPreviewType); if (previewFile) { - showTextPreview(buildUri(outputDir, previewFile)); + showTextPreview(vscode.Uri.joinPath(outputDir, previewFile)); } } diff --git a/src/test/runTest.ts b/src/test/runTest.ts new file mode 100644 index 0000000..1eabfa3 --- /dev/null +++ b/src/test/runTest.ts @@ -0,0 +1,23 @@ +import * as path from 'path'; + +import { runTests } from 'vscode-test'; + +async function main() { + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, '../../'); + + // The path to test runner + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, './suite/index'); + + // Download VS Code, unzip it and run the integration test + await runTests({ extensionDevelopmentPath, extensionTestsPath }); + } catch (err) { + console.error('Failed to run tests'); + process.exit(1); + } +} + +main(); diff --git a/src/test/suite/Gitignore.test.ts b/src/test/suite/Gitignore.test.ts new file mode 100644 index 0000000..aa7a4ac --- /dev/null +++ b/src/test/suite/Gitignore.test.ts @@ -0,0 +1,18 @@ +import * as assert from 'assert'; +import * as mocha from 'mocha'; //① + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from 'vscode'; +import Gitignore from '../../Gitignore'; + +mocha.describe('Extension Test Suite', () => { //① + before(() => { + vscode.window.showInformationMessage('Start all tests.'); + }); + + it('Sample test', () => { //① + const g = new Gitignore(`**/logs`); + assert.ok(g.includes('logs/debug.log')); + }); +}); \ No newline at end of file diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts new file mode 100644 index 0000000..d59ba91 --- /dev/null +++ b/src/test/suite/extension.test.ts @@ -0,0 +1,15 @@ +import * as assert from 'assert'; + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from 'vscode'; +// import * as myExtension from '../extension'; + +suite('Extension Test Suite', () => { + vscode.window.showInformationMessage('Start all tests.'); + + test('Sample test', () => { + assert.equal(-1, [1, 2, 3].indexOf(5)); + assert.equal(-1, [1, 2, 3].indexOf(0)); + }); +}); diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts new file mode 100644 index 0000000..b9e2e93 --- /dev/null +++ b/src/test/suite/index.ts @@ -0,0 +1,37 @@ +import * as path from 'path'; +import * as Mocha from 'mocha'; +import * as glob from 'glob'; + +export function run(): Promise { + // Create the mocha test + const mocha = new Mocha({ + ui: 'tdd', + }); + // mocha.useColors(true); + + const testsRoot = path.resolve(__dirname, '..'); + + return new Promise((c, e) => { + glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { + if (err) { + return e(err); + } + + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + + try { + // Run the mocha test + mocha.run(failures => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } else { + c(); + } + }); + } catch (err) { + e(err); + } + }); + }); +} diff --git a/src/vscode-utils.ts b/src/vscode-utils.ts index ed4a923..0e268b0 100644 --- a/src/vscode-utils.ts +++ b/src/vscode-utils.ts @@ -16,15 +16,17 @@ export const currentWorkspaceFolder = async () => { throw Error('workspace not open.'); } -export const buildUri = (uri: vscode.Uri, ...names: string[]) => uri.with({ path: `${uri.path}/${names.join('/')}` }); -export const dirUri = (uri: vscode.Uri) => uri.with({ path: path.dirname(uri.path) }); -export const parseUriOrFile = (uriOrFileath: string, baseUri?: vscode.Uri) => { - const u = vscode.Uri.parse(uriOrFileath); - // log(uriOrFileath, u.toString(), path.isAbsolute(uriOrFileath), baseUri?.toString(), buildUri(baseUri??u, uriOrFileath).fsPath, (!baseUri || path.isAbsolute(uriOrFileath))); - return uriOrFileath.startsWith(u.scheme + ':/') ? u - : (!baseUri || path.isAbsolute(uriOrFileath)) ? vscode.Uri.file(uriOrFileath) - : buildUri(baseUri, uriOrFileath); +export const buildUri = (uri: vscode.Uri, ...uriOrPaths: string[]) => { + return uriOrPaths.reduce((baseUri, uriOrPath) => { + const u = vscode.Uri.parse(uriOrPath); + // log('buildUri', uriOrPath, u.toString(), path.isAbsolute(uriOrPath), baseUri?.toString(), vscode.Uri.joinPath(baseUri??u, uriOrPath).fsPath, (!baseUri || path.isAbsolute(uriOrPath))); + return uriOrPath.startsWith(u.scheme + ':/') ? u + : (!baseUri || path.isAbsolute(uriOrPath)) ? vscode.Uri.file(uriOrPath) + : vscode.Uri.joinPath(baseUri, uriOrPath); + }, uri); } +export const dirUri = (uri: vscode.Uri) => uri.with({ path: path.dirname(uri.path) }); + const decoderU8 = new TextDecoder('utf8'); const encoderU8 = new TextEncoder(); @@ -80,15 +82,14 @@ const vscodeEncodingTable = new Map([ export const createTextDecoder = (vscodeTextEncoding: string) => new TextDecoder(vscodeEncodingTable.get(vscodeTextEncoding) || vscodeTextEncoding); -export const readUtf8File = async (baseUri: vscode.Uri, path?: string): Promise<{ uri: vscode.Uri, data: string, error?: any }> => { - const uri = path ? buildUri(baseUri, path) : baseUri; +export const readUtf8File = async (uri: vscode.Uri): Promise<{ uri: vscode.Uri, data: string, error?: any }> => { try { const bin = await vscode.workspace.fs.readFile(uri); // log(`read ${uri} : ${bin.length}B`); const data = decoderU8.decode(bin); return {uri, data}; } catch (error: any) { - log(`readUtf8File(${baseUri}, ${path}) failed. : ${error}`); + log(`readUtf8File(${uri}) failed. : ${error}`); return { uri, data: '', error }; } } @@ -111,14 +112,14 @@ export const checkJsonType = | return defaultValue; } -export const readJsonFile = async | { [key: string]: any }>(baseUri: vscode.Uri, path: string | undefined, defaultValue: T): Promise => { +export const readJsonFile = async | { [key: string]: any }>(uri: vscode.Uri, defaultValue: T): Promise => { try { - const text = await readUtf8File(baseUri, path); + const text = await readUtf8File(uri); if (text.error) return defaultValue; const json = JSONC.parse(text.data); return checkJsonType(json, defaultValue); } catch (e: any) { - log(`readJsonFile(${baseUri}, ${path}) failed. : ${e}`); + log(`readJsonFile(${uri}) failed. : ${e}`); } return defaultValue; }