Skip to content

Commit

Permalink
Cleanup dependencies (#195026)
Browse files Browse the repository at this point in the history
* move build dependencies to devDependencies

* build: bump tree-sitter

* dependencies cleanup

* remove leftover file
  • Loading branch information
joaomoreno authored Oct 9, 2023
1 parent 55d1cfe commit a5d71aa
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 908 deletions.
17 changes: 12 additions & 5 deletions build/lib/electron.js

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions build/lib/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as vfs from 'vinyl-fs';
import * as filter from 'gulp-filter';
import * as _ from 'underscore';
import * as util from './util';
import { getVersion } from './getVersion';

Expand All @@ -29,7 +28,15 @@ const root = path.dirname(path.dirname(__dirname));
const product = JSON.parse(fs.readFileSync(path.join(root, 'product.json'), 'utf8'));
const commit = getVersion(root);

const darwinCreditsTemplate = product.darwinCredits && _.template(fs.readFileSync(path.join(root, product.darwinCredits), 'utf8'));
function createTemplate(input: string): (params: Record<string, string>) => string {
return (params: Record<string, string>) => {
return input.replace(/<%=\s*([^\s]+)\s*%>/g, (match, key) => {
return params[key] || match;
});
};
}

const darwinCreditsTemplate = product.darwinCredits && createTemplate(fs.readFileSync(path.join(root, product.darwinCredits), 'utf8'));

/**
* Generate a `DarwinDocumentType` given a list of file extensions, an icon name, and an optional suffix or file type name.
Expand Down Expand Up @@ -201,12 +208,13 @@ function getElectron(arch: string): () => NodeJS.ReadWriteStream {
const electron = require('@vscode/gulp-electron');
const json = require('gulp-json-editor') as typeof import('gulp-json-editor');

const electronOpts = _.extend({}, config, {
const electronOpts = {
...config,
platform: process.platform,
arch: arch === 'armhf' ? 'arm' : arch,
ffmpegChromium: false,
keepDefaultApp: true
});
};

return vfs.src('package.json')
.pipe(json({ name: product.nameShort }))
Expand Down
13 changes: 6 additions & 7 deletions build/lib/i18n.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions build/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as fs from 'fs';
import { map, merge, through, ThroughStream } from 'event-stream';
import * as jsonMerge from 'gulp-merge-json';
import * as File from 'vinyl';
import * as Is from 'is';
import * as xml2js from 'xml2js';
import * as gulp from 'gulp';
import * as fancyLog from 'fancy-log';
Expand Down Expand Up @@ -69,7 +68,7 @@ interface LocalizeInfo {
module LocalizeInfo {
export function is(value: any): value is LocalizeInfo {
const candidate = value as LocalizeInfo;
return Is.defined(candidate) && Is.string(candidate.key) && (Is.undef(candidate.comment) || (Is.array(candidate.comment) && candidate.comment.every(element => Is.string(element))));
return candidate && typeof candidate.key === 'string' && (candidate.comment === undefined || (Array.isArray(candidate.comment) && candidate.comment.every(element => typeof element === 'string')));
}
}

Expand All @@ -81,14 +80,14 @@ interface BundledFormat {

module BundledFormat {
export function is(value: any): value is BundledFormat {
if (Is.undef(value)) {
if (value === undefined) {
return false;
}

const candidate = value as BundledFormat;
const length = Object.keys(value).length;

return length === 3 && Is.defined(candidate.keys) && Is.defined(candidate.messages) && Is.defined(candidate.bundles);
return length === 3 && !!candidate.keys && !!candidate.messages && !!candidate.bundles;
}
}

Expand Down Expand Up @@ -183,7 +182,7 @@ export class XLF {
const key = keys[i];
let realKey: string | undefined;
let comment: string | undefined;
if (Is.string(key)) {
if (typeof key === 'string') {
realKey = key;
comment = undefined;
} else if (LocalizeInfo.is(key)) {
Expand Down Expand Up @@ -474,7 +473,7 @@ function processCoreBundleFormat(fileHeader: string, languages: Language[], json
});
sortedLanguages.forEach(language => {
const stats = statistics[language.id];
if (Is.undef(stats)) {
if (!stats) {
log(`\tNo translations found for language ${language.id}. Using default language instead.`);
}
});
Expand Down
11 changes: 0 additions & 11 deletions build/lib/typings/is.d.ts

This file was deleted.

13 changes: 4 additions & 9 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
"@types/mkdirp": "^1.0.1",
"@types/mocha": "^9.1.1",
"@types/node": "18.x",
"@types/p-limit": "^2.2.0",
"@types/pump": "^1.0.1",
"@types/rimraf": "^2.0.4",
"@types/through": "^0.0.29",
"@types/through2": "^2.0.36",
"@types/tmp": "^0.2.1",
"@types/underscore": "^1.8.9",
"@types/workerpool": "^6.4.0",
"@types/xml2js": "0.0.33",
"@vscode/iconv-lite-umd": "0.7.0",
Expand All @@ -53,24 +51,21 @@
"mime": "^1.4.1",
"mkdirp": "^1.0.4",
"node-fetch": "2",
"p-limit": "^3.1.0",
"source-map": "0.6.1",
"ternary-stream": "^3.0.0",
"through2": "^4.0.2",
"tmp": "^0.2.1",
"vscode-universal-bundler": "^0.0.2"
"vscode-universal-bundler": "^0.0.2",
"workerpool": "^6.4.0"
},
"scripts": {
"compile": "../node_modules/.bin/tsc -p tsconfig.build.json",
"watch": "../node_modules/.bin/tsc -p tsconfig.build.json --watch",
"npmCheckJs": "../node_modules/.bin/tsc --noEmit"
},
"optionalDependencies": {
"tree-sitter": "https://github.com/joaomoreno/node-tree-sitter/releases/download/v0.20.0/tree-sitter-0.20.0.tgz",
"tree-sitter-typescript": "^0.20.1",
"tree-sitter": "^0.20.5",
"tree-sitter-typescript": "^0.20.3",
"vscode-gulp-watch": "^5.0.3"
},
"dependencies": {
"workerpool": "^6.4.0"
}
}
Loading

0 comments on commit a5d71aa

Please sign in to comment.