Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tolgee/cli

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tolgee/cli - npm Package Compare versions

Comparing version 2.3.4 to 2.4.0

4

dist/commands/push.js
import { extname, join } from 'path';
import { readdir, readFile, stat } from 'fs/promises';
import { Command, Option } from 'commander';
import { glob } from 'tinyglobby';
import { loading, success, error, warn, exitWithError, } from '../utils/logger.js';

@@ -8,6 +9,5 @@ import { askString } from '../utils/ask.js';

import { handleLoadableError } from '../client/TolgeeClient.js';
import { windowsCompatibleGlob } from '../utils/windowsCompatibleGlob.js';
async function allInPattern(pattern) {
const files = [];
const items = await windowsCompatibleGlob(pattern);
const items = await glob(pattern);
for (const item of items) {

@@ -14,0 +14,0 @@ if ((await stat(item)).isDirectory()) {

@@ -31,3 +31,3 @@ import { cosmiconfig, defaultLoaders } from 'cosmiconfig';

if (rc.extractor !== undefined) {
rc.extractor = resolve(configDir, rc.extractor);
rc.extractor = resolve(configDir, rc.extractor).replace(/\\/g, '/');
if (!existsSync(rc.extractor)) {

@@ -39,3 +39,3 @@ throw new Error(`Invalid config: extractor points to a file that does not exists (${rc.extractor})`);

if (rc.patterns !== undefined) {
rc.patterns = rc.patterns.map((pattern) => resolve(configDir, pattern));
rc.patterns = rc.patterns.map((pattern) => resolve(configDir, pattern).replace(/\\/g, '/'));
}

@@ -46,3 +46,3 @@ // convert relative paths in config to absolute

...r,
path: resolve(configDir, r.path),
path: resolve(configDir, r.path).replace(/\\/g, '/'),
}));

@@ -52,3 +52,3 @@ }

if (rc.pull?.path !== undefined) {
rc.pull.path = resolve(configDir, rc.pull.path);
rc.pull.path = resolve(configDir, rc.pull.path).replace(/\\/g, '/');
}

@@ -55,0 +55,0 @@ return rc;

@@ -0,5 +1,5 @@

import { glob } from 'tinyglobby';
import { extname } from 'path';
import { callWorker } from './worker.js';
import { exitWithError } from '../utils/logger.js';
import { windowsCompatibleGlob } from '../utils/windowsCompatibleGlob.js';
export const NullNamespace = Symbol('namespace.null');

@@ -10,8 +10,17 @@ function parseVerbose(v) {

export async function extractKeysFromFile(file, parserType, options, extractor) {
return callWorker({
extractor: extractor,
parserType,
file: file,
options,
});
if (typeof extractor !== 'undefined') {
return callWorker({
extractor,
file,
options,
});
}
else if (typeof parserType !== 'undefined') {
return callWorker({
parserType,
file,
options,
});
}
throw new Error('Internal error: neither the parser type nor a custom extractors have been defined! Please report this.');
}

@@ -58,5 +67,3 @@ export function findPossibleFrameworks(fileNames) {

}
const files = await windowsCompatibleGlob(opts.patterns, {
nodir: true,
});
const files = await glob(opts.patterns, { onlyFiles: true });
if (files.length === 0) {

@@ -66,3 +73,3 @@ exitWithError('No files were matched for extraction');

let parserType = opts.parser;
if (!parserType) {
if (!parserType && !opts.extractor) {
parserType = detectParserType(files);

@@ -69,0 +76,0 @@ }

import { fileURLToPath } from 'url';
import { resolve, extname } from 'path';
import { Worker, isMainThread, parentPort } from 'worker_threads';
import { readFile } from 'fs/promises';
import { extname, resolve } from 'path';
import { isMainThread, parentPort, SHARE_ENV, Worker } from 'worker_threads';
import { readFileSync } from 'fs';
import internalExtractor from './extractor.js';

@@ -9,12 +9,10 @@ import { loadModule } from '../utils/moduleLoader.js';

const FILE_TIME_LIMIT = 60 * 1000; // one minute
const IS_TS_NODE = extname(import.meta.url) === '.ts';
const IS_TSX = extname(import.meta.url) === '.ts';
// --- Worker functions
let loadedExtractor = Symbol('unloaded');
let extractor;
async function handleJob(args) {
const file = resolve(args.file);
const code = await readFile(file, 'utf8');
if (args.extractor) {
if (args.extractor !== loadedExtractor) {
loadedExtractor = args.extractor;
const code = readFileSync(file, 'utf8');
if ('extractor' in args) {
if (!extractor) {
extractor = await loadModule(args.extractor).then((mdl) => mdl.default);

@@ -24,7 +22,5 @@ }

}
else {
return internalExtractor(code, file, args.parserType, args.options);
}
return internalExtractor(code, file, args.parserType, args.options);
}
async function workerInit() {
function workerInit() {
parentPort.on('message', (params) => {

@@ -42,8 +38,14 @@ handleJob(params)

function createWorker() {
const worker = IS_TS_NODE
? new Worker(fileURLToPath(new URL(import.meta.url)).replace('.ts', '.js'), {
// ts-node workaround
execArgv: ['--require', 'ts-node/register'],
})
: new Worker(fileURLToPath(new URL(import.meta.url)));
let worker;
if (IS_TSX) {
worker = new Worker(`import('tsx/esm/api').then(({ register }) => { register(); import('${fileURLToPath(new URL(import.meta.url))}') })`, {
env: SHARE_ENV,
eval: true,
});
}
else {
worker = new Worker(fileURLToPath(new URL(import.meta.url)), {
env: SHARE_ENV,
});
}
let timeout;

@@ -50,0 +52,0 @@ let currentDeferred;

@@ -1,25 +0,17 @@

import { extname } from 'path';
let tsService;
async function registerTsNode() {
if (!tsService) {
// try {
// const tsNode = await import('ts-node');
// tsService = tsNode.register({ compilerOptions: { module: 'CommonJS' } });
// } catch (e: any) {
// if (e.code === 'ERR_MODULE_NOT_FOUND') {
// throw new Error('ts-node is required to load TypeScript files.');
// }
// throw e;
// }
}
}
import { pathToFileURL } from 'url';
let jiti;
// https://github.com/eslint/eslint/blob/6f37b0747a14dfa9a9e3bdebc5caed1f39b6b0e2/lib/config/config-loader.js#L164-L197
async function importTypeScript(file) {
if (extname(import.meta.url) === '.ts') {
// @ts-ignore
if (!!globalThis.Bun || !!globalThis.Deno) {
// We're in an env that natively supports TS
return import(file);
}
await registerTsNode();
tsService.enabled(true);
const mdl = await import(file);
tsService.enabled(false);
return mdl;
if (!jiti) {
const { createJiti } = await import('jiti').catch(() => {
throw new Error("The 'jiti' library is required for loading TypeScript extractors. Make sure to install it.");
});
jiti = createJiti(import.meta.url);
}
return jiti.import(file);
}

@@ -30,3 +22,4 @@ export async function loadModule(module) {

}
const mdl = await import(module);
const fileUrl = pathToFileURL(module);
const mdl = await import(fileUrl.href);
if (mdl.default?.default) {

@@ -33,0 +26,0 @@ return mdl.default;

{
"name": "@tolgee/cli",
"version": "2.3.4",
"version": "2.4.0",
"type": "module",

@@ -37,37 +37,46 @@ "description": "A tool to interact with the Tolgee Platform through CLI",

"cosmiconfig": "^9.0.0",
"glob": "^11.0.0",
"json5": "^2.2.3",
"jsonschema": "^1.4.1",
"openapi-fetch": "^0.10.6",
"openapi-fetch": "0.13.1",
"tinyglobby": "^0.2.10",
"unescape-js": "^1.1.4",
"vscode-oniguruma": "^2.0.1",
"vscode-textmate": "^9.1.0",
"yauzl": "^3.1.3"
"yauzl": "^3.2.0"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
"@eslint/js": "^9.16.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@tsconfig/node18": "^18.2.4",
"@tsconfig/recommended": "^1.0.7",
"@tsconfig/recommended": "^1.0.8",
"@types/eslint__js": "^8.42.3",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.1.0",
"@types/node": "^22.10.1",
"@types/yauzl": "^2.10.3",
"cross-env": "^7.0.3",
"eslint": "^9.8.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jiti": "^2.4.1",
"js-yaml": "^4.1.0",
"json-schema-to-typescript": "^15.0.0",
"openapi-typescript": "^7.3.0",
"json-schema-to-typescript": "^15.0.3",
"openapi-typescript": "^7.4.4",
"premove": "^4.0.0",
"prettier": "^3.3.3",
"semantic-release": "^24.0.0",
"prettier": "^3.4.1",
"semantic-release": "^24.2.0",
"tree-cli": "^0.6.7",
"tsx": "^4.17.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.1",
"vitest": "^2.0.5"
"tsx": "^4.19.2",
"typescript": "~5.6.3",
"typescript-eslint": "^8.17.0",
"vitest": "^2.1.8"
},
"peerDependencies": {
"jiti": ">= 2"
},
"peerDependenciesMeta": {
"jiti": {
"optional": true
}
},
"engines": {

@@ -74,0 +83,0 @@ "node": ">= 18"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc