@adbayb/stack 0.0.0-next-389cf5e → 0.0.0-next-f1ca685

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +39 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -145,6 +145,25 @@ const turbo = async (command, options = {})=>{
145
145
  throw createError("turbo", error);
146
146
  }
147
147
  };
148
+ const logCheckableFiles = (files)=>{
149
+ if (files.length === 0) {
150
+ helpers.message("The whole project will be checked.", {
151
+ label: false,
152
+ lineBreak: {
153
+ end: true,
154
+ start: false
155
+ }
156
+ });
157
+ return;
158
+ }
159
+ helpers.message(files.join("\n "), {
160
+ label: "Following files will be checked:",
161
+ lineBreak: {
162
+ end: true,
163
+ start: false
164
+ }
165
+ });
166
+ };
148
167
  const changeset = async (command)=>{
149
168
  try {
150
169
  return await helpers.exec(command, {
@@ -167,7 +186,7 @@ const ESLINT_EXTENSIONS = [
167
186
  "mdx"
168
187
  ];
169
188
 
170
- var version = "0.0.0-next-389cf5e";
189
+ var version = "0.0.0-next-f1ca685";
171
190
 
172
191
  const createWatchCommand = (program)=>{
173
192
  program.command({
@@ -249,7 +268,9 @@ const createInstallCommand = (program)=>{
249
268
  }).task({
250
269
  label: label$4("Install `git.pre-commit` hook"),
251
270
  async handler () {
252
- await installGitHook("pre-commit", `${getStackCommand("fix $(git status --porcelain | awk 'BEGIN{ ORS=\" \" } { print $2 }')", false)} && git add -A`);
271
+ const lineBreakMatcher = String.raw`\n|\r\n`;
272
+ const modifiedFilesCommand = `node -e 'console.log(require("child_process").execSync("git status --porcelain", {encoding: "utf8"}).split(/${lineBreakMatcher}/).filter(Boolean).map(item => item.split(" ").at(-1)).join(" "))'`;
273
+ await installGitHook("pre-commit", `${getStackCommand(`fix $(${modifiedFilesCommand})`, false)} && git add -A`);
253
274
  }
254
275
  }).task({
255
276
  label: label$4("Install `git.commit-msg` hook"),
@@ -302,6 +323,10 @@ const createFixCommand = (program)=>{
302
323
  program.command({
303
324
  name: "fix",
304
325
  description: "Fix auto-fixable issues"
326
+ }).task({
327
+ handler (_, argv) {
328
+ logCheckableFiles(argv.operands);
329
+ }
305
330
  }).task({
306
331
  label: label$3("Prepare the project"),
307
332
  async handler () {
@@ -521,6 +546,10 @@ const createCleanCommand = (program)=>{
521
546
  handler ({ files }) {
522
547
  helpers.message(files.join("\n "), {
523
548
  label: "Removed assets",
549
+ lineBreak: {
550
+ end: false,
551
+ start: true
552
+ },
524
553
  type: "information"
525
554
  });
526
555
  },
@@ -636,7 +665,7 @@ const createPackagesVersionMismatchChecker = ()=>{
636
665
  }
637
666
  const isSameMonorepoVersion = depVersion === storedVersion;
638
667
  if (!isSameMonorepoVersion) {
639
- throw createPackageError(`Mismatched versions: received version \`${depVersion}\` while others use \`${storedVersion}\`. To prevent issues with singleton-like code (React contexts, …), please make sure to update all packages to use the same \`${dependencyName}\` version (either \`${storedVersion}\` or \`${depVersion}\`.`, {
668
+ throw createPackageError(`Mismatched versions: received version \`${depVersion}\` while others use \`${storedVersion}\`. To prevent issues with singleton-like code (React contexts, …), please make sure to update all packages to use the same \`${dependencyName}\` version (either \`${storedVersion}\` or \`${depVersion}\`).`, {
640
669
  name: dependencyName,
641
670
  consumedBy: packageName
642
671
  });
@@ -649,7 +678,7 @@ const createPackagesVersionMismatchChecker = ()=>{
649
678
  };
650
679
  };
651
680
  const createPackageError = (message, context)=>{
652
- return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to \`package.json\` guidelines.\n${message}`);
681
+ return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to package guidelines.\n${message}`);
653
682
  };
654
683
  function assertVersion(version, { name, consumedBy }) {
655
684
  assert(version, ()=>createPackageError(`\`${name}\` must have a valid version specified (current version equals to \`${String(version)}\`).`, {
@@ -687,6 +716,11 @@ const createCheckCommand = (program)=>{
687
716
  name: "only",
688
717
  description: `Run only one specified task (accepted value: ${ONLY_VALUES.join(", ")})`,
689
718
  defaultValue: undefined
719
+ }).task({
720
+ handler (_, argv) {
721
+ logCheckableFiles(argv.operands);
722
+ },
723
+ skip: ifOnlyDefinedAndNotEqualTo("linter")
690
724
  }).task({
691
725
  label: label("Prepare the project"),
692
726
  async handler () {
@@ -696,7 +730,7 @@ const createCheckCommand = (program)=>{
696
730
  });
697
731
  },
698
732
  skip ({ only }) {
699
- return only === "commit"; // No need to build if only commitlint is run
733
+ return only === "commit"; // No need to build if only commit is checked
700
734
  }
701
735
  }).task({
702
736
  label: label("Check package guidelines"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adbayb/stack",
3
- "version": "0.0.0-next-389cf5e",
3
+ "version": "0.0.0-next-f1ca685",
4
4
  "description": "My opinionated JavaScript-based toolchain",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -74,7 +74,7 @@
74
74
  "fdir": "^6.4.2",
75
75
  "globals": "^15.12.0",
76
76
  "prettier": "^3.3.3",
77
- "termost": "^1.2.0",
77
+ "termost": "^1.4.0",
78
78
  "turbo": "^2.3.0",
79
79
  "typescript-eslint": "^8.14.0",
80
80
  "typescript": "^5.6.3"