-
Notifications
You must be signed in to change notification settings - Fork 64
Windows installers: same existing-account gate as install.sh #4997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd58301
464d3fb
b439eb7
b18e60e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,57 @@ if %ERRORLEVEL% NEQ 0 ( | |
| ) | ||
|
|
||
| echo ✓ Installed clawmetry | ||
| echo. | ||
|
|
||
| REM ── Existing setup: account probe + "re-onboard?" gate ────────────────── | ||
| REM Same contract as install.sh / install.ps1: this script is also the upgrade | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The blueprint specifies that both installer entry points shall apply the existing-setup gate at two points: the "already up to date" early exit and the post-install path. The CMD installer only applies the gate after a successful install, not on an early exit for already-current installations. |
||
| REM path, so on a machine that is ALREADY linked to a ClawMetry account it | ||
| REM reports that setup and asks before replaying the wizard over it. With no | ||
| REM account linked it runs `clawmetry onboard` straight away. | ||
| REM | ||
| REM The probe below both PRINTS the summary and carries the answer in its exit | ||
| REM code (0 = connected), so batch never has to parse JSON. Any failure -- an | ||
| REM unreadable config, a CLI too old for `status --json`, no network -- exits | ||
| REM non-zero, which means "not connected" and simply runs the wizard as before. | ||
| if "%CLAWMETRY_SKIP_ONBOARD%"=="1" ( | ||
| echo Skipping onboard ^(CLAWMETRY_SKIP_ONBOARD=1^) - set up later with: clawmetry onboard | ||
| goto :cm_onboard_done | ||
| ) | ||
|
|
||
| set "CM_STATUS_FILE=%TEMP%\clawmetry-status.json" | ||
| %PYTHON% -m clawmetry status --json > "%CM_STATUS_FILE%" 2>nul | ||
| %PYTHON% -c "import json,os;h=os.path.expanduser('~');d=os.path.join(h,'.clawmetry');g=lambda p:(json.loads(open(p).read()) if p and os.path.exists(p) else {});c=g(os.path.join(d,'config.json'));s=g(os.environ.get('CM_STATUS_FILE',''));cl=s.get('cloud_sync') or {};a=cl.get('account') or {};k=str(c.get('api_key') or '') or os.environ.get('CLAWMETRY_API_KEY','');e=str(a.get('email') or c.get('account_email') or '');ph=bool(a.get('placeholder')) or e.lower().endswith(('@clawmetry.auto','@clawmetry.linked'));conn=(bool(k) or bool(cl.get('api_key_masked'))) and not ph;pl=str(a.get('plan') or g(os.path.join(d,'cloud_plan.json')).get('plan') or '');lo=cl.get('local_only');lo=(bool(c.get('local_only')) or os.path.exists(os.path.join(d,'nocloud'))) if lo is None else bool(lo);L={'oss':'OSS','cloud_free':'Free','free':'Free','trial':'Trial','cloud_starter':'Starter','cloud_pro':'Pro','pro':'Self-hosted Pro','enterprise':'Enterprise'};lab=L.get(pl.lower(),pl.replace('cloud_','').replace('_',' ').title());n=str(cl.get('node_id') or c.get('node_id') or '');v=str(s.get('version') or '');out=[];out.append(' You are already connected to ClawMetry');out.append('');out.append(' Account: '+e+(' ['+lab+' plan]' if lab else '')) if e else None;out.append(' Cloud sync: '+('Local-only, data stays on this machine' if lo else 'On, syncing to app.clawmetry.com'));out.append(' Version: '+v) if v else None;out.append(' Node: '+n) if n else None;print(chr(10).join(out)) if conn else None;raise SystemExit(0 if conn else 1)" 2>nul | ||
| set "CM_PROBE_RC=%ERRORLEVEL%" | ||
| del "%CM_STATUS_FILE%" >nul 2>&1 | ||
| set "CM_STATUS_FILE=" | ||
|
|
||
| if not "%CM_PROBE_RC%"=="0" ( | ||
| %PYTHON% -m clawmetry onboard | ||
| goto :cm_onboard_done | ||
| ) | ||
|
|
||
| REM CLAWMETRY_REONBOARD forces the answer without asking; anything else asks, | ||
| REM and an empty answer (including a non-interactive run, where `set /p` | ||
| REM returns immediately) keeps the setup that is already on this machine. | ||
| if /I "%CLAWMETRY_REONBOARD%"=="1" goto :cm_reonboard | ||
| if /I "%CLAWMETRY_REONBOARD%"=="0" goto :cm_keep | ||
| echo. | ||
| set "CM_ANS=" | ||
| set /p "CM_ANS= Re-run setup [account, cloud vs local-only, license]? [y/N]: " | ||
| if /I "%CM_ANS%"=="y" goto :cm_reonboard | ||
| if /I "%CM_ANS%"=="yes" goto :cm_reonboard | ||
|
|
||
| :cm_keep | ||
| echo. | ||
| echo Keeping your current setup. | ||
| echo Change it anytime: clawmetry onboard | ||
| goto :cm_onboard_done | ||
|
|
||
| :cm_reonboard | ||
| %PYTHON% -m clawmetry onboard | ||
|
|
||
| :cm_onboard_done | ||
|
|
||
| echo. | ||
| echo Ready! Run 'clawmetry' to start the dashboard. | ||
| echo Then open http://localhost:8900 in your browser. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blueprint specifies that both installer entry points shall apply the existing-setup gate at the "already up to date" early exit and the post-install path. The CMD installer only applies the gate after a successful install (around line 73), not on an early exit for already-current installations.