latinfo 0.13.0 → 0.13.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 +42 -19
  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.0';
50
+ const VERSION = '0.13.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');
@@ -1786,12 +1786,16 @@ async function pipeTest(args) {
1786
1786
  }
1787
1787
  }
1788
1788
  // Run import with --limit 100
1789
- const scriptPath = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
1789
+ // Check YAML for custom import_script path
1790
+ const importScriptMatch = yamlContent.match(/import_script:\s*(.+)/);
1791
+ const customScript = importScriptMatch ? path_1.default.join(repo, importScriptMatch[1].trim()) : null;
1792
+ const defaultScript = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
1793
+ const scriptPath = customScript && fs_1.default.existsSync(customScript) ? customScript
1794
+ : fs_1.default.existsSync(defaultScript) ? defaultScript : null;
1790
1795
  const easypipePath = path_1.default.join(repo, 'src', 'imports', 'easypipe.ts');
1791
- const useEasypipe = !fs_1.default.existsSync(scriptPath);
1792
- const cmd = useEasypipe
1793
- ? `npx tsx ${easypipePath} ${yamlPath} --limit 100 --local`
1794
- : `npx tsx ${scriptPath} --limit 100 --local`;
1796
+ const cmd = scriptPath
1797
+ ? `npx tsx ${scriptPath} --limit 100 --local`
1798
+ : `npx tsx ${easypipePath} ${yamlPath} --limit 100 --local`;
1795
1799
  console.log(`[pipe] Gate 1: TEST (100 records)\n`);
1796
1800
  console.log(`Running: ${cmd}\n`);
1797
1801
  let output = '';
@@ -1852,12 +1856,17 @@ async function pipeValidate(args) {
1852
1856
  requireGate(status, 'test', 'validate');
1853
1857
  const repo = getRepoPath();
1854
1858
  const { execSync: run } = await Promise.resolve().then(() => __importStar(require('child_process')));
1855
- const scriptPath = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
1859
+ const yamlPath = path_1.default.join(repo, 'sources', `${sourceName}.yaml`);
1860
+ const yamlContent = fs_1.default.existsSync(yamlPath) ? fs_1.default.readFileSync(yamlPath, 'utf-8') : '';
1861
+ const importScriptMatch = yamlContent.match(/import_script:\s*(.+)/);
1862
+ const customScript = importScriptMatch ? path_1.default.join(repo, importScriptMatch[1].trim()) : null;
1863
+ const defaultScript = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
1864
+ const scriptPath = customScript && fs_1.default.existsSync(customScript) ? customScript
1865
+ : fs_1.default.existsSync(defaultScript) ? defaultScript : null;
1856
1866
  const easypipePath = path_1.default.join(repo, 'src', 'imports', 'easypipe.ts');
1857
- const useEasypipe = !fs_1.default.existsSync(scriptPath);
1858
- const cmd = useEasypipe
1859
- ? `npx tsx ${easypipePath} ${path_1.default.join(repo, 'sources', `${sourceName}.yaml`)} --local`
1860
- : `npx tsx ${scriptPath} --local`;
1867
+ const cmd = scriptPath
1868
+ ? `npx tsx ${scriptPath} --local`
1869
+ : `npx tsx ${easypipePath} ${yamlPath} --local`;
1861
1870
  console.log(`[pipe] Gate 2: VALIDATE (full import, local only — no R2 upload)\n`);
1862
1871
  console.log(`Running: ${cmd}\n`);
1863
1872
  try {
@@ -2130,17 +2139,31 @@ async function pipePublish(args) {
2130
2139
  const { execSync: run } = await Promise.resolve().then(() => __importStar(require('child_process')));
2131
2140
  const RUNNER = 'f3mt0@100.109.82.87';
2132
2141
  console.log(`[pipe] Gate 4: PUBLISH\n`);
2133
- // 1. Git add + commit + push
2142
+ // 1. Auto-generate sources.ts from YAMLs
2143
+ console.log(`[pipe] Generating sources.ts...`);
2144
+ try {
2145
+ run(`npx tsx src/imports/generate-sources.ts`, { cwd: repo, stdio: 'inherit' });
2146
+ }
2147
+ catch {
2148
+ console.error(`[pipe] Failed to generate sources.ts`);
2149
+ process.exit(1);
2150
+ }
2151
+ // 2. Git add + commit + push
2134
2152
  console.log(`[pipe] Committing to repo...`);
2135
- const files = [`sources/${sourceName}.yaml`];
2153
+ const files = [`sources/${sourceName}.yaml`, 'src/sources.ts'];
2136
2154
  const scriptPath = path_1.default.join(repo, 'src', 'imports', `${sourceName}.ts`);
2137
- if (fs_1.default.existsSync(scriptPath))
2155
+ const yamlContent = fs_1.default.readFileSync(path_1.default.join(repo, 'sources', `${sourceName}.yaml`), 'utf-8');
2156
+ const importScriptMatch = yamlContent.match(/import_script:\s*(.+)/);
2157
+ const customScript = importScriptMatch ? importScriptMatch[1].trim() : null;
2158
+ if (customScript && fs_1.default.existsSync(path_1.default.join(repo, customScript)))
2159
+ files.push(customScript);
2160
+ else if (fs_1.default.existsSync(scriptPath))
2138
2161
  files.push(`src/imports/${sourceName}.ts`);
2162
+ const docsFile = `docs/sources/${sourceName}.md`;
2163
+ if (fs_1.default.existsSync(path_1.default.join(repo, docsFile)))
2164
+ files.push(docsFile);
2139
2165
  try {
2140
- const docsFile = `docs/sources/${sourceName}.md`;
2141
- if (fs_1.default.existsSync(path_1.default.join(repo, docsFile)))
2142
- files.push(docsFile);
2143
- run(`git add ${files.join(' ')} src/sources.ts .github/workflows/import.yml`, { cwd: repo, stdio: 'pipe' });
2166
+ run(`git add ${files.join(' ')}`, { cwd: repo, stdio: 'pipe' });
2144
2167
  run(`git commit -m "Add data source: ${sourceName}"`, { cwd: repo, stdio: 'pipe' });
2145
2168
  run(`git push`, { cwd: repo, stdio: 'pipe' });
2146
2169
  console.log(`[pipe] Pushed to remote.`);
@@ -2170,7 +2193,7 @@ async function pipePublish(args) {
2170
2193
  // 4. Restart search server
2171
2194
  console.log(`[pipe] Restarting search server on Linux Mint...`);
2172
2195
  try {
2173
- run(`ssh ${RUNNER} "sudo systemctl restart search-server 2>/dev/null || echo 'No service yet'"`, { stdio: 'inherit' });
2196
+ run(`ssh ${RUNNER} "sudo systemctl restart latinfo-search 2>/dev/null || echo 'No service yet'"`, { stdio: 'inherit' });
2174
2197
  }
2175
2198
  catch { }
2176
2199
  console.log(`\n[pipe] Gate 4 PASSED ✓`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.13.0",
3
+ "version": "0.13.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": {