@explorer02/cfm-survey-sdk 0.2.1 → 0.2.3
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/cli/index.js +18 -18
- package/dist/cli/index.mjs +14 -14
- package/dist/index.d.mts +465 -580
- package/dist/index.d.ts +465 -580
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -4
- package/postinstall.js +96 -69
- package/templates/AGENT.md +18 -8
- package/templates/docs/00-integration/analytics-events-catalog.md +54 -0
- package/templates/docs/00-integration/answer-logic-and-navigation.md +50 -0
- package/templates/docs/00-integration/aws-deploy.md +281 -0
- package/templates/docs/00-integration/client-integration-guide.md +351 -0
- package/templates/docs/00-integration/component-checklist.md +55 -22
- package/templates/docs/00-integration/constraints.md +49 -4
- package/templates/docs/00-integration/custom-field-logic-and-navigation.md +174 -0
- package/templates/docs/00-integration/display-logic-and-navigation.md +64 -0
- package/templates/docs/00-integration/end-page-logic.md +64 -0
- package/templates/docs/00-integration/file-upload-aws.md +116 -0
- package/templates/docs/00-integration/logic-fields-catalog.md +105 -0
- package/templates/docs/00-integration/partial-save-and-recovery.md +98 -0
- package/templates/docs/00-integration/placeholders-and-tokens.md +116 -0
- package/templates/docs/00-integration/progress.md +61 -0
- package/templates/docs/00-integration/question-display-variants.md +65 -0
- package/templates/docs/00-integration/question-numbering.md +51 -0
- package/templates/docs/00-integration/question-type-sdk-matrix.md +244 -0
- package/templates/docs/00-integration/setup.md +84 -0
- package/templates/docs/00-integration/skip-logic-and-navigation.md +80 -0
- package/templates/docs/00-integration/survey-lifecycle-analytics.md +94 -0
- package/templates/docs/00-integration/useSurveySDK.md +151 -23
- package/templates/docs/01-components/01-survey-page.md +76 -54
- package/templates/docs/01-components/02-question.md +61 -58
- package/templates/docs/01-components/03-rating-scale.md +11 -1
- package/templates/docs/01-components/04-star-rating-scale.md +45 -0
- package/templates/docs/01-components/05-csat-matrix-scale.md +20 -11
- package/templates/docs/01-components/06-likert-matrix-scale.md +14 -4
- package/templates/docs/01-components/07-slider-matrix-scale.md +11 -2
- package/templates/docs/01-components/08-file-upload-scale.md +23 -51
- package/templates/docs/01-components/09-custom-slider-track.md +2 -2
- package/templates/docs/01-components/11-progress-bar.md +10 -4
- package/templates/docs/01-components/13-matrix-dropdown.md +29 -32
- package/templates/docs/01-components/14-intro-page.md +34 -0
- package/templates/docs/01-components/15-end-page.md +31 -0
- package/templates/docs/01-components/16-paused-page.md +27 -0
- package/templates/docs/01-components/17-heatmap-scale.md +75 -0
- package/templates/docs/01-components/18-rank-order-scale.md +93 -0
- package/templates/docs/01-components/README.md +42 -36
- package/templates/docs/02-reference/config-field-index.md +141 -139
- package/templates/docs/02-reference/exports.md +149 -0
- package/templates/docs/02-reference/question-types/01-rating.md +31 -32
- package/templates/docs/02-reference/question-types/04-csat.md +51 -42
- package/templates/docs/02-reference/question-types/05-rating-scale.md +16 -11
- package/templates/docs/02-reference/question-types/06-slider.md +2 -2
- package/templates/docs/02-reference/question-types/07-matrix-cfm.md +44 -30
- package/templates/docs/02-reference/question-types/08-matrix-csat.md +4 -26
- package/templates/docs/02-reference/question-types/09-matrix-rating.md +29 -13
- package/templates/docs/02-reference/question-types/10-slider-matrix.md +15 -4
- package/templates/docs/02-reference/question-types/11-file-upload.md +43 -17
- package/templates/docs/02-reference/question-types/12-heatmap.md +59 -0
- package/templates/docs/02-reference/question-types/13-rank-order.md +101 -0
- package/templates/docs/02-reference/question-types/README.md +96 -47
- package/templates/docs/02-reference/routing-table.md +33 -18
- package/templates/docs/02-reference/value-derivation.md +63 -0
- package/templates/docs/03-ui-specs/00-question-shell.md +19 -88
- package/templates/docs/03-ui-specs/01-rating.md +18 -52
- package/templates/docs/03-ui-specs/02-radio.md +80 -37
- package/templates/docs/03-ui-specs/03-text.md +2 -2
- package/templates/docs/03-ui-specs/04-csat.md +68 -33
- package/templates/docs/03-ui-specs/05-rating-scale.md +21 -18
- package/templates/docs/03-ui-specs/06-slider.md +3 -1
- package/templates/docs/03-ui-specs/07-matrix-cfm.md +44 -25
- package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +19 -43
- package/templates/docs/03-ui-specs/09-slider-matrix.md +18 -1
- package/templates/docs/03-ui-specs/10-file-upload.md +42 -21
- package/templates/docs/03-ui-specs/11-text-and-media.md +29 -29
- package/templates/docs/03-ui-specs/12-survey-chrome.md +58 -14
- package/templates/docs/03-ui-specs/13-heatmap.md +80 -0
- package/templates/docs/03-ui-specs/14-rank-order.md +128 -0
- package/templates/docs/03-ui-specs/README.md +16 -14
- package/templates/docs/03-ui-specs/shared/custom-slider-track.md +28 -35
- package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +5 -0
- package/templates/docs/MANIFEST.json +476 -69
- package/templates/docs/index.md +82 -30
- package/templates/docs/templates/CustomSliderTrack.tsx +144 -0
- package/templates/docs/templates/MatrixDropdown.tsx +216 -0
- package/templates/docs/templates/Question.tsx +221 -154
- package/templates/docs/templates/RankOrderScale.tsx +353 -0
- package/templates/docs/templates/deploy-to-aws.sh +114 -0
- package/templates/docs/templates/heatmapCoords.ts +58 -0
- package/templates/docs/templates/implementation_plan.md +126 -67
- package/templates/docs/templates/survey-inventory.schema.json +77 -0
- package/templates/docs/templates/surveyUiIcons.tsx +52 -0
- package/templates/docs/templates/verify-agent-build.sh +85 -0
- package/templates/docs/01-components/04-csat-scale.md +0 -40
- package/templates/docs/02-question-types/01-rating.md +0 -44
package/dist/cli/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var B=Object.create;var N=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var G=(o,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of z(n))!Q.call(o,s)&&s!==t&&N(o,s,{get:()=>n[s],enumerable:!(r=W(n,s))||r.enumerable});return o};var b=(o,n,t)=>(t=o!=null?B(K(o)):{},G(n||!o||!o.__esModule?N(t,"default",{value:o,enumerable:!0}):t,o));var e={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"};var $=require("child_process");function f(o){try{let n=process.platform==="win32"?`where ${o}`:`command -v ${o}`;return(0,$.execSync)(n,{stdio:"ignore"}),!0}catch{return!1}}var U={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function w(o,n){try{let t=`${o} ${n.join(" ")}`;return(0,$.execSync)(t,U),!0}catch{return!1}}function v(o,n){return new Promise(t=>{(0,$.spawn)(o,n,{stdio:"inherit",shell:!0}).on("close",s=>{t(s)})})}var E=b(require("readline/promises")),x=require("process");async function y(o){let n=E.default.createInterface({input:x.stdin,output:x.stdout});try{return(await n.question(o)).trim()}finally{n.close()}}async function I(){let o=parseInt(process.version.slice(1).split(".")[0],10);if(console.log(`${e.dim}Step 1/4: Checking Node.js version (current: ${process.version})...${e.reset}`),o<18){console.log(`\u26A0\uFE0F ${e.yellow}Outdated Node.js version detected. v18.0.0 or higher is required.${e.reset}`),console.log(`${e.dim}Note: If you already have a higher version installed via nvm, please run 'nvm use <version>' first.${e.reset}
|
|
3
3
|
`);let n=await y("Would you like to install/upgrade Node.js v18+ automatically? (y/N): ");n.toLowerCase()==="y"||n.toLowerCase()==="yes"||(console.log(`
|
|
4
4
|
\u274C ${e.red}Aborted. Please manually upgrade Node.js to v18+ and try again.${e.reset}
|
|
5
|
-
`),process.exit(1));let
|
|
6
|
-
\u{1F4E6} ${e.green}winget package manager found! Installing Node.js v18+ in background...${e.reset}`),
|
|
5
|
+
`),process.exit(1));let r=process.platform==="win32",s=process.platform==="darwin";r?f("winget")?(console.log(`
|
|
6
|
+
\u{1F4E6} ${e.green}winget package manager found! Installing Node.js v18+ in background...${e.reset}`),w("winget",["upgrade","OpenJS.NodeJS","--silent","--accept-package-agreements","--accept-source-agreements"])?(console.log(`
|
|
7
7
|
\u2714 ${e.green}Node.js installation triggered successfully. Please restart your terminal/command-prompt for changes to take effect.${e.reset}
|
|
8
8
|
`),process.exit(0)):(console.log(`
|
|
9
9
|
\u274C ${e.red}winget update failed. Please update Node.js manually at https://nodejs.org/${e.reset}
|
|
10
10
|
`),process.exit(1))):(console.log(`
|
|
11
11
|
\u274C ${e.red}winget package manager is not installed on this system.${e.reset}`),console.log(`${e.bold}\u{1F449} To proceed, please either:${e.reset}`),console.log(" 1. Install winget (App Installer) from the Microsoft Store."),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
|
|
12
|
-
`),process.exit(1)):
|
|
13
|
-
\u{1F4E6} ${e.green}Homebrew package manager found! Installing Node.js v18+ in background...${e.reset}`),
|
|
12
|
+
`),process.exit(1)):s?f("brew")?(console.log(`
|
|
13
|
+
\u{1F4E6} ${e.green}Homebrew package manager found! Installing Node.js v18+ in background...${e.reset}`),w("brew",["install","node"])?console.log(`
|
|
14
14
|
\u2714 ${e.green}Node.js installed successfully via Homebrew.${e.reset}
|
|
15
15
|
`):(console.log(`
|
|
16
16
|
\u274C ${e.red}Homebrew installation failed. Please install Node.js manually at https://nodejs.org/${e.reset}
|
|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
\u274C ${e.red}Homebrew package manager (brew) is not installed on this system.${e.reset}`),console.log(`${e.bold}\u{1F449} To proceed, please either:${e.reset}`),console.log(" 1. Install Homebrew by running the following command in your terminal:"),console.log(` ${e.cyan}/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"${e.reset}`),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
|
|
19
19
|
`),process.exit(1)):(console.log(`
|
|
20
20
|
\u274C ${e.red}Please install or update Node.js to v18+ using your system's package manager.${e.reset}
|
|
21
|
-
`),process.exit(1))}else console.log(`\u2714 ${e.green}Node.js version (v${o}) is sufficient.${e.reset}`)}async function
|
|
21
|
+
`),process.exit(1))}else console.log(`\u2714 ${e.green}Node.js version (v${o}) is sufficient.${e.reset}`)}async function L(){console.log(`
|
|
22
22
|
${e.dim}Step 2/4: Checking Vercel CLI...${e.reset}`);let o="vercel",n=!1;if(f("vercel"))console.log(`\u2714 ${e.green}Vercel CLI is installed!${e.reset}`);else{console.log(`\u2753 ${e.yellow}Vercel CLI was not found on your system.${e.reset}`);let t=await y("\u{1F449} Would you like to install Vercel CLI globally? (Y/n): ");t.toLowerCase()==="y"||t===""?(console.log(`
|
|
23
|
-
\u{1F4E5} ${e.cyan}Installing Vercel CLI globally... (npm install -g vercel)${e.reset}`),
|
|
24
|
-
\u26A0\uFE0F ${e.yellow}Global installation failed or permissions restricted.${e.reset}`),console.log(`\u2139 ${e.dim}Falling back: Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)):(console.log(`\u2139 ${e.dim}Skipping global installation. Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)}return{vercelCmd:o,useNpx:n}}var
|
|
25
|
-
${e.dim}Step 3/4: Checking Vercel Login...${e.reset}`);let n=!!process.env.VERCEL_TOKEN,t=!1;if(n)console.log(`\u2714 ${e.green}VERCEL_TOKEN environment variable detected. Skipping login check.${e.reset}`),t=!0;else try{(0,
|
|
26
|
-
\u2714 ${e.green}Logged in successfully!${e.reset}`)}return n}async function
|
|
27
|
-
${e.dim}Step 4/4: Deploying project to production...${e.reset}`);let t=["--prod","--yes"];n&&t.push("--token",process.env.VERCEL_TOKEN);let
|
|
28
|
-
`),await v(s
|
|
23
|
+
\u{1F4E5} ${e.cyan}Installing Vercel CLI globally... (npm install -g vercel)${e.reset}`),w("npm",["install","-g","vercel"])&&f("vercel")?console.log(`\u2714 ${e.green}Vercel CLI installed successfully!${e.reset}`):(console.log(`
|
|
24
|
+
\u26A0\uFE0F ${e.yellow}Global installation failed or permissions restricted.${e.reset}`),console.log(`\u2139 ${e.dim}Falling back: Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)):(console.log(`\u2139 ${e.dim}Skipping global installation. Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)}return{vercelCmd:o,useNpx:n}}var P=require("child_process");var Y={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function O(o){console.log(`
|
|
25
|
+
${e.dim}Step 3/4: Checking Vercel Login...${e.reset}`);let n=!!process.env.VERCEL_TOKEN,t=!1;if(n)console.log(`\u2714 ${e.green}VERCEL_TOKEN environment variable detected. Skipping login check.${e.reset}`),t=!0;else try{(0,P.execSync)(o?"npx --yes vercel whoami":"vercel whoami",Y),t=!0,console.log(`\u2714 ${e.green}Logged in!${e.reset}`)}catch{t=!1}if(!t){console.log(`\u{1F511} ${e.yellow}Not logged in to Vercel.${e.reset}`),await y("\u{1F449} Press [Enter] to login to Vercel... ");let r=["login"],s=o?"npx":"vercel",u=o?["--yes","vercel",...r]:r;if(await v(s,u)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
|
|
26
|
+
\u2714 ${e.green}Logged in successfully!${e.reset}`)}return n}async function A(o,n){console.log(`
|
|
27
|
+
${e.dim}Step 4/4: Deploying project to production...${e.reset}`);let t=["--prod","--yes"];n&&t.push("--token",process.env.VERCEL_TOKEN);let r=o?"npx":"vercel",s=o?["--yes","vercel",...t]:t;if(console.log(`${e.cyan}\u26A1 Running deployment in: ${process.cwd()}${e.reset}
|
|
28
|
+
`),await v(r,s)!==0)throw new Error("Vercel deployment failed.");console.log(`
|
|
29
29
|
${e.bold}${e.green}\u{1F389} Deployment completed successfully!${e.reset}
|
|
30
30
|
`)}async function D(){console.log(`
|
|
31
31
|
${e.bold}${e.cyan}\u{1F680} Starting CFM Vercel Deployment...${e.reset}
|
|
32
|
-
`),await I();let{vercelCmd:o,useNpx:n}=await
|
|
33
|
-
${a.green}\u2705 Configuration saved to ${t}${a.reset}`),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({ok:!0})),setTimeout(()=>{
|
|
32
|
+
`),await I();let{vercelCmd:o,useNpx:n}=await L(),t=await O(n);await A(n,t)}var k=b(require("http")),p=b(require("fs")),c=b(require("path"));function h(o){return o instanceof Error?o.message:String(o)}var a=e;function H(o){return new Promise((n,t)=>{let r=k.createServer();r.listen(o,()=>{r.close(()=>n(o))}),r.on("error",()=>{n(H(o+1))})})}function T(o){return new Promise((n,t)=>{let r="";o.on("data",s=>r+=s),o.on("end",()=>n(r)),o.on("error",t)})}function X(o){let{exec:n}=require("child_process"),t=process.platform==="darwin"?`open "${o}"`:process.platform==="win32"?`start "" "${o}"`:`xdg-open "${o}"`;n(t)}async function _(){let o=process.env.INIT_CWD||process.cwd(),n=c.join(o,"public"),t=c.join(o,"survey-config.json"),r=c.join(__dirname,"..","..","templates"),s=await H(4200);return new Promise((u,S)=>{let C=k.createServer(async(l,i)=>{try{if(l.method==="GET"&&(l.url==="/"||l.url==="/index.html")){let d=c.join(r,"wizard.html"),m=p.readFileSync(d,"utf8");i.writeHead(200,{"Content-Type":"text/html"}),i.end(m)}else if(l.method==="POST"&&l.url==="/api/upload-logo"){let d=await T(l),m=JSON.parse(d);p.existsSync(n)||p.mkdirSync(n,{recursive:!0});let M=m.base64.replace(/^data:image\/\w+;base64,/,""),J=Buffer.from(M,"base64"),V=c.extname(m.filename),F=c.basename(m.filename,V).toLowerCase().replace(/[^a-z0-9_-]/g,""),j=`logo_${Date.now()}_${F}${V||".png"}`;p.writeFileSync(c.join(n,j),J),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({fileName:j}))}else if(l.method==="POST"&&l.url==="/api/save-config"){let d=await T(l),m=JSON.parse(d);m.configuredAt=new Date().toISOString(),p.writeFileSync(t,JSON.stringify(m,null,2),"utf8"),console.log(`
|
|
33
|
+
${a.green}\u2705 Configuration saved to ${t}${a.reset}`),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({ok:!0})),setTimeout(()=>{C.close(()=>u())},500)}else i.writeHead(404,{"Content-Type":"text/plain"}),i.end("Not found")}catch(d){i.writeHead(500,{"Content-Type":"text/plain"}),i.end(`Server error: ${h(d)}`)}});C.listen(s,()=>{let l=`http://localhost:${s}`;console.log(`
|
|
34
34
|
${a.bold}${a.cyan}\u{1F680} Survey Setup Wizard${a.reset}`),console.log(`${a.dim} Running at ${a.reset}${a.green}${l}${a.reset}
|
|
35
|
-
`),
|
|
36
|
-
${g.red}\u274C Error: ${o
|
|
37
|
-
${g.red}\u274C Error: ${o
|
|
35
|
+
`),X(l)}),C.on("error",S)})}var g=e,Z=process.argv.slice(2),R=Z[0];async function q(){if(R==="init")try{await _()}catch(o){console.error(`
|
|
36
|
+
${g.red}\u274C Error: ${h(o)}${g.reset}`),process.exit(1)}else if(R==="deploy")try{await D()}catch(o){console.error(`
|
|
37
|
+
${g.red}\u274C Error: ${h(o)}${g.reset}`),process.exit(1)}else console.log(`
|
|
38
38
|
${g.bold}${g.cyan}CFM SDK CLI Tool${g.reset}`),console.log(`
|
|
39
|
-
Usage:`),console.log(" npx cfm-sdk init \u2013 Launch the survey setup wizard"),console.log(" npx cfm-sdk deploy \u2013 Deploy the current project to Vercel"),process.exit(0)}
|
|
39
|
+
Usage:`),console.log(" npx cfm-sdk init \u2013 Launch the survey setup wizard"),console.log(" npx cfm-sdk deploy \u2013 Deploy the current project to Vercel"),process.exit(0)}q();
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var _=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var e={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"};import{execSync as S,spawn as R}from"child_process";function f(o){try{let n=process.platform==="win32"?`where ${o}`:`command -v ${o}`;return S(n,{stdio:"ignore"}),!0}catch{return!1}}var M={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function $(o,n){try{let t=`${o} ${n.join(" ")}`;return S(t,M),!0}catch{return!1}}function h(o,n){return new Promise(t=>{R(o,n,{stdio:"inherit",shell:!0}).on("close",s=>{t(s)})})}import J from"readline/promises";import{stdin as F,stdout as B}from"process";async function y(o){let n=J.createInterface({input:F,output:B});try{return(await n.question(o)).trim()}finally{n.close()}}async function V(){let o=parseInt(process.version.slice(1).split(".")[0],10);if(console.log(`${e.dim}Step 1/4: Checking Node.js version (current: ${process.version})...${e.reset}`),o<18){console.log(`\u26A0\uFE0F ${e.yellow}Outdated Node.js version detected. v18.0.0 or higher is required.${e.reset}`),console.log(`${e.dim}Note: If you already have a higher version installed via nvm, please run 'nvm use <version>' first.${e.reset}
|
|
3
3
|
`);let n=await y("Would you like to install/upgrade Node.js v18+ automatically? (y/N): ");n.toLowerCase()==="y"||n.toLowerCase()==="yes"||(console.log(`
|
|
4
4
|
\u274C ${e.red}Aborted. Please manually upgrade Node.js to v18+ and try again.${e.reset}
|
|
5
|
-
`),process.exit(1));let
|
|
5
|
+
`),process.exit(1));let r=process.platform==="win32",s=process.platform==="darwin";r?f("winget")?(console.log(`
|
|
6
6
|
\u{1F4E6} ${e.green}winget package manager found! Installing Node.js v18+ in background...${e.reset}`),$("winget",["upgrade","OpenJS.NodeJS","--silent","--accept-package-agreements","--accept-source-agreements"])?(console.log(`
|
|
7
7
|
\u2714 ${e.green}Node.js installation triggered successfully. Please restart your terminal/command-prompt for changes to take effect.${e.reset}
|
|
8
8
|
`),process.exit(0)):(console.log(`
|
|
9
9
|
\u274C ${e.red}winget update failed. Please update Node.js manually at https://nodejs.org/${e.reset}
|
|
10
10
|
`),process.exit(1))):(console.log(`
|
|
11
11
|
\u274C ${e.red}winget package manager is not installed on this system.${e.reset}`),console.log(`${e.bold}\u{1F449} To proceed, please either:${e.reset}`),console.log(" 1. Install winget (App Installer) from the Microsoft Store."),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
|
|
12
|
-
`),process.exit(1)):
|
|
12
|
+
`),process.exit(1)):s?f("brew")?(console.log(`
|
|
13
13
|
\u{1F4E6} ${e.green}Homebrew package manager found! Installing Node.js v18+ in background...${e.reset}`),$("brew",["install","node"])?console.log(`
|
|
14
14
|
\u2714 ${e.green}Node.js installed successfully via Homebrew.${e.reset}
|
|
15
15
|
`):(console.log(`
|
|
@@ -21,19 +21,19 @@ var A=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,t)=>(t
|
|
|
21
21
|
`),process.exit(1))}else console.log(`\u2714 ${e.green}Node.js version (v${o}) is sufficient.${e.reset}`)}async function j(){console.log(`
|
|
22
22
|
${e.dim}Step 2/4: Checking Vercel CLI...${e.reset}`);let o="vercel",n=!1;if(f("vercel"))console.log(`\u2714 ${e.green}Vercel CLI is installed!${e.reset}`);else{console.log(`\u2753 ${e.yellow}Vercel CLI was not found on your system.${e.reset}`);let t=await y("\u{1F449} Would you like to install Vercel CLI globally? (Y/n): ");t.toLowerCase()==="y"||t===""?(console.log(`
|
|
23
23
|
\u{1F4E5} ${e.cyan}Installing Vercel CLI globally... (npm install -g vercel)${e.reset}`),$("npm",["install","-g","vercel"])&&f("vercel")?console.log(`\u2714 ${e.green}Vercel CLI installed successfully!${e.reset}`):(console.log(`
|
|
24
|
-
\u26A0\uFE0F ${e.yellow}Global installation failed or permissions restricted.${e.reset}`),console.log(`\u2139 ${e.dim}Falling back: Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)):(console.log(`\u2139 ${e.dim}Skipping global installation. Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)}return{vercelCmd:o,useNpx:n}}import{execSync as
|
|
25
|
-
${e.dim}Step 3/4: Checking Vercel Login...${e.reset}`);let n=!!process.env.VERCEL_TOKEN,t=!1;if(n)console.log(`\u2714 ${e.green}VERCEL_TOKEN environment variable detected. Skipping login check.${e.reset}`),t=!0;else try{
|
|
26
|
-
\u2714 ${e.green}Logged in successfully!${e.reset}`)}return n}async function
|
|
27
|
-
${e.dim}Step 4/4: Deploying project to production...${e.reset}`);let t=["--prod","--yes"];n&&t.push("--token",process.env.VERCEL_TOKEN);let
|
|
28
|
-
`),await h(s
|
|
24
|
+
\u26A0\uFE0F ${e.yellow}Global installation failed or permissions restricted.${e.reset}`),console.log(`\u2139 ${e.dim}Falling back: Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)):(console.log(`\u2139 ${e.dim}Skipping global installation. Running Vercel dynamically via npx.${e.reset}`),o="npx --yes vercel",n=!0)}return{vercelCmd:o,useNpx:n}}import{execSync as W}from"child_process";var z={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function N(o){console.log(`
|
|
25
|
+
${e.dim}Step 3/4: Checking Vercel Login...${e.reset}`);let n=!!process.env.VERCEL_TOKEN,t=!1;if(n)console.log(`\u2714 ${e.green}VERCEL_TOKEN environment variable detected. Skipping login check.${e.reset}`),t=!0;else try{W(o?"npx --yes vercel whoami":"vercel whoami",z),t=!0,console.log(`\u2714 ${e.green}Logged in!${e.reset}`)}catch{t=!1}if(!t){console.log(`\u{1F511} ${e.yellow}Not logged in to Vercel.${e.reset}`),await y("\u{1F449} Press [Enter] to login to Vercel... ");let r=["login"],s=o?"npx":"vercel",u=o?["--yes","vercel",...r]:r;if(await h(s,u)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
|
|
26
|
+
\u2714 ${e.green}Logged in successfully!${e.reset}`)}return n}async function E(o,n){console.log(`
|
|
27
|
+
${e.dim}Step 4/4: Deploying project to production...${e.reset}`);let t=["--prod","--yes"];n&&t.push("--token",process.env.VERCEL_TOKEN);let r=o?"npx":"vercel",s=o?["--yes","vercel",...t]:t;if(console.log(`${e.cyan}\u26A1 Running deployment in: ${process.cwd()}${e.reset}
|
|
28
|
+
`),await h(r,s)!==0)throw new Error("Vercel deployment failed.");console.log(`
|
|
29
29
|
${e.bold}${e.green}\u{1F389} Deployment completed successfully!${e.reset}
|
|
30
30
|
`)}async function I(){console.log(`
|
|
31
31
|
${e.bold}${e.cyan}\u{1F680} Starting CFM Vercel Deployment...${e.reset}
|
|
32
|
-
`),await
|
|
33
|
-
${a.green}\u2705 Configuration saved to ${t}${a.reset}`),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({ok:!0})),setTimeout(()=>{
|
|
32
|
+
`),await V();let{vercelCmd:o,useNpx:n}=await j(),t=await N(n);await E(n,t)}import*as v from"http";import*as p from"fs";import*as c from"path";function w(o){return o instanceof Error?o.message:String(o)}var a=e;function P(o){return new Promise((n,t)=>{let r=v.createServer();r.listen(o,()=>{r.close(()=>n(o))}),r.on("error",()=>{n(P(o+1))})})}function L(o){return new Promise((n,t)=>{let r="";o.on("data",s=>r+=s),o.on("end",()=>n(r)),o.on("error",t)})}function K(o){let{exec:n}=_("child_process"),t=process.platform==="darwin"?`open "${o}"`:process.platform==="win32"?`start "" "${o}"`:`xdg-open "${o}"`;n(t)}async function O(){let o=process.env.INIT_CWD||process.cwd(),n=c.join(o,"public"),t=c.join(o,"survey-config.json"),r=c.join(__dirname,"..","..","templates"),s=await P(4200);return new Promise((u,x)=>{let b=v.createServer(async(l,i)=>{try{if(l.method==="GET"&&(l.url==="/"||l.url==="/index.html")){let d=c.join(r,"wizard.html"),m=p.readFileSync(d,"utf8");i.writeHead(200,{"Content-Type":"text/html"}),i.end(m)}else if(l.method==="POST"&&l.url==="/api/upload-logo"){let d=await L(l),m=JSON.parse(d);p.existsSync(n)||p.mkdirSync(n,{recursive:!0});let D=m.base64.replace(/^data:image\/\w+;base64,/,""),T=Buffer.from(D,"base64"),C=c.extname(m.filename),H=c.basename(m.filename,C).toLowerCase().replace(/[^a-z0-9_-]/g,""),k=`logo_${Date.now()}_${H}${C||".png"}`;p.writeFileSync(c.join(n,k),T),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({fileName:k}))}else if(l.method==="POST"&&l.url==="/api/save-config"){let d=await L(l),m=JSON.parse(d);m.configuredAt=new Date().toISOString(),p.writeFileSync(t,JSON.stringify(m,null,2),"utf8"),console.log(`
|
|
33
|
+
${a.green}\u2705 Configuration saved to ${t}${a.reset}`),i.writeHead(200,{"Content-Type":"application/json"}),i.end(JSON.stringify({ok:!0})),setTimeout(()=>{b.close(()=>u())},500)}else i.writeHead(404,{"Content-Type":"text/plain"}),i.end("Not found")}catch(d){i.writeHead(500,{"Content-Type":"text/plain"}),i.end(`Server error: ${w(d)}`)}});b.listen(s,()=>{let l=`http://localhost:${s}`;console.log(`
|
|
34
34
|
${a.bold}${a.cyan}\u{1F680} Survey Setup Wizard${a.reset}`),console.log(`${a.dim} Running at ${a.reset}${a.green}${l}${a.reset}
|
|
35
|
-
`),
|
|
36
|
-
${g.red}\u274C Error: ${o
|
|
37
|
-
${g.red}\u274C Error: ${o
|
|
35
|
+
`),K(l)}),b.on("error",x)})}var g=e,Q=process.argv.slice(2),A=Q[0];async function G(){if(A==="init")try{await O()}catch(o){console.error(`
|
|
36
|
+
${g.red}\u274C Error: ${w(o)}${g.reset}`),process.exit(1)}else if(A==="deploy")try{await I()}catch(o){console.error(`
|
|
37
|
+
${g.red}\u274C Error: ${w(o)}${g.reset}`),process.exit(1)}else console.log(`
|
|
38
38
|
${g.bold}${g.cyan}CFM SDK CLI Tool${g.reset}`),console.log(`
|
|
39
|
-
Usage:`),console.log(" npx cfm-sdk init \u2013 Launch the survey setup wizard"),console.log(" npx cfm-sdk deploy \u2013 Deploy the current project to Vercel"),process.exit(0)}
|
|
39
|
+
Usage:`),console.log(" npx cfm-sdk init \u2013 Launch the survey setup wizard"),console.log(" npx cfm-sdk deploy \u2013 Deploy the current project to Vercel"),process.exit(0)}G();
|