@anolilab/lint-staged-config 1.0.1 → 1.1.1

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 (65) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/chunk-26UFUGBI.js +11 -0
  3. package/dist/chunk-26UFUGBI.js.map +1 -0
  4. package/dist/chunk-32WCNCA6.mjs +8 -0
  5. package/dist/chunk-32WCNCA6.mjs.map +1 -0
  6. package/dist/{chunk-2NJHQVOR.mjs → chunk-3GJFQHMH.mjs} +2 -2
  7. package/dist/{chunk-X6YOEYWM.js → chunk-57F5GRFM.js} +3 -3
  8. package/dist/chunk-7NERYZQR.mjs +8 -0
  9. package/dist/{chunk-BVGKAMQV.mjs.map → chunk-7NERYZQR.mjs.map} +1 -1
  10. package/dist/{chunk-CCERQD4S.js → chunk-B7BKRXC3.js} +1 -1
  11. package/dist/{chunk-CCERQD4S.js.map → chunk-B7BKRXC3.js.map} +1 -1
  12. package/dist/{chunk-5AJKEWYR.js → chunk-CZNOXHD3.js} +3 -3
  13. package/dist/chunk-EFS7QODA.js +15 -0
  14. package/dist/chunk-EFS7QODA.js.map +1 -0
  15. package/dist/{chunk-VWUDOPED.js → chunk-FHMGSJ6B.js} +3 -3
  16. package/dist/{chunk-A5GQULUO.mjs → chunk-JPSOVV4A.mjs} +2 -2
  17. package/dist/{chunk-QUK4P43M.mjs → chunk-KNLP6LX4.mjs} +2 -2
  18. package/dist/chunk-KQX2BKNX.mjs +12 -0
  19. package/dist/chunk-KQX2BKNX.mjs.map +1 -0
  20. package/dist/chunk-NRIST5UV.js +9 -0
  21. package/dist/{chunk-MQKG4NW7.mjs → chunk-OKIQX5HY.mjs} +2 -2
  22. package/dist/chunk-VAUDCZ4C.js +10 -0
  23. package/dist/{chunk-MCOYFEKC.js.map → chunk-VAUDCZ4C.js.map} +1 -1
  24. package/dist/{chunk-YUER2OJU.mjs → chunk-WAVKF2WX.mjs} +1 -1
  25. package/dist/{chunk-YUER2OJU.mjs.map → chunk-WAVKF2WX.mjs.map} +1 -1
  26. package/dist/groups/eslint/index.js +4 -4
  27. package/dist/groups/eslint/index.mjs +3 -3
  28. package/dist/groups/json.js +3 -3
  29. package/dist/groups/json.mjs +2 -2
  30. package/dist/groups/markdown.js +3 -3
  31. package/dist/groups/markdown.mjs +2 -2
  32. package/dist/groups/stylesheets.js +3 -3
  33. package/dist/groups/stylesheets.mjs +2 -2
  34. package/dist/groups/tests.js +3 -3
  35. package/dist/groups/tests.mjs +2 -2
  36. package/dist/groups/typescript.js +3 -3
  37. package/dist/groups/typescript.mjs +2 -2
  38. package/dist/index.js +13 -13
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +14 -14
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/postinstall.js +13 -12
  43. package/dist/postinstall.js.map +1 -1
  44. package/dist/postinstall.mjs +13 -12
  45. package/dist/postinstall.mjs.map +1 -1
  46. package/package.json +7 -7
  47. package/dist/chunk-5IWFJALT.mjs +0 -12
  48. package/dist/chunk-5IWFJALT.mjs.map +0 -1
  49. package/dist/chunk-BVGKAMQV.mjs +0 -8
  50. package/dist/chunk-GXZBYQVF.js +0 -9
  51. package/dist/chunk-HAERDTLI.js +0 -11
  52. package/dist/chunk-HAERDTLI.js.map +0 -1
  53. package/dist/chunk-MCOYFEKC.js +0 -10
  54. package/dist/chunk-MKZ4RRUB.mjs +0 -8
  55. package/dist/chunk-MKZ4RRUB.mjs.map +0 -1
  56. package/dist/chunk-TWU5ONPK.js +0 -15
  57. package/dist/chunk-TWU5ONPK.js.map +0 -1
  58. /package/dist/{chunk-2NJHQVOR.mjs.map → chunk-3GJFQHMH.mjs.map} +0 -0
  59. /package/dist/{chunk-X6YOEYWM.js.map → chunk-57F5GRFM.js.map} +0 -0
  60. /package/dist/{chunk-5AJKEWYR.js.map → chunk-CZNOXHD3.js.map} +0 -0
  61. /package/dist/{chunk-VWUDOPED.js.map → chunk-FHMGSJ6B.js.map} +0 -0
  62. /package/dist/{chunk-A5GQULUO.mjs.map → chunk-JPSOVV4A.mjs.map} +0 -0
  63. /package/dist/{chunk-QUK4P43M.mjs.map → chunk-KNLP6LX4.mjs.map} +0 -0
  64. /package/dist/{chunk-GXZBYQVF.js.map → chunk-NRIST5UV.js.map} +0 -0
  65. /package/dist/{chunk-MQKG4NW7.mjs.map → chunk-OKIQX5HY.mjs.map} +0 -0
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","dependencies","config","configName","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"uVAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,WAAY,SACZ,OAAQC,EACR,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,WAAY,OACZ,OAAQC,EACR,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,WAAY,WACZ,OAAQC,EACR,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,WAAY,aACZ,OAAQC,EACR,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,WAAY,cACZ,OAAQC,EACR,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,WAAY,QACZ,OAAQC,EACR,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,WAAY,aACZ,OAAQC,EACR,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,aAAAC,EAAc,O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EAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,iGAAiG,EAE5G,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n configName: string;\n config: Config;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n configName: \"eslint\",\n config: eslintConfig,\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n configName: \"json\",\n config: jsonConfig,\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n configName: \"markdown\",\n config: markdownConfig,\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n configName: \"secretlint\",\n config: secretlintConfig,\n dependencies: [\"secretlint\"],\n },\n {\n configName: \"stylesheets\",\n config: stylesheetsConfig,\n dependencies: [\"stylelint\"],\n },\n {\n configName: \"tests\",\n config: testsConfig,\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n configName: \"typescript\",\n config: typescriptConfig,\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { dependencies, config, configName } = plugin;\n\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })?.[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) =>\n // eslint-disable-next-line implicit-arrow-linebreak\n (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"uVAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,OAAAC,EAAQ,WAAAC,EAAY,aAAAC,CAAa,EAAIH,EAG7C,GAAKI,EAAgG,SAAYF,CAAU,IAAM,GAAO,CACpI,IAAMG,EAAoB,CAAC,EAE3BF,EAAa,QAASG,GAAe,EAC7BnB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,IACxDD,EAAkB,KAAKC,CAAU,CAEzC,CAAC,EAEGD,EAAkB,OAAS,GAC3BR,EAAgB,CAAE,GAAGA,EAAe,GAAGI,CAAO,EAC9CH,EAAmB,KAAKI,CAAU,IAGlCH,EAAgBG,CAAU,EAAI,CAAC,EAE/BC,EAAa,QAASG,GAAe,CAEhCP,EAAgBG,CAAU,EAAiCI,CAAU,EAAInB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,CACtI,CAAC,EAET,CACJ,CAAC,EAED,IAAMC,EAAiB,CAAE,GAAGV,CAAc,ECzF1C,OAAS,OAAAX,MAAW,UAEpB,IAAMsB,EAAO,IAAG,GAEVC,EAAiBC,GAAoBxB,EAAI,QAAasB,EAAQG,GAAoB,QAAQ,IAAI,GAAGD,CAAM,GAAGC,CAAO,EAAE,EAEnHC,EAAaH,EAAc,EAAE,EAE5BI,EAAQD,EFFf,GAAI,CAAC,OAAO,kCAAmC,CACvC1B,EAAI,QACJ2B,EAAW;AAAA;AAAA,CAA+D,EAE1Ef,EAAmB,QAASgB,GAAe,CACvCD,EAAW,OAAOC,CAAU,EAAE,CAClC,CAAC,GAGL,IAAIC,EAAY,GAEhB,OAAO,QAAQhB,CAAe,EAAE,QAAQ,CAAC,CAACC,EAAQG,CAAY,IAAM,CACvC,OAAO,OAAOA,CAAY,EAAE,KAAK,OAAO,IAG7DY,EAAY,GACZF,EACI;AAAA,oDAAuDb,CAAM,yGACjE,EAEA,OAAO,QAAQG,CAAY,EAAE,QAAQ,CAAC,CAACG,EAAYU,CAAS,IAAM,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,iGAAiG,EAE5G,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
package/dist/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
- import { a as a$6 } from './chunk-A5GQULUO.mjs';
2
- import { a, b } from './chunk-5IWFJALT.mjs';
3
- import './chunk-YUER2OJU.mjs';
4
- import { a as a$1 } from './chunk-MQKG4NW7.mjs';
5
- import { a as a$2 } from './chunk-QUK4P43M.mjs';
6
- import { a as a$3 } from './chunk-4RVIFLAT.mjs';
7
- import { a as a$4 } from './chunk-2NJHQVOR.mjs';
8
- import { a as a$5 } from './chunk-BVGKAMQV.mjs';
9
- import './chunk-MKZ4RRUB.mjs';
1
+ import { a as a$7 } from './chunk-JPSOVV4A.mjs';
2
+ import { a as a$1, b } from './chunk-KQX2BKNX.mjs';
3
+ import './chunk-WAVKF2WX.mjs';
4
+ import { a as a$2 } from './chunk-OKIQX5HY.mjs';
5
+ import { a as a$3 } from './chunk-KNLP6LX4.mjs';
6
+ import { a as a$4 } from './chunk-4RVIFLAT.mjs';
7
+ import { a as a$5 } from './chunk-3GJFQHMH.mjs';
8
+ import { a as a$6 } from './chunk-7NERYZQR.mjs';
9
+ import './chunk-32WCNCA6.mjs';
10
10
  import { env } from 'process';
11
11
  import { hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
12
12
 
13
- var N=[{configName:"eslint",config:b,dependencies:["prettier","eslint"]},{configName:"json",config:a$1,dependencies:["prettier","sort-package-json"]},{configName:"markdown",config:a$2,dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{configName:"secretlint",config:a$3,dependencies:["secretlint"]},{configName:"stylesheets",config:a$4,dependencies:["stylelint"]},{configName:"tests",config:a$5,dependencies:["vite","jest","ava"]},{configName:"typescript",config:a$6,dependencies:["typescript"]}],g={},r=[],l={};N.forEach(i=>{let{dependencies:n,config:t,configName:s}=i;if(a?.plugin?.[s]!==!1){let a=[];n.forEach(e=>{(hasDependency(e)||hasDevDependency(e))&&a.push(e);}),a.length>0?(g={...g,...t},r.push(s)):(l[s]={},n.forEach(e=>{l[s][e]=hasDependency(e)||hasDevDependency(e);}));}});var k={...g};var L=()=>{},j=i=>env.NO_LOGS?L:n=>console.log(`${i}${n}`),O=j(""),o=O;if(!global.hasAnolilabStagedLintConfigLoaded){env.DEBUG&&(o(`
13
+ var N=[{config:b,configName:"eslint",dependencies:["prettier","eslint"]},{config:a$2,configName:"json",dependencies:["prettier","sort-package-json"]},{config:a$3,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:a$4,configName:"secretlint",dependencies:["secretlint"]},{config:a$5,configName:"stylesheets",dependencies:["stylelint"]},{config:a$6,configName:"tests",dependencies:["vite","jest","ava"]},{config:a$7,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};N.forEach(s=>{let{config:o,configName:i,dependencies:l}=s;if(a$1.plugin?.[i]!==!1){let t=[];l.forEach(e=>{(hasDependency(e)||hasDevDependency(e))&&t.push(e);}),t.length>0?(g={...g,...o},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=hasDependency(e)||hasDevDependency(e);}));}});var k={...g};var L=()=>{},j=s=>env.NO_LOGS?L:o=>console.log(`${s}${o}`),O=j(""),n=O;if(!global.hasAnolilabStagedLintConfigLoaded){env.DEBUG&&(n(`
14
14
  @anolilab/lint-stage-config loaded the following plugins:
15
- `),r.forEach(n=>{o(` ${n}`);}));let i=!1;Object.entries(l).forEach(([n,t])=>{Object.values(t).some(Boolean)&&(i=!0,o(`
16
- Your package.json container dependencies for the "${n}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(t).forEach(([a,e])=>{e||o(` ${a}`);}));}),i&&(o(`
17
- To disable this message, add the following to your package.json:`),o(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
18
- `)),o('To disable all logging, add the following to your eslint command call "NO_LOGS=true eslint ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
15
+ `),r.forEach(o=>{n(` ${o}`);}));let s=!1;Object.entries(a).forEach(([o,i])=>{Object.values(i).some(Boolean)&&(s=!0,n(`
16
+ Your package.json container dependencies for the "${o}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([t,e])=>{e||n(` ${t}`);}));}),s&&(n(`
17
+ To disable this message, add the following to your package.json:`),n(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
18
+ `)),n('To disable all logging, add the following to your eslint command call "NO_LOGS=true eslint ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
19
19
 
20
20
  export { k as default };
21
21
  //# sourceMappingURL=out.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","dependencies","config","configName","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"gWAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,WAAY,SACZ,OAAQC,EACR,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,WAAY,OACZ,OAAQC,EACR,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,WAAY,WACZ,OAAQC,EACR,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,WAAY,aACZ,OAAQC,EACR,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,WAAY,cACZ,OAAQC,EACR,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,WAAY,QACZ,OAAQC,EACR,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,WAAY,aACZ,OAAQC,EACR,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,aAAAC,EAAc,OAAAC,EAAQ,WAAAC,CAAW,EAAIH,EAE7C,GAAKI,GAAkG,SAAYD,CAAU,IAAM,GAAO,CACtI,IAAME,EAAoB,CAAC,EAE3BJ,EAAa,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edPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n configName: string;\n config: Config;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n configName: \"eslint\",\n config: eslintConfig,\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n configName: \"json\",\n config: jsonConfig,\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n configName: \"markdown\",\n config: markdownConfig,\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n configName: \"secretlint\",\n config: secretlintConfig,\n dependencies: [\"secretlint\"],\n },\n {\n configName: \"stylesheets\",\n config: stylesheetsConfig,\n dependencies: [\"stylelint\"],\n },\n {\n configName: \"tests\",\n config: testsConfig,\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n configName: \"typescript\",\n config: typescriptConfig,\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { dependencies, config, configName } = plugin;\n\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })?.[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) =>\n // eslint-disable-next-line implicit-arrow-linebreak\n (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"gWAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,OAAAC,EAAQ,WAAAC,EAAY,aAAAC,CAAa,EAAIH,EAG7C,GAAKI,EAAgG,SAAYF,CAAU,IAAM,GAAO,CACpI,IAAMG,EAAoB,CAAC,EAE3BF,EAAa,QAASG,GAAe,EAC7BnB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,IACxDD,EAAkB,KAAKC,CAAU,CAEzC,CAAC,EAEGD,EAAkB,OAAS,GAC3BR,EAAgB,CAAE,GAAGA,EAAe,GAAGI,CAAO,EAC9CH,EAAmB,KAAKI,CAAU,IAGlCH,EAAgBG,CAAU,EAAI,CAAC,EAE/BC,EAAa,QAASG,GAAe,CAEhCP,EAAgBG,CAAU,EAAiCI,CAAU,EAAInB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,CACtI,CAAC,EAET,CACJ,CAAC,EAED,IAAMC,EAAiB,CAAE,GAAGV,CAAc,ECzF1C,OAAS,OAAAX,MAAW,UAEpB,IAAMsB,EAAO,IAAG,GAEVC,EAAiBC,GAAoBxB,EAAI,QAAasB,EAAQG,GAAoB,QAAQ,IAAI,GAAGD,CAAM,GAAGC,CAAO,EAAE,EAEnHC,EAAaH,EAAc,EAAE,EAE5BI,EAAQD,EFFf,GAAI,CAAC,OAAO,kCAAmC,CACvC1B,EAAI,QACJ2B,EAAW;AAAA;AAAA,CAA+D,EAE1Ef,EAAmB,QAASgB,GAAe,CACvCD,EAAW,OAAOC,CAAU,EAAE,CAClC,CAAC,GAGL,IAAIC,EAAY,GAEhB,OAAO,QAAQhB,CAAe,EAAE,QAAQ,CAAC,CAACC,EAAQG,CAAY,IAAM,CACvC,OAAO,OAAOA,CAAY,EAAE,KAAK,OAAO,IAG7DY,EAAY,GACZF,EACI;AAAA,oDAAuDb,CAAM,yGACjE,EAEA,OAAO,QAAQG,CAAY,EAAE,QAAQ,CAAC,CAACG,EAAYU,CAAS,IAAM,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,iGAAiG,EAE5G,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
@@ -1,18 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkCCERQD4S_js = require('./chunk-CCERQD4S.js');
3
+ var chunkB7BKRXC3_js = require('./chunk-B7BKRXC3.js');
4
4
  var packageJsonUtils = require('@anolilab/package-json-utils');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
+ var process$1 = require('process');
7
8
  var util = require('util');
8
9
 
9
- process.env.CI&&process.exit(0);var a=util.promisify(fs.writeFile),$=util.promisify(fs.mkdir);console.log("Configuring @anolilab/lint-staged-config",packageJsonUtils.projectPath,`
10
- `);var e=".lintstagedrc",r=t=>fs.existsSync(t)?(console.warn(`\u26A0\uFE0F ${t} already exists;`),!0):!1,_=()=>{for(let s of [e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e}.yaml`,`${e}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(r(path.join(packageJsonUtils.projectPath,s)))return Promise.resolve();let t=path.join(packageJsonUtils.projectPath,".lintstagedrc.js");return a(t,`${packageJsonUtils.packageIsTypeModule?'import config from "@anolilab/lint-staged-config"':'const config = require("@anolilab/lint-staged-config")'};
10
+ process.env.CI&&process$1.exit(0);var a=util.promisify(fs.writeFile),_=util.promisify(fs.mkdir);console.log("Configuring @anolilab/lint-staged-config",packageJsonUtils.projectPath,`
11
+ `);var i=".lintstagedrc",c=t=>fs.existsSync(t)?(console.warn(`\u26A0\uFE0F ${t} already exists;`),!0):!1,I=async()=>{for(let s of [i,`${i}.js`,`${i}.cjs`,`${i}.mjs`,`${i}.json`,`${i}.yaml`,`${i}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(c(path.join(packageJsonUtils.projectPath,s)))return;let t=path.join(packageJsonUtils.projectPath,".lintstagedrc.js");await a(t,`${packageJsonUtils.packageIsTypeModule?'import config from "@anolilab/lint-staged-config"':'const config = require("@anolilab/lint-staged-config")'};
11
12
 
12
13
  ${packageJsonUtils.packageIsTypeModule?"export default":"module.exports ="} {
13
14
  ...config,
14
15
  };
15
- `,"utf-8")},I=async()=>{if(!(packageJsonUtils.hasDependency("husky")||packageJsonUtils.hasDevDependency("husky"))){console.warn("\u26A0\uFE0F husky is not installed;");return}let i=path.join(packageJsonUtils.projectPath,".husky");fs.existsSync(i)||await $(i);let s=path.join(i,"common.sh");r(s)||await a(s,`#!/bin/sh
16
+ `,"utf-8");},w=async()=>{if(!(packageJsonUtils.hasDependency("husky")||packageJsonUtils.hasDevDependency("husky"))){console.warn("\u26A0\uFE0F husky is not installed;");return}let o=path.join(packageJsonUtils.projectPath,".husky");fs.existsSync(o)||await _(o);let s=path.join(o,"common.sh");c(s)||await a(s,`#!/bin/sh
16
17
 
17
18
  command_exists () {
18
19
  command -v "$1" >/dev/null 2>&1
@@ -34,7 +35,7 @@ if [ "$IS_WINDOWS" = "true" ]; then
34
35
  exec < /dev/tty
35
36
  fi
36
37
  fi
37
- `,"utf-8");let m=path.join(i,"pre-commit"),o=!1;try{o=chunkCCERQD4S_js.a("pnpm-lock.yaml")!==void 0;}catch{}r(m)||await a(m,`#!/bin/sh
38
+ `,"utf-8");let h=path.join(o,"pre-commit"),e=!1;try{chunkB7BKRXC3_js.a("pnpm-lock.yaml"),e=!0;}catch{e=!1;}c(h)||await a(h,`#!/bin/sh
38
39
 
39
40
  . "$(dirname "$0")/_/husky.sh"
40
41
  . "$(dirname "$0")/common.sh"
@@ -45,11 +46,11 @@ fi
45
46
  echo --------------------------------------------
46
47
  echo Starting Git hook: pre-commit
47
48
 
48
- ${o?"pnpx":"npx"} lint-staged --verbose --concurrent false
49
+ ${e?"pnpx":"npx"} lint-staged --verbose --concurrent false
49
50
 
50
51
  echo Finished Git hook: pre-commit
51
52
  echo --------------------------------------------
52
- `,"utf-8");let h=path.join(i,"prepare-commit-msg");(packageJsonUtils.hasDependency("commitizen")||packageJsonUtils.hasDevDependency("commitizen"))&&!r(h)&&await a(h,`#!/bin/sh
53
+ `,"utf-8");let f=path.join(o,"prepare-commit-msg");(packageJsonUtils.hasDependency("commitizen")||packageJsonUtils.hasDevDependency("commitizen"))&&!c(f)&&await a(f,`#!/bin/sh
53
54
 
54
55
  . "$(dirname "$0")/_/husky.sh"
55
56
  . "$(dirname "$0")/common.sh"
@@ -57,14 +58,14 @@ echo --------------------------------------------
57
58
  echo --------------------------------------------
58
59
  echo Starting Git hook: prepare-commit-msg
59
60
 
60
- # if we hve a cmd that is running ${o?"pnpx":"npx"} cz that means finalize and commit
61
+ # if we hve a cmd that is running ${e?"pnpx":"npx"} cz that means finalize and commit
61
62
  FILE=commit.cmd
62
63
  if test -f "$FILE"; then
63
64
  echo "$FILE exists."
64
65
  rm commit.cmd
65
66
  exit 0;
66
67
  fi
67
- # if on Windows, spawn a cmd that will run ${o?"pnpx":"npx"} cz
68
+ # if on Windows, spawn a cmd that will run ${e?"pnpx":"npx"} cz
68
69
  case \`uname\` in
69
70
  *CYGWIN*|*MINGW*|*MSYS* )
70
71
  # Only run commitizen if no commit message was already provided.
@@ -72,7 +73,7 @@ case \`uname\` in
72
73
  export CZ_TYPE="\${CZ_TYPE:-fix}"
73
74
  export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
74
75
  export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
75
- echo "${o?"pnpx":"npx"} cz && exit" > commit.cmd
76
+ echo "${e?"pnpx":"npx"} cz && exit" > commit.cmd
76
77
  start commit.cmd
77
78
  exit 1;
78
79
  fi
@@ -86,11 +87,11 @@ if [ -z "\${2-}" ]; then
86
87
  export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
87
88
  export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
88
89
  # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.
89
- exec < /dev/tty && ${o?"pnpx":"npx"} cz --hook || true
90
+ exec < /dev/tty && ${e?"pnpx":"npx"} cz --hook || true
90
91
  fi
91
92
 
92
93
  echo Finished Git hook: prepare-commit-msg
93
94
  echo --------------------------------------------
94
- `,"utf-8");};(async()=>{try{await _(),await I(),console.log("\u{1F60E} Everything went well, have fun!"),process.exit(0);}catch(t){console.log("\u{1F62C} something went wrong:"),console.error(t),process.exit(1);}})();
95
+ `,"utf-8");};(async()=>{try{await I(),await w(),console.log("\u{1F60E} Everything went well, have fun!"),process$1.exit(0);}catch(t){console.log("\u{1F62C} something went wrong:"),console.error(t),process$1.exit(1);}})();
95
96
  //# sourceMappingURL=out.js.map
96
97
  //# sourceMappingURL=postinstall.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/postinstall.ts"],"names":["hasDependency","hasDevDependency","packageIsTypeModule","projectPath","existsSync","mkdir","writeFile","join","promisify","writeFileAsync","mkdirAsync","configFile","checkIfFileExists","filename","writeLintstagedRc","lintstagedPath","writeHuskyFiles","huskyFolderPath","commonShPath","preCommitPath","hasPnpm","get_nearest_config_path_default","prepareCommitMessagePath","error"],"mappings":"wCAAA,OACC,iBAAAA,EAAe,oBAAAC,EAAkB,uBAAAC,EAAqB,eAAAC,MAChD,+BACP,OAAS,cAAAC,EAAY,SAAAC,EAAO,aAAAC,MAAiB,KAC7C,OAAS,QAAAC,MAAY,OACrB,OAAS,aAAAC,MAAiB,OAItB,QAAQ,IAAI,IAEZ,QAAQ,KAAK,CAAC,EAGlB,IAAMC,EAAiBD,EAAUF,CAAS,EACpCI,EAAaF,EAAUH,CAAK,EAElC,QAAQ,IAAI,2CAA4CF,EAAa;AAAA,CAAI,EAEzE,IAAMQ,EAAa,gBAEbC,EAAqBC,GACnBT,EAAWS,CAAQ,GACnB,QAAQ,KAAK,iBAAOA,CAAQ,kBAAkB,EAEvC,IAGJ,GAMLC,EAAoB,IAAM,CAE5B,QAAWD,IAAY,CACnBF,EACA,GAAGA,CAAU,MACb,GAAGA,CAAU,OACb,GAAGA,CAAU,OACb,GAAGA,CAAU,QACb,GAAGA,CAAU,QACb,GAAGA,CAAU,OACb,wBACA,yBACA,wBACJ,EACI,GAAIC,EAAkBL,EAAKJ,EAAaU,CAAQ,CAAC,EAC7C,OAAO,QAAQ,QAAQ,EAI/B,IAAME,EAAiBR,EAAKJ,EAAa,kBAAkB,EAS3D,OAAOM,EAAeM,EAPN,GAAGb,EAAsB,oDAAsD,wDAAwD;AAAA;AAAA,EAEzJA,EAAsB,iBAAmB,kBAAkB;AAAA;AAAA;AAAA,EAKV,OAAO,CAC1D,EAMMc,EAAkB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AAA,EAMrC,OACJ,CAER,GAGC,SAAY,CACT,GAAI,CACA,MAAMN,EAAkB,EACxB,MAAME,EAAgB,EAEtB,QAAQ,IAAI,4CAAqC,EAGjD,QAAQ,KAAK,CAAC,CAClB,OAASO,EAAP,CACE,QAAQ,IAAI,kCAA2B,EACvC,QAAQ,MAAMA,CAAK,EAGnB,QAAQ,KAAK,CAAC,CAClB,CACJ,GAAG","sourcesContent":["import {\n hasDependency, hasDevDependency, packageIsTypeModule, projectPath\n} from \"@anolilab/package-json-utils\";\nimport { existsSync, mkdir, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nimport getNearestConfigPath from \"./utils/get-nearest-config-path\";\n\nif (process.env[\"CI\"]) {\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\nconst mkdirAsync = promisify(mkdir);\n\nconsole.log(\"Configuring @anolilab/lint-staged-config\", projectPath, \"\\n\");\n\nconst configFile = \".lintstagedrc\";\n\nconst checkIfFileExists = (filename: string): boolean => {\n if (existsSync(filename)) {\n console.warn(`⚠️ ${filename} already exists;`);\n\n return true;\n }\n\n return false;\n};\n\n/**\n * Writes .lintstagedrc.js if it doesn't exist. Warns if it exists.\n */\nconst writeLintstagedRc = () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [\n configFile,\n `${configFile}.js`,\n `${configFile}.cjs`,\n `${configFile}.mjs`,\n `${configFile}.json`,\n `${configFile}.yaml`,\n `${configFile}.yml`,\n \"lint-staged.config.js\",\n \"lint-staged.config.mjs\",\n \"lint-staged.config.cjs\",\n ]) {\n if (checkIfFileExists(join(projectPath, filename))) {\n return Promise.resolve();\n }\n }\n\n const lintstagedPath = join(projectPath, \".lintstagedrc.js\");\n\n const content = `${packageIsTypeModule ? 'import config from \"@anolilab/lint-staged-config\"' : 'const config = require(\"@anolilab/lint-staged-config\")'};\n\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n ...config,\n};\n`;\n\n return writeFileAsync(lintstagedPath, content, \"utf-8\");\n};\n\n/**\n * Adds husky hooks to .husky folder if they don't exist. Warns if they exist.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeHuskyFiles = async () => {\n const hasHusky = hasDependency(\"husky\") || hasDevDependency(\"husky\");\n\n if (!hasHusky) {\n console.warn(\"⚠️ husky is not installed;\");\n\n return;\n }\n\n const huskyFolderPath = join(projectPath, \".husky\");\n\n if (!existsSync(huskyFolderPath)) {\n await mkdirAsync(huskyFolderPath);\n }\n\n const commonShPath = join(huskyFolderPath, \"common.sh\");\n\n if (!checkIfFileExists(commonShPath)) {\n await writeFileAsync(\n commonShPath,\n `#!/bin/sh\n\ncommand_exists () {\n command -v \"$1\" >/dev/null 2>&1\n}\n\nIS_WINDOWS=\"false\"\n\nif [ \"$OSTYPE\" = \"cygwin\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"msys\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"win32\" ]; then\n IS_WINDOWS=\"true\"\nfi\n\n# Workaround for Windows 10, Git Bash and Yarn\nif [ \"$IS_WINDOWS\" = \"true\" ]; then\n if command_exists winpty && test -t 1; then\n exec < /dev/tty\n fi\nfi\n`,\n \"utf-8\",\n );\n }\n\n const preCommitPath = join(huskyFolderPath, \"pre-commit\");\n\n let hasPnpm = false;\n\n try {\n hasPnpm = getNearestConfigPath(\"pnpm-lock.yaml\") !== undefined;\n } catch {\n // ignore\n }\n\n if (!checkIfFileExists(preCommitPath)) {\n await writeFileAsync(\n preCommitPath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\n# The hook should exit with non-zero status after issuing\n# an appropriate message if it wants to stop the commit.\n\necho --------------------------------------------\necho Starting Git hook: pre-commit\n\n${hasPnpm ? \"pnpx\" : \"npx\"} lint-staged --verbose --concurrent false\n\necho Finished Git hook: pre-commit\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n\n const prepareCommitMessagePath = join(huskyFolderPath, \"prepare-commit-msg\");\n const hasCz = hasDependency(\"commitizen\") || hasDevDependency(\"commitizen\");\n\n if (hasCz && !checkIfFileExists(prepareCommitMessagePath)) {\n await writeFileAsync(\n prepareCommitMessagePath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\necho --------------------------------------------\necho Starting Git hook: prepare-commit-msg\n\n# if we hve a cmd that is running ${hasPnpm ? \"pnpx\" : \"npx\"} cz that means finalize and commit\nFILE=commit.cmd\nif test -f \"$FILE\"; then\n echo \"$FILE exists.\"\n rm commit.cmd\n exit 0;\nfi\n# if on Windows, spawn a cmd that will run ${hasPnpm ? \"pnpx\" : \"npx\"} cz\ncase \\`uname\\` in\n *CYGWIN*|*MINGW*|*MSYS* )\n # Only run commitizen if no commit message was already provided.\n if [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n echo \"${hasPnpm ? \"pnpx\" : \"npx\"} cz && exit\" > commit.cmd\n start commit.cmd\n exit 1;\n fi\n\n exit 0;;\nesac\n\n# Only run commitizen if no commit message was already provided.\nif [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.\n exec < /dev/tty && ${hasPnpm ? \"pnpx\" : \"npx\"} cz --hook || true\nfi\n\necho Finished Git hook: prepare-commit-msg\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n await writeLintstagedRc();\n await writeHuskyFiles();\n\n console.log(\"😎 Everything went well, have fun!\");\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n})();\n"]}
1
+ {"version":3,"sources":["../src/postinstall.ts"],"names":["hasDependency","hasDevDependency","packageIsTypeModule","projectPath","existsSync","mkdir","writeFile","join","exit","promisify","writeFileAsync","mkdirAsync","configFile","checkIfFileExists","filename","writeLintstagedRc","lintstagedPath","writeHuskyFiles","huskyFolderPath","commonShPath","preCommitPath","hasPnpm","get_nearest_config_path_default","prepareCommitMessagePath","error"],"mappings":"wCAAA,OAAS,iBAAAA,EAAe,oBAAAC,EAAkB,uBAAAC,EAAqB,eAAAC,MAAmB,+BAClF,OAAS,cAAAC,EAAY,SAAAC,EAAO,aAAAC,MAAiB,KAC7C,OAAS,QAAAC,MAAY,OACrB,OAAS,QAAAC,MAAY,UACrB,OAAS,aAAAC,MAAiB,OAItB,QAAQ,IAAI,IACZD,EAAK,CAAC,EAGV,IAAME,EAAiBD,EAAUH,CAAS,EACpCK,EAAaF,EAAUJ,CAAK,EAElC,QAAQ,IAAI,2CAA4CF,EAAa;AAAA,CAAI,EAEzE,IAAMS,EAAa,gBAEbC,EAAqBC,GAEnBV,EAAWU,CAAQ,GACnB,QAAQ,KAAK,iBAAOA,CAAQ,kBAAkB,EAEvC,IAGJ,GAMLC,EAAoB,SAAY,CAElC,QAAWD,IAAY,CACnBF,EACA,GAAGA,CAAU,MACb,GAAGA,CAAU,OACb,GAAGA,CAAU,OACb,GAAGA,CAAU,QACb,GAAGA,CAAU,QACb,GAAGA,CAAU,OACb,wBACA,yBACA,wBACJ,EACI,GAAIC,EAAkBN,EAAKJ,EAAaW,CAAQ,CAAC,EAC7C,OAIR,IAAME,EAAiBT,EAAKJ,EAAa,kBAAkB,EAS3D,MA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AAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAcnBA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrC,OACJ,CAER,GAGC,SAAY,CACT,GAAI,CACA,MAAMN,EAAkB,EACxB,MAAME,EAAgB,EAEtB,QAAQ,IAAI,4CAAqC,EAEjDT,EAAK,CAAC,CACV,OAASgB,EAAP,CACE,QAAQ,IAAI,kCAA2B,EACvC,QAAQ,MAAMA,CAAK,EAEnBhB,EAAK,CAAC,CACV,CACJ,GAAG","sourcesContent":["import { hasDependency, hasDevDependency, packageIsTypeModule, projectPath } from \"@anolilab/package-json-utils\";\nimport { existsSync, mkdir, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { exit } from \"node:process\";\nimport { promisify } from \"node:util\";\n\nimport getNearestConfigPath from \"./utils/get-nearest-config-path\";\n\nif (process.env[\"CI\"]) {\n exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\nconst mkdirAsync = promisify(mkdir);\n\nconsole.log(\"Configuring @anolilab/lint-staged-config\", projectPath, \"\\n\");\n\nconst configFile = \".lintstagedrc\";\n\nconst checkIfFileExists = (filename: string): boolean => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(filename)) {\n console.warn(`⚠️ ${filename} already exists;`);\n\n return true;\n }\n\n return false;\n};\n\n/**\n * Writes .lintstagedrc.js if it doesn't exist. Warns if it exists.\n */\nconst writeLintstagedRc = async () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [\n configFile,\n `${configFile}.js`,\n `${configFile}.cjs`,\n `${configFile}.mjs`,\n `${configFile}.json`,\n `${configFile}.yaml`,\n `${configFile}.yml`,\n \"lint-staged.config.js\",\n \"lint-staged.config.mjs\",\n \"lint-staged.config.cjs\",\n ]) {\n if (checkIfFileExists(join(projectPath, filename))) {\n return;\n }\n }\n\n const lintstagedPath = join(projectPath, \".lintstagedrc.js\");\n\n const content = `${packageIsTypeModule ? 'import config from \"@anolilab/lint-staged-config\"' : 'const config = require(\"@anolilab/lint-staged-config\")'};\n\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n ...config,\n};\n`;\n\n await writeFileAsync(lintstagedPath, content, \"utf-8\");\n};\n\n/**\n * Adds husky hooks to .husky folder if they don't exist. Warns if they exist.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeHuskyFiles = async () => {\n const hasHusky = hasDependency(\"husky\") || hasDevDependency(\"husky\");\n\n if (!hasHusky) {\n console.warn(\"⚠️ husky is not installed;\");\n\n return;\n }\n\n const huskyFolderPath = join(projectPath, \".husky\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(huskyFolderPath)) {\n await mkdirAsync(huskyFolderPath);\n }\n\n const commonShPath = join(huskyFolderPath, \"common.sh\");\n\n if (!checkIfFileExists(commonShPath)) {\n await writeFileAsync(\n commonShPath,\n `#!/bin/sh\n\ncommand_exists () {\n command -v \"$1\" >/dev/null 2>&1\n}\n\nIS_WINDOWS=\"false\"\n\nif [ \"$OSTYPE\" = \"cygwin\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"msys\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"win32\" ]; then\n IS_WINDOWS=\"true\"\nfi\n\n# Workaround for Windows 10, Git Bash and Yarn\nif [ \"$IS_WINDOWS\" = \"true\" ]; then\n if command_exists winpty && test -t 1; then\n exec < /dev/tty\n fi\nfi\n`,\n \"utf-8\",\n );\n }\n\n const preCommitPath = join(huskyFolderPath, \"pre-commit\");\n\n let hasPnpm = false;\n\n try {\n getNearestConfigPath(\"pnpm-lock.yaml\");\n\n hasPnpm = true;\n } catch {\n hasPnpm = false;\n\n // ignore\n }\n\n if (!checkIfFileExists(preCommitPath)) {\n await writeFileAsync(\n preCommitPath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\n# The hook should exit with non-zero status after issuing\n# an appropriate message if it wants to stop the commit.\n\necho --------------------------------------------\necho Starting Git hook: pre-commit\n\n${hasPnpm ? \"pnpx\" : \"npx\"} lint-staged --verbose --concurrent false\n\necho Finished Git hook: pre-commit\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n\n const prepareCommitMessagePath = join(huskyFolderPath, \"prepare-commit-msg\");\n const hasCz = hasDependency(\"commitizen\") || hasDevDependency(\"commitizen\");\n\n if (hasCz && !checkIfFileExists(prepareCommitMessagePath)) {\n await writeFileAsync(\n prepareCommitMessagePath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\necho --------------------------------------------\necho Starting Git hook: prepare-commit-msg\n\n# if we hve a cmd that is running ${hasPnpm ? \"pnpx\" : \"npx\"} cz that means finalize and commit\nFILE=commit.cmd\nif test -f \"$FILE\"; then\n echo \"$FILE exists.\"\n rm commit.cmd\n exit 0;\nfi\n# if on Windows, spawn a cmd that will run ${hasPnpm ? \"pnpx\" : \"npx\"} cz\ncase \\`uname\\` in\n *CYGWIN*|*MINGW*|*MSYS* )\n # Only run commitizen if no commit message was already provided.\n if [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n echo \"${hasPnpm ? \"pnpx\" : \"npx\"} cz && exit\" > commit.cmd\n start commit.cmd\n exit 1;\n fi\n\n exit 0;;\nesac\n\n# Only run commitizen if no commit message was already provided.\nif [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.\n exec < /dev/tty && ${hasPnpm ? \"pnpx\" : \"npx\"} cz --hook || true\nfi\n\necho Finished Git hook: prepare-commit-msg\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n await writeLintstagedRc();\n await writeHuskyFiles();\n\n console.log(\"😎 Everything went well, have fun!\");\n\n exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n exit(1);\n }\n})();\n"]}
@@ -1,16 +1,17 @@
1
- import { a as a$1 } from './chunk-YUER2OJU.mjs';
1
+ import { a as a$1 } from './chunk-WAVKF2WX.mjs';
2
2
  import { projectPath, packageIsTypeModule, hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
3
3
  import { writeFile, mkdir, existsSync } from 'fs';
4
4
  import { join } from 'path';
5
+ import { exit } from 'process';
5
6
  import { promisify } from 'util';
6
7
 
7
- process.env.CI&&process.exit(0);var a=promisify(writeFile),$=promisify(mkdir);console.log("Configuring @anolilab/lint-staged-config",projectPath,`
8
- `);var e=".lintstagedrc",r=t=>existsSync(t)?(console.warn(`\u26A0\uFE0F ${t} already exists;`),!0):!1,_=()=>{for(let s of [e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e}.yaml`,`${e}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(r(join(projectPath,s)))return Promise.resolve();let t=join(projectPath,".lintstagedrc.js");return a(t,`${packageIsTypeModule?'import config from "@anolilab/lint-staged-config"':'const config = require("@anolilab/lint-staged-config")'};
8
+ process.env.CI&&exit(0);var a=promisify(writeFile),_=promisify(mkdir);console.log("Configuring @anolilab/lint-staged-config",projectPath,`
9
+ `);var i=".lintstagedrc",c=t=>existsSync(t)?(console.warn(`\u26A0\uFE0F ${t} already exists;`),!0):!1,I=async()=>{for(let s of [i,`${i}.js`,`${i}.cjs`,`${i}.mjs`,`${i}.json`,`${i}.yaml`,`${i}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(c(join(projectPath,s)))return;let t=join(projectPath,".lintstagedrc.js");await a(t,`${packageIsTypeModule?'import config from "@anolilab/lint-staged-config"':'const config = require("@anolilab/lint-staged-config")'};
9
10
 
10
11
  ${packageIsTypeModule?"export default":"module.exports ="} {
11
12
  ...config,
12
13
  };
13
- `,"utf-8")},I=async()=>{if(!(hasDependency("husky")||hasDevDependency("husky"))){console.warn("\u26A0\uFE0F husky is not installed;");return}let i=join(projectPath,".husky");existsSync(i)||await $(i);let s=join(i,"common.sh");r(s)||await a(s,`#!/bin/sh
14
+ `,"utf-8");},w=async()=>{if(!(hasDependency("husky")||hasDevDependency("husky"))){console.warn("\u26A0\uFE0F husky is not installed;");return}let o=join(projectPath,".husky");existsSync(o)||await _(o);let s=join(o,"common.sh");c(s)||await a(s,`#!/bin/sh
14
15
 
15
16
  command_exists () {
16
17
  command -v "$1" >/dev/null 2>&1
@@ -32,7 +33,7 @@ if [ "$IS_WINDOWS" = "true" ]; then
32
33
  exec < /dev/tty
33
34
  fi
34
35
  fi
35
- `,"utf-8");let m=join(i,"pre-commit"),o=!1;try{o=a$1("pnpm-lock.yaml")!==void 0;}catch{}r(m)||await a(m,`#!/bin/sh
36
+ `,"utf-8");let h=join(o,"pre-commit"),e=!1;try{a$1("pnpm-lock.yaml"),e=!0;}catch{e=!1;}c(h)||await a(h,`#!/bin/sh
36
37
 
37
38
  . "$(dirname "$0")/_/husky.sh"
38
39
  . "$(dirname "$0")/common.sh"
@@ -43,11 +44,11 @@ fi
43
44
  echo --------------------------------------------
44
45
  echo Starting Git hook: pre-commit
45
46
 
46
- ${o?"pnpx":"npx"} lint-staged --verbose --concurrent false
47
+ ${e?"pnpx":"npx"} lint-staged --verbose --concurrent false
47
48
 
48
49
  echo Finished Git hook: pre-commit
49
50
  echo --------------------------------------------
50
- `,"utf-8");let h=join(i,"prepare-commit-msg");(hasDependency("commitizen")||hasDevDependency("commitizen"))&&!r(h)&&await a(h,`#!/bin/sh
51
+ `,"utf-8");let f=join(o,"prepare-commit-msg");(hasDependency("commitizen")||hasDevDependency("commitizen"))&&!c(f)&&await a(f,`#!/bin/sh
51
52
 
52
53
  . "$(dirname "$0")/_/husky.sh"
53
54
  . "$(dirname "$0")/common.sh"
@@ -55,14 +56,14 @@ echo --------------------------------------------
55
56
  echo --------------------------------------------
56
57
  echo Starting Git hook: prepare-commit-msg
57
58
 
58
- # if we hve a cmd that is running ${o?"pnpx":"npx"} cz that means finalize and commit
59
+ # if we hve a cmd that is running ${e?"pnpx":"npx"} cz that means finalize and commit
59
60
  FILE=commit.cmd
60
61
  if test -f "$FILE"; then
61
62
  echo "$FILE exists."
62
63
  rm commit.cmd
63
64
  exit 0;
64
65
  fi
65
- # if on Windows, spawn a cmd that will run ${o?"pnpx":"npx"} cz
66
+ # if on Windows, spawn a cmd that will run ${e?"pnpx":"npx"} cz
66
67
  case \`uname\` in
67
68
  *CYGWIN*|*MINGW*|*MSYS* )
68
69
  # Only run commitizen if no commit message was already provided.
@@ -70,7 +71,7 @@ case \`uname\` in
70
71
  export CZ_TYPE="\${CZ_TYPE:-fix}"
71
72
  export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
72
73
  export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
73
- echo "${o?"pnpx":"npx"} cz && exit" > commit.cmd
74
+ echo "${e?"pnpx":"npx"} cz && exit" > commit.cmd
74
75
  start commit.cmd
75
76
  exit 1;
76
77
  fi
@@ -84,11 +85,11 @@ if [ -z "\${2-}" ]; then
84
85
  export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
85
86
  export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
86
87
  # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.
87
- exec < /dev/tty && ${o?"pnpx":"npx"} cz --hook || true
88
+ exec < /dev/tty && ${e?"pnpx":"npx"} cz --hook || true
88
89
  fi
89
90
 
90
91
  echo Finished Git hook: prepare-commit-msg
91
92
  echo --------------------------------------------
92
- `,"utf-8");};(async()=>{try{await _(),await I(),console.log("\u{1F60E} Everything went well, have fun!"),process.exit(0);}catch(t){console.log("\u{1F62C} something went wrong:"),console.error(t),process.exit(1);}})();
93
+ `,"utf-8");};(async()=>{try{await I(),await w(),console.log("\u{1F60E} Everything went well, have fun!"),exit(0);}catch(t){console.log("\u{1F62C} something went wrong:"),console.error(t),exit(1);}})();
93
94
  //# sourceMappingURL=out.js.map
94
95
  //# sourceMappingURL=postinstall.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/postinstall.ts"],"names":["hasDependency","hasDevDependency","packageIsTypeModule","projectPath","existsSync","mkdir","writeFile","join","promisify","writeFileAsync","mkdirAsync","configFile","checkIfFileExists","filename","writeLintstagedRc","lintstagedPath","writeHuskyFiles","huskyFolderPath","commonShPath","preCommitPath","hasPnpm","get_nearest_config_path_default","prepareCommitMessagePath","error"],"mappings":"yCAAA,OACC,iBAAAA,EAAe,oBAAAC,EAAkB,uBAAAC,EAAqB,eAAAC,MAChD,+BACP,OAAS,cAAAC,EAAY,SAAAC,EAAO,aAAAC,MAAiB,KAC7C,OAAS,QAAAC,MAAY,OACrB,OAAS,aAAAC,MAAiB,OAItB,QAAQ,IAAI,IAEZ,QAAQ,KAAK,CAAC,EAGlB,IAAMC,EAAiBD,EAAUF,CAAS,EACpCI,EAAaF,EAAUH,CAAK,EAElC,QAAQ,IAAI,2CAA4CF,EAAa;AAAA,CAAI,EAEzE,IAAMQ,EAAa,gBAEbC,EAAqBC,GACnBT,EAAWS,CAAQ,GACnB,QAAQ,KAAK,iBAAOA,CAAQ,kBAAkB,EAEvC,IAGJ,GAMLC,EAAoB,IAAM,CAE5B,QAAWD,IAAY,CACnBF,EACA,GAAGA,CAAU,MACb,GAAGA,CAAU,OACb,GAAGA,CAAU,OACb,GAAG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AAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAQwBF,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAOfA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQjDA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAcnBA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrC,OACJ,CAER,GAGC,SAAY,CACT,GAAI,CACA,MAAMN,EAAkB,EACxB,MAAME,EAAgB,EAEtB,QAAQ,IAAI,4CAAqC,EAGjD,QAAQ,KAAK,CAAC,CAClB,OAASO,EAAP,CACE,QAAQ,IAAI,kCAA2B,EACvC,QAAQ,MAAMA,CAAK,EAGnB,QAAQ,KAAK,CAAC,CAClB,CACJ,GAAG","sourcesContent":["import {\n hasDependency, hasDevDependency, packageIsTypeModule, projectPath\n} from \"@anolilab/package-json-utils\";\nimport { existsSync, mkdir, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nimport getNearestConfigPath from \"./utils/get-nearest-config-path\";\n\nif (process.env[\"CI\"]) {\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\nconst mkdirAsync = promisify(mkdir);\n\nconsole.log(\"Configuring @anolilab/lint-staged-config\", projectPath, \"\\n\");\n\nconst configFile = \".lintstagedrc\";\n\nconst checkIfFileExists = (filename: string): boolean => {\n if (existsSync(filename)) {\n console.warn(`⚠️ ${filename} already exists;`);\n\n return true;\n }\n\n return false;\n};\n\n/**\n * Writes .lintstagedrc.js if it doesn't exist. Warns if it exists.\n */\nconst writeLintstagedRc = () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [\n configFile,\n `${configFile}.js`,\n `${configFile}.cjs`,\n `${configFile}.mjs`,\n `${configFile}.json`,\n `${configFile}.yaml`,\n `${configFile}.yml`,\n \"lint-staged.config.js\",\n \"lint-staged.config.mjs\",\n \"lint-staged.config.cjs\",\n ]) {\n if (checkIfFileExists(join(projectPath, filename))) {\n return Promise.resolve();\n }\n }\n\n const lintstagedPath = join(projectPath, \".lintstagedrc.js\");\n\n const content = `${packageIsTypeModule ? 'import config from \"@anolilab/lint-staged-config\"' : 'const config = require(\"@anolilab/lint-staged-config\")'};\n\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n ...config,\n};\n`;\n\n return writeFileAsync(lintstagedPath, content, \"utf-8\");\n};\n\n/**\n * Adds husky hooks to .husky folder if they don't exist. Warns if they exist.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeHuskyFiles = async () => {\n const hasHusky = hasDependency(\"husky\") || hasDevDependency(\"husky\");\n\n if (!hasHusky) {\n console.warn(\"⚠️ husky is not installed;\");\n\n return;\n }\n\n const huskyFolderPath = join(projectPath, \".husky\");\n\n if (!existsSync(huskyFolderPath)) {\n await mkdirAsync(huskyFolderPath);\n }\n\n const commonShPath = join(huskyFolderPath, \"common.sh\");\n\n if (!checkIfFileExists(commonShPath)) {\n await writeFileAsync(\n commonShPath,\n `#!/bin/sh\n\ncommand_exists () {\n command -v \"$1\" >/dev/null 2>&1\n}\n\nIS_WINDOWS=\"false\"\n\nif [ \"$OSTYPE\" = \"cygwin\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"msys\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"win32\" ]; then\n IS_WINDOWS=\"true\"\nfi\n\n# Workaround for Windows 10, Git Bash and Yarn\nif [ \"$IS_WINDOWS\" = \"true\" ]; then\n if command_exists winpty && test -t 1; then\n exec < /dev/tty\n fi\nfi\n`,\n \"utf-8\",\n );\n }\n\n const preCommitPath = join(huskyFolderPath, \"pre-commit\");\n\n let hasPnpm = false;\n\n try {\n hasPnpm = getNearestConfigPath(\"pnpm-lock.yaml\") !== undefined;\n } catch {\n // ignore\n }\n\n if (!checkIfFileExists(preCommitPath)) {\n await writeFileAsync(\n preCommitPath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\n# The hook should exit with non-zero status after issuing\n# an appropriate message if it wants to stop the commit.\n\necho --------------------------------------------\necho Starting Git hook: pre-commit\n\n${hasPnpm ? \"pnpx\" : \"npx\"} lint-staged --verbose --concurrent false\n\necho Finished Git hook: pre-commit\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n\n const prepareCommitMessagePath = join(huskyFolderPath, \"prepare-commit-msg\");\n const hasCz = hasDependency(\"commitizen\") || hasDevDependency(\"commitizen\");\n\n if (hasCz && !checkIfFileExists(prepareCommitMessagePath)) {\n await writeFileAsync(\n prepareCommitMessagePath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\necho --------------------------------------------\necho Starting Git hook: prepare-commit-msg\n\n# if we hve a cmd that is running ${hasPnpm ? \"pnpx\" : \"npx\"} cz that means finalize and commit\nFILE=commit.cmd\nif test -f \"$FILE\"; then\n echo \"$FILE exists.\"\n rm commit.cmd\n exit 0;\nfi\n# if on Windows, spawn a cmd that will run ${hasPnpm ? \"pnpx\" : \"npx\"} cz\ncase \\`uname\\` in\n *CYGWIN*|*MINGW*|*MSYS* )\n # Only run commitizen if no commit message was already provided.\n if [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n echo \"${hasPnpm ? \"pnpx\" : \"npx\"} cz && exit\" > commit.cmd\n start commit.cmd\n exit 1;\n fi\n\n exit 0;;\nesac\n\n# Only run commitizen if no commit message was already provided.\nif [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.\n exec < /dev/tty && ${hasPnpm ? \"pnpx\" : \"npx\"} cz --hook || true\nfi\n\necho Finished Git hook: prepare-commit-msg\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n await writeLintstagedRc();\n await writeHuskyFiles();\n\n console.log(\"😎 Everything went well, have fun!\");\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n // eslint-disable-next-line unicorn/no-process-exit\n process.exit(1);\n }\n})();\n"]}
1
+ {"version":3,"sources":["../src/postinstall.ts"],"names":["hasDependency","hasDevDependency","packageIsTypeModule","projectPath","existsSync","mkdir","writeFile","join","exit","promisify","writeFileAsync","mkdirAsync","configFile","checkIfFileExists","filename","writeLintstagedRc","lintstagedPath","writeHuskyFiles","huskyFolderPath","commonShPath","preCommitPath","hasPnpm","get_nearest_config_path_default","prepareCommitMessagePath","error"],"mappings":"yCAAA,OAAS,iBAAAA,EAAe,oBAAAC,EAAkB,uBAAAC,EAAqB,eAAAC,MAAmB,+BAClF,OAAS,cAAAC,EAAY,SAAAC,EAAO,aAAAC,MAAiB,KAC7C,OAAS,QAAAC,MAAY,OACrB,OAAS,QAAAC,MAAY,UACrB,OAAS,aAAAC,MAAiB,OAItB,QAAQ,IAAI,IACZD,EAAK,CAAC,EAGV,IAAME,EAAiBD,EAAUH,CAAS,EACpCK,EAAaF,EAAUJ,CAAK,EAElC,QAAQ,IAAI,2CAA4CF,EAAa;AAAA,CAAI,EAEzE,IAAMS,EAAa,gBAEbC,EAAqBC,GAEnBV,EAAWU,CAAQ,GAC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EAGJ,IAAME,EAA2BhB,EAAKW,EAAiB,oBAAoB,GAC7DlB,EAAc,YAAY,GAAKC,EAAiB,YAAY,IAE7D,CAACY,EAAkBU,CAAwB,GACpD,MAAMb,EACFa,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAQwBF,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6CAOfA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQjDA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAcnBA,EAAU,OAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrC,OACJ,CAER,GAGC,SAAY,CACT,GAAI,CACA,MAAMN,EAAkB,EACxB,MAAME,EAAgB,EAEtB,QAAQ,IAAI,4CAAqC,EAEjDT,EAAK,CAAC,CACV,OAASgB,EAAP,CACE,QAAQ,IAAI,kCAA2B,EACvC,QAAQ,MAAMA,CAAK,EAEnBhB,EAAK,CAAC,CACV,CACJ,GAAG","sourcesContent":["import { hasDependency, hasDevDependency, packageIsTypeModule, projectPath } from \"@anolilab/package-json-utils\";\nimport { existsSync, mkdir, writeFile } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { exit } from \"node:process\";\nimport { promisify } from \"node:util\";\n\nimport getNearestConfigPath from \"./utils/get-nearest-config-path\";\n\nif (process.env[\"CI\"]) {\n exit(0);\n}\n\nconst writeFileAsync = promisify(writeFile);\nconst mkdirAsync = promisify(mkdir);\n\nconsole.log(\"Configuring @anolilab/lint-staged-config\", projectPath, \"\\n\");\n\nconst configFile = \".lintstagedrc\";\n\nconst checkIfFileExists = (filename: string): boolean => {\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(filename)) {\n console.warn(`⚠️ ${filename} already exists;`);\n\n return true;\n }\n\n return false;\n};\n\n/**\n * Writes .lintstagedrc.js if it doesn't exist. Warns if it exists.\n */\nconst writeLintstagedRc = async () => {\n // eslint-disable-next-line no-restricted-syntax\n for (const filename of [\n configFile,\n `${configFile}.js`,\n `${configFile}.cjs`,\n `${configFile}.mjs`,\n `${configFile}.json`,\n `${configFile}.yaml`,\n `${configFile}.yml`,\n \"lint-staged.config.js\",\n \"lint-staged.config.mjs\",\n \"lint-staged.config.cjs\",\n ]) {\n if (checkIfFileExists(join(projectPath, filename))) {\n return;\n }\n }\n\n const lintstagedPath = join(projectPath, \".lintstagedrc.js\");\n\n const content = `${packageIsTypeModule ? 'import config from \"@anolilab/lint-staged-config\"' : 'const config = require(\"@anolilab/lint-staged-config\")'};\n\n${packageIsTypeModule ? \"export default\" : \"module.exports =\"} {\n ...config,\n};\n`;\n\n await writeFileAsync(lintstagedPath, content, \"utf-8\");\n};\n\n/**\n * Adds husky hooks to .husky folder if they don't exist. Warns if they exist.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst writeHuskyFiles = async () => {\n const hasHusky = hasDependency(\"husky\") || hasDevDependency(\"husky\");\n\n if (!hasHusky) {\n console.warn(\"⚠️ husky is not installed;\");\n\n return;\n }\n\n const huskyFolderPath = join(projectPath, \".husky\");\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (!existsSync(huskyFolderPath)) {\n await mkdirAsync(huskyFolderPath);\n }\n\n const commonShPath = join(huskyFolderPath, \"common.sh\");\n\n if (!checkIfFileExists(commonShPath)) {\n await writeFileAsync(\n commonShPath,\n `#!/bin/sh\n\ncommand_exists () {\n command -v \"$1\" >/dev/null 2>&1\n}\n\nIS_WINDOWS=\"false\"\n\nif [ \"$OSTYPE\" = \"cygwin\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"msys\" ]; then\n IS_WINDOWS=\"true\"\nelif [ \"$OSTYPE\" = \"win32\" ]; then\n IS_WINDOWS=\"true\"\nfi\n\n# Workaround for Windows 10, Git Bash and Yarn\nif [ \"$IS_WINDOWS\" = \"true\" ]; then\n if command_exists winpty && test -t 1; then\n exec < /dev/tty\n fi\nfi\n`,\n \"utf-8\",\n );\n }\n\n const preCommitPath = join(huskyFolderPath, \"pre-commit\");\n\n let hasPnpm = false;\n\n try {\n getNearestConfigPath(\"pnpm-lock.yaml\");\n\n hasPnpm = true;\n } catch {\n hasPnpm = false;\n\n // ignore\n }\n\n if (!checkIfFileExists(preCommitPath)) {\n await writeFileAsync(\n preCommitPath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\n# The hook should exit with non-zero status after issuing\n# an appropriate message if it wants to stop the commit.\n\necho --------------------------------------------\necho Starting Git hook: pre-commit\n\n${hasPnpm ? \"pnpx\" : \"npx\"} lint-staged --verbose --concurrent false\n\necho Finished Git hook: pre-commit\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n\n const prepareCommitMessagePath = join(huskyFolderPath, \"prepare-commit-msg\");\n const hasCz = hasDependency(\"commitizen\") || hasDevDependency(\"commitizen\");\n\n if (hasCz && !checkIfFileExists(prepareCommitMessagePath)) {\n await writeFileAsync(\n prepareCommitMessagePath,\n `#!/bin/sh\n\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\necho --------------------------------------------\necho Starting Git hook: prepare-commit-msg\n\n# if we hve a cmd that is running ${hasPnpm ? \"pnpx\" : \"npx\"} cz that means finalize and commit\nFILE=commit.cmd\nif test -f \"$FILE\"; then\n echo \"$FILE exists.\"\n rm commit.cmd\n exit 0;\nfi\n# if on Windows, spawn a cmd that will run ${hasPnpm ? \"pnpx\" : \"npx\"} cz\ncase \\`uname\\` in\n *CYGWIN*|*MINGW*|*MSYS* )\n # Only run commitizen if no commit message was already provided.\n if [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n echo \"${hasPnpm ? \"pnpx\" : \"npx\"} cz && exit\" > commit.cmd\n start commit.cmd\n exit 1;\n fi\n\n exit 0;;\nesac\n\n# Only run commitizen if no commit message was already provided.\nif [ -z \"\\${2-}\" ]; then\n export CZ_TYPE=\"\\${CZ_TYPE:-fix}\"\n export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH\n export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH\n # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.\n exec < /dev/tty && ${hasPnpm ? \"pnpx\" : \"npx\"} cz --hook || true\nfi\n\necho Finished Git hook: prepare-commit-msg\necho --------------------------------------------\n`,\n \"utf-8\",\n );\n }\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\n(async () => {\n try {\n await writeLintstagedRc();\n await writeHuskyFiles();\n\n console.log(\"😎 Everything went well, have fun!\");\n\n exit(0);\n } catch (error) {\n console.log(\"😬 something went wrong:\");\n console.error(error);\n\n exit(1);\n }\n})();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/lint-staged-config",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Shareable Lint-Staged Config for any project.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -93,17 +93,17 @@
93
93
  "test:coverage": "vitest --config ./vitest.config.ts --run --coverage"
94
94
  },
95
95
  "dependencies": {
96
- "@anolilab/package-json-utils": "1.5.2",
96
+ "@anolilab/package-json-utils": "2.0.1",
97
97
  "cross-env": "^7.0.3",
98
98
  "find-up": "5.0.0",
99
99
  "shell-quote": "^1.8.1"
100
100
  },
101
101
  "devDependencies": {
102
- "@anolilab/semantic-release-preset": "4.0.4",
102
+ "@anolilab/semantic-release-preset": "5.0.1",
103
103
  "@total-typescript/ts-reset": "^0.4.2",
104
104
  "@types/lint-staged": "^13.2.0",
105
105
  "@types/shell-quote": "^1.7.1",
106
- "@vitest/coverage-v8": "^0.32.2",
106
+ "@vitest/coverage-v8": "^0.32.4",
107
107
  "husky": "^8.0.3",
108
108
  "lint-staged": "^13.2.3",
109
109
  "rimraf": "^5.0.1",
@@ -111,17 +111,17 @@
111
111
  "tsup": "^7.1.0",
112
112
  "type-fest": "^3.12.0",
113
113
  "typescript": "5.1.6",
114
- "vitest": "^0.32.2"
114
+ "vitest": "^0.32.4"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "husky": "^8.x",
118
118
  "lint-staged": "^13.x"
119
119
  },
120
120
  "optionalDependencies": {
121
- "eslint": "^8.43.0",
121
+ "eslint": "^8.44.0",
122
122
  "jest": "^29.5.0",
123
123
  "prettier": "^2.8.8",
124
- "secretlint": "^6.2.3",
124
+ "secretlint": "^7.0.2",
125
125
  "stylelint": "^15.9.0",
126
126
  "vite": "^4.3.9"
127
127
  },
@@ -1,12 +0,0 @@
1
- import { a } from './chunk-YUER2OJU.mjs';
2
- import { b, a as a$1 } from './chunk-MKZ4RRUB.mjs';
3
- import { pkg, hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
4
- import { dirname } from 'path';
5
- import { ESLint } from 'eslint';
6
- import { quote } from 'shell-quote';
7
-
8
- !global.anolilabLintStagedPackageJsonConfig&&pkg&&(global.anolilabLintStagedPackageJsonConfig=pkg?.anolilab?.["lint-staged-config"]);var $=global.anolilabLintStagedPackageJsonConfig??{},u=$;var k=n=>{let t={};return n.forEach(s=>{let i=dirname(s);t[i]||(t[i]=[]),t[i].push(s);}),t},p=k;var F=async n=>{let t=new ESLint,s=await Promise.all(n.map(o=>t.isPathIgnored(o)));return n.filter((o,a)=>!s[a]).map(o=>`"${a$1?o:quote([o])}"`)},h=F;var e=u?.settings?.eslint??{},y=["react-hooks/exhaustive-deps: off"],r=".eslintrc",A=()=>{let n=[];e?.["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?n.push(`--max-warnings=${e["max-warnings"]}`):e?.["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[];e?.rules!==void 0&&Array.isArray(e.rules)?t.push([...e.rules,...y].filter(i=>i.trim().length>0).map(i=>`"${i.trim()}"`)):t.push(y.map(i=>`"${i.trim()}"`)),t.length>0&&n.push(`--rule ${t.join(" --rule ")}`);let s=[...e?.["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),e?.cache&&n.push("--cache"),n},E=async n=>{let t=await h(n),s=A();if(e?.config)return s.push(`--config ${e.config}`),[`cross-env NO_LOGS=true eslint ${s.join(" ")} ${t.join(" ")}`];let i=p(t),o=[];return Object.values(i).forEach(a$1=>{let l;[r,`${r}.js`,`${r}.cjs`,`${r}.json`,`${r}.yaml`,`${r}.yml`].forEach(S=>{if(!l)try{l=a(S,a$1[0]);}catch{}}),l&&o.push(`cross-env NO_LOGS=true eslint ${s.join(" ")} --config ${l} ${a$1.join(" ")}`);}),o},g=E;var x=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=hasDependency("markdownlint-cli")||hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=hasDependency("markdownlint-cli2")||hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&x.push("md");var N={[`*.{${[x].join(",")}}`]:async n=>[`prettier --write ${b(n)}`,...await g(n)],[`*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await g(n)]},K=N;
9
-
10
- export { u as a, K as b };
11
- //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-5IWFJALT.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"yFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,GAAM,WAAc,oBAAoB,GAGzF,IAAMC,EAAiD,OAAO,qCAAuC,CAAC,EAE/FC,EAAQD,ECTf,OAAS,WAAAE,MAAe,OAExB,IAAMC,EAAiCC,GAAqD,CACxF,IAAMC,EAAsC,CAAC,EAE7C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,CAAQ,EAEjCD,EAAOE,CAAa,IACrBF,EAAOE,CAAa,EAAI,CAAC,GAG5BF,EAAOE,CAAa,EAAe,KAAKD,CAAQ,CACrD,CAAC,EAEMD,CACX,EAEOG,EAAQL,ECjBf,OAAS,UAAAM,MAAc,SACvB,OAAS,SAAAC,MAAa,cAItB,IAAMC,EAAqB,MAAOC,GAA2C,CACzE,IAAMC,EAAS,IAAIJ,EAEbK,EAAe,MAAM,QAAQ,IAAIF,EAAU,IAAKG,GAAaF,EAAO,cAAcE,CAAQ,CAAC,CAAC,EAGlG,OAFsBH,EAAU,OAAO,CAACI,EAAGC,IAAU,CAACH,EAAaG,CAAK,CAAC,EAEpD,IAAKF,GAAa,IAAIG,EAAYH,EAAWL,EAAM,CAACK,CAAQ,CAA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B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n [`*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n};\n\nexport default group;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg?.[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: { [key: string]: boolean | undefined } = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): { [key: string]: string[] } => {\n const groups: { [key: string]: string[] } = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n if (!groups[directoryName]) {\n groups[directoryName] = [];\n }\n\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const ignoredFiles = await Promise.all(filenames.map((filename) => eslint.isPathIgnored(filename)));\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ntype ESLintSettings = {\n settings: {\n eslint?: {\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n \"fix-type\": string[];\n cache?: boolean;\n config?: string;\n };\n };\n};\n\nconst eslintSettings: ESLintSettings[\"settings\"][\"eslint\"] = (anolilabLintStagedConfig as unknown as ESLintSettings)?.[\"settings\"]?.[\"eslint\"] ?? ({} as ESLintSettings[\"settings\"][\"eslint\"]);\n\nconst eslintGlobalRulesForFix = [\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n \"react-hooks/exhaustive-deps: off\",\n];\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings?.[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings?.[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [];\n\n if (eslintSettings?.[\"rules\"] !== undefined && Array.isArray(eslintSettings[\"rules\"])) {\n rules.push([...eslintSettings[\"rules\"], ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings?.[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings?.[\"cache\"]) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings?.[\"config\"]) {\n eslintArguments.push(`--config ${eslintSettings[\"config\"]}`);\n\n return [`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\");\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -1,8 +0,0 @@
1
- import { b } from './chunk-MKZ4RRUB.mjs';
2
- import { hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
3
-
4
- var n=hasDependency("vitest")||hasDevDependency("vitest"),i=hasDependency("jest")||hasDevDependency("jest"),j=hasDependency("ava")||hasDevDependency("ava"),d={...n&&{"**/__tests__/**/*.?(c|m)[jt]s?(x)":["vitest related --run"],"**/?(*.){test,spec}.?(c|m)[jt]s?(x)":["vitest related --run"]},...i&&{"**/*.spec.{js,ts,tsx}":["jest --findRelatedTests"],"**/*.test.{js,ts,tsx}":["jest --findRelatedTests"],"**/test/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__mocks__/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__tests__/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__tests__/**/*.?(c|m)[jt]s?(x)":["jest --findRelatedTests"],"**/?(*.){test,spec}.?(c|m)[jt]s?(x)":["jest --findRelatedTests"]},...j&&{"**/test.js":t=>[`ava ${b(t)}`],"**/test-*.js":t=>[`ava ${b(t)}`],"**/*.(spec|test).js":t=>[`ava ${b(t)}`],"**/(test|tests|__tests__)/**/*.js":t=>[`ava ${b(t)}`]}},o=d;
5
-
6
- export { o as a };
7
- //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-BVGKAMQV.mjs.map
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkHAERDTLI_js = require('./chunk-HAERDTLI.js');
4
-
5
- var i={[`*.{${["css","sass","scss","less"].join(",")}}`]:t=>[`prettier --ignore-unknown --write ${chunkHAERDTLI_js.b(t)}`,"stylelint --fix"]},n=i;
6
-
7
- exports.a = n;
8
- //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-GXZBYQVF.js.map
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- var shellQuote = require('shell-quote');
4
- var process$1 = require('process');
5
-
6
- var i=process&&(process.platform==="win32"||/^(msys|cygwin)$/.test(process$1.env.OSTYPE??"")),s=i;var p=t=>t.map(o=>`"${s?o:shellQuote.quote([o])}"`).join(" "),a=p;
7
-
8
- exports.a = s;
9
- exports.b = a;
10
- //# sourceMappingURL=out.js.map
11
- //# sourceMappingURL=chunk-HAERDTLI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/concat-files.ts","../src/utils/is-windows.ts"],"names":["quote","env","isWindows","is_windows_default","concatFiles","filenames","filename","concat_files_default"],"mappings":"AAAA,OAAS,SAAAA,MAAa,cCAtB,OAAS,OAAAC,MAAW,UAGpB,IAAMC,EAAY,UAAY,QAAQ,WAAa,SAAW,kBAAkB,KAAKD,EAAI,QAAa,EAAE,GAEjGE,EAAQD,EDUf,IAAME,EAAeC,GAAgCA,EAAU,IAAKC,GAAa,IAAIH,EAAYG,EAAWN,EAAM,CAACM,CAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,EAEnIC,EAAQH","sourcesContent":["import { quote } from \"shell-quote\";\n\nimport isWindows from \"./is-windows\";\n\n/**\n * Concatenate and escape a list of filenames that can be passed as args to prettier cli\n *\n * Prettier and Stylelint have an issue with special characters in filenames,\n * such as the ones uses for Next.js dynamic routes (ie: [id].tsx...)\n *\n * @link https://github.com/okonet/lint-staged/issues/676\n *\n * @param {string[]} filenames\n * @returns {string} Return concatenated and escaped filenames\n */\nconst concatFiles = (filenames: string[]): string => filenames.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`).join(\" \");\n\nexport default concatFiles;\n","import { env } from \"node:process\";\n\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isWindows = process && (process.platform === \"win32\" || /^(msys|cygwin)$/.test(env[\"OSTYPE\"] ?? \"\"));\n\nexport default isWindows;\n"]}
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkHAERDTLI_js = require('./chunk-HAERDTLI.js');
4
- var packageJsonUtils = require('@anolilab/package-json-utils');
5
-
6
- var n=packageJsonUtils.hasDependency("vitest")||packageJsonUtils.hasDevDependency("vitest"),i=packageJsonUtils.hasDependency("jest")||packageJsonUtils.hasDevDependency("jest"),j=packageJsonUtils.hasDependency("ava")||packageJsonUtils.hasDevDependency("ava"),d={...n&&{"**/__tests__/**/*.?(c|m)[jt]s?(x)":["vitest related --run"],"**/?(*.){test,spec}.?(c|m)[jt]s?(x)":["vitest related --run"]},...i&&{"**/*.spec.{js,ts,tsx}":["jest --findRelatedTests"],"**/*.test.{js,ts,tsx}":["jest --findRelatedTests"],"**/test/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__mocks__/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__tests__/*.{js,ts,tsx}":["jest --findRelatedTests"],"**/__tests__/**/*.?(c|m)[jt]s?(x)":["jest --findRelatedTests"],"**/?(*.){test,spec}.?(c|m)[jt]s?(x)":["jest --findRelatedTests"]},...j&&{"**/test.js":t=>[`ava ${chunkHAERDTLI_js.b(t)}`],"**/test-*.js":t=>[`ava ${chunkHAERDTLI_js.b(t)}`],"**/*.(spec|test).js":t=>[`ava ${chunkHAERDTLI_js.b(t)}`],"**/(test|tests|__tests__)/**/*.js":t=>[`ava ${chunkHAERDTLI_js.b(t)}`]}},o=d;
7
-
8
- exports.a = o;
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-MCOYFEKC.js.map
@@ -1,8 +0,0 @@
1
- import { quote } from 'shell-quote';
2
- import { env } from 'process';
3
-
4
- var i=process&&(process.platform==="win32"||/^(msys|cygwin)$/.test(env.OSTYPE??"")),s=i;var p=t=>t.map(o=>`"${s?o:quote([o])}"`).join(" "),a=p;
5
-
6
- export { s as a, a as b };
7
- //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-MKZ4RRUB.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/concat-files.ts","../src/utils/is-windows.ts"],"names":["quote","env","isWindows","is_windows_default","concatFiles","filenames","filename","concat_files_default"],"mappings":"AAAA,OAAS,SAAAA,MAAa,cCAtB,OAAS,OAAAC,MAAW,UAGpB,IAAMC,EAAY,UAAY,QAAQ,WAAa,SAAW,kBAAkB,KAAKD,EAAI,QAAa,EAAE,GAEjGE,EAAQD,EDUf,IAAME,EAAeC,GAAgCA,EAAU,IAAKC,GAAa,IAAIH,EAAYG,EAAWN,EAAM,CAACM,CAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,EAEnIC,EAAQH","sourcesContent":["import { quote } from \"shell-quote\";\n\nimport isWindows from \"./is-windows\";\n\n/**\n * Concatenate and escape a list of filenames that can be passed as args to prettier cli\n *\n * Prettier and Stylelint have an issue with special characters in filenames,\n * such as the ones uses for Next.js dynamic routes (ie: [id].tsx...)\n *\n * @link https://github.com/okonet/lint-staged/issues/676\n *\n * @param {string[]} filenames\n * @returns {string} Return concatenated and escaped filenames\n */\nconst concatFiles = (filenames: string[]): string => filenames.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`).join(\" \");\n\nexport default concatFiles;\n","import { env } from \"node:process\";\n\n// eslint-disable-next-line regexp/no-unused-capturing-group\nconst isWindows = process && (process.platform === \"win32\" || /^(msys|cygwin)$/.test(env[\"OSTYPE\"] ?? \"\"));\n\nexport default isWindows;\n"]}