@baic/yolk-cli 2.1.0-alpha.233 → 2.1.0-alpha.235

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/es/_util.js CHANGED
@@ -1 +1,105 @@
1
- import{spawn as r}from"node:child_process";import e from"node:fs";import o from"node:path";import{rimrafSync as t,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 f=process.cwd(),s=console;export var ENCODING="utf-8";export var warn=function(r){return r&&s.log(i.yellow("warn -"),r)};export var error=function(r){return r&&s.log(i.red("error -"),r)};export var ready=function(r){return r&&s.log(i.green("ready -"),r)};export var info=function(r){return r&&s.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):t(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 o=e.command,t=e.args,n=e.complete,i=e.close,c=e.exit,f=void 0===c||c,s=r(p(o),t||[],{stdio:"inherit"}).on("close",(function(r){r?(i&&i(),error("yolk close!"),process.exit(r)):(n&&n(),f&&completeExit())}));process.on("SIGINT",(function(){a.exitOverride(),s.kill(),breakExit()}))};export var getYolkConfig=function(){var r=c("*.yolkrc*",{cwd:f,dot:!0});if(!r.length)return{};var t=o.join(f,r[0]);if(!e.existsSync(t))return{};try{return JSON.parse(e.readFileSync(t,ENCODING))||{}}catch(error){return error(error.message||".yolkrc\u8f6c\u6362\u9519\u8bef"),{}}};export var getProjectConfigJSON=function(){var r=o.join(f,"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=o.join(f,"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 o=getYolkConfig(),t="";try{t=require.resolve("@baic/".concat(r,"-config-yolk"))}catch(error){}var n=c("*.".concat(r,"rc*"),{cwd:f,dot:!0}),i=null===n||void 0===n?void 0:n[0];return!1===o.strict&&i&&e.existsSync(i)?i:e.existsSync(t)?t:i};export var getEsLintConfigPath=function(){return getConfigFilePath("eslint")};export var getStyleLintConfigPath=function(){return getConfigFilePath("stylelint")};export var getPrettierConfigPath=function(){return getConfigFilePath("prettier")};export var getBiomeConfigPath=function(){return getConfigFilePath("biome")};
1
+ var m = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, {
2
+ get: (e, o) => (typeof require < "u" ? require : e)[o]
3
+ }) : t)(function(t) {
4
+ if (typeof require < "u")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + t + '" is not supported');
7
+ });
8
+
9
+ // src/_util.ts
10
+ import { spawn as k } from "node:child_process";
11
+ import r from "node:fs";
12
+ import a from "node:path";
13
+ import c from "chalk";
14
+ import { globSync as x } from "glob";
15
+ import {
16
+ rimrafSync as u,
17
+ windowsSync as d
18
+ } from "rimraf";
19
+ import { program as h } from "../compiled/commander";
20
+ var i = process.cwd(), l = console, p = "utf-8", C = (t) => t && l.log(c.yellow("warn -"), t), P = (t) => t && l.log(c.red("error -"), t), j = (t) => t && l.log(c.green("ready -"), t), _ = (t) => t && l.log(c.blue("info -"), t), S = () => process.platform === "win32", N = (t) => S() ? `${t}.cmd` : t, $ = (t) => S() ? d(t) : u(t), b = () => {
21
+ j("yolk complete!"), process.exit(0);
22
+ }, w = () => {
23
+ C("yolk break!"), process.exit(0);
24
+ }, G = ({
25
+ command: t,
26
+ args: e,
27
+ complete: o,
28
+ close: n,
29
+ exit: s = !0
30
+ }) => {
31
+ let f = k(N(t), e || [], {
32
+ stdio: "inherit"
33
+ }).on("close", (y) => {
34
+ y ? (n && n(), P("yolk close!"), process.exit(y)) : (o && o(), s && b());
35
+ });
36
+ process.on("SIGINT", () => {
37
+ h.exitOverride(), f.kill(), w();
38
+ });
39
+ }, O = () => {
40
+ let t = x("*.yolkrc*", {
41
+ cwd: i,
42
+ dot: !0
43
+ });
44
+ if (!t.length)
45
+ return {};
46
+ let e = a.join(i, t[0]);
47
+ if (r.existsSync(e))
48
+ try {
49
+ return JSON.parse(r.readFileSync(e, p)) || {};
50
+ } catch (o) {
51
+ return o(o.message || ".yolkrc转换错误"), {};
52
+ }
53
+ else
54
+ return {};
55
+ }, q = () => {
56
+ let t = a.join(i, "project.config.json");
57
+ if (r.existsSync(t))
58
+ try {
59
+ return JSON.parse(r.readFileSync(t, p)) || {};
60
+ } catch (e) {
61
+ return e(e.message || "project.config.json转换错误"), {};
62
+ }
63
+ else
64
+ return {};
65
+ }, B = () => {
66
+ let t = a.join(i, "package.json");
67
+ if (r.existsSync(t))
68
+ try {
69
+ return JSON.parse(r.readFileSync(t, p)) || {};
70
+ } catch (e) {
71
+ return e(e.message || "package.json转换错误"), {};
72
+ }
73
+ else
74
+ return {};
75
+ }, g = (t) => {
76
+ let e = O(), o = "";
77
+ try {
78
+ o = m.resolve(`@baic/${t}-config-yolk`);
79
+ } catch {
80
+ }
81
+ let n = x(`*.${t}rc*`, {
82
+ cwd: i,
83
+ dot: !0
84
+ }), s = n == null ? void 0 : n[0];
85
+ return e.strict === !1 && s && r.existsSync(s) ? s : r.existsSync(o) ? o : s;
86
+ }, D = () => g("eslint"), T = () => g("stylelint"), W = () => g("prettier"), z = () => g("biome");
87
+ export {
88
+ p as ENCODING,
89
+ w as breakExit,
90
+ b as completeExit,
91
+ P as error,
92
+ G as execCommand,
93
+ z as getBiomeConfigPath,
94
+ g as getConfigFilePath,
95
+ D as getEsLintConfigPath,
96
+ B as getPackageJSON,
97
+ W as getPrettierConfigPath,
98
+ q as getProjectConfigJSON,
99
+ T as getStyleLintConfigPath,
100
+ O as getYolkConfig,
101
+ _ as info,
102
+ j as ready,
103
+ $ as rimrafSync,
104
+ C as warn
105
+ };
package/es/index.js CHANGED
@@ -1,2 +1,12 @@
1
1
  #! /usr/bin/env node
2
- require("../compiled/v8-compile-cache"),require("./yolk");
2
+ var r = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, {
3
+ get: (i, n) => (typeof require < "u" ? require : i)[n]
4
+ }) : e)(function(e) {
5
+ if (typeof require < "u")
6
+ return require.apply(this, arguments);
7
+ throw new Error('Dynamic require of "' + e + '" is not supported');
8
+ });
9
+
10
+ // src/index.ts
11
+ r("../compiled/v8-compile-cache");
12
+ r("./yolk");
@@ -0,0 +1,61 @@
1
+ var i = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, {
2
+ get: (e, p) => (typeof require < "u" ? require : e)[p]
3
+ }) : t)(function(t) {
4
+ if (typeof require < "u")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + t + '" is not supported');
7
+ });
8
+ var u = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
9
+
10
+ // src/lintstagedrc.js
11
+ var b = u((P, h) => {
12
+ var { join: n } = i("node:path"), {
13
+ getYolkConfig: m,
14
+ getEsLintConfigPath: f,
15
+ getStyleLintConfigPath: $,
16
+ getPrettierConfigPath: d,
17
+ getBiomeConfigPath: y
18
+ } = i("./_util"), l = [
19
+ "**/node_modules/**",
20
+ "**/build/**",
21
+ "**/dist/**",
22
+ "**/lib/**",
23
+ "**/es/**",
24
+ "**/mock/**",
25
+ "**/test/**",
26
+ "**/public/**",
27
+ "**/assets/**",
28
+ "**/.umi/**",
29
+ "**/.umi-production/**",
30
+ "**/h5+app/**",
31
+ "**/*uni*/**",
32
+ "**/android/**",
33
+ "**/ios/**",
34
+ "**/*.ignore/**"
35
+ ], j = m(), g = j.strict !== !1, c = n(process.cwd(), "node_modules", ".cache"), s = `prettier --write --cache --cache-strategy=content --cache-location=${n(
36
+ c,
37
+ ".prettiercache"
38
+ )} --config ${d()} --no-error-on-unmatched-pattern`, r = `eslint --fix ${g ? "--no-inline-config" : ""} --no-error-on-unmatched-pattern --cache --cache-strategy=content --cache-location=${n(
39
+ c,
40
+ ".eslintcache"
41
+ )} --config ${f()} ${l.map((t) => `--ignore-pattern ${t}`).join(" ")}`, o = `stylelint --fix ${g ? "--ignore-disables" : ""} --allow-empty-input --cache --cache-strategy=content --cache-location=${n(
42
+ c,
43
+ ".stylelintcache"
44
+ )} --config ${$()} ${l.map((t) => `--ignore-pattern ${t}`).join(" ")}`, C = `biome check --write --unsafe --no-errors-on-unmatched --log-level=error --files-ignore-unknown=true --config-path=${y()}`, a = {
45
+ "*.{md,json,jsonc}": [s],
46
+ // '*.{png,jpeg,jpg,gif,svg}': ['imagemin-lint-staged'],
47
+ "*.css": [s, `${o} --custom-syntax postcss`],
48
+ "*.less": [s, `${o} --custom-syntax postcss-less`],
49
+ "*.{sass,scss}": [
50
+ s,
51
+ `${o} --custom-syntax postcss-scss`
52
+ ],
53
+ "*.{js,jsx,cjs,mjs}": [s, r],
54
+ "*.{ts,tsx,cts,mts}": [`${s} --parser=typescript`, r]
55
+ }, x = {
56
+ ...a,
57
+ [`!(${Object.keys(a).join("|")})`]: [C]
58
+ };
59
+ h.exports = x;
60
+ });
61
+ export default b();