@reveldigital/gadgetizer 1.0.7 → 1.0.9

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/README.md CHANGED
@@ -71,6 +71,7 @@ The Gadgetizer tool performs the following actions based on your project type:
71
71
  After running the tool, your project will have:
72
72
 
73
73
  - 📄 `gadget.yaml` - Gadget configuration file
74
+ - 📄 `deploy-to-pages.yml` (optional) - GitHub Actions workflow for automatic deployment to GitHub Pages
74
75
  - 📦 Updated `package.json` with Revel Digital dependencies
75
76
  - 🛠️ `build:gadget` npm script for regenerating the gadget XML
76
77
  - 🗂️ Generated XML file in your build/dist directory
@@ -101,12 +102,36 @@ prefs:
101
102
 
102
103
  Edit this file to customize your gadget's properties and user preferences.
103
104
 
105
+ ### Working with Preferences
106
+
107
+ Preferences defined in the `prefs` section become configurable options in the Revel Digital CMS, allowing end users to customize your gadget's behavior and appearance. You can access these preferences in your application code using the Revel Digital client SDK.
108
+
109
+ For detailed information about accessing preferences and using the client SDK in your gadget, see the [client SDK documentation](https://www.npmjs.com/package/@reveldigital/client-sdk).
110
+
111
+ ## 🚀 GitHub Pages Deployment (Optional)
112
+
113
+ The `deploy-to-pages.yml` file is an optional GitHub Actions workflow that provides automated building and deployment of your gadget to GitHub Pages. When placed in your project's `.github/workflows/` directory, this workflow will:
114
+
115
+ - **Automatically trigger** on pushes to your main branch
116
+ - **Build your project** using your existing build commands
117
+ - **Run the Gadgetizer** to generate the XML configuration
118
+ - **Deploy the result** to GitHub Pages for easy hosting and testing
119
+
120
+ To use this feature:
121
+
122
+ 1. Copy `deploy-to-pages.yml` to `.github/workflows/` in your project
123
+ 2. Customize the build commands for your specific project type
124
+ 3. Ensure GitHub Pages is enabled in your repository settings
125
+ 4. Push changes to your main branch to trigger automatic deployment
126
+
127
+ This makes it easy to share and test your gadgets with others by providing a publicly accessible URL.
128
+
104
129
  ## 🛠️ Supported Frameworks
105
130
 
106
- - **Angular** - Uses the official Revel Digital Angular schematic
107
- - **React** - Instruments with client SDK and generates gadget configuration
108
- - **Vue** - Instruments with client SDK and generates gadget configuration
109
- - **Vanilla JavaScript** - Instruments with client SDK and generates gadget configuration
131
+ - **Angular** - Uses the official Revel Digital Angular schematic.
132
+ - **React** - Instruments with client SDK and generates gadget configuration. [Sample Project](https://github.com/RevelDigital/gadget-demo-react)
133
+ - **Vue** - Instruments with client SDK and generates gadget configuration. [Sample Project](https://github.com/RevelDigital/gadget-demo-vue)
134
+ - **Vanilla JavaScript** - Instruments with client SDK and generates gadget configuration.
110
135
 
111
136
  ## 📚 Revel Digital Client SDK
112
137
 
package/dist/cli.js CHANGED
@@ -48,7 +48,7 @@ Options:
48
48
  Description:
49
49
  Integrates the Revel Digital SDK into your project and generates gadget XML.
50
50
  Supports React, Vue, Angular, and vanilla JavaScript projects.
51
- `)),process.exit(0)),console.log("dir:"+oM),oG&&(o8({projectPath:process.cwd(),__dirname:oM}),process.exit(0));let oV=await e5({message:"Select your project framework:",options:[{value:"react",label:"React"},{value:"vue",label:"Vue"},{value:"angular",label:"Angular"},{value:"js",label:"Vanilla JavaScript"}]}),oH="";switch(oV){case"react":oH=n.existsSync(o.join(oz,"src","App.tsx"))?o.join("src","App.tsx"):"";break;case"vue":oH=n.existsSync(o.join(oz,"src","App.vue"))?o.join("src","App.vue"):"";break;case"angular":oH=n.existsSync(o.join(oz,"src","main.ts"))?o.join("src","main.ts"):"";break;case"js":oH=n.existsSync(o.join(oz,"src","main.js"))?o.join("src","main.js"):""}oH||e6(X(ea).yellow(`\u{26A0}\u{FE0F} Could not automatically detect the main entry file for ${oV}. Please manually instrument your app with the Revel Digital SDK.`));let oW=o.join(oz,"package.json");if(n.existsSync(oW)||(e6(X(ea).red("❌ No package.json found in this directory. Please run this tool from your project root.")),process.exit(1)),"angular"===oV){e6(X(ea).cyan("\uD83D\uDCE6 Installing @reveldigital/player-client and running ng add schematic..."));try{r("npm install @reveldigital/player-client@latest",{stdio:"inherit"}),r("ng add @reveldigital/player-client@latest",{stdio:"inherit"}),e6(X(ea).green("✅ Angular project successfully instrumented with Revel Digital Player Client.")),process.exit(0)}catch(e){e6(X(ea).red("❌ Error instrumenting Angular project. Please check your Angular CLI and npm setup.")),process.exit(1)}}let o$=o.join(oM,"assets","gadget.yaml"),oY=o.join(oz,"gadget.yaml");if(n.existsSync(oY))e6(X(ea).yellow("⚠️ gadget.yaml already exists in project root. Skipping copy."));else try{n.copyFileSync(o$,oY),e6(X(ea).green("\uD83D\uDCC4 gadget.yaml copied to project root."))}catch(e){e6(X(ea).red("❌ Failed to copy gadget.yaml to project root. Please copy it manually."))}if(await e8({message:"Add GitHub Actions workflow for automatic Pages deployment?"})){let e=o.join(oz,".github","workflows"),t=o.join(oM,"assets","deploy-to-pages.yaml"),r=o.join(e,"deploy-to-pages.yaml");try{n.existsSync(e)||n.mkdirSync(e,{recursive:!0}),n.existsSync(r)?e6(X(ea).yellow("⚠️ GitHub Actions workflow already exists. Skipping copy.")):(n.copyFileSync(t,r),e6(X(ea).green("\uD83D\uDCC4 GitHub Actions workflow copied to .github/workflows/deploy-to-pages.yaml")),e6(X(ea).cyan("ℹ️ Don't forget to enable GitHub Pages in your repository settings!")))}catch(e){e6(X(ea).red("❌ Failed to copy GitHub Actions workflow. Please copy deploy-to-pages.yaml manually."))}}let oX="";try{oX=await new Promise((e,t)=>{((...e)=>ee("h0Fpa").then(({default:t})=>t(...e)))(oW).then(r=>{try{let t=r.split("/"),n=`https://${t[3]}.github.io/${t[4].split(".")[0]}/`;e(n)}catch(e){t(e)}}).catch(t)}),e6(X(ea).cyan(`\u{1F30E} Configuring gadget deployment URL based on Git: ${oX}`))}catch(e){oX="",e6(X(ea).yellow(`\u{26A0}\u{FE0F} Warning: Could not get deployment URL automatically.`))}let oJ=await e3({message:"Enter the deployment URL:",initialValue:oX}),oK=await e5({message:"Select Revel Digital SDK version to install:",options:[{value:"latest",label:"Latest"},{value:"custom",label:"Custom version"}]}),oQ="";"custom"===oK&&(oQ=await e3({message:"Enter the custom SDK version:"}));let oZ=JSON.parse(n.readFileSync(oW,"utf8"));if(await e8({message:`Install Revel Digital SDK (${"custom"===oK?oQ:oK})?`})){oZ.dependencies=oZ.dependencies||{},oZ.dependencies["@reveldigital/gadget-types"]="latest";let e="custom"===oK?oQ:oK;oZ.dependencies["@reveldigital/client-sdk"]="latest"===e?"latest":e,n.writeFileSync(oW,JSON.stringify(oZ,null,2)),e6(X(ea).cyan(`\u{1F389} Revel Digital SDK (${e}) added to dependencies.`));try{r("npm install",{stdio:"inherit"}),e6(X(ea).green("\uD83D\uDCE6 npm install completed successfully."))}catch(e){e6(X(ea).red("❌ npm install failed. Please run it manually."))}}let o0=o.join(oz,"vite.config.js"),o1=o.join(oz,"vite.config.ts"),o2=o.join(oz,"vue.config.js"),o3="";if(n.existsSync(o0)?o3=o0:n.existsSync(o1)&&(o3=o1),o3)try{let e=n.readFileSync(o3,"utf8");/\bbase\s*:/.test(e)?(e=e.replace(/(\bbase\s*:\s*['"])[^'"]*(['"])/,`$1${oJ}$2`),e6(X(ea).yellow(`\u{1F527} Updated "base" in ${o.basename(o3)}.`))):e.includes("defineConfig({")&&(e=e.replace(/(defineConfig\({)/,`$1
51
+ `)),process.exit(0)),console.log("dir:"+oM),oG&&(o8({projectPath:process.cwd(),__dirname:oM}),process.exit(0));let oV=await e5({message:"Select your project framework:",options:[{value:"react",label:"React"},{value:"vue",label:"Vue"},{value:"angular",label:"Angular"},{value:"js",label:"Vanilla JavaScript"}]}),oH="";switch(oV){case"react":oH=n.existsSync(o.join(oz,"src","App.tsx"))?o.join("src","App.tsx"):"";break;case"vue":oH=n.existsSync(o.join(oz,"src","App.vue"))?o.join("src","App.vue"):"";break;case"angular":oH=n.existsSync(o.join(oz,"src","main.ts"))?o.join("src","main.ts"):"";break;case"js":oH=n.existsSync(o.join(oz,"src","main.js"))?o.join("src","main.js"):""}oH||e6(X(ea).yellow(`\u{26A0}\u{FE0F} Could not automatically detect the main entry file for ${oV}. Please manually instrument your app with the Revel Digital SDK.`));let oW=o.join(oz,"package.json");if(n.existsSync(oW)||(e6(X(ea).red("❌ No package.json found in this directory. Please run this tool from your project root.")),process.exit(1)),"angular"===oV){e6(X(ea).cyan("\uD83D\uDCE6 Installing @reveldigital/player-client and running ng add schematic..."));try{r("npm install @reveldigital/player-client@latest",{stdio:"inherit"}),r("ng add @reveldigital/player-client@latest",{stdio:"inherit"}),e6(X(ea).green("✅ Angular project successfully instrumented with Revel Digital Player Client.")),process.exit(0)}catch(e){e6(X(ea).red("❌ Error instrumenting Angular project. Please check your Angular CLI and npm setup.")),process.exit(1)}}let o$=o.join(oM,"assets","gadget.yaml"),oY=o.join(oz,"gadget.yaml");if(n.existsSync(oY))e6(X(ea).yellow("⚠️ gadget.yaml already exists in project root. Skipping copy."));else try{n.copyFileSync(o$,oY),e6(X(ea).green("\uD83D\uDCC4 gadget.yaml copied to project root."))}catch(e){e6(X(ea).red("❌ Failed to copy gadget.yaml to project root. Please copy it manually."))}if(await e8({message:"Add GitHub Actions workflow for automatic Pages deployment?"})){let e=o.join(oz,".github","workflows"),t=o.join(oM,"assets","deploy-to-pages.yml"),r=o.join(e,"deploy-to-pages.yml");try{n.existsSync(e)||n.mkdirSync(e,{recursive:!0}),n.existsSync(r)?e6(X(ea).yellow("⚠️ GitHub Actions workflow already exists. Skipping copy.")):(n.copyFileSync(t,r),e6(X(ea).green("\uD83D\uDCC4 GitHub Actions workflow copied to .github/workflows/deploy-to-pages.yml")),e6(X(ea).cyan("ℹ️ Don't forget to enable GitHub Pages in your repository settings!")))}catch(e){e6(X(ea).red("❌ Failed to copy GitHub Actions workflow. Please copy deploy-to-pages.yml manually."))}}let oX="";try{oX=await new Promise((e,t)=>{((...e)=>ee("h0Fpa").then(({default:t})=>t(...e)))(oW).then(r=>{try{let t=r.split("/"),n=`https://${t[3]}.github.io/${t[4].split(".")[0]}/`;e(n)}catch(e){t(e)}}).catch(t)}),e6(X(ea).cyan(`\u{1F30E} Configuring gadget deployment URL based on Git: ${oX}`))}catch(e){oX="",e6(X(ea).yellow(`\u{26A0}\u{FE0F} Warning: Could not get deployment URL automatically.`))}let oJ=await e3({message:"Enter the deployment URL:",initialValue:oX}),oK=await e5({message:"Select Revel Digital SDK version to install:",options:[{value:"latest",label:"Latest"},{value:"custom",label:"Custom version"}]}),oQ="";"custom"===oK&&(oQ=await e3({message:"Enter the custom SDK version:"}));let oZ=JSON.parse(n.readFileSync(oW,"utf8"));if(await e8({message:`Install Revel Digital SDK (${"custom"===oK?oQ:oK})?`})){oZ.dependencies=oZ.dependencies||{},oZ.dependencies["@reveldigital/gadget-types"]="latest";let e="custom"===oK?oQ:oK;oZ.dependencies["@reveldigital/client-sdk"]="latest"===e?"latest":e,n.writeFileSync(oW,JSON.stringify(oZ,null,2)),e6(X(ea).cyan(`\u{1F389} Revel Digital SDK (${e}) added to dependencies.`));try{r("npm install",{stdio:"inherit"}),e6(X(ea).green("\uD83D\uDCE6 npm install completed successfully."))}catch(e){e6(X(ea).red("❌ npm install failed. Please run it manually."))}}let o0=o.join(oz,"vite.config.js"),o1=o.join(oz,"vite.config.ts"),o2=o.join(oz,"vue.config.js"),o3="";if(n.existsSync(o0)?o3=o0:n.existsSync(o1)&&(o3=o1),o3)try{let e=n.readFileSync(o3,"utf8");/\bbase\s*:/.test(e)?(e=e.replace(/(\bbase\s*:\s*['"])[^'"]*(['"])/,`$1${oJ}$2`),e6(X(ea).yellow(`\u{1F527} Updated "base" in ${o.basename(o3)}.`))):e.includes("defineConfig({")&&(e=e.replace(/(defineConfig\({)/,`$1
52
52
  base: '${oJ}',`),e6(X(ea).green(`\u{1F527} Added "base" to ${o.basename(o3)}.`))),n.writeFileSync(o3,e)}catch(e){e6(X(ea).red(`\u{274C} Failed to update ${o.basename(o3)}. Please set the "base" property manually.`))}else if(n.existsSync(o2))try{let e=n.readFileSync(o2,"utf8");/\bpublicPath\s*:/.test(e)?(e=e.replace(/(\bpublicPath\s*:\s*['"])[^'"]*(['"])/,`$1${oJ}$2`),e6(X(ea).yellow('\uD83D\uDD27 Updated "publicPath" in vue.config.js.'))):e.includes("module.exports = {")&&(e=e.replace(/(module.exports = {)/,`$1
53
53
  publicPath: '${oJ}',`),e6(X(ea).green('\uD83D\uDD27 Added "publicPath" to vue.config.js.'))),n.writeFileSync(o2,e)}catch(e){e6(X(ea).red('❌ Failed to update vue.config.js. Please set the "publicPath" property manually.'))}function o8({projectPath:e,__dirname:t}){let r=o.join(e,"package.json"),i=JSON.parse(n.readFileSync(r,"utf8")),a=o.join(e,"gadget.yaml"),u=[o.join(e,"dist","index.html"),o.join(e,"public","index.html")],s="";for(let e of u)if(n.existsSync(e)){s=e;break}s||(e6(X(ea).red("❌ index.html not found in public/, src/, or project root. Please add it and re-run the tool.")),process.exit(1));let l=o.join(o.dirname(s));try{let e=`${i.name}.xml`;!function(e,t,r,o="1.0"){try{let i=rt(n.readFileSync(e,"utf8")),a=n.readFileSync(t),u=oj(i,a,o);n.writeFileSync(r,u)}catch(e){return console.error(e),!1}}(a,s,o.join(l,e),i.version),e6(X(ea).green(`\u{2705} Gadget XML file "${e}" generated in dist folder.`))}catch(e){e6(X(ea).red("❌ Failed to generate XML file. Please check yml2xml.js and your input files."))}}(oZ.dependencies&&oZ.dependencies.parcel||oZ.devDependencies&&oZ.devDependencies.parcel)&&(oZ.targets=oZ.targets||{},oZ.targets.default=oZ.targets.default||{},oZ.targets.default.publicUrl=oJ,e6(X(ea).green('\uD83D\uDD27 Set "targets.default.publicUrl" in package.json for Parcel.'))),oZ.scripts=oZ.scripts||{},oZ.scripts["build:gadget"]="npm run build && npx gadgetizer --build-only",n.writeFileSync(oW,JSON.stringify(oZ,null,2)),e6(X(ea).green('\uD83D\uDD27 Added "build:gadget" script to package.json.')),o8({projectPath:oz,__dirname:oM});
54
54
  //# sourceMappingURL=cli.js.map