create-chayns-app 1.3.0-beta.1 → 1.3.0
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 +15 -19
- package/dist/index.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,18 +75,18 @@ yarn dev
|
|
|
75
75
|
|
|
76
76
|
You need to develop the project in a chayns-environment for all features to work
|
|
77
77
|
properly. You have to create a Page on a chayns-Site you can manage, if you do
|
|
78
|
-
not have one yet, create one [here](https://chayns.
|
|
78
|
+
not have one yet, create one [here](https://chayns.site/).
|
|
79
79
|
|
|
80
80
|
After finishing the setup of your site, head to **Administration > Content >
|
|
81
|
-
Pages** and
|
|
81
|
+
Pages** and choose the "Add Page" option via the floating button in the bottom right corner.
|
|
82
82
|
|
|
83
|
-

|
|
84
84
|
|
|
85
|
-
Choose the "
|
|
85
|
+
Choose the "External website" option and enter a name you like (e.g. "Local
|
|
86
86
|
Development"). Set the source to `http://localhost:1234/`, the address at which
|
|
87
87
|
your local development server operates.
|
|
88
88
|
|
|
89
|
-

|
|
90
90
|
|
|
91
91
|
Your freshly created page should appear in the menu. Navigate to the page by
|
|
92
92
|
clicking it.
|
|
@@ -117,26 +117,26 @@ properly. You have to create a Page on a chayns-Site you can manage, if you do
|
|
|
117
117
|
not have one yet, create one [here](https://chayns.net/).
|
|
118
118
|
|
|
119
119
|
After finishing the setup of your site, head to **Administration > Content >
|
|
120
|
-
Pages** and
|
|
120
|
+
Pages** and choose the "Add Page" option via the floating button in the bottom right corner.
|
|
121
121
|
|
|
122
|
-

|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Enter a name you like (e.g. "Local
|
|
125
125
|
Development"). Click the "Add" button to create the Page.
|
|
126
126
|
|
|
127
|
-

|
|
128
128
|
|
|
129
129
|
Your freshly created page should appear in the menu. Navigate to the page by
|
|
130
130
|
clicking it. There we want to enter _"admin-mode"_ by activating the switch in
|
|
131
131
|
the main menu, next to the name of your Site.
|
|
132
132
|
|
|
133
|
-

|
|
134
134
|
|
|
135
135
|
A floating button with a big plus sign should appear in the bottom right corner.
|
|
136
|
-
Click it and choose **
|
|
136
|
+
Click it and choose **Plugins > Iframe** in the flyout-menu to add an iframe
|
|
137
137
|
to your Page.
|
|
138
138
|
|
|
139
|
-

|
|
140
140
|
|
|
141
141
|
Hover over your newly created iframe and activate the chayns-API by clicking on
|
|
142
142
|
the code-symbol and confirming your choice in the dialog.
|
|
@@ -147,7 +147,7 @@ Now we have to set the iframe source (_"Quelle"_) to the address of your local
|
|
|
147
147
|
development server by tapping on the gear-icon and entering
|
|
148
148
|
`http://localhost:1234/` in the second input field.
|
|
149
149
|
|
|
150
|
-

|
|
151
151
|
|
|
152
152
|
**Congrats!** You are now ready to develop your Pagemaker plugin! Start making
|
|
153
153
|
changes to your code and you should see them reflected on your Page in
|
|
@@ -171,10 +171,6 @@ especially non-developers.
|
|
|
171
171
|
|
|
172
172
|
### How can I deploy the application so it will be permanently available to all users of my Site?
|
|
173
173
|
|
|
174
|
-
The
|
|
175
|
-
like [Vercel](https://vercel.com/home) or [Netlify](https://www.netlify.com/).
|
|
176
|
-
These services will deploy any project for you, aslong as it is managed with a
|
|
177
|
-
Git repository on GitHub or similar services.
|
|
174
|
+
The simplest way of deploying your app is to build it locally via `chayns-toolkit build` and then upload the build directory in the chayns space of your site.
|
|
178
175
|
|
|
179
|
-
|
|
180
|
-
they ask for a publish directory, enter `build`.
|
|
176
|
+
There is currently no automated deployment solution for chayns® projects, but we might look into this in the future. Especially during the process of improving our online IDE and the consistency between the local development environment and the online IDE.
|
package/dist/index.cjs
CHANGED
|
@@ -110,7 +110,7 @@ ${e}`,wT=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),_T=Objec
|
|
|
110
110
|
`),u=o-1;i=[...l.slice(0,u),"... (content truncated to fit terminal)"].join(`
|
|
111
111
|
`)}this.#u(()=>this.#r.write(i))===!1&&this.#r.isTTY&&(this.#c=()=>{this.#c=void 0,this.#m()},this.#r.once("drain",this.#c)),this.#n=this.#d(i,n)}finally{r&&this.#u(()=>this.#r.write(JT))}return this}start(e){if(e!==void 0&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let r=this.text?"-":"",i=" ".repeat(this.#e.indent)+this.#y(r,this.text,this.#e.prefixText,this.#e.suffixText);return i.trim()!==""&&this.#u(()=>this.#r.write(i+`
|
|
112
112
|
`)),this}return this.isSpinning?this:(this.#e.hideCursor&&Ol.hide(this.#r),this.#e.discardStdin&&hr.default.stdin.isTTY&&(Ll.start(),this.#p=!0),this.#A(),this.render(),this.#o=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#o),this.#o=void 0,this.#i=-1,this.#t=0,this.#g(),this.#O(),this.#c&&(this.#r.removeListener("drain",this.#c),this.#c=void 0),this.isEnabled&&(this.clear(),this.#e.hideCursor&&Ol.show(this.#r)),this.#p&&(this.#p=!1,Ll.stop()),this}succeed(e){return this.stopAndPersist({symbol:$t.success,text:e})}fail(e){return this.stopAndPersist({symbol:$t.error,text:e})}warn(e){return this.stopAndPersist({symbol:$t.warning,text:e})}info(e){return this.stopAndPersist({symbol:$t.info,text:e})}stopAndPersist(e={}){if(this.isSilent)return this;let r=e.symbol??" ",i=e.text??this.text,n=e.prefixText??this.#e.prefixText,s=e.suffixText??this.#e.suffixText,o=this.#y(r,i,n,s)+`
|
|
113
|
-
`;return this.stop(),this.#u(()=>this.#r.write(o)),this}};function kt(t){return new Bl(t)}var ge=j(require("fs"),1),Es=require("fs/promises");var Fb={name:"create-chayns-app",version:"1.3.0
|
|
113
|
+
`;return this.stop(),this.#u(()=>this.#r.write(o)),this}};function kt(t){return new Bl(t)}var ge=j(require("fs"),1),Es=require("fs/promises");var Fb={name:"create-chayns-app",version:"1.3.0",private:!1,description:"Create a new chayns\xAE development project in one command.",keywords:["chayns","react","chayns-toolkit","chayns-components","starter-kit"],bugs:{url:"https://github.com/TobitSoftware/create-chayns-app/issues",email:"leonhard.driesch@tobit.com"},repository:{type:"git",url:"git+https://github.com/TobitSoftware/create-chayns-app.git"},license:"MIT",author:{name:"Leonhard Driesch",email:"leonhard.driesch@tobit.com"},main:"index.js",bin:{"create-chayns-app":"dist/index.cjs"},type:"module",files:["dist","templates"],engines:{node:">=18"},scripts:{build:"node ./scripts/build.js",watch:"node ./scripts/watch.js",format:"prettier . --ignore-path .gitignore --write",prepublishOnly:"npm run build",start:"node src/index.js"},devDependencies:{"@eslint/js":"^9.39.5",chalk:"^5.6.2",commander:"^14.0.3",enquirer:"^2.4.1",esbuild:"^0.28.1",eslint:"^9.39.5",execa:"^9.6.1","fast-glob":"^3.3.3","is-npm":"^6.1.0",ora:"^9.4.1",prettier:"^3.9.6","prettier-plugin-packagejson":"^3.0.2","validate-npm-package-name":"^7.0.2"},publishConfig:{access:"public"}};var tt={page:"A complete page",pagemakerPlugin:"A pagemaker plugin",moduleFederation:"A module federation module"},mt={v4:"v4 (Javascript api)",v5:"v5 (React api (new))"},Mt=[{name:"Yes",value:!0},{name:"No",value:!1}];var ws=j(require("path"),1),wr=require("fs/promises"),$S=j(IS(),1);async function jt({destination:t,templateDir:e,adjustContent:r}){let n=(await(0,$S.default)("**/*",{cwd:e})).map(async s=>{let o=await(0,wr.readFile)(ws.default.join(e,s),{encoding:"utf-8"});typeof r=="function"&&(o=r(o));let a=s.replace("template-gitignore",".gitignore"),l=ws.default.join(t,a);await(0,wr.mkdir)(ws.default.join(l,".."),{recursive:!0}),await(0,wr.writeFile)(l,o)});await Promise.all(n)}function Ft(t,e){let r=t;for(let[i,n]of Object.entries(e))r=r.replace(new RegExp(`\\{\\{ ${i} \\}\\}`,"g"),n);return r}var kS={"chayns-components":"latest","prop-types":"latest",react:"18","react-dom":"18"},MS={"chayns-toolkit":"latest",prettier:"latest","prettier-plugin-packagejson":"latest"},LS=t=>({"@chayns-components/core":"latest","prop-types":"latest",react:String(t),"react-dom":String(t),"chayns-api":"latest"}),BS={"chayns-toolkit":"latest",prettier:"latest","prettier-plugin-packagejson":"latest"},NS={"react-redux":"latest","@reduxjs/toolkit":"latest"},jS=t=>({typescript:"5","@types/react":String(t),"@types/react-dom":String(t)}),FS={"@testing-library/jest-dom":"latest","@testing-library/react":"latest","@testing-library/user-event":"latest","@vitejs/plugin-react":"latest","@vitest/coverage-v8":"latest",jsdom:"latest",vitest:"latest"},qS={"@chayns/textstrings":"latest"},_s={"chayns-logger":"latest"};var HS=require("node:child_process");var Ss=async(t,e)=>{let r=e?`${t}@${e}`:t,i=t in _s;try{let n=await new Promise((a,l)=>{(0,HS.exec)(`npm view ${r} version --json${i?" --registry https://repo.tobit.ag/repository/npm/":""}`,(u,c)=>{u?l(u):a(c.trim())})}),s=JSON.parse(n),o;return Array.isArray(s)?o=s.reduce((a,l)=>{let u=a.split(".").map(Number),c=l.split(".").map(Number);for(let h=0;h<Math.max(u.length,c.length);h++){let f=u[h]||0,m=c[h]||0;if(m>f)return l;if(m<f)return a}return a}):o=s,`^${o}`}catch{}return console.warn(`
|
|
114
114
|
Could not resolve ${Z.yellow(r)}`),e||"latest"};var GS=j(require("path"),1),WS=j(require("fs"),1);var p$=["react","react-dom"],d$=t=>{let e=t.match(/^(?:[~^])?(\d+)\.(\d+)\.\d+/);return e?`^${e[1]}.${e[2]}.0`:t},m$=(t,e)=>({name:t,version:"1.0.0",private:!0,description:e,keywords:["chayns","chayns-toolkit","react"],scripts:{build:"chayns-toolkit build",dev:"chayns-toolkit dev",start:"chayns-toolkit dev",format:"prettier . --write",lint:"chayns-toolkit lint"},prettier:{proseWrap:"always",singleQuote:!0,tabWidth:4,printWidth:100},dependencies:{},devDependencies:{}}),US=async({name:t,description:e="",devDependencies:r={},dependencies:i={},peerDependencies:n={},useTypescript:s,useVitest:o})=>{let a=m$(t,e);for(let[u,c]of Object.entries(r).sort(([h],[f])=>h.localeCompare(f)))a.devDependencies[u]=await Ss(u,c);for(let[u,c]of Object.entries(i).sort(([h],[f])=>h.localeCompare(f)))a.dependencies[u]=await Ss(u,c);let l=Object.entries(n).sort(([u],[c])=>u.localeCompare(c));if(l.length){a.peerDependencies={};for(let[u,c]of l){let h=a.devDependencies[u]||await Ss(u,c);a.peerDependencies[u]=d$(h)}}return s&&(a.scripts["check-types"]="tsc"),o&&(a.scripts.test="vitest"),JSON.stringify(a,void 0,4)},xu=async({destination:t,projectVersion:e,reactVersion:r,useRedux:i,tobitInternal:n,moduleFederation:s,...o})=>{let{useTypescript:a,useVitest:l}=o,u=kt("Resolving latest versions of required dependencies").start(),c,h=GS.default.join(t,"package.json");if(e===mt.v4)c=await US({...o,dependencies:kS,devDependencies:MS});else{let f=LS(r),m={...BS},p={};if(s)for(let d of p$)m[d]=f[d],p[d]=f[d],delete f[d];i&&Object.assign(f,NS),a&&(Object.assign(m,jS(r)),delete f["prop-types"]),l&&Object.assign(m,FS),n&&Object.assign(f,qS,_s),c=await US({...o,dependencies:f,devDependencies:m,peerDependencies:p})}u.succeed("Resolved latest versions of required dependencies"),WS.default.writeFileSync(h,c)};function xs(t){var e=t.match(/[A-Za-z][a-z]*/g)||[];return e.map(g$).join(" ")}function g$(t){return t.charAt(0).toUpperCase()+t.substring(1)}var VS=({useTypescript:t,moduleFederation:e,useRedux:r,tobitInternal:i,packageNameUnderscore:n})=>{let s=[],o=0,a=[];e&&t&&a.push("ComponentPropsWithoutRef"),e&&r&&a.push("useState");let l=a.length?`, { ${a.join(", ")} }`:"";return s.push(`import React${l} from 'react';`),r&&s.push("import { Provider } from 'react-redux';"),s.push(`import { ChaynsProvider${e?", withCompatMode":""} } from 'chayns-api';`),s.push("import { PageProvider } from '@chayns-components/core';"),i&&s.push("import { TextStringProvider } from '@chayns/textstrings';"),s.push("import App from './App';"),r&&s.push(`import ${e?"{ createStore }":"store"} from '../redux-modules';`),i&&e&&s.push("import '../utils/logger';"),s.push(""),i&&(s.push("// TODO: insert your libraryName"),s.push("const libraries = ['<libraryName>'];"),s.push("")),e&&r?(s.push(`const AppWrapper = (${e?"props":""}${e&&t?": ComponentPropsWithoutRef<typeof ChaynsProvider>":""}) => {`),o+=4,s.push(`${" ".repeat(o)}const [store] = useState(createStore);`),s.push(""),s.push(`${" ".repeat(o)}return (`)):s.push(`const AppWrapper = (${e?"props":""}${e&&t?": ComponentPropsWithoutRef<typeof ChaynsProvider>":""}) => (`),o+=4,e&&(s.push(`${" ".repeat(o)}<div className="${n}">`),o+=4),s.push(`${" ".repeat(o)}<ChaynsProvider${e?" {...props}":""}>`),o+=4,r&&(s.push(`${" ".repeat(o)}<Provider store={store}>`),o+=4),s.push(`${" ".repeat(o)}<PageProvider>`),o+=4,i&&(s.push(`${" ".repeat(o)}<TextStringProvider libraries={libraries}>`),o+=4),s.push(`${" ".repeat(o)}<App />`),i&&(o-=4,s.push(`${" ".repeat(o)}</TextStringProvider>`)),o-=4,s.push(`${" ".repeat(o)}</PageProvider>`),r&&(o-=4,s.push(`${" ".repeat(o)}</Provider>`)),o-=4,s.push(`${" ".repeat(o)}</ChaynsProvider>`),e&&(o-=4,s.push(`${" ".repeat(o)}</div>`)),e&&r?(o-=4,s.push(`${" ".repeat(o)});`),s.push("};")):s.push(");"),s.push(""),e?s.push("export default withCompatMode(AppWrapper);"):s.push("export default AppWrapper;"),s.push(""),s.join(`
|
|
115
115
|
`)};var{prompt:ke}=zS.default,y$=new Pb,ri=__dirname,b$=async()=>{try{return(await fetch("https://repo.tobit.ag",{method:"HEAD",signal:AbortSignal.timeout(3e3)})).ok}catch{return!1}};y$.version(Fb.version).option("-G, --no-git","initialize the project without a git repository").option("-C, --no-initial-commit","don't perform an initial commit").option("-I, --no-install","don't install packages after initialization").option("-M, --module-federation","install to use as module (only internal)").option("-T, --tobit-internal","includes tobit internal packages (chayns-logger and @chayns/textstrings)").option("-p, --package-manager <manager>","specify the package manager to use (`npm` or `yarn`). Defaults to the one used to execute the command.").action((t,e)=>w$(t,e)).parse(process.argv);async function w$({git:t,initialCommit:e,install:r,packageManager:i,moduleFederation:n,tobitInternal:s},o){let a,l,u,c=async()=>(u??=b$(),u);n?(a=mt.v5,l=tt.moduleFederation):({projectVersion:a}=await ke({type:"select",name:"projectVersion",message:"What api version do you want to use?",choices:Object.values(mt),initial:1}),{projectType:l}=await ke({type:"select",name:"projectType",message:"What type of project do you want to create?",choices:a===mt.v5?Object.values(tt):[tt.page,tt.pagemakerPlugin],initial:0}),n=l===tt.moduleFederation),!n&&a!==mt.v5?s=!1:c();let h=!1,f;for(;!h;){let{packageName:x}=await ke([{type:"input",name:"packageName",message:"What should the name of your project be?",initial:"my-awesome-project"}]),{validForNewPackages:S,errors:P=[],warnings:O=[]}=(0,YS.default)(x);if(S)h=!0,f=x;else{console.log(`
|
|
116
116
|
${Z.hex("#31D1DF")(`\`${x}\``)} is unfortunately not a valid project name, because:`);for(let C of[...P,...O])console.log(Z.hex("#94A3B8")(` - ${C}`));console.log("")}}let{summary:m}=await ke({type:"input",message:"How would you summarize this project in a few words?",name:"summary"});function p(x){return Ft(x,{"package-name":f,"readable-package-name":xs(f),description:m,"install-command":E==="yarn"?"yarn":"npm install","run-command":E==="yarn"?"yarn":"npm run","package-name-underscore":f.replace("-","_"),"logger-import":s?`import './utils/logger';
|