chayns-toolkit 2.0.8 → 2.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.
Files changed (3) hide show
  1. package/cli.js +0 -0
  2. package/lib/cli.js +1 -1
  3. package/package.json +2 -2
package/cli.js CHANGED
File without changes
package/lib/cli.js CHANGED
@@ -49,7 +49,7 @@ ${d.substring(B)}`}if(d){let B=t==="production"?{removeComments:!0,collapseWhite
49
49
  module.exports = `;var Ys=F(require("fs"));function c_({config:t}){let{cert:e,key:r}=t.development,n=!1;return r&&!e||!r&&e?(q.error(`You have specified the ${D.code(r?"key":"cert")} field in your ${D.path`chayns-toolkit.json`} file, but not ${D.code(r?"cert":"key")}. You need to specify paths in both fields for SSL to work.`),n=!0):(r&&(Ys.existsSync(r)||(q.error(`No file exists at the ${D.code`key`} path specified in ${D.path`chayns-toolkit.json`}.`),n=!0)),e&&(Ys.existsSync(e)||(q.error(`No file exists at the ${D.code`cert`} path specified in ${D.path`chayns-toolkit.json`}.`),n=!0))),n}var f_=F(require("fs")),p_=F(require("path")),h_=F(require("util")),wR=(0,h_.promisify)(f_.readFile);async function Js(t){let e=p_.resolve("package.json"),r=await wR(e,{encoding:"utf-8"}),n=JSON.parse(r),i=Object.keys(H(H({},n.dependencies),n.devDependencies));return Array.isArray(t)?i.filter(s=>t.some(o=>d_(o)?o.test(s):o===s)):d_(t)?i.some(s=>t.test(s)):i.includes(t)}function d_(t){return Object.prototype.toString.call(t)==="[object RegExp]"}async function m_(t){let e=await Js("@types/react"),r=await Js("@types/react-dom"),n=[!e&&"@types/react",!r&&"@types/react-dom"].filter(Boolean);if(n.length>0){let i=n.map(s=>D.code(s)).join(" and ");q.hint(`You should install the ${i} package${n.length>0?"s":""} to get TypeScript support for React.
50
50
  `),t!==void 0&&q.blank(`Install them by running ${rt.install(t,n,!0)}`)}}async function g_(){var n;if(!j.hasFile("tsconfig.json"))return!0;let r=((n=await j.readFile("tsconfig.json"))!=null?n:"").replace(/\s/gi,"");return r===""||r==="{}"}var Cb=F(Ab());async function Ob(){return j.hasFile("tsconfig.json")?!0:(await(0,Cb.default)("src/**/*.{ts,tsx}")).length>0}async function Pb({packageJson:t,packageManager:e}){let r=Zr(t,"typescript"),n=await g_();return r?(await m_(e),n&&await Tb(),!1):await Ob()?(n&&await Tb(),q.error(`To use TypeScript, you have to install the ${D.code`typescript`} package by running ${rt.install(e,"typescript",!0)}.`),!0):!1}async function Tb(){await j.writeFile("tsconfig.json",JSON.stringify(vM,void 0,4)),q.info(`Seems like you want to use TypeScript. A ${D.path`tsconfig.json`} file has been set up for you.`)}var vM={compilerOptions:{allowJs:!0,allowSyntheticDefaultImports:!0,checkJs:!1,esModuleInterop:!0,experimentalDecorators:!0,isolatedModules:!0,jsx:"react",lib:["DOM","ESNext"],noEmit:!0,skipLibCheck:!0,strict:!0}};var ai=F(require("tcp-port-used"));async function Rb({config:t}){let{port:e,host:r}=t.development;if(await(0,ai.check)(e,r)){q.warn(`The port ${D.number(e)} on host ${D.code(r)} is already in use. Waiting for it to free up...`);try{return await(0,ai.waitUntilFreeOnHost)(e,r,500,6e4),q.info("Is has freed up. Starting the development server..."),!1}catch{return q.error("The port did not free up within 60 seconds."),!0}}return!1}function Fb(){let t=xM.some(r=>j.hasFile(r)),e=SM.some(r=>j.hasFile(r));if(t&&e&&(q.warn(`You have both ${D.path`package-lock.json`} and ${D.path`yarn.lock`} files in your project.
51
51
  `),q.blank("Decide on wether you want to use Yarn or NPM and remove one of the lockfiles.")),t)return"npm";if(e)return"yarn"}var xM=["./package-lock.json","../package-lock.json","../../package-lock.json"],SM=["./yarn.lock","../yarn.lock","../../yarn.lock"];async function qb(){let t=await j.readFile("package.json");if(t===null)throw Error("No package.json file was found.");return JSON.parse(t)}async function ui(...t){let e;try{e=await Wg()}catch(s){let o=s;q.error(`An error occured while loading the ${D.path`chayns-toolkit.json`} file:
52
- `),q.blank(o.message);return}let[r,n]=await Promise.all([qb(),Fb()]),i=!0;for(let s of t)if(i){for(let o of s)await o({config:e,packageJson:r,packageManager:n})&&(i=!1);t.indexOf(s)!==t.length-1&&q.blank("")}}var Gt=new kb.Command;Gt.version("2.0.8","-v, --version","output the version number");Gt.command("dev").description("start up a development server with hot module replacement").option("-d, --devtools","open react-devtools in a separate window",!1).action(async t=>{await ui([l_,Pb,c_,Rb],[i_({devtools:t.devtools})])});Gt.command("build").description("bundles your code for production").option("-a, --analyze","analyze your bundle size",!1).action(async t=>{try{await ui([Qg({analyze:t.analyze})])}catch(e){q.error(e)}console.info("")});Gt.command("lint").description("lints your code for possible errors").action(async()=>{await s_(),console.info("")});Gt.command("test").description("executes all Jest tests for this project").option("-w, --watch","watch for changes to rerun tests",!1).option("--setupFile <path>","file that should be executed before the tests are initialized","").action(async t=>{try{await ui([u_(t)])}catch(e){q.error(e)}console.info("")});Gt.parse(process.argv);
52
+ `),q.blank(o.message);return}let[r,n]=await Promise.all([qb(),Fb()]),i=!0;for(let s of t)if(i){for(let o of s)await o({config:e,packageJson:r,packageManager:n})&&(i=!1);t.indexOf(s)!==t.length-1&&q.blank("")}}var Gt=new kb.Command;Gt.version("2.0.9","-v, --version","output the version number");Gt.command("dev").description("start up a development server with hot module replacement").option("-d, --devtools","open react-devtools in a separate window",!1).action(async t=>{await ui([l_,Pb,c_,Rb],[i_({devtools:t.devtools})])});Gt.command("build").description("bundles your code for production").option("-a, --analyze","analyze your bundle size",!1).action(async t=>{try{await ui([Qg({analyze:t.analyze})])}catch(e){q.error(e)}console.info("")});Gt.command("lint").description("lints your code for possible errors").action(async()=>{await s_(),console.info("")});Gt.command("test").description("executes all Jest tests for this project").option("-w, --watch","watch for changes to rerun tests",!1).option("--setupFile <path>","file that should be executed before the tests are initialized","").action(async t=>{try{await ui([u_(t)])}catch(e){q.error(e)}console.info("")});Gt.parse(process.argv);
53
53
  /*!
54
54
  * fill-range <https://github.com/jonschlinkert/fill-range>
55
55
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-toolkit",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "A zero-config toolchain for developing chayns® apps.",
5
5
  "keywords": [
6
6
  "chayns",
@@ -85,7 +85,7 @@
85
85
  "eslint-plugin-jsx-a11y": "^6.5.1",
86
86
  "eslint-plugin-react": "^7.27.1",
87
87
  "eslint-plugin-react-hooks": "^4.3.0",
88
- "html-webpack-plugin": "^5.5.0",
88
+ "html-webpack-plugin": "^5.5.0 <5.5.4",
89
89
  "jest": "^27.3.1",
90
90
  "mini-css-extract-plugin": "^2.4.5",
91
91
  "postcss": "^8.4.4",