job-pro 1.0.9 → 1.0.11

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/apply.js CHANGED
@@ -13,7 +13,7 @@
13
13
  // Fields beyond first_name / last_name / email / phone / resume are
14
14
  // passed through to whatever per-company custom question matches their
15
15
  // `name` (e.g. `linkedin_url`, `nationality`).
16
- import { readFileSync, existsSync, statSync } from "node:fs";
16
+ import { readFileSync, writeFileSync, existsSync, statSync } from "node:fs";
17
17
  import { homedir } from "node:os";
18
18
  import { basename, join } from "node:path";
19
19
  import { withPage, injectCookies } from "./cdp.js";
@@ -91,6 +91,16 @@ export function loadProfile() {
91
91
  export function profileTemplate() {
92
92
  return { path: PROFILE_PATH, template: TEMPLATE };
93
93
  }
94
+ /** Persist a profile back to disk. Used by `apply --remember`. */
95
+ export function saveProfile(profile) {
96
+ try {
97
+ writeFileSync(PROFILE_PATH, JSON.stringify(profile, null, 2) + "\n", "utf8");
98
+ return { ok: true, path: PROFILE_PATH };
99
+ }
100
+ catch (err) {
101
+ return { ok: false, message: `could not write ${PROFILE_PATH}: ${err instanceof Error ? err.message : err}` };
102
+ }
103
+ }
94
104
  /** Fill in known answers from the profile; flag any unanswered required fields. */
95
105
  export function stageApplication(schema, profile) {
96
106
  const staged = [];
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ import * as geely from "./geely.js";
50
50
  import * as webank from "./webank.js";
51
51
  import * as horizonrobotics from "./horizonrobotics.js";
52
52
  import * as cambricon from "./cambricon.js";
53
- import { loadProfile, loadSession, profileTemplate, stageApplication, submitApplication, executeFeishu3Step, executeMokaApply, executeBeisenWecruit, executeBeisenITalent, executeCdpRealBrowser, buildFormTemplate, applyFormFile, promptUnansweredFields, formatStaged, } from "./apply.js";
53
+ import { loadProfile, loadSession, profileTemplate, saveProfile, stageApplication, submitApplication, executeFeishu3Step, executeMokaApply, executeBeisenWecruit, executeBeisenITalent, executeCdpRealBrowser, buildFormTemplate, applyFormFile, promptUnansweredFields, formatStaged, } from "./apply.js";
54
54
  import { createInterface } from "node:readline";
55
55
  import { memoryList, memoryGet, memorySet, memoryEvent, memoryClear, } from "./memory.js";
56
56
  import { writeFileSync, mkdirSync, existsSync, readdirSync, statSync } from "node:fs";
@@ -164,6 +164,7 @@ VERBS (same surface for every company)
164
164
  --print-form emit a fillable JSON template
165
165
  --form-file <path> merge per-job answers
166
166
  --interactive prompt for unanswered fields
167
+ --remember + persist answers to profile.custom
167
168
  --batch <file|-> apply to many post_ids (one/line)
168
169
  --debug-submit-to <url> verify wire format
169
170
  --really-submit actually fire (env-gated)
@@ -417,6 +418,7 @@ async function runCompany(adapter, company, rawArgs) {
417
418
  const reallySubmit = args.includes("--really-submit");
418
419
  const printForm = args.includes("--print-form");
419
420
  const interactive = args.includes("--interactive");
421
+ const remember = args.includes("--remember");
420
422
  const { args: aDebug, value: debugUrl } = popFlagValue(args, "--debug-submit-to");
421
423
  const { args: aForm, value: formFilePath } = popFlagValue(aDebug, "--form-file");
422
424
  const { args: aBatch, value: batchPath } = popFlagValue(aForm, "--batch");
@@ -501,7 +503,7 @@ async function runCompany(adapter, company, rawArgs) {
501
503
  void aBatch;
502
504
  const postId = args[0];
503
505
  if (!postId)
504
- die(`usage: job-pro ${company} apply <post_id> [--print-form | --form-file <path> | --interactive | --batch <file>] [--debug-submit-to <url> | --really-submit]`);
506
+ die(`usage: job-pro ${company} apply <post_id> [--print-form | --form-file <path> | --interactive [--remember] | --batch <file>] [--debug-submit-to <url> | --really-submit]`);
505
507
  const fetchSchema = adapter.fetchApplicationSchema;
506
508
  if (typeof fetchSchema !== "function") {
507
509
  return emit({
@@ -552,6 +554,20 @@ async function runCompany(adapter, company, rawArgs) {
552
554
  }, compact);
553
555
  }
554
556
  effectiveProfile = merged.profile;
557
+ // --remember + --form-file: persist the merged answers back to profile.
558
+ if (remember && !compact) {
559
+ const before = JSON.stringify(prof.profile.custom ?? {});
560
+ const after = JSON.stringify(effectiveProfile.custom ?? {});
561
+ if (before !== after) {
562
+ const saved = saveProfile(effectiveProfile);
563
+ if (saved.ok) {
564
+ console.log(`Saved form-file answers to ${saved.path} (custom.*).`);
565
+ }
566
+ else {
567
+ console.error(`--remember failed: ${saved.message}`);
568
+ }
569
+ }
570
+ }
555
571
  }
556
572
  // --interactive: prompt stdin for each unanswered required field.
557
573
  // Skipped in --compact mode (we'd be polluting JSON output with prompts).
@@ -573,7 +589,17 @@ async function runCompany(adapter, company, rawArgs) {
573
589
  ...effectiveProfile,
574
590
  custom: { ...(effectiveProfile.custom ?? {}), ...overrides },
575
591
  };
576
- console.log(`\nCollected ${Object.keys(overrides).length} answer(s). Staging now…\n`);
592
+ const collectedCount = Object.keys(overrides).length;
593
+ console.log(`\nCollected ${collectedCount} answer(s). Staging now…\n`);
594
+ if (remember && collectedCount > 0) {
595
+ const saved = saveProfile(effectiveProfile);
596
+ if (saved.ok) {
597
+ console.log(`Saved ${collectedCount} answer(s) to ${saved.path} (custom.*).\n`);
598
+ }
599
+ else {
600
+ console.error(`--remember failed: ${saved.message}`);
601
+ }
602
+ }
577
603
  }
578
604
  const staged = stageApplication(sr.schema, effectiveProfile);
579
605
  const session = loadSession(company);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "job-pro",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Query Chinese big-tech campus recruiting from your terminal. 50 companies, all 50 live. 46 via each company's own API; the 4 with no public canonical feed (Hikvision, CICC, Cainiao, WeBank) surfaced via Liepin as a clearly-labeled third-party fallback. No signup, no token, no server.",
5
5
  "homepage": "https://job.ha7ch.com",
6
6
  "repository": "https://github.com/HA7CH/job-pro",