chayns-toolkit 2.0.0-beta.19 → 2.0.0-beta.21

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 (2) hide show
  1. package/lib/cli.js +1 -1
  2. package/package.json +2 -2
package/lib/cli.js CHANGED
@@ -52,7 +52,7 @@ ${d.substring(I)}`}let q=t==="production"?{removeComments:!0,collapseWhitespace:
52
52
  module.exports = `;var Ks=F(require("fs"));function c_({config:t}){let{cert:e,key:r}=t.development,n=!1;return r&&!e||!r&&e?(k.error(`You have specified the ${j.code(r?"key":"cert")} field in your ${j.path`chayns-toolkit.json`} file, but not ${j.code(r?"cert":"key")}. You need to specify paths in both fields for SSL to work.`),n=!0):(r&&(Ks.existsSync(r)||(k.error(`No file exists at the ${j.code`key`} path specified in ${j.path`chayns-toolkit.json`}.`),n=!0)),e&&(Ks.existsSync(e)||(k.error(`No file exists at the ${j.code`cert`} path specified in ${j.path`chayns-toolkit.json`}.`),n=!0))),n}var f_=F(require("fs")),p_=F(require("path")),h_=F(require("util")),wT=(0,h_.promisify)(f_.readFile);async function Ys(t){let e=p_.resolve("package.json"),r=await wT(e,{encoding:"utf-8"}),n=JSON.parse(r),i=Object.keys(B(B({},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 Ys("@types/react"),r=await Ys("@types/react-dom"),n=[!e&&"@types/react",!r&&"@types/react-dom"].filter(Boolean);if(n.length>0){let i=n.map(s=>j.code(s)).join(" and ");k.hint(`You should install the ${i} package${n.length>0?"s":""} to get TypeScript support for React.
53
53
  `),t!==void 0&&k.blank(`Install them by running ${rt.install(t,n,!0)}`)}}async function g_(){var n;if(!N.hasFile("tsconfig.json"))return!0;let r=((n=await N.readFile("tsconfig.json"))!=null?n:"").replace(/\s/gi,"");return r===""||r==="{}"}var Cb=F(Ab());async function Ob(){return N.hasFile("tsconfig.json")?!0:(await(0,Cb.default)("src/**/*.{ts,tsx}")).length>0}async function Pb({packageJson:t,packageManager:e}){let r=Xr(t,"typescript"),n=await g_();return r?(await m_(e),n&&await Rb(),!1):await Ob()?(n&&await Rb(),k.error(`To use TypeScript, you have to install the ${j.code`typescript`} package by running ${rt.install(e,"typescript",!0)}.`),!0):!1}async function Rb(){await N.writeFile("tsconfig.json",JSON.stringify(vM,void 0,4)),k.info(`Seems like you want to use TypeScript. A ${j.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 oi=F(require("tcp-port-used"));async function Tb({config:t}){let{port:e,host:r}=t.development;if(await(0,oi.check)(e,r)){k.warn(`The port ${j.number(e)} on host ${j.code(r)} is already in use. Waiting for it to free up...`);try{return await(0,oi.waitUntilFreeOnHost)(e,r,500,6e4),k.info("Is has freed up. Starting the development server..."),!1}catch{return k.error("The port did not free up within 60 seconds."),!0}}return!1}function Fb(){let t=xM.some(r=>N.hasFile(r)),e=SM.some(r=>N.hasFile(r));if(t&&e&&(k.warn(`You have both ${j.path`package-lock.json`} and ${j.path`yarn.lock`} files in your project.
54
54
  `),k.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 N.readFile("package.json");if(t===null)throw Error("No package.json file was found.");return JSON.parse(t)}async function ai(...t){let e;try{e=await Wg()}catch(s){let o=s;k.error(`An error occured while loading the ${j.path`chayns-toolkit.json`} file:
55
- `),k.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&&k.blank("")}}var Vt=new kb.Command;Vt.version("2.0.0-beta.19","-v, --version","output the version number");Vt.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 ai([l_,Pb,c_,Tb],[i_({devtools:t.devtools})])});Vt.command("build").description("bundles your code for production").option("-a, --analyze","analyze your bundle size",!1).action(async t=>{try{await ai([Qg({analyze:t.analyze})])}catch(e){k.error(e)}console.info("")});Vt.command("lint").description("lints your code for possible errors").action(async()=>{await s_(),console.info("")});Vt.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 ai([u_(t)])}catch(e){k.error(e)}console.info("")});Vt.parse(process.argv);
55
+ `),k.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&&k.blank("")}}var Vt=new kb.Command;Vt.version("2.0.0-beta.21","-v, --version","output the version number");Vt.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 ai([l_,Pb,c_,Tb],[i_({devtools:t.devtools})])});Vt.command("build").description("bundles your code for production").option("-a, --analyze","analyze your bundle size",!1).action(async t=>{try{await ai([Qg({analyze:t.analyze})])}catch(e){k.error(e)}console.info("")});Vt.command("lint").description("lints your code for possible errors").action(async()=>{await s_(),console.info("")});Vt.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 ai([u_(t)])}catch(e){k.error(e)}console.info("")});Vt.parse(process.argv);
56
56
  /*!
57
57
  * fill-range <https://github.com/jonschlinkert/fill-range>
58
58
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-toolkit",
3
- "version": "2.0.0-beta.19",
3
+ "version": "2.0.0-beta.21",
4
4
  "description": "A zero-config toolchain for developing chayns® apps.",
5
5
  "keywords": [
6
6
  "chayns",
@@ -54,7 +54,7 @@
54
54
  "@babel/preset-react": "^7.16.0",
55
55
  "@babel/preset-typescript": "^7.16.0",
56
56
  "@babel/runtime": "^7.16.3",
57
- "@chayns-toolkit/eslint-config": "^2.0.0",
57
+ "@chayns-toolkit/eslint-config": "^2.0.2",
58
58
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
59
59
  "@svgr/webpack": "^6.0.0",
60
60
  "@testing-library/jest-dom": "^5.15.1",