-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from TNG/add-formatting-and-linting-for-types…
…cript Add formatting and linting for typescript
- Loading branch information
Showing
123 changed files
with
14,062 additions
and
11,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Lint TS | ||
on: [push, pull_request] | ||
jobs: | ||
lint-ts: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./WebUI | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npm run lint:ci | ||
- run: npm run format:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}] | ||
charset = utf-8 | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
end_of_line = lf | ||
max_line_length = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
// Usage: node check-i18n.js --i18n-dir=$DIR | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
const fs = require('fs') | ||
const path = require('path') | ||
const argv = require('minimist')(process.argv.slice(2)) | ||
|
||
const i18nDirArg = argv.i18n_dir; | ||
const i18nDirArg = argv.i18n_dir | ||
if (!i18nDirArg) { | ||
console.error('Usage: node check-i18n.js --i18n-dir=$DIR\n'); | ||
process.exit(1); | ||
console.error('Usage: node check-i18n.js --i18n-dir=$DIR\n') | ||
process.exit(1) | ||
} | ||
|
||
const i18nDir = path.resolve(i18nDirArg); | ||
const enData = JSON.parse(fs.readFileSync(path.join(i18nDir, 'en-US.json'))); | ||
const keys = Object.keys(enData); | ||
const i18nDir = path.resolve(i18nDirArg) | ||
const enData = JSON.parse(fs.readFileSync(path.join(i18nDir, 'en-US.json'))) | ||
const keys = Object.keys(enData) | ||
|
||
const langs = fs.readdirSync(i18nDir).filter(f => f.endsWith('.json')); | ||
const missingKeys = {}; | ||
const unusedKeys = {}; | ||
const langs = fs.readdirSync(i18nDir).filter((f) => f.endsWith('.json')) | ||
const missingKeys = {} | ||
const unusedKeys = {} | ||
|
||
langs.forEach(lang => { | ||
const data = JSON.parse(fs.readFileSync(path.join(i18nDir, lang))); | ||
keys.forEach(key => { | ||
if (!data[key]) { | ||
if (!missingKeys[lang]) { | ||
missingKeys[lang] = []; | ||
} | ||
missingKeys[lang].push(key); | ||
} | ||
}); | ||
|
||
Object.keys(data).forEach(key => { | ||
if (!keys.includes(key)) { | ||
if (!unusedKeys[lang]) { | ||
unusedKeys[lang] = []; | ||
} | ||
unusedKeys[lang].push(key); | ||
} | ||
}); | ||
langs.forEach((lang) => { | ||
const data = JSON.parse(fs.readFileSync(path.join(i18nDir, lang))) | ||
keys.forEach((key) => { | ||
if (!data[key]) { | ||
if (!missingKeys[lang]) { | ||
missingKeys[lang] = [] | ||
} | ||
missingKeys[lang].push(key) | ||
} | ||
}) | ||
|
||
if (missingKeys[lang]) { | ||
// print pretty | ||
// 5 entries per row | ||
const entriesPerRow = 5; | ||
const entries = missingKeys[lang]; | ||
const rows = []; | ||
for (let i = 0; i < entries.length; i += entriesPerRow) { | ||
rows.push(entries.slice(i, i + entriesPerRow).join(', ')); | ||
} | ||
console.log(`${missingKeys[lang].length} missing keys for ${lang}:`); | ||
console.log(` ${rows.join('\n ')}`); | ||
console.log(); | ||
Object.keys(data).forEach((key) => { | ||
if (!keys.includes(key)) { | ||
if (!unusedKeys[lang]) { | ||
unusedKeys[lang] = [] | ||
} | ||
unusedKeys[lang].push(key) | ||
} | ||
if (unusedKeys[lang]) { | ||
console.log(`${unusedKeys[lang].length} unused keys for ${lang}:`); | ||
console.log(` ${unusedKeys[lang].join(', ')}`); | ||
console.log(); | ||
}) | ||
|
||
if (missingKeys[lang]) { | ||
// print pretty | ||
// 5 entries per row | ||
const entriesPerRow = 5 | ||
const entries = missingKeys[lang] | ||
const rows = [] | ||
for (let i = 0; i < entries.length; i += entriesPerRow) { | ||
rows.push(entries.slice(i, i + entriesPerRow).join(', ')) | ||
} | ||
}); | ||
console.log(`${missingKeys[lang].length} missing keys for ${lang}:`) | ||
console.log(` ${rows.join('\n ')}`) | ||
console.log() | ||
} | ||
if (unusedKeys[lang]) { | ||
console.log(`${unusedKeys[lang].length} unused keys for ${lang}:`) | ||
console.log(` ${unusedKeys[lang].join(', ')}`) | ||
console.log() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
// Usage: node fetch-python-package-resources.js --target-dir=$DIR --conda_env_dir=$DIR | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { HttpsProxyAgent } = require('https-proxy-agent'); | ||
const https = require('https') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const { HttpsProxyAgent } = require('https-proxy-agent') | ||
|
||
|
||
const argv = require('minimist')(process.argv.slice(2)); | ||
const argv = require('minimist')(process.argv.slice(2)) | ||
const targetDirArg = argv.target_dir | ||
const condaEnvDirArg = argv.conda_env_dir | ||
|
||
if (!targetDirArg || !condaEnvDirArg) { | ||
console.error('Usage: node fetch-python-package-resources.js --target_dir=$DIR --conda_env_dir=$DIR\n'); | ||
process.exit(1); | ||
console.error( | ||
'Usage: node fetch-python-package-resources.js --target_dir=$DIR --conda_env_dir=$DIR\n', | ||
) | ||
process.exit(1) | ||
} | ||
|
||
const targetDir = path.resolve(targetDirArg); | ||
const targetDir = path.resolve(targetDirArg) | ||
const condaTargetDir = path.join(targetDir, 'conda-env-lib') | ||
const condaEnvLibraryDir = path.resolve(path.join(condaEnvDirArg, 'Library')); | ||
const condaEnvLibraryDir = path.resolve(path.join(condaEnvDirArg, 'Library')) | ||
|
||
const embeddablePythonUrl = 'https://raw.githubusercontent.com/adang1345/PythonWindows/master/3.11.10/python-3.11.10-embed-amd64.zip'; | ||
const embeddablePythonUrl = | ||
'https://raw.githubusercontent.com/adang1345/PythonWindows/master/3.11.10/python-3.11.10-embed-amd64.zip' | ||
const getPipScriptUrl = 'https://bootstrap.pypa.io/get-pip.py' | ||
const sevenZrExeUrl = 'https://www.7-zip.org/a/7zr.exe' | ||
|
||
function fetchFileIfNotPresent(url) { | ||
const expectedFilePath = path.join(targetDir, getBaseFileName(url)) | ||
if (fs.existsSync(expectedFilePath)) { | ||
console.log(`omitting fetching of ${url} as ${expectedFilePath} already exists`) | ||
} else { | ||
fetchFile(url) | ||
} | ||
const expectedFilePath = path.join(targetDir, getBaseFileName(url)) | ||
if (fs.existsSync(expectedFilePath)) { | ||
console.log(`omitting fetching of ${url} as ${expectedFilePath} already exists`) | ||
} else { | ||
fetchFile(url) | ||
} | ||
} | ||
|
||
function fetchFile(url) { | ||
const proxy = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy; | ||
const options = proxy ? { agent: new HttpsProxyAgent(proxy) } : {}; | ||
https.get(url, options, (response) => { | ||
const filePath = path.join(targetDir, getBaseFileName(url)) | ||
const file = fs.createWriteStream(filePath); | ||
response.pipe(file); | ||
const proxy = | ||
process.env.HTTPS_PROXY || | ||
process.env.https_proxy || | ||
process.env.HTTP_PROXY || | ||
process.env.http_proxy | ||
const options = proxy ? { agent: new HttpsProxyAgent(proxy) } : {} | ||
https | ||
.get(url, options, (response) => { | ||
const filePath = path.join(targetDir, getBaseFileName(url)) | ||
const file = fs.createWriteStream(filePath) | ||
response.pipe(file) | ||
|
||
file.on('finish', () => { | ||
file.close(); | ||
console.log(`Downloaded ${filePath} successfully!`); | ||
}); | ||
}).on('error', (err) => { | ||
console.error(`Error downloading ${embeddablePythonUrl}: ${err}`); | ||
}); | ||
file.on('finish', () => { | ||
file.close() | ||
console.log(`Downloaded ${filePath} successfully!`) | ||
}) | ||
}) | ||
.on('error', (err) => { | ||
console.error(`Error downloading ${embeddablePythonUrl}: ${err}`) | ||
}) | ||
} | ||
|
||
|
||
function getBaseFileName(url) { | ||
const urlPathSegments = url.split('/'); | ||
const baseFileName = urlPathSegments[urlPathSegments.length - 1] | ||
return baseFileName; | ||
const urlPathSegments = url.split('/') | ||
const baseFileName = urlPathSegments[urlPathSegments.length - 1] | ||
return baseFileName | ||
} | ||
|
||
function prepareTargetPath() { | ||
if (!fs.existsSync(condaTargetDir)) { | ||
fs.mkdirSync(targetDir, { recursive: true }); | ||
} | ||
if (!fs.existsSync(condaTargetDir)) { | ||
fs.mkdirSync(targetDir, { recursive: true }) | ||
} | ||
} | ||
|
||
function copyLibuvDllsIfNotPresent() { | ||
if (fs.existsSync(path.join(condaTargetDir, 'Library', 'bin', 'uv.dll'))) { | ||
console.log(`omitting fetching copying of libuv DLLs, as they already exist`) | ||
} else { | ||
if (!path.join(condaEnvLibraryDir, 'bin', 'uv.dll')) { | ||
console.log(`provided conda env at ${condaEnvLibraryDir} is missing uv.dll. Aborting`) | ||
process.exit(1); | ||
} | ||
fs.cp(condaEnvLibraryDir, path.join(condaTargetDir, 'Library'), { recursive: true }, (err) => { | ||
if (err) { | ||
console.error(err); | ||
console.log('Failed to copy directory'); | ||
process.exit(1) | ||
} else { | ||
console.log('Directory copied successfully'); | ||
} | ||
}); | ||
if (fs.existsSync(path.join(condaTargetDir, 'Library', 'bin', 'uv.dll'))) { | ||
console.log(`omitting fetching copying of libuv DLLs, as they already exist`) | ||
} else { | ||
if (!path.join(condaEnvLibraryDir, 'bin', 'uv.dll')) { | ||
console.log(`provided conda env at ${condaEnvLibraryDir} is missing uv.dll. Aborting`) | ||
process.exit(1) | ||
} | ||
fs.cp(condaEnvLibraryDir, path.join(condaTargetDir, 'Library'), { recursive: true }, (err) => { | ||
if (err) { | ||
console.error(err) | ||
console.log('Failed to copy directory') | ||
process.exit(1) | ||
} else { | ||
console.log('Directory copied successfully') | ||
} | ||
}) | ||
} | ||
} | ||
|
||
|
||
function main() { | ||
prepareTargetPath() | ||
fetchFileIfNotPresent(embeddablePythonUrl) | ||
fetchFileIfNotPresent(getPipScriptUrl) | ||
fetchFileIfNotPresent(sevenZrExeUrl) | ||
copyLibuvDllsIfNotPresent() | ||
prepareTargetPath() | ||
fetchFileIfNotPresent(embeddablePythonUrl) | ||
fetchFileIfNotPresent(getPipScriptUrl) | ||
fetchFileIfNotPresent(sevenZrExeUrl) | ||
copyLibuvDllsIfNotPresent() | ||
} | ||
|
||
main() |
Oops, something went wrong.