latinfo 0.13.5 → 0.14.1

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 +56 -18
  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.5';
50
+ const VERSION = '0.14.1';
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,30 @@ 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] Python deps added to YAML: ${deps.join(', ')}`);
1757
+ console.log(`[pipe] Will be installed on Linux Mint during pipe stage.`);
1754
1758
  }
1755
- catch {
1756
- console.error(`[pipe] Failed to install dependencies.`);
1757
- process.exit(1);
1759
+ else {
1760
+ console.log(`[pipe] Installing npm: ${deps.join(', ')}...`);
1761
+ try {
1762
+ run(`npm install ${deps.join(' ')}`, { cwd: repo, stdio: 'inherit' });
1763
+ console.log(`[pipe] npm dependencies installed and added to YAML.`);
1764
+ }
1765
+ catch {
1766
+ console.error(`[pipe] Failed to install npm dependencies.`);
1767
+ process.exit(1);
1768
+ }
1758
1769
  }
1759
1770
  }
1760
1771
  async function pipeTest(args) {
@@ -1774,17 +1785,29 @@ async function pipeTest(args) {
1774
1785
  const errors = [];
1775
1786
  // Install deps from YAML if present
1776
1787
  const yamlContent = fs_1.default.readFileSync(yamlPath, 'utf-8');
1777
- const depsMatch = yamlContent.match(/dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1788
+ const depsMatch = yamlContent.match(/^dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/m);
1778
1789
  if (depsMatch) {
1779
1790
  const deps = depsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1780
1791
  if (deps.length > 0) {
1781
- console.log(`[pipe] Installing dependencies: ${deps.join(', ')}...`);
1792
+ console.log(`[pipe] Installing npm deps: ${deps.join(', ')}...`);
1782
1793
  try {
1783
1794
  run(`npm install ${deps.join(' ')}`, { cwd: repo, stdio: 'pipe' });
1784
1795
  }
1785
1796
  catch { }
1786
1797
  }
1787
1798
  }
1799
+ const pyDepsMatch = yamlContent.match(/python_dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1800
+ if (pyDepsMatch) {
1801
+ const pyDeps = pyDepsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1802
+ if (pyDeps.length > 0) {
1803
+ console.log(`[pipe] Python deps: ${pyDeps.join(', ')} (installed on Linux Mint during stage)`);
1804
+ // Try local install but don't fail if it can't (Mac blocks pip)
1805
+ try {
1806
+ run(`pip3 install --user ${pyDeps.join(' ')} 2>/dev/null`, { cwd: repo, stdio: 'pipe' });
1807
+ }
1808
+ catch { }
1809
+ }
1810
+ }
1788
1811
  // Run import with --limit 100
1789
1812
  // Check YAML for custom import_script path
1790
1813
  const importScriptMatch = yamlContent.match(/import_script:\s*(.+)/);
@@ -1945,6 +1968,21 @@ async function pipeStage(args) {
1945
1968
  }
1946
1969
  }
1947
1970
  }
1971
+ // 3b. Install Python deps on Linux Mint
1972
+ const pyDepsMatch = yamlContent.match(/python_dependencies:\n([\s\S]*?)(?=\n\w|\n$|$)/);
1973
+ if (pyDepsMatch) {
1974
+ const pyDeps = pyDepsMatch[1].split('\n').map(l => l.replace(/^\s*-\s*/, '').trim()).filter(Boolean);
1975
+ if (pyDeps.length > 0) {
1976
+ console.log(`[pipe] Installing Python deps on Linux Mint: ${pyDeps.join(', ')}...`);
1977
+ try {
1978
+ run(`ssh ${RUNNER} "pip3 install ${pyDeps.join(' ')}"`, { stdio: 'inherit' });
1979
+ }
1980
+ catch {
1981
+ console.error('[pipe] Failed to install Python deps on Linux Mint');
1982
+ process.exit(1);
1983
+ }
1984
+ }
1985
+ }
1948
1986
  // 4. Run import on Linux Mint
1949
1987
  console.log(`[pipe] Running import on Linux Mint...`);
1950
1988
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.13.5",
3
+ "version": "0.14.1",
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": {