@spike-forms/cli 0.2.3 → 0.2.5

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 +1 -1
  2. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -323,7 +323,7 @@ server.listen(0, '127.0.0.1', () => {
323
323
  <div class="error-message">${e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</div>
324
324
  </div>
325
325
  </body>
326
- </html>`}function Pe(){let e=null,t=0,o=null,r=null,n=null,s=false;function m(a,d){if(a.method!=="GET"||!a.url?.startsWith("/callback")){d.writeHead(404,{"Content-Type":"text/plain"}),d.end("Not Found");return}let p=Rt(a.url);if(p.error){let h=p.message||p.error;d.writeHead(200,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}if(!p.state||!o||!Se(p.state,o)){let h="State verification failed. This may be a security issue.";d.writeHead(400,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}if(!p.key){let h="No API key received in callback.";d.writeHead(400,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}d.writeHead(200,{"Content-Type":"text/html"}),d.end(Dt),r&&!s&&(s=true,r({success:true,apiKey:p.key}));}return {async start(){return new Promise((a,d)=>{e=ce.createServer(m),e.on("error",p=>{d(p);}),e.listen(0,"127.0.0.1",()=>{let p=e.address();if(p&&typeof p=="object"){t=p.port;let h=`http://127.0.0.1:${t}`;a({port:t,url:h});}else d(new Error("Failed to get server address"));});})},async waitForCallback(a,d){return o=a,s=false,new Promise(p=>{r=p,n=setTimeout(()=>{s||(s=true,p({success:false,error:"Login timed out. Please try again."}));},d);})},async stop(){if(n&&(clearTimeout(n),n=null),e)return new Promise(a=>{e.close(()=>{e=null,a();});})}}}var Mt=120,Kt="https://app.spike.ac";function Nt(){return process.env.SPIKE_DASHBOARD_URL||Kt}function Ht(e,t){let o=Nt(),r=`http://127.0.0.1:${t}/callback`,n=new URL("/consent/authorize",o);return n.searchParams.set("state",e),n.searchParams.set("callback_url",r),n.toString()}function je(){return new Command("login").description("Authenticate the CLI via browser").option("-t, --timeout <seconds>","Timeout for the login flow in seconds",String(Mt)).option("--no-browser","Skip automatic browser opening and display URL only").action(async t=>{await Gt(t);})}async function Gt(e){let t=parseInt(e.timeout,10);(isNaN(t)||t<=0)&&(c("Invalid timeout value. Please provide a positive number of seconds."),process.exit(1));let o=t*1e3;i("Starting login flow...");let r=Ce(),n=Pe(),s;try{s=await n.start();}catch(a){c(`Failed to start callback server: ${a instanceof Error?a.message:String(a)}`),i("You can manually configure your API key with: spike config set api-key <your-key>"),process.exit(1);}let m=Ht(r,s.port);e.browser?(i("Opening browser for authentication..."),await T(m)||(i("Could not open browser automatically."),console.log(""),i("Please open the following URL in your browser:"),console.log(""),console.log(` ${m}`),console.log(""))):(i("Please open the following URL in your browser:"),console.log(""),console.log(` ${m}`),console.log("")),i(`Waiting for authentication (timeout: ${t}s)...`);try{let a=await n.waitForCallback(r,o);a.success&&a.apiKey?(K({apiKey:a.apiKey}),console.log(""),l("Login successful! API key has been saved."),i("You can now use the CLI to manage your forms and submissions.")):(console.log(""),c(a.error||"Login failed. Please try again."),process.exit(1));}catch(a){c(`Login error: ${a instanceof Error?a.message:String(a)}`),process.exit(1);}finally{await n.stop();}}var Vt=`# Spike Forms CLI Skill
326
+ </html>`}function Pe(){let e=null,t=0,o=null,r=null,n=null,s=false;function m(a,d){if(a.method!=="GET"||!a.url?.startsWith("/callback")){d.writeHead(404,{"Content-Type":"text/plain"}),d.end("Not Found");return}let p=Rt(a.url);if(p.error){let h=p.message||p.error;d.writeHead(200,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}if(!p.state||!o||!Se(p.state,o)){let h="State verification failed. This may be a security issue.";d.writeHead(400,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}if(!p.key){let h="No API key received in callback.";d.writeHead(400,{"Content-Type":"text/html"}),d.end(Q(h)),r&&!s&&(s=true,r({success:false,error:h}));return}d.writeHead(200,{"Content-Type":"text/html"}),d.end(Dt),r&&!s&&(s=true,r({success:true,apiKey:p.key}));}return {async start(){return new Promise((a,d)=>{e=ce.createServer(m),e.on("error",p=>{d(p);}),e.listen(0,"127.0.0.1",()=>{let p=e.address();if(p&&typeof p=="object"){t=p.port;let h=`http://127.0.0.1:${t}`;a({port:t,url:h});}else d(new Error("Failed to get server address"));});})},async waitForCallback(a,d){return o=a,s=false,new Promise(p=>{r=p,n=setTimeout(()=>{s||(s=true,p({success:false,error:"Login timed out. Please try again."}));},d);})},async stop(){if(n&&(clearTimeout(n),n=null),e)return new Promise(a=>{e.close(()=>{e=null,a();});})}}}var Mt=120,Kt="https://app.spike.ac";function Nt(){return process.env.SPIKE_DASHBOARD_URL||Kt}function Ht(e,t){let o=Nt(),r=`http://127.0.0.1:${t}/callback`,n=new URL("/consent/authorize",o);return n.searchParams.set("client_id","spike-cli"),n.searchParams.set("state",e),n.searchParams.set("callback_url",r),n.toString()}function je(){return new Command("login").description("Authenticate the CLI via browser").option("-t, --timeout <seconds>","Timeout for the login flow in seconds",String(Mt)).option("--no-browser","Skip automatic browser opening and display URL only").action(async t=>{await Gt(t);})}async function Gt(e){let t=parseInt(e.timeout,10);(isNaN(t)||t<=0)&&(c("Invalid timeout value. Please provide a positive number of seconds."),process.exit(1));let o=t*1e3;i("Starting login flow...");let r=Ce(),n=Pe(),s;try{s=await n.start();}catch(a){c(`Failed to start callback server: ${a instanceof Error?a.message:String(a)}`),i("You can manually configure your API key with: spike config set api-key <your-key>"),process.exit(1);}let m=Ht(r,s.port);e.browser?(i("Opening browser for authentication..."),await T(m)||(i("Could not open browser automatically."),console.log(""),i("Please open the following URL in your browser:"),console.log(""),console.log(` ${m}`),console.log(""))):(i("Please open the following URL in your browser:"),console.log(""),console.log(` ${m}`),console.log("")),i(`Waiting for authentication (timeout: ${t}s)...`);try{let a=await n.waitForCallback(r,o);a.success&&a.apiKey?(K({apiKey:a.apiKey}),console.log(""),l("Login successful! API key has been saved."),i("You can now use the CLI to manage your forms and submissions.")):(console.log(""),c(a.error||"Login failed. Please try again."),process.exit(1));}catch(a){c(`Login error: ${a instanceof Error?a.message:String(a)}`),process.exit(1);}finally{await n.stop();}}var Vt=`# Spike Forms CLI Skill
327
327
 
328
328
  This skill provides knowledge about the Spike Forms CLI (\`spike\`) commands for managing forms, submissions, projects, teams, and configuration.
329
329
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spike-forms/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Command-line interface for the Spike Forms API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,9 @@
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
14
17
  "scripts": {
15
18
  "build": "tsup",
16
19
  "dev": "tsup --watch",
@@ -29,7 +32,7 @@
29
32
  "author": "",
30
33
  "license": "MIT",
31
34
  "dependencies": {
32
- "@spike-forms/sdk": "workspace:*",
35
+ "@spike-forms/sdk": "^0.2.2",
33
36
  "chalk": "^5.4.1",
34
37
  "commander": "^13.1.0"
35
38
  },