@rent-scraper/create-config 1.0.20 → 1.0.22
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.
- package/dist/bin/run-create-config.mjs +1 -1
- package/dist/bin/run-init-config.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/create-config.BVVrX66f.mjs +1 -0
- package/dist/shared/{create-config.24bVYSys.mjs → create-config.Cv5GB98J.mjs} +1 -1
- package/package.json +4 -4
- package/dist/shared/create-config.Dn37D6BY.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import t from"minimist";import{log as i}from"@clack/prompts";import{parseError as m}from"@rent-scraper/utils";import{r as e}from"../shared/create-config.
|
|
2
|
+
import t from"minimist";import{log as i}from"@clack/prompts";import{parseError as m}from"@rent-scraper/utils";import{r as e}from"../shared/create-config.Cv5GB98J.mjs";import"../shared/create-config.BVVrX66f.mjs";import"@pnpm/find-workspace-dir";import"@rent-scraper/utils/config";import"node:path";import"node:timers/promises";import"picocolors";import"node:fs/promises";const s=t(process.argv.slice(2)),p=s.source??"zillow";e(p).then(()=>process.exit(0)).catch(r=>{const{message:o}=m(r);i.error(o),process.exit(1)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r}from"../shared/create-config.
|
|
1
|
+
import{r}from"../shared/create-config.BVVrX66f.mjs";import"@clack/prompts";import"@pnpm/find-workspace-dir";import"@rent-scraper/utils";import"@rent-scraper/utils/config";import"minimist";import"node:path";import"node:timers/promises";import"picocolors";r().catch(console.error);
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{r as runCreateConfig}from"./shared/create-config.
|
|
1
|
+
export{r as runCreateConfig}from"./shared/create-config.Cv5GB98J.mjs";export{r as runInitConfig}from"./shared/create-config.BVVrX66f.mjs";export{a as generateRedfinRegionIds,g as generateZillowRegionIds,r as runGenerateRegionIds}from"./shared/create-config.DS6TtXI8.mjs";export{r as runCheckConfig}from"./shared/create-config.Khzo3bcG.mjs";import"@rent-scraper/utils/config";import"@clack/prompts";import"node:timers/promises";import"node:fs/promises";import"@rent-scraper/utils";import"@pnpm/find-workspace-dir";import"minimist";import"node:path";import"picocolors";import"axios";import"@rent-scraper/api";import"@rent-scraper/browser-server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{intro as $,log as l,select as g,isCancel as o,cancel as r,text as n,confirm as F,tasks as O,outro as V}from"@clack/prompts";import{findWorkspaceDir as W}from"@pnpm/find-workspace-dir";import{parseAbsolutePath as j}from"@rent-scraper/utils";import{checkForPointerFile as L,readPointerFile as S,globalDir as b,writePointerFile as Z,checkForConfigFile as A,readConfigFile as D,getConfigFilePath as R,writeConfigFile as T}from"@rent-scraper/utils/config";import E from"minimist";import k from"node:path";import{setTimeout as d}from"node:timers/promises";import I from"picocolors";const N=E(process.argv.slice(2)),c=N.source,x=i=>/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(i);async function B(i){$(I.inverse(" create config "));let f;if(!await W(process.cwd())&&(!await L()||!c||!await S(c))){if(c)l.info(`Using source ${c==="redfin"?"Redfin":"Zillow"}`);else if(f=await g({message:"Which listings would you like to scrape?",initialValue:"zillow",options:[{value:"zillow",label:"Zillow"},{value:"redfin",label:"Redfin"}]}),o(f))return r("Operation cancelled"),process.exit(1);i=c??f??i;const e=(await n({message:"Where would like you to save the config file?",placeholder:b,defaultValue:b}))?.trim();if(await Z(i,e),o(e))return r("Operation cancelled"),process.exit(1)}const u=i&&await A(i)?await D(i):void 0;if(i=i??await g({message:"Which listings would you like to scrape?",initialValue:"zillow",options:[{value:"zillow",label:"Zillow"},{value:"redfin",label:"Redfin"}]}),o(i))return r("Operation cancelled"),process.exit(1);const h=k.dirname(await R(i)),s=u?.outputPath??(await n({message:"Where would you like the data to be stored?",placeholder:h,defaultValue:h}))?.trim();if(o(s))return r("Operation cancelled"),process.exit(1);let t=(u?.zipCodes??await n({message:"What zip codes would you like to scrape?",placeholder:"Example: 90026, 90039, 90027",validate(e){if(!e||e?.length===0)return"Please enter a list of zip codes"}})).replace(/ /g,"").split(",").filter(e=>e);const a=t.filter(e=>!x(e));if(t=t.filter(e=>!a.includes(e)),a.length){l.error("Invalid zips!");const e=await g({message:`The following zip codes are invalid: ${a.join(", ")}.`,initialValue:"remove",options:[{value:"remove",label:"Please remove them."},{value:"edit",label:"Let me edit them."}]});if(e==="remove"&&(t=t.filter(w=>!a.includes(w))),e==="edit"){const w=(await n({message:"Please fix the following zip codes:",placeholder:a.join(", "),initialValue:a.join(", "),validate(y){if(y?.length===0)return"Please enter a list of zip codes";const P=y?.replace(/ /g,"").split(",").filter(m=>m)?.filter(m=>!x(m));if(P?.length)return`The following zip codes are invalid: ${P.join(", ")}.`}})).replace(/ /g,"").split(",");t=[...t,...w]}}if(t=[...new Set(t)],a.length||l.success("Great! All your zips are valid!"),o(t))return r("Operation cancelled"),process.exit(1);const p=u?.daysListed??(await n({message:"How many days would you like to search listings? (Max. 90)",placeholder:"1",defaultValue:"1",validate(e){if(e&&e==="0")return"Please enter a number.";if(Number(e)>90)return"Please enter a number less than 90."}}))?.trim();if(o(p))return r("Operation cancelled"),process.exit(1);await d(1e3);const z=[`Listings source: ${i}`,`Output path: ${s}`,`Zip codes: ${t.join(", ")}`,`Days listed: ${p}`].filter(e=>e);l.info(""),l.info("Please review your answers:"),z.map(e=>{l.warn(e)}),l.info("");const v=await F({message:"Would you like to save this config?"});if(o(v)||!v)return r("Create config canceled. Please try again."),process.exit(1);const C={outputPath:k.isAbsolute(s)?s:j(s),zipCodes:t.join(", "),daysListed:Number(p)};return await O([{title:"Saving config to file",task:async()=>(await d(3e3),`Saved config to ${await T(i,C)}`)}]),await d(1e3),V("Config file saved!"),await d(1e3),i}export{B as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r}from"./create-config.
|
|
1
|
+
import{r}from"./create-config.BVVrX66f.mjs";import{readConfigFile as s,writeConfigFile as d,checkForConfigFile as m,checkRequiredConfigValues as h}from"@rent-scraper/utils/config";import{log as c,select as u,isCancel as C,cancel as b,multiselect as v,outro as k}from"@clack/prompts";import{setTimeout as f}from"node:timers/promises";import{rename as p}from"node:fs/promises";import{throwError as y,parseAbsolutePath as o}from"@rent-scraper/utils";async function $(e){const i=await s(e);i||y("config required");const l=i.zipCodes.split(", ").length,w=[`Output path: ${o(i.outputPath)}`,...i.browser?[`Browser: ${i.browser}`]:[],`Zip codes: ${l>10?i.zipCodes.split(", ").splice(0,10).join(", ")+"...":i.zipCodes}`].filter(t=>t);c.warn(`Config file found at ${o("./config."+e+".yaml")}`);let a=await u({message:"Would you like to:",initialValue:"keep",options:[{value:"keep",label:"Keep this config"},{value:"edit",label:"Edit this config"},{value:"review",label:"Review this config"},{value:"new",label:"Create a new config"}]});if(C(a))return b("Operation cancelled"),process.exit(1);if(a==="review"||a==="edit")for(const t of w)await f(300),c.info(t);const n=a==="edit"&&await v({message:"Which fields would you like to edit?",options:[{value:"outputPath",label:"Output path"},{value:"zipCodes",label:"Zip codes"}],required:!1});if(n&&Array.isArray(n)&&n.length){const t=await s(e);if(t){await f(1e3),await p(o(`./config.${e}.yaml`),o(`./config.${e}.yaml.bak`));for(const g of n)delete t[g];await f(1e3),await d(e,t),await r(e)}}if(a==="new"&&(await p(o(`./config.${e}.yaml`),o(`./config.${e}.yaml.bak`)),await r()),a=a==="review"?await u({message:"Would you like to:",initialValue:"keep",options:[{value:"keep",label:"Keep this config"},{value:"edit",label:"Edit this config"},{value:"new",label:"Create a new config"}]}):a,a==="keep")return k("Config file saved!"),process.exit(0)}async function F(e){if(e&&await m(e)){const i=await s(e),l=h(e,i);l.length?(console.log({missingFields:l}),await r(e)):await $(e)}else await r(e)}export{F as r};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rent-scraper/create-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"minimist": "^1.2.8",
|
|
47
47
|
"picocolors": "^1.1.1",
|
|
48
48
|
"puppeteer": "^24.11.2",
|
|
49
|
-
"@rent-scraper/
|
|
50
|
-
"@rent-scraper/
|
|
51
|
-
"@rent-scraper/utils": "1.0.
|
|
49
|
+
"@rent-scraper/browser-server": "1.0.22",
|
|
50
|
+
"@rent-scraper/api": "1.0.22",
|
|
51
|
+
"@rent-scraper/utils": "1.0.22"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/minimist": "^1.2.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{intro as F,log as l,select as g,isCancel as o,cancel as r,text as n,confirm as O,tasks as V,outro as W}from"@clack/prompts";import{findWorkspaceDir as j}from"@pnpm/find-workspace-dir";import{parseAbsolutePath as L}from"@rent-scraper/utils";import{checkForPointerFile as S,readPointerFile as Z,globalDir as b,writePointerFile as A,checkForConfigFile as D,readConfigFile as R,getConfigFilePath as T,writeConfigFile as E}from"@rent-scraper/utils/config";import I from"minimist";import k from"node:path";import{setTimeout as f}from"node:timers/promises";import N from"picocolors";const B=I(process.argv.slice(2)),c=B.source,x=i=>/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(i);async function G(i){F(N.inverse(" create config "));let u;if(!await j(process.cwd())&&(!await S()||!c||!await Z(c))){if(c)l.info(`Using source ${c==="redfin"?"Redfin":"Zillow"}`);else if(u=await g({message:"Which listings would you like to scrape?",initialValue:"zillow",options:[{value:"zillow",label:"Zillow"},{value:"redfin",label:"Redfin"}]}),o(u))return r("Operation cancelled"),process.exit(1);i=c??u??i;const e=(await n({message:"Where would like you to save the config file?",placeholder:b,defaultValue:b}))?.trim();if(await A(i,e),o(e))return r("Operation cancelled"),process.exit(1)}const d=i&&await D(i)?await R(i):void 0;if(i=i??await g({message:"Which listings would you like to scrape?",initialValue:"zillow",options:[{value:"zillow",label:"Zillow"},{value:"redfin",label:"Redfin"}]}),o(i))return r("Operation cancelled"),process.exit(1);const h=k.dirname(await T(i)),s=d?.outputPath??(await n({message:"Where would you like the data to be stored?",placeholder:h,defaultValue:h}))?.trim();if(o(s))return r("Operation cancelled"),process.exit(1);const z=null;let t=(d?.zipCodes??await n({message:"What zip codes would you like to scrape?",placeholder:"Example: 90026, 90039, 90027",validate(e){if(!e||e?.length===0)return"Please enter a list of zip codes"}})).replace(/ /g,"").split(",").filter(e=>e);const a=t.filter(e=>!x(e));if(t=t.filter(e=>!a.includes(e)),a.length){l.error("Invalid zips!");const e=await g({message:`The following zip codes are invalid: ${a.join(", ")}.`,initialValue:"remove",options:[{value:"remove",label:"Please remove them."},{value:"edit",label:"Let me edit them."}]});if(e==="remove"&&(t=t.filter(m=>!a.includes(m))),e==="edit"){const m=(await n({message:"Please fix the following zip codes:",placeholder:a.join(", "),initialValue:a.join(", "),validate(y){if(y?.length===0)return"Please enter a list of zip codes";const P=y?.replace(/ /g,"").split(",").filter(w=>w)?.filter(w=>!x(w));if(P?.length)return`The following zip codes are invalid: ${P.join(", ")}.`}})).replace(/ /g,"").split(",");t=[...t,...m]}}if(t=[...new Set(t)],a.length||l.success("Great! All your zips are valid!"),o(t))return r("Operation cancelled"),process.exit(1);const p=d?.daysListed??(await n({message:"How many days would you like to search listings? (Max. 90)",placeholder:"1",defaultValue:"1",validate(e){if(e&&e==="0")return"Please enter a number.";if(Number(e)>90)return"Please enter a number less than 90."}}))?.trim();if(o(p))return r("Operation cancelled"),process.exit(1);await f(1e3);const C=[`Listings source: ${i}`,`Output path: ${s}`,`Zip codes: ${t.join(", ")}`,`Days listed: ${p}`].filter(e=>e);l.info(""),l.info("Please review your answers:"),C.map(e=>{l.warn(e)}),l.info("");const v=await O({message:"Would you like to save this config?"});if(o(v)||!v)return r("Create config canceled. Please try again."),process.exit(1);const $={outputPath:k.isAbsolute(s)?s:L(s),...z,zipCodes:t.join(", "),daysListed:Number(p)};return await V([{title:"Saving config to file",task:async()=>(await f(3e3),`Saved config to ${await E(i,$)}`)}]),await f(1e3),W("Config file saved!"),await f(1e3),i}export{G as r};
|