@baic/yolk-cli 2.1.0-alpha.222 → 2.1.0-alpha.224

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.
@@ -4,6 +4,7 @@ const {
4
4
  getYolkConfig,
5
5
  getEsLintConfigPath,
6
6
  getStyleLintConfigPath,
7
+ getPrettierConfigPath,
7
8
  } = require('./_util');
8
9
 
9
10
  const defaultIgnore = [
@@ -28,14 +29,16 @@ const defaultIgnore = [
28
29
  const yolkConfig = getYolkConfig();
29
30
  const isStrict = yolkConfig.strict !== false;
30
31
 
31
- const prettierCLI =
32
- 'prettier --write --cache --cache-strategy=content --loglevel=error';
32
+ const cacheDirPath = join(process.cwd(), 'node_modules', '.cache');
33
+
34
+ const prettierCLI = `prettier --write --cache --cache-strategy=content --cache-location=${join(
35
+ cacheDirPath,
36
+ '.prettiercache',
37
+ )} --config ${getPrettierConfigPath()} --loglevel=error`;
33
38
  const eslintCLI = `eslint --fix ${
34
39
  isStrict ? '--no-inline-config' : ''
35
40
  } --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${join(
36
- process.cwd(),
37
- 'node_modules',
38
- '.cache',
41
+ cacheDirPath,
39
42
  '.eslintcache',
40
43
  )} --config ${getEsLintConfigPath()} ${defaultIgnore
41
44
  .map((i) => `--ignore-pattern ${i}`)
@@ -43,9 +46,7 @@ const eslintCLI = `eslint --fix ${
43
46
  const stylelintCLI = `stylelint --fix ${
44
47
  isStrict ? '--ignore-disables' : ''
45
48
  } --allow-empty-input --cache --cache-strategy=content --cache-location=${join(
46
- process.cwd(),
47
- 'node_modules',
48
- '.cache',
49
+ cacheDirPath,
49
50
  '.stylelintcache',
50
51
  )} --config ${getStyleLintConfigPath()} ${defaultIgnore
51
52
  .map((i) => `--ignore-pattern ${i}`)
package/es/_util.d.ts CHANGED
@@ -22,5 +22,7 @@ export declare const getYolkConfig: () => YolkConfig;
22
22
  export declare const getPrettierConfig: () => any;
23
23
  export declare const getProjectConfigJSON: () => any;
24
24
  export declare const getPackageJSON: () => any;
25
+ export declare const getConfigFilePath: (type: 'eslint' | 'stylelint' | 'prettier') => string;
25
26
  export declare const getEsLintConfigPath: () => string;
26
27
  export declare const getStyleLintConfigPath: () => string;
28
+ export declare const getPrettierConfigPath: () => string;
package/es/_util.js CHANGED
@@ -1 +1 @@
1
- import{spawn as r}from"child_process";import e from"fs";import t from"path";import{rimrafSync as o,windowsSync as n}from"@baic/yolk-prebundle/compiled/rimraf";import i from"chalk";import{globSync as c}from"glob";import{program as a}from"../compiled/commander";var s=process.cwd(),f=console;export var ENCODING="utf-8";export var warn=function(r){return r&&f.log(i.yellow("warn -"),r)};export var error=function(r){return r&&f.log(i.red("error -"),r)};export var ready=function(r){return r&&f.log(i.green("ready -"),r)};export var info=function(r){return r&&f.log(i.blue("info -"),r)};var l=function(){return"win32"===process.platform},p=function(r){return l()?"".concat(r,".cmd"):r};export var rimrafSync=function(r){return l()?n(r):o(r)};export var completeExit=function(){ready("yolk complete!"),process.exit(0)};export var breakExit=function(){warn("yolk break!"),process.exit(0)};export var execCommand=function(e){var t=e.command,o=e.args,n=e.complete,i=e.close,c=e.exit,s=void 0===c||c,f=r(p(t),o||[],{stdio:"inherit"}).on("close",(function(r){r?(i&&i(),error("yolk close!"),process.exit(r)):(n&&n(),s&&completeExit())}));process.on("SIGINT",(function(){a.exitOverride(),f.kill(),breakExit()}))};export var getYolkConfig=function(){var r=c("*.yolkrc*",{cwd:s,dot:!0});if(!r.length)return{};var o=t.join(s,r[0]);if(!e.existsSync(o))return{};try{return JSON.parse(e.readFileSync(o,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getPrettierConfig=function(){var r=t.join(s,".prettierrc");if(e.existsSync(r))try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")};export var getProjectConfigJSON=function(){var r=t.join(s,"project.config.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getPackageJSON=function(){var r=t.join(s,"package.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getEsLintConfigPath=function(){var r=getYolkConfig(),t="";try{t=require.resolve("@baic/eslint-config-yolk")}catch(error){}var o=c("*.eslintrc*",{cwd:s,dot:!0}),n=o[0];return!1===r.strict&&n&&e.existsSync(n)?n:e.existsSync(t)?t:n};export var getStyleLintConfigPath=function(){var r=getYolkConfig(),t="";try{t=require.resolve("@baic/stylelint-config-yolk")}catch(error){}var o=c("*.stylelintrc*",{cwd:s,dot:!0}),n=o[0];return!1===r.strict&&n&&e.existsSync(n)?n:e.existsSync(t)?t:n};
1
+ import{spawn as r}from"child_process";import e from"fs";import t from"path";import{rimrafSync as o,windowsSync as n}from"@baic/yolk-prebundle/compiled/rimraf";import i from"chalk";import{globSync as c}from"glob";import{program as a}from"../compiled/commander";var s=process.cwd(),f=console;export var ENCODING="utf-8";export var warn=function(r){return r&&f.log(i.yellow("warn -"),r)};export var error=function(r){return r&&f.log(i.red("error -"),r)};export var ready=function(r){return r&&f.log(i.green("ready -"),r)};export var info=function(r){return r&&f.log(i.blue("info -"),r)};var p=function(){return"win32"===process.platform},u=function(r){return p()?"".concat(r,".cmd"):r};export var rimrafSync=function(r){return p()?n(r):o(r)};export var completeExit=function(){ready("yolk complete!"),process.exit(0)};export var breakExit=function(){warn("yolk break!"),process.exit(0)};export var execCommand=function(e){var t=e.command,o=e.args,n=e.complete,i=e.close,c=e.exit,s=void 0===c||c,f=r(u(t),o||[],{stdio:"inherit"}).on("close",(function(r){r?(i&&i(),error("yolk close!"),process.exit(r)):(n&&n(),s&&completeExit())}));process.on("SIGINT",(function(){a.exitOverride(),f.kill(),breakExit()}))};export var getYolkConfig=function(){var r=c("*.yolkrc*",{cwd:s,dot:!0});if(!r.length)return{};var o=t.join(s,r[0]);if(!e.existsSync(o))return{};try{return JSON.parse(e.readFileSync(o,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getPrettierConfig=function(){var r=t.join(s,".prettierrc");if(e.existsSync(r))try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")};export var getProjectConfigJSON=function(){var r=t.join(s,"project.config.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getPackageJSON=function(){var r=t.join(s,"package.json");if(!e.existsSync(r))return{};try{return JSON.parse(e.readFileSync(r,ENCODING))||{}}catch(error){return error(error.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}};export var getConfigFilePath=function(r){var t=getYolkConfig(),o="";try{o=require.resolve("@baic/".concat(r,"-config-yolk"))}catch(error){}var n=c("*.".concat(r,"rc*"),{cwd:s,dot:!0}),i=n[0];return!1===t.strict&&i&&e.existsSync(i)?i:e.existsSync(o)?o:i};export var getEsLintConfigPath=function(){return getConfigFilePath("eslint")};export var getStyleLintConfigPath=function(){return getConfigFilePath("stylelint")};export var getPrettierConfigPath=function(){return getConfigFilePath("prettier")};
@@ -4,6 +4,7 @@ const {
4
4
  getYolkConfig,
5
5
  getEsLintConfigPath,
6
6
  getStyleLintConfigPath,
7
+ getPrettierConfigPath,
7
8
  } = require('./_util');
8
9
 
9
10
  const defaultIgnore = [
@@ -28,14 +29,16 @@ const defaultIgnore = [
28
29
  const yolkConfig = getYolkConfig();
29
30
  const isStrict = yolkConfig.strict !== false;
30
31
 
31
- const prettierCLI =
32
- 'prettier --write --cache --cache-strategy=content --loglevel=error';
32
+ const cacheDirPath = join(process.cwd(), 'node_modules', '.cache');
33
+
34
+ const prettierCLI = `prettier --write --cache --cache-strategy=content --cache-location=${join(
35
+ cacheDirPath,
36
+ '.prettiercache',
37
+ )} --config ${getPrettierConfigPath()} --loglevel=error`;
33
38
  const eslintCLI = `eslint --fix ${
34
39
  isStrict ? '--no-inline-config' : ''
35
40
  } --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${join(
36
- process.cwd(),
37
- 'node_modules',
38
- '.cache',
41
+ cacheDirPath,
39
42
  '.eslintcache',
40
43
  )} --config ${getEsLintConfigPath()} ${defaultIgnore
41
44
  .map((i) => `--ignore-pattern ${i}`)
@@ -43,9 +46,7 @@ const eslintCLI = `eslint --fix ${
43
46
  const stylelintCLI = `stylelint --fix ${
44
47
  isStrict ? '--ignore-disables' : ''
45
48
  } --allow-empty-input --cache --cache-strategy=content --cache-location=${join(
46
- process.cwd(),
47
- 'node_modules',
48
- '.cache',
49
+ cacheDirPath,
49
50
  '.stylelintcache',
50
51
  )} --config ${getStyleLintConfigPath()} ${defaultIgnore
51
52
  .map((i) => `--ignore-pattern ${i}`)
package/lib/_util.d.ts CHANGED
@@ -22,5 +22,7 @@ export declare const getYolkConfig: () => YolkConfig;
22
22
  export declare const getPrettierConfig: () => any;
23
23
  export declare const getProjectConfigJSON: () => any;
24
24
  export declare const getPackageJSON: () => any;
25
+ export declare const getConfigFilePath: (type: 'eslint' | 'stylelint' | 'prettier') => string;
25
26
  export declare const getEsLintConfigPath: () => string;
26
27
  export declare const getStyleLintConfigPath: () => string;
28
+ export declare const getPrettierConfigPath: () => string;
package/lib/_util.js CHANGED
@@ -1 +1 @@
1
- var e=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,c=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},i=(e,c,l,i)=>{if(c&&"object"===typeof c||"function"===typeof c)for(let a of o(c))n.call(e,a)||a===l||r(e,a,{get:()=>c[a],enumerable:!(i=t(c,a))||i.enumerable});return e},a=(t,o,n)=>(n=null!=t?e(c(t)):{},i(!o&&t&&t.__esModule?n:r(n,"default",{value:t,enumerable:!0}),t)),s=e=>i(r({},"__esModule",{value:!0}),e),u={};l(u,{ENCODING:()=>O,breakExit:()=>C,completeExit:()=>v,error:()=>k,execCommand:()=>J,getEsLintConfigPath:()=>D,getPackageJSON:()=>I,getPrettierConfig:()=>E,getProjectConfigJSON:()=>F,getStyleLintConfigPath:()=>G,getYolkConfig:()=>_,info:()=>w,ready:()=>h,rimrafSync:()=>P,warn:()=>x}),module.exports=s(u);var f=require("child_process"),d=a(require("fs")),y=a(require("path")),g=require("@baic/yolk-prebundle/compiled/rimraf"),p=a(require("chalk")),m=require("glob"),S=require("../compiled/commander"),b=process.cwd(),j=console,O="utf-8",x=e=>e&&j.log(p.default.yellow("warn -"),e),k=e=>e&&j.log(p.default.red("error -"),e),h=e=>e&&j.log(p.default.green("ready -"),e),w=e=>e&&j.log(p.default.blue("info -"),e),q=()=>"win32"===process.platform,N=e=>q()?`${e}.cmd`:e,P=e=>q()?(0,g.windowsSync)(e):(0,g.rimrafSync)(e),v=()=>{h("yolk complete!"),process.exit(0)},C=()=>{x("yolk break!"),process.exit(0)},J=({command:e,args:r,complete:t,close:o,exit:c=!0})=>{const n=(0,f.spawn)(N(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(o&&o(),k("yolk close!"),process.exit(e)):(t&&t(),c&&v())}));process.on("SIGINT",(()=>{S.program.exitOverride(),n.kill(),C()}))},_=()=>{const e=(0,m.globSync)("*.yolkrc*",{cwd:b,dot:!0});if(!e.length)return{};const r=y.default.join(b,e[0]);if(!d.default.existsSync(r))return{};try{return JSON.parse(d.default.readFileSync(r,O))||{}}catch(t){return t(t.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},E=()=>{const e=y.default.join(b,".prettierrc");if(d.default.existsSync(e))try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},F=()=>{const e=y.default.join(b,"project.config.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},I=()=>{const e=y.default.join(b,"package.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},D=()=>{const e=_();let r="";try{r=require.resolve("@baic/eslint-config-yolk")}catch(c){}const t=(0,m.globSync)("*.eslintrc*",{cwd:b,dot:!0}),o=t[0];return!1===e.strict&&o&&d.default.existsSync(o)?o:d.default.existsSync(r)?r:o},G=()=>{const e=_();let r="";try{r=require.resolve("@baic/stylelint-config-yolk")}catch(c){}const t=(0,m.globSync)("*.stylelintrc*",{cwd:b,dot:!0}),o=t[0];return!1===e.strict&&o&&d.default.existsSync(o)?o:d.default.existsSync(r)?r:o};
1
+ var e=Object.create,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,a=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},i=(e,n,a,i)=>{if(n&&"object"===typeof n||"function"===typeof n)for(let l of o(n))c.call(e,l)||l===a||r(e,l,{get:()=>n[l],enumerable:!(i=t(n,l))||i.enumerable});return e},l=(t,o,c)=>(c=null!=t?e(n(t)):{},i(!o&&t&&t.__esModule?c:r(c,"default",{value:t,enumerable:!0}),t)),s=e=>i(r({},"__esModule",{value:!0}),e),u={};a(u,{ENCODING:()=>O,breakExit:()=>v,completeExit:()=>C,error:()=>k,execCommand:()=>J,getConfigFilePath:()=>$,getEsLintConfigPath:()=>D,getPackageJSON:()=>I,getPrettierConfig:()=>_,getPrettierConfigPath:()=>L,getProjectConfigJSON:()=>E,getStyleLintConfigPath:()=>G,getYolkConfig:()=>F,info:()=>w,ready:()=>x,rimrafSync:()=>q,warn:()=>h}),module.exports=s(u);var f=require("child_process"),d=l(require("fs")),g=l(require("path")),p=require("@baic/yolk-prebundle/compiled/rimraf"),y=l(require("chalk")),m=require("glob"),S=require("../compiled/commander"),b=process.cwd(),j=console,O="utf-8",h=e=>e&&j.log(y.default.yellow("warn -"),e),k=e=>e&&j.log(y.default.red("error -"),e),x=e=>e&&j.log(y.default.green("ready -"),e),w=e=>e&&j.log(y.default.blue("info -"),e),P=()=>"win32"===process.platform,N=e=>P()?`${e}.cmd`:e,q=e=>P()?(0,p.windowsSync)(e):(0,p.rimrafSync)(e),C=()=>{x("yolk complete!"),process.exit(0)},v=()=>{h("yolk break!"),process.exit(0)},J=({command:e,args:r,complete:t,close:o,exit:n=!0})=>{const c=(0,f.spawn)(N(e),r||[],{stdio:"inherit"}).on("close",(e=>{e?(o&&o(),k("yolk close!"),process.exit(e)):(t&&t(),n&&C())}));process.on("SIGINT",(()=>{S.program.exitOverride(),c.kill(),v()}))},F=()=>{const e=(0,m.globSync)("*.yolkrc*",{cwd:b,dot:!0});if(!e.length)return{};const r=g.default.join(b,e[0]);if(!d.default.existsSync(r))return{};try{return JSON.parse(d.default.readFileSync(r,O))||{}}catch(t){return t(t.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}},_=()=>{const e=g.default.join(b,".prettierrc");if(d.default.existsSync(e))try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||".prettierrc\u8f6c\u6362\u9519\u8bef"),{}}return require("./.prettierrc")},E=()=>{const e=g.default.join(b,"project.config.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"project.config.json\u8f6c\u6362\u9519\u8bef"),{}}},I=()=>{const e=g.default.join(b,"package.json");if(!d.default.existsSync(e))return{};try{return JSON.parse(d.default.readFileSync(e,O))||{}}catch(r){return r(r.message||"package.json\u8f6c\u6362\u9519\u8bef"),{}}},$=e=>{const r=F();let t="";try{t=require.resolve(`@baic/${e}-config-yolk`)}catch(c){}const o=(0,m.globSync)(`*.${e}rc*`,{cwd:b,dot:!0}),n=o[0];return!1===r.strict&&n&&d.default.existsSync(n)?n:d.default.existsSync(t)?t:n},D=()=>$("eslint"),G=()=>$("stylelint"),L=()=>$("prettier");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baic/yolk-cli",
3
- "version": "2.1.0-alpha.222",
3
+ "version": "2.1.0-alpha.224",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/303394539/yolk.git"
@@ -25,7 +25,7 @@
25
25
  "prebundle": "father prebundle"
26
26
  },
27
27
  "dependencies": {
28
- "@baic/yolk-prebundle": "^2.1.0-alpha.222",
28
+ "@baic/yolk-prebundle": "^2.1.0-alpha.224",
29
29
  "@democrance/imagemin-lint-staged": "2.x",
30
30
  "@types/inquirer": "8.x",
31
31
  "@types/lint-staged": "~13.x",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "2f69459607cedbb58d0ac2e6956eef08981d2a1c"
61
+ "gitHead": "9fc31021648f519d5914e658140426c74f5893c3"
62
62
  }