create-chayns-app 1.2.12 → 1.2.13
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/index.cjs
CHANGED
|
@@ -110,7 +110,7 @@ ${e}`,gT=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),yT=Objec
|
|
|
110
110
|
`),c=o-1;i=[...l.slice(0,c),"... (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.#d()},this.#r.once("drain",this.#c)),this.#n=this.#p(i,n)}finally{r&&this.#u(()=>this.#r.write(QT))}return this}start(e){if(e&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let r=this.text?"-":"",i=" ".repeat(this.#e.indent)+this.#g(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&&Al.hide(this.#r),this.#e.discardStdin&&ar.default.stdin.isTTY&&(Ml.start(),this.#f=!0),this.#v(),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.#m(),this.#A(),this.#c&&(this.#r.removeListener("drain",this.#c),this.#c=void 0),this.isEnabled&&(this.clear(),this.#e.hideCursor&&Al.show(this.#r)),this.#f&&(this.#f=!1,Ml.stop()),this}succeed(e){return this.stopAndPersist({symbol:Rt.success,text:e})}fail(e){return this.stopAndPersist({symbol:Rt.error,text:e})}warn(e){return this.stopAndPersist({symbol:Rt.warning,text:e})}info(e){return this.stopAndPersist({symbol:Rt.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.#g(r,i,n,s)+`
|
|
113
|
-
`;return this.stop(),this.#u(()=>this.#r.write(o)),this}};function Dt(t){return new Ll(t)}var me=j(require("fs"),1),Ss=require("fs/promises");var jb={name:"create-chayns-app",version:"1.2.
|
|
113
|
+
`;return this.stop(),this.#u(()=>this.#r.write(o)),this}};function Dt(t){return new Ll(t)}var me=j(require("fs"),1),Ss=require("fs/promises");var jb={name:"create-chayns-app",version:"1.2.13",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.4",chalk:"^5.6.2",commander:"^14.0.3",enquirer:"^2.4.1",esbuild:"^0.27.4",eslint:"^9.39.4",execa:"^9.6.1","fast-glob":"^3.3.3","is-npm":"^6.1.0",ora:"^9.3.0",prettier:"^3.8.1","prettier-plugin-packagejson":"^3.0.2","validate-npm-package-name":"^7.0.2"},publishConfig:{access:"public"}};var Wr={page:"A complete page",pagemakerPlugin:"A pagemaker plugin"},Vr={v4:"v4 (Javascript api)",v5:"v5 (React api (new))"},Hn=[{name:"Yes",value:!0},{name:"No",value:!1}];var bs=j(require("path"),1),mr=require("fs/promises"),PS=j(RS(),1);async function Mt({destination:t,templateDir:e,adjustContent:r}){let n=(await(0,PS.default)("**/*",{cwd:e})).map(async s=>{let o=await(0,mr.readFile)(bs.default.join(e,s),{encoding:"utf-8"});typeof r=="function"&&(o=r(o));let a=s.replace("template-gitignore",".gitignore"),l=bs.default.join(t,a);await(0,mr.mkdir)(bs.default.join(l,".."),{recursive:!0}),await(0,mr.writeFile)(l,o)});await Promise.all(n)}function Lt(t,e){let r=t;for(let[i,n]of Object.entries(e))r=r.replace(new RegExp(`\\{\\{ ${i} \\}\\}`,"g"),n);return r}var DS={"chayns-components":"latest","prop-types":"latest",react:"18","react-dom":"18"},IS={"chayns-toolkit":"latest",prettier:"latest","prettier-plugin-packagejson":"latest"},$S=t=>({"@chayns-components/core":"latest","prop-types":"latest",react:String(t),"react-dom":String(t),"chayns-api":"latest"}),kS={"chayns-toolkit":"latest",prettier:"latest","prettier-plugin-packagejson":"latest"},MS={"react-redux":"latest","@reduxjs/toolkit":"latest"},LS=t=>({typescript:"5","@types/react":String(t),"@types/react-dom":String(t)}),BS={"@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"},NS={"@chayns/textstrings":"latest"},ws={"chayns-logger":"latest"};var jS=require("node:child_process");var _u=async(t,e)=>{let r=e?`${t}@${e}`:t,i=t in ws;try{let n=await new Promise((a,l)=>{(0,jS.exec)(`npm view ${r} version --json${i?" --registry https://repo.tobit.ag/repository/npm/":""}`,(c,u)=>{c?l(c):a(u.trim())})}),s=JSON.parse(n),o;return Array.isArray(s)?o=s.reduce((a,l)=>{let c=a.split(".").map(Number),u=l.split(".").map(Number);for(let h=0;h<Math.max(c.length,u.length);h++){let f=c[h]||0,d=u[h]||0;if(d>f)return l;if(d<f)return a}return a}):o=s,`^${o}`}catch{}return console.warn(`
|
|
114
114
|
Could not resolve ${Q.yellow(r)}`),e||"latest"};var qS=j(require("path"),1),HS=j(require("fs"),1);var i$=(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:{}}),FS=async({name:t,description:e="",devDependencies:r={},dependencies:i={},useTypescript:n,useVitest:s})=>{let o=i$(t,e);for(let[a,l]of Object.entries(r).sort(([c],[u])=>c.localeCompare(u)))o.devDependencies[a]=await _u(a,l);for(let[a,l]of Object.entries(i).sort(([c],[u])=>c.localeCompare(u)))o.dependencies[a]=await _u(a,l);return n&&(o.scripts["check-types"]="tsc"),s&&(o.scripts.test="vitest"),JSON.stringify(o,void 0,4)},Su=async({destination:t,projectVersion:e,reactVersion:r,useRedux:i,tobitInternal:n,...s})=>{let{useTypescript:o,useVitest:a}=s,l=Dt("Resolving latest versions of required dependencies").start(),c,u=qS.default.join(t,"package.json");if(e===Vr.v4)c=await FS({...s,dependencies:DS,devDependencies:IS});else{let h=$S(r),f={...kS};i&&Object.assign(h,MS),o&&(Object.assign(f,LS(r)),delete h["prop-types"]),a&&Object.assign(f,BS),n&&Object.assign(h,NS,ws),c=await FS({...s,dependencies:h,devDependencies:f})}l.succeed("Resolved latest versions of required dependencies"),HS.default.writeFileSync(u,c)};function _s(t){var e=t.match(/[A-Za-z][a-z]*/g)||[];return e.map(n$).join(" ")}function n$(t){return t.charAt(0).toUpperCase()+t.substring(1)}var US=({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:yt}=GS.default,s$=new Rb,Zr=__dirname;s$.version(jb.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(o$).parse(process.argv);async function o$({git:t,initialCommit:e,install:r,packageManager:i,moduleFederation:n,tobitInternal:s}){let o,a;if(s)try{(await fetch("https://repo.tobit.ag",{method:"HEAD",signal:AbortSignal.timeout(3e3)})).ok||(s=!1)}catch{s=!1}n||({projectVersion:o}=await yt({type:"select",name:"projectVersion",message:"What api version do you want to use?",choices:Object.values(Vr)}),{projectType:a}=await yt({type:"select",name:"projectType",message:"What type of project do you want to create?",choices:Object.values(Wr)}));let l=!1,c;for(;!l;){let{packageName:m}=await yt([{type:"input",name:"packageName",message:"What should the name of your project be?",initial:"my-awesome-project"}]),{validForNewPackages:x,errors:_=[],warnings:v=[]}=(0,WS.default)(m);if(x)l=!0,c=m;else{console.log(`
|
|
116
116
|
${Q.hex("#31D1DF")(`\`${m}\``)} is unfortunately not a valid project name, because:`);for(let S of[..._,...v])console.log(Q.hex("#94A3B8")(` - ${S}`));console.log("")}}let{summary:u}=await yt({type:"input",message:"How would you summarize this project in a few words?",name:"summary"});function h(m){return Lt(m,{"package-name":c,"readable-package-name":_s(c),description:u,"install-command":d==="yarn"?"yarn":"npm install","run-command":d==="yarn"?"yarn":"npm run","package-name-underscore":c.replace("-","_"),"logger-import":s?`import './utils/logger';
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { createAsyncThunk } from '@reduxjs/toolkit';
|
|
1
2
|
import { useDispatch, useSelector } from 'react-redux';
|
|
2
3
|
import type { RootState, AppDispatch } from '../redux-modules';
|
|
3
4
|
|
|
4
5
|
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
|
|
5
6
|
export const useAppSelector = useSelector.withTypes<RootState>();
|
|
7
|
+
export const createAppAsyncThunk = createAsyncThunk.withTypes<{ dispatch: AppDispatch; state: RootState }>();
|