latinfo 0.13.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +68 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const local_search_1 = require("./local-search");
47
47
  const client_search_1 = require("./client-search");
48
48
  const odis_search_1 = require("./odis-search");
49
49
  const mphf_search_1 = require("./mphf-search");
50
- const VERSION = '0.13.2';
50
+ const VERSION = '0.14.0';
51
51
  const API_URL = process.env.LATINFO_API_URL || 'https://api.latinfo.dev';
52
52
  const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID || 'Ov23li5fcQaiCsVtaMKK';
53
53
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.latinfo');
@@ -1724,9 +1724,16 @@ async function pipeScript(args) {
1724
1724
  console.log(`[pipe] Gates reset — run: latinfo pipe test ${sourceName}`);
1725
1725
  }
1726
1726
  async function pipeDeps(args) {
1727
- const [sourceName, ...deps] = args;
1727
+ const isPython = args.includes('--python');
1728
+ const filtered = args.filter(a => a !== '--python');
1729
+ const [sourceName, ...deps] = filtered;
1728
1730
  if (!sourceName || deps.length === 0) {
1729
- console.error('Usage: latinfo pipe deps <source-name> <pkg1> [pkg2] ...');
1731
+ console.error(`Usage: latinfo pipe deps <source-name> <pkg1> [pkg2] ...
1732
+ latinfo pipe deps <source-name> --python <pkg1> [pkg2] ...
1733
+
1734
+ Examples:
1735
+ latinfo pipe deps pe-redam-registry playwright # npm package
1736
+ latinfo pipe deps pe-redam-registry --python ddddocr # Python package (pip3)`);
1730
1737
  process.exit(1);
1731
1738
  }
1732
1739
  const repo = getRepoPath();
@@ -1735,26 +1742,37 @@ async function pipeDeps(args) {
1735
1742
  console.error(`Source not found: ${yamlPath}`);
1736
1743
  process.exit(1);
1737
1744
  }
1738
- // Add dependencies to YAML
1739
1745
  let yaml = fs_1.default.readFileSync(yamlPath, 'utf-8');
1740
- if (yaml.includes('dependencies:')) {
1741
- // Replace existing deps
1742
- yaml = yaml.replace(/dependencies:[\s\S]*?(?=\n\w|\n$|$)/, `dependencies:\n${deps.map(d => ` - ${d}`).join('\n')}\n`);
1746
+ const key = isPython ? 'python_dependencies' : 'dependencies';
1747
+ if (yaml.includes(`${key}:`)) {
1748
+ yaml = yaml.replace(new RegExp(`${key}:[\\s\\S]*?(?=\\n\\w|\\n$|$)`), `${key}:\n${deps.map(d => ` - ${d}`).join('\n')}\n`);
1743
1749
  }
1744
1750
  else {
1745
- yaml += `\ndependencies:\n${deps.map(d => ` - ${d}`).join('\n')}\n`;
1751
+ yaml += `\n${key}:\n${deps.map(d => ` - ${d}`).join('\n')}\n`;
1746
1752
  }
1747
1753
  fs_1.default.writeFileSync(yamlPath, yaml);
1748
- // Install deps in repo
1749
- console.log(`[pipe] Installing: ${deps.join(', ')}...`);
1750
1754
  const { execSync: run } = await Promise.resolve().then(() => __importStar(require('child_process')));
1751
- try {
1752
- run(`npm install ${deps.join(' ')}`, { cwd: repo, stdio: 'inherit' });
1753
- console.log(`[pipe] Dependencies installed and added to YAML.`);
1755
+ if (isPython) {
1756
+ console.log(`[pipe] Installing Python: ${deps.join(', ')}...`);
1757
+ try {
1758
+ run(`pip3 install ${deps.join(' ')}`, { cwd: repo, stdio: 'inherit' });
1759
+ console.log(`[pipe] Python dependencies installed and added to YAML.`);
1760
+ }
1761
+ catch {
1762
+ console.error(`[pipe] Failed to install Python dependencies.`);
1763
+ process.exit(1);
1764
+ }
1754
1765
  }
1755
- catch {
1756
- console.error(`[pipe] Failed to install dependencies.`);
1757
- process.exit(1);
1766
+ else {
1767
+ console.log(`[pipe] Installing npm: ${deps.join(', ')}...`);
1768
+ try {
1769
+ run(`npm install ${deps.join(' ')}`, { cwd: repo, stdio: 'inherit' });
1770
+ console.log(`[pipe] npm dependencies installed and added to YAML.`);
1771
+ }
1772
+ catch {
1773
+ console.error(`[pipe] Failed to install npm dependencies.`);
1774
+ process.exit(1);
1775
+ }
1758
1776
  }
1759
1777
  }
1760
1778
  async function pipeTest(args) {
@@ -1774,17 +1792,28 @@ async function pipeTest(args) {
1774
1792
  const errors = [];
1775
1793
  // Install deps from YAML if present
1776
1794
  const yamlContent = fs_1.default.readFileSync(yamlPath, 'utf-8');
1777
- const depsMatch = yamlContent.match(/dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1795
+ const depsMatch = yamlContent.match(/^dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/m);
1778
1796
  if (depsMatch) {
1779
1797
  const deps = depsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1780
1798
  if (deps.length > 0) {
1781
- console.log(`[pipe] Installing dependencies: ${deps.join(', ')}...`);
1799
+ console.log(`[pipe] Installing npm deps: ${deps.join(', ')}...`);
1782
1800
  try {
1783
1801
  run(`npm install ${deps.join(' ')}`, { cwd: repo, stdio: 'pipe' });
1784
1802
  }
1785
1803
  catch { }
1786
1804
  }
1787
1805
  }
1806
+ const pyDepsMatch = yamlContent.match(/python_dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1807
+ if (pyDepsMatch) {
1808
+ const pyDeps = pyDepsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1809
+ if (pyDeps.length > 0) {
1810
+ console.log(`[pipe] Installing Python deps: ${pyDeps.join(', ')}...`);
1811
+ try {
1812
+ run(`pip3 install ${pyDeps.join(' ')}`, { cwd: repo, stdio: 'pipe' });
1813
+ }
1814
+ catch { }
1815
+ }
1816
+ }
1788
1817
  // Run import with --limit 100
1789
1818
  // Check YAML for custom import_script path
1790
1819
  const importScriptMatch = yamlContent.match(/import_script:\s*(.+)/);
@@ -1899,7 +1928,7 @@ async function pipeStage(args) {
1899
1928
  const remoteRepo = '~/actions-runner/_work/latinfo-api/latinfo-api';
1900
1929
  console.log('[pipe] Syncing files to Linux Mint...');
1901
1930
  try {
1902
- run(`ssh ${RUNNER} "echo OK"`, { stdio: 'pipe', timeout: 10_000 });
1931
+ run(`ssh -o ConnectTimeout=10 ${RUNNER} "echo OK"`, { stdio: 'pipe' });
1903
1932
  // Copy import script and YAML
1904
1933
  const scriptFile = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
1905
1934
  const yamlFile = path_1.default.join(repo, 'sources', `${sourceName}.yaml`);
@@ -1932,11 +1961,11 @@ async function pipeStage(args) {
1932
1961
  if (deps.length > 0) {
1933
1962
  console.log(`[pipe] Installing deps on Linux Mint: ${deps.join(', ')}...`);
1934
1963
  try {
1935
- run(`ssh ${RUNNER} "cd ${remoteRepo} && npm install ${deps.join(' ')}"`, { stdio: 'inherit', timeout: 120_000 });
1964
+ run(`ssh ${RUNNER} "cd ${remoteRepo} && npm install ${deps.join(' ')}"`, { stdio: 'inherit' });
1936
1965
  // Install playwright browsers if needed
1937
1966
  if (deps.some(d => d.includes('playwright'))) {
1938
- console.log(`[pipe] Installing Playwright browser...`);
1939
- run(`ssh ${RUNNER} "cd ${remoteRepo} && npx playwright install chromium --with-deps"`, { stdio: 'inherit', timeout: 120_000 });
1967
+ console.log(`[pipe] Installing Playwright browser (this may take a few minutes)...`);
1968
+ run(`ssh ${RUNNER} "cd ${remoteRepo} && npx playwright install chromium --with-deps"`, { stdio: 'inherit' });
1940
1969
  }
1941
1970
  }
1942
1971
  catch {
@@ -1945,11 +1974,26 @@ async function pipeStage(args) {
1945
1974
  }
1946
1975
  }
1947
1976
  }
1977
+ // 3b. Install Python deps on Linux Mint
1978
+ const pyDepsMatch = yamlContent.match(/python_dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1979
+ if (pyDepsMatch) {
1980
+ const pyDeps = pyDepsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1981
+ if (pyDeps.length > 0) {
1982
+ console.log(`[pipe] Installing Python deps on Linux Mint: ${pyDeps.join(', ')}...`);
1983
+ try {
1984
+ run(`ssh ${RUNNER} "pip3 install ${pyDeps.join(' ')}"`, { stdio: 'inherit' });
1985
+ }
1986
+ catch {
1987
+ console.error('[pipe] Failed to install Python deps on Linux Mint');
1988
+ process.exit(1);
1989
+ }
1990
+ }
1991
+ }
1948
1992
  // 4. Run import on Linux Mint
1949
1993
  console.log(`[pipe] Running import on Linux Mint...`);
1950
1994
  try {
1951
1995
  run(`ssh ${RUNNER} "cd ${remoteRepo} && set -a && source .env 2>/dev/null; source .dev.vars 2>/dev/null; set +a && R2_BUCKET_NAME=latinfo-data npx tsx src/imports/${sourceName}.ts"`, {
1952
- stdio: 'inherit', timeout: 600_000,
1996
+ stdio: 'inherit',
1953
1997
  });
1954
1998
  }
1955
1999
  catch {
@@ -1977,7 +2021,7 @@ Promise.all(Array.from({length:CONC},()=>go())).then(()=>{
1977
2021
  lats.sort((a,b)=>a-b);
1978
2022
  console.log(JSON.stringify({total_ms:Date.now()-t0,success,fails,qps:Math.round(TOTAL/((Date.now()-t0)/1000)),
1979
2023
  p50:lats[Math.floor(lats.length*0.5)],p95:lats[Math.floor(lats.length*0.95)],p99:lats[Math.floor(lats.length*0.99)]}));
1980
- });\\"" `, { encoding: 'utf-8', stdio: 'pipe', timeout: 60_000 });
2024
+ });\\"" `, { encoding: 'utf-8', stdio: 'pipe' });
1981
2025
  const bench = JSON.parse(benchOutput.trim());
1982
2026
  const successRate = ((bench.success) / 500 * 100);
1983
2027
  console.log(`\n 500 concurrent: ${bench.qps} q/s, ${successRate.toFixed(1)}% success`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "Tax registry & procurement API for Latin America. Query RUC, DNI, NIT, licitaciones from Peru & Colombia. Offline MPHF search, full OCDS data, updated daily.",
5
5
  "homepage": "https://latinfo.dev",
6
6
  "repository": {