latinfo 0.13.5 → 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 +62 -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.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*(.+)/);
@@ -1945,6 +1974,21 @@ 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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.13.5",
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": {